@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,126 @@
|
|
|
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, getOptionDecoder, getOptionEncoder, getProgramDerivedAddress, getStructDecoder, getStructEncoder, getU32Decoder, getU32Encoder, getU64Decoder, getU64Encoder, getU8Decoder, getU8Encoder, 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 Option, type OptionOrNullable, 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_TENANT_DISCRIMINATOR = new Uint8Array([94, 120, 34, 186, 57, 167, 241, 206]);
|
|
14
|
+
|
|
15
|
+
export function getInitializeTenantDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(INITIALIZE_TENANT_DISCRIMINATOR); }
|
|
16
|
+
|
|
17
|
+
export type InitializeTenantInstruction<TProgram extends string = typeof DUEL_PROGRAM_ADDRESS, 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<[TAccountTenant extends string ? WritableAccount<TAccountTenant> : TAccountTenant, TAccountAuthority extends string ? WritableSignerAccount<TAccountAuthority> & AccountSignerMeta<TAccountAuthority> : TAccountAuthority, TAccountSystemProgram extends string ? ReadonlyAccount<TAccountSystemProgram> : TAccountSystemProgram, ...TRemainingAccounts]>;
|
|
19
|
+
|
|
20
|
+
export type InitializeTenantInstructionData = { discriminator: ReadonlyUint8Array; tenantProgramId: Address; eloOffset: number; eloSize: number; eloWindow: bigint; callbackProgramId: Option<Address>; callbackDiscriminator: Option<ReadonlyUint8Array>; };
|
|
21
|
+
|
|
22
|
+
export type InitializeTenantInstructionDataArgs = { tenantProgramId: Address; eloOffset: number; eloSize: number; eloWindow: number | bigint; callbackProgramId: OptionOrNullable<Address>; callbackDiscriminator: OptionOrNullable<ReadonlyUint8Array>; };
|
|
23
|
+
|
|
24
|
+
export function getInitializeTenantInstructionDataEncoder(): Encoder<InitializeTenantInstructionDataArgs> {
|
|
25
|
+
return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['tenantProgramId', getAddressEncoder()], ['eloOffset', getU32Encoder()], ['eloSize', getU8Encoder()], ['eloWindow', getU64Encoder()], ['callbackProgramId', getOptionEncoder(getAddressEncoder())], ['callbackDiscriminator', getOptionEncoder(fixEncoderSize(getBytesEncoder(), 8))]]), (value) => ({ ...value, discriminator: INITIALIZE_TENANT_DISCRIMINATOR }));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getInitializeTenantInstructionDataDecoder(): Decoder<InitializeTenantInstructionData> {
|
|
29
|
+
return getStructDecoder([['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['tenantProgramId', getAddressDecoder()], ['eloOffset', getU32Decoder()], ['eloSize', getU8Decoder()], ['eloWindow', getU64Decoder()], ['callbackProgramId', getOptionDecoder(getAddressDecoder())], ['callbackDiscriminator', getOptionDecoder(fixDecoderSize(getBytesDecoder(), 8))]]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function getInitializeTenantInstructionDataCodec(): Codec<InitializeTenantInstructionDataArgs, InitializeTenantInstructionData> {
|
|
33
|
+
return combineCodec(getInitializeTenantInstructionDataEncoder(), getInitializeTenantInstructionDataDecoder());
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type InitializeTenantAsyncInput<TAccountTenant extends string = string, TAccountAuthority extends string = string, TAccountSystemProgram extends string = string> = {
|
|
37
|
+
tenant?: Address<TAccountTenant>;
|
|
38
|
+
authority: TransactionSigner<TAccountAuthority>;
|
|
39
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
40
|
+
tenantProgramId: InitializeTenantInstructionDataArgs["tenantProgramId"];
|
|
41
|
+
eloOffset: InitializeTenantInstructionDataArgs["eloOffset"];
|
|
42
|
+
eloSize: InitializeTenantInstructionDataArgs["eloSize"];
|
|
43
|
+
eloWindow: InitializeTenantInstructionDataArgs["eloWindow"];
|
|
44
|
+
callbackProgramId: InitializeTenantInstructionDataArgs["callbackProgramId"];
|
|
45
|
+
callbackDiscriminator: InitializeTenantInstructionDataArgs["callbackDiscriminator"];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export async function getInitializeTenantInstructionAsync<TAccountTenant extends string, TAccountAuthority extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof DUEL_PROGRAM_ADDRESS>(input: InitializeTenantAsyncInput<TAccountTenant, TAccountAuthority, TAccountSystemProgram>, config?: { programAddress?: TProgramAddress } ): Promise<InitializeTenantInstruction<TProgramAddress, TAccountTenant, TAccountAuthority, TAccountSystemProgram>> {
|
|
49
|
+
// Program address.
|
|
50
|
+
const programAddress = config?.programAddress ?? DUEL_PROGRAM_ADDRESS;
|
|
51
|
+
|
|
52
|
+
// Original accounts.
|
|
53
|
+
const originalAccounts = { tenant: { value: input.tenant ?? null, isWritable: true }, authority: { value: input.authority ?? null, isWritable: true }, systemProgram: { value: input.systemProgram ?? null, isWritable: false } }
|
|
54
|
+
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
// Original args.
|
|
58
|
+
const args = { ...input, };
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
// Resolve default values.
|
|
62
|
+
if (!accounts.tenant.value) {
|
|
63
|
+
accounts.tenant.value = await getProgramDerivedAddress({ programAddress, seeds: [getBytesEncoder().encode(new Uint8Array([116, 101, 110, 97, 110, 116])), getAddressEncoder().encode(getAddressFromResolvedInstructionAccount("authority", accounts.authority.value))] });
|
|
64
|
+
}
|
|
65
|
+
if (!accounts.systemProgram.value) {
|
|
66
|
+
accounts.systemProgram.value = '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
70
|
+
return Object.freeze({ accounts: [getAccountMeta("tenant", accounts.tenant), getAccountMeta("authority", accounts.authority), getAccountMeta("systemProgram", accounts.systemProgram)], data: getInitializeTenantInstructionDataEncoder().encode(args as InitializeTenantInstructionDataArgs), programAddress } as InitializeTenantInstruction<TProgramAddress, TAccountTenant, TAccountAuthority, TAccountSystemProgram>);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export type InitializeTenantInput<TAccountTenant extends string = string, TAccountAuthority extends string = string, TAccountSystemProgram extends string = string> = {
|
|
74
|
+
tenant: Address<TAccountTenant>;
|
|
75
|
+
authority: TransactionSigner<TAccountAuthority>;
|
|
76
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
77
|
+
tenantProgramId: InitializeTenantInstructionDataArgs["tenantProgramId"];
|
|
78
|
+
eloOffset: InitializeTenantInstructionDataArgs["eloOffset"];
|
|
79
|
+
eloSize: InitializeTenantInstructionDataArgs["eloSize"];
|
|
80
|
+
eloWindow: InitializeTenantInstructionDataArgs["eloWindow"];
|
|
81
|
+
callbackProgramId: InitializeTenantInstructionDataArgs["callbackProgramId"];
|
|
82
|
+
callbackDiscriminator: InitializeTenantInstructionDataArgs["callbackDiscriminator"];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function getInitializeTenantInstruction<TAccountTenant extends string, TAccountAuthority extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof DUEL_PROGRAM_ADDRESS>(input: InitializeTenantInput<TAccountTenant, TAccountAuthority, TAccountSystemProgram>, config?: { programAddress?: TProgramAddress } ): InitializeTenantInstruction<TProgramAddress, TAccountTenant, TAccountAuthority, TAccountSystemProgram> {
|
|
86
|
+
// Program address.
|
|
87
|
+
const programAddress = config?.programAddress ?? DUEL_PROGRAM_ADDRESS;
|
|
88
|
+
|
|
89
|
+
// Original accounts.
|
|
90
|
+
const originalAccounts = { tenant: { value: input.tenant ?? null, isWritable: true }, authority: { value: input.authority ?? null, isWritable: true }, systemProgram: { value: input.systemProgram ?? null, isWritable: false } }
|
|
91
|
+
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
// Original args.
|
|
95
|
+
const args = { ...input, };
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
// Resolve default values.
|
|
99
|
+
if (!accounts.systemProgram.value) {
|
|
100
|
+
accounts.systemProgram.value = '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
104
|
+
return Object.freeze({ accounts: [getAccountMeta("tenant", accounts.tenant), getAccountMeta("authority", accounts.authority), getAccountMeta("systemProgram", accounts.systemProgram)], data: getInitializeTenantInstructionDataEncoder().encode(args as InitializeTenantInstructionDataArgs), programAddress } as InitializeTenantInstruction<TProgramAddress, TAccountTenant, TAccountAuthority, TAccountSystemProgram>);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export type ParsedInitializeTenantInstruction<TProgram extends string = typeof DUEL_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = { programAddress: Address<TProgram>;
|
|
108
|
+
accounts: {
|
|
109
|
+
tenant: TAccountMetas[0];
|
|
110
|
+
authority: TAccountMetas[1];
|
|
111
|
+
systemProgram: TAccountMetas[2];
|
|
112
|
+
};
|
|
113
|
+
data: InitializeTenantInstructionData; };
|
|
114
|
+
|
|
115
|
+
export function parseInitializeTenantInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedInitializeTenantInstruction<TProgram, TAccountMetas> {
|
|
116
|
+
if (instruction.accounts.length < 3) {
|
|
117
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 3 });
|
|
118
|
+
}
|
|
119
|
+
let accountIndex = 0;
|
|
120
|
+
const getNextAccount = () => {
|
|
121
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
122
|
+
accountIndex += 1;
|
|
123
|
+
return accountMeta;
|
|
124
|
+
}
|
|
125
|
+
return { programAddress: instruction.programAddress, accounts: { tenant: getNextAccount(), authority: getNextAccount(), systemProgram: getNextAccount() }, data: getInitializeTenantInstructionDataDecoder().decode(instruction.data) };
|
|
126
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
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 ReadonlySignerAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount } 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 JOIN_QUEUE_DISCRIMINATOR = new Uint8Array([157, 115, 48, 109, 65, 86, 203, 238]);
|
|
14
|
+
|
|
15
|
+
export function getJoinQueueDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(JOIN_QUEUE_DISCRIMINATOR); }
|
|
16
|
+
|
|
17
|
+
export type JoinQueueInstruction<TProgram extends string = typeof DUEL_PROGRAM_ADDRESS, TAccountQueue extends string | AccountMeta<string> = string, TAccountTenant extends string | AccountMeta<string> = string, TAccountPlayerData extends string | AccountMeta<string> = string, TAccountPlayerTicket 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, TAccountPlayerData extends string ? WritableAccount<TAccountPlayerData> : TAccountPlayerData, TAccountPlayerTicket extends string ? WritableAccount<TAccountPlayerTicket> : TAccountPlayerTicket, TAccountSigner extends string ? ReadonlySignerAccount<TAccountSigner> & AccountSignerMeta<TAccountSigner> : TAccountSigner, ...TRemainingAccounts]>;
|
|
19
|
+
|
|
20
|
+
export type JoinQueueInstructionData = { discriminator: ReadonlyUint8Array; };
|
|
21
|
+
|
|
22
|
+
export type JoinQueueInstructionDataArgs = { };
|
|
23
|
+
|
|
24
|
+
export function getJoinQueueInstructionDataEncoder(): FixedSizeEncoder<JoinQueueInstructionDataArgs> {
|
|
25
|
+
return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({ ...value, discriminator: JOIN_QUEUE_DISCRIMINATOR }));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getJoinQueueInstructionDataDecoder(): FixedSizeDecoder<JoinQueueInstructionData> {
|
|
29
|
+
return getStructDecoder([['discriminator', fixDecoderSize(getBytesDecoder(), 8)]]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function getJoinQueueInstructionDataCodec(): FixedSizeCodec<JoinQueueInstructionDataArgs, JoinQueueInstructionData> {
|
|
33
|
+
return combineCodec(getJoinQueueInstructionDataEncoder(), getJoinQueueInstructionDataDecoder());
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type JoinQueueAsyncInput<TAccountQueue extends string = string, TAccountTenant extends string = string, TAccountPlayerData extends string = string, TAccountPlayerTicket extends string = string, TAccountSigner extends string = string> = {
|
|
37
|
+
queue: Address<TAccountQueue>;
|
|
38
|
+
tenant: Address<TAccountTenant>;
|
|
39
|
+
playerData: Address<TAccountPlayerData>;
|
|
40
|
+
playerTicket?: Address<TAccountPlayerTicket>;
|
|
41
|
+
signer: TransactionSigner<TAccountSigner>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function getJoinQueueInstructionAsync<TAccountQueue extends string, TAccountTenant extends string, TAccountPlayerData extends string, TAccountPlayerTicket extends string, TAccountSigner extends string, TProgramAddress extends Address = typeof DUEL_PROGRAM_ADDRESS>(input: JoinQueueAsyncInput<TAccountQueue, TAccountTenant, TAccountPlayerData, TAccountPlayerTicket, TAccountSigner>, config?: { programAddress?: TProgramAddress } ): Promise<JoinQueueInstruction<TProgramAddress, TAccountQueue, TAccountTenant, TAccountPlayerData, TAccountPlayerTicket, TAccountSigner>> {
|
|
45
|
+
// Program address.
|
|
46
|
+
const programAddress = config?.programAddress ?? DUEL_PROGRAM_ADDRESS;
|
|
47
|
+
|
|
48
|
+
// Original accounts.
|
|
49
|
+
const originalAccounts = { queue: { value: input.queue ?? null, isWritable: true }, tenant: { value: input.tenant ?? null, isWritable: false }, playerData: { value: input.playerData ?? null, isWritable: true }, playerTicket: { value: input.playerTicket ?? null, isWritable: true }, signer: { value: input.signer ?? null, isWritable: false } }
|
|
50
|
+
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
// Resolve default values.
|
|
54
|
+
if (!accounts.playerTicket.value) {
|
|
55
|
+
accounts.playerTicket.value = await getProgramDerivedAddress({ programAddress, seeds: [getBytesEncoder().encode(new Uint8Array([116, 105, 99, 107, 101, 116])), getAddressEncoder().encode(getAddressFromResolvedInstructionAccount("signer", accounts.signer.value)), getAddressEncoder().encode(getAddressFromResolvedInstructionAccount("tenant", accounts.tenant.value))] });
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
59
|
+
return Object.freeze({ accounts: [getAccountMeta("queue", accounts.queue), getAccountMeta("tenant", accounts.tenant), getAccountMeta("playerData", accounts.playerData), getAccountMeta("playerTicket", accounts.playerTicket), getAccountMeta("signer", accounts.signer)], data: getJoinQueueInstructionDataEncoder().encode({}), programAddress } as JoinQueueInstruction<TProgramAddress, TAccountQueue, TAccountTenant, TAccountPlayerData, TAccountPlayerTicket, TAccountSigner>);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type JoinQueueInput<TAccountQueue extends string = string, TAccountTenant extends string = string, TAccountPlayerData extends string = string, TAccountPlayerTicket extends string = string, TAccountSigner extends string = string> = {
|
|
63
|
+
queue: Address<TAccountQueue>;
|
|
64
|
+
tenant: Address<TAccountTenant>;
|
|
65
|
+
playerData: Address<TAccountPlayerData>;
|
|
66
|
+
playerTicket: Address<TAccountPlayerTicket>;
|
|
67
|
+
signer: TransactionSigner<TAccountSigner>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function getJoinQueueInstruction<TAccountQueue extends string, TAccountTenant extends string, TAccountPlayerData extends string, TAccountPlayerTicket extends string, TAccountSigner extends string, TProgramAddress extends Address = typeof DUEL_PROGRAM_ADDRESS>(input: JoinQueueInput<TAccountQueue, TAccountTenant, TAccountPlayerData, TAccountPlayerTicket, TAccountSigner>, config?: { programAddress?: TProgramAddress } ): JoinQueueInstruction<TProgramAddress, TAccountQueue, TAccountTenant, TAccountPlayerData, TAccountPlayerTicket, TAccountSigner> {
|
|
71
|
+
// Program address.
|
|
72
|
+
const programAddress = config?.programAddress ?? DUEL_PROGRAM_ADDRESS;
|
|
73
|
+
|
|
74
|
+
// Original accounts.
|
|
75
|
+
const originalAccounts = { queue: { value: input.queue ?? null, isWritable: true }, tenant: { value: input.tenant ?? null, isWritable: false }, playerData: { value: input.playerData ?? null, isWritable: true }, playerTicket: { value: input.playerTicket ?? null, isWritable: true }, signer: { value: input.signer ?? null, isWritable: false } }
|
|
76
|
+
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
82
|
+
return Object.freeze({ accounts: [getAccountMeta("queue", accounts.queue), getAccountMeta("tenant", accounts.tenant), getAccountMeta("playerData", accounts.playerData), getAccountMeta("playerTicket", accounts.playerTicket), getAccountMeta("signer", accounts.signer)], data: getJoinQueueInstructionDataEncoder().encode({}), programAddress } as JoinQueueInstruction<TProgramAddress, TAccountQueue, TAccountTenant, TAccountPlayerData, TAccountPlayerTicket, TAccountSigner>);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export type ParsedJoinQueueInstruction<TProgram extends string = typeof DUEL_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = { programAddress: Address<TProgram>;
|
|
86
|
+
accounts: {
|
|
87
|
+
queue: TAccountMetas[0];
|
|
88
|
+
tenant: TAccountMetas[1];
|
|
89
|
+
playerData: TAccountMetas[2];
|
|
90
|
+
playerTicket: TAccountMetas[3];
|
|
91
|
+
signer: TAccountMetas[4];
|
|
92
|
+
};
|
|
93
|
+
data: JoinQueueInstructionData; };
|
|
94
|
+
|
|
95
|
+
export function parseJoinQueueInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedJoinQueueInstruction<TProgram, TAccountMetas> {
|
|
96
|
+
if (instruction.accounts.length < 5) {
|
|
97
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 5 });
|
|
98
|
+
}
|
|
99
|
+
let accountIndex = 0;
|
|
100
|
+
const getNextAccount = () => {
|
|
101
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
102
|
+
accountIndex += 1;
|
|
103
|
+
return accountMeta;
|
|
104
|
+
}
|
|
105
|
+
return { programAddress: instruction.programAddress, accounts: { queue: getNextAccount(), tenant: getNextAccount(), playerData: getNextAccount(), playerTicket: getNextAccount(), signer: getNextAccount() }, data: getJoinQueueInstructionDataDecoder().decode(instruction.data) };
|
|
106
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
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 { addDecoderSizePrefix, addEncoderSizePrefix, combineCodec, fixDecoderSize, fixEncoderSize, getArrayDecoder, getArrayEncoder, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, getU32Decoder, getU32Encoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, transformEncoder, type AccountMeta, type Address, type Codec, type Decoder, type Encoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyAccount, type ReadonlyUint8Array, 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 PROCESS_UNDELEGATION_DISCRIMINATOR = new Uint8Array([196, 28, 41, 206, 48, 37, 51, 167]);
|
|
14
|
+
|
|
15
|
+
export function getProcessUndelegationDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(PROCESS_UNDELEGATION_DISCRIMINATOR); }
|
|
16
|
+
|
|
17
|
+
export type ProcessUndelegationInstruction<TProgram extends string = typeof DUEL_PROGRAM_ADDRESS, TAccountBaseAccount extends string | AccountMeta<string> = string, TAccountBuffer 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<[TAccountBaseAccount extends string ? WritableAccount<TAccountBaseAccount> : TAccountBaseAccount, TAccountBuffer extends string ? ReadonlyAccount<TAccountBuffer> : TAccountBuffer, TAccountPayer extends string ? WritableAccount<TAccountPayer> : TAccountPayer, TAccountSystemProgram extends string ? ReadonlyAccount<TAccountSystemProgram> : TAccountSystemProgram, ...TRemainingAccounts]>;
|
|
19
|
+
|
|
20
|
+
export type ProcessUndelegationInstructionData = { discriminator: ReadonlyUint8Array; accountSeeds: Array<ReadonlyUint8Array>; };
|
|
21
|
+
|
|
22
|
+
export type ProcessUndelegationInstructionDataArgs = { accountSeeds: Array<ReadonlyUint8Array>; };
|
|
23
|
+
|
|
24
|
+
export function getProcessUndelegationInstructionDataEncoder(): Encoder<ProcessUndelegationInstructionDataArgs> {
|
|
25
|
+
return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['accountSeeds', getArrayEncoder(addEncoderSizePrefix(getBytesEncoder(), getU32Encoder()))]]), (value) => ({ ...value, discriminator: PROCESS_UNDELEGATION_DISCRIMINATOR }));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getProcessUndelegationInstructionDataDecoder(): Decoder<ProcessUndelegationInstructionData> {
|
|
29
|
+
return getStructDecoder([['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['accountSeeds', getArrayDecoder(addDecoderSizePrefix(getBytesDecoder(), getU32Decoder()))]]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function getProcessUndelegationInstructionDataCodec(): Codec<ProcessUndelegationInstructionDataArgs, ProcessUndelegationInstructionData> {
|
|
33
|
+
return combineCodec(getProcessUndelegationInstructionDataEncoder(), getProcessUndelegationInstructionDataDecoder());
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type ProcessUndelegationInput<TAccountBaseAccount extends string = string, TAccountBuffer extends string = string, TAccountPayer extends string = string, TAccountSystemProgram extends string = string> = {
|
|
37
|
+
baseAccount: Address<TAccountBaseAccount>;
|
|
38
|
+
buffer: Address<TAccountBuffer>;
|
|
39
|
+
payer: Address<TAccountPayer>;
|
|
40
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
41
|
+
accountSeeds: ProcessUndelegationInstructionDataArgs["accountSeeds"];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function getProcessUndelegationInstruction<TAccountBaseAccount extends string, TAccountBuffer extends string, TAccountPayer extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof DUEL_PROGRAM_ADDRESS>(input: ProcessUndelegationInput<TAccountBaseAccount, TAccountBuffer, TAccountPayer, TAccountSystemProgram>, config?: { programAddress?: TProgramAddress } ): ProcessUndelegationInstruction<TProgramAddress, TAccountBaseAccount, TAccountBuffer, TAccountPayer, TAccountSystemProgram> {
|
|
45
|
+
// Program address.
|
|
46
|
+
const programAddress = config?.programAddress ?? DUEL_PROGRAM_ADDRESS;
|
|
47
|
+
|
|
48
|
+
// Original accounts.
|
|
49
|
+
const originalAccounts = { baseAccount: { value: input.baseAccount ?? null, isWritable: true }, buffer: { value: input.buffer ?? null, isWritable: false }, payer: { value: input.payer ?? null, isWritable: true }, systemProgram: { value: input.systemProgram ?? null, isWritable: false } }
|
|
50
|
+
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
// Original args.
|
|
54
|
+
const args = { ...input, };
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
// Resolve default values.
|
|
58
|
+
if (!accounts.systemProgram.value) {
|
|
59
|
+
accounts.systemProgram.value = '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
63
|
+
return Object.freeze({ accounts: [getAccountMeta("baseAccount", accounts.baseAccount), getAccountMeta("buffer", accounts.buffer), getAccountMeta("payer", accounts.payer), getAccountMeta("systemProgram", accounts.systemProgram)], data: getProcessUndelegationInstructionDataEncoder().encode(args as ProcessUndelegationInstructionDataArgs), programAddress } as ProcessUndelegationInstruction<TProgramAddress, TAccountBaseAccount, TAccountBuffer, TAccountPayer, TAccountSystemProgram>);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type ParsedProcessUndelegationInstruction<TProgram extends string = typeof DUEL_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = { programAddress: Address<TProgram>;
|
|
67
|
+
accounts: {
|
|
68
|
+
baseAccount: TAccountMetas[0];
|
|
69
|
+
buffer: TAccountMetas[1];
|
|
70
|
+
payer: TAccountMetas[2];
|
|
71
|
+
systemProgram: TAccountMetas[3];
|
|
72
|
+
};
|
|
73
|
+
data: ProcessUndelegationInstructionData; };
|
|
74
|
+
|
|
75
|
+
export function parseProcessUndelegationInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedProcessUndelegationInstruction<TProgram, TAccountMetas> {
|
|
76
|
+
if (instruction.accounts.length < 4) {
|
|
77
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 4 });
|
|
78
|
+
}
|
|
79
|
+
let accountIndex = 0;
|
|
80
|
+
const getNextAccount = () => {
|
|
81
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
82
|
+
accountIndex += 1;
|
|
83
|
+
return accountMeta;
|
|
84
|
+
}
|
|
85
|
+
return { programAddress: instruction.programAddress, accounts: { baseAccount: getNextAccount(), buffer: getNextAccount(), payer: getNextAccount(), systemProgram: getNextAccount() }, data: getProcessUndelegationInstructionDataDecoder().decode(instruction.data) };
|
|
86
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
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 { assertIsInstructionWithAccounts, containsBytes, fixEncoderSize, getBytesEncoder, SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT, SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, SolanaError, type Address, type ClientWithPayer, type ClientWithRpc, type ClientWithTransactionPlanning, type ClientWithTransactionSending, type GetAccountInfoApi, type GetMultipleAccountsApi, type Instruction, type InstructionWithData, type ReadonlyUint8Array } from '@solana/kit';
|
|
10
|
+
import { addSelfFetchFunctions, addSelfPlanAndSendFunctions, type SelfFetchFunctions, type SelfPlanAndSendFunctions } from '@solana/program-client-core';
|
|
11
|
+
import { getMatchTicketCodec, getQueueCodec, getTenantCodec, type MatchTicket, type MatchTicketArgs, type Queue, type QueueArgs, type Tenant, type TenantArgs } from '../accounts';
|
|
12
|
+
import { getCancelTicketInstructionAsync, getCloseTicketInstructionAsync, getCommitTicketsInstruction, getCreateTicketInstructionAsync, getDelegateQueueInstructionAsync, getDelegateTicketInstructionAsync, getFlushMatchesInstruction, getInitializeQueueInstructionAsync, getInitializeTenantInstructionAsync, getJoinQueueInstructionAsync, getProcessUndelegationInstruction, parseCancelTicketInstruction, parseCloseTicketInstruction, parseCommitTicketsInstruction, parseCreateTicketInstruction, parseDelegateQueueInstruction, parseDelegateTicketInstruction, parseFlushMatchesInstruction, parseInitializeQueueInstruction, parseInitializeTenantInstruction, parseJoinQueueInstruction, parseProcessUndelegationInstruction, type CancelTicketAsyncInput, type CloseTicketAsyncInput, type CommitTicketsInput, type CreateTicketAsyncInput, type DelegateQueueAsyncInput, type DelegateTicketAsyncInput, type FlushMatchesInput, type InitializeQueueAsyncInput, type InitializeTenantAsyncInput, type JoinQueueAsyncInput, type ParsedCancelTicketInstruction, type ParsedCloseTicketInstruction, type ParsedCommitTicketsInstruction, type ParsedCreateTicketInstruction, type ParsedDelegateQueueInstruction, type ParsedDelegateTicketInstruction, type ParsedFlushMatchesInstruction, type ParsedInitializeQueueInstruction, type ParsedInitializeTenantInstruction, type ParsedJoinQueueInstruction, type ParsedProcessUndelegationInstruction, type ProcessUndelegationInput } from '../instructions';
|
|
13
|
+
|
|
14
|
+
export const DUEL_PROGRAM_ADDRESS = 'EdZzUwKd1X2ZWjxLPpz1cpEzMF7RUZC43Pq64v1VcK5X' as Address<'EdZzUwKd1X2ZWjxLPpz1cpEzMF7RUZC43Pq64v1VcK5X'>;
|
|
15
|
+
|
|
16
|
+
export enum DuelAccount { MatchTicket, Queue, Tenant }
|
|
17
|
+
|
|
18
|
+
export function identifyDuelAccount(account: { data: ReadonlyUint8Array } | ReadonlyUint8Array): DuelAccount {
|
|
19
|
+
const data = 'data' in account ? account.data : account;
|
|
20
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([11, 131, 4, 157, 207, 79, 126, 5])), 0)) { return DuelAccount.MatchTicket; }
|
|
21
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([204, 167, 6, 247, 20, 33, 2, 188])), 0)) { return DuelAccount.Queue; }
|
|
22
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([61, 43, 215, 51, 232, 242, 209, 170])), 0)) { return DuelAccount.Tenant; }
|
|
23
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT, { accountData: data, programName: "duel" });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export enum DuelInstruction { CancelTicket, CloseTicket, CommitTickets, CreateTicket, DelegateQueue, DelegateTicket, FlushMatches, InitializeQueue, InitializeTenant, JoinQueue, ProcessUndelegation }
|
|
27
|
+
|
|
28
|
+
export function identifyDuelInstruction(instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array): DuelInstruction {
|
|
29
|
+
const data = 'data' in instruction ? instruction.data : instruction;
|
|
30
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([216, 28, 247, 206, 195, 171, 100, 143])), 0)) { return DuelInstruction.CancelTicket; }
|
|
31
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([66, 209, 114, 197, 75, 27, 182, 117])), 0)) { return DuelInstruction.CloseTicket; }
|
|
32
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([245, 199, 81, 0, 62, 133, 18, 22])), 0)) { return DuelInstruction.CommitTickets; }
|
|
33
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([16, 178, 122, 25, 213, 85, 96, 129])), 0)) { return DuelInstruction.CreateTicket; }
|
|
34
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([31, 200, 139, 125, 93, 239, 83, 87])), 0)) { return DuelInstruction.DelegateQueue; }
|
|
35
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([195, 3, 78, 64, 128, 235, 209, 171])), 0)) { return DuelInstruction.DelegateTicket; }
|
|
36
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([49, 148, 163, 71, 77, 63, 197, 76])), 0)) { return DuelInstruction.FlushMatches; }
|
|
37
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([174, 102, 132, 232, 90, 202, 27, 20])), 0)) { return DuelInstruction.InitializeQueue; }
|
|
38
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([94, 120, 34, 186, 57, 167, 241, 206])), 0)) { return DuelInstruction.InitializeTenant; }
|
|
39
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([157, 115, 48, 109, 65, 86, 203, 238])), 0)) { return DuelInstruction.JoinQueue; }
|
|
40
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([196, 28, 41, 206, 48, 37, 51, 167])), 0)) { return DuelInstruction.ProcessUndelegation; }
|
|
41
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, { instructionData: data, programName: "duel" });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type ParsedDuelInstruction<TProgram extends string = 'EdZzUwKd1X2ZWjxLPpz1cpEzMF7RUZC43Pq64v1VcK5X'> =
|
|
45
|
+
| { instructionType: DuelInstruction.CancelTicket } & ParsedCancelTicketInstruction<TProgram>
|
|
46
|
+
| { instructionType: DuelInstruction.CloseTicket } & ParsedCloseTicketInstruction<TProgram>
|
|
47
|
+
| { instructionType: DuelInstruction.CommitTickets } & ParsedCommitTicketsInstruction<TProgram>
|
|
48
|
+
| { instructionType: DuelInstruction.CreateTicket } & ParsedCreateTicketInstruction<TProgram>
|
|
49
|
+
| { instructionType: DuelInstruction.DelegateQueue } & ParsedDelegateQueueInstruction<TProgram>
|
|
50
|
+
| { instructionType: DuelInstruction.DelegateTicket } & ParsedDelegateTicketInstruction<TProgram>
|
|
51
|
+
| { instructionType: DuelInstruction.FlushMatches } & ParsedFlushMatchesInstruction<TProgram>
|
|
52
|
+
| { instructionType: DuelInstruction.InitializeQueue } & ParsedInitializeQueueInstruction<TProgram>
|
|
53
|
+
| { instructionType: DuelInstruction.InitializeTenant } & ParsedInitializeTenantInstruction<TProgram>
|
|
54
|
+
| { instructionType: DuelInstruction.JoinQueue } & ParsedJoinQueueInstruction<TProgram>
|
|
55
|
+
| { instructionType: DuelInstruction.ProcessUndelegation } & ParsedProcessUndelegationInstruction<TProgram>
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
export function parseDuelInstruction<TProgram extends string>(
|
|
59
|
+
instruction: Instruction<TProgram>
|
|
60
|
+
& InstructionWithData<ReadonlyUint8Array>
|
|
61
|
+
): ParsedDuelInstruction<TProgram> {
|
|
62
|
+
const instructionType = identifyDuelInstruction(instruction);
|
|
63
|
+
switch (instructionType) {
|
|
64
|
+
case DuelInstruction.CancelTicket: { assertIsInstructionWithAccounts(instruction);
|
|
65
|
+
return { instructionType: DuelInstruction.CancelTicket, ...parseCancelTicketInstruction(instruction) }; }
|
|
66
|
+
case DuelInstruction.CloseTicket: { assertIsInstructionWithAccounts(instruction);
|
|
67
|
+
return { instructionType: DuelInstruction.CloseTicket, ...parseCloseTicketInstruction(instruction) }; }
|
|
68
|
+
case DuelInstruction.CommitTickets: { assertIsInstructionWithAccounts(instruction);
|
|
69
|
+
return { instructionType: DuelInstruction.CommitTickets, ...parseCommitTicketsInstruction(instruction) }; }
|
|
70
|
+
case DuelInstruction.CreateTicket: { assertIsInstructionWithAccounts(instruction);
|
|
71
|
+
return { instructionType: DuelInstruction.CreateTicket, ...parseCreateTicketInstruction(instruction) }; }
|
|
72
|
+
case DuelInstruction.DelegateQueue: { assertIsInstructionWithAccounts(instruction);
|
|
73
|
+
return { instructionType: DuelInstruction.DelegateQueue, ...parseDelegateQueueInstruction(instruction) }; }
|
|
74
|
+
case DuelInstruction.DelegateTicket: { assertIsInstructionWithAccounts(instruction);
|
|
75
|
+
return { instructionType: DuelInstruction.DelegateTicket, ...parseDelegateTicketInstruction(instruction) }; }
|
|
76
|
+
case DuelInstruction.FlushMatches: { assertIsInstructionWithAccounts(instruction);
|
|
77
|
+
return { instructionType: DuelInstruction.FlushMatches, ...parseFlushMatchesInstruction(instruction) }; }
|
|
78
|
+
case DuelInstruction.InitializeQueue: { assertIsInstructionWithAccounts(instruction);
|
|
79
|
+
return { instructionType: DuelInstruction.InitializeQueue, ...parseInitializeQueueInstruction(instruction) }; }
|
|
80
|
+
case DuelInstruction.InitializeTenant: { assertIsInstructionWithAccounts(instruction);
|
|
81
|
+
return { instructionType: DuelInstruction.InitializeTenant, ...parseInitializeTenantInstruction(instruction) }; }
|
|
82
|
+
case DuelInstruction.JoinQueue: { assertIsInstructionWithAccounts(instruction);
|
|
83
|
+
return { instructionType: DuelInstruction.JoinQueue, ...parseJoinQueueInstruction(instruction) }; }
|
|
84
|
+
case DuelInstruction.ProcessUndelegation: { assertIsInstructionWithAccounts(instruction);
|
|
85
|
+
return { instructionType: DuelInstruction.ProcessUndelegation, ...parseProcessUndelegationInstruction(instruction) }; }
|
|
86
|
+
default: throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, { instructionType: instructionType as string, programName: "duel" });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export type DuelPlugin = { accounts: DuelPluginAccounts; instructions: DuelPluginInstructions; }
|
|
91
|
+
|
|
92
|
+
export type DuelPluginAccounts = { matchTicket: ReturnType<typeof getMatchTicketCodec> & SelfFetchFunctions<MatchTicketArgs, MatchTicket>; queue: ReturnType<typeof getQueueCodec> & SelfFetchFunctions<QueueArgs, Queue>; tenant: ReturnType<typeof getTenantCodec> & SelfFetchFunctions<TenantArgs, Tenant>; }
|
|
93
|
+
|
|
94
|
+
export type DuelPluginInstructions = { cancelTicket: (input: CancelTicketAsyncInput) => ReturnType<typeof getCancelTicketInstructionAsync> & SelfPlanAndSendFunctions; closeTicket: (input: CloseTicketAsyncInput) => ReturnType<typeof getCloseTicketInstructionAsync> & SelfPlanAndSendFunctions; commitTickets: (input: MakeOptional<CommitTicketsInput, "payer">) => ReturnType<typeof getCommitTicketsInstruction> & SelfPlanAndSendFunctions; createTicket: (input: CreateTicketAsyncInput) => ReturnType<typeof getCreateTicketInstructionAsync> & SelfPlanAndSendFunctions; delegateQueue: (input: MakeOptional<DelegateQueueAsyncInput, "payer">) => ReturnType<typeof getDelegateQueueInstructionAsync> & SelfPlanAndSendFunctions; delegateTicket: (input: MakeOptional<DelegateTicketAsyncInput, "payer">) => ReturnType<typeof getDelegateTicketInstructionAsync> & SelfPlanAndSendFunctions; flushMatches: (input: FlushMatchesInput) => ReturnType<typeof getFlushMatchesInstruction> & SelfPlanAndSendFunctions; initializeQueue: (input: InitializeQueueAsyncInput) => ReturnType<typeof getInitializeQueueInstructionAsync> & SelfPlanAndSendFunctions; initializeTenant: (input: InitializeTenantAsyncInput) => ReturnType<typeof getInitializeTenantInstructionAsync> & SelfPlanAndSendFunctions; joinQueue: (input: JoinQueueAsyncInput) => ReturnType<typeof getJoinQueueInstructionAsync> & SelfPlanAndSendFunctions; processUndelegation: (input: MakeOptional<ProcessUndelegationInput, "payer">) => ReturnType<typeof getProcessUndelegationInstruction> & SelfPlanAndSendFunctions; }
|
|
95
|
+
|
|
96
|
+
export type DuelPluginRequirements = ClientWithRpc<GetAccountInfoApi & GetMultipleAccountsApi> & ClientWithPayer & ClientWithTransactionPlanning & ClientWithTransactionSending
|
|
97
|
+
|
|
98
|
+
export function duelProgram() {
|
|
99
|
+
return <T extends DuelPluginRequirements>(client: T) => {
|
|
100
|
+
return { ...client, duel: <DuelPlugin>{ accounts: { matchTicket: addSelfFetchFunctions(client, getMatchTicketCodec()), queue: addSelfFetchFunctions(client, getQueueCodec()), tenant: addSelfFetchFunctions(client, getTenantCodec()) }, instructions: { cancelTicket: input => addSelfPlanAndSendFunctions(client, getCancelTicketInstructionAsync(input)), closeTicket: input => addSelfPlanAndSendFunctions(client, getCloseTicketInstructionAsync(input)), commitTickets: input => addSelfPlanAndSendFunctions(client, getCommitTicketsInstruction({ ...input, payer: input.payer ?? client.payer })), createTicket: input => addSelfPlanAndSendFunctions(client, getCreateTicketInstructionAsync(input)), delegateQueue: input => addSelfPlanAndSendFunctions(client, getDelegateQueueInstructionAsync({ ...input, payer: input.payer ?? client.payer })), delegateTicket: input => addSelfPlanAndSendFunctions(client, getDelegateTicketInstructionAsync({ ...input, payer: input.payer ?? client.payer })), flushMatches: input => addSelfPlanAndSendFunctions(client, getFlushMatchesInstruction(input)), initializeQueue: input => addSelfPlanAndSendFunctions(client, getInitializeQueueInstructionAsync(input)), initializeTenant: input => addSelfPlanAndSendFunctions(client, getInitializeTenantInstructionAsync(input)), joinQueue: input => addSelfPlanAndSendFunctions(client, getJoinQueueInstructionAsync(input)), processUndelegation: input => addSelfPlanAndSendFunctions(client, getProcessUndelegationInstruction({ ...input, payer: input.payer ?? client.payer.address })) } } };
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
@@ -0,0 +1,36 @@
|
|
|
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, getAddressDecoder, getAddressEncoder, getDiscriminatedUnionDecoder, getDiscriminatedUnionEncoder, getStructDecoder, getStructEncoder, type Address, type Codec, type Decoder, type Encoder, type GetDiscriminatedUnionVariant, type GetDiscriminatedUnionVariantContent } from '@solana/kit';
|
|
10
|
+
|
|
11
|
+
export type AccountType = { __kind: "Queue", authority: Address; } | { __kind: "Ticket", player: Address; tenant: Address; };
|
|
12
|
+
|
|
13
|
+
export type AccountTypeArgs = AccountType;
|
|
14
|
+
|
|
15
|
+
export function getAccountTypeEncoder(): Encoder<AccountTypeArgs> {
|
|
16
|
+
return getDiscriminatedUnionEncoder([['Queue', getStructEncoder([['authority', getAddressEncoder()]])], ['Ticket', getStructEncoder([['player', getAddressEncoder()], ['tenant', getAddressEncoder()]])]]);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getAccountTypeDecoder(): Decoder<AccountType> {
|
|
20
|
+
return getDiscriminatedUnionDecoder([['Queue', getStructDecoder([['authority', getAddressDecoder()]])], ['Ticket', getStructDecoder([['player', getAddressDecoder()], ['tenant', getAddressDecoder()]])]]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function getAccountTypeCodec(): Codec<AccountTypeArgs, AccountType> {
|
|
24
|
+
return combineCodec(getAccountTypeEncoder(), getAccountTypeDecoder());
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Data Enum Helpers.
|
|
28
|
+
export function accountType(kind: 'Queue', data: GetDiscriminatedUnionVariantContent<AccountTypeArgs, '__kind', 'Queue'>): GetDiscriminatedUnionVariant<AccountTypeArgs, '__kind', 'Queue'>;
|
|
29
|
+
export function accountType(kind: 'Ticket', data: GetDiscriminatedUnionVariantContent<AccountTypeArgs, '__kind', 'Ticket'>): GetDiscriminatedUnionVariant<AccountTypeArgs, '__kind', 'Ticket'>;
|
|
30
|
+
export function accountType<K extends AccountTypeArgs['__kind'], Data>(kind: K, data?: Data) {
|
|
31
|
+
return Array.isArray(data) ? { __kind: kind, fields: data } : { __kind: kind, ...(data ?? {}) };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function isAccountType<K extends AccountType['__kind']>(kind: K, value: AccountType): value is AccountType & { __kind: K } {
|
|
35
|
+
return value.__kind === kind;
|
|
36
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
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 './accountType';
|
|
10
|
+
export * from './matchEntry';
|
|
11
|
+
export * from './matchFound';
|
|
12
|
+
export * from './pendingMatch';
|
|
13
|
+
export * from './queueEntry';
|
|
14
|
+
export * from './ticketStatus';
|
|
@@ -0,0 +1,25 @@
|
|
|
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, getAddressDecoder, getAddressEncoder, getI64Decoder, getI64Encoder, getStructDecoder, getStructEncoder, getU64Decoder, getU64Encoder, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder } from '@solana/kit';
|
|
10
|
+
|
|
11
|
+
export type MatchEntry = { player1: Address; player2: Address; matchId: bigint; timestamp: bigint; };
|
|
12
|
+
|
|
13
|
+
export type MatchEntryArgs = { player1: Address; player2: Address; matchId: number | bigint; timestamp: number | bigint; };
|
|
14
|
+
|
|
15
|
+
export function getMatchEntryEncoder(): FixedSizeEncoder<MatchEntryArgs> {
|
|
16
|
+
return getStructEncoder([['player1', getAddressEncoder()], ['player2', getAddressEncoder()], ['matchId', getU64Encoder()], ['timestamp', getI64Encoder()]]);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getMatchEntryDecoder(): FixedSizeDecoder<MatchEntry> {
|
|
20
|
+
return getStructDecoder([['player1', getAddressDecoder()], ['player2', getAddressDecoder()], ['matchId', getU64Decoder()], ['timestamp', getI64Decoder()]]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function getMatchEntryCodec(): FixedSizeCodec<MatchEntryArgs, MatchEntry> {
|
|
24
|
+
return combineCodec(getMatchEntryEncoder(), getMatchEntryDecoder());
|
|
25
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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, getAddressDecoder, getAddressEncoder, getI64Decoder, getI64Encoder, getStructDecoder, getStructEncoder, getU64Decoder, getU64Encoder, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder } from '@solana/kit';
|
|
10
|
+
|
|
11
|
+
export type MatchFound = { player1: Address; player2: Address; matchId: bigint; timestamp: bigint; };
|
|
12
|
+
|
|
13
|
+
export type MatchFoundArgs = { player1: Address; player2: Address; matchId: number | bigint; timestamp: number | bigint; };
|
|
14
|
+
|
|
15
|
+
export function getMatchFoundEncoder(): FixedSizeEncoder<MatchFoundArgs> {
|
|
16
|
+
return getStructEncoder([['player1', getAddressEncoder()], ['player2', getAddressEncoder()], ['matchId', getU64Encoder()], ['timestamp', getI64Encoder()]]);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getMatchFoundDecoder(): FixedSizeDecoder<MatchFound> {
|
|
20
|
+
return getStructDecoder([['player1', getAddressDecoder()], ['player2', getAddressDecoder()], ['matchId', getU64Decoder()], ['timestamp', getI64Decoder()]]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function getMatchFoundCodec(): FixedSizeCodec<MatchFoundArgs, MatchFound> {
|
|
24
|
+
return combineCodec(getMatchFoundEncoder(), getMatchFoundDecoder());
|
|
25
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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, getAddressDecoder, getAddressEncoder, getStructDecoder, getStructEncoder, getU64Decoder, getU64Encoder, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder } from '@solana/kit';
|
|
10
|
+
|
|
11
|
+
export type PendingMatch = { player: Address; opponent: Address; matchId: bigint; };
|
|
12
|
+
|
|
13
|
+
export type PendingMatchArgs = { player: Address; opponent: Address; matchId: number | bigint; };
|
|
14
|
+
|
|
15
|
+
export function getPendingMatchEncoder(): FixedSizeEncoder<PendingMatchArgs> {
|
|
16
|
+
return getStructEncoder([['player', getAddressEncoder()], ['opponent', getAddressEncoder()], ['matchId', getU64Encoder()]]);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getPendingMatchDecoder(): FixedSizeDecoder<PendingMatch> {
|
|
20
|
+
return getStructDecoder([['player', getAddressDecoder()], ['opponent', getAddressDecoder()], ['matchId', getU64Decoder()]]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function getPendingMatchCodec(): FixedSizeCodec<PendingMatchArgs, PendingMatch> {
|
|
24
|
+
return combineCodec(getPendingMatchEncoder(), getPendingMatchDecoder());
|
|
25
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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, getAddressDecoder, getAddressEncoder, getStructDecoder, getStructEncoder, getU64Decoder, getU64Encoder, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder } from '@solana/kit';
|
|
10
|
+
|
|
11
|
+
export type QueueEntry = { player: Address; elo: bigint; };
|
|
12
|
+
|
|
13
|
+
export type QueueEntryArgs = { player: Address; elo: number | bigint; };
|
|
14
|
+
|
|
15
|
+
export function getQueueEntryEncoder(): FixedSizeEncoder<QueueEntryArgs> {
|
|
16
|
+
return getStructEncoder([['player', getAddressEncoder()], ['elo', getU64Encoder()]]);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getQueueEntryDecoder(): FixedSizeDecoder<QueueEntry> {
|
|
20
|
+
return getStructDecoder([['player', getAddressDecoder()], ['elo', getU64Decoder()]]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function getQueueEntryCodec(): FixedSizeCodec<QueueEntryArgs, QueueEntry> {
|
|
24
|
+
return combineCodec(getQueueEntryEncoder(), getQueueEntryDecoder());
|
|
25
|
+
}
|