@robertprp/intents-sdk
Version:
Shogun Network Intent-based cross-chain swaps SDK
248 lines (240 loc) • 7.25 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 ParsedCancelDcaOrderInstruction,
type ParsedCancelLimitOrderInstruction,
type ParsedCollectProtocolFeesInstruction,
type ParsedCreateDcaOrderInstruction,
type ParsedCreateGuardInstruction,
type ParsedCreateLimitOrderInstruction,
type ParsedFulfillDcaOrderIntervalInstruction,
type ParsedFulfillLimitOrderInstruction,
type ParsedInitializeInstruction,
type ParsedSetAdminInstruction,
type ParsedSetAuctioneerPubKeyInstruction,
} from '../instructions/index.js';
export const SINGLE_CHAIN_GUARD_PROGRAM_ADDRESS =
'EaSKMioKTLtbFXVaMEmHjSdZDEoZHpSmQBu6NfsND87n' as Address<'EaSKMioKTLtbFXVaMEmHjSdZDEoZHpSmQBu6NfsND87n'>;
export enum SingleChainGuardAccount {
AdminSingleton,
DcaOrder,
Guard,
LimitOrder,
}
export function identifySingleChainGuardAccount(
account: { data: ReadonlyUint8Array } | ReadonlyUint8Array,
): SingleChainGuardAccount {
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 SingleChainGuardAccount.AdminSingleton;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([55, 1, 103, 253, 215, 66, 27, 57])),
0,
)
) {
return SingleChainGuardAccount.DcaOrder;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([54, 187, 84, 137, 192, 15, 74, 248])),
0,
)
) {
return SingleChainGuardAccount.Guard;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([137, 183, 212, 91, 115, 29, 141, 227])),
0,
)
) {
return SingleChainGuardAccount.LimitOrder;
}
throw new Error('The provided account could not be identified as a singleChainGuard account.');
}
export enum SingleChainGuardInstruction {
AcceptAdmin,
CancelDcaOrder,
CancelLimitOrder,
CollectProtocolFees,
CreateDcaOrder,
CreateGuard,
CreateLimitOrder,
FulfillDcaOrderInterval,
FulfillLimitOrder,
Initialize,
SetAdmin,
SetAuctioneerPubKey,
}
export function identifySingleChainGuardInstruction(
instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array,
): SingleChainGuardInstruction {
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 SingleChainGuardInstruction.AcceptAdmin;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([60, 161, 130, 157, 181, 55, 218, 163])),
0,
)
) {
return SingleChainGuardInstruction.CancelDcaOrder;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([132, 156, 132, 31, 67, 40, 232, 97])),
0,
)
) {
return SingleChainGuardInstruction.CancelLimitOrder;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([22, 67, 23, 98, 150, 178, 70, 220])),
0,
)
) {
return SingleChainGuardInstruction.CollectProtocolFees;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([95, 66, 166, 38, 170, 3, 150, 169])),
0,
)
) {
return SingleChainGuardInstruction.CreateDcaOrder;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([251, 254, 17, 198, 219, 218, 154, 99])),
0,
)
) {
return SingleChainGuardInstruction.CreateGuard;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([76, 161, 70, 122, 82, 20, 142, 75])),
0,
)
) {
return SingleChainGuardInstruction.CreateLimitOrder;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([15, 118, 183, 60, 46, 43, 243, 244])),
0,
)
) {
return SingleChainGuardInstruction.FulfillDcaOrderInterval;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([70, 1, 151, 197, 125, 110, 46, 244])),
0,
)
) {
return SingleChainGuardInstruction.FulfillLimitOrder;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([175, 175, 109, 31, 13, 152, 155, 237])),
0,
)
) {
return SingleChainGuardInstruction.Initialize;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([251, 163, 0, 52, 91, 194, 187, 92])),
0,
)
) {
return SingleChainGuardInstruction.SetAdmin;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([153, 39, 10, 108, 220, 0, 84, 47])),
0,
)
) {
return SingleChainGuardInstruction.SetAuctioneerPubKey;
}
throw new Error('The provided instruction could not be identified as a singleChainGuard instruction.');
}
export type ParsedSingleChainGuardInstruction<
TProgram extends string = 'EaSKMioKTLtbFXVaMEmHjSdZDEoZHpSmQBu6NfsND87n',
> =
| ({
instructionType: SingleChainGuardInstruction.AcceptAdmin;
} & ParsedAcceptAdminInstruction<TProgram>)
| ({
instructionType: SingleChainGuardInstruction.CancelDcaOrder;
} & ParsedCancelDcaOrderInstruction<TProgram>)
| ({
instructionType: SingleChainGuardInstruction.CancelLimitOrder;
} & ParsedCancelLimitOrderInstruction<TProgram>)
| ({
instructionType: SingleChainGuardInstruction.CollectProtocolFees;
} & ParsedCollectProtocolFeesInstruction<TProgram>)
| ({
instructionType: SingleChainGuardInstruction.CreateDcaOrder;
} & ParsedCreateDcaOrderInstruction<TProgram>)
| ({
instructionType: SingleChainGuardInstruction.CreateGuard;
} & ParsedCreateGuardInstruction<TProgram>)
| ({
instructionType: SingleChainGuardInstruction.CreateLimitOrder;
} & ParsedCreateLimitOrderInstruction<TProgram>)
| ({
instructionType: SingleChainGuardInstruction.FulfillDcaOrderInterval;
} & ParsedFulfillDcaOrderIntervalInstruction<TProgram>)
| ({
instructionType: SingleChainGuardInstruction.FulfillLimitOrder;
} & ParsedFulfillLimitOrderInstruction<TProgram>)
| ({
instructionType: SingleChainGuardInstruction.Initialize;
} & ParsedInitializeInstruction<TProgram>)
| ({
instructionType: SingleChainGuardInstruction.SetAdmin;
} & ParsedSetAdminInstruction<TProgram>)
| ({
instructionType: SingleChainGuardInstruction.SetAuctioneerPubKey;
} & ParsedSetAuctioneerPubKeyInstruction<TProgram>);