@1upmonster/duel 0.1.8 → 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.
Files changed (181) hide show
  1. package/dist/admin.d.ts +20 -42
  2. package/dist/admin.js +82 -117
  3. package/dist/encryption.js +1 -2
  4. package/dist/generated/duel/accounts/index.d.ts +10 -0
  5. package/dist/generated/duel/accounts/index.js +11 -0
  6. package/dist/generated/duel/accounts/matchTicket.d.ts +38 -0
  7. package/dist/generated/duel/accounts/matchTicket.js +45 -0
  8. package/dist/generated/duel/accounts/queue.d.ts +42 -0
  9. package/dist/generated/duel/accounts/queue.js +45 -0
  10. package/dist/generated/duel/accounts/tenant.d.ts +41 -0
  11. package/dist/generated/duel/accounts/tenant.js +44 -0
  12. package/dist/generated/duel/errors/duel.d.ts +33 -0
  13. package/dist/generated/duel/errors/duel.js +37 -0
  14. package/dist/generated/duel/errors/index.d.ts +8 -0
  15. package/dist/generated/duel/errors/index.js +9 -0
  16. package/dist/generated/duel/index.d.ts +12 -0
  17. package/dist/generated/duel/index.js +13 -0
  18. package/dist/generated/duel/instructions/cancelTicket.d.ts +45 -0
  19. package/dist/generated/duel/instructions/cancelTicket.js +56 -0
  20. package/dist/generated/duel/instructions/closeTicket.d.ts +45 -0
  21. package/dist/generated/duel/instructions/closeTicket.js +56 -0
  22. package/dist/generated/duel/instructions/commitTickets.d.ts +39 -0
  23. package/dist/generated/duel/instructions/commitTickets.js +50 -0
  24. package/dist/generated/duel/instructions/createTicket.d.ts +48 -0
  25. package/dist/generated/duel/instructions/createTicket.js +63 -0
  26. package/dist/generated/duel/instructions/delegateQueue.d.ts +69 -0
  27. package/dist/generated/duel/instructions/delegateQueue.js +90 -0
  28. package/dist/generated/duel/instructions/delegateTicket.d.ts +69 -0
  29. package/dist/generated/duel/instructions/delegateTicket.js +90 -0
  30. package/dist/generated/duel/instructions/flushMatches.d.ts +37 -0
  31. package/dist/generated/duel/instructions/flushMatches.js +43 -0
  32. package/dist/generated/duel/instructions/index.d.ts +18 -0
  33. package/dist/generated/duel/instructions/index.js +19 -0
  34. package/dist/generated/duel/instructions/initializeQueue.d.ts +48 -0
  35. package/dist/generated/duel/instructions/initializeQueue.js +63 -0
  36. package/dist/generated/duel/instructions/initializeTenant.d.ts +70 -0
  37. package/dist/generated/duel/instructions/initializeTenant.js +67 -0
  38. package/dist/generated/duel/instructions/joinQueue.d.ts +51 -0
  39. package/dist/generated/duel/instructions/joinQueue.js +56 -0
  40. package/dist/generated/duel/instructions/processUndelegation.d.ts +43 -0
  41. package/dist/generated/duel/instructions/processUndelegation.js +49 -0
  42. package/dist/generated/duel/programs/duel.d.ts +88 -0
  43. package/dist/generated/duel/programs/duel.js +138 -0
  44. package/dist/generated/duel/programs/index.d.ts +8 -0
  45. package/dist/generated/duel/programs/index.js +9 -0
  46. package/dist/generated/duel/types/accountType.d.ts +25 -0
  47. package/dist/generated/duel/types/accountType.js +25 -0
  48. package/dist/generated/duel/types/index.d.ts +13 -0
  49. package/dist/generated/duel/types/index.js +14 -0
  50. package/dist/generated/duel/types/matchEntry.d.ts +23 -0
  51. package/dist/generated/duel/types/matchEntry.js +18 -0
  52. package/dist/generated/duel/types/matchFound.d.ts +23 -0
  53. package/dist/generated/duel/types/matchFound.js +18 -0
  54. package/dist/generated/duel/types/pendingMatch.d.ts +21 -0
  55. package/dist/generated/duel/types/pendingMatch.js +18 -0
  56. package/dist/generated/duel/types/queueEntry.d.ts +19 -0
  57. package/dist/generated/duel/types/queueEntry.js +18 -0
  58. package/dist/generated/duel/types/ticketStatus.d.ts +40 -0
  59. package/dist/generated/duel/types/ticketStatus.js +25 -0
  60. package/dist/generated/rps-game/accounts/gameSession.d.ts +40 -0
  61. package/dist/generated/rps-game/accounts/gameSession.js +45 -0
  62. package/dist/generated/rps-game/accounts/index.d.ts +9 -0
  63. package/dist/generated/rps-game/accounts/index.js +10 -0
  64. package/dist/generated/rps-game/accounts/playerProfile.d.ts +36 -0
  65. package/dist/generated/rps-game/accounts/playerProfile.js +47 -0
  66. package/dist/generated/rps-game/errors/index.d.ts +8 -0
  67. package/dist/generated/rps-game/errors/index.js +9 -0
  68. package/dist/generated/rps-game/errors/rpsGame.d.ts +25 -0
  69. package/dist/generated/rps-game/errors/rpsGame.js +29 -0
  70. package/dist/generated/rps-game/index.d.ts +12 -0
  71. package/dist/generated/rps-game/index.js +13 -0
  72. package/dist/generated/rps-game/instructions/closePlayer.d.ts +45 -0
  73. package/dist/generated/rps-game/instructions/closePlayer.js +56 -0
  74. package/dist/generated/rps-game/instructions/delegatePda.d.ts +69 -0
  75. package/dist/generated/rps-game/instructions/delegatePda.js +90 -0
  76. package/dist/generated/rps-game/instructions/index.d.ts +16 -0
  77. package/dist/generated/rps-game/instructions/index.js +17 -0
  78. package/dist/generated/rps-game/instructions/initializePlayer.d.ts +48 -0
  79. package/dist/generated/rps-game/instructions/initializePlayer.js +63 -0
  80. package/dist/generated/rps-game/instructions/makeChoice.d.ts +44 -0
  81. package/dist/generated/rps-game/instructions/makeChoice.js +46 -0
  82. package/dist/generated/rps-game/instructions/onMatchFound.d.ts +43 -0
  83. package/dist/generated/rps-game/instructions/onMatchFound.js +45 -0
  84. package/dist/generated/rps-game/instructions/persistResults.d.ts +43 -0
  85. package/dist/generated/rps-game/instructions/persistResults.js +50 -0
  86. package/dist/generated/rps-game/instructions/processUndelegation.d.ts +43 -0
  87. package/dist/generated/rps-game/instructions/processUndelegation.js +49 -0
  88. package/dist/generated/rps-game/instructions/startGame.d.ts +54 -0
  89. package/dist/generated/rps-game/instructions/startGame.js +67 -0
  90. package/dist/generated/rps-game/instructions/startGameWithTicket.d.ts +57 -0
  91. package/dist/generated/rps-game/instructions/startGameWithTicket.js +67 -0
  92. package/dist/generated/rps-game/programs/index.d.ts +8 -0
  93. package/dist/generated/rps-game/programs/index.js +9 -0
  94. package/dist/generated/rps-game/programs/rpsGame.d.ts +78 -0
  95. package/dist/generated/rps-game/programs/rpsGame.js +118 -0
  96. package/dist/generated/rps-game/types/accountType.d.ts +34 -0
  97. package/dist/generated/rps-game/types/accountType.js +25 -0
  98. package/dist/generated/rps-game/types/choice.d.ts +17 -0
  99. package/dist/generated/rps-game/types/choice.js +25 -0
  100. package/dist/generated/rps-game/types/gameResult.d.ts +26 -0
  101. package/dist/generated/rps-game/types/gameResult.js +25 -0
  102. package/dist/generated/rps-game/types/index.d.ts +10 -0
  103. package/dist/generated/rps-game/types/index.js +11 -0
  104. package/dist/index.d.ts +2 -1
  105. package/dist/index.js +3 -2
  106. package/dist/player.d.ts +21 -48
  107. package/dist/player.js +61 -140
  108. package/dist/tee.d.ts +14 -0
  109. package/dist/tee.js +62 -0
  110. package/dist/transaction.d.ts +11 -0
  111. package/dist/transaction.js +50 -0
  112. package/dist/utils.d.ts +4 -4
  113. package/dist/utils.js +23 -8
  114. package/package.json +3 -6
  115. package/src/admin.ts +129 -163
  116. package/src/duel.json +66 -2
  117. package/src/encryption.ts +0 -3
  118. package/src/generated/duel/accounts/index.ts +11 -0
  119. package/src/generated/duel/accounts/matchTicket.ts +77 -0
  120. package/src/generated/duel/accounts/queue.ts +77 -0
  121. package/src/generated/duel/accounts/tenant.ts +76 -0
  122. package/src/generated/duel/errors/duel.ts +48 -0
  123. package/src/generated/duel/errors/index.ts +9 -0
  124. package/src/generated/duel/index.ts +13 -0
  125. package/src/generated/duel/instructions/cancelTicket.ts +100 -0
  126. package/src/generated/duel/instructions/closeTicket.ts +100 -0
  127. package/src/generated/duel/instructions/commitTickets.ts +84 -0
  128. package/src/generated/duel/instructions/createTicket.ts +109 -0
  129. package/src/generated/duel/instructions/delegateQueue.ts +157 -0
  130. package/src/generated/duel/instructions/delegateTicket.ts +157 -0
  131. package/src/generated/duel/instructions/flushMatches.ts +76 -0
  132. package/src/generated/duel/instructions/index.ts +19 -0
  133. package/src/generated/duel/instructions/initializeQueue.ts +109 -0
  134. package/src/generated/duel/instructions/initializeTenant.ts +126 -0
  135. package/src/generated/duel/instructions/joinQueue.ts +106 -0
  136. package/src/generated/duel/instructions/processUndelegation.ts +86 -0
  137. package/src/generated/duel/programs/duel.ts +104 -0
  138. package/src/generated/duel/programs/index.ts +9 -0
  139. package/src/generated/duel/types/accountType.ts +36 -0
  140. package/src/generated/duel/types/index.ts +14 -0
  141. package/src/generated/duel/types/matchEntry.ts +25 -0
  142. package/src/generated/duel/types/matchFound.ts +25 -0
  143. package/src/generated/duel/types/pendingMatch.ts +25 -0
  144. package/src/generated/duel/types/queueEntry.ts +25 -0
  145. package/src/generated/duel/types/ticketStatus.ts +38 -0
  146. package/src/generated/rps-game/accounts/gameSession.ts +77 -0
  147. package/src/generated/rps-game/accounts/index.ts +10 -0
  148. package/src/generated/rps-game/accounts/playerProfile.ts +80 -0
  149. package/src/generated/rps-game/errors/index.ts +9 -0
  150. package/src/generated/rps-game/errors/rpsGame.ts +40 -0
  151. package/src/generated/rps-game/index.ts +13 -0
  152. package/src/generated/rps-game/instructions/closePlayer.ts +100 -0
  153. package/src/generated/rps-game/instructions/delegatePda.ts +157 -0
  154. package/src/generated/rps-game/instructions/index.ts +17 -0
  155. package/src/generated/rps-game/instructions/initializePlayer.ts +109 -0
  156. package/src/generated/rps-game/instructions/makeChoice.ts +84 -0
  157. package/src/generated/rps-game/instructions/onMatchFound.ts +79 -0
  158. package/src/generated/rps-game/instructions/persistResults.ts +88 -0
  159. package/src/generated/rps-game/instructions/processUndelegation.ts +86 -0
  160. package/src/generated/rps-game/instructions/startGame.ts +118 -0
  161. package/src/generated/rps-game/instructions/startGameWithTicket.ts +121 -0
  162. package/src/generated/rps-game/programs/index.ts +9 -0
  163. package/src/generated/rps-game/programs/rpsGame.ts +95 -0
  164. package/src/generated/rps-game/types/accountType.ts +36 -0
  165. package/src/generated/rps-game/types/choice.ts +25 -0
  166. package/src/generated/rps-game/types/gameResult.ts +37 -0
  167. package/src/generated/rps-game/types/index.ts +11 -0
  168. package/src/index.ts +2 -1
  169. package/src/player.ts +96 -192
  170. package/src/rps_game.json +991 -0
  171. package/src/tee.ts +79 -0
  172. package/src/transaction.ts +90 -0
  173. package/src/utils.ts +35 -20
  174. package/tsconfig.json +2 -2
  175. package/dist/client.d.ts +0 -54
  176. package/dist/client.js +0 -265
  177. package/dist/duel.json +0 -1207
  178. package/dist/private_matchmaking.json +0 -534
  179. package/dist/types.d.ts +0 -635
  180. package/dist/types.js +0 -2
  181. package/src/types.ts +0 -300
@@ -0,0 +1,38 @@
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, getU64Decoder, getU64Encoder, getUnitDecoder, getUnitEncoder, type Address, type Codec, type Decoder, type Encoder, type GetDiscriminatedUnionVariant, type GetDiscriminatedUnionVariantContent } from '@solana/kit';
10
+
11
+ export type TicketStatus = { __kind: "Searching" } | { __kind: "Matched", opponent: Address; matchId: bigint; } | { __kind: "Expired" } | { __kind: "Cancelled" };
12
+
13
+ export type TicketStatusArgs = { __kind: "Searching" } | { __kind: "Matched", opponent: Address; matchId: number | bigint; } | { __kind: "Expired" } | { __kind: "Cancelled" };
14
+
15
+ export function getTicketStatusEncoder(): Encoder<TicketStatusArgs> {
16
+ return getDiscriminatedUnionEncoder([['Searching', getUnitEncoder()], ['Matched', getStructEncoder([['opponent', getAddressEncoder()], ['matchId', getU64Encoder()]])], ['Expired', getUnitEncoder()], ['Cancelled', getUnitEncoder()]]);
17
+ }
18
+
19
+ export function getTicketStatusDecoder(): Decoder<TicketStatus> {
20
+ return getDiscriminatedUnionDecoder([['Searching', getUnitDecoder()], ['Matched', getStructDecoder([['opponent', getAddressDecoder()], ['matchId', getU64Decoder()]])], ['Expired', getUnitDecoder()], ['Cancelled', getUnitDecoder()]]);
21
+ }
22
+
23
+ export function getTicketStatusCodec(): Codec<TicketStatusArgs, TicketStatus> {
24
+ return combineCodec(getTicketStatusEncoder(), getTicketStatusDecoder());
25
+ }
26
+
27
+ // Data Enum Helpers.
28
+ export function ticketStatus(kind: 'Searching'): GetDiscriminatedUnionVariant<TicketStatusArgs, '__kind', 'Searching'>;
29
+ export function ticketStatus(kind: 'Matched', data: GetDiscriminatedUnionVariantContent<TicketStatusArgs, '__kind', 'Matched'>): GetDiscriminatedUnionVariant<TicketStatusArgs, '__kind', 'Matched'>;
30
+ export function ticketStatus(kind: 'Expired'): GetDiscriminatedUnionVariant<TicketStatusArgs, '__kind', 'Expired'>;
31
+ export function ticketStatus(kind: 'Cancelled'): GetDiscriminatedUnionVariant<TicketStatusArgs, '__kind', 'Cancelled'>;
32
+ export function ticketStatus<K extends TicketStatusArgs['__kind'], Data>(kind: K, data?: Data) {
33
+ return Array.isArray(data) ? { __kind: kind, fields: data } : { __kind: kind, ...(data ?? {}) };
34
+ }
35
+
36
+ export function isTicketStatus<K extends TicketStatus['__kind']>(kind: K, value: TicketStatus): value is TicketStatus & { __kind: K } {
37
+ return value.__kind === kind;
38
+ };
@@ -0,0 +1,77 @@
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 { assertAccountExists, assertAccountsExist, combineCodec, decodeAccount, fetchEncodedAccount, fetchEncodedAccounts, fixDecoderSize, fixEncoderSize, getAddressDecoder, getAddressEncoder, getBytesDecoder, getBytesEncoder, getOptionDecoder, getOptionEncoder, getStructDecoder, getStructEncoder, getU64Decoder, getU64Encoder, transformEncoder, type Account, type Address, type Codec, type Decoder, type EncodedAccount, type Encoder, type FetchAccountConfig, type FetchAccountsConfig, type MaybeAccount, type MaybeEncodedAccount, type Option, type OptionOrNullable, type ReadonlyUint8Array } from '@solana/kit';
10
+ import { getChoiceDecoder, getChoiceEncoder, getGameResultDecoder, getGameResultEncoder, type Choice, type ChoiceArgs, type GameResult, type GameResultArgs } from '../types';
11
+
12
+ export const GAME_SESSION_DISCRIMINATOR = new Uint8Array([150, 116, 20, 197, 205, 121, 220, 240]);
13
+
14
+ export function getGameSessionDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(GAME_SESSION_DISCRIMINATOR); }
15
+
16
+ export type GameSession = { discriminator: ReadonlyUint8Array; gameId: bigint; player1: Address; player2: Address; player1Choice: Option<Choice>; player2Choice: Option<Choice>; result: GameResult; };
17
+
18
+ export type GameSessionArgs = { gameId: number | bigint; player1: Address; player2: Address; player1Choice: OptionOrNullable<ChoiceArgs>; player2Choice: OptionOrNullable<ChoiceArgs>; result: GameResultArgs; };
19
+
20
+ /** Gets the encoder for {@link GameSessionArgs} account data. */
21
+ export function getGameSessionEncoder(): Encoder<GameSessionArgs> {
22
+ return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['gameId', getU64Encoder()], ['player1', getAddressEncoder()], ['player2', getAddressEncoder()], ['player1Choice', getOptionEncoder(getChoiceEncoder())], ['player2Choice', getOptionEncoder(getChoiceEncoder())], ['result', getGameResultEncoder()]]), (value) => ({ ...value, discriminator: GAME_SESSION_DISCRIMINATOR }));
23
+ }
24
+
25
+ /** Gets the decoder for {@link GameSession} account data. */
26
+ export function getGameSessionDecoder(): Decoder<GameSession> {
27
+ return getStructDecoder([['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['gameId', getU64Decoder()], ['player1', getAddressDecoder()], ['player2', getAddressDecoder()], ['player1Choice', getOptionDecoder(getChoiceDecoder())], ['player2Choice', getOptionDecoder(getChoiceDecoder())], ['result', getGameResultDecoder()]]);
28
+ }
29
+
30
+ /** Gets the codec for {@link GameSession} account data. */
31
+ export function getGameSessionCodec(): Codec<GameSessionArgs, GameSession> {
32
+ return combineCodec(getGameSessionEncoder(), getGameSessionDecoder());
33
+ }
34
+
35
+ export function decodeGameSession<TAddress extends string = string>(encodedAccount: EncodedAccount<TAddress>): Account<GameSession, TAddress>;
36
+ export function decodeGameSession<TAddress extends string = string>(encodedAccount: MaybeEncodedAccount<TAddress>): MaybeAccount<GameSession, TAddress>;
37
+ export function decodeGameSession<TAddress extends string = string>(encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>): Account<GameSession, TAddress> | MaybeAccount<GameSession, TAddress> {
38
+ return decodeAccount(encodedAccount as MaybeEncodedAccount<TAddress>, getGameSessionDecoder());
39
+ }
40
+
41
+ export async function fetchGameSession<TAddress extends string = string>(
42
+ rpc: Parameters<typeof fetchEncodedAccount>[0],
43
+ address: Address<TAddress>,
44
+ config?: FetchAccountConfig,
45
+ ): Promise<Account<GameSession, TAddress>> {
46
+ const maybeAccount = await fetchMaybeGameSession(rpc, address, config);
47
+ assertAccountExists(maybeAccount);
48
+ return maybeAccount;
49
+ }
50
+
51
+ export async function fetchMaybeGameSession<TAddress extends string = string>(
52
+ rpc: Parameters<typeof fetchEncodedAccount>[0],
53
+ address: Address<TAddress>,
54
+ config?: FetchAccountConfig,
55
+ ): Promise<MaybeAccount<GameSession, TAddress>> {
56
+ const maybeAccount = await fetchEncodedAccount(rpc, address, config);
57
+ return decodeGameSession(maybeAccount);
58
+ }
59
+
60
+ export async function fetchAllGameSession(
61
+ rpc: Parameters<typeof fetchEncodedAccounts>[0],
62
+ addresses: Array<Address>,
63
+ config?: FetchAccountsConfig,
64
+ ): Promise<Account<GameSession>[]> {
65
+ const maybeAccounts = await fetchAllMaybeGameSession(rpc, addresses, config);
66
+ assertAccountsExist(maybeAccounts);
67
+ return maybeAccounts;
68
+ }
69
+
70
+ export async function fetchAllMaybeGameSession(
71
+ rpc: Parameters<typeof fetchEncodedAccounts>[0],
72
+ addresses: Array<Address>,
73
+ config?: FetchAccountsConfig,
74
+ ): Promise<MaybeAccount<GameSession>[]> {
75
+ const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
76
+ return maybeAccounts.map((maybeAccount) => decodeGameSession(maybeAccount));
77
+ }
@@ -0,0 +1,10 @@
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 './gameSession';
10
+ export * from './playerProfile';
@@ -0,0 +1,80 @@
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 { assertAccountExists, assertAccountsExist, combineCodec, decodeAccount, fetchEncodedAccount, fetchEncodedAccounts, fixDecoderSize, fixEncoderSize, getAddressDecoder, getAddressEncoder, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, getU64Decoder, getU64Encoder, transformEncoder, type Account, type Address, type EncodedAccount, type FetchAccountConfig, type FetchAccountsConfig, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type MaybeAccount, type MaybeEncodedAccount, type ReadonlyUint8Array } from '@solana/kit';
10
+
11
+ export const PLAYER_PROFILE_DISCRIMINATOR = new Uint8Array([82, 226, 99, 87, 164, 130, 181, 80]);
12
+
13
+ export function getPlayerProfileDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(PLAYER_PROFILE_DISCRIMINATOR); }
14
+
15
+ export type PlayerProfile = { discriminator: ReadonlyUint8Array; player: Address; elo: bigint; gamesPlayed: bigint; gamesWon: bigint; };
16
+
17
+ export type PlayerProfileArgs = { player: Address; elo: number | bigint; gamesPlayed: number | bigint; gamesWon: number | bigint; };
18
+
19
+ /** Gets the encoder for {@link PlayerProfileArgs} account data. */
20
+ export function getPlayerProfileEncoder(): FixedSizeEncoder<PlayerProfileArgs> {
21
+ return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['player', getAddressEncoder()], ['elo', getU64Encoder()], ['gamesPlayed', getU64Encoder()], ['gamesWon', getU64Encoder()]]), (value) => ({ ...value, discriminator: PLAYER_PROFILE_DISCRIMINATOR }));
22
+ }
23
+
24
+ /** Gets the decoder for {@link PlayerProfile} account data. */
25
+ export function getPlayerProfileDecoder(): FixedSizeDecoder<PlayerProfile> {
26
+ return getStructDecoder([['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['player', getAddressDecoder()], ['elo', getU64Decoder()], ['gamesPlayed', getU64Decoder()], ['gamesWon', getU64Decoder()]]);
27
+ }
28
+
29
+ /** Gets the codec for {@link PlayerProfile} account data. */
30
+ export function getPlayerProfileCodec(): FixedSizeCodec<PlayerProfileArgs, PlayerProfile> {
31
+ return combineCodec(getPlayerProfileEncoder(), getPlayerProfileDecoder());
32
+ }
33
+
34
+ export function decodePlayerProfile<TAddress extends string = string>(encodedAccount: EncodedAccount<TAddress>): Account<PlayerProfile, TAddress>;
35
+ export function decodePlayerProfile<TAddress extends string = string>(encodedAccount: MaybeEncodedAccount<TAddress>): MaybeAccount<PlayerProfile, TAddress>;
36
+ export function decodePlayerProfile<TAddress extends string = string>(encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>): Account<PlayerProfile, TAddress> | MaybeAccount<PlayerProfile, TAddress> {
37
+ return decodeAccount(encodedAccount as MaybeEncodedAccount<TAddress>, getPlayerProfileDecoder());
38
+ }
39
+
40
+ export async function fetchPlayerProfile<TAddress extends string = string>(
41
+ rpc: Parameters<typeof fetchEncodedAccount>[0],
42
+ address: Address<TAddress>,
43
+ config?: FetchAccountConfig,
44
+ ): Promise<Account<PlayerProfile, TAddress>> {
45
+ const maybeAccount = await fetchMaybePlayerProfile(rpc, address, config);
46
+ assertAccountExists(maybeAccount);
47
+ return maybeAccount;
48
+ }
49
+
50
+ export async function fetchMaybePlayerProfile<TAddress extends string = string>(
51
+ rpc: Parameters<typeof fetchEncodedAccount>[0],
52
+ address: Address<TAddress>,
53
+ config?: FetchAccountConfig,
54
+ ): Promise<MaybeAccount<PlayerProfile, TAddress>> {
55
+ const maybeAccount = await fetchEncodedAccount(rpc, address, config);
56
+ return decodePlayerProfile(maybeAccount);
57
+ }
58
+
59
+ export async function fetchAllPlayerProfile(
60
+ rpc: Parameters<typeof fetchEncodedAccounts>[0],
61
+ addresses: Array<Address>,
62
+ config?: FetchAccountsConfig,
63
+ ): Promise<Account<PlayerProfile>[]> {
64
+ const maybeAccounts = await fetchAllMaybePlayerProfile(rpc, addresses, config);
65
+ assertAccountsExist(maybeAccounts);
66
+ return maybeAccounts;
67
+ }
68
+
69
+ export async function fetchAllMaybePlayerProfile(
70
+ rpc: Parameters<typeof fetchEncodedAccounts>[0],
71
+ addresses: Array<Address>,
72
+ config?: FetchAccountsConfig,
73
+ ): Promise<MaybeAccount<PlayerProfile>[]> {
74
+ const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
75
+ return maybeAccounts.map((maybeAccount) => decodePlayerProfile(maybeAccount));
76
+ }
77
+
78
+ export function getPlayerProfileSize(): number {
79
+ return 64;
80
+ }
@@ -0,0 +1,9 @@
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 './rpsGame';
@@ -0,0 +1,40 @@
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 { isProgramError, type Address, type SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM, type SolanaError } from '@solana/kit';
10
+ import { RPS_GAME_PROGRAM_ADDRESS } from '../programs';
11
+
12
+ /** AlreadyChose: Already chose */
13
+ export const RPS_GAME_ERROR__ALREADY_CHOSE = 0x1770; // 6000
14
+ /** InvalidPlayer: Invalid player */
15
+ export const RPS_GAME_ERROR__INVALID_PLAYER = 0x1771; // 6001
16
+ /** InvalidMatchTicket: Invalid match ticket - not matched or wrong opponent */
17
+ export const RPS_GAME_ERROR__INVALID_MATCH_TICKET = 0x1772; // 6002
18
+
19
+ export type RpsGameError = typeof RPS_GAME_ERROR__ALREADY_CHOSE | typeof RPS_GAME_ERROR__INVALID_MATCH_TICKET | typeof RPS_GAME_ERROR__INVALID_PLAYER;
20
+
21
+ let rpsGameErrorMessages: Record<RpsGameError, string> | undefined;
22
+ if (process.env.NODE_ENV !== 'production') {
23
+ rpsGameErrorMessages = { [RPS_GAME_ERROR__ALREADY_CHOSE]: `Already chose`, [RPS_GAME_ERROR__INVALID_MATCH_TICKET]: `Invalid match ticket - not matched or wrong opponent`, [RPS_GAME_ERROR__INVALID_PLAYER]: `Invalid player` };
24
+ }
25
+
26
+ export function getRpsGameErrorMessage(code: RpsGameError): string {
27
+ if (process.env.NODE_ENV !== 'production') {
28
+ return (rpsGameErrorMessages as Record<RpsGameError, string>)[code];
29
+ }
30
+
31
+ return 'Error message not available in production bundles.';
32
+ }
33
+
34
+ export function isRpsGameError<TProgramErrorCode extends RpsGameError>(
35
+ error: unknown,
36
+ transactionMessage: { instructions: Record<number, { programAddress: Address }> },
37
+ code?: TProgramErrorCode,
38
+ ): error is SolanaError<typeof SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM> & Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> {
39
+ return isProgramError<TProgramErrorCode>(error, transactionMessage, RPS_GAME_PROGRAM_ADDRESS, code);
40
+ }
@@ -0,0 +1,13 @@
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 './accounts';
10
+ export * from './errors';
11
+ export * from './instructions';
12
+ export * from './programs';
13
+ export * from './types';
@@ -0,0 +1,100 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+
9
+ import { combineCodec, fixDecoderSize, fixEncoderSize, getAddressEncoder, getBytesDecoder, getBytesEncoder, getProgramDerivedAddress, getStructDecoder, getStructEncoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, transformEncoder, type AccountMeta, type AccountSignerMeta, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlySignerAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount } from '@solana/kit';
10
+ import { getAccountMetaFactory, getAddressFromResolvedInstructionAccount, type ResolvedInstructionAccount } from '@solana/program-client-core';
11
+ import { RPS_GAME_PROGRAM_ADDRESS } from '../programs';
12
+
13
+ export const CLOSE_PLAYER_DISCRIMINATOR = new Uint8Array([225, 227, 204, 63, 32, 122, 58, 227]);
14
+
15
+ export function getClosePlayerDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(CLOSE_PLAYER_DISCRIMINATOR); }
16
+
17
+ export type ClosePlayerInstruction<TProgram extends string = typeof RPS_GAME_PROGRAM_ADDRESS, TAccountProfile extends string | AccountMeta<string> = string, TAccountPlayer extends string | AccountMeta<string> = string, TAccountPayer extends string | AccountMeta<string> = string, TRemainingAccounts extends readonly AccountMeta<string>[] = []> =
18
+ Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[TAccountProfile extends string ? WritableAccount<TAccountProfile> : TAccountProfile, TAccountPlayer extends string ? ReadonlySignerAccount<TAccountPlayer> & AccountSignerMeta<TAccountPlayer> : TAccountPlayer, TAccountPayer extends string ? WritableAccount<TAccountPayer> : TAccountPayer, ...TRemainingAccounts]>;
19
+
20
+ export type ClosePlayerInstructionData = { discriminator: ReadonlyUint8Array; };
21
+
22
+ export type ClosePlayerInstructionDataArgs = { };
23
+
24
+ export function getClosePlayerInstructionDataEncoder(): FixedSizeEncoder<ClosePlayerInstructionDataArgs> {
25
+ return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({ ...value, discriminator: CLOSE_PLAYER_DISCRIMINATOR }));
26
+ }
27
+
28
+ export function getClosePlayerInstructionDataDecoder(): FixedSizeDecoder<ClosePlayerInstructionData> {
29
+ return getStructDecoder([['discriminator', fixDecoderSize(getBytesDecoder(), 8)]]);
30
+ }
31
+
32
+ export function getClosePlayerInstructionDataCodec(): FixedSizeCodec<ClosePlayerInstructionDataArgs, ClosePlayerInstructionData> {
33
+ return combineCodec(getClosePlayerInstructionDataEncoder(), getClosePlayerInstructionDataDecoder());
34
+ }
35
+
36
+ export type ClosePlayerAsyncInput<TAccountProfile extends string = string, TAccountPlayer extends string = string, TAccountPayer extends string = string> = {
37
+ profile?: Address<TAccountProfile>;
38
+ player: TransactionSigner<TAccountPlayer>;
39
+ payer: Address<TAccountPayer>;
40
+ }
41
+
42
+ export async function getClosePlayerInstructionAsync<TAccountProfile extends string, TAccountPlayer extends string, TAccountPayer extends string, TProgramAddress extends Address = typeof RPS_GAME_PROGRAM_ADDRESS>(input: ClosePlayerAsyncInput<TAccountProfile, TAccountPlayer, TAccountPayer>, config?: { programAddress?: TProgramAddress } ): Promise<ClosePlayerInstruction<TProgramAddress, TAccountProfile, TAccountPlayer, TAccountPayer>> {
43
+ // Program address.
44
+ const programAddress = config?.programAddress ?? RPS_GAME_PROGRAM_ADDRESS;
45
+
46
+ // Original accounts.
47
+ const originalAccounts = { profile: { value: input.profile ?? null, isWritable: true }, player: { value: input.player ?? null, isWritable: false }, payer: { value: input.payer ?? null, isWritable: true } }
48
+ const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
49
+
50
+
51
+ // Resolve default values.
52
+ if (!accounts.profile.value) {
53
+ accounts.profile.value = await getProgramDerivedAddress({ programAddress, seeds: [getBytesEncoder().encode(new Uint8Array([112, 108, 97, 121, 101, 114, 95, 112, 114, 111, 102, 105, 108, 101, 95, 118, 51, 53])), getAddressEncoder().encode(getAddressFromResolvedInstructionAccount("player", accounts.player.value))] });
54
+ }
55
+
56
+ const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
57
+ return Object.freeze({ accounts: [getAccountMeta("profile", accounts.profile), getAccountMeta("player", accounts.player), getAccountMeta("payer", accounts.payer)], data: getClosePlayerInstructionDataEncoder().encode({}), programAddress } as ClosePlayerInstruction<TProgramAddress, TAccountProfile, TAccountPlayer, TAccountPayer>);
58
+ }
59
+
60
+ export type ClosePlayerInput<TAccountProfile extends string = string, TAccountPlayer extends string = string, TAccountPayer extends string = string> = {
61
+ profile: Address<TAccountProfile>;
62
+ player: TransactionSigner<TAccountPlayer>;
63
+ payer: Address<TAccountPayer>;
64
+ }
65
+
66
+ export function getClosePlayerInstruction<TAccountProfile extends string, TAccountPlayer extends string, TAccountPayer extends string, TProgramAddress extends Address = typeof RPS_GAME_PROGRAM_ADDRESS>(input: ClosePlayerInput<TAccountProfile, TAccountPlayer, TAccountPayer>, config?: { programAddress?: TProgramAddress } ): ClosePlayerInstruction<TProgramAddress, TAccountProfile, TAccountPlayer, TAccountPayer> {
67
+ // Program address.
68
+ const programAddress = config?.programAddress ?? RPS_GAME_PROGRAM_ADDRESS;
69
+
70
+ // Original accounts.
71
+ const originalAccounts = { profile: { value: input.profile ?? null, isWritable: true }, player: { value: input.player ?? null, isWritable: false }, payer: { value: input.payer ?? null, isWritable: true } }
72
+ const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
73
+
74
+
75
+
76
+
77
+ const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
78
+ return Object.freeze({ accounts: [getAccountMeta("profile", accounts.profile), getAccountMeta("player", accounts.player), getAccountMeta("payer", accounts.payer)], data: getClosePlayerInstructionDataEncoder().encode({}), programAddress } as ClosePlayerInstruction<TProgramAddress, TAccountProfile, TAccountPlayer, TAccountPayer>);
79
+ }
80
+
81
+ export type ParsedClosePlayerInstruction<TProgram extends string = typeof RPS_GAME_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = { programAddress: Address<TProgram>;
82
+ accounts: {
83
+ profile: TAccountMetas[0];
84
+ player: TAccountMetas[1];
85
+ payer: TAccountMetas[2];
86
+ };
87
+ data: ClosePlayerInstructionData; };
88
+
89
+ export function parseClosePlayerInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedClosePlayerInstruction<TProgram, TAccountMetas> {
90
+ if (instruction.accounts.length < 3) {
91
+ throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 3 });
92
+ }
93
+ let accountIndex = 0;
94
+ const getNextAccount = () => {
95
+ const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
96
+ accountIndex += 1;
97
+ return accountMeta;
98
+ }
99
+ return { programAddress: instruction.programAddress, accounts: { profile: getNextAccount(), player: getNextAccount(), payer: getNextAccount() }, data: getClosePlayerInstructionDataDecoder().decode(instruction.data) };
100
+ }
@@ -0,0 +1,157 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+
9
+ import { combineCodec, fixDecoderSize, fixEncoderSize, getAddressEncoder, getBytesDecoder, getBytesEncoder, getProgramDerivedAddress, getStructDecoder, getStructEncoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, transformEncoder, type AccountMeta, type AccountSignerMeta, type Address, type Codec, type Decoder, type Encoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, type WritableSignerAccount } from '@solana/kit';
10
+ import { getAccountMetaFactory, getAddressFromResolvedInstructionAccount, type ResolvedInstructionAccount } from '@solana/program-client-core';
11
+ import { RPS_GAME_PROGRAM_ADDRESS } from '../programs';
12
+ import { getAccountTypeDecoder, getAccountTypeEncoder, type AccountType, type AccountTypeArgs } from '../types';
13
+
14
+ export const DELEGATE_PDA_DISCRIMINATOR = new Uint8Array([248, 217, 193, 46, 124, 191, 64, 135]);
15
+
16
+ export function getDelegatePdaDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(DELEGATE_PDA_DISCRIMINATOR); }
17
+
18
+ export type DelegatePdaInstruction<TProgram extends string = typeof RPS_GAME_PROGRAM_ADDRESS, TAccountBufferPda extends string | AccountMeta<string> = string, TAccountDelegationRecordPda extends string | AccountMeta<string> = string, TAccountDelegationMetadataPda extends string | AccountMeta<string> = string, TAccountPda extends string | AccountMeta<string> = string, TAccountPayer extends string | AccountMeta<string> = string, TAccountValidator extends string | AccountMeta<string> = string, TAccountOwnerProgram extends string | AccountMeta<string> = "8ohu3RobXyZ2DebyJjbs2co9YCG275FUsVckEcmDbCos", TAccountDelegationProgram extends string | AccountMeta<string> = "DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh", TAccountSystemProgram extends string | AccountMeta<string> = "11111111111111111111111111111111", TRemainingAccounts extends readonly AccountMeta<string>[] = []> =
19
+ Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[TAccountBufferPda extends string ? WritableAccount<TAccountBufferPda> : TAccountBufferPda, TAccountDelegationRecordPda extends string ? WritableAccount<TAccountDelegationRecordPda> : TAccountDelegationRecordPda, TAccountDelegationMetadataPda extends string ? WritableAccount<TAccountDelegationMetadataPda> : TAccountDelegationMetadataPda, TAccountPda extends string ? WritableAccount<TAccountPda> : TAccountPda, TAccountPayer extends string ? WritableSignerAccount<TAccountPayer> & AccountSignerMeta<TAccountPayer> : TAccountPayer, TAccountValidator extends string ? ReadonlyAccount<TAccountValidator> : TAccountValidator, TAccountOwnerProgram extends string ? ReadonlyAccount<TAccountOwnerProgram> : TAccountOwnerProgram, TAccountDelegationProgram extends string ? ReadonlyAccount<TAccountDelegationProgram> : TAccountDelegationProgram, TAccountSystemProgram extends string ? ReadonlyAccount<TAccountSystemProgram> : TAccountSystemProgram, ...TRemainingAccounts]>;
20
+
21
+ export type DelegatePdaInstructionData = { discriminator: ReadonlyUint8Array; accountType: AccountType; };
22
+
23
+ export type DelegatePdaInstructionDataArgs = { accountType: AccountTypeArgs; };
24
+
25
+ export function getDelegatePdaInstructionDataEncoder(): Encoder<DelegatePdaInstructionDataArgs> {
26
+ return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['accountType', getAccountTypeEncoder()]]), (value) => ({ ...value, discriminator: DELEGATE_PDA_DISCRIMINATOR }));
27
+ }
28
+
29
+ export function getDelegatePdaInstructionDataDecoder(): Decoder<DelegatePdaInstructionData> {
30
+ return getStructDecoder([['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['accountType', getAccountTypeDecoder()]]);
31
+ }
32
+
33
+ export function getDelegatePdaInstructionDataCodec(): Codec<DelegatePdaInstructionDataArgs, DelegatePdaInstructionData> {
34
+ return combineCodec(getDelegatePdaInstructionDataEncoder(), getDelegatePdaInstructionDataDecoder());
35
+ }
36
+
37
+ export type DelegatePdaAsyncInput<TAccountBufferPda extends string = string, TAccountDelegationRecordPda extends string = string, TAccountDelegationMetadataPda extends string = string, TAccountPda extends string = string, TAccountPayer extends string = string, TAccountValidator extends string = string, TAccountOwnerProgram extends string = string, TAccountDelegationProgram extends string = string, TAccountSystemProgram extends string = string> = {
38
+ bufferPda?: Address<TAccountBufferPda>;
39
+ delegationRecordPda?: Address<TAccountDelegationRecordPda>;
40
+ delegationMetadataPda?: Address<TAccountDelegationMetadataPda>;
41
+ pda: Address<TAccountPda>;
42
+ payer: TransactionSigner<TAccountPayer>;
43
+ validator?: Address<TAccountValidator>;
44
+ ownerProgram?: Address<TAccountOwnerProgram>;
45
+ delegationProgram?: Address<TAccountDelegationProgram>;
46
+ systemProgram?: Address<TAccountSystemProgram>;
47
+ accountType: DelegatePdaInstructionDataArgs["accountType"];
48
+ }
49
+
50
+ export async function getDelegatePdaInstructionAsync<TAccountBufferPda extends string, TAccountDelegationRecordPda extends string, TAccountDelegationMetadataPda extends string, TAccountPda extends string, TAccountPayer extends string, TAccountValidator extends string, TAccountOwnerProgram extends string, TAccountDelegationProgram extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof RPS_GAME_PROGRAM_ADDRESS>(input: DelegatePdaAsyncInput<TAccountBufferPda, TAccountDelegationRecordPda, TAccountDelegationMetadataPda, TAccountPda, TAccountPayer, TAccountValidator, TAccountOwnerProgram, TAccountDelegationProgram, TAccountSystemProgram>, config?: { programAddress?: TProgramAddress } ): Promise<DelegatePdaInstruction<TProgramAddress, TAccountBufferPda, TAccountDelegationRecordPda, TAccountDelegationMetadataPda, TAccountPda, TAccountPayer, TAccountValidator, TAccountOwnerProgram, TAccountDelegationProgram, TAccountSystemProgram>> {
51
+ // Program address.
52
+ const programAddress = config?.programAddress ?? RPS_GAME_PROGRAM_ADDRESS;
53
+
54
+ // Original accounts.
55
+ const originalAccounts = { bufferPda: { value: input.bufferPda ?? null, isWritable: true }, delegationRecordPda: { value: input.delegationRecordPda ?? null, isWritable: true }, delegationMetadataPda: { value: input.delegationMetadataPda ?? null, isWritable: true }, pda: { value: input.pda ?? null, isWritable: true }, payer: { value: input.payer ?? null, isWritable: true }, validator: { value: input.validator ?? null, isWritable: false }, ownerProgram: { value: input.ownerProgram ?? null, isWritable: false }, delegationProgram: { value: input.delegationProgram ?? null, isWritable: false }, systemProgram: { value: input.systemProgram ?? null, isWritable: false } }
56
+ const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
57
+
58
+
59
+ // Original args.
60
+ const args = { ...input, };
61
+
62
+
63
+ // Resolve default values.
64
+ if (!accounts.bufferPda.value) {
65
+ accounts.bufferPda.value = await getProgramDerivedAddress({ programAddress: '8ohu3RobXyZ2DebyJjbs2co9YCG275FUsVckEcmDbCos' as Address<'8ohu3RobXyZ2DebyJjbs2co9YCG275FUsVckEcmDbCos'>, seeds: [getBytesEncoder().encode(new Uint8Array([98, 117, 102, 102, 101, 114])), getAddressEncoder().encode(getAddressFromResolvedInstructionAccount("pda", accounts.pda.value))] });
66
+ }
67
+ if (!accounts.delegationRecordPda.value) {
68
+ accounts.delegationRecordPda.value = await getProgramDerivedAddress({ programAddress: 'DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh' as Address<'DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh'>, seeds: [getBytesEncoder().encode(new Uint8Array([100, 101, 108, 101, 103, 97, 116, 105, 111, 110])), getAddressEncoder().encode(getAddressFromResolvedInstructionAccount("pda", accounts.pda.value))] });
69
+ }
70
+ if (!accounts.delegationMetadataPda.value) {
71
+ accounts.delegationMetadataPda.value = await getProgramDerivedAddress({ programAddress: 'DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh' as Address<'DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh'>, seeds: [getBytesEncoder().encode(new Uint8Array([100, 101, 108, 101, 103, 97, 116, 105, 111, 110, 45, 109, 101, 116, 97, 100, 97, 116, 97])), getAddressEncoder().encode(getAddressFromResolvedInstructionAccount("pda", accounts.pda.value))] });
72
+ }
73
+ if (!accounts.ownerProgram.value) {
74
+ accounts.ownerProgram.value = '8ohu3RobXyZ2DebyJjbs2co9YCG275FUsVckEcmDbCos' as Address<'8ohu3RobXyZ2DebyJjbs2co9YCG275FUsVckEcmDbCos'>;
75
+ }
76
+ if (!accounts.delegationProgram.value) {
77
+ accounts.delegationProgram.value = 'DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh' as Address<'DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh'>;
78
+ }
79
+ if (!accounts.systemProgram.value) {
80
+ accounts.systemProgram.value = '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>;
81
+ }
82
+
83
+ const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
84
+ return Object.freeze({ accounts: [getAccountMeta("bufferPda", accounts.bufferPda), getAccountMeta("delegationRecordPda", accounts.delegationRecordPda), getAccountMeta("delegationMetadataPda", accounts.delegationMetadataPda), getAccountMeta("pda", accounts.pda), getAccountMeta("payer", accounts.payer), getAccountMeta("validator", accounts.validator), getAccountMeta("ownerProgram", accounts.ownerProgram), getAccountMeta("delegationProgram", accounts.delegationProgram), getAccountMeta("systemProgram", accounts.systemProgram)], data: getDelegatePdaInstructionDataEncoder().encode(args as DelegatePdaInstructionDataArgs), programAddress } as DelegatePdaInstruction<TProgramAddress, TAccountBufferPda, TAccountDelegationRecordPda, TAccountDelegationMetadataPda, TAccountPda, TAccountPayer, TAccountValidator, TAccountOwnerProgram, TAccountDelegationProgram, TAccountSystemProgram>);
85
+ }
86
+
87
+ export type DelegatePdaInput<TAccountBufferPda extends string = string, TAccountDelegationRecordPda extends string = string, TAccountDelegationMetadataPda extends string = string, TAccountPda extends string = string, TAccountPayer extends string = string, TAccountValidator extends string = string, TAccountOwnerProgram extends string = string, TAccountDelegationProgram extends string = string, TAccountSystemProgram extends string = string> = {
88
+ bufferPda: Address<TAccountBufferPda>;
89
+ delegationRecordPda: Address<TAccountDelegationRecordPda>;
90
+ delegationMetadataPda: Address<TAccountDelegationMetadataPda>;
91
+ pda: Address<TAccountPda>;
92
+ payer: TransactionSigner<TAccountPayer>;
93
+ validator?: Address<TAccountValidator>;
94
+ ownerProgram?: Address<TAccountOwnerProgram>;
95
+ delegationProgram?: Address<TAccountDelegationProgram>;
96
+ systemProgram?: Address<TAccountSystemProgram>;
97
+ accountType: DelegatePdaInstructionDataArgs["accountType"];
98
+ }
99
+
100
+ export function getDelegatePdaInstruction<TAccountBufferPda extends string, TAccountDelegationRecordPda extends string, TAccountDelegationMetadataPda extends string, TAccountPda extends string, TAccountPayer extends string, TAccountValidator extends string, TAccountOwnerProgram extends string, TAccountDelegationProgram extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof RPS_GAME_PROGRAM_ADDRESS>(input: DelegatePdaInput<TAccountBufferPda, TAccountDelegationRecordPda, TAccountDelegationMetadataPda, TAccountPda, TAccountPayer, TAccountValidator, TAccountOwnerProgram, TAccountDelegationProgram, TAccountSystemProgram>, config?: { programAddress?: TProgramAddress } ): DelegatePdaInstruction<TProgramAddress, TAccountBufferPda, TAccountDelegationRecordPda, TAccountDelegationMetadataPda, TAccountPda, TAccountPayer, TAccountValidator, TAccountOwnerProgram, TAccountDelegationProgram, TAccountSystemProgram> {
101
+ // Program address.
102
+ const programAddress = config?.programAddress ?? RPS_GAME_PROGRAM_ADDRESS;
103
+
104
+ // Original accounts.
105
+ const originalAccounts = { bufferPda: { value: input.bufferPda ?? null, isWritable: true }, delegationRecordPda: { value: input.delegationRecordPda ?? null, isWritable: true }, delegationMetadataPda: { value: input.delegationMetadataPda ?? null, isWritable: true }, pda: { value: input.pda ?? null, isWritable: true }, payer: { value: input.payer ?? null, isWritable: true }, validator: { value: input.validator ?? null, isWritable: false }, ownerProgram: { value: input.ownerProgram ?? null, isWritable: false }, delegationProgram: { value: input.delegationProgram ?? null, isWritable: false }, systemProgram: { value: input.systemProgram ?? null, isWritable: false } }
106
+ const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
107
+
108
+
109
+ // Original args.
110
+ const args = { ...input, };
111
+
112
+
113
+ // Resolve default values.
114
+ if (!accounts.ownerProgram.value) {
115
+ accounts.ownerProgram.value = '8ohu3RobXyZ2DebyJjbs2co9YCG275FUsVckEcmDbCos' as Address<'8ohu3RobXyZ2DebyJjbs2co9YCG275FUsVckEcmDbCos'>;
116
+ }
117
+ if (!accounts.delegationProgram.value) {
118
+ accounts.delegationProgram.value = 'DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh' as Address<'DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh'>;
119
+ }
120
+ if (!accounts.systemProgram.value) {
121
+ accounts.systemProgram.value = '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>;
122
+ }
123
+
124
+ const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
125
+ return Object.freeze({ accounts: [getAccountMeta("bufferPda", accounts.bufferPda), getAccountMeta("delegationRecordPda", accounts.delegationRecordPda), getAccountMeta("delegationMetadataPda", accounts.delegationMetadataPda), getAccountMeta("pda", accounts.pda), getAccountMeta("payer", accounts.payer), getAccountMeta("validator", accounts.validator), getAccountMeta("ownerProgram", accounts.ownerProgram), getAccountMeta("delegationProgram", accounts.delegationProgram), getAccountMeta("systemProgram", accounts.systemProgram)], data: getDelegatePdaInstructionDataEncoder().encode(args as DelegatePdaInstructionDataArgs), programAddress } as DelegatePdaInstruction<TProgramAddress, TAccountBufferPda, TAccountDelegationRecordPda, TAccountDelegationMetadataPda, TAccountPda, TAccountPayer, TAccountValidator, TAccountOwnerProgram, TAccountDelegationProgram, TAccountSystemProgram>);
126
+ }
127
+
128
+ export type ParsedDelegatePdaInstruction<TProgram extends string = typeof RPS_GAME_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = { programAddress: Address<TProgram>;
129
+ accounts: {
130
+ bufferPda: TAccountMetas[0];
131
+ delegationRecordPda: TAccountMetas[1];
132
+ delegationMetadataPda: TAccountMetas[2];
133
+ pda: TAccountMetas[3];
134
+ payer: TAccountMetas[4];
135
+ validator?: TAccountMetas[5] | undefined;
136
+ ownerProgram: TAccountMetas[6];
137
+ delegationProgram: TAccountMetas[7];
138
+ systemProgram: TAccountMetas[8];
139
+ };
140
+ data: DelegatePdaInstructionData; };
141
+
142
+ export function parseDelegatePdaInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedDelegatePdaInstruction<TProgram, TAccountMetas> {
143
+ if (instruction.accounts.length < 9) {
144
+ throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 9 });
145
+ }
146
+ let accountIndex = 0;
147
+ const getNextAccount = () => {
148
+ const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
149
+ accountIndex += 1;
150
+ return accountMeta;
151
+ }
152
+ const getNextOptionalAccount = () => {
153
+ const accountMeta = getNextAccount();
154
+ return accountMeta.address === RPS_GAME_PROGRAM_ADDRESS ? undefined : accountMeta;
155
+ };
156
+ return { programAddress: instruction.programAddress, accounts: { bufferPda: getNextAccount(), delegationRecordPda: getNextAccount(), delegationMetadataPda: getNextAccount(), pda: getNextAccount(), payer: getNextAccount(), validator: getNextOptionalAccount(), ownerProgram: getNextAccount(), delegationProgram: getNextAccount(), systemProgram: getNextAccount() }, data: getDelegatePdaInstructionDataDecoder().decode(instruction.data) };
157
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+
9
+ export * from './closePlayer';
10
+ export * from './delegatePda';
11
+ export * from './initializePlayer';
12
+ export * from './makeChoice';
13
+ export * from './onMatchFound';
14
+ export * from './persistResults';
15
+ export * from './processUndelegation';
16
+ export * from './startGame';
17
+ export * from './startGameWithTicket';