UNPKG

@ledgerhq/live-common

Version:
127 lines 4.11 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("getWalletAPITransactionSignFlowInfos", () => { describe("should properly get infos for DOT platform tx", () => { it("with most basic tx", () => { const dotPlatformTx = { family: "polkadot", amount: new bignumber_js_1.default(100000), recipient: "0xABCDEF", mode: "send", }; const { canEditFees, hasFeesProvided, liveTx } = walletApiAdapter_1.default.getWalletAPITransactionSignFlowInfos({ walletApiTransaction: dotPlatformTx, account: {}, }); expect(canEditFees).toBe(true); expect(hasFeesProvided).toBe(false); expect(liveTx).toMatchInlineSnapshot(` { "amount": "100000", "era": null, "family": "polkadot", "fees": null, "mode": "send", "numSlashingSpans": 0, "recipient": "0xABCDEF", "rewardDestination": null, "useAllAmount": false, "validators": [], } `); }); it("with era provided", () => { const dotPlatformTx = { family: "polkadot", amount: new bignumber_js_1.default(100000), recipient: "0xABCDEF", mode: "send", era: 1, }; const { canEditFees, hasFeesProvided, liveTx } = walletApiAdapter_1.default.getWalletAPITransactionSignFlowInfos({ walletApiTransaction: dotPlatformTx, account: {}, }); expect(canEditFees).toBe(true); expect(hasFeesProvided).toBe(false); expect(liveTx).toMatchInlineSnapshot(` { "amount": "100000", "era": "1", "family": "polkadot", "fees": null, "mode": "send", "numSlashingSpans": 0, "recipient": "0xABCDEF", "rewardDestination": null, "useAllAmount": false, "validators": [], } `); }); it("with mode provided", () => { const dotPlatformTx = { family: "polkadot", amount: new bignumber_js_1.default(100000), recipient: "0xABCDEF", mode: "bond", }; const { canEditFees, hasFeesProvided, liveTx } = walletApiAdapter_1.default.getWalletAPITransactionSignFlowInfos({ walletApiTransaction: dotPlatformTx, account: {}, }); expect(canEditFees).toBe(true); expect(hasFeesProvided).toBe(false); expect(liveTx).toMatchInlineSnapshot(` { "amount": "100000", "era": null, "family": "polkadot", "fees": null, "mode": "bond", "numSlashingSpans": 0, "recipient": "0xABCDEF", "rewardDestination": null, "useAllAmount": false, "validators": [], } `); }); it("with fees provided", () => { const dotPlatformTx = { family: "polkadot", amount: new bignumber_js_1.default(100000), recipient: "0xABCDEF", mode: "send", fee: new bignumber_js_1.default(300), }; const { canEditFees, hasFeesProvided, liveTx } = walletApiAdapter_1.default.getWalletAPITransactionSignFlowInfos({ walletApiTransaction: dotPlatformTx, account: {}, }); expect(canEditFees).toBe(true); expect(hasFeesProvided).toBe(true); expect(liveTx).toMatchInlineSnapshot(` { "amount": "100000", "era": null, "family": "polkadot", "fees": "300", "feesStrategy": null, "mode": "send", "numSlashingSpans": 0, "recipient": "0xABCDEF", "rewardDestination": null, "useAllAmount": false, "validators": [], } `); }); }); }); //# sourceMappingURL=walletApiAdapter.test.js.map