-
Notifications
You must be signed in to change notification settings - Fork 2
/
spl_token_instruction.h
153 lines (129 loc) · 4.5 KB
/
spl_token_instruction.h
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#pragma once
#include "sol/print_config.h"
#include "sol/transaction_summary.h"
#include "spl/token.h"
#define SplTokenBody(b) Token_TokenInstruction_Token_##b##_Body
#define SplTokenKind(b) Token_TokenInstruction_##b
#define SplTokenInstructionKind Token_TokenInstruction_Tag
typedef struct SplTokenMultisigners {
const Pubkey* first;
uint8_t count;
} SplTokenMultisigners;
typedef enum {
SplTokenSignKindSingle,
SplTokenSignKindMulti,
} SplTokenSignKind;
typedef struct {
SplTokenSignKind kind;
union {
struct {
const Pubkey* signer;
} single;
struct {
const Pubkey* account;
SplTokenMultisigners signers;
} multi;
};
} SplTokenSign;
extern const Pubkey spl_token_program_id;
typedef struct SplTokenInitializeMintInfo {
const Pubkey* mint_account;
const Pubkey* mint_authority;
const Pubkey* freeze_authority;
uint8_t decimals;
} SplTokenInitializeMintInfo;
typedef struct SplTokenInitializeAccountInfo {
const Pubkey* token_account;
const Pubkey* mint_account;
const Pubkey* owner;
} SplTokenInitializeAccountInfo;
typedef struct SplTokenInitializeMultisigInfo {
const Pubkey* multisig_account;
SplTokenMultisigners signers;
SplTokenBody(InitializeMultisig) body;
} SplTokenInitializeMultisigInfo;
typedef struct SplTokenTransferInfo {
const Pubkey* src_account;
const Pubkey* dest_account;
const Pubkey* mint_account;
SplTokenSign sign;
SplTokenBody(TransferChecked) body;
} SplTokenTransferInfo;
typedef struct SplTokenApproveInfo {
const Pubkey* token_account;
const Pubkey* delegate;
const Pubkey* mint_account;
SplTokenSign sign;
SplTokenBody(ApproveChecked) body;
} SplTokenApproveInfo;
typedef struct SplTokenRevokeInfo {
const Pubkey* token_account;
SplTokenSign sign;
} SplTokenRevokeInfo;
typedef struct SplTokenSetAuthorityInfo {
const Pubkey* account;
const Pubkey* new_authority;
Token_AuthorityType authority_type;
SplTokenSign sign;
} SplTokenSetAuthorityInfo;
typedef struct SplTokenMintToInfo {
const Pubkey* mint_account;
const Pubkey* token_account;
SplTokenSign sign;
SplTokenBody(MintToChecked) body;
} SplTokenMintToInfo;
typedef struct SplTokenBurnInfo {
const Pubkey* token_account;
const Pubkey* mint_account;
SplTokenSign sign;
SplTokenBody(BurnChecked) body;
} SplTokenBurnInfo;
typedef struct SplTokenCloseAccountInfo {
const Pubkey* token_account;
const Pubkey* dest_account;
SplTokenSign sign;
} SplTokenCloseAccountInfo;
typedef struct SplTokenFreezeAccountInfo {
const Pubkey* token_account;
const Pubkey* mint_account;
SplTokenSign sign;
} SplTokenFreezeAccountInfo;
typedef struct SplTokenThawAccountInfo {
const Pubkey* token_account;
const Pubkey* mint_account;
SplTokenSign sign;
} SplTokenThawAccountInfo;
typedef struct SplTokenSyncNativeInfo {
const Pubkey* token_account;
} SplTokenSyncNativeInfo;
typedef struct SplTokenInfo {
SplTokenInstructionKind kind;
union {
SplTokenInitializeMintInfo initialize_mint;
SplTokenInitializeAccountInfo initialize_account;
SplTokenInitializeMultisigInfo initialize_multisig;
SplTokenTransferInfo transfer;
SplTokenApproveInfo approve;
SplTokenRevokeInfo revoke;
SplTokenSetAuthorityInfo set_owner;
SplTokenMintToInfo mint_to;
SplTokenBurnInfo burn;
SplTokenCloseAccountInfo close_account;
SplTokenFreezeAccountInfo freeze_account;
SplTokenThawAccountInfo thaw_account;
SplTokenSyncNativeInfo sync_native;
};
} SplTokenInfo;
int parse_spl_token_instructions(const Instruction* instruction,
const MessageHeader* header,
SplTokenInfo* info);
int print_spl_token_info(const SplTokenInfo* info, const PrintConfig* print_config);
void summary_item_set_multisig_m_of_n(SummaryItem* item, uint8_t m, uint8_t n);
#define SplTokenOptionPubkeyKind Token_COption_Pubkey_Tag
#define SplTokenToOptionPubkeyKind(k) Token_COption_Pubkey_##k##_Pubkey
#define SplTokenOptionPubkeyBody Token_COption_Pubkey_Token_Some_Body_Pubkey
#define SplTokenOptionPubkey Token_COption_Pubkey
const Pubkey* spl_token_option_pubkey_get(const SplTokenOptionPubkey* option_pubkey);
int print_spl_token_transfer_info(const SplTokenTransferInfo* info,
const PrintConfig* print_config,
bool primary);