UNPKG

@ledgerhq/live-common

Version:
59 lines 2.49 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 Solana TX", () => { it("simple transfer", () => { const solanaTx = { family: "solana", amount: new bignumber_js_1.default(100000), recipient: "0xABCDEFG", model: { kind: "transfer", uiState: {}, }, }; const expectedLiveTx = { ...solanaTx, model: { ...solanaTx.model, commandDescriptor: undefined }, }; const { canEditFees, hasFeesProvided, liveTx } = walletApiAdapter_1.default.getWalletAPITransactionSignFlowInfos({ walletApiTransaction: solanaTx, account: {}, }); expect(canEditFees).toBe(false); expect(hasFeesProvided).toBe(false); expect(liveTx).toEqual(expectedLiveTx); }); it("should add subAccountId for token transfer", () => { const solanaTx = { family: "solana", amount: new bignumber_js_1.default(100000), recipient: "0xABCDEFG", model: { kind: "token.transfer", uiState: { subAccountId: "", // Automatically replaced by LL }, }, }; const expectedLiveTx = { ...solanaTx, model: { ...solanaTx.model, commandDescriptor: undefined }, subAccountId: "subAccountId", }; const { canEditFees, hasFeesProvided, liveTx } = walletApiAdapter_1.default.getWalletAPITransactionSignFlowInfos({ walletApiTransaction: solanaTx, account: { id: "subAccountId", type: "TokenAccount" }, }); expect(canEditFees).toBe(false); expect(hasFeesProvided).toBe(false); expect(liveTx).toEqual(expectedLiveTx); }); }); }); //# sourceMappingURL=walletApiAdapter.test.js.map