generated from codama-idl/renderers-demo
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathwenTransferGuard.ts
More file actions
95 lines (87 loc) · 3.25 KB
/
wenTransferGuard.ts
File metadata and controls
95 lines (87 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
* 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 { containsBytes, fixEncoderSize, getBytesEncoder, type Address, type ReadonlyUint8Array } from '@solana/kit';
import {
type ParsedCreateGuardInstruction,
type ParsedExecuteInstruction,
type ParsedInitializeInstruction,
type ParsedUpdateGuardInstruction,
} from '../instructions';
export const WEN_TRANSFER_GUARD_PROGRAM_ADDRESS =
'LockdqYQ9X2kwtWB99ioSbxubAmEi8o9jqYwbXgrrRw' as Address<'LockdqYQ9X2kwtWB99ioSbxubAmEi8o9jqYwbXgrrRw'>;
export enum WenTransferGuardAccount {
GuardV1,
}
export function identifyWenTransferGuardAccount(
account: { data: ReadonlyUint8Array } | ReadonlyUint8Array,
): WenTransferGuardAccount {
const data = 'data' in account ? account.data : account;
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([185, 149, 156, 78, 245, 108, 172, 68])),
0,
)
) {
return WenTransferGuardAccount.GuardV1;
}
throw new Error('The provided account could not be identified as a wenTransferGuard account.');
}
export enum WenTransferGuardInstruction {
CreateGuard,
Execute,
Initialize,
UpdateGuard,
}
export function identifyWenTransferGuardInstruction(
instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array,
): WenTransferGuardInstruction {
const data = 'data' in instruction ? instruction.data : instruction;
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([251, 254, 17, 198, 219, 218, 154, 99])),
0,
)
) {
return WenTransferGuardInstruction.CreateGuard;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([105, 37, 101, 197, 75, 251, 102, 26])),
0,
)
) {
return WenTransferGuardInstruction.Execute;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([43, 34, 13, 49, 167, 88, 235, 235])),
0,
)
) {
return WenTransferGuardInstruction.Initialize;
}
if (
containsBytes(
data,
fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([51, 38, 175, 180, 25, 249, 39, 24])),
0,
)
) {
return WenTransferGuardInstruction.UpdateGuard;
}
throw new Error('The provided instruction could not be identified as a wenTransferGuard instruction.');
}
export type ParsedWenTransferGuardInstruction<TProgram extends string = 'LockdqYQ9X2kwtWB99ioSbxubAmEi8o9jqYwbXgrrRw'> =
| ({ instructionType: WenTransferGuardInstruction.CreateGuard } & ParsedCreateGuardInstruction<TProgram>)
| ({ instructionType: WenTransferGuardInstruction.Execute } & ParsedExecuteInstruction<TProgram>)
| ({ instructionType: WenTransferGuardInstruction.Initialize } & ParsedInitializeInstruction<TProgram>)
| ({ instructionType: WenTransferGuardInstruction.UpdateGuard } & ParsedUpdateGuardInstruction<TProgram>);