import { FAMILIES } from "@ledgerhq/live-app-sdk";
import BigNumber from "bignumber.js";
import evm from "./platformAdapter";
import { DEFAULT_NONCE } from "@ledgerhq/coin-evm/utils";
describe("getPlatformTransactionSignFlowInfos", () => {
    describe("should properly get infos for ETH platform tx", () => {
        test("without fees provided", () => {
            const ethPlatformTx = {
                family: FAMILIES.ETHEREUM,
                amount: new BigNumber(100000),
                recipient: "0xABCDEF",
            };
            const expectedLiveTx = {
                family: "evm",
                amount: ethPlatformTx.amount,
                recipient: ethPlatformTx.recipient,
                data: undefined,
                gasLimit: undefined,
                nonce: DEFAULT_NONCE,
                customGasLimit: undefined,
                feesStrategy: undefined,
                type: 2,
            };
            const { canEditFees, hasFeesProvided, liveTx } = evm.getPlatformTransactionSignFlowInfos(ethPlatformTx);
            expect(canEditFees).toBe(true);
            expect(hasFeesProvided).toBe(false);
            expect(liveTx).toEqual(expectedLiveTx);
        });
        // FIXME: add tests for tx of type 2
        test("with fees provided for legacy tx", () => {
            const ethPlatformTx = {
                family: FAMILIES.ETHEREUM,
                amount: new BigNumber(100000),
                recipient: "0xABCDEF",
                gasPrice: new BigNumber(300),
                gasLimit: new BigNumber(21000),
            };
            const expectedLiveTx = {
                family: "evm",
                amount: ethPlatformTx.amount,
                recipient: ethPlatformTx.recipient,
                gasPrice: ethPlatformTx.gasPrice,
                gasLimit: ethPlatformTx.gasLimit,
                customGasLimit: ethPlatformTx.gasLimit,
                nonce: DEFAULT_NONCE,
                data: undefined,
                feesStrategy: "custom",
                type: 0,
            };
            const { canEditFees, hasFeesProvided, liveTx } = evm.getPlatformTransactionSignFlowInfos(ethPlatformTx);
            expect(canEditFees).toBe(true);
            expect(hasFeesProvided).toBe(true);
            expect(liveTx).toEqual(expectedLiveTx);
        });
        test("with only gasLimit provided", () => {
            const ethPlatformTx = {
                family: FAMILIES.ETHEREUM,
                amount: new BigNumber(100000),
                recipient: "0xABCDEF",
                gasLimit: new BigNumber(21000),
            };
            const expectedLiveTx = {
                family: "evm",
                amount: ethPlatformTx.amount,
                recipient: ethPlatformTx.recipient,
                gasLimit: ethPlatformTx.gasLimit,
                customGasLimit: ethPlatformTx.gasLimit,
                nonce: DEFAULT_NONCE,
                data: undefined,
                type: 2,
            };
            const { canEditFees, hasFeesProvided, liveTx } = evm.getPlatformTransactionSignFlowInfos(ethPlatformTx);
            expect(canEditFees).toBe(true);
            expect(hasFeesProvided).toBe(false);
            expect(liveTx).toEqual(expectedLiveTx);
        });
        test("with nonce provided", () => {
            const ethPlatformTx = {
                family: FAMILIES.ETHEREUM,
                amount: new BigNumber(100000),
                recipient: "0xABCDEF",
                nonce: 1,
            };
            const expectedLiveTx = {
                family: "evm",
                amount: ethPlatformTx.amount,
                recipient: ethPlatformTx.recipient,
                data: undefined,
                gasLimit: undefined,
                nonce: 1,
                customGasLimit: undefined,
                feesStrategy: undefined,
                type: 2,
            };
            const { canEditFees, hasFeesProvided, liveTx } = evm.getPlatformTransactionSignFlowInfos(ethPlatformTx);
            expect(canEditFees).toBe(true);
            expect(hasFeesProvided).toBe(false);
            expect(liveTx).toEqual(expectedLiveTx);
        });
    });
});
//# sourceMappingURL=platformAdapter.test.js.map