/**
 * 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
 */
import { __assign } from "tslib";
import { assertIsInstructionWithAccounts, containsBytes, fixEncoderSize, getBytesEncoder, } from "@solana/kit";
import { parseBridgeTokensToHubPoolInstruction, parseClaimRelayerRefundInstruction, parseCloseClaimAccountInstruction, parseCloseFillPdaInstruction, parseCloseInstructionParamsInstruction, parseCreateTokenAccountsInstruction, parseDepositInstruction, parseDepositNowInstruction, parseEmergencyDeleteRootBundleInstruction, parseExecuteRelayerRefundLeafDeferredInstruction, parseExecuteRelayerRefundLeafInstruction, parseExecuteSlowRelayLeafInstruction, parseFillRelayInstruction, parseGetUnsafeDepositIdInstruction, parseHandleReceiveMessageInstruction, parseInitializeClaimAccountInstruction, parseInitializeInstruction, parseInitializeInstructionParamsInstruction, parsePauseDepositsInstruction, parsePauseFillsInstruction, parseRelayRootBundleInstruction, parseRequestSlowFillInstruction, parseSetCrossDomainAdminInstruction, parseSetCurrentTimeInstruction, parseTransferOwnershipInstruction, parseUnsafeDepositInstruction, parseWriteInstructionParamsFragmentInstruction, } from "../instructions";
export var SVM_SPOKE_PROGRAM_ADDRESS = "DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru";
export var SvmSpokeAccount;
(function (SvmSpokeAccount) {
    SvmSpokeAccount[SvmSpokeAccount["ClaimAccount"] = 0] = "ClaimAccount";
    SvmSpokeAccount[SvmSpokeAccount["ExecuteRelayerRefundLeafParams"] = 1] = "ExecuteRelayerRefundLeafParams";
    SvmSpokeAccount[SvmSpokeAccount["ExecuteSlowRelayLeafParams"] = 2] = "ExecuteSlowRelayLeafParams";
    SvmSpokeAccount[SvmSpokeAccount["FillRelayParams"] = 3] = "FillRelayParams";
    SvmSpokeAccount[SvmSpokeAccount["FillStatusAccount"] = 4] = "FillStatusAccount";
    SvmSpokeAccount[SvmSpokeAccount["RequestSlowFillParams"] = 5] = "RequestSlowFillParams";
    SvmSpokeAccount[SvmSpokeAccount["RootBundle"] = 6] = "RootBundle";
    SvmSpokeAccount[SvmSpokeAccount["State"] = 7] = "State";
    SvmSpokeAccount[SvmSpokeAccount["TransferLiability"] = 8] = "TransferLiability";
})(SvmSpokeAccount || (SvmSpokeAccount = {}));
export function identifySvmSpokeAccount(account) {
    var data = "data" in account ? account.data : account;
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([113, 109, 47, 96, 242, 219, 61, 165])), 0)) {
        return SvmSpokeAccount.ClaimAccount;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([192, 59, 93, 9, 171, 77, 28, 250])), 0)) {
        return SvmSpokeAccount.ExecuteRelayerRefundLeafParams;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([135, 208, 119, 251, 14, 222, 66, 155])), 0)) {
        return SvmSpokeAccount.ExecuteSlowRelayLeafParams;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([50, 243, 51, 185, 89, 60, 43, 202])), 0)) {
        return SvmSpokeAccount.FillRelayParams;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([105, 89, 88, 35, 24, 147, 178, 137])), 0)) {
        return SvmSpokeAccount.FillStatusAccount;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([5, 54, 214, 89, 197, 37, 118, 28])), 0)) {
        return SvmSpokeAccount.RequestSlowFillParams;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([66, 221, 214, 231, 25, 222, 184, 219])), 0)) {
        return SvmSpokeAccount.RootBundle;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([216, 146, 107, 94, 104, 75, 182, 177])), 0)) {
        return SvmSpokeAccount.State;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([157, 137, 86, 109, 206, 241, 183, 79])), 0)) {
        return SvmSpokeAccount.TransferLiability;
    }
    throw new Error("The provided account could not be identified as a svmSpoke account.");
}
export var SvmSpokeInstruction;
(function (SvmSpokeInstruction) {
    SvmSpokeInstruction[SvmSpokeInstruction["BridgeTokensToHubPool"] = 0] = "BridgeTokensToHubPool";
    SvmSpokeInstruction[SvmSpokeInstruction["ClaimRelayerRefund"] = 1] = "ClaimRelayerRefund";
    SvmSpokeInstruction[SvmSpokeInstruction["CloseClaimAccount"] = 2] = "CloseClaimAccount";
    SvmSpokeInstruction[SvmSpokeInstruction["CloseFillPda"] = 3] = "CloseFillPda";
    SvmSpokeInstruction[SvmSpokeInstruction["CloseInstructionParams"] = 4] = "CloseInstructionParams";
    SvmSpokeInstruction[SvmSpokeInstruction["CreateTokenAccounts"] = 5] = "CreateTokenAccounts";
    SvmSpokeInstruction[SvmSpokeInstruction["Deposit"] = 6] = "Deposit";
    SvmSpokeInstruction[SvmSpokeInstruction["DepositNow"] = 7] = "DepositNow";
    SvmSpokeInstruction[SvmSpokeInstruction["EmergencyDeleteRootBundle"] = 8] = "EmergencyDeleteRootBundle";
    SvmSpokeInstruction[SvmSpokeInstruction["ExecuteRelayerRefundLeaf"] = 9] = "ExecuteRelayerRefundLeaf";
    SvmSpokeInstruction[SvmSpokeInstruction["ExecuteRelayerRefundLeafDeferred"] = 10] = "ExecuteRelayerRefundLeafDeferred";
    SvmSpokeInstruction[SvmSpokeInstruction["ExecuteSlowRelayLeaf"] = 11] = "ExecuteSlowRelayLeaf";
    SvmSpokeInstruction[SvmSpokeInstruction["FillRelay"] = 12] = "FillRelay";
    SvmSpokeInstruction[SvmSpokeInstruction["GetUnsafeDepositId"] = 13] = "GetUnsafeDepositId";
    SvmSpokeInstruction[SvmSpokeInstruction["HandleReceiveMessage"] = 14] = "HandleReceiveMessage";
    SvmSpokeInstruction[SvmSpokeInstruction["Initialize"] = 15] = "Initialize";
    SvmSpokeInstruction[SvmSpokeInstruction["InitializeClaimAccount"] = 16] = "InitializeClaimAccount";
    SvmSpokeInstruction[SvmSpokeInstruction["InitializeInstructionParams"] = 17] = "InitializeInstructionParams";
    SvmSpokeInstruction[SvmSpokeInstruction["PauseDeposits"] = 18] = "PauseDeposits";
    SvmSpokeInstruction[SvmSpokeInstruction["PauseFills"] = 19] = "PauseFills";
    SvmSpokeInstruction[SvmSpokeInstruction["RelayRootBundle"] = 20] = "RelayRootBundle";
    SvmSpokeInstruction[SvmSpokeInstruction["RequestSlowFill"] = 21] = "RequestSlowFill";
    SvmSpokeInstruction[SvmSpokeInstruction["SetCrossDomainAdmin"] = 22] = "SetCrossDomainAdmin";
    SvmSpokeInstruction[SvmSpokeInstruction["SetCurrentTime"] = 23] = "SetCurrentTime";
    SvmSpokeInstruction[SvmSpokeInstruction["TransferOwnership"] = 24] = "TransferOwnership";
    SvmSpokeInstruction[SvmSpokeInstruction["UnsafeDeposit"] = 25] = "UnsafeDeposit";
    SvmSpokeInstruction[SvmSpokeInstruction["WriteInstructionParamsFragment"] = 26] = "WriteInstructionParamsFragment";
})(SvmSpokeInstruction || (SvmSpokeInstruction = {}));
export function identifySvmSpokeInstruction(instruction) {
    var data = "data" in instruction ? instruction.data : instruction;
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([1, 83, 255, 59, 232, 55, 64, 216])), 0)) {
        return SvmSpokeInstruction.BridgeTokensToHubPool;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([205, 34, 34, 224, 204, 103, 81, 176])), 0)) {
        return SvmSpokeInstruction.ClaimRelayerRefund;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([241, 146, 203, 216, 58, 222, 91, 118])), 0)) {
        return SvmSpokeInstruction.CloseClaimAccount;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([224, 39, 208, 68, 8, 226, 23, 214])), 0)) {
        return SvmSpokeInstruction.CloseFillPda;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([224, 44, 254, 10, 216, 8, 172, 96])), 0)) {
        return SvmSpokeInstruction.CloseInstructionParams;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([163, 216, 49, 204, 97, 16, 80, 167])), 0)) {
        return SvmSpokeInstruction.CreateTokenAccounts;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([242, 35, 198, 137, 82, 225, 242, 182])), 0)) {
        return SvmSpokeInstruction.Deposit;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([75, 228, 135, 221, 200, 25, 148, 26])), 0)) {
        return SvmSpokeInstruction.DepositNow;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([226, 158, 1, 74, 84, 113, 24, 152])), 0)) {
        return SvmSpokeInstruction.EmergencyDeleteRootBundle;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([27, 136, 159, 240, 127, 68, 123, 164])), 0)) {
        return SvmSpokeInstruction.ExecuteRelayerRefundLeaf;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([110, 112, 89, 208, 38, 116, 93, 10])), 0)) {
        return SvmSpokeInstruction.ExecuteRelayerRefundLeafDeferred;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([26, 207, 3, 168, 193, 252, 59, 127])), 0)) {
        return SvmSpokeInstruction.ExecuteSlowRelayLeaf;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([100, 84, 222, 90, 106, 209, 58, 222])), 0)) {
        return SvmSpokeInstruction.FillRelay;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([118, 10, 135, 0, 168, 243, 223, 117])), 0)) {
        return SvmSpokeInstruction.GetUnsafeDepositId;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([133, 102, 1, 180, 145, 11, 138, 180])), 0)) {
        return SvmSpokeInstruction.HandleReceiveMessage;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([175, 175, 109, 31, 13, 152, 155, 237])), 0)) {
        return SvmSpokeInstruction.Initialize;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([22, 247, 214, 191, 90, 74, 87, 216])), 0)) {
        return SvmSpokeInstruction.InitializeClaimAccount;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([94, 206, 190, 192, 127, 8, 186, 28])), 0)) {
        return SvmSpokeInstruction.InitializeInstructionParams;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([206, 186, 203, 153, 253, 61, 206, 122])), 0)) {
        return SvmSpokeInstruction.PauseDeposits;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([92, 114, 214, 49, 13, 243, 73, 35])), 0)) {
        return SvmSpokeInstruction.PauseFills;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([69, 13, 223, 204, 251, 61, 105, 6])), 0)) {
        return SvmSpokeInstruction.RelayRootBundle;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([39, 157, 165, 187, 88, 217, 207, 98])), 0)) {
        return SvmSpokeInstruction.RequestSlowFill;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([102, 206, 237, 106, 63, 141, 42, 248])), 0)) {
        return SvmSpokeInstruction.SetCrossDomainAdmin;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([69, 100, 169, 193, 125, 0, 150, 69])), 0)) {
        return SvmSpokeInstruction.SetCurrentTime;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([65, 177, 215, 73, 53, 45, 99, 47])), 0)) {
        return SvmSpokeInstruction.TransferOwnership;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([196, 187, 166, 179, 3, 146, 150, 246])), 0)) {
        return SvmSpokeInstruction.UnsafeDeposit;
    }
    if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([238, 182, 109, 113, 124, 255, 72, 18])), 0)) {
        return SvmSpokeInstruction.WriteInstructionParamsFragment;
    }
    throw new Error("The provided instruction could not be identified as a svmSpoke instruction.");
}
export function parseSvmSpokeInstruction(instruction) {
    var instructionType = identifySvmSpokeInstruction(instruction);
    switch (instructionType) {
        case SvmSpokeInstruction.BridgeTokensToHubPool: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.BridgeTokensToHubPool }, parseBridgeTokensToHubPoolInstruction(instruction));
        }
        case SvmSpokeInstruction.ClaimRelayerRefund: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.ClaimRelayerRefund }, parseClaimRelayerRefundInstruction(instruction));
        }
        case SvmSpokeInstruction.CloseClaimAccount: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.CloseClaimAccount }, parseCloseClaimAccountInstruction(instruction));
        }
        case SvmSpokeInstruction.CloseFillPda: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.CloseFillPda }, parseCloseFillPdaInstruction(instruction));
        }
        case SvmSpokeInstruction.CloseInstructionParams: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.CloseInstructionParams }, parseCloseInstructionParamsInstruction(instruction));
        }
        case SvmSpokeInstruction.CreateTokenAccounts: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.CreateTokenAccounts }, parseCreateTokenAccountsInstruction(instruction));
        }
        case SvmSpokeInstruction.Deposit: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.Deposit }, parseDepositInstruction(instruction));
        }
        case SvmSpokeInstruction.DepositNow: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.DepositNow }, parseDepositNowInstruction(instruction));
        }
        case SvmSpokeInstruction.EmergencyDeleteRootBundle: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.EmergencyDeleteRootBundle }, parseEmergencyDeleteRootBundleInstruction(instruction));
        }
        case SvmSpokeInstruction.ExecuteRelayerRefundLeaf: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.ExecuteRelayerRefundLeaf }, parseExecuteRelayerRefundLeafInstruction(instruction));
        }
        case SvmSpokeInstruction.ExecuteRelayerRefundLeafDeferred: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.ExecuteRelayerRefundLeafDeferred }, parseExecuteRelayerRefundLeafDeferredInstruction(instruction));
        }
        case SvmSpokeInstruction.ExecuteSlowRelayLeaf: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.ExecuteSlowRelayLeaf }, parseExecuteSlowRelayLeafInstruction(instruction));
        }
        case SvmSpokeInstruction.FillRelay: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.FillRelay }, parseFillRelayInstruction(instruction));
        }
        case SvmSpokeInstruction.GetUnsafeDepositId: {
            return __assign({ instructionType: SvmSpokeInstruction.GetUnsafeDepositId }, parseGetUnsafeDepositIdInstruction(instruction));
        }
        case SvmSpokeInstruction.HandleReceiveMessage: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.HandleReceiveMessage }, parseHandleReceiveMessageInstruction(instruction));
        }
        case SvmSpokeInstruction.Initialize: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.Initialize }, parseInitializeInstruction(instruction));
        }
        case SvmSpokeInstruction.InitializeClaimAccount: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.InitializeClaimAccount }, parseInitializeClaimAccountInstruction(instruction));
        }
        case SvmSpokeInstruction.InitializeInstructionParams: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.InitializeInstructionParams }, parseInitializeInstructionParamsInstruction(instruction));
        }
        case SvmSpokeInstruction.PauseDeposits: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.PauseDeposits }, parsePauseDepositsInstruction(instruction));
        }
        case SvmSpokeInstruction.PauseFills: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.PauseFills }, parsePauseFillsInstruction(instruction));
        }
        case SvmSpokeInstruction.RelayRootBundle: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.RelayRootBundle }, parseRelayRootBundleInstruction(instruction));
        }
        case SvmSpokeInstruction.RequestSlowFill: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.RequestSlowFill }, parseRequestSlowFillInstruction(instruction));
        }
        case SvmSpokeInstruction.SetCrossDomainAdmin: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.SetCrossDomainAdmin }, parseSetCrossDomainAdminInstruction(instruction));
        }
        case SvmSpokeInstruction.SetCurrentTime: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.SetCurrentTime }, parseSetCurrentTimeInstruction(instruction));
        }
        case SvmSpokeInstruction.TransferOwnership: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.TransferOwnership }, parseTransferOwnershipInstruction(instruction));
        }
        case SvmSpokeInstruction.UnsafeDeposit: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.UnsafeDeposit }, parseUnsafeDepositInstruction(instruction));
        }
        case SvmSpokeInstruction.WriteInstructionParamsFragment: {
            assertIsInstructionWithAccounts(instruction);
            return __assign({ instructionType: SvmSpokeInstruction.WriteInstructionParamsFragment }, parseWriteInstructionParamsFragmentInstruction(instruction));
        }
        default:
            throw new Error("Unrecognized instruction type: ".concat(instructionType));
    }
}
//# sourceMappingURL=svmSpoke.js.map