UNPKG

@ledgerhq/live-common

Version:
54 lines 2.14 kB
import BigNumber from "bignumber.js"; import sol from "./walletApiAdapter"; describe("getWalletAPITransactionSignFlowInfos", () => { describe("should properly get infos for Solana TX", () => { it("simple transfer", () => { const solanaTx = { family: "solana", amount: new BigNumber(100000), recipient: "0xABCDEFG", model: { kind: "transfer", uiState: {}, }, }; const expectedLiveTx = { ...solanaTx, model: { ...solanaTx.model, commandDescriptor: undefined }, }; const { canEditFees, hasFeesProvided, liveTx } = sol.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(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 } = sol.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