"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EXECUTE_SLOW_RELAY_LEAF_PARAMS_DISCRIMINATOR = void 0;
exports.getExecuteSlowRelayLeafParamsDiscriminatorBytes = getExecuteSlowRelayLeafParamsDiscriminatorBytes;
exports.getExecuteSlowRelayLeafParamsEncoder = getExecuteSlowRelayLeafParamsEncoder;
exports.getExecuteSlowRelayLeafParamsDecoder = getExecuteSlowRelayLeafParamsDecoder;
exports.getExecuteSlowRelayLeafParamsCodec = getExecuteSlowRelayLeafParamsCodec;
exports.decodeExecuteSlowRelayLeafParams = decodeExecuteSlowRelayLeafParams;
exports.fetchExecuteSlowRelayLeafParams = fetchExecuteSlowRelayLeafParams;
exports.fetchMaybeExecuteSlowRelayLeafParams = fetchMaybeExecuteSlowRelayLeafParams;
exports.fetchAllExecuteSlowRelayLeafParams = fetchAllExecuteSlowRelayLeafParams;
exports.fetchAllMaybeExecuteSlowRelayLeafParams = fetchAllMaybeExecuteSlowRelayLeafParams;
var tslib_1 = require("tslib");
var kit_1 = require("@solana/kit");
var types_1 = require("../types");
exports.EXECUTE_SLOW_RELAY_LEAF_PARAMS_DISCRIMINATOR = new Uint8Array([
    135, 208, 119, 251, 14, 222, 66, 155,
]);
function getExecuteSlowRelayLeafParamsDiscriminatorBytes() {
    return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.EXECUTE_SLOW_RELAY_LEAF_PARAMS_DISCRIMINATOR);
}
function getExecuteSlowRelayLeafParamsEncoder() {
    return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([
        ["discriminator", (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)],
        ["slowFillLeaf", (0, types_1.getSlowFillEncoder)()],
        ["rootBundleId", (0, kit_1.getU32Encoder)()],
        ["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_SLOW_RELAY_LEAF_PARAMS_DISCRIMINATOR })); });
}
function getExecuteSlowRelayLeafParamsDecoder() {
    return (0, kit_1.getStructDecoder)([
        ["discriminator", (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)],
        ["slowFillLeaf", (0, types_1.getSlowFillDecoder)()],
        ["rootBundleId", (0, kit_1.getU32Decoder)()],
        ["proof", (0, kit_1.getArrayDecoder)((0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 32))],
    ]);
}
function getExecuteSlowRelayLeafParamsCodec() {
    return (0, kit_1.combineCodec)(getExecuteSlowRelayLeafParamsEncoder(), getExecuteSlowRelayLeafParamsDecoder());
}
function decodeExecuteSlowRelayLeafParams(encodedAccount) {
    return (0, kit_1.decodeAccount)(encodedAccount, getExecuteSlowRelayLeafParamsDecoder());
}
function fetchExecuteSlowRelayLeafParams(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, fetchMaybeExecuteSlowRelayLeafParams(rpc, address, config)];
                case 1:
                    maybeAccount = _a.sent();
                    (0, kit_1.assertAccountExists)(maybeAccount);
                    return [2, maybeAccount];
            }
        });
    });
}
function fetchMaybeExecuteSlowRelayLeafParams(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, decodeExecuteSlowRelayLeafParams(maybeAccount)];
            }
        });
    });
}
function fetchAllExecuteSlowRelayLeafParams(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, fetchAllMaybeExecuteSlowRelayLeafParams(rpc, addresses, config)];
                case 1:
                    maybeAccounts = _a.sent();
                    (0, kit_1.assertAccountsExist)(maybeAccounts);
                    return [2, maybeAccounts];
            }
        });
    });
}
function fetchAllMaybeExecuteSlowRelayLeafParams(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 decodeExecuteSlowRelayLeafParams(maybeAccount);
                        })];
            }
        });
    });
}
//# sourceMappingURL=executeSlowRelayLeafParams.js.map