"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Action_1 = require("@wireio/sdk-core/chain/Action");
const PermissionLevel_1 = require("@wireio/sdk-core/chain/PermissionLevel");
const Transaction_1 = require("@wireio/sdk-core/chain/Transaction");
const sdk_core_1 = require("@wireio/sdk-core");
const { buildProposalTransaction, decodeProposalTransactionActions } = sdk_core_1.contracts.sysio.msig;
const tokenAbi = {
    version: "eosio::abi/1.2",
    types: [],
    structs: [
        {
            name: "transfer",
            base: "",
            fields: [
                { name: "from", type: "name" },
                { name: "to", type: "name" },
                { name: "quantity", type: "asset" },
                { name: "memo", type: "string" }
            ]
        }
    ],
    actions: [{ name: "transfer", type: "transfer", ricardian_contract: "" }],
    tables: [],
    ricardian_clauses: [],
    variants: [],
    action_results: [],
    kv_tables: {}
};
describe("proposal transaction helpers", () => {
    test("builds an inner proposal transaction with ABI-encoded actions", () => {
        const transaction = buildProposalTransaction({
            header: {
                expiration: "2026-06-16T16:00:00",
                ref_block_num: 1,
                ref_block_prefix: 2
            },
            actions: [
                {
                    account: "sysio.token",
                    name: "transfer",
                    authorization: [PermissionLevel_1.PermissionLevel.from("alice@active")],
                    data: {
                        from: "alice",
                        to: "bob",
                        quantity: "1.0000 SYS",
                        memo: "msig test"
                    }
                }
            ],
            abis: [{ contract: "sysio.token", abi: tokenAbi }]
        });
        expect(transaction).toBeInstanceOf(Transaction_1.Transaction);
        expect(transaction.actions.length).toBe(1);
        expect(transaction.actions[0]).toBeInstanceOf(Action_1.Action);
        expect(transaction.actions[0].account.toString()).toBe("sysio.token");
    });
    test("decodes transaction actions with the matching contract ABI", () => {
        const transaction = buildProposalTransaction({
            header: {
                expiration: "2026-06-16T16:00:00",
                ref_block_num: 1,
                ref_block_prefix: 2
            },
            actions: [
                {
                    account: "sysio.token",
                    name: "transfer",
                    authorization: [PermissionLevel_1.PermissionLevel.from("alice@active")],
                    data: {
                        from: "alice",
                        to: "bob",
                        quantity: "1.0000 SYS",
                        memo: "msig test"
                    }
                }
            ],
            abis: [{ contract: "sysio.token", abi: tokenAbi }]
        }), decoded = decodeProposalTransactionActions(transaction, [
            { contract: "sysio.token", abi: tokenAbi }
        ]);
        expect(decoded).toHaveLength(1);
        expect(decoded[0].decoded).toBe(true);
        expect(decoded[0].data).toMatchObject({
            from: "alice",
            to: "bob",
            quantity: "1.0000 SYS",
            memo: "msig test"
        });
    });
});
//# sourceMappingURL=Transaction.test.js.map