@@ -315,79 +315,81 @@ export function AddressLookupTables(tables: Record<string, string[]>) {
315
315
}
316
316
317
317
export const PROGRAMS = {
318
- System : idl . defineIDL ( SystemIDL ) ,
319
- Token : idl . defineIDL ( TokenIDL ) ,
320
- Token2022 : idl . defineIDL ( Token2022IDL ) ,
321
- ALT : idl . defineIDL ( ALTIDL ) ,
322
- ComputeBudget : idl . defineIDL ( ComputeBudgetIDL ) ,
323
- Config : idl . defineIDL ( ConfigIDL ) ,
324
- Memo : idl . defineIDL ( MemoIDL ) ,
318
+ ... idl . defineIDL ( SystemIDL ) ,
319
+ ... idl . defineIDL ( TokenIDL ) ,
320
+ ... idl . defineIDL ( Token2022IDL ) ,
321
+ ... idl . defineIDL ( ALTIDL ) ,
322
+ ... idl . defineIDL ( ComputeBudgetIDL ) ,
323
+ ... idl . defineIDL ( ConfigIDL ) ,
324
+ ... idl . defineIDL ( MemoIDL ) ,
325
325
} ;
326
326
// Old API compat
327
- export const sys = PROGRAMS . System . system . instructions . encoders ;
328
- export const token = PROGRAMS . Token . token . instructions . encoders ;
327
+ export const sys = PROGRAMS . system . program . instructions . encoders ;
328
+ export const token = PROGRAMS . token . program . instructions . encoders ;
329
329
// TODO: The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.
330
- export const token2022 = PROGRAMS . Token2022 [ 'token-2022' ] . instructions . encoders as any ;
331
- export const associatedToken = PROGRAMS . Token . associatedToken . instructions . encoders ;
330
+ export const token2022 = PROGRAMS [ 'token-2022' ] . program . instructions . encoders as any ;
331
+ export const associatedToken =
332
+ PROGRAMS . token . additionalPrograms . associatedToken . instructions . encoders ;
332
333
333
- export const SYS_PROGRAM = PROGRAMS . System . system . contract ;
334
- export const TOKEN_PROGRAM = PROGRAMS . Token . token . contract ;
335
- export const TOKEN_PROGRAM2022 = PROGRAMS . Token2022 [ 'token-2022' ] . contract ;
336
- export const ASSOCIATED_TOKEN_PROGRAM = PROGRAMS . Token . associatedToken . contract ;
334
+ export const SYS_PROGRAM = PROGRAMS . system . program . contract ;
335
+ export const TOKEN_PROGRAM = PROGRAMS . token . program . contract ;
336
+ export const TOKEN_PROGRAM2022 = PROGRAMS [ 'token-2022' ] . program . contract ;
337
+ export const ASSOCIATED_TOKEN_PROGRAM = PROGRAMS . token . additionalPrograms . associatedToken . contract ;
337
338
338
- export const tokenAddress = PROGRAMS . Token . associatedToken . pdas . associatedToken ;
339
- export const TokenAccount = PROGRAMS . Token . token . accounts . decoder ;
340
- export const AddressTableLookupData = PROGRAMS . ALT . addressLookupTable . accounts . decoder ;
339
+ export const tokenAddress = PROGRAMS . token . additionalPrograms . associatedToken . pdas . associatedToken ;
340
+ export const TokenAccount = PROGRAMS . token . program . accounts . decoder ;
341
+ export const AddressTableLookupData = PROGRAMS . addressLookupTable . program . accounts . decoder ;
341
342
342
343
export const isOnCurve = idl . isOnCurve ;
343
344
export const programAddress = idl . programAddress ;
344
345
345
346
const TOKENS_ENCODE : Record < string , any > = {
346
- [ TOKEN_PROGRAM ] : PROGRAMS . Token . token . instructions . encoders ,
347
- [ TOKEN_PROGRAM2022 ] : PROGRAMS . Token2022 [ 'token-2022' ] . instructions . encoders ,
347
+ [ TOKEN_PROGRAM ] : PROGRAMS . token . program . instructions . encoders ,
348
+ [ TOKEN_PROGRAM2022 ] : PROGRAMS [ 'token-2022' ] . program . instructions . encoders ,
348
349
} ;
349
350
350
351
const ACCOUNTS_DECODE : Record < string , any > = {
351
- [ SYS_PROGRAM ] : PROGRAMS . System . system . accounts . decoder ,
352
- [ TOKEN_PROGRAM ] : PROGRAMS . Token . token . accounts . decoder ,
353
- [ TOKEN_PROGRAM2022 ] : PROGRAMS . Token2022 [ 'token-2022' ] . accounts . decoder ,
354
- [ ASSOCIATED_TOKEN_PROGRAM ] : PROGRAMS . Token . associatedToken . accounts . decoder ,
355
- [ PROGRAMS . ALT . addressLookupTable . contract ] : PROGRAMS . ALT . addressLookupTable . accounts . decoder ,
356
- [ PROGRAMS . ComputeBudget . computeBudget . contract ] :
357
- PROGRAMS . ComputeBudget . computeBudget . accounts . decoder ,
358
- [ PROGRAMS . Config . solanaConfig . contract ] : PROGRAMS . Config . solanaConfig . accounts . decoder ,
359
- [ PROGRAMS . Memo . memo . contract ] : PROGRAMS . Memo . memo . accounts . decoder ,
352
+ [ SYS_PROGRAM ] : PROGRAMS . system . program . accounts . decoder ,
353
+ [ TOKEN_PROGRAM ] : PROGRAMS . token . program . accounts . decoder ,
354
+ [ TOKEN_PROGRAM2022 ] : PROGRAMS [ 'token-2022' ] . program . accounts . decoder ,
355
+ [ ASSOCIATED_TOKEN_PROGRAM ] : PROGRAMS . token . additionalPrograms . associatedToken . accounts . decoder ,
356
+ [ PROGRAMS . addressLookupTable . program . contract ] :
357
+ PROGRAMS . addressLookupTable . program . accounts . decoder ,
358
+ [ PROGRAMS . computeBudget . program . contract ] : PROGRAMS . computeBudget . program . accounts . decoder ,
359
+ [ PROGRAMS . solanaConfig . program . contract ] : PROGRAMS . solanaConfig . program . accounts . decoder ,
360
+ [ PROGRAMS . memo . program . contract ] : PROGRAMS . memo . program . accounts . decoder ,
360
361
} ;
361
362
export function decodeAccount ( contract : string , data : Bytes ) : unknown {
362
363
if ( ACCOUNTS_DECODE [ contract ] === undefined ) throw new Error ( 'unknown contract' ) ;
363
364
return removeUndefined ( ACCOUNTS_DECODE [ contract ] ( data ) ) ;
364
365
}
365
366
366
367
const REGISTRY : Record < string , any > = {
367
- [ SYS_PROGRAM ] : PROGRAMS . System . system . instructions . decoder ,
368
- [ TOKEN_PROGRAM ] : PROGRAMS . Token . token . instructions . decoder ,
369
- [ TOKEN_PROGRAM2022 ] : PROGRAMS . Token2022 [ 'token-2022' ] . instructions . decoder ,
370
- [ ASSOCIATED_TOKEN_PROGRAM ] : PROGRAMS . Token . associatedToken . instructions . decoder ,
371
- [ PROGRAMS . ALT . addressLookupTable . contract ] : PROGRAMS . ALT . addressLookupTable . instructions . decoder ,
372
- [ PROGRAMS . ComputeBudget . computeBudget . contract ] :
373
- PROGRAMS . ComputeBudget . computeBudget . instructions . decoder ,
374
- [ PROGRAMS . Config . solanaConfig . contract ] : PROGRAMS . Config . solanaConfig . instructions . decoder ,
375
- [ PROGRAMS . Memo . memo . contract ] : PROGRAMS . Memo . memo . instructions . decoder ,
368
+ [ SYS_PROGRAM ] : PROGRAMS . system . program . instructions . decoder ,
369
+ [ TOKEN_PROGRAM ] : PROGRAMS . token . program . instructions . decoder ,
370
+ [ TOKEN_PROGRAM2022 ] : PROGRAMS [ 'token-2022' ] . program . instructions . decoder ,
371
+ [ ASSOCIATED_TOKEN_PROGRAM ] :
372
+ PROGRAMS . token . additionalPrograms . associatedToken . instructions . decoder ,
373
+ [ PROGRAMS . addressLookupTable . program . contract ] :
374
+ PROGRAMS . addressLookupTable . program . instructions . decoder ,
375
+ [ PROGRAMS . computeBudget . program . contract ] : PROGRAMS . computeBudget . program . instructions . decoder ,
376
+ [ PROGRAMS . solanaConfig . program . contract ] : PROGRAMS . solanaConfig . program . instructions . decoder ,
377
+ [ PROGRAMS . memo . program . contract ] : PROGRAMS . memo . program . instructions . decoder ,
376
378
} ;
377
379
export function parseInstruction ( instruction : Instruction ) : unknown {
378
380
if ( REGISTRY [ instruction . program ] === undefined ) throw new Error ( 'unknown contract' ) ;
379
381
return removeUndefined ( REGISTRY [ instruction . program ] ( instruction ) ) ;
380
382
}
381
383
382
384
export const CONTRACTS : Record < string , any > = {
383
- [ SYS_PROGRAM ] : PROGRAMS . System . system ,
384
- [ TOKEN_PROGRAM ] : PROGRAMS . Token . token ,
385
- [ TOKEN_PROGRAM2022 ] : PROGRAMS . Token2022 [ 'token-2022' ] ,
386
- [ ASSOCIATED_TOKEN_PROGRAM ] : PROGRAMS . Token . associatedToken ,
387
- [ PROGRAMS . ALT . addressLookupTable . contract ] : PROGRAMS . ALT . addressLookupTable ,
388
- [ PROGRAMS . ComputeBudget . computeBudget . contract ] : PROGRAMS . ComputeBudget . computeBudget ,
389
- [ PROGRAMS . Config . solanaConfig . contract ] : PROGRAMS . Config . solanaConfig ,
390
- [ PROGRAMS . Memo . memo . contract ] : PROGRAMS . Memo . memo ,
385
+ [ SYS_PROGRAM ] : PROGRAMS . system . program ,
386
+ [ TOKEN_PROGRAM ] : PROGRAMS . token . program ,
387
+ [ TOKEN_PROGRAM2022 ] : PROGRAMS [ 'token-2022' ] . program ,
388
+ [ ASSOCIATED_TOKEN_PROGRAM ] : PROGRAMS . token . additionalPrograms . associatedToken ,
389
+ [ PROGRAMS . addressLookupTable . program . contract ] : PROGRAMS . addressLookupTable . program ,
390
+ [ PROGRAMS . computeBudget . program . contract ] : PROGRAMS . computeBudget . program ,
391
+ [ PROGRAMS . solanaConfig . program . contract ] : PROGRAMS . solanaConfig . program ,
392
+ [ PROGRAMS . memo . program . contract ] : PROGRAMS . memo . program ,
391
393
} ;
392
394
393
395
// Basic tx stuff
0 commit comments