@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
57 lines • 2.14 kB
JavaScript
import BigNumber from "bignumber.js";
import cosmos from "./walletApiAdapter";
describe("getWalletAPITransactionSignFlowInfos", () => {
describe("should properly get infos for Cosmos platform tx", () => {
it("without fees provided", () => {
const cosmosPlatformTx = {
family: "cosmos",
amount: new BigNumber(100000),
recipient: "0xABCDEF",
mode: "send",
};
const expectedLiveTx = {
...cosmosPlatformTx,
fees: null,
gas: null,
useAllAmount: false,
networkInfo: null,
memo: null,
sourceValidator: null,
validators: [],
};
const { canEditFees, hasFeesProvided, liveTx } = cosmos.getWalletAPITransactionSignFlowInfos({
walletApiTransaction: cosmosPlatformTx,
account: {},
});
expect(canEditFees).toBe(true);
expect(hasFeesProvided).toBe(false);
expect(liveTx).toEqual(expectedLiveTx);
});
it("with fees provided", () => {
const cosmosPlatformTx = {
family: "cosmos",
amount: new BigNumber(100000),
recipient: "0xABCDEF",
fees: new BigNumber(300),
mode: "send",
};
const expectedLiveTx = {
...cosmosPlatformTx,
gas: null,
useAllAmount: false,
networkInfo: null,
memo: null,
sourceValidator: null,
validators: [],
};
const { canEditFees, hasFeesProvided, liveTx } = cosmos.getWalletAPITransactionSignFlowInfos({
walletApiTransaction: cosmosPlatformTx,
account: {},
});
expect(canEditFees).toBe(true);
expect(hasFeesProvided).toBe(true);
expect(liveTx).toEqual(expectedLiveTx);
});
});
});
//# sourceMappingURL=walletApiAdapter.test.js.map