/** * 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 { assertIsInstructionWithAccounts, containsBytes, fixEncoderSize, getBytesEncoder, type Address, type Instruction, type InstructionWithData, type ReadonlyUint8Array, } from "@solana/kit"; import { parseApproveAdminCachedInstruction, parseCloseMintMapInstruction, parseCreateMintMapInstruction, parseFreezePriceInstruction, parseInitializeInstruction, parseRefreshChainlinkPriceInstruction, parseRefreshPriceListInstruction, parseRefreshPythLazerPriceInstruction, parseResetTwapInstruction, parseResumeChainlinkxPriceInstruction, parseSetAdminCachedInstruction, parseSetEmergencyCouncilInstruction, parseSetResumeAuthorityInstruction, parseUpdateMappingAndMetadataInstruction, type ParsedApproveAdminCachedInstruction, type ParsedCloseMintMapInstruction, type ParsedCreateMintMapInstruction, type ParsedFreezePriceInstruction, type ParsedInitializeInstruction, type ParsedRefreshChainlinkPriceInstruction, type ParsedRefreshPriceListInstruction, type ParsedRefreshPythLazerPriceInstruction, type ParsedResetTwapInstruction, type ParsedResumeChainlinkxPriceInstruction, type ParsedSetAdminCachedInstruction, type ParsedSetEmergencyCouncilInstruction, type ParsedSetResumeAuthorityInstruction, type ParsedUpdateMappingAndMetadataInstruction, } from "../instructions"; export const SCOPE_PROGRAM_ADDRESS = "HFn8GnPADiny6XqUoWE8uRPPxb29ikn4yTuPa9MF2fWJ" as Address<"HFn8GnPADiny6XqUoWE8uRPPxb29ikn4yTuPa9MF2fWJ">; export enum ScopeAccount { Configuration, MintsToScopeChains, OracleMappings, OraclePrices, OracleTwaps, TokenMetadatas, } export function identifyScopeAccount( account: { data: ReadonlyUint8Array } | ReadonlyUint8Array, ): ScopeAccount { const data = "data" in account ? account.data : account; if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([192, 79, 172, 30, 21, 173, 25, 43]), ), 0, ) ) { return ScopeAccount.Configuration; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([156, 236, 56, 20, 39, 141, 42, 183]), ), 0, ) ) { return ScopeAccount.MintsToScopeChains; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([40, 244, 110, 80, 255, 214, 243, 188]), ), 0, ) ) { return ScopeAccount.OracleMappings; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([89, 128, 118, 221, 6, 72, 180, 146]), ), 0, ) ) { return ScopeAccount.OraclePrices; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([192, 139, 27, 250, 53, 166, 101, 61]), ), 0, ) ) { return ScopeAccount.OracleTwaps; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([221, 107, 64, 103, 67, 0, 165, 22]), ), 0, ) ) { return ScopeAccount.TokenMetadatas; } throw new Error( "The provided account could not be identified as a scope account.", ); } export enum ScopeInstruction { Initialize, RefreshPriceList, RefreshChainlinkPrice, RefreshPythLazerPrice, UpdateMappingAndMetadata, ResetTwap, SetAdminCached, ApproveAdminCached, CreateMintMap, CloseMintMap, ResumeChainlinkxPrice, FreezePrice, SetEmergencyCouncil, SetResumeAuthority, } export function identifyScopeInstruction( instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array, ): ScopeInstruction { const data = "data" in instruction ? instruction.data : instruction; if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([175, 175, 109, 31, 13, 152, 155, 237]), ), 0, ) ) { return ScopeInstruction.Initialize; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([83, 186, 207, 131, 203, 254, 198, 130]), ), 0, ) ) { return ScopeInstruction.RefreshPriceList; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([97, 9, 20, 115, 72, 255, 4, 140]), ), 0, ) ) { return ScopeInstruction.RefreshChainlinkPrice; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([122, 47, 177, 133, 177, 35, 93, 118]), ), 0, ) ) { return ScopeInstruction.RefreshPythLazerPrice; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([158, 81, 149, 146, 206, 154, 91, 56]), ), 0, ) ) { return ScopeInstruction.UpdateMappingAndMetadata; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([101, 216, 28, 92, 154, 79, 49, 187]), ), 0, ) ) { return ScopeInstruction.ResetTwap; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([114, 14, 105, 205, 216, 148, 30, 75]), ), 0, ) ) { return ScopeInstruction.SetAdminCached; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([101, 149, 97, 58, 48, 79, 16, 105]), ), 0, ) ) { return ScopeInstruction.ApproveAdminCached; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([216, 218, 224, 60, 23, 31, 193, 243]), ), 0, ) ) { return ScopeInstruction.CreateMintMap; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([146, 212, 203, 239, 191, 104, 38, 102]), ), 0, ) ) { return ScopeInstruction.CloseMintMap; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([136, 48, 103, 146, 227, 97, 87, 108]), ), 0, ) ) { return ScopeInstruction.ResumeChainlinkxPrice; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([82, 182, 166, 239, 171, 188, 133, 14]), ), 0, ) ) { return ScopeInstruction.FreezePrice; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([182, 76, 39, 172, 127, 44, 38, 203]), ), 0, ) ) { return ScopeInstruction.SetEmergencyCouncil; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([191, 152, 68, 90, 221, 93, 245, 30]), ), 0, ) ) { return ScopeInstruction.SetResumeAuthority; } throw new Error( "The provided instruction could not be identified as a scope instruction.", ); } export type ParsedScopeInstruction = | ({ instructionType: ScopeInstruction.Initialize; } & ParsedInitializeInstruction) | ({ instructionType: ScopeInstruction.RefreshPriceList; } & ParsedRefreshPriceListInstruction) | ({ instructionType: ScopeInstruction.RefreshChainlinkPrice; } & ParsedRefreshChainlinkPriceInstruction) | ({ instructionType: ScopeInstruction.RefreshPythLazerPrice; } & ParsedRefreshPythLazerPriceInstruction) | ({ instructionType: ScopeInstruction.UpdateMappingAndMetadata; } & ParsedUpdateMappingAndMetadataInstruction) | ({ instructionType: ScopeInstruction.ResetTwap; } & ParsedResetTwapInstruction) | ({ instructionType: ScopeInstruction.SetAdminCached; } & ParsedSetAdminCachedInstruction) | ({ instructionType: ScopeInstruction.ApproveAdminCached; } & ParsedApproveAdminCachedInstruction) | ({ instructionType: ScopeInstruction.CreateMintMap; } & ParsedCreateMintMapInstruction) | ({ instructionType: ScopeInstruction.CloseMintMap; } & ParsedCloseMintMapInstruction) | ({ instructionType: ScopeInstruction.ResumeChainlinkxPrice; } & ParsedResumeChainlinkxPriceInstruction) | ({ instructionType: ScopeInstruction.FreezePrice; } & ParsedFreezePriceInstruction) | ({ instructionType: ScopeInstruction.SetEmergencyCouncil; } & ParsedSetEmergencyCouncilInstruction) | ({ instructionType: ScopeInstruction.SetResumeAuthority; } & ParsedSetResumeAuthorityInstruction); export function parseScopeInstruction( instruction: Instruction & InstructionWithData, ): ParsedScopeInstruction { const instructionType = identifyScopeInstruction(instruction); switch (instructionType) { case ScopeInstruction.Initialize: { assertIsInstructionWithAccounts(instruction); return { instructionType: ScopeInstruction.Initialize, ...parseInitializeInstruction(instruction), }; } case ScopeInstruction.RefreshPriceList: { assertIsInstructionWithAccounts(instruction); return { instructionType: ScopeInstruction.RefreshPriceList, ...parseRefreshPriceListInstruction(instruction), }; } case ScopeInstruction.RefreshChainlinkPrice: { assertIsInstructionWithAccounts(instruction); return { instructionType: ScopeInstruction.RefreshChainlinkPrice, ...parseRefreshChainlinkPriceInstruction(instruction), }; } case ScopeInstruction.RefreshPythLazerPrice: { assertIsInstructionWithAccounts(instruction); return { instructionType: ScopeInstruction.RefreshPythLazerPrice, ...parseRefreshPythLazerPriceInstruction(instruction), }; } case ScopeInstruction.UpdateMappingAndMetadata: { assertIsInstructionWithAccounts(instruction); return { instructionType: ScopeInstruction.UpdateMappingAndMetadata, ...parseUpdateMappingAndMetadataInstruction(instruction), }; } case ScopeInstruction.ResetTwap: { assertIsInstructionWithAccounts(instruction); return { instructionType: ScopeInstruction.ResetTwap, ...parseResetTwapInstruction(instruction), }; } case ScopeInstruction.SetAdminCached: { assertIsInstructionWithAccounts(instruction); return { instructionType: ScopeInstruction.SetAdminCached, ...parseSetAdminCachedInstruction(instruction), }; } case ScopeInstruction.ApproveAdminCached: { assertIsInstructionWithAccounts(instruction); return { instructionType: ScopeInstruction.ApproveAdminCached, ...parseApproveAdminCachedInstruction(instruction), }; } case ScopeInstruction.CreateMintMap: { assertIsInstructionWithAccounts(instruction); return { instructionType: ScopeInstruction.CreateMintMap, ...parseCreateMintMapInstruction(instruction), }; } case ScopeInstruction.CloseMintMap: { assertIsInstructionWithAccounts(instruction); return { instructionType: ScopeInstruction.CloseMintMap, ...parseCloseMintMapInstruction(instruction), }; } case ScopeInstruction.ResumeChainlinkxPrice: { assertIsInstructionWithAccounts(instruction); return { instructionType: ScopeInstruction.ResumeChainlinkxPrice, ...parseResumeChainlinkxPriceInstruction(instruction), }; } case ScopeInstruction.FreezePrice: { assertIsInstructionWithAccounts(instruction); return { instructionType: ScopeInstruction.FreezePrice, ...parseFreezePriceInstruction(instruction), }; } case ScopeInstruction.SetEmergencyCouncil: { assertIsInstructionWithAccounts(instruction); return { instructionType: ScopeInstruction.SetEmergencyCouncil, ...parseSetEmergencyCouncilInstruction(instruction), }; } case ScopeInstruction.SetResumeAuthority: { assertIsInstructionWithAccounts(instruction); return { instructionType: ScopeInstruction.SetResumeAuthority, ...parseSetResumeAuthorityInstruction(instruction), }; } default: throw new Error( `Unrecognized instruction type: ${instructionType as string}`, ); } }