-
Notifications
You must be signed in to change notification settings - Fork 0
/
constants.ts
338 lines (328 loc) · 10 KB
/
constants.ts
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
import { PublicKey } from '@solana/web3.js'
import { ErrorCatalog } from '../types.js'
// CONSTANTS from raydium-ui... might be a good idea to fetch those from their github?
export const SYSTEM_PROGRAM_ID = new PublicKey(
'11111111111111111111111111111111',
)
export const TOKEN_PROGRAM_ID = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
export const TOKEN_PROGRAM_ID_PK = new PublicKey(TOKEN_PROGRAM_ID)
export const MEMO_PROGRAM_ID = new PublicKey(
'Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo',
)
export const RENT_PROGRAM_ID = new PublicKey(
'SysvarRent111111111111111111111111111111111',
)
export const CLOCK_PROGRAM_ID = new PublicKey(
'SysvarC1ock11111111111111111111111111111111',
)
export const ASSOCIATED_TOKEN_PROGRAM_ID = new PublicKey(
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
)
export const WRAPPED_SOL_TOKEN_ADDRESS =
'So11111111111111111111111111111111111111112'
export const usdDecimals = 6
export const MAX_TIMER_INTEGER = 2 ** 32 / 2 - 1
// @note: Taken from: https://github.com/solana-labs/solana/blob/master/sdk/src/transaction/error.rs#L13
export enum TransactionErrorType {
AccountInUse,
AccountLoadedTwice,
AccountNotFound,
ProgramAccountNotFound,
InsufficientFundsForFee,
InvalidAccountForFee,
AlreadyProcessed,
BlockhashNotFound,
InstructionError,
CallChainTooDeep,
MissingSignatureForFee,
InvalidAccountIndex,
SignatureFailure,
InvalidProgramForExecution,
SanitizeFailure,
ClusterMaintenance,
AccountBorrowOutstanding,
WouldExceedMaxBlockCostLimit,
UnsupportedVersion,
InvalidWritableAccount,
WouldExceedMaxAccountCostLimit,
WouldExceedMaxAccountDataCostLimit,
TooManyAccountLocks,
AddressLookupTableNotFound,
InvalidAddressLookupTableOwner,
InvalidAddressLookupTableData,
InvalidAddressLookupTableIndex,
InvalidRentPayingAccount,
WouldExceedMaxVoteCostLimit,
}
// @note: Taken from: https://github.com/solana-labs/solana/blob/master/sdk/program/src/program_error.rs#L12
export enum ProgramErrorType {
Custom,
InvalidArgument,
InvalidInstructionData,
InvalidAccountData,
AccountDataTooSmall,
InsufficientFunds,
IncorrectProgramId,
MissingRequiredSignature,
AccountAlreadyInitialized,
UninitializedAccount,
NotEnoughAccountKeys,
AccountBorrowFailed,
MaxSeedLengthExceeded,
InvalidSeeds,
BorshIoError,
AccountNotRentExempt,
UnsupportedSysvar,
IllegalOwner,
AccountsDataBudgetExceeded,
ActiveVoteAccountClose,
}
export const transactionErrorCatalog: ErrorCatalog = [
{
code: TransactionErrorType.AccountInUse,
name: 'AccountInUse',
msg: 'Account in use',
},
{
code: TransactionErrorType.AccountLoadedTwice,
name: 'AccountLoadedTwice',
msg: 'Account loaded twice',
},
{
code: TransactionErrorType.AccountNotFound,
name: 'AccountNotFound',
msg: 'Attempt to debit an account but found no record of a prior credit.',
},
{
code: TransactionErrorType.ProgramAccountNotFound,
name: 'ProgramAccountNotFound',
msg: 'Attempt to load a program that does not exist',
},
{
code: TransactionErrorType.InsufficientFundsForFee,
name: 'InsufficientFundsForFee',
msg: 'Insufficient funds for fee',
},
{
code: TransactionErrorType.InvalidAccountForFee,
name: 'InvalidAccountForFee',
msg: 'This account may not be used to pay transaction fees',
},
{
code: TransactionErrorType.AlreadyProcessed,
name: 'AlreadyProcessed',
msg: 'This transaction has already been processed',
},
{
code: TransactionErrorType.BlockhashNotFound,
name: 'BlockhashNotFound',
msg: 'Blockhash not found',
},
{
code: TransactionErrorType.InstructionError,
name: 'InstructionError',
msg: 'Error processing Instruction {0}: {1}',
},
{
code: TransactionErrorType.CallChainTooDeep,
name: 'CallChainTooDeep',
msg: 'Loader call chain is too deep',
},
{
code: TransactionErrorType.MissingSignatureForFee,
name: 'MissingSignatureForFee',
msg: 'Transaction requires a fee but has no signature present',
},
{
code: TransactionErrorType.InvalidAccountIndex,
name: 'InvalidAccountIndex',
msg: 'Transaction contains an invalid account reference',
},
{
code: TransactionErrorType.SignatureFailure,
name: 'SignatureFailure',
msg: 'Transaction did not pass signature verification',
},
{
code: TransactionErrorType.InvalidProgramForExecution,
name: 'InvalidProgramForExecution',
msg: 'This program may not be used for executing instructions',
},
{
code: TransactionErrorType.SanitizeFailure,
name: 'SanitizeFailure',
msg: 'Transaction failed to sanitize accounts offsets correctly',
},
{
code: TransactionErrorType.ClusterMaintenance,
name: 'ClusterMaintenance',
msg: 'Transactions are currently disabled due to cluster maintenance',
},
{
code: TransactionErrorType.AccountBorrowOutstanding,
name: 'AccountBorrowOutstanding',
msg: 'Transaction processing left an account with an outstanding borrowed reference',
},
{
code: TransactionErrorType.WouldExceedMaxBlockCostLimit,
name: 'WouldExceedMaxBlockCostLimit',
msg: 'Transaction would exceed max Block Cost Limit',
},
{
code: TransactionErrorType.UnsupportedVersion,
name: 'UnsupportedVersion',
msg: 'Transaction version is unsupported',
},
{
code: TransactionErrorType.InvalidWritableAccount,
name: 'InvalidWritableAccount',
msg: 'Transaction loads a writable account that cannot be written',
},
{
code: TransactionErrorType.WouldExceedMaxAccountCostLimit,
name: 'WouldExceedMaxAccountCostLimit',
msg: 'Transaction would exceed max account limit within the block',
},
{
code: TransactionErrorType.WouldExceedMaxAccountDataCostLimit,
name: 'WouldExceedMaxAccountDataCostLimit',
msg: 'Transaction would exceed max account data limit within the block',
},
{
code: TransactionErrorType.TooManyAccountLocks,
name: 'TooManyAccountLocks',
msg: 'Transaction locked too many accounts',
},
{
code: TransactionErrorType.AddressLookupTableNotFound,
name: 'AddressLookupTableNotFound',
msg: "Transaction loads an address table account that doesn't exist",
},
{
code: TransactionErrorType.InvalidAddressLookupTableOwner,
name: 'InvalidAddressLookupTableOwner',
msg: 'Transaction loads an address table account with an invalid owner',
},
{
code: TransactionErrorType.InvalidAddressLookupTableData,
name: 'InvalidAddressLookupTableData',
msg: 'Transaction loads an address table account with invalid data',
},
{
code: TransactionErrorType.InvalidAddressLookupTableIndex,
name: 'InvalidAddressLookupTableIndex',
msg: 'Transaction address table lookup uses an invalid index',
},
{
code: TransactionErrorType.InvalidRentPayingAccount,
name: 'InvalidRentPayingAccount',
msg: 'Transaction leaves an account with data with a lower balance than rent-exempt minimum',
},
{
code: TransactionErrorType.WouldExceedMaxVoteCostLimit,
name: 'WouldExceedMaxVoteCostLimit',
msg: 'Transaction would exceed max Vote Cost Limit',
},
]
export const programErrorCatalog: ErrorCatalog = [
{
code: ProgramErrorType.Custom,
name: 'Custom',
msg: 'Custom program error: {0:#x}',
},
{
code: ProgramErrorType.InvalidArgument,
name: 'InvalidArgument',
msg: 'The arguments provided to a program instruction where invalid',
},
{
code: ProgramErrorType.InvalidInstructionData,
name: 'InvalidInstructionData',
msg: "An instruction's data contents was invalid",
},
{
code: ProgramErrorType.InvalidAccountData,
name: 'InvalidAccountData',
msg: "An account's data contents was invalid",
},
{
code: ProgramErrorType.AccountDataTooSmall,
name: 'AccountDataTooSmall',
msg: "An account's data was too small",
},
{
code: ProgramErrorType.InsufficientFunds,
name: 'InsufficientFunds',
msg: "An account's balance was too small to complete the instruction",
},
{
code: ProgramErrorType.IncorrectProgramId,
name: 'IncorrectProgramId',
msg: 'The account did not have the expected program id',
},
{
code: ProgramErrorType.MissingRequiredSignature,
name: 'MissingRequiredSignature',
msg: 'A signature was required but not found',
},
{
code: ProgramErrorType.AccountAlreadyInitialized,
name: 'AccountAlreadyInitialized',
msg: 'An initialize instruction was sent to an account that has already been initialized',
},
{
code: ProgramErrorType.UninitializedAccount,
name: 'UninitializedAccount',
msg: "An attempt to operate on an account that hasn't been initialized",
},
{
code: ProgramErrorType.NotEnoughAccountKeys,
name: 'NotEnoughAccountKeys',
msg: 'The instruction expected additional account keys',
},
{
code: ProgramErrorType.AccountBorrowFailed,
name: 'AccountBorrowFailed',
msg: 'Failed to borrow a reference to account data, already borrowed',
},
{
code: ProgramErrorType.MaxSeedLengthExceeded,
name: 'MaxSeedLengthExceeded',
msg: 'Length of the seed is too long for address generation',
},
{
code: ProgramErrorType.InvalidSeeds,
name: 'InvalidSeeds',
msg: 'Provided seeds do not result in a valid address',
},
{
code: ProgramErrorType.BorshIoError,
name: 'BorshIoError',
msg: 'IO Error: {0}',
},
{
code: ProgramErrorType.AccountNotRentExempt,
name: 'AccountNotRentExempt',
msg: 'An account does not have enough lamports to be rent-exempt',
},
{
code: ProgramErrorType.UnsupportedSysvar,
name: 'UnsupportedSysvar',
msg: 'Unsupported sysvar',
},
{
code: ProgramErrorType.IllegalOwner,
name: 'IllegalOwner',
msg: 'Provided owner is not allowed',
},
{
code: ProgramErrorType.AccountsDataBudgetExceeded,
name: 'AccountsDataBudgetExceeded',
msg: 'Requested account data allocation exceeded the accounts data budget',
},
{
code: ProgramErrorType.ActiveVoteAccountClose,
name: 'ActiveVoteAccountClose',
msg: 'Cannot close vote account unless it stopped voting at least one full epoch ago',
},
]