"use strict";
/**
 * This code was AUTOGENERATED using the codama library.
 * Please DO NOT EDIT THIS FILE, instead use visitors
 * to add features, then rerun codama to update it.
 *
 * @see https://github.com/codama-idl/codama
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.FILL_RELAY_PARAMS_DISCRIMINATOR = void 0;
exports.getFillRelayParamsDiscriminatorBytes = getFillRelayParamsDiscriminatorBytes;
exports.getFillRelayParamsEncoder = getFillRelayParamsEncoder;
exports.getFillRelayParamsDecoder = getFillRelayParamsDecoder;
exports.getFillRelayParamsCodec = getFillRelayParamsCodec;
exports.decodeFillRelayParams = decodeFillRelayParams;
exports.fetchFillRelayParams = fetchFillRelayParams;
exports.fetchMaybeFillRelayParams = fetchMaybeFillRelayParams;
exports.fetchAllFillRelayParams = fetchAllFillRelayParams;
exports.fetchAllMaybeFillRelayParams = fetchAllMaybeFillRelayParams;
const web3_v2_js_1 = require("@solana/web3-v2.js");
const types_1 = require("../types");
exports.FILL_RELAY_PARAMS_DISCRIMINATOR = new Uint8Array([
    50, 243, 51, 185, 89, 60, 43, 202,
]);
function getFillRelayParamsDiscriminatorBytes() {
    return (0, web3_v2_js_1.fixEncoderSize)((0, web3_v2_js_1.getBytesEncoder)(), 8).encode(exports.FILL_RELAY_PARAMS_DISCRIMINATOR);
}
function getFillRelayParamsEncoder() {
    return (0, web3_v2_js_1.transformEncoder)((0, web3_v2_js_1.getStructEncoder)([
        ['discriminator', (0, web3_v2_js_1.fixEncoderSize)((0, web3_v2_js_1.getBytesEncoder)(), 8)],
        ['relayData', (0, types_1.getRelayDataEncoder)()],
        ['repaymentChainId', (0, web3_v2_js_1.getU64Encoder)()],
        ['repaymentAddress', (0, web3_v2_js_1.getAddressEncoder)()],
    ]), (value) => ({ ...value, discriminator: exports.FILL_RELAY_PARAMS_DISCRIMINATOR }));
}
function getFillRelayParamsDecoder() {
    return (0, web3_v2_js_1.getStructDecoder)([
        ['discriminator', (0, web3_v2_js_1.fixDecoderSize)((0, web3_v2_js_1.getBytesDecoder)(), 8)],
        ['relayData', (0, types_1.getRelayDataDecoder)()],
        ['repaymentChainId', (0, web3_v2_js_1.getU64Decoder)()],
        ['repaymentAddress', (0, web3_v2_js_1.getAddressDecoder)()],
    ]);
}
function getFillRelayParamsCodec() {
    return (0, web3_v2_js_1.combineCodec)(getFillRelayParamsEncoder(), getFillRelayParamsDecoder());
}
function decodeFillRelayParams(encodedAccount) {
    return (0, web3_v2_js_1.decodeAccount)(encodedAccount, getFillRelayParamsDecoder());
}
async function fetchFillRelayParams(rpc, address, config) {
    const maybeAccount = await fetchMaybeFillRelayParams(rpc, address, config);
    (0, web3_v2_js_1.assertAccountExists)(maybeAccount);
    return maybeAccount;
}
async function fetchMaybeFillRelayParams(rpc, address, config) {
    const maybeAccount = await (0, web3_v2_js_1.fetchEncodedAccount)(rpc, address, config);
    return decodeFillRelayParams(maybeAccount);
}
async function fetchAllFillRelayParams(rpc, addresses, config) {
    const maybeAccounts = await fetchAllMaybeFillRelayParams(rpc, addresses, config);
    (0, web3_v2_js_1.assertAccountsExist)(maybeAccounts);
    return maybeAccounts;
}
async function fetchAllMaybeFillRelayParams(rpc, addresses, config) {
    const maybeAccounts = await (0, web3_v2_js_1.fetchEncodedAccounts)(rpc, addresses, config);
    return maybeAccounts.map((maybeAccount) => decodeFillRelayParams(maybeAccount));
}
