@robertprp/intents-sdk
Version:
Shogun Network Intent-based cross-chain swaps SDK
238 lines (230 loc) • 7.03 kB
text/typescript
/**
* 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 } from '@solana/kit';
import { containsBytes, fixEncoderSize, getBytesEncoder, type ReadonlyUint8Array } from '@solana/kit';
import {
type ParsedAcceptAdminInstruction,
type ParsedCancelOrderInstruction,
type ParsedClaimTokensInstruction,
type ParsedCollectProtocolFeesInstruction,
type ParsedCreateGuardInstruction,
type ParsedCreateOrderInstruction,
type ParsedInitializeInstruction,
type ParsedPreStartOrderExecutionInstruction,
type ParsedSetAdminInstruction,
type ParsedSetAuctioneerPubKeyInstruction,
type ParsedStartOrderExecutionAfterSwapInstruction,
type ParsedStartOrderExecutionInstruction,
} from '../instructions/index.js';
export const SOURCE_CHAIN_GUARD_PROGRAM_ADDRESS =
'43cctGU9QJ4WEPzLoNEvo3TPiv6nMUG9puN2pXQSnB6V' as Address<'43cctGU9QJ4WEPzLoNEvo3TPiv6nMUG9puN2pXQSnB6V'>;
export enum SourceChainGuardAccount {
AdminSingleton,
Guard,
Order,
}
export function identifySourceChainGuardAccount(
account: { data: ReadonlyUint8Array } | ReadonlyUint8Array,
): SourceChainGuardAccount {
const data = 'data' in account ? account.data : account;
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([179, 22, 254, 245, 204, 230, 222, 194])),
0,
)
) {
return SourceChainGuardAccount.AdminSingleton;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([54, 187, 84, 137, 192, 15, 74, 248])),
0,
)
) {
return SourceChainGuardAccount.Guard;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([134, 173, 223, 185, 77, 86, 28, 51])),
0,
)
) {
return SourceChainGuardAccount.Order;
}
throw new Error('The provided account could not be identified as a sourceChainGuard account.');
}
export enum SourceChainGuardInstruction {
AcceptAdmin,
CancelOrder,
ClaimTokens,
CollectProtocolFees,
CreateGuard,
CreateOrder,
Initialize,
PreStartOrderExecution,
SetAdmin,
SetAuctioneerPubKey,
StartOrderExecution,
StartOrderExecutionAfterSwap,
}
export function identifySourceChainGuardInstruction(
instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array,
): SourceChainGuardInstruction {
const data = 'data' in instruction ? instruction.data : instruction;
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([112, 42, 45, 90, 116, 181, 13, 170])),
0,
)
) {
return SourceChainGuardInstruction.AcceptAdmin;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([95, 129, 237, 240, 8, 49, 223, 132])),
0,
)
) {
return SourceChainGuardInstruction.CancelOrder;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([108, 216, 210, 231, 0, 212, 42, 64])),
0,
)
) {
return SourceChainGuardInstruction.ClaimTokens;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([22, 67, 23, 98, 150, 178, 70, 220])),
0,
)
) {
return SourceChainGuardInstruction.CollectProtocolFees;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([251, 254, 17, 198, 219, 218, 154, 99])),
0,
)
) {
return SourceChainGuardInstruction.CreateGuard;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([141, 54, 37, 207, 237, 210, 250, 215])),
0,
)
) {
return SourceChainGuardInstruction.CreateOrder;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([175, 175, 109, 31, 13, 152, 155, 237])),
0,
)
) {
return SourceChainGuardInstruction.Initialize;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([69, 230, 54, 217, 254, 93, 181, 32])),
0,
)
) {
return SourceChainGuardInstruction.PreStartOrderExecution;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([251, 163, 0, 52, 91, 194, 187, 92])),
0,
)
) {
return SourceChainGuardInstruction.SetAdmin;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([153, 39, 10, 108, 220, 0, 84, 47])),
0,
)
) {
return SourceChainGuardInstruction.SetAuctioneerPubKey;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([38, 237, 19, 225, 182, 31, 246, 143])),
0,
)
) {
return SourceChainGuardInstruction.StartOrderExecution;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([142, 117, 45, 141, 169, 107, 117, 209])),
0,
)
) {
return SourceChainGuardInstruction.StartOrderExecutionAfterSwap;
}
throw new Error('The provided instruction could not be identified as a sourceChainGuard instruction.');
}
export type ParsedSourceChainGuardInstruction<
TProgram extends string = '43cctGU9QJ4WEPzLoNEvo3TPiv6nMUG9puN2pXQSnB6V',
> =
| ({
instructionType: SourceChainGuardInstruction.AcceptAdmin;
} & ParsedAcceptAdminInstruction<TProgram>)
| ({
instructionType: SourceChainGuardInstruction.CancelOrder;
} & ParsedCancelOrderInstruction<TProgram>)
| ({
instructionType: SourceChainGuardInstruction.ClaimTokens;
} & ParsedClaimTokensInstruction<TProgram>)
| ({
instructionType: SourceChainGuardInstruction.CollectProtocolFees;
} & ParsedCollectProtocolFeesInstruction<TProgram>)
| ({
instructionType: SourceChainGuardInstruction.CreateGuard;
} & ParsedCreateGuardInstruction<TProgram>)
| ({
instructionType: SourceChainGuardInstruction.CreateOrder;
} & ParsedCreateOrderInstruction<TProgram>)
| ({
instructionType: SourceChainGuardInstruction.Initialize;
} & ParsedInitializeInstruction<TProgram>)
| ({
instructionType: SourceChainGuardInstruction.PreStartOrderExecution;
} & ParsedPreStartOrderExecutionInstruction<TProgram>)
| ({
instructionType: SourceChainGuardInstruction.SetAdmin;
} & ParsedSetAdminInstruction<TProgram>)
| ({
instructionType: SourceChainGuardInstruction.SetAuctioneerPubKey;
} & ParsedSetAuctioneerPubKeyInstruction<TProgram>)
| ({
instructionType: SourceChainGuardInstruction.StartOrderExecution;
} & ParsedStartOrderExecutionInstruction<TProgram>)
| ({
instructionType: SourceChainGuardInstruction.StartOrderExecutionAfterSwap;
} & ParsedStartOrderExecutionAfterSwapInstruction<TProgram>);