@1upmonster/duel 0.1.8 → 0.2.2
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/README.md +110 -59
- package/dist/admin.d.ts +25 -40
- package/dist/admin.js +93 -114
- 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 +31 -0
- package/dist/generated/duel/errors/duel.js +35 -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 +19 -0
- package/dist/generated/duel/instructions/index.js +20 -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/instructions/setupTicketPermission.d.ts +54 -0
- package/dist/generated/duel/instructions/setupTicketPermission.js +63 -0
- package/dist/generated/duel/programs/duel.d.ts +92 -0
- package/dist/generated/duel/programs/duel.js +146 -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 +25 -46
- package/dist/player.js +81 -140
- 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 +3 -6
- package/src/admin.ts +151 -161
- package/src/duel.json +66 -7
- 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 +46 -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 +20 -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/instructions/setupTicketPermission.ts +115 -0
- package/src/generated/duel/programs/duel.ts +108 -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 +129 -192
- package/src/{idl/private_matchmaking.json → rps_game.json} +547 -583
- 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 -1207
- package/dist/private_matchmaking.json +0 -534
- package/dist/types.d.ts +0 -635
- package/dist/types.js +0 -2
- package/src/idl/private_matchmaking.ts +0 -1033
- package/src/types.ts +0 -300
|
@@ -0,0 +1,100 @@
|
|
|
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 ReadonlySignerAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount } from '@solana/kit';
|
|
10
|
+
import { getAccountMetaFactory, getAddressFromResolvedInstructionAccount, type ResolvedInstructionAccount } from '@solana/program-client-core';
|
|
11
|
+
import { RPS_GAME_PROGRAM_ADDRESS } from '../programs';
|
|
12
|
+
|
|
13
|
+
export const CLOSE_PLAYER_DISCRIMINATOR = new Uint8Array([225, 227, 204, 63, 32, 122, 58, 227]);
|
|
14
|
+
|
|
15
|
+
export function getClosePlayerDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(CLOSE_PLAYER_DISCRIMINATOR); }
|
|
16
|
+
|
|
17
|
+
export type ClosePlayerInstruction<TProgram extends string = typeof RPS_GAME_PROGRAM_ADDRESS, TAccountProfile extends string | AccountMeta<string> = string, TAccountPlayer extends string | AccountMeta<string> = string, TAccountPayer extends string | AccountMeta<string> = string, TRemainingAccounts extends readonly AccountMeta<string>[] = []> =
|
|
18
|
+
Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[TAccountProfile extends string ? WritableAccount<TAccountProfile> : TAccountProfile, TAccountPlayer extends string ? ReadonlySignerAccount<TAccountPlayer> & AccountSignerMeta<TAccountPlayer> : TAccountPlayer, TAccountPayer extends string ? WritableAccount<TAccountPayer> : TAccountPayer, ...TRemainingAccounts]>;
|
|
19
|
+
|
|
20
|
+
export type ClosePlayerInstructionData = { discriminator: ReadonlyUint8Array; };
|
|
21
|
+
|
|
22
|
+
export type ClosePlayerInstructionDataArgs = { };
|
|
23
|
+
|
|
24
|
+
export function getClosePlayerInstructionDataEncoder(): FixedSizeEncoder<ClosePlayerInstructionDataArgs> {
|
|
25
|
+
return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({ ...value, discriminator: CLOSE_PLAYER_DISCRIMINATOR }));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getClosePlayerInstructionDataDecoder(): FixedSizeDecoder<ClosePlayerInstructionData> {
|
|
29
|
+
return getStructDecoder([['discriminator', fixDecoderSize(getBytesDecoder(), 8)]]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function getClosePlayerInstructionDataCodec(): FixedSizeCodec<ClosePlayerInstructionDataArgs, ClosePlayerInstructionData> {
|
|
33
|
+
return combineCodec(getClosePlayerInstructionDataEncoder(), getClosePlayerInstructionDataDecoder());
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type ClosePlayerAsyncInput<TAccountProfile extends string = string, TAccountPlayer extends string = string, TAccountPayer extends string = string> = {
|
|
37
|
+
profile?: Address<TAccountProfile>;
|
|
38
|
+
player: TransactionSigner<TAccountPlayer>;
|
|
39
|
+
payer: Address<TAccountPayer>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export async function getClosePlayerInstructionAsync<TAccountProfile extends string, TAccountPlayer extends string, TAccountPayer extends string, TProgramAddress extends Address = typeof RPS_GAME_PROGRAM_ADDRESS>(input: ClosePlayerAsyncInput<TAccountProfile, TAccountPlayer, TAccountPayer>, config?: { programAddress?: TProgramAddress } ): Promise<ClosePlayerInstruction<TProgramAddress, TAccountProfile, TAccountPlayer, TAccountPayer>> {
|
|
43
|
+
// Program address.
|
|
44
|
+
const programAddress = config?.programAddress ?? RPS_GAME_PROGRAM_ADDRESS;
|
|
45
|
+
|
|
46
|
+
// Original accounts.
|
|
47
|
+
const originalAccounts = { profile: { value: input.profile ?? null, isWritable: true }, player: { value: input.player ?? null, isWritable: false }, payer: { value: input.payer ?? null, isWritable: true } }
|
|
48
|
+
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
// Resolve default values.
|
|
52
|
+
if (!accounts.profile.value) {
|
|
53
|
+
accounts.profile.value = await getProgramDerivedAddress({ programAddress, seeds: [getBytesEncoder().encode(new Uint8Array([112, 108, 97, 121, 101, 114, 95, 112, 114, 111, 102, 105, 108, 101, 95, 118, 51, 53])), getAddressEncoder().encode(getAddressFromResolvedInstructionAccount("player", accounts.player.value))] });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
57
|
+
return Object.freeze({ accounts: [getAccountMeta("profile", accounts.profile), getAccountMeta("player", accounts.player), getAccountMeta("payer", accounts.payer)], data: getClosePlayerInstructionDataEncoder().encode({}), programAddress } as ClosePlayerInstruction<TProgramAddress, TAccountProfile, TAccountPlayer, TAccountPayer>);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type ClosePlayerInput<TAccountProfile extends string = string, TAccountPlayer extends string = string, TAccountPayer extends string = string> = {
|
|
61
|
+
profile: Address<TAccountProfile>;
|
|
62
|
+
player: TransactionSigner<TAccountPlayer>;
|
|
63
|
+
payer: Address<TAccountPayer>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function getClosePlayerInstruction<TAccountProfile extends string, TAccountPlayer extends string, TAccountPayer extends string, TProgramAddress extends Address = typeof RPS_GAME_PROGRAM_ADDRESS>(input: ClosePlayerInput<TAccountProfile, TAccountPlayer, TAccountPayer>, config?: { programAddress?: TProgramAddress } ): ClosePlayerInstruction<TProgramAddress, TAccountProfile, TAccountPlayer, TAccountPayer> {
|
|
67
|
+
// Program address.
|
|
68
|
+
const programAddress = config?.programAddress ?? RPS_GAME_PROGRAM_ADDRESS;
|
|
69
|
+
|
|
70
|
+
// Original accounts.
|
|
71
|
+
const originalAccounts = { profile: { value: input.profile ?? null, isWritable: true }, player: { value: input.player ?? null, isWritable: false }, payer: { value: input.payer ?? null, isWritable: true } }
|
|
72
|
+
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
78
|
+
return Object.freeze({ accounts: [getAccountMeta("profile", accounts.profile), getAccountMeta("player", accounts.player), getAccountMeta("payer", accounts.payer)], data: getClosePlayerInstructionDataEncoder().encode({}), programAddress } as ClosePlayerInstruction<TProgramAddress, TAccountProfile, TAccountPlayer, TAccountPayer>);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export type ParsedClosePlayerInstruction<TProgram extends string = typeof RPS_GAME_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = { programAddress: Address<TProgram>;
|
|
82
|
+
accounts: {
|
|
83
|
+
profile: TAccountMetas[0];
|
|
84
|
+
player: TAccountMetas[1];
|
|
85
|
+
payer: TAccountMetas[2];
|
|
86
|
+
};
|
|
87
|
+
data: ClosePlayerInstructionData; };
|
|
88
|
+
|
|
89
|
+
export function parseClosePlayerInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedClosePlayerInstruction<TProgram, TAccountMetas> {
|
|
90
|
+
if (instruction.accounts.length < 3) {
|
|
91
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 3 });
|
|
92
|
+
}
|
|
93
|
+
let accountIndex = 0;
|
|
94
|
+
const getNextAccount = () => {
|
|
95
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
96
|
+
accountIndex += 1;
|
|
97
|
+
return accountMeta;
|
|
98
|
+
}
|
|
99
|
+
return { programAddress: instruction.programAddress, accounts: { profile: getNextAccount(), player: getNextAccount(), payer: getNextAccount() }, data: getClosePlayerInstructionDataDecoder().decode(instruction.data) };
|
|
100
|
+
}
|
|
@@ -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 { RPS_GAME_PROGRAM_ADDRESS } from '../programs';
|
|
12
|
+
import { getAccountTypeDecoder, getAccountTypeEncoder, type AccountType, type AccountTypeArgs } from '../types';
|
|
13
|
+
|
|
14
|
+
export const DELEGATE_PDA_DISCRIMINATOR = new Uint8Array([248, 217, 193, 46, 124, 191, 64, 135]);
|
|
15
|
+
|
|
16
|
+
export function getDelegatePdaDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(DELEGATE_PDA_DISCRIMINATOR); }
|
|
17
|
+
|
|
18
|
+
export type DelegatePdaInstruction<TProgram extends string = typeof RPS_GAME_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> = "8ohu3RobXyZ2DebyJjbs2co9YCG275FUsVckEcmDbCos", 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 DelegatePdaInstructionData = { discriminator: ReadonlyUint8Array; accountType: AccountType; };
|
|
22
|
+
|
|
23
|
+
export type DelegatePdaInstructionDataArgs = { accountType: AccountTypeArgs; };
|
|
24
|
+
|
|
25
|
+
export function getDelegatePdaInstructionDataEncoder(): Encoder<DelegatePdaInstructionDataArgs> {
|
|
26
|
+
return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['accountType', getAccountTypeEncoder()]]), (value) => ({ ...value, discriminator: DELEGATE_PDA_DISCRIMINATOR }));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function getDelegatePdaInstructionDataDecoder(): Decoder<DelegatePdaInstructionData> {
|
|
30
|
+
return getStructDecoder([['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['accountType', getAccountTypeDecoder()]]);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function getDelegatePdaInstructionDataCodec(): Codec<DelegatePdaInstructionDataArgs, DelegatePdaInstructionData> {
|
|
34
|
+
return combineCodec(getDelegatePdaInstructionDataEncoder(), getDelegatePdaInstructionDataDecoder());
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type DelegatePdaAsyncInput<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: DelegatePdaInstructionDataArgs["accountType"];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export async function getDelegatePdaInstructionAsync<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 RPS_GAME_PROGRAM_ADDRESS>(input: DelegatePdaAsyncInput<TAccountBufferPda, TAccountDelegationRecordPda, TAccountDelegationMetadataPda, TAccountPda, TAccountPayer, TAccountValidator, TAccountOwnerProgram, TAccountDelegationProgram, TAccountSystemProgram>, config?: { programAddress?: TProgramAddress } ): Promise<DelegatePdaInstruction<TProgramAddress, TAccountBufferPda, TAccountDelegationRecordPda, TAccountDelegationMetadataPda, TAccountPda, TAccountPayer, TAccountValidator, TAccountOwnerProgram, TAccountDelegationProgram, TAccountSystemProgram>> {
|
|
51
|
+
// Program address.
|
|
52
|
+
const programAddress = config?.programAddress ?? RPS_GAME_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: '8ohu3RobXyZ2DebyJjbs2co9YCG275FUsVckEcmDbCos' as Address<'8ohu3RobXyZ2DebyJjbs2co9YCG275FUsVckEcmDbCos'>, 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 = '8ohu3RobXyZ2DebyJjbs2co9YCG275FUsVckEcmDbCos' as Address<'8ohu3RobXyZ2DebyJjbs2co9YCG275FUsVckEcmDbCos'>;
|
|
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: getDelegatePdaInstructionDataEncoder().encode(args as DelegatePdaInstructionDataArgs), programAddress } as DelegatePdaInstruction<TProgramAddress, TAccountBufferPda, TAccountDelegationRecordPda, TAccountDelegationMetadataPda, TAccountPda, TAccountPayer, TAccountValidator, TAccountOwnerProgram, TAccountDelegationProgram, TAccountSystemProgram>);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type DelegatePdaInput<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: DelegatePdaInstructionDataArgs["accountType"];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function getDelegatePdaInstruction<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 RPS_GAME_PROGRAM_ADDRESS>(input: DelegatePdaInput<TAccountBufferPda, TAccountDelegationRecordPda, TAccountDelegationMetadataPda, TAccountPda, TAccountPayer, TAccountValidator, TAccountOwnerProgram, TAccountDelegationProgram, TAccountSystemProgram>, config?: { programAddress?: TProgramAddress } ): DelegatePdaInstruction<TProgramAddress, TAccountBufferPda, TAccountDelegationRecordPda, TAccountDelegationMetadataPda, TAccountPda, TAccountPayer, TAccountValidator, TAccountOwnerProgram, TAccountDelegationProgram, TAccountSystemProgram> {
|
|
101
|
+
// Program address.
|
|
102
|
+
const programAddress = config?.programAddress ?? RPS_GAME_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 = '8ohu3RobXyZ2DebyJjbs2co9YCG275FUsVckEcmDbCos' as Address<'8ohu3RobXyZ2DebyJjbs2co9YCG275FUsVckEcmDbCos'>;
|
|
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: getDelegatePdaInstructionDataEncoder().encode(args as DelegatePdaInstructionDataArgs), programAddress } as DelegatePdaInstruction<TProgramAddress, TAccountBufferPda, TAccountDelegationRecordPda, TAccountDelegationMetadataPda, TAccountPda, TAccountPayer, TAccountValidator, TAccountOwnerProgram, TAccountDelegationProgram, TAccountSystemProgram>);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export type ParsedDelegatePdaInstruction<TProgram extends string = typeof RPS_GAME_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: DelegatePdaInstructionData; };
|
|
141
|
+
|
|
142
|
+
export function parseDelegatePdaInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedDelegatePdaInstruction<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 === RPS_GAME_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: getDelegatePdaInstructionDataDecoder().decode(instruction.data) };
|
|
157
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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 './closePlayer';
|
|
10
|
+
export * from './delegatePda';
|
|
11
|
+
export * from './initializePlayer';
|
|
12
|
+
export * from './makeChoice';
|
|
13
|
+
export * from './onMatchFound';
|
|
14
|
+
export * from './persistResults';
|
|
15
|
+
export * from './processUndelegation';
|
|
16
|
+
export * from './startGame';
|
|
17
|
+
export * from './startGameWithTicket';
|
|
@@ -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 { RPS_GAME_PROGRAM_ADDRESS } from '../programs';
|
|
12
|
+
|
|
13
|
+
export const INITIALIZE_PLAYER_DISCRIMINATOR = new Uint8Array([79, 249, 88, 177, 220, 62, 56, 128]);
|
|
14
|
+
|
|
15
|
+
export function getInitializePlayerDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(INITIALIZE_PLAYER_DISCRIMINATOR); }
|
|
16
|
+
|
|
17
|
+
export type InitializePlayerInstruction<TProgram extends string = typeof RPS_GAME_PROGRAM_ADDRESS, TAccountProfile extends string | AccountMeta<string> = string, TAccountPlayer extends string | AccountMeta<string> = string, TAccountPayer extends string | AccountMeta<string> = string, TAccountSystemProgram extends string | AccountMeta<string> = "11111111111111111111111111111111", TRemainingAccounts extends readonly AccountMeta<string>[] = []> =
|
|
18
|
+
Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[TAccountProfile extends string ? WritableAccount<TAccountProfile> : TAccountProfile, TAccountPlayer extends string ? WritableSignerAccount<TAccountPlayer> & AccountSignerMeta<TAccountPlayer> : TAccountPlayer, TAccountPayer extends string ? WritableSignerAccount<TAccountPayer> & AccountSignerMeta<TAccountPayer> : TAccountPayer, TAccountSystemProgram extends string ? ReadonlyAccount<TAccountSystemProgram> : TAccountSystemProgram, ...TRemainingAccounts]>;
|
|
19
|
+
|
|
20
|
+
export type InitializePlayerInstructionData = { discriminator: ReadonlyUint8Array; };
|
|
21
|
+
|
|
22
|
+
export type InitializePlayerInstructionDataArgs = { };
|
|
23
|
+
|
|
24
|
+
export function getInitializePlayerInstructionDataEncoder(): FixedSizeEncoder<InitializePlayerInstructionDataArgs> {
|
|
25
|
+
return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({ ...value, discriminator: INITIALIZE_PLAYER_DISCRIMINATOR }));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getInitializePlayerInstructionDataDecoder(): FixedSizeDecoder<InitializePlayerInstructionData> {
|
|
29
|
+
return getStructDecoder([['discriminator', fixDecoderSize(getBytesDecoder(), 8)]]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function getInitializePlayerInstructionDataCodec(): FixedSizeCodec<InitializePlayerInstructionDataArgs, InitializePlayerInstructionData> {
|
|
33
|
+
return combineCodec(getInitializePlayerInstructionDataEncoder(), getInitializePlayerInstructionDataDecoder());
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type InitializePlayerAsyncInput<TAccountProfile extends string = string, TAccountPlayer extends string = string, TAccountPayer extends string = string, TAccountSystemProgram extends string = string> = {
|
|
37
|
+
profile?: Address<TAccountProfile>;
|
|
38
|
+
player: TransactionSigner<TAccountPlayer>;
|
|
39
|
+
payer: TransactionSigner<TAccountPayer>;
|
|
40
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function getInitializePlayerInstructionAsync<TAccountProfile extends string, TAccountPlayer extends string, TAccountPayer extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof RPS_GAME_PROGRAM_ADDRESS>(input: InitializePlayerAsyncInput<TAccountProfile, TAccountPlayer, TAccountPayer, TAccountSystemProgram>, config?: { programAddress?: TProgramAddress } ): Promise<InitializePlayerInstruction<TProgramAddress, TAccountProfile, TAccountPlayer, TAccountPayer, TAccountSystemProgram>> {
|
|
44
|
+
// Program address.
|
|
45
|
+
const programAddress = config?.programAddress ?? RPS_GAME_PROGRAM_ADDRESS;
|
|
46
|
+
|
|
47
|
+
// Original accounts.
|
|
48
|
+
const originalAccounts = { profile: { value: input.profile ?? null, isWritable: true }, player: { value: input.player ?? null, isWritable: true }, payer: { value: input.payer ?? 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.profile.value) {
|
|
54
|
+
accounts.profile.value = await getProgramDerivedAddress({ programAddress, seeds: [getBytesEncoder().encode(new Uint8Array([112, 108, 97, 121, 101, 114, 95, 112, 114, 111, 102, 105, 108, 101, 95, 118, 51, 53])), getAddressEncoder().encode(getAddressFromResolvedInstructionAccount("player", accounts.player.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("profile", accounts.profile), getAccountMeta("player", accounts.player), getAccountMeta("payer", accounts.payer), getAccountMeta("systemProgram", accounts.systemProgram)], data: getInitializePlayerInstructionDataEncoder().encode({}), programAddress } as InitializePlayerInstruction<TProgramAddress, TAccountProfile, TAccountPlayer, TAccountPayer, TAccountSystemProgram>);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type InitializePlayerInput<TAccountProfile extends string = string, TAccountPlayer extends string = string, TAccountPayer extends string = string, TAccountSystemProgram extends string = string> = {
|
|
65
|
+
profile: Address<TAccountProfile>;
|
|
66
|
+
player: TransactionSigner<TAccountPlayer>;
|
|
67
|
+
payer: TransactionSigner<TAccountPayer>;
|
|
68
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function getInitializePlayerInstruction<TAccountProfile extends string, TAccountPlayer extends string, TAccountPayer extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof RPS_GAME_PROGRAM_ADDRESS>(input: InitializePlayerInput<TAccountProfile, TAccountPlayer, TAccountPayer, TAccountSystemProgram>, config?: { programAddress?: TProgramAddress } ): InitializePlayerInstruction<TProgramAddress, TAccountProfile, TAccountPlayer, TAccountPayer, TAccountSystemProgram> {
|
|
72
|
+
// Program address.
|
|
73
|
+
const programAddress = config?.programAddress ?? RPS_GAME_PROGRAM_ADDRESS;
|
|
74
|
+
|
|
75
|
+
// Original accounts.
|
|
76
|
+
const originalAccounts = { profile: { value: input.profile ?? null, isWritable: true }, player: { value: input.player ?? null, isWritable: true }, payer: { value: input.payer ?? 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("profile", accounts.profile), getAccountMeta("player", accounts.player), getAccountMeta("payer", accounts.payer), getAccountMeta("systemProgram", accounts.systemProgram)], data: getInitializePlayerInstructionDataEncoder().encode({}), programAddress } as InitializePlayerInstruction<TProgramAddress, TAccountProfile, TAccountPlayer, TAccountPayer, TAccountSystemProgram>);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export type ParsedInitializePlayerInstruction<TProgram extends string = typeof RPS_GAME_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = { programAddress: Address<TProgram>;
|
|
90
|
+
accounts: {
|
|
91
|
+
profile: TAccountMetas[0];
|
|
92
|
+
player: TAccountMetas[1];
|
|
93
|
+
payer: TAccountMetas[2];
|
|
94
|
+
systemProgram: TAccountMetas[3];
|
|
95
|
+
};
|
|
96
|
+
data: InitializePlayerInstructionData; };
|
|
97
|
+
|
|
98
|
+
export function parseInitializePlayerInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedInitializePlayerInstruction<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: { profile: getNextAccount(), player: getNextAccount(), payer: getNextAccount(), systemProgram: getNextAccount() }, data: getInitializePlayerInstructionDataDecoder().decode(instruction.data) };
|
|
109
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
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 ReadonlySignerAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount } from '@solana/kit';
|
|
10
|
+
import { getAccountMetaFactory, type ResolvedInstructionAccount } from '@solana/program-client-core';
|
|
11
|
+
import { RPS_GAME_PROGRAM_ADDRESS } from '../programs';
|
|
12
|
+
import { getChoiceDecoder, getChoiceEncoder, type Choice, type ChoiceArgs } from '../types';
|
|
13
|
+
|
|
14
|
+
export const MAKE_CHOICE_DISCRIMINATOR = new Uint8Array([207, 18, 251, 32, 135, 122, 160, 77]);
|
|
15
|
+
|
|
16
|
+
export function getMakeChoiceDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(MAKE_CHOICE_DISCRIMINATOR); }
|
|
17
|
+
|
|
18
|
+
export type MakeChoiceInstruction<TProgram extends string = typeof RPS_GAME_PROGRAM_ADDRESS, TAccountGameSession extends string | AccountMeta<string> = string, TAccountPlayer1Profile extends string | AccountMeta<string> = string, TAccountPlayer2Profile extends string | AccountMeta<string> = string, TAccountPlayer extends string | AccountMeta<string> = string, TRemainingAccounts extends readonly AccountMeta<string>[] = []> =
|
|
19
|
+
Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[TAccountGameSession extends string ? WritableAccount<TAccountGameSession> : TAccountGameSession, TAccountPlayer1Profile extends string ? WritableAccount<TAccountPlayer1Profile> : TAccountPlayer1Profile, TAccountPlayer2Profile extends string ? WritableAccount<TAccountPlayer2Profile> : TAccountPlayer2Profile, TAccountPlayer extends string ? ReadonlySignerAccount<TAccountPlayer> & AccountSignerMeta<TAccountPlayer> : TAccountPlayer, ...TRemainingAccounts]>;
|
|
20
|
+
|
|
21
|
+
export type MakeChoiceInstructionData = { discriminator: ReadonlyUint8Array; choice: Choice; };
|
|
22
|
+
|
|
23
|
+
export type MakeChoiceInstructionDataArgs = { choice: ChoiceArgs; };
|
|
24
|
+
|
|
25
|
+
export function getMakeChoiceInstructionDataEncoder(): FixedSizeEncoder<MakeChoiceInstructionDataArgs> {
|
|
26
|
+
return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['choice', getChoiceEncoder()]]), (value) => ({ ...value, discriminator: MAKE_CHOICE_DISCRIMINATOR }));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function getMakeChoiceInstructionDataDecoder(): FixedSizeDecoder<MakeChoiceInstructionData> {
|
|
30
|
+
return getStructDecoder([['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['choice', getChoiceDecoder()]]);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function getMakeChoiceInstructionDataCodec(): FixedSizeCodec<MakeChoiceInstructionDataArgs, MakeChoiceInstructionData> {
|
|
34
|
+
return combineCodec(getMakeChoiceInstructionDataEncoder(), getMakeChoiceInstructionDataDecoder());
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type MakeChoiceInput<TAccountGameSession extends string = string, TAccountPlayer1Profile extends string = string, TAccountPlayer2Profile extends string = string, TAccountPlayer extends string = string> = {
|
|
38
|
+
gameSession: Address<TAccountGameSession>;
|
|
39
|
+
player1Profile: Address<TAccountPlayer1Profile>;
|
|
40
|
+
player2Profile: Address<TAccountPlayer2Profile>;
|
|
41
|
+
player: TransactionSigner<TAccountPlayer>;
|
|
42
|
+
choice: MakeChoiceInstructionDataArgs["choice"];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function getMakeChoiceInstruction<TAccountGameSession extends string, TAccountPlayer1Profile extends string, TAccountPlayer2Profile extends string, TAccountPlayer extends string, TProgramAddress extends Address = typeof RPS_GAME_PROGRAM_ADDRESS>(input: MakeChoiceInput<TAccountGameSession, TAccountPlayer1Profile, TAccountPlayer2Profile, TAccountPlayer>, config?: { programAddress?: TProgramAddress } ): MakeChoiceInstruction<TProgramAddress, TAccountGameSession, TAccountPlayer1Profile, TAccountPlayer2Profile, TAccountPlayer> {
|
|
46
|
+
// Program address.
|
|
47
|
+
const programAddress = config?.programAddress ?? RPS_GAME_PROGRAM_ADDRESS;
|
|
48
|
+
|
|
49
|
+
// Original accounts.
|
|
50
|
+
const originalAccounts = { gameSession: { value: input.gameSession ?? null, isWritable: true }, player1Profile: { value: input.player1Profile ?? null, isWritable: true }, player2Profile: { value: input.player2Profile ?? null, isWritable: true }, player: { value: input.player ?? null, isWritable: false } }
|
|
51
|
+
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
// Original args.
|
|
55
|
+
const args = { ...input, };
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
61
|
+
return Object.freeze({ accounts: [getAccountMeta("gameSession", accounts.gameSession), getAccountMeta("player1Profile", accounts.player1Profile), getAccountMeta("player2Profile", accounts.player2Profile), getAccountMeta("player", accounts.player)], data: getMakeChoiceInstructionDataEncoder().encode(args as MakeChoiceInstructionDataArgs), programAddress } as MakeChoiceInstruction<TProgramAddress, TAccountGameSession, TAccountPlayer1Profile, TAccountPlayer2Profile, TAccountPlayer>);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type ParsedMakeChoiceInstruction<TProgram extends string = typeof RPS_GAME_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = { programAddress: Address<TProgram>;
|
|
65
|
+
accounts: {
|
|
66
|
+
gameSession: TAccountMetas[0];
|
|
67
|
+
player1Profile: TAccountMetas[1];
|
|
68
|
+
player2Profile: TAccountMetas[2];
|
|
69
|
+
player: TAccountMetas[3];
|
|
70
|
+
};
|
|
71
|
+
data: MakeChoiceInstructionData; };
|
|
72
|
+
|
|
73
|
+
export function parseMakeChoiceInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedMakeChoiceInstruction<TProgram, TAccountMetas> {
|
|
74
|
+
if (instruction.accounts.length < 4) {
|
|
75
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 4 });
|
|
76
|
+
}
|
|
77
|
+
let accountIndex = 0;
|
|
78
|
+
const getNextAccount = () => {
|
|
79
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
80
|
+
accountIndex += 1;
|
|
81
|
+
return accountMeta;
|
|
82
|
+
}
|
|
83
|
+
return { programAddress: instruction.programAddress, accounts: { gameSession: getNextAccount(), player1Profile: getNextAccount(), player2Profile: getNextAccount(), player: getNextAccount() }, data: getMakeChoiceInstructionDataDecoder().decode(instruction.data) };
|
|
84
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
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, getAddressDecoder, getAddressEncoder, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, getU64Decoder, getU64Encoder, 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 ReadonlySignerAccount, type ReadonlyUint8Array, type TransactionSigner } from '@solana/kit';
|
|
10
|
+
import { getAccountMetaFactory, type ResolvedInstructionAccount } from '@solana/program-client-core';
|
|
11
|
+
import { RPS_GAME_PROGRAM_ADDRESS } from '../programs';
|
|
12
|
+
|
|
13
|
+
export const ON_MATCH_FOUND_DISCRIMINATOR = new Uint8Array([66, 209, 170, 159, 10, 195, 34, 214]);
|
|
14
|
+
|
|
15
|
+
export function getOnMatchFoundDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(ON_MATCH_FOUND_DISCRIMINATOR); }
|
|
16
|
+
|
|
17
|
+
export type OnMatchFoundInstruction<TProgram extends string = typeof RPS_GAME_PROGRAM_ADDRESS, TAccountSigner extends string | AccountMeta<string> = string, TRemainingAccounts extends readonly AccountMeta<string>[] = []> =
|
|
18
|
+
Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[TAccountSigner extends string ? ReadonlySignerAccount<TAccountSigner> & AccountSignerMeta<TAccountSigner> : TAccountSigner, ...TRemainingAccounts]>;
|
|
19
|
+
|
|
20
|
+
export type OnMatchFoundInstructionData = { discriminator: ReadonlyUint8Array; player1: Address; player2: Address; matchId: bigint; };
|
|
21
|
+
|
|
22
|
+
export type OnMatchFoundInstructionDataArgs = { player1: Address; player2: Address; matchId: number | bigint; };
|
|
23
|
+
|
|
24
|
+
export function getOnMatchFoundInstructionDataEncoder(): FixedSizeEncoder<OnMatchFoundInstructionDataArgs> {
|
|
25
|
+
return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['player1', getAddressEncoder()], ['player2', getAddressEncoder()], ['matchId', getU64Encoder()]]), (value) => ({ ...value, discriminator: ON_MATCH_FOUND_DISCRIMINATOR }));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getOnMatchFoundInstructionDataDecoder(): FixedSizeDecoder<OnMatchFoundInstructionData> {
|
|
29
|
+
return getStructDecoder([['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['player1', getAddressDecoder()], ['player2', getAddressDecoder()], ['matchId', getU64Decoder()]]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function getOnMatchFoundInstructionDataCodec(): FixedSizeCodec<OnMatchFoundInstructionDataArgs, OnMatchFoundInstructionData> {
|
|
33
|
+
return combineCodec(getOnMatchFoundInstructionDataEncoder(), getOnMatchFoundInstructionDataDecoder());
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type OnMatchFoundInput<TAccountSigner extends string = string> = {
|
|
37
|
+
signer: TransactionSigner<TAccountSigner>;
|
|
38
|
+
player1: OnMatchFoundInstructionDataArgs["player1"];
|
|
39
|
+
player2: OnMatchFoundInstructionDataArgs["player2"];
|
|
40
|
+
matchId: OnMatchFoundInstructionDataArgs["matchId"];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function getOnMatchFoundInstruction<TAccountSigner extends string, TProgramAddress extends Address = typeof RPS_GAME_PROGRAM_ADDRESS>(input: OnMatchFoundInput<TAccountSigner>, config?: { programAddress?: TProgramAddress } ): OnMatchFoundInstruction<TProgramAddress, TAccountSigner> {
|
|
44
|
+
// Program address.
|
|
45
|
+
const programAddress = config?.programAddress ?? RPS_GAME_PROGRAM_ADDRESS;
|
|
46
|
+
|
|
47
|
+
// Original accounts.
|
|
48
|
+
const originalAccounts = { signer: { value: input.signer ?? null, isWritable: false } }
|
|
49
|
+
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
// Original args.
|
|
53
|
+
const args = { ...input, };
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
59
|
+
return Object.freeze({ accounts: [getAccountMeta("signer", accounts.signer)], data: getOnMatchFoundInstructionDataEncoder().encode(args as OnMatchFoundInstructionDataArgs), programAddress } as OnMatchFoundInstruction<TProgramAddress, TAccountSigner>);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type ParsedOnMatchFoundInstruction<TProgram extends string = typeof RPS_GAME_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = { programAddress: Address<TProgram>;
|
|
63
|
+
accounts: {
|
|
64
|
+
signer: TAccountMetas[0];
|
|
65
|
+
};
|
|
66
|
+
data: OnMatchFoundInstructionData; };
|
|
67
|
+
|
|
68
|
+
export function parseOnMatchFoundInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedOnMatchFoundInstruction<TProgram, TAccountMetas> {
|
|
69
|
+
if (instruction.accounts.length < 1) {
|
|
70
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 1 });
|
|
71
|
+
}
|
|
72
|
+
let accountIndex = 0;
|
|
73
|
+
const getNextAccount = () => {
|
|
74
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
75
|
+
accountIndex += 1;
|
|
76
|
+
return accountMeta;
|
|
77
|
+
}
|
|
78
|
+
return { programAddress: instruction.programAddress, accounts: { signer: getNextAccount() }, data: getOnMatchFoundInstructionDataDecoder().decode(instruction.data) };
|
|
79
|
+
}
|