UNPKG

@ledgerhq/live-common

Version:
117 lines 3.47 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const bignumber_js_1 = __importDefault(require("bignumber.js")); const walletApiAdapter_1 = __importDefault(require("./walletApiAdapter")); describe("getPlatformTransactionSignFlowInfos", () => { describe("should properly get infos for BTC platform tx", () => { test("without fees provided", () => { const btcPlatformTx = { family: "bitcoin", amount: new bignumber_js_1.default(100000), recipient: "0xABCDEF", }; const { canEditFees, hasFeesProvided, liveTx } = walletApiAdapter_1.default.getWalletAPITransactionSignFlowInfos({ walletApiTransaction: btcPlatformTx, account: {}, }); expect(canEditFees).toBe(true); expect(hasFeesProvided).toBe(false); expect(liveTx).toMatchInlineSnapshot(` { "amount": "100000", "family": "bitcoin", "feePerByte": null, "feesStrategy": "medium", "networkInfo": null, "rbf": false, "recipient": "0xABCDEF", "useAllAmount": false, "utxoStrategy": { "excludeUTXOs": [], "strategy": 0, }, } `); }); test("with fees provided", () => { const btcPlatformTx = { family: "bitcoin", amount: new bignumber_js_1.default(100000), recipient: "0xABCDEF", feePerByte: new bignumber_js_1.default(300), }; const { canEditFees, hasFeesProvided, liveTx } = walletApiAdapter_1.default.getWalletAPITransactionSignFlowInfos({ walletApiTransaction: btcPlatformTx, account: {}, }); expect(canEditFees).toBe(true); expect(hasFeesProvided).toBe(true); expect(liveTx).toMatchInlineSnapshot(` { "amount": "100000", "family": "bitcoin", "feePerByte": "300", "feesStrategy": null, "networkInfo": null, "rbf": false, "recipient": "0xABCDEF", "useAllAmount": false, "utxoStrategy": { "excludeUTXOs": [], "strategy": 0, }, } `); }); test("with opReturnData provided", () => { const btcPlatformTx = { family: "bitcoin", amount: new bignumber_js_1.default(100000), recipient: "0xABCDEF", opReturnData: Buffer.from("hello world"), }; const { canEditFees, hasFeesProvided, liveTx } = walletApiAdapter_1.default.getWalletAPITransactionSignFlowInfos({ walletApiTransaction: btcPlatformTx, account: {}, }); expect(canEditFees).toBe(true); expect(hasFeesProvided).toBe(false); expect(liveTx).toMatchInlineSnapshot(` { "amount": "100000", "family": "bitcoin", "feePerByte": null, "feesStrategy": "medium", "networkInfo": null, "opReturnData": { "data": [ 104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, ], "type": "Buffer", }, "rbf": false, "recipient": "0xABCDEF", "useAllAmount": false, "utxoStrategy": { "excludeUTXOs": [], "strategy": 0, }, } `); }); }); }); //# sourceMappingURL=walletApiAdapter.test.js.map