@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.
Files changed (186) hide show
  1. package/README.md +110 -59
  2. package/dist/admin.d.ts +25 -40
  3. package/dist/admin.js +93 -114
  4. package/dist/encryption.js +1 -2
  5. package/dist/generated/duel/accounts/index.d.ts +10 -0
  6. package/dist/generated/duel/accounts/index.js +11 -0
  7. package/dist/generated/duel/accounts/matchTicket.d.ts +38 -0
  8. package/dist/generated/duel/accounts/matchTicket.js +45 -0
  9. package/dist/generated/duel/accounts/queue.d.ts +42 -0
  10. package/dist/generated/duel/accounts/queue.js +45 -0
  11. package/dist/generated/duel/accounts/tenant.d.ts +41 -0
  12. package/dist/generated/duel/accounts/tenant.js +44 -0
  13. package/dist/generated/duel/errors/duel.d.ts +31 -0
  14. package/dist/generated/duel/errors/duel.js +35 -0
  15. package/dist/generated/duel/errors/index.d.ts +8 -0
  16. package/dist/generated/duel/errors/index.js +9 -0
  17. package/dist/generated/duel/index.d.ts +12 -0
  18. package/dist/generated/duel/index.js +13 -0
  19. package/dist/generated/duel/instructions/cancelTicket.d.ts +45 -0
  20. package/dist/generated/duel/instructions/cancelTicket.js +56 -0
  21. package/dist/generated/duel/instructions/closeTicket.d.ts +45 -0
  22. package/dist/generated/duel/instructions/closeTicket.js +56 -0
  23. package/dist/generated/duel/instructions/commitTickets.d.ts +39 -0
  24. package/dist/generated/duel/instructions/commitTickets.js +50 -0
  25. package/dist/generated/duel/instructions/createTicket.d.ts +48 -0
  26. package/dist/generated/duel/instructions/createTicket.js +63 -0
  27. package/dist/generated/duel/instructions/delegateQueue.d.ts +69 -0
  28. package/dist/generated/duel/instructions/delegateQueue.js +90 -0
  29. package/dist/generated/duel/instructions/delegateTicket.d.ts +69 -0
  30. package/dist/generated/duel/instructions/delegateTicket.js +90 -0
  31. package/dist/generated/duel/instructions/flushMatches.d.ts +37 -0
  32. package/dist/generated/duel/instructions/flushMatches.js +43 -0
  33. package/dist/generated/duel/instructions/index.d.ts +19 -0
  34. package/dist/generated/duel/instructions/index.js +20 -0
  35. package/dist/generated/duel/instructions/initializeQueue.d.ts +48 -0
  36. package/dist/generated/duel/instructions/initializeQueue.js +63 -0
  37. package/dist/generated/duel/instructions/initializeTenant.d.ts +70 -0
  38. package/dist/generated/duel/instructions/initializeTenant.js +67 -0
  39. package/dist/generated/duel/instructions/joinQueue.d.ts +51 -0
  40. package/dist/generated/duel/instructions/joinQueue.js +56 -0
  41. package/dist/generated/duel/instructions/processUndelegation.d.ts +43 -0
  42. package/dist/generated/duel/instructions/processUndelegation.js +49 -0
  43. package/dist/generated/duel/instructions/setupTicketPermission.d.ts +54 -0
  44. package/dist/generated/duel/instructions/setupTicketPermission.js +63 -0
  45. package/dist/generated/duel/programs/duel.d.ts +92 -0
  46. package/dist/generated/duel/programs/duel.js +146 -0
  47. package/dist/generated/duel/programs/index.d.ts +8 -0
  48. package/dist/generated/duel/programs/index.js +9 -0
  49. package/dist/generated/duel/types/accountType.d.ts +25 -0
  50. package/dist/generated/duel/types/accountType.js +25 -0
  51. package/dist/generated/duel/types/index.d.ts +13 -0
  52. package/dist/generated/duel/types/index.js +14 -0
  53. package/dist/generated/duel/types/matchEntry.d.ts +23 -0
  54. package/dist/generated/duel/types/matchEntry.js +18 -0
  55. package/dist/generated/duel/types/matchFound.d.ts +23 -0
  56. package/dist/generated/duel/types/matchFound.js +18 -0
  57. package/dist/generated/duel/types/pendingMatch.d.ts +21 -0
  58. package/dist/generated/duel/types/pendingMatch.js +18 -0
  59. package/dist/generated/duel/types/queueEntry.d.ts +19 -0
  60. package/dist/generated/duel/types/queueEntry.js +18 -0
  61. package/dist/generated/duel/types/ticketStatus.d.ts +40 -0
  62. package/dist/generated/duel/types/ticketStatus.js +25 -0
  63. package/dist/generated/rps-game/accounts/gameSession.d.ts +40 -0
  64. package/dist/generated/rps-game/accounts/gameSession.js +45 -0
  65. package/dist/generated/rps-game/accounts/index.d.ts +9 -0
  66. package/dist/generated/rps-game/accounts/index.js +10 -0
  67. package/dist/generated/rps-game/accounts/playerProfile.d.ts +36 -0
  68. package/dist/generated/rps-game/accounts/playerProfile.js +47 -0
  69. package/dist/generated/rps-game/errors/index.d.ts +8 -0
  70. package/dist/generated/rps-game/errors/index.js +9 -0
  71. package/dist/generated/rps-game/errors/rpsGame.d.ts +25 -0
  72. package/dist/generated/rps-game/errors/rpsGame.js +29 -0
  73. package/dist/generated/rps-game/index.d.ts +12 -0
  74. package/dist/generated/rps-game/index.js +13 -0
  75. package/dist/generated/rps-game/instructions/closePlayer.d.ts +45 -0
  76. package/dist/generated/rps-game/instructions/closePlayer.js +56 -0
  77. package/dist/generated/rps-game/instructions/delegatePda.d.ts +69 -0
  78. package/dist/generated/rps-game/instructions/delegatePda.js +90 -0
  79. package/dist/generated/rps-game/instructions/index.d.ts +16 -0
  80. package/dist/generated/rps-game/instructions/index.js +17 -0
  81. package/dist/generated/rps-game/instructions/initializePlayer.d.ts +48 -0
  82. package/dist/generated/rps-game/instructions/initializePlayer.js +63 -0
  83. package/dist/generated/rps-game/instructions/makeChoice.d.ts +44 -0
  84. package/dist/generated/rps-game/instructions/makeChoice.js +46 -0
  85. package/dist/generated/rps-game/instructions/onMatchFound.d.ts +43 -0
  86. package/dist/generated/rps-game/instructions/onMatchFound.js +45 -0
  87. package/dist/generated/rps-game/instructions/persistResults.d.ts +43 -0
  88. package/dist/generated/rps-game/instructions/persistResults.js +50 -0
  89. package/dist/generated/rps-game/instructions/processUndelegation.d.ts +43 -0
  90. package/dist/generated/rps-game/instructions/processUndelegation.js +49 -0
  91. package/dist/generated/rps-game/instructions/startGame.d.ts +54 -0
  92. package/dist/generated/rps-game/instructions/startGame.js +67 -0
  93. package/dist/generated/rps-game/instructions/startGameWithTicket.d.ts +57 -0
  94. package/dist/generated/rps-game/instructions/startGameWithTicket.js +67 -0
  95. package/dist/generated/rps-game/programs/index.d.ts +8 -0
  96. package/dist/generated/rps-game/programs/index.js +9 -0
  97. package/dist/generated/rps-game/programs/rpsGame.d.ts +78 -0
  98. package/dist/generated/rps-game/programs/rpsGame.js +118 -0
  99. package/dist/generated/rps-game/types/accountType.d.ts +34 -0
  100. package/dist/generated/rps-game/types/accountType.js +25 -0
  101. package/dist/generated/rps-game/types/choice.d.ts +17 -0
  102. package/dist/generated/rps-game/types/choice.js +25 -0
  103. package/dist/generated/rps-game/types/gameResult.d.ts +26 -0
  104. package/dist/generated/rps-game/types/gameResult.js +25 -0
  105. package/dist/generated/rps-game/types/index.d.ts +10 -0
  106. package/dist/generated/rps-game/types/index.js +11 -0
  107. package/dist/index.d.ts +2 -1
  108. package/dist/index.js +3 -2
  109. package/dist/player.d.ts +25 -46
  110. package/dist/player.js +81 -140
  111. package/dist/tee.d.ts +14 -0
  112. package/dist/tee.js +62 -0
  113. package/dist/transaction.d.ts +11 -0
  114. package/dist/transaction.js +50 -0
  115. package/dist/utils.d.ts +4 -4
  116. package/dist/utils.js +23 -8
  117. package/package.json +3 -6
  118. package/src/admin.ts +151 -161
  119. package/src/duel.json +66 -7
  120. package/src/encryption.ts +0 -3
  121. package/src/generated/duel/accounts/index.ts +11 -0
  122. package/src/generated/duel/accounts/matchTicket.ts +77 -0
  123. package/src/generated/duel/accounts/queue.ts +77 -0
  124. package/src/generated/duel/accounts/tenant.ts +76 -0
  125. package/src/generated/duel/errors/duel.ts +46 -0
  126. package/src/generated/duel/errors/index.ts +9 -0
  127. package/src/generated/duel/index.ts +13 -0
  128. package/src/generated/duel/instructions/cancelTicket.ts +100 -0
  129. package/src/generated/duel/instructions/closeTicket.ts +100 -0
  130. package/src/generated/duel/instructions/commitTickets.ts +84 -0
  131. package/src/generated/duel/instructions/createTicket.ts +109 -0
  132. package/src/generated/duel/instructions/delegateQueue.ts +157 -0
  133. package/src/generated/duel/instructions/delegateTicket.ts +157 -0
  134. package/src/generated/duel/instructions/flushMatches.ts +76 -0
  135. package/src/generated/duel/instructions/index.ts +20 -0
  136. package/src/generated/duel/instructions/initializeQueue.ts +109 -0
  137. package/src/generated/duel/instructions/initializeTenant.ts +126 -0
  138. package/src/generated/duel/instructions/joinQueue.ts +106 -0
  139. package/src/generated/duel/instructions/processUndelegation.ts +86 -0
  140. package/src/generated/duel/instructions/setupTicketPermission.ts +115 -0
  141. package/src/generated/duel/programs/duel.ts +108 -0
  142. package/src/generated/duel/programs/index.ts +9 -0
  143. package/src/generated/duel/types/accountType.ts +36 -0
  144. package/src/generated/duel/types/index.ts +14 -0
  145. package/src/generated/duel/types/matchEntry.ts +25 -0
  146. package/src/generated/duel/types/matchFound.ts +25 -0
  147. package/src/generated/duel/types/pendingMatch.ts +25 -0
  148. package/src/generated/duel/types/queueEntry.ts +25 -0
  149. package/src/generated/duel/types/ticketStatus.ts +38 -0
  150. package/src/generated/rps-game/accounts/gameSession.ts +77 -0
  151. package/src/generated/rps-game/accounts/index.ts +10 -0
  152. package/src/generated/rps-game/accounts/playerProfile.ts +80 -0
  153. package/src/generated/rps-game/errors/index.ts +9 -0
  154. package/src/generated/rps-game/errors/rpsGame.ts +40 -0
  155. package/src/generated/rps-game/index.ts +13 -0
  156. package/src/generated/rps-game/instructions/closePlayer.ts +100 -0
  157. package/src/generated/rps-game/instructions/delegatePda.ts +157 -0
  158. package/src/generated/rps-game/instructions/index.ts +17 -0
  159. package/src/generated/rps-game/instructions/initializePlayer.ts +109 -0
  160. package/src/generated/rps-game/instructions/makeChoice.ts +84 -0
  161. package/src/generated/rps-game/instructions/onMatchFound.ts +79 -0
  162. package/src/generated/rps-game/instructions/persistResults.ts +88 -0
  163. package/src/generated/rps-game/instructions/processUndelegation.ts +86 -0
  164. package/src/generated/rps-game/instructions/startGame.ts +118 -0
  165. package/src/generated/rps-game/instructions/startGameWithTicket.ts +121 -0
  166. package/src/generated/rps-game/programs/index.ts +9 -0
  167. package/src/generated/rps-game/programs/rpsGame.ts +95 -0
  168. package/src/generated/rps-game/types/accountType.ts +36 -0
  169. package/src/generated/rps-game/types/choice.ts +25 -0
  170. package/src/generated/rps-game/types/gameResult.ts +37 -0
  171. package/src/generated/rps-game/types/index.ts +11 -0
  172. package/src/index.ts +2 -1
  173. package/src/player.ts +129 -192
  174. package/src/{idl/private_matchmaking.json → rps_game.json} +547 -583
  175. package/src/tee.ts +79 -0
  176. package/src/transaction.ts +90 -0
  177. package/src/utils.ts +35 -20
  178. package/tsconfig.json +2 -2
  179. package/dist/client.d.ts +0 -54
  180. package/dist/client.js +0 -265
  181. package/dist/duel.json +0 -1207
  182. package/dist/private_matchmaking.json +0 -534
  183. package/dist/types.d.ts +0 -635
  184. package/dist/types.js +0 -2
  185. package/src/idl/private_matchmaking.ts +0 -1033
  186. package/src/types.ts +0 -300
@@ -0,0 +1,109 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+
9
+ import { combineCodec, fixDecoderSize, fixEncoderSize, getAddressEncoder, getBytesDecoder, getBytesEncoder, getProgramDerivedAddress, getStructDecoder, getStructEncoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, transformEncoder, type AccountMeta, type AccountSignerMeta, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, type WritableSignerAccount } from '@solana/kit';
10
+ import { getAccountMetaFactory, getAddressFromResolvedInstructionAccount, type ResolvedInstructionAccount } from '@solana/program-client-core';
11
+ import { DUEL_PROGRAM_ADDRESS } from '../programs';
12
+
13
+ export const INITIALIZE_QUEUE_DISCRIMINATOR = new Uint8Array([174, 102, 132, 232, 90, 202, 27, 20]);
14
+
15
+ export function getInitializeQueueDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(INITIALIZE_QUEUE_DISCRIMINATOR); }
16
+
17
+ export type InitializeQueueInstruction<TProgram extends string = typeof DUEL_PROGRAM_ADDRESS, TAccountQueue extends string | AccountMeta<string> = string, TAccountTenant extends string | AccountMeta<string> = string, TAccountAuthority extends string | AccountMeta<string> = string, TAccountSystemProgram extends string | AccountMeta<string> = "11111111111111111111111111111111", TRemainingAccounts extends readonly AccountMeta<string>[] = []> =
18
+ Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[TAccountQueue extends string ? WritableAccount<TAccountQueue> : TAccountQueue, TAccountTenant extends string ? ReadonlyAccount<TAccountTenant> : TAccountTenant, TAccountAuthority extends string ? WritableSignerAccount<TAccountAuthority> & AccountSignerMeta<TAccountAuthority> : TAccountAuthority, TAccountSystemProgram extends string ? ReadonlyAccount<TAccountSystemProgram> : TAccountSystemProgram, ...TRemainingAccounts]>;
19
+
20
+ export type InitializeQueueInstructionData = { discriminator: ReadonlyUint8Array; };
21
+
22
+ export type InitializeQueueInstructionDataArgs = { };
23
+
24
+ export function getInitializeQueueInstructionDataEncoder(): FixedSizeEncoder<InitializeQueueInstructionDataArgs> {
25
+ return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({ ...value, discriminator: INITIALIZE_QUEUE_DISCRIMINATOR }));
26
+ }
27
+
28
+ export function getInitializeQueueInstructionDataDecoder(): FixedSizeDecoder<InitializeQueueInstructionData> {
29
+ return getStructDecoder([['discriminator', fixDecoderSize(getBytesDecoder(), 8)]]);
30
+ }
31
+
32
+ export function getInitializeQueueInstructionDataCodec(): FixedSizeCodec<InitializeQueueInstructionDataArgs, InitializeQueueInstructionData> {
33
+ return combineCodec(getInitializeQueueInstructionDataEncoder(), getInitializeQueueInstructionDataDecoder());
34
+ }
35
+
36
+ export type InitializeQueueAsyncInput<TAccountQueue extends string = string, TAccountTenant extends string = string, TAccountAuthority extends string = string, TAccountSystemProgram extends string = string> = {
37
+ queue?: Address<TAccountQueue>;
38
+ tenant: Address<TAccountTenant>;
39
+ authority: TransactionSigner<TAccountAuthority>;
40
+ systemProgram?: Address<TAccountSystemProgram>;
41
+ }
42
+
43
+ export async function getInitializeQueueInstructionAsync<TAccountQueue extends string, TAccountTenant extends string, TAccountAuthority extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof DUEL_PROGRAM_ADDRESS>(input: InitializeQueueAsyncInput<TAccountQueue, TAccountTenant, TAccountAuthority, TAccountSystemProgram>, config?: { programAddress?: TProgramAddress } ): Promise<InitializeQueueInstruction<TProgramAddress, TAccountQueue, TAccountTenant, TAccountAuthority, TAccountSystemProgram>> {
44
+ // Program address.
45
+ const programAddress = config?.programAddress ?? DUEL_PROGRAM_ADDRESS;
46
+
47
+ // Original accounts.
48
+ const originalAccounts = { queue: { value: input.queue ?? null, isWritable: true }, tenant: { value: input.tenant ?? null, isWritable: false }, authority: { value: input.authority ?? null, isWritable: true }, systemProgram: { value: input.systemProgram ?? null, isWritable: false } }
49
+ const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
50
+
51
+
52
+ // Resolve default values.
53
+ if (!accounts.queue.value) {
54
+ accounts.queue.value = await getProgramDerivedAddress({ programAddress, seeds: [getBytesEncoder().encode(new Uint8Array([113, 117, 101, 117, 101])), getAddressEncoder().encode(getAddressFromResolvedInstructionAccount("authority", accounts.authority.value))] });
55
+ }
56
+ if (!accounts.systemProgram.value) {
57
+ accounts.systemProgram.value = '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>;
58
+ }
59
+
60
+ const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
61
+ return Object.freeze({ accounts: [getAccountMeta("queue", accounts.queue), getAccountMeta("tenant", accounts.tenant), getAccountMeta("authority", accounts.authority), getAccountMeta("systemProgram", accounts.systemProgram)], data: getInitializeQueueInstructionDataEncoder().encode({}), programAddress } as InitializeQueueInstruction<TProgramAddress, TAccountQueue, TAccountTenant, TAccountAuthority, TAccountSystemProgram>);
62
+ }
63
+
64
+ export type InitializeQueueInput<TAccountQueue extends string = string, TAccountTenant extends string = string, TAccountAuthority extends string = string, TAccountSystemProgram extends string = string> = {
65
+ queue: Address<TAccountQueue>;
66
+ tenant: Address<TAccountTenant>;
67
+ authority: TransactionSigner<TAccountAuthority>;
68
+ systemProgram?: Address<TAccountSystemProgram>;
69
+ }
70
+
71
+ export function getInitializeQueueInstruction<TAccountQueue extends string, TAccountTenant extends string, TAccountAuthority extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof DUEL_PROGRAM_ADDRESS>(input: InitializeQueueInput<TAccountQueue, TAccountTenant, TAccountAuthority, TAccountSystemProgram>, config?: { programAddress?: TProgramAddress } ): InitializeQueueInstruction<TProgramAddress, TAccountQueue, TAccountTenant, TAccountAuthority, TAccountSystemProgram> {
72
+ // Program address.
73
+ const programAddress = config?.programAddress ?? DUEL_PROGRAM_ADDRESS;
74
+
75
+ // Original accounts.
76
+ const originalAccounts = { queue: { value: input.queue ?? null, isWritable: true }, tenant: { value: input.tenant ?? null, isWritable: false }, authority: { value: input.authority ?? null, isWritable: true }, systemProgram: { value: input.systemProgram ?? null, isWritable: false } }
77
+ const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
78
+
79
+
80
+ // Resolve default values.
81
+ if (!accounts.systemProgram.value) {
82
+ accounts.systemProgram.value = '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>;
83
+ }
84
+
85
+ const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
86
+ return Object.freeze({ accounts: [getAccountMeta("queue", accounts.queue), getAccountMeta("tenant", accounts.tenant), getAccountMeta("authority", accounts.authority), getAccountMeta("systemProgram", accounts.systemProgram)], data: getInitializeQueueInstructionDataEncoder().encode({}), programAddress } as InitializeQueueInstruction<TProgramAddress, TAccountQueue, TAccountTenant, TAccountAuthority, TAccountSystemProgram>);
87
+ }
88
+
89
+ export type ParsedInitializeQueueInstruction<TProgram extends string = typeof DUEL_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = { programAddress: Address<TProgram>;
90
+ accounts: {
91
+ queue: TAccountMetas[0];
92
+ tenant: TAccountMetas[1];
93
+ authority: TAccountMetas[2];
94
+ systemProgram: TAccountMetas[3];
95
+ };
96
+ data: InitializeQueueInstructionData; };
97
+
98
+ export function parseInitializeQueueInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedInitializeQueueInstruction<TProgram, TAccountMetas> {
99
+ if (instruction.accounts.length < 4) {
100
+ throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 4 });
101
+ }
102
+ let accountIndex = 0;
103
+ const getNextAccount = () => {
104
+ const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
105
+ accountIndex += 1;
106
+ return accountMeta;
107
+ }
108
+ return { programAddress: instruction.programAddress, accounts: { queue: getNextAccount(), tenant: getNextAccount(), authority: getNextAccount(), systemProgram: getNextAccount() }, data: getInitializeQueueInstructionDataDecoder().decode(instruction.data) };
109
+ }
@@ -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 ? ReadonlyAccount<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: false }, 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: false }, 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,115 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+
9
+ import { combineCodec, fixDecoderSize, fixEncoderSize, getAddressEncoder, getBytesDecoder, getBytesEncoder, getProgramDerivedAddress, getStructDecoder, getStructEncoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, transformEncoder, type AccountMeta, type AccountSignerMeta, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, type WritableSignerAccount } from '@solana/kit';
10
+ import { getAccountMetaFactory, getAddressFromResolvedInstructionAccount, type ResolvedInstructionAccount } from '@solana/program-client-core';
11
+ import { DUEL_PROGRAM_ADDRESS } from '../programs';
12
+
13
+ export const SETUP_TICKET_PERMISSION_DISCRIMINATOR = new Uint8Array([164, 29, 7, 235, 183, 223, 11, 85]);
14
+
15
+ export function getSetupTicketPermissionDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(SETUP_TICKET_PERMISSION_DISCRIMINATOR); }
16
+
17
+ export type SetupTicketPermissionInstruction<TProgram extends string = typeof DUEL_PROGRAM_ADDRESS, TAccountTicket extends string | AccountMeta<string> = string, TAccountTenant extends string | AccountMeta<string> = string, TAccountPlayer extends string | AccountMeta<string> = string, TAccountPermission extends string | AccountMeta<string> = string, TAccountPermissionProgram extends string | AccountMeta<string> = string, TAccountSystemProgram extends string | AccountMeta<string> = "11111111111111111111111111111111", TRemainingAccounts extends readonly AccountMeta<string>[] = []> =
18
+ Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[TAccountTicket extends string ? ReadonlyAccount<TAccountTicket> : TAccountTicket, TAccountTenant extends string ? ReadonlyAccount<TAccountTenant> : TAccountTenant, TAccountPlayer extends string ? WritableSignerAccount<TAccountPlayer> & AccountSignerMeta<TAccountPlayer> : TAccountPlayer, TAccountPermission extends string ? WritableAccount<TAccountPermission> : TAccountPermission, TAccountPermissionProgram extends string ? ReadonlyAccount<TAccountPermissionProgram> : TAccountPermissionProgram, TAccountSystemProgram extends string ? ReadonlyAccount<TAccountSystemProgram> : TAccountSystemProgram, ...TRemainingAccounts]>;
19
+
20
+ export type SetupTicketPermissionInstructionData = { discriminator: ReadonlyUint8Array; };
21
+
22
+ export type SetupTicketPermissionInstructionDataArgs = { };
23
+
24
+ export function getSetupTicketPermissionInstructionDataEncoder(): FixedSizeEncoder<SetupTicketPermissionInstructionDataArgs> {
25
+ return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({ ...value, discriminator: SETUP_TICKET_PERMISSION_DISCRIMINATOR }));
26
+ }
27
+
28
+ export function getSetupTicketPermissionInstructionDataDecoder(): FixedSizeDecoder<SetupTicketPermissionInstructionData> {
29
+ return getStructDecoder([['discriminator', fixDecoderSize(getBytesDecoder(), 8)]]);
30
+ }
31
+
32
+ export function getSetupTicketPermissionInstructionDataCodec(): FixedSizeCodec<SetupTicketPermissionInstructionDataArgs, SetupTicketPermissionInstructionData> {
33
+ return combineCodec(getSetupTicketPermissionInstructionDataEncoder(), getSetupTicketPermissionInstructionDataDecoder());
34
+ }
35
+
36
+ export type SetupTicketPermissionAsyncInput<TAccountTicket extends string = string, TAccountTenant extends string = string, TAccountPlayer extends string = string, TAccountPermission extends string = string, TAccountPermissionProgram extends string = string, TAccountSystemProgram extends string = string> = {
37
+ ticket?: Address<TAccountTicket>;
38
+ tenant: Address<TAccountTenant>;
39
+ player: TransactionSigner<TAccountPlayer>;
40
+ permission: Address<TAccountPermission>;
41
+ permissionProgram: Address<TAccountPermissionProgram>;
42
+ systemProgram?: Address<TAccountSystemProgram>;
43
+ }
44
+
45
+ export async function getSetupTicketPermissionInstructionAsync<TAccountTicket extends string, TAccountTenant extends string, TAccountPlayer extends string, TAccountPermission extends string, TAccountPermissionProgram extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof DUEL_PROGRAM_ADDRESS>(input: SetupTicketPermissionAsyncInput<TAccountTicket, TAccountTenant, TAccountPlayer, TAccountPermission, TAccountPermissionProgram, TAccountSystemProgram>, config?: { programAddress?: TProgramAddress } ): Promise<SetupTicketPermissionInstruction<TProgramAddress, TAccountTicket, TAccountTenant, TAccountPlayer, TAccountPermission, TAccountPermissionProgram, TAccountSystemProgram>> {
46
+ // Program address.
47
+ const programAddress = config?.programAddress ?? DUEL_PROGRAM_ADDRESS;
48
+
49
+ // Original accounts.
50
+ const originalAccounts = { ticket: { value: input.ticket ?? null, isWritable: false }, tenant: { value: input.tenant ?? null, isWritable: false }, player: { value: input.player ?? null, isWritable: true }, permission: { value: input.permission ?? null, isWritable: true }, permissionProgram: { value: input.permissionProgram ?? null, isWritable: false }, systemProgram: { value: input.systemProgram ?? null, isWritable: false } }
51
+ const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
52
+
53
+
54
+ // Resolve default values.
55
+ if (!accounts.ticket.value) {
56
+ accounts.ticket.value = await getProgramDerivedAddress({ programAddress, seeds: [getBytesEncoder().encode(new Uint8Array([116, 105, 99, 107, 101, 116])), getAddressEncoder().encode(getAddressFromResolvedInstructionAccount("player", accounts.player.value)), getAddressEncoder().encode(getAddressFromResolvedInstructionAccount("tenant", accounts.tenant.value))] });
57
+ }
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("ticket", accounts.ticket), getAccountMeta("tenant", accounts.tenant), getAccountMeta("player", accounts.player), getAccountMeta("permission", accounts.permission), getAccountMeta("permissionProgram", accounts.permissionProgram), getAccountMeta("systemProgram", accounts.systemProgram)], data: getSetupTicketPermissionInstructionDataEncoder().encode({}), programAddress } as SetupTicketPermissionInstruction<TProgramAddress, TAccountTicket, TAccountTenant, TAccountPlayer, TAccountPermission, TAccountPermissionProgram, TAccountSystemProgram>);
64
+ }
65
+
66
+ export type SetupTicketPermissionInput<TAccountTicket extends string = string, TAccountTenant extends string = string, TAccountPlayer extends string = string, TAccountPermission extends string = string, TAccountPermissionProgram extends string = string, TAccountSystemProgram extends string = string> = {
67
+ ticket: Address<TAccountTicket>;
68
+ tenant: Address<TAccountTenant>;
69
+ player: TransactionSigner<TAccountPlayer>;
70
+ permission: Address<TAccountPermission>;
71
+ permissionProgram: Address<TAccountPermissionProgram>;
72
+ systemProgram?: Address<TAccountSystemProgram>;
73
+ }
74
+
75
+ export function getSetupTicketPermissionInstruction<TAccountTicket extends string, TAccountTenant extends string, TAccountPlayer extends string, TAccountPermission extends string, TAccountPermissionProgram extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof DUEL_PROGRAM_ADDRESS>(input: SetupTicketPermissionInput<TAccountTicket, TAccountTenant, TAccountPlayer, TAccountPermission, TAccountPermissionProgram, TAccountSystemProgram>, config?: { programAddress?: TProgramAddress } ): SetupTicketPermissionInstruction<TProgramAddress, TAccountTicket, TAccountTenant, TAccountPlayer, TAccountPermission, TAccountPermissionProgram, TAccountSystemProgram> {
76
+ // Program address.
77
+ const programAddress = config?.programAddress ?? DUEL_PROGRAM_ADDRESS;
78
+
79
+ // Original accounts.
80
+ const originalAccounts = { ticket: { value: input.ticket ?? null, isWritable: false }, tenant: { value: input.tenant ?? null, isWritable: false }, player: { value: input.player ?? null, isWritable: true }, permission: { value: input.permission ?? null, isWritable: true }, permissionProgram: { value: input.permissionProgram ?? null, isWritable: false }, systemProgram: { value: input.systemProgram ?? null, isWritable: false } }
81
+ const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
82
+
83
+
84
+ // Resolve default values.
85
+ if (!accounts.systemProgram.value) {
86
+ accounts.systemProgram.value = '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>;
87
+ }
88
+
89
+ const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
90
+ return Object.freeze({ accounts: [getAccountMeta("ticket", accounts.ticket), getAccountMeta("tenant", accounts.tenant), getAccountMeta("player", accounts.player), getAccountMeta("permission", accounts.permission), getAccountMeta("permissionProgram", accounts.permissionProgram), getAccountMeta("systemProgram", accounts.systemProgram)], data: getSetupTicketPermissionInstructionDataEncoder().encode({}), programAddress } as SetupTicketPermissionInstruction<TProgramAddress, TAccountTicket, TAccountTenant, TAccountPlayer, TAccountPermission, TAccountPermissionProgram, TAccountSystemProgram>);
91
+ }
92
+
93
+ export type ParsedSetupTicketPermissionInstruction<TProgram extends string = typeof DUEL_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = { programAddress: Address<TProgram>;
94
+ accounts: {
95
+ ticket: TAccountMetas[0];
96
+ tenant: TAccountMetas[1];
97
+ player: TAccountMetas[2];
98
+ permission: TAccountMetas[3];
99
+ permissionProgram: TAccountMetas[4];
100
+ systemProgram: TAccountMetas[5];
101
+ };
102
+ data: SetupTicketPermissionInstructionData; };
103
+
104
+ export function parseSetupTicketPermissionInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedSetupTicketPermissionInstruction<TProgram, TAccountMetas> {
105
+ if (instruction.accounts.length < 6) {
106
+ throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 6 });
107
+ }
108
+ let accountIndex = 0;
109
+ const getNextAccount = () => {
110
+ const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
111
+ accountIndex += 1;
112
+ return accountMeta;
113
+ }
114
+ return { programAddress: instruction.programAddress, accounts: { ticket: getNextAccount(), tenant: getNextAccount(), player: getNextAccount(), permission: getNextAccount(), permissionProgram: getNextAccount(), systemProgram: getNextAccount() }, data: getSetupTicketPermissionInstructionDataDecoder().decode(instruction.data) };
115
+ }