UNPKG

@macalinao/clients-quarry

Version:

TypeScript client for Quarry protocol programs

104 lines (96 loc) 2.9 kB
/** * 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 type { Address, ReadonlyUint8Array } from "@solana/kit"; import type { ParsedCreateRedeemerInstruction, ParsedRedeemAllTokensInstruction, ParsedRedeemTokensInstruction, } from "../instructions/index.js"; import { containsBytes, fixEncoderSize, getBytesEncoder } from "@solana/kit"; export const QUARRY_REDEEMER_PROGRAM_ADDRESS = "QRDxhMw1P2NEfiw5mYXG79bwfgHTdasY2xNP76XSea9" as Address<"QRDxhMw1P2NEfiw5mYXG79bwfgHTdasY2xNP76XSea9">; export enum QuarryRedeemerAccount { Redeemer = 0, } export function identifyQuarryRedeemerAccount( account: { data: ReadonlyUint8Array } | ReadonlyUint8Array, ): QuarryRedeemerAccount { const data = "data" in account ? account.data : account; if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([41, 191, 197, 8, 98, 64, 17, 99]), ), 0, ) ) { return QuarryRedeemerAccount.Redeemer; } throw new Error( "The provided account could not be identified as a quarryRedeemer account.", ); } export enum QuarryRedeemerInstruction { CreateRedeemer = 0, RedeemTokens = 1, RedeemAllTokens = 2, } export function identifyQuarryRedeemerInstruction( instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array, ): QuarryRedeemerInstruction { const data = "data" in instruction ? instruction.data : instruction; if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([137, 228, 81, 63, 209, 33, 131, 195]), ), 0, ) ) { return QuarryRedeemerInstruction.CreateRedeemer; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([246, 98, 134, 41, 152, 33, 120, 69]), ), 0, ) ) { return QuarryRedeemerInstruction.RedeemTokens; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([68, 38, 47, 47, 226, 176, 31, 48]), ), 0, ) ) { return QuarryRedeemerInstruction.RedeemAllTokens; } throw new Error( "The provided instruction could not be identified as a quarryRedeemer instruction.", ); } export type ParsedQuarryRedeemerInstruction< TProgram extends string = "QRDxhMw1P2NEfiw5mYXG79bwfgHTdasY2xNP76XSea9", > = | ({ instructionType: QuarryRedeemerInstruction.CreateRedeemer; } & ParsedCreateRedeemerInstruction<TProgram>) | ({ instructionType: QuarryRedeemerInstruction.RedeemTokens; } & ParsedRedeemTokensInstruction<TProgram>) | ({ instructionType: QuarryRedeemerInstruction.RedeemAllTokens; } & ParsedRedeemAllTokensInstruction<TProgram>);