@1upmonster/duel 0.1.7 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin.d.ts +20 -42
- package/dist/admin.js +82 -118
- package/dist/encryption.js +1 -2
- package/dist/generated/duel/accounts/index.d.ts +10 -0
- package/dist/generated/duel/accounts/index.js +11 -0
- package/dist/generated/duel/accounts/matchTicket.d.ts +38 -0
- package/dist/generated/duel/accounts/matchTicket.js +45 -0
- package/dist/generated/duel/accounts/queue.d.ts +42 -0
- package/dist/generated/duel/accounts/queue.js +45 -0
- package/dist/generated/duel/accounts/tenant.d.ts +41 -0
- package/dist/generated/duel/accounts/tenant.js +44 -0
- package/dist/generated/duel/errors/duel.d.ts +33 -0
- package/dist/generated/duel/errors/duel.js +37 -0
- package/dist/generated/duel/errors/index.d.ts +8 -0
- package/dist/generated/duel/errors/index.js +9 -0
- package/dist/generated/duel/index.d.ts +12 -0
- package/dist/generated/duel/index.js +13 -0
- package/dist/generated/duel/instructions/cancelTicket.d.ts +45 -0
- package/dist/generated/duel/instructions/cancelTicket.js +56 -0
- package/dist/generated/duel/instructions/closeTicket.d.ts +45 -0
- package/dist/generated/duel/instructions/closeTicket.js +56 -0
- package/dist/generated/duel/instructions/commitTickets.d.ts +39 -0
- package/dist/generated/duel/instructions/commitTickets.js +50 -0
- package/dist/generated/duel/instructions/createTicket.d.ts +48 -0
- package/dist/generated/duel/instructions/createTicket.js +63 -0
- package/dist/generated/duel/instructions/delegateQueue.d.ts +69 -0
- package/dist/generated/duel/instructions/delegateQueue.js +90 -0
- package/dist/generated/duel/instructions/delegateTicket.d.ts +69 -0
- package/dist/generated/duel/instructions/delegateTicket.js +90 -0
- package/dist/generated/duel/instructions/flushMatches.d.ts +37 -0
- package/dist/generated/duel/instructions/flushMatches.js +43 -0
- package/dist/generated/duel/instructions/index.d.ts +18 -0
- package/dist/generated/duel/instructions/index.js +19 -0
- package/dist/generated/duel/instructions/initializeQueue.d.ts +48 -0
- package/dist/generated/duel/instructions/initializeQueue.js +63 -0
- package/dist/generated/duel/instructions/initializeTenant.d.ts +70 -0
- package/dist/generated/duel/instructions/initializeTenant.js +67 -0
- package/dist/generated/duel/instructions/joinQueue.d.ts +51 -0
- package/dist/generated/duel/instructions/joinQueue.js +56 -0
- package/dist/generated/duel/instructions/processUndelegation.d.ts +43 -0
- package/dist/generated/duel/instructions/processUndelegation.js +49 -0
- package/dist/generated/duel/programs/duel.d.ts +88 -0
- package/dist/generated/duel/programs/duel.js +138 -0
- package/dist/generated/duel/programs/index.d.ts +8 -0
- package/dist/generated/duel/programs/index.js +9 -0
- package/dist/generated/duel/types/accountType.d.ts +25 -0
- package/dist/generated/duel/types/accountType.js +25 -0
- package/dist/generated/duel/types/index.d.ts +13 -0
- package/dist/generated/duel/types/index.js +14 -0
- package/dist/generated/duel/types/matchEntry.d.ts +23 -0
- package/dist/generated/duel/types/matchEntry.js +18 -0
- package/dist/generated/duel/types/matchFound.d.ts +23 -0
- package/dist/generated/duel/types/matchFound.js +18 -0
- package/dist/generated/duel/types/pendingMatch.d.ts +21 -0
- package/dist/generated/duel/types/pendingMatch.js +18 -0
- package/dist/generated/duel/types/queueEntry.d.ts +19 -0
- package/dist/generated/duel/types/queueEntry.js +18 -0
- package/dist/generated/duel/types/ticketStatus.d.ts +40 -0
- package/dist/generated/duel/types/ticketStatus.js +25 -0
- package/dist/generated/rps-game/accounts/gameSession.d.ts +40 -0
- package/dist/generated/rps-game/accounts/gameSession.js +45 -0
- package/dist/generated/rps-game/accounts/index.d.ts +9 -0
- package/dist/generated/rps-game/accounts/index.js +10 -0
- package/dist/generated/rps-game/accounts/playerProfile.d.ts +36 -0
- package/dist/generated/rps-game/accounts/playerProfile.js +47 -0
- package/dist/generated/rps-game/errors/index.d.ts +8 -0
- package/dist/generated/rps-game/errors/index.js +9 -0
- package/dist/generated/rps-game/errors/rpsGame.d.ts +25 -0
- package/dist/generated/rps-game/errors/rpsGame.js +29 -0
- package/dist/generated/rps-game/index.d.ts +12 -0
- package/dist/generated/rps-game/index.js +13 -0
- package/dist/generated/rps-game/instructions/closePlayer.d.ts +45 -0
- package/dist/generated/rps-game/instructions/closePlayer.js +56 -0
- package/dist/generated/rps-game/instructions/delegatePda.d.ts +69 -0
- package/dist/generated/rps-game/instructions/delegatePda.js +90 -0
- package/dist/generated/rps-game/instructions/index.d.ts +16 -0
- package/dist/generated/rps-game/instructions/index.js +17 -0
- package/dist/generated/rps-game/instructions/initializePlayer.d.ts +48 -0
- package/dist/generated/rps-game/instructions/initializePlayer.js +63 -0
- package/dist/generated/rps-game/instructions/makeChoice.d.ts +44 -0
- package/dist/generated/rps-game/instructions/makeChoice.js +46 -0
- package/dist/generated/rps-game/instructions/onMatchFound.d.ts +43 -0
- package/dist/generated/rps-game/instructions/onMatchFound.js +45 -0
- package/dist/generated/rps-game/instructions/persistResults.d.ts +43 -0
- package/dist/generated/rps-game/instructions/persistResults.js +50 -0
- package/dist/generated/rps-game/instructions/processUndelegation.d.ts +43 -0
- package/dist/generated/rps-game/instructions/processUndelegation.js +49 -0
- package/dist/generated/rps-game/instructions/startGame.d.ts +54 -0
- package/dist/generated/rps-game/instructions/startGame.js +67 -0
- package/dist/generated/rps-game/instructions/startGameWithTicket.d.ts +57 -0
- package/dist/generated/rps-game/instructions/startGameWithTicket.js +67 -0
- package/dist/generated/rps-game/programs/index.d.ts +8 -0
- package/dist/generated/rps-game/programs/index.js +9 -0
- package/dist/generated/rps-game/programs/rpsGame.d.ts +78 -0
- package/dist/generated/rps-game/programs/rpsGame.js +118 -0
- package/dist/generated/rps-game/types/accountType.d.ts +34 -0
- package/dist/generated/rps-game/types/accountType.js +25 -0
- package/dist/generated/rps-game/types/choice.d.ts +17 -0
- package/dist/generated/rps-game/types/choice.js +25 -0
- package/dist/generated/rps-game/types/gameResult.d.ts +26 -0
- package/dist/generated/rps-game/types/gameResult.js +25 -0
- package/dist/generated/rps-game/types/index.d.ts +10 -0
- package/dist/generated/rps-game/types/index.js +11 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -2
- package/dist/player.d.ts +21 -49
- package/dist/player.js +61 -141
- package/dist/tee.d.ts +14 -0
- package/dist/tee.js +62 -0
- package/dist/transaction.d.ts +11 -0
- package/dist/transaction.js +50 -0
- package/dist/utils.d.ts +4 -4
- package/dist/utils.js +23 -8
- package/package.json +4 -7
- package/src/admin.ts +129 -164
- package/src/duel.json +66 -2
- package/src/encryption.ts +0 -3
- package/src/generated/duel/accounts/index.ts +11 -0
- package/src/generated/duel/accounts/matchTicket.ts +77 -0
- package/src/generated/duel/accounts/queue.ts +77 -0
- package/src/generated/duel/accounts/tenant.ts +76 -0
- package/src/generated/duel/errors/duel.ts +48 -0
- package/src/generated/duel/errors/index.ts +9 -0
- package/src/generated/duel/index.ts +13 -0
- package/src/generated/duel/instructions/cancelTicket.ts +100 -0
- package/src/generated/duel/instructions/closeTicket.ts +100 -0
- package/src/generated/duel/instructions/commitTickets.ts +84 -0
- package/src/generated/duel/instructions/createTicket.ts +109 -0
- package/src/generated/duel/instructions/delegateQueue.ts +157 -0
- package/src/generated/duel/instructions/delegateTicket.ts +157 -0
- package/src/generated/duel/instructions/flushMatches.ts +76 -0
- package/src/generated/duel/instructions/index.ts +19 -0
- package/src/generated/duel/instructions/initializeQueue.ts +109 -0
- package/src/generated/duel/instructions/initializeTenant.ts +126 -0
- package/src/generated/duel/instructions/joinQueue.ts +106 -0
- package/src/generated/duel/instructions/processUndelegation.ts +86 -0
- package/src/generated/duel/programs/duel.ts +104 -0
- package/src/generated/duel/programs/index.ts +9 -0
- package/src/generated/duel/types/accountType.ts +36 -0
- package/src/generated/duel/types/index.ts +14 -0
- package/src/generated/duel/types/matchEntry.ts +25 -0
- package/src/generated/duel/types/matchFound.ts +25 -0
- package/src/generated/duel/types/pendingMatch.ts +25 -0
- package/src/generated/duel/types/queueEntry.ts +25 -0
- package/src/generated/duel/types/ticketStatus.ts +38 -0
- package/src/generated/rps-game/accounts/gameSession.ts +77 -0
- package/src/generated/rps-game/accounts/index.ts +10 -0
- package/src/generated/rps-game/accounts/playerProfile.ts +80 -0
- package/src/generated/rps-game/errors/index.ts +9 -0
- package/src/generated/rps-game/errors/rpsGame.ts +40 -0
- package/src/generated/rps-game/index.ts +13 -0
- package/src/generated/rps-game/instructions/closePlayer.ts +100 -0
- package/src/generated/rps-game/instructions/delegatePda.ts +157 -0
- package/src/generated/rps-game/instructions/index.ts +17 -0
- package/src/generated/rps-game/instructions/initializePlayer.ts +109 -0
- package/src/generated/rps-game/instructions/makeChoice.ts +84 -0
- package/src/generated/rps-game/instructions/onMatchFound.ts +79 -0
- package/src/generated/rps-game/instructions/persistResults.ts +88 -0
- package/src/generated/rps-game/instructions/processUndelegation.ts +86 -0
- package/src/generated/rps-game/instructions/startGame.ts +118 -0
- package/src/generated/rps-game/instructions/startGameWithTicket.ts +121 -0
- package/src/generated/rps-game/programs/index.ts +9 -0
- package/src/generated/rps-game/programs/rpsGame.ts +95 -0
- package/src/generated/rps-game/types/accountType.ts +36 -0
- package/src/generated/rps-game/types/choice.ts +25 -0
- package/src/generated/rps-game/types/gameResult.ts +37 -0
- package/src/generated/rps-game/types/index.ts +11 -0
- package/src/index.ts +2 -1
- package/src/player.ts +96 -193
- package/src/rps_game.json +991 -0
- package/src/tee.ts +79 -0
- package/src/transaction.ts +90 -0
- package/src/utils.ts +35 -20
- package/tsconfig.json +2 -2
- package/dist/client.d.ts +0 -54
- package/dist/client.js +0 -265
- package/dist/duel.json +0 -517
- package/dist/private_matchmaking.json +0 -534
- package/dist/types.d.ts +0 -635
- package/dist/types.js +0 -2
- package/src/types.ts +0 -300
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { combineCodec, fixDecoderSize, fixEncoderSize, getAddressEncoder, getBytesDecoder, getBytesEncoder, getProgramDerivedAddress, getStructDecoder, getStructEncoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, transformEncoder, type AccountMeta, type AccountSignerMeta, type Address, type Codec, type Decoder, type Encoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, type WritableSignerAccount } from '@solana/kit';
|
|
10
|
+
import { getAccountMetaFactory, getAddressFromResolvedInstructionAccount, type ResolvedInstructionAccount } from '@solana/program-client-core';
|
|
11
|
+
import { DUEL_PROGRAM_ADDRESS } from '../programs';
|
|
12
|
+
import { getAccountTypeDecoder, getAccountTypeEncoder, type AccountType, type AccountTypeArgs } from '../types';
|
|
13
|
+
|
|
14
|
+
export const DELEGATE_QUEUE_DISCRIMINATOR = new Uint8Array([31, 200, 139, 125, 93, 239, 83, 87]);
|
|
15
|
+
|
|
16
|
+
export function getDelegateQueueDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(DELEGATE_QUEUE_DISCRIMINATOR); }
|
|
17
|
+
|
|
18
|
+
export type DelegateQueueInstruction<TProgram extends string = typeof DUEL_PROGRAM_ADDRESS, TAccountBufferPda extends string | AccountMeta<string> = string, TAccountDelegationRecordPda extends string | AccountMeta<string> = string, TAccountDelegationMetadataPda extends string | AccountMeta<string> = string, TAccountPda extends string | AccountMeta<string> = string, TAccountPayer extends string | AccountMeta<string> = string, TAccountValidator extends string | AccountMeta<string> = string, TAccountOwnerProgram extends string | AccountMeta<string> = "EdZzUwKd1X2ZWjxLPpz1cpEzMF7RUZC43Pq64v1VcK5X", TAccountDelegationProgram extends string | AccountMeta<string> = "DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh", TAccountSystemProgram extends string | AccountMeta<string> = "11111111111111111111111111111111", TRemainingAccounts extends readonly AccountMeta<string>[] = []> =
|
|
19
|
+
Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[TAccountBufferPda extends string ? WritableAccount<TAccountBufferPda> : TAccountBufferPda, TAccountDelegationRecordPda extends string ? WritableAccount<TAccountDelegationRecordPda> : TAccountDelegationRecordPda, TAccountDelegationMetadataPda extends string ? WritableAccount<TAccountDelegationMetadataPda> : TAccountDelegationMetadataPda, TAccountPda extends string ? WritableAccount<TAccountPda> : TAccountPda, TAccountPayer extends string ? WritableSignerAccount<TAccountPayer> & AccountSignerMeta<TAccountPayer> : TAccountPayer, TAccountValidator extends string ? ReadonlyAccount<TAccountValidator> : TAccountValidator, TAccountOwnerProgram extends string ? ReadonlyAccount<TAccountOwnerProgram> : TAccountOwnerProgram, TAccountDelegationProgram extends string ? ReadonlyAccount<TAccountDelegationProgram> : TAccountDelegationProgram, TAccountSystemProgram extends string ? ReadonlyAccount<TAccountSystemProgram> : TAccountSystemProgram, ...TRemainingAccounts]>;
|
|
20
|
+
|
|
21
|
+
export type DelegateQueueInstructionData = { discriminator: ReadonlyUint8Array; accountType: AccountType; };
|
|
22
|
+
|
|
23
|
+
export type DelegateQueueInstructionDataArgs = { accountType: AccountTypeArgs; };
|
|
24
|
+
|
|
25
|
+
export function getDelegateQueueInstructionDataEncoder(): Encoder<DelegateQueueInstructionDataArgs> {
|
|
26
|
+
return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['accountType', getAccountTypeEncoder()]]), (value) => ({ ...value, discriminator: DELEGATE_QUEUE_DISCRIMINATOR }));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function getDelegateQueueInstructionDataDecoder(): Decoder<DelegateQueueInstructionData> {
|
|
30
|
+
return getStructDecoder([['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['accountType', getAccountTypeDecoder()]]);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function getDelegateQueueInstructionDataCodec(): Codec<DelegateQueueInstructionDataArgs, DelegateQueueInstructionData> {
|
|
34
|
+
return combineCodec(getDelegateQueueInstructionDataEncoder(), getDelegateQueueInstructionDataDecoder());
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type DelegateQueueAsyncInput<TAccountBufferPda extends string = string, TAccountDelegationRecordPda extends string = string, TAccountDelegationMetadataPda extends string = string, TAccountPda extends string = string, TAccountPayer extends string = string, TAccountValidator extends string = string, TAccountOwnerProgram extends string = string, TAccountDelegationProgram extends string = string, TAccountSystemProgram extends string = string> = {
|
|
38
|
+
bufferPda?: Address<TAccountBufferPda>;
|
|
39
|
+
delegationRecordPda?: Address<TAccountDelegationRecordPda>;
|
|
40
|
+
delegationMetadataPda?: Address<TAccountDelegationMetadataPda>;
|
|
41
|
+
pda: Address<TAccountPda>;
|
|
42
|
+
payer: TransactionSigner<TAccountPayer>;
|
|
43
|
+
validator?: Address<TAccountValidator>;
|
|
44
|
+
ownerProgram?: Address<TAccountOwnerProgram>;
|
|
45
|
+
delegationProgram?: Address<TAccountDelegationProgram>;
|
|
46
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
47
|
+
accountType: DelegateQueueInstructionDataArgs["accountType"];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export async function getDelegateQueueInstructionAsync<TAccountBufferPda extends string, TAccountDelegationRecordPda extends string, TAccountDelegationMetadataPda extends string, TAccountPda extends string, TAccountPayer extends string, TAccountValidator extends string, TAccountOwnerProgram extends string, TAccountDelegationProgram extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof DUEL_PROGRAM_ADDRESS>(input: DelegateQueueAsyncInput<TAccountBufferPda, TAccountDelegationRecordPda, TAccountDelegationMetadataPda, TAccountPda, TAccountPayer, TAccountValidator, TAccountOwnerProgram, TAccountDelegationProgram, TAccountSystemProgram>, config?: { programAddress?: TProgramAddress } ): Promise<DelegateQueueInstruction<TProgramAddress, TAccountBufferPda, TAccountDelegationRecordPda, TAccountDelegationMetadataPda, TAccountPda, TAccountPayer, TAccountValidator, TAccountOwnerProgram, TAccountDelegationProgram, TAccountSystemProgram>> {
|
|
51
|
+
// Program address.
|
|
52
|
+
const programAddress = config?.programAddress ?? DUEL_PROGRAM_ADDRESS;
|
|
53
|
+
|
|
54
|
+
// Original accounts.
|
|
55
|
+
const originalAccounts = { bufferPda: { value: input.bufferPda ?? null, isWritable: true }, delegationRecordPda: { value: input.delegationRecordPda ?? null, isWritable: true }, delegationMetadataPda: { value: input.delegationMetadataPda ?? null, isWritable: true }, pda: { value: input.pda ?? null, isWritable: true }, payer: { value: input.payer ?? null, isWritable: true }, validator: { value: input.validator ?? null, isWritable: false }, ownerProgram: { value: input.ownerProgram ?? null, isWritable: false }, delegationProgram: { value: input.delegationProgram ?? null, isWritable: false }, systemProgram: { value: input.systemProgram ?? null, isWritable: false } }
|
|
56
|
+
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
// Original args.
|
|
60
|
+
const args = { ...input, };
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
// Resolve default values.
|
|
64
|
+
if (!accounts.bufferPda.value) {
|
|
65
|
+
accounts.bufferPda.value = await getProgramDerivedAddress({ programAddress: 'EdZzUwKd1X2ZWjxLPpz1cpEzMF7RUZC43Pq64v1VcK5X' as Address<'EdZzUwKd1X2ZWjxLPpz1cpEzMF7RUZC43Pq64v1VcK5X'>, seeds: [getBytesEncoder().encode(new Uint8Array([98, 117, 102, 102, 101, 114])), getAddressEncoder().encode(getAddressFromResolvedInstructionAccount("pda", accounts.pda.value))] });
|
|
66
|
+
}
|
|
67
|
+
if (!accounts.delegationRecordPda.value) {
|
|
68
|
+
accounts.delegationRecordPda.value = await getProgramDerivedAddress({ programAddress: 'DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh' as Address<'DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh'>, seeds: [getBytesEncoder().encode(new Uint8Array([100, 101, 108, 101, 103, 97, 116, 105, 111, 110])), getAddressEncoder().encode(getAddressFromResolvedInstructionAccount("pda", accounts.pda.value))] });
|
|
69
|
+
}
|
|
70
|
+
if (!accounts.delegationMetadataPda.value) {
|
|
71
|
+
accounts.delegationMetadataPda.value = await getProgramDerivedAddress({ programAddress: 'DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh' as Address<'DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh'>, seeds: [getBytesEncoder().encode(new Uint8Array([100, 101, 108, 101, 103, 97, 116, 105, 111, 110, 45, 109, 101, 116, 97, 100, 97, 116, 97])), getAddressEncoder().encode(getAddressFromResolvedInstructionAccount("pda", accounts.pda.value))] });
|
|
72
|
+
}
|
|
73
|
+
if (!accounts.ownerProgram.value) {
|
|
74
|
+
accounts.ownerProgram.value = 'EdZzUwKd1X2ZWjxLPpz1cpEzMF7RUZC43Pq64v1VcK5X' as Address<'EdZzUwKd1X2ZWjxLPpz1cpEzMF7RUZC43Pq64v1VcK5X'>;
|
|
75
|
+
}
|
|
76
|
+
if (!accounts.delegationProgram.value) {
|
|
77
|
+
accounts.delegationProgram.value = 'DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh' as Address<'DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh'>;
|
|
78
|
+
}
|
|
79
|
+
if (!accounts.systemProgram.value) {
|
|
80
|
+
accounts.systemProgram.value = '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
84
|
+
return Object.freeze({ accounts: [getAccountMeta("bufferPda", accounts.bufferPda), getAccountMeta("delegationRecordPda", accounts.delegationRecordPda), getAccountMeta("delegationMetadataPda", accounts.delegationMetadataPda), getAccountMeta("pda", accounts.pda), getAccountMeta("payer", accounts.payer), getAccountMeta("validator", accounts.validator), getAccountMeta("ownerProgram", accounts.ownerProgram), getAccountMeta("delegationProgram", accounts.delegationProgram), getAccountMeta("systemProgram", accounts.systemProgram)], data: getDelegateQueueInstructionDataEncoder().encode(args as DelegateQueueInstructionDataArgs), programAddress } as DelegateQueueInstruction<TProgramAddress, TAccountBufferPda, TAccountDelegationRecordPda, TAccountDelegationMetadataPda, TAccountPda, TAccountPayer, TAccountValidator, TAccountOwnerProgram, TAccountDelegationProgram, TAccountSystemProgram>);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type DelegateQueueInput<TAccountBufferPda extends string = string, TAccountDelegationRecordPda extends string = string, TAccountDelegationMetadataPda extends string = string, TAccountPda extends string = string, TAccountPayer extends string = string, TAccountValidator extends string = string, TAccountOwnerProgram extends string = string, TAccountDelegationProgram extends string = string, TAccountSystemProgram extends string = string> = {
|
|
88
|
+
bufferPda: Address<TAccountBufferPda>;
|
|
89
|
+
delegationRecordPda: Address<TAccountDelegationRecordPda>;
|
|
90
|
+
delegationMetadataPda: Address<TAccountDelegationMetadataPda>;
|
|
91
|
+
pda: Address<TAccountPda>;
|
|
92
|
+
payer: TransactionSigner<TAccountPayer>;
|
|
93
|
+
validator?: Address<TAccountValidator>;
|
|
94
|
+
ownerProgram?: Address<TAccountOwnerProgram>;
|
|
95
|
+
delegationProgram?: Address<TAccountDelegationProgram>;
|
|
96
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
97
|
+
accountType: DelegateQueueInstructionDataArgs["accountType"];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function getDelegateQueueInstruction<TAccountBufferPda extends string, TAccountDelegationRecordPda extends string, TAccountDelegationMetadataPda extends string, TAccountPda extends string, TAccountPayer extends string, TAccountValidator extends string, TAccountOwnerProgram extends string, TAccountDelegationProgram extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof DUEL_PROGRAM_ADDRESS>(input: DelegateQueueInput<TAccountBufferPda, TAccountDelegationRecordPda, TAccountDelegationMetadataPda, TAccountPda, TAccountPayer, TAccountValidator, TAccountOwnerProgram, TAccountDelegationProgram, TAccountSystemProgram>, config?: { programAddress?: TProgramAddress } ): DelegateQueueInstruction<TProgramAddress, TAccountBufferPda, TAccountDelegationRecordPda, TAccountDelegationMetadataPda, TAccountPda, TAccountPayer, TAccountValidator, TAccountOwnerProgram, TAccountDelegationProgram, TAccountSystemProgram> {
|
|
101
|
+
// Program address.
|
|
102
|
+
const programAddress = config?.programAddress ?? DUEL_PROGRAM_ADDRESS;
|
|
103
|
+
|
|
104
|
+
// Original accounts.
|
|
105
|
+
const originalAccounts = { bufferPda: { value: input.bufferPda ?? null, isWritable: true }, delegationRecordPda: { value: input.delegationRecordPda ?? null, isWritable: true }, delegationMetadataPda: { value: input.delegationMetadataPda ?? null, isWritable: true }, pda: { value: input.pda ?? null, isWritable: true }, payer: { value: input.payer ?? null, isWritable: true }, validator: { value: input.validator ?? null, isWritable: false }, ownerProgram: { value: input.ownerProgram ?? null, isWritable: false }, delegationProgram: { value: input.delegationProgram ?? null, isWritable: false }, systemProgram: { value: input.systemProgram ?? null, isWritable: false } }
|
|
106
|
+
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
// Original args.
|
|
110
|
+
const args = { ...input, };
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
// Resolve default values.
|
|
114
|
+
if (!accounts.ownerProgram.value) {
|
|
115
|
+
accounts.ownerProgram.value = 'EdZzUwKd1X2ZWjxLPpz1cpEzMF7RUZC43Pq64v1VcK5X' as Address<'EdZzUwKd1X2ZWjxLPpz1cpEzMF7RUZC43Pq64v1VcK5X'>;
|
|
116
|
+
}
|
|
117
|
+
if (!accounts.delegationProgram.value) {
|
|
118
|
+
accounts.delegationProgram.value = 'DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh' as Address<'DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh'>;
|
|
119
|
+
}
|
|
120
|
+
if (!accounts.systemProgram.value) {
|
|
121
|
+
accounts.systemProgram.value = '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
125
|
+
return Object.freeze({ accounts: [getAccountMeta("bufferPda", accounts.bufferPda), getAccountMeta("delegationRecordPda", accounts.delegationRecordPda), getAccountMeta("delegationMetadataPda", accounts.delegationMetadataPda), getAccountMeta("pda", accounts.pda), getAccountMeta("payer", accounts.payer), getAccountMeta("validator", accounts.validator), getAccountMeta("ownerProgram", accounts.ownerProgram), getAccountMeta("delegationProgram", accounts.delegationProgram), getAccountMeta("systemProgram", accounts.systemProgram)], data: getDelegateQueueInstructionDataEncoder().encode(args as DelegateQueueInstructionDataArgs), programAddress } as DelegateQueueInstruction<TProgramAddress, TAccountBufferPda, TAccountDelegationRecordPda, TAccountDelegationMetadataPda, TAccountPda, TAccountPayer, TAccountValidator, TAccountOwnerProgram, TAccountDelegationProgram, TAccountSystemProgram>);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export type ParsedDelegateQueueInstruction<TProgram extends string = typeof DUEL_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = { programAddress: Address<TProgram>;
|
|
129
|
+
accounts: {
|
|
130
|
+
bufferPda: TAccountMetas[0];
|
|
131
|
+
delegationRecordPda: TAccountMetas[1];
|
|
132
|
+
delegationMetadataPda: TAccountMetas[2];
|
|
133
|
+
pda: TAccountMetas[3];
|
|
134
|
+
payer: TAccountMetas[4];
|
|
135
|
+
validator?: TAccountMetas[5] | undefined;
|
|
136
|
+
ownerProgram: TAccountMetas[6];
|
|
137
|
+
delegationProgram: TAccountMetas[7];
|
|
138
|
+
systemProgram: TAccountMetas[8];
|
|
139
|
+
};
|
|
140
|
+
data: DelegateQueueInstructionData; };
|
|
141
|
+
|
|
142
|
+
export function parseDelegateQueueInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedDelegateQueueInstruction<TProgram, TAccountMetas> {
|
|
143
|
+
if (instruction.accounts.length < 9) {
|
|
144
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 9 });
|
|
145
|
+
}
|
|
146
|
+
let accountIndex = 0;
|
|
147
|
+
const getNextAccount = () => {
|
|
148
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
149
|
+
accountIndex += 1;
|
|
150
|
+
return accountMeta;
|
|
151
|
+
}
|
|
152
|
+
const getNextOptionalAccount = () => {
|
|
153
|
+
const accountMeta = getNextAccount();
|
|
154
|
+
return accountMeta.address === DUEL_PROGRAM_ADDRESS ? undefined : accountMeta;
|
|
155
|
+
};
|
|
156
|
+
return { programAddress: instruction.programAddress, accounts: { bufferPda: getNextAccount(), delegationRecordPda: getNextAccount(), delegationMetadataPda: getNextAccount(), pda: getNextAccount(), payer: getNextAccount(), validator: getNextOptionalAccount(), ownerProgram: getNextAccount(), delegationProgram: getNextAccount(), systemProgram: getNextAccount() }, data: getDelegateQueueInstructionDataDecoder().decode(instruction.data) };
|
|
157
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { combineCodec, fixDecoderSize, fixEncoderSize, getAddressEncoder, getBytesDecoder, getBytesEncoder, getProgramDerivedAddress, getStructDecoder, getStructEncoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, transformEncoder, type AccountMeta, type AccountSignerMeta, type Address, type Codec, type Decoder, type Encoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, type WritableSignerAccount } from '@solana/kit';
|
|
10
|
+
import { getAccountMetaFactory, getAddressFromResolvedInstructionAccount, type ResolvedInstructionAccount } from '@solana/program-client-core';
|
|
11
|
+
import { DUEL_PROGRAM_ADDRESS } from '../programs';
|
|
12
|
+
import { getAccountTypeDecoder, getAccountTypeEncoder, type AccountType, type AccountTypeArgs } from '../types';
|
|
13
|
+
|
|
14
|
+
export const DELEGATE_TICKET_DISCRIMINATOR = new Uint8Array([195, 3, 78, 64, 128, 235, 209, 171]);
|
|
15
|
+
|
|
16
|
+
export function getDelegateTicketDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(DELEGATE_TICKET_DISCRIMINATOR); }
|
|
17
|
+
|
|
18
|
+
export type DelegateTicketInstruction<TProgram extends string = typeof DUEL_PROGRAM_ADDRESS, TAccountBufferPda extends string | AccountMeta<string> = string, TAccountDelegationRecordPda extends string | AccountMeta<string> = string, TAccountDelegationMetadataPda extends string | AccountMeta<string> = string, TAccountPda extends string | AccountMeta<string> = string, TAccountPayer extends string | AccountMeta<string> = string, TAccountValidator extends string | AccountMeta<string> = string, TAccountOwnerProgram extends string | AccountMeta<string> = "EdZzUwKd1X2ZWjxLPpz1cpEzMF7RUZC43Pq64v1VcK5X", TAccountDelegationProgram extends string | AccountMeta<string> = "DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh", TAccountSystemProgram extends string | AccountMeta<string> = "11111111111111111111111111111111", TRemainingAccounts extends readonly AccountMeta<string>[] = []> =
|
|
19
|
+
Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[TAccountBufferPda extends string ? WritableAccount<TAccountBufferPda> : TAccountBufferPda, TAccountDelegationRecordPda extends string ? WritableAccount<TAccountDelegationRecordPda> : TAccountDelegationRecordPda, TAccountDelegationMetadataPda extends string ? WritableAccount<TAccountDelegationMetadataPda> : TAccountDelegationMetadataPda, TAccountPda extends string ? WritableAccount<TAccountPda> : TAccountPda, TAccountPayer extends string ? WritableSignerAccount<TAccountPayer> & AccountSignerMeta<TAccountPayer> : TAccountPayer, TAccountValidator extends string ? ReadonlyAccount<TAccountValidator> : TAccountValidator, TAccountOwnerProgram extends string ? ReadonlyAccount<TAccountOwnerProgram> : TAccountOwnerProgram, TAccountDelegationProgram extends string ? ReadonlyAccount<TAccountDelegationProgram> : TAccountDelegationProgram, TAccountSystemProgram extends string ? ReadonlyAccount<TAccountSystemProgram> : TAccountSystemProgram, ...TRemainingAccounts]>;
|
|
20
|
+
|
|
21
|
+
export type DelegateTicketInstructionData = { discriminator: ReadonlyUint8Array; accountType: AccountType; };
|
|
22
|
+
|
|
23
|
+
export type DelegateTicketInstructionDataArgs = { accountType: AccountTypeArgs; };
|
|
24
|
+
|
|
25
|
+
export function getDelegateTicketInstructionDataEncoder(): Encoder<DelegateTicketInstructionDataArgs> {
|
|
26
|
+
return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['accountType', getAccountTypeEncoder()]]), (value) => ({ ...value, discriminator: DELEGATE_TICKET_DISCRIMINATOR }));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function getDelegateTicketInstructionDataDecoder(): Decoder<DelegateTicketInstructionData> {
|
|
30
|
+
return getStructDecoder([['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['accountType', getAccountTypeDecoder()]]);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function getDelegateTicketInstructionDataCodec(): Codec<DelegateTicketInstructionDataArgs, DelegateTicketInstructionData> {
|
|
34
|
+
return combineCodec(getDelegateTicketInstructionDataEncoder(), getDelegateTicketInstructionDataDecoder());
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type DelegateTicketAsyncInput<TAccountBufferPda extends string = string, TAccountDelegationRecordPda extends string = string, TAccountDelegationMetadataPda extends string = string, TAccountPda extends string = string, TAccountPayer extends string = string, TAccountValidator extends string = string, TAccountOwnerProgram extends string = string, TAccountDelegationProgram extends string = string, TAccountSystemProgram extends string = string> = {
|
|
38
|
+
bufferPda?: Address<TAccountBufferPda>;
|
|
39
|
+
delegationRecordPda?: Address<TAccountDelegationRecordPda>;
|
|
40
|
+
delegationMetadataPda?: Address<TAccountDelegationMetadataPda>;
|
|
41
|
+
pda: Address<TAccountPda>;
|
|
42
|
+
payer: TransactionSigner<TAccountPayer>;
|
|
43
|
+
validator?: Address<TAccountValidator>;
|
|
44
|
+
ownerProgram?: Address<TAccountOwnerProgram>;
|
|
45
|
+
delegationProgram?: Address<TAccountDelegationProgram>;
|
|
46
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
47
|
+
accountType: DelegateTicketInstructionDataArgs["accountType"];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export async function getDelegateTicketInstructionAsync<TAccountBufferPda extends string, TAccountDelegationRecordPda extends string, TAccountDelegationMetadataPda extends string, TAccountPda extends string, TAccountPayer extends string, TAccountValidator extends string, TAccountOwnerProgram extends string, TAccountDelegationProgram extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof DUEL_PROGRAM_ADDRESS>(input: DelegateTicketAsyncInput<TAccountBufferPda, TAccountDelegationRecordPda, TAccountDelegationMetadataPda, TAccountPda, TAccountPayer, TAccountValidator, TAccountOwnerProgram, TAccountDelegationProgram, TAccountSystemProgram>, config?: { programAddress?: TProgramAddress } ): Promise<DelegateTicketInstruction<TProgramAddress, TAccountBufferPda, TAccountDelegationRecordPda, TAccountDelegationMetadataPda, TAccountPda, TAccountPayer, TAccountValidator, TAccountOwnerProgram, TAccountDelegationProgram, TAccountSystemProgram>> {
|
|
51
|
+
// Program address.
|
|
52
|
+
const programAddress = config?.programAddress ?? DUEL_PROGRAM_ADDRESS;
|
|
53
|
+
|
|
54
|
+
// Original accounts.
|
|
55
|
+
const originalAccounts = { bufferPda: { value: input.bufferPda ?? null, isWritable: true }, delegationRecordPda: { value: input.delegationRecordPda ?? null, isWritable: true }, delegationMetadataPda: { value: input.delegationMetadataPda ?? null, isWritable: true }, pda: { value: input.pda ?? null, isWritable: true }, payer: { value: input.payer ?? null, isWritable: true }, validator: { value: input.validator ?? null, isWritable: false }, ownerProgram: { value: input.ownerProgram ?? null, isWritable: false }, delegationProgram: { value: input.delegationProgram ?? null, isWritable: false }, systemProgram: { value: input.systemProgram ?? null, isWritable: false } }
|
|
56
|
+
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
// Original args.
|
|
60
|
+
const args = { ...input, };
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
// Resolve default values.
|
|
64
|
+
if (!accounts.bufferPda.value) {
|
|
65
|
+
accounts.bufferPda.value = await getProgramDerivedAddress({ programAddress: 'EdZzUwKd1X2ZWjxLPpz1cpEzMF7RUZC43Pq64v1VcK5X' as Address<'EdZzUwKd1X2ZWjxLPpz1cpEzMF7RUZC43Pq64v1VcK5X'>, seeds: [getBytesEncoder().encode(new Uint8Array([98, 117, 102, 102, 101, 114])), getAddressEncoder().encode(getAddressFromResolvedInstructionAccount("pda", accounts.pda.value))] });
|
|
66
|
+
}
|
|
67
|
+
if (!accounts.delegationRecordPda.value) {
|
|
68
|
+
accounts.delegationRecordPda.value = await getProgramDerivedAddress({ programAddress: 'DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh' as Address<'DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh'>, seeds: [getBytesEncoder().encode(new Uint8Array([100, 101, 108, 101, 103, 97, 116, 105, 111, 110])), getAddressEncoder().encode(getAddressFromResolvedInstructionAccount("pda", accounts.pda.value))] });
|
|
69
|
+
}
|
|
70
|
+
if (!accounts.delegationMetadataPda.value) {
|
|
71
|
+
accounts.delegationMetadataPda.value = await getProgramDerivedAddress({ programAddress: 'DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh' as Address<'DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh'>, seeds: [getBytesEncoder().encode(new Uint8Array([100, 101, 108, 101, 103, 97, 116, 105, 111, 110, 45, 109, 101, 116, 97, 100, 97, 116, 97])), getAddressEncoder().encode(getAddressFromResolvedInstructionAccount("pda", accounts.pda.value))] });
|
|
72
|
+
}
|
|
73
|
+
if (!accounts.ownerProgram.value) {
|
|
74
|
+
accounts.ownerProgram.value = 'EdZzUwKd1X2ZWjxLPpz1cpEzMF7RUZC43Pq64v1VcK5X' as Address<'EdZzUwKd1X2ZWjxLPpz1cpEzMF7RUZC43Pq64v1VcK5X'>;
|
|
75
|
+
}
|
|
76
|
+
if (!accounts.delegationProgram.value) {
|
|
77
|
+
accounts.delegationProgram.value = 'DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh' as Address<'DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh'>;
|
|
78
|
+
}
|
|
79
|
+
if (!accounts.systemProgram.value) {
|
|
80
|
+
accounts.systemProgram.value = '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
84
|
+
return Object.freeze({ accounts: [getAccountMeta("bufferPda", accounts.bufferPda), getAccountMeta("delegationRecordPda", accounts.delegationRecordPda), getAccountMeta("delegationMetadataPda", accounts.delegationMetadataPda), getAccountMeta("pda", accounts.pda), getAccountMeta("payer", accounts.payer), getAccountMeta("validator", accounts.validator), getAccountMeta("ownerProgram", accounts.ownerProgram), getAccountMeta("delegationProgram", accounts.delegationProgram), getAccountMeta("systemProgram", accounts.systemProgram)], data: getDelegateTicketInstructionDataEncoder().encode(args as DelegateTicketInstructionDataArgs), programAddress } as DelegateTicketInstruction<TProgramAddress, TAccountBufferPda, TAccountDelegationRecordPda, TAccountDelegationMetadataPda, TAccountPda, TAccountPayer, TAccountValidator, TAccountOwnerProgram, TAccountDelegationProgram, TAccountSystemProgram>);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type DelegateTicketInput<TAccountBufferPda extends string = string, TAccountDelegationRecordPda extends string = string, TAccountDelegationMetadataPda extends string = string, TAccountPda extends string = string, TAccountPayer extends string = string, TAccountValidator extends string = string, TAccountOwnerProgram extends string = string, TAccountDelegationProgram extends string = string, TAccountSystemProgram extends string = string> = {
|
|
88
|
+
bufferPda: Address<TAccountBufferPda>;
|
|
89
|
+
delegationRecordPda: Address<TAccountDelegationRecordPda>;
|
|
90
|
+
delegationMetadataPda: Address<TAccountDelegationMetadataPda>;
|
|
91
|
+
pda: Address<TAccountPda>;
|
|
92
|
+
payer: TransactionSigner<TAccountPayer>;
|
|
93
|
+
validator?: Address<TAccountValidator>;
|
|
94
|
+
ownerProgram?: Address<TAccountOwnerProgram>;
|
|
95
|
+
delegationProgram?: Address<TAccountDelegationProgram>;
|
|
96
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
97
|
+
accountType: DelegateTicketInstructionDataArgs["accountType"];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function getDelegateTicketInstruction<TAccountBufferPda extends string, TAccountDelegationRecordPda extends string, TAccountDelegationMetadataPda extends string, TAccountPda extends string, TAccountPayer extends string, TAccountValidator extends string, TAccountOwnerProgram extends string, TAccountDelegationProgram extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof DUEL_PROGRAM_ADDRESS>(input: DelegateTicketInput<TAccountBufferPda, TAccountDelegationRecordPda, TAccountDelegationMetadataPda, TAccountPda, TAccountPayer, TAccountValidator, TAccountOwnerProgram, TAccountDelegationProgram, TAccountSystemProgram>, config?: { programAddress?: TProgramAddress } ): DelegateTicketInstruction<TProgramAddress, TAccountBufferPda, TAccountDelegationRecordPda, TAccountDelegationMetadataPda, TAccountPda, TAccountPayer, TAccountValidator, TAccountOwnerProgram, TAccountDelegationProgram, TAccountSystemProgram> {
|
|
101
|
+
// Program address.
|
|
102
|
+
const programAddress = config?.programAddress ?? DUEL_PROGRAM_ADDRESS;
|
|
103
|
+
|
|
104
|
+
// Original accounts.
|
|
105
|
+
const originalAccounts = { bufferPda: { value: input.bufferPda ?? null, isWritable: true }, delegationRecordPda: { value: input.delegationRecordPda ?? null, isWritable: true }, delegationMetadataPda: { value: input.delegationMetadataPda ?? null, isWritable: true }, pda: { value: input.pda ?? null, isWritable: true }, payer: { value: input.payer ?? null, isWritable: true }, validator: { value: input.validator ?? null, isWritable: false }, ownerProgram: { value: input.ownerProgram ?? null, isWritable: false }, delegationProgram: { value: input.delegationProgram ?? null, isWritable: false }, systemProgram: { value: input.systemProgram ?? null, isWritable: false } }
|
|
106
|
+
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
// Original args.
|
|
110
|
+
const args = { ...input, };
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
// Resolve default values.
|
|
114
|
+
if (!accounts.ownerProgram.value) {
|
|
115
|
+
accounts.ownerProgram.value = 'EdZzUwKd1X2ZWjxLPpz1cpEzMF7RUZC43Pq64v1VcK5X' as Address<'EdZzUwKd1X2ZWjxLPpz1cpEzMF7RUZC43Pq64v1VcK5X'>;
|
|
116
|
+
}
|
|
117
|
+
if (!accounts.delegationProgram.value) {
|
|
118
|
+
accounts.delegationProgram.value = 'DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh' as Address<'DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh'>;
|
|
119
|
+
}
|
|
120
|
+
if (!accounts.systemProgram.value) {
|
|
121
|
+
accounts.systemProgram.value = '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
125
|
+
return Object.freeze({ accounts: [getAccountMeta("bufferPda", accounts.bufferPda), getAccountMeta("delegationRecordPda", accounts.delegationRecordPda), getAccountMeta("delegationMetadataPda", accounts.delegationMetadataPda), getAccountMeta("pda", accounts.pda), getAccountMeta("payer", accounts.payer), getAccountMeta("validator", accounts.validator), getAccountMeta("ownerProgram", accounts.ownerProgram), getAccountMeta("delegationProgram", accounts.delegationProgram), getAccountMeta("systemProgram", accounts.systemProgram)], data: getDelegateTicketInstructionDataEncoder().encode(args as DelegateTicketInstructionDataArgs), programAddress } as DelegateTicketInstruction<TProgramAddress, TAccountBufferPda, TAccountDelegationRecordPda, TAccountDelegationMetadataPda, TAccountPda, TAccountPayer, TAccountValidator, TAccountOwnerProgram, TAccountDelegationProgram, TAccountSystemProgram>);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export type ParsedDelegateTicketInstruction<TProgram extends string = typeof DUEL_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = { programAddress: Address<TProgram>;
|
|
129
|
+
accounts: {
|
|
130
|
+
bufferPda: TAccountMetas[0];
|
|
131
|
+
delegationRecordPda: TAccountMetas[1];
|
|
132
|
+
delegationMetadataPda: TAccountMetas[2];
|
|
133
|
+
pda: TAccountMetas[3];
|
|
134
|
+
payer: TAccountMetas[4];
|
|
135
|
+
validator?: TAccountMetas[5] | undefined;
|
|
136
|
+
ownerProgram: TAccountMetas[6];
|
|
137
|
+
delegationProgram: TAccountMetas[7];
|
|
138
|
+
systemProgram: TAccountMetas[8];
|
|
139
|
+
};
|
|
140
|
+
data: DelegateTicketInstructionData; };
|
|
141
|
+
|
|
142
|
+
export function parseDelegateTicketInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedDelegateTicketInstruction<TProgram, TAccountMetas> {
|
|
143
|
+
if (instruction.accounts.length < 9) {
|
|
144
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 9 });
|
|
145
|
+
}
|
|
146
|
+
let accountIndex = 0;
|
|
147
|
+
const getNextAccount = () => {
|
|
148
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
149
|
+
accountIndex += 1;
|
|
150
|
+
return accountMeta;
|
|
151
|
+
}
|
|
152
|
+
const getNextOptionalAccount = () => {
|
|
153
|
+
const accountMeta = getNextAccount();
|
|
154
|
+
return accountMeta.address === DUEL_PROGRAM_ADDRESS ? undefined : accountMeta;
|
|
155
|
+
};
|
|
156
|
+
return { programAddress: instruction.programAddress, accounts: { bufferPda: getNextAccount(), delegationRecordPda: getNextAccount(), delegationMetadataPda: getNextAccount(), pda: getNextAccount(), payer: getNextAccount(), validator: getNextOptionalAccount(), ownerProgram: getNextAccount(), delegationProgram: getNextAccount(), systemProgram: getNextAccount() }, data: getDelegateTicketInstructionDataDecoder().decode(instruction.data) };
|
|
157
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { combineCodec, fixDecoderSize, fixEncoderSize, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, transformEncoder, type AccountMeta, type AccountSignerMeta, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyAccount, type ReadonlySignerAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount } from '@solana/kit';
|
|
10
|
+
import { getAccountMetaFactory, type ResolvedInstructionAccount } from '@solana/program-client-core';
|
|
11
|
+
import { DUEL_PROGRAM_ADDRESS } from '../programs';
|
|
12
|
+
|
|
13
|
+
export const FLUSH_MATCHES_DISCRIMINATOR = new Uint8Array([49, 148, 163, 71, 77, 63, 197, 76]);
|
|
14
|
+
|
|
15
|
+
export function getFlushMatchesDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(FLUSH_MATCHES_DISCRIMINATOR); }
|
|
16
|
+
|
|
17
|
+
export type FlushMatchesInstruction<TProgram extends string = typeof DUEL_PROGRAM_ADDRESS, TAccountQueue extends string | AccountMeta<string> = string, TAccountTenant extends string | AccountMeta<string> = string, TAccountSigner extends string | AccountMeta<string> = string, TRemainingAccounts extends readonly AccountMeta<string>[] = []> =
|
|
18
|
+
Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[TAccountQueue extends string ? WritableAccount<TAccountQueue> : TAccountQueue, TAccountTenant extends string ? ReadonlyAccount<TAccountTenant> : TAccountTenant, TAccountSigner extends string ? ReadonlySignerAccount<TAccountSigner> & AccountSignerMeta<TAccountSigner> : TAccountSigner, ...TRemainingAccounts]>;
|
|
19
|
+
|
|
20
|
+
export type FlushMatchesInstructionData = { discriminator: ReadonlyUint8Array; };
|
|
21
|
+
|
|
22
|
+
export type FlushMatchesInstructionDataArgs = { };
|
|
23
|
+
|
|
24
|
+
export function getFlushMatchesInstructionDataEncoder(): FixedSizeEncoder<FlushMatchesInstructionDataArgs> {
|
|
25
|
+
return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({ ...value, discriminator: FLUSH_MATCHES_DISCRIMINATOR }));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getFlushMatchesInstructionDataDecoder(): FixedSizeDecoder<FlushMatchesInstructionData> {
|
|
29
|
+
return getStructDecoder([['discriminator', fixDecoderSize(getBytesDecoder(), 8)]]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function getFlushMatchesInstructionDataCodec(): FixedSizeCodec<FlushMatchesInstructionDataArgs, FlushMatchesInstructionData> {
|
|
33
|
+
return combineCodec(getFlushMatchesInstructionDataEncoder(), getFlushMatchesInstructionDataDecoder());
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type FlushMatchesInput<TAccountQueue extends string = string, TAccountTenant extends string = string, TAccountSigner extends string = string> = {
|
|
37
|
+
queue: Address<TAccountQueue>;
|
|
38
|
+
tenant: Address<TAccountTenant>;
|
|
39
|
+
signer: TransactionSigner<TAccountSigner>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function getFlushMatchesInstruction<TAccountQueue extends string, TAccountTenant extends string, TAccountSigner extends string, TProgramAddress extends Address = typeof DUEL_PROGRAM_ADDRESS>(input: FlushMatchesInput<TAccountQueue, TAccountTenant, TAccountSigner>, config?: { programAddress?: TProgramAddress } ): FlushMatchesInstruction<TProgramAddress, TAccountQueue, TAccountTenant, TAccountSigner> {
|
|
43
|
+
// Program address.
|
|
44
|
+
const programAddress = config?.programAddress ?? DUEL_PROGRAM_ADDRESS;
|
|
45
|
+
|
|
46
|
+
// Original accounts.
|
|
47
|
+
const originalAccounts = { queue: { value: input.queue ?? null, isWritable: true }, tenant: { value: input.tenant ?? null, isWritable: false }, signer: { value: input.signer ?? null, isWritable: false } }
|
|
48
|
+
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
54
|
+
return Object.freeze({ accounts: [getAccountMeta("queue", accounts.queue), getAccountMeta("tenant", accounts.tenant), getAccountMeta("signer", accounts.signer)], data: getFlushMatchesInstructionDataEncoder().encode({}), programAddress } as FlushMatchesInstruction<TProgramAddress, TAccountQueue, TAccountTenant, TAccountSigner>);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export type ParsedFlushMatchesInstruction<TProgram extends string = typeof DUEL_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = { programAddress: Address<TProgram>;
|
|
58
|
+
accounts: {
|
|
59
|
+
queue: TAccountMetas[0];
|
|
60
|
+
tenant: TAccountMetas[1];
|
|
61
|
+
signer: TAccountMetas[2];
|
|
62
|
+
};
|
|
63
|
+
data: FlushMatchesInstructionData; };
|
|
64
|
+
|
|
65
|
+
export function parseFlushMatchesInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedFlushMatchesInstruction<TProgram, TAccountMetas> {
|
|
66
|
+
if (instruction.accounts.length < 3) {
|
|
67
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 3 });
|
|
68
|
+
}
|
|
69
|
+
let accountIndex = 0;
|
|
70
|
+
const getNextAccount = () => {
|
|
71
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
72
|
+
accountIndex += 1;
|
|
73
|
+
return accountMeta;
|
|
74
|
+
}
|
|
75
|
+
return { programAddress: instruction.programAddress, accounts: { queue: getNextAccount(), tenant: getNextAccount(), signer: getNextAccount() }, data: getFlushMatchesInstructionDataDecoder().decode(instruction.data) };
|
|
76
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export * from './cancelTicket';
|
|
10
|
+
export * from './closeTicket';
|
|
11
|
+
export * from './commitTickets';
|
|
12
|
+
export * from './createTicket';
|
|
13
|
+
export * from './delegateQueue';
|
|
14
|
+
export * from './delegateTicket';
|
|
15
|
+
export * from './flushMatches';
|
|
16
|
+
export * from './initializeQueue';
|
|
17
|
+
export * from './initializeTenant';
|
|
18
|
+
export * from './joinQueue';
|
|
19
|
+
export * from './processUndelegation';
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { combineCodec, fixDecoderSize, fixEncoderSize, getAddressEncoder, getBytesDecoder, getBytesEncoder, getProgramDerivedAddress, getStructDecoder, getStructEncoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, transformEncoder, type AccountMeta, type AccountSignerMeta, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, type WritableSignerAccount } from '@solana/kit';
|
|
10
|
+
import { getAccountMetaFactory, getAddressFromResolvedInstructionAccount, type ResolvedInstructionAccount } from '@solana/program-client-core';
|
|
11
|
+
import { DUEL_PROGRAM_ADDRESS } from '../programs';
|
|
12
|
+
|
|
13
|
+
export const INITIALIZE_QUEUE_DISCRIMINATOR = new Uint8Array([174, 102, 132, 232, 90, 202, 27, 20]);
|
|
14
|
+
|
|
15
|
+
export function getInitializeQueueDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(INITIALIZE_QUEUE_DISCRIMINATOR); }
|
|
16
|
+
|
|
17
|
+
export type InitializeQueueInstruction<TProgram extends string = typeof DUEL_PROGRAM_ADDRESS, TAccountQueue extends string | AccountMeta<string> = string, TAccountTenant extends string | AccountMeta<string> = string, TAccountAuthority extends string | AccountMeta<string> = string, TAccountSystemProgram extends string | AccountMeta<string> = "11111111111111111111111111111111", TRemainingAccounts extends readonly AccountMeta<string>[] = []> =
|
|
18
|
+
Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[TAccountQueue extends string ? WritableAccount<TAccountQueue> : TAccountQueue, TAccountTenant extends string ? ReadonlyAccount<TAccountTenant> : TAccountTenant, TAccountAuthority extends string ? WritableSignerAccount<TAccountAuthority> & AccountSignerMeta<TAccountAuthority> : TAccountAuthority, TAccountSystemProgram extends string ? ReadonlyAccount<TAccountSystemProgram> : TAccountSystemProgram, ...TRemainingAccounts]>;
|
|
19
|
+
|
|
20
|
+
export type InitializeQueueInstructionData = { discriminator: ReadonlyUint8Array; };
|
|
21
|
+
|
|
22
|
+
export type InitializeQueueInstructionDataArgs = { };
|
|
23
|
+
|
|
24
|
+
export function getInitializeQueueInstructionDataEncoder(): FixedSizeEncoder<InitializeQueueInstructionDataArgs> {
|
|
25
|
+
return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({ ...value, discriminator: INITIALIZE_QUEUE_DISCRIMINATOR }));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getInitializeQueueInstructionDataDecoder(): FixedSizeDecoder<InitializeQueueInstructionData> {
|
|
29
|
+
return getStructDecoder([['discriminator', fixDecoderSize(getBytesDecoder(), 8)]]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function getInitializeQueueInstructionDataCodec(): FixedSizeCodec<InitializeQueueInstructionDataArgs, InitializeQueueInstructionData> {
|
|
33
|
+
return combineCodec(getInitializeQueueInstructionDataEncoder(), getInitializeQueueInstructionDataDecoder());
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type InitializeQueueAsyncInput<TAccountQueue extends string = string, TAccountTenant extends string = string, TAccountAuthority extends string = string, TAccountSystemProgram extends string = string> = {
|
|
37
|
+
queue?: Address<TAccountQueue>;
|
|
38
|
+
tenant: Address<TAccountTenant>;
|
|
39
|
+
authority: TransactionSigner<TAccountAuthority>;
|
|
40
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function getInitializeQueueInstructionAsync<TAccountQueue extends string, TAccountTenant extends string, TAccountAuthority extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof DUEL_PROGRAM_ADDRESS>(input: InitializeQueueAsyncInput<TAccountQueue, TAccountTenant, TAccountAuthority, TAccountSystemProgram>, config?: { programAddress?: TProgramAddress } ): Promise<InitializeQueueInstruction<TProgramAddress, TAccountQueue, TAccountTenant, TAccountAuthority, TAccountSystemProgram>> {
|
|
44
|
+
// Program address.
|
|
45
|
+
const programAddress = config?.programAddress ?? DUEL_PROGRAM_ADDRESS;
|
|
46
|
+
|
|
47
|
+
// Original accounts.
|
|
48
|
+
const originalAccounts = { queue: { value: input.queue ?? null, isWritable: true }, tenant: { value: input.tenant ?? null, isWritable: false }, authority: { value: input.authority ?? null, isWritable: true }, systemProgram: { value: input.systemProgram ?? null, isWritable: false } }
|
|
49
|
+
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
// Resolve default values.
|
|
53
|
+
if (!accounts.queue.value) {
|
|
54
|
+
accounts.queue.value = await getProgramDerivedAddress({ programAddress, seeds: [getBytesEncoder().encode(new Uint8Array([113, 117, 101, 117, 101])), getAddressEncoder().encode(getAddressFromResolvedInstructionAccount("authority", accounts.authority.value))] });
|
|
55
|
+
}
|
|
56
|
+
if (!accounts.systemProgram.value) {
|
|
57
|
+
accounts.systemProgram.value = '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
61
|
+
return Object.freeze({ accounts: [getAccountMeta("queue", accounts.queue), getAccountMeta("tenant", accounts.tenant), getAccountMeta("authority", accounts.authority), getAccountMeta("systemProgram", accounts.systemProgram)], data: getInitializeQueueInstructionDataEncoder().encode({}), programAddress } as InitializeQueueInstruction<TProgramAddress, TAccountQueue, TAccountTenant, TAccountAuthority, TAccountSystemProgram>);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type InitializeQueueInput<TAccountQueue extends string = string, TAccountTenant extends string = string, TAccountAuthority extends string = string, TAccountSystemProgram extends string = string> = {
|
|
65
|
+
queue: Address<TAccountQueue>;
|
|
66
|
+
tenant: Address<TAccountTenant>;
|
|
67
|
+
authority: TransactionSigner<TAccountAuthority>;
|
|
68
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function getInitializeQueueInstruction<TAccountQueue extends string, TAccountTenant extends string, TAccountAuthority extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof DUEL_PROGRAM_ADDRESS>(input: InitializeQueueInput<TAccountQueue, TAccountTenant, TAccountAuthority, TAccountSystemProgram>, config?: { programAddress?: TProgramAddress } ): InitializeQueueInstruction<TProgramAddress, TAccountQueue, TAccountTenant, TAccountAuthority, TAccountSystemProgram> {
|
|
72
|
+
// Program address.
|
|
73
|
+
const programAddress = config?.programAddress ?? DUEL_PROGRAM_ADDRESS;
|
|
74
|
+
|
|
75
|
+
// Original accounts.
|
|
76
|
+
const originalAccounts = { queue: { value: input.queue ?? null, isWritable: true }, tenant: { value: input.tenant ?? null, isWritable: false }, authority: { value: input.authority ?? null, isWritable: true }, systemProgram: { value: input.systemProgram ?? null, isWritable: false } }
|
|
77
|
+
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
// Resolve default values.
|
|
81
|
+
if (!accounts.systemProgram.value) {
|
|
82
|
+
accounts.systemProgram.value = '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
86
|
+
return Object.freeze({ accounts: [getAccountMeta("queue", accounts.queue), getAccountMeta("tenant", accounts.tenant), getAccountMeta("authority", accounts.authority), getAccountMeta("systemProgram", accounts.systemProgram)], data: getInitializeQueueInstructionDataEncoder().encode({}), programAddress } as InitializeQueueInstruction<TProgramAddress, TAccountQueue, TAccountTenant, TAccountAuthority, TAccountSystemProgram>);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export type ParsedInitializeQueueInstruction<TProgram extends string = typeof DUEL_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = { programAddress: Address<TProgram>;
|
|
90
|
+
accounts: {
|
|
91
|
+
queue: TAccountMetas[0];
|
|
92
|
+
tenant: TAccountMetas[1];
|
|
93
|
+
authority: TAccountMetas[2];
|
|
94
|
+
systemProgram: TAccountMetas[3];
|
|
95
|
+
};
|
|
96
|
+
data: InitializeQueueInstructionData; };
|
|
97
|
+
|
|
98
|
+
export function parseInitializeQueueInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedInitializeQueueInstruction<TProgram, TAccountMetas> {
|
|
99
|
+
if (instruction.accounts.length < 4) {
|
|
100
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 4 });
|
|
101
|
+
}
|
|
102
|
+
let accountIndex = 0;
|
|
103
|
+
const getNextAccount = () => {
|
|
104
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
105
|
+
accountIndex += 1;
|
|
106
|
+
return accountMeta;
|
|
107
|
+
}
|
|
108
|
+
return { programAddress: instruction.programAddress, accounts: { queue: getNextAccount(), tenant: getNextAccount(), authority: getNextAccount(), systemProgram: getNextAccount() }, data: getInitializeQueueInstructionDataDecoder().decode(instruction.data) };
|
|
109
|
+
}
|