"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EXECUTE_RELAYER_REFUND_LEAF_PARAMS_DISCRIMINATOR = void 0;
exports.getExecuteRelayerRefundLeafParamsDiscriminatorBytes = getExecuteRelayerRefundLeafParamsDiscriminatorBytes;
exports.getExecuteRelayerRefundLeafParamsEncoder = getExecuteRelayerRefundLeafParamsEncoder;
exports.getExecuteRelayerRefundLeafParamsDecoder = getExecuteRelayerRefundLeafParamsDecoder;
exports.getExecuteRelayerRefundLeafParamsCodec = getExecuteRelayerRefundLeafParamsCodec;
exports.decodeExecuteRelayerRefundLeafParams = decodeExecuteRelayerRefundLeafParams;
exports.fetchExecuteRelayerRefundLeafParams = fetchExecuteRelayerRefundLeafParams;
exports.fetchMaybeExecuteRelayerRefundLeafParams = fetchMaybeExecuteRelayerRefundLeafParams;
exports.fetchAllExecuteRelayerRefundLeafParams = fetchAllExecuteRelayerRefundLeafParams;
exports.fetchAllMaybeExecuteRelayerRefundLeafParams = fetchAllMaybeExecuteRelayerRefundLeafParams;
var tslib_1 = require("tslib");
var kit_1 = require("@solana/kit");
var types_1 = require("../types");
exports.EXECUTE_RELAYER_REFUND_LEAF_PARAMS_DISCRIMINATOR = new Uint8Array([
    192, 59, 93, 9, 171, 77, 28, 250,
]);
function getExecuteRelayerRefundLeafParamsDiscriminatorBytes() {
    return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.EXECUTE_RELAYER_REFUND_LEAF_PARAMS_DISCRIMINATOR);
}
function getExecuteRelayerRefundLeafParamsEncoder() {
    return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([
        ["discriminator", (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)],
        ["rootBundleId", (0, kit_1.getU32Encoder)()],
        ["relayerRefundLeaf", (0, types_1.getRelayerRefundLeafEncoder)()],
        ["proof", (0, kit_1.getArrayEncoder)((0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 32))],
    ]), function (value) { return (tslib_1.__assign(tslib_1.__assign({}, value), { discriminator: exports.EXECUTE_RELAYER_REFUND_LEAF_PARAMS_DISCRIMINATOR })); });
}
function getExecuteRelayerRefundLeafParamsDecoder() {
    return (0, kit_1.getStructDecoder)([
        ["discriminator", (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)],
        ["rootBundleId", (0, kit_1.getU32Decoder)()],
        ["relayerRefundLeaf", (0, types_1.getRelayerRefundLeafDecoder)()],
        ["proof", (0, kit_1.getArrayDecoder)((0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 32))],
    ]);
}
function getExecuteRelayerRefundLeafParamsCodec() {
    return (0, kit_1.combineCodec)(getExecuteRelayerRefundLeafParamsEncoder(), getExecuteRelayerRefundLeafParamsDecoder());
}
function decodeExecuteRelayerRefundLeafParams(encodedAccount) {
    return (0, kit_1.decodeAccount)(encodedAccount, getExecuteRelayerRefundLeafParamsDecoder());
}
function fetchExecuteRelayerRefundLeafParams(rpc, address, config) {
    return tslib_1.__awaiter(this, void 0, void 0, function () {
        var maybeAccount;
        return tslib_1.__generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4, fetchMaybeExecuteRelayerRefundLeafParams(rpc, address, config)];
                case 1:
                    maybeAccount = _a.sent();
                    (0, kit_1.assertAccountExists)(maybeAccount);
                    return [2, maybeAccount];
            }
        });
    });
}
function fetchMaybeExecuteRelayerRefundLeafParams(rpc, address, config) {
    return tslib_1.__awaiter(this, void 0, void 0, function () {
        var maybeAccount;
        return tslib_1.__generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4, (0, kit_1.fetchEncodedAccount)(rpc, address, config)];
                case 1:
                    maybeAccount = _a.sent();
                    return [2, decodeExecuteRelayerRefundLeafParams(maybeAccount)];
            }
        });
    });
}
function fetchAllExecuteRelayerRefundLeafParams(rpc, addresses, config) {
    return tslib_1.__awaiter(this, void 0, void 0, function () {
        var maybeAccounts;
        return tslib_1.__generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4, fetchAllMaybeExecuteRelayerRefundLeafParams(rpc, addresses, config)];
                case 1:
                    maybeAccounts = _a.sent();
                    (0, kit_1.assertAccountsExist)(maybeAccounts);
                    return [2, maybeAccounts];
            }
        });
    });
}
function fetchAllMaybeExecuteRelayerRefundLeafParams(rpc, addresses, config) {
    return tslib_1.__awaiter(this, void 0, void 0, function () {
        var maybeAccounts;
        return tslib_1.__generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4, (0, kit_1.fetchEncodedAccounts)(rpc, addresses, config)];
                case 1:
                    maybeAccounts = _a.sent();
                    return [2, maybeAccounts.map(function (maybeAccount) {
                            return decodeExecuteRelayerRefundLeafParams(maybeAccount);
                        })];
            }
        });
    });
}
//# sourceMappingURL=executeRelayerRefundLeafParams.js.map