@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
56 lines (43 loc) • 1.55 kB
text/typescript
import BigNumber from "bignumber.js";
import { FAMILIES, RippleTransaction as PlatformTransaction } from "@ledgerhq/live-app-sdk";
import xrp from "./platformAdapter";
import { Transaction } from "./types";
describe("getPlatformTransactionSignFlowInfos", () => {
describe("should properly get infos for XRP platform tx", () => {
it("without fees provided", () => {
const xrpPlatformTx: PlatformTransaction = {
family: FAMILIES.RIPPLE,
amount: new BigNumber(100000),
recipient: "0xABCDEF",
tag: 1,
};
const expectedLiveTx: Partial<Transaction> = {
...xrpPlatformTx,
family: "xrp",
};
const { canEditFees, hasFeesProvided, liveTx } =
xrp.getPlatformTransactionSignFlowInfos(xrpPlatformTx);
expect(canEditFees).toBe(true);
expect(hasFeesProvided).toBe(false);
expect(liveTx).toEqual(expectedLiveTx);
});
it("with fees provided", () => {
const xrpPlatformTx: PlatformTransaction = {
family: FAMILIES.RIPPLE,
amount: new BigNumber(100000),
recipient: "0xABCDEF",
fee: new BigNumber(300),
tag: 1,
};
const expectedLiveTx: Partial<Transaction> = {
...xrpPlatformTx,
family: "xrp",
};
const { canEditFees, hasFeesProvided, liveTx } =
xrp.getPlatformTransactionSignFlowInfos(xrpPlatformTx);
expect(canEditFees).toBe(true);
expect(hasFeesProvided).toBe(true);
expect(liveTx).toEqual(expectedLiveTx);
});
});
});