@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.
- package/dist/admin.d.ts +20 -42
- package/dist/admin.js +82 -117
- package/dist/encryption.js +1 -2
- package/dist/generated/duel/accounts/index.d.ts +10 -0
- package/dist/generated/duel/accounts/index.js +11 -0
- package/dist/generated/duel/accounts/matchTicket.d.ts +38 -0
- package/dist/generated/duel/accounts/matchTicket.js +45 -0
- package/dist/generated/duel/accounts/queue.d.ts +42 -0
- package/dist/generated/duel/accounts/queue.js +45 -0
- package/dist/generated/duel/accounts/tenant.d.ts +41 -0
- package/dist/generated/duel/accounts/tenant.js +44 -0
- package/dist/generated/duel/errors/duel.d.ts +33 -0
- package/dist/generated/duel/errors/duel.js +37 -0
- package/dist/generated/duel/errors/index.d.ts +8 -0
- package/dist/generated/duel/errors/index.js +9 -0
- package/dist/generated/duel/index.d.ts +12 -0
- package/dist/generated/duel/index.js +13 -0
- package/dist/generated/duel/instructions/cancelTicket.d.ts +45 -0
- package/dist/generated/duel/instructions/cancelTicket.js +56 -0
- package/dist/generated/duel/instructions/closeTicket.d.ts +45 -0
- package/dist/generated/duel/instructions/closeTicket.js +56 -0
- package/dist/generated/duel/instructions/commitTickets.d.ts +39 -0
- package/dist/generated/duel/instructions/commitTickets.js +50 -0
- package/dist/generated/duel/instructions/createTicket.d.ts +48 -0
- package/dist/generated/duel/instructions/createTicket.js +63 -0
- package/dist/generated/duel/instructions/delegateQueue.d.ts +69 -0
- package/dist/generated/duel/instructions/delegateQueue.js +90 -0
- package/dist/generated/duel/instructions/delegateTicket.d.ts +69 -0
- package/dist/generated/duel/instructions/delegateTicket.js +90 -0
- package/dist/generated/duel/instructions/flushMatches.d.ts +37 -0
- package/dist/generated/duel/instructions/flushMatches.js +43 -0
- package/dist/generated/duel/instructions/index.d.ts +18 -0
- package/dist/generated/duel/instructions/index.js +19 -0
- package/dist/generated/duel/instructions/initializeQueue.d.ts +48 -0
- package/dist/generated/duel/instructions/initializeQueue.js +63 -0
- package/dist/generated/duel/instructions/initializeTenant.d.ts +70 -0
- package/dist/generated/duel/instructions/initializeTenant.js +67 -0
- package/dist/generated/duel/instructions/joinQueue.d.ts +51 -0
- package/dist/generated/duel/instructions/joinQueue.js +56 -0
- package/dist/generated/duel/instructions/processUndelegation.d.ts +43 -0
- package/dist/generated/duel/instructions/processUndelegation.js +49 -0
- package/dist/generated/duel/programs/duel.d.ts +88 -0
- package/dist/generated/duel/programs/duel.js +138 -0
- package/dist/generated/duel/programs/index.d.ts +8 -0
- package/dist/generated/duel/programs/index.js +9 -0
- package/dist/generated/duel/types/accountType.d.ts +25 -0
- package/dist/generated/duel/types/accountType.js +25 -0
- package/dist/generated/duel/types/index.d.ts +13 -0
- package/dist/generated/duel/types/index.js +14 -0
- package/dist/generated/duel/types/matchEntry.d.ts +23 -0
- package/dist/generated/duel/types/matchEntry.js +18 -0
- package/dist/generated/duel/types/matchFound.d.ts +23 -0
- package/dist/generated/duel/types/matchFound.js +18 -0
- package/dist/generated/duel/types/pendingMatch.d.ts +21 -0
- package/dist/generated/duel/types/pendingMatch.js +18 -0
- package/dist/generated/duel/types/queueEntry.d.ts +19 -0
- package/dist/generated/duel/types/queueEntry.js +18 -0
- package/dist/generated/duel/types/ticketStatus.d.ts +40 -0
- package/dist/generated/duel/types/ticketStatus.js +25 -0
- package/dist/generated/rps-game/accounts/gameSession.d.ts +40 -0
- package/dist/generated/rps-game/accounts/gameSession.js +45 -0
- package/dist/generated/rps-game/accounts/index.d.ts +9 -0
- package/dist/generated/rps-game/accounts/index.js +10 -0
- package/dist/generated/rps-game/accounts/playerProfile.d.ts +36 -0
- package/dist/generated/rps-game/accounts/playerProfile.js +47 -0
- package/dist/generated/rps-game/errors/index.d.ts +8 -0
- package/dist/generated/rps-game/errors/index.js +9 -0
- package/dist/generated/rps-game/errors/rpsGame.d.ts +25 -0
- package/dist/generated/rps-game/errors/rpsGame.js +29 -0
- package/dist/generated/rps-game/index.d.ts +12 -0
- package/dist/generated/rps-game/index.js +13 -0
- package/dist/generated/rps-game/instructions/closePlayer.d.ts +45 -0
- package/dist/generated/rps-game/instructions/closePlayer.js +56 -0
- package/dist/generated/rps-game/instructions/delegatePda.d.ts +69 -0
- package/dist/generated/rps-game/instructions/delegatePda.js +90 -0
- package/dist/generated/rps-game/instructions/index.d.ts +16 -0
- package/dist/generated/rps-game/instructions/index.js +17 -0
- package/dist/generated/rps-game/instructions/initializePlayer.d.ts +48 -0
- package/dist/generated/rps-game/instructions/initializePlayer.js +63 -0
- package/dist/generated/rps-game/instructions/makeChoice.d.ts +44 -0
- package/dist/generated/rps-game/instructions/makeChoice.js +46 -0
- package/dist/generated/rps-game/instructions/onMatchFound.d.ts +43 -0
- package/dist/generated/rps-game/instructions/onMatchFound.js +45 -0
- package/dist/generated/rps-game/instructions/persistResults.d.ts +43 -0
- package/dist/generated/rps-game/instructions/persistResults.js +50 -0
- package/dist/generated/rps-game/instructions/processUndelegation.d.ts +43 -0
- package/dist/generated/rps-game/instructions/processUndelegation.js +49 -0
- package/dist/generated/rps-game/instructions/startGame.d.ts +54 -0
- package/dist/generated/rps-game/instructions/startGame.js +67 -0
- package/dist/generated/rps-game/instructions/startGameWithTicket.d.ts +57 -0
- package/dist/generated/rps-game/instructions/startGameWithTicket.js +67 -0
- package/dist/generated/rps-game/programs/index.d.ts +8 -0
- package/dist/generated/rps-game/programs/index.js +9 -0
- package/dist/generated/rps-game/programs/rpsGame.d.ts +78 -0
- package/dist/generated/rps-game/programs/rpsGame.js +118 -0
- package/dist/generated/rps-game/types/accountType.d.ts +34 -0
- package/dist/generated/rps-game/types/accountType.js +25 -0
- package/dist/generated/rps-game/types/choice.d.ts +17 -0
- package/dist/generated/rps-game/types/choice.js +25 -0
- package/dist/generated/rps-game/types/gameResult.d.ts +26 -0
- package/dist/generated/rps-game/types/gameResult.js +25 -0
- package/dist/generated/rps-game/types/index.d.ts +10 -0
- package/dist/generated/rps-game/types/index.js +11 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -2
- package/dist/player.d.ts +21 -48
- package/dist/player.js +61 -140
- package/dist/tee.d.ts +14 -0
- package/dist/tee.js +62 -0
- package/dist/transaction.d.ts +11 -0
- package/dist/transaction.js +50 -0
- package/dist/utils.d.ts +4 -4
- package/dist/utils.js +23 -8
- package/package.json +3 -6
- package/src/admin.ts +129 -163
- package/src/duel.json +66 -2
- package/src/encryption.ts +0 -3
- package/src/generated/duel/accounts/index.ts +11 -0
- package/src/generated/duel/accounts/matchTicket.ts +77 -0
- package/src/generated/duel/accounts/queue.ts +77 -0
- package/src/generated/duel/accounts/tenant.ts +76 -0
- package/src/generated/duel/errors/duel.ts +48 -0
- package/src/generated/duel/errors/index.ts +9 -0
- package/src/generated/duel/index.ts +13 -0
- package/src/generated/duel/instructions/cancelTicket.ts +100 -0
- package/src/generated/duel/instructions/closeTicket.ts +100 -0
- package/src/generated/duel/instructions/commitTickets.ts +84 -0
- package/src/generated/duel/instructions/createTicket.ts +109 -0
- package/src/generated/duel/instructions/delegateQueue.ts +157 -0
- package/src/generated/duel/instructions/delegateTicket.ts +157 -0
- package/src/generated/duel/instructions/flushMatches.ts +76 -0
- package/src/generated/duel/instructions/index.ts +19 -0
- package/src/generated/duel/instructions/initializeQueue.ts +109 -0
- package/src/generated/duel/instructions/initializeTenant.ts +126 -0
- package/src/generated/duel/instructions/joinQueue.ts +106 -0
- package/src/generated/duel/instructions/processUndelegation.ts +86 -0
- package/src/generated/duel/programs/duel.ts +104 -0
- package/src/generated/duel/programs/index.ts +9 -0
- package/src/generated/duel/types/accountType.ts +36 -0
- package/src/generated/duel/types/index.ts +14 -0
- package/src/generated/duel/types/matchEntry.ts +25 -0
- package/src/generated/duel/types/matchFound.ts +25 -0
- package/src/generated/duel/types/pendingMatch.ts +25 -0
- package/src/generated/duel/types/queueEntry.ts +25 -0
- package/src/generated/duel/types/ticketStatus.ts +38 -0
- package/src/generated/rps-game/accounts/gameSession.ts +77 -0
- package/src/generated/rps-game/accounts/index.ts +10 -0
- package/src/generated/rps-game/accounts/playerProfile.ts +80 -0
- package/src/generated/rps-game/errors/index.ts +9 -0
- package/src/generated/rps-game/errors/rpsGame.ts +40 -0
- package/src/generated/rps-game/index.ts +13 -0
- package/src/generated/rps-game/instructions/closePlayer.ts +100 -0
- package/src/generated/rps-game/instructions/delegatePda.ts +157 -0
- package/src/generated/rps-game/instructions/index.ts +17 -0
- package/src/generated/rps-game/instructions/initializePlayer.ts +109 -0
- package/src/generated/rps-game/instructions/makeChoice.ts +84 -0
- package/src/generated/rps-game/instructions/onMatchFound.ts +79 -0
- package/src/generated/rps-game/instructions/persistResults.ts +88 -0
- package/src/generated/rps-game/instructions/processUndelegation.ts +86 -0
- package/src/generated/rps-game/instructions/startGame.ts +118 -0
- package/src/generated/rps-game/instructions/startGameWithTicket.ts +121 -0
- package/src/generated/rps-game/programs/index.ts +9 -0
- package/src/generated/rps-game/programs/rpsGame.ts +95 -0
- package/src/generated/rps-game/types/accountType.ts +36 -0
- package/src/generated/rps-game/types/choice.ts +25 -0
- package/src/generated/rps-game/types/gameResult.ts +37 -0
- package/src/generated/rps-game/types/index.ts +11 -0
- package/src/index.ts +2 -1
- package/src/player.ts +96 -192
- package/src/rps_game.json +991 -0
- package/src/tee.ts +79 -0
- package/src/transaction.ts +90 -0
- package/src/utils.ts +35 -20
- package/tsconfig.json +2 -2
- package/dist/client.d.ts +0 -54
- package/dist/client.js +0 -265
- package/dist/duel.json +0 -1207
- package/dist/private_matchmaking.json +0 -534
- package/dist/types.d.ts +0 -635
- package/dist/types.js +0 -2
- package/src/types.ts +0 -300
|
@@ -0,0 +1,121 @@
|
|
|
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, getProgramDerivedAddress, getStructDecoder, getStructEncoder, getU64Decoder, getU64Encoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, transformEncoder, type AccountMeta, type AccountSignerMeta, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, type WritableSignerAccount } from '@solana/kit';
|
|
10
|
+
import { getAccountMetaFactory, getAddressFromResolvedInstructionAccount, getNonNullResolvedInstructionInput, type ResolvedInstructionAccount } from '@solana/program-client-core';
|
|
11
|
+
import { RPS_GAME_PROGRAM_ADDRESS } from '../programs';
|
|
12
|
+
|
|
13
|
+
export const START_GAME_WITH_TICKET_DISCRIMINATOR = new Uint8Array([2, 250, 253, 202, 51, 138, 80, 20]);
|
|
14
|
+
|
|
15
|
+
export function getStartGameWithTicketDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(START_GAME_WITH_TICKET_DISCRIMINATOR); }
|
|
16
|
+
|
|
17
|
+
export type StartGameWithTicketInstruction<TProgram extends string = typeof RPS_GAME_PROGRAM_ADDRESS, TAccountGameSession extends string | AccountMeta<string> = string, TAccountPlayer extends string | AccountMeta<string> = string, TAccountMatchTicket extends string | AccountMeta<string> = string, TAccountSystemProgram extends string | AccountMeta<string> = "11111111111111111111111111111111", TRemainingAccounts extends readonly AccountMeta<string>[] = []> =
|
|
18
|
+
Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[TAccountGameSession extends string ? WritableAccount<TAccountGameSession> : TAccountGameSession, TAccountPlayer extends string ? WritableSignerAccount<TAccountPlayer> & AccountSignerMeta<TAccountPlayer> : TAccountPlayer, TAccountMatchTicket extends string ? ReadonlyAccount<TAccountMatchTicket> : TAccountMatchTicket, TAccountSystemProgram extends string ? ReadonlyAccount<TAccountSystemProgram> : TAccountSystemProgram, ...TRemainingAccounts]>;
|
|
19
|
+
|
|
20
|
+
export type StartGameWithTicketInstructionData = { discriminator: ReadonlyUint8Array; gameId: bigint; opponent: Address; };
|
|
21
|
+
|
|
22
|
+
export type StartGameWithTicketInstructionDataArgs = { gameId: number | bigint; opponent: Address; };
|
|
23
|
+
|
|
24
|
+
export function getStartGameWithTicketInstructionDataEncoder(): FixedSizeEncoder<StartGameWithTicketInstructionDataArgs> {
|
|
25
|
+
return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['gameId', getU64Encoder()], ['opponent', getAddressEncoder()]]), (value) => ({ ...value, discriminator: START_GAME_WITH_TICKET_DISCRIMINATOR }));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getStartGameWithTicketInstructionDataDecoder(): FixedSizeDecoder<StartGameWithTicketInstructionData> {
|
|
29
|
+
return getStructDecoder([['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['gameId', getU64Decoder()], ['opponent', getAddressDecoder()]]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function getStartGameWithTicketInstructionDataCodec(): FixedSizeCodec<StartGameWithTicketInstructionDataArgs, StartGameWithTicketInstructionData> {
|
|
33
|
+
return combineCodec(getStartGameWithTicketInstructionDataEncoder(), getStartGameWithTicketInstructionDataDecoder());
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type StartGameWithTicketAsyncInput<TAccountGameSession extends string = string, TAccountPlayer extends string = string, TAccountMatchTicket extends string = string, TAccountSystemProgram extends string = string> = {
|
|
37
|
+
gameSession?: Address<TAccountGameSession>;
|
|
38
|
+
player: TransactionSigner<TAccountPlayer>;
|
|
39
|
+
matchTicket: Address<TAccountMatchTicket>;
|
|
40
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
41
|
+
gameId: StartGameWithTicketInstructionDataArgs["gameId"];
|
|
42
|
+
opponent: StartGameWithTicketInstructionDataArgs["opponent"];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function getStartGameWithTicketInstructionAsync<TAccountGameSession extends string, TAccountPlayer extends string, TAccountMatchTicket extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof RPS_GAME_PROGRAM_ADDRESS>(input: StartGameWithTicketAsyncInput<TAccountGameSession, TAccountPlayer, TAccountMatchTicket, TAccountSystemProgram>, config?: { programAddress?: TProgramAddress } ): Promise<StartGameWithTicketInstruction<TProgramAddress, TAccountGameSession, TAccountPlayer, TAccountMatchTicket, TAccountSystemProgram>> {
|
|
46
|
+
// Program address.
|
|
47
|
+
const programAddress = config?.programAddress ?? RPS_GAME_PROGRAM_ADDRESS;
|
|
48
|
+
|
|
49
|
+
// Original accounts.
|
|
50
|
+
const originalAccounts = { gameSession: { value: input.gameSession ?? null, isWritable: true }, player: { value: input.player ?? null, isWritable: true }, matchTicket: { value: input.matchTicket ?? null, isWritable: false }, systemProgram: { value: input.systemProgram ?? null, isWritable: false } }
|
|
51
|
+
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
// Original args.
|
|
55
|
+
const args = { ...input, };
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
// Resolve default values.
|
|
59
|
+
if (!accounts.gameSession.value) {
|
|
60
|
+
accounts.gameSession.value = await getProgramDerivedAddress({ programAddress, seeds: [getBytesEncoder().encode(new Uint8Array([103, 97, 109, 101, 95, 115, 101, 115, 115, 105, 111, 110, 95, 118, 49])), getAddressEncoder().encode(getAddressFromResolvedInstructionAccount("player", accounts.player.value)), getAddressEncoder().encode(getNonNullResolvedInstructionInput("opponent", args.opponent)), getU64Encoder().encode(getNonNullResolvedInstructionInput("gameId", args.gameId))] });
|
|
61
|
+
}
|
|
62
|
+
if (!accounts.systemProgram.value) {
|
|
63
|
+
accounts.systemProgram.value = '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
67
|
+
return Object.freeze({ accounts: [getAccountMeta("gameSession", accounts.gameSession), getAccountMeta("player", accounts.player), getAccountMeta("matchTicket", accounts.matchTicket), getAccountMeta("systemProgram", accounts.systemProgram)], data: getStartGameWithTicketInstructionDataEncoder().encode(args as StartGameWithTicketInstructionDataArgs), programAddress } as StartGameWithTicketInstruction<TProgramAddress, TAccountGameSession, TAccountPlayer, TAccountMatchTicket, TAccountSystemProgram>);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export type StartGameWithTicketInput<TAccountGameSession extends string = string, TAccountPlayer extends string = string, TAccountMatchTicket extends string = string, TAccountSystemProgram extends string = string> = {
|
|
71
|
+
gameSession: Address<TAccountGameSession>;
|
|
72
|
+
player: TransactionSigner<TAccountPlayer>;
|
|
73
|
+
matchTicket: Address<TAccountMatchTicket>;
|
|
74
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
75
|
+
gameId: StartGameWithTicketInstructionDataArgs["gameId"];
|
|
76
|
+
opponent: StartGameWithTicketInstructionDataArgs["opponent"];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function getStartGameWithTicketInstruction<TAccountGameSession extends string, TAccountPlayer extends string, TAccountMatchTicket extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof RPS_GAME_PROGRAM_ADDRESS>(input: StartGameWithTicketInput<TAccountGameSession, TAccountPlayer, TAccountMatchTicket, TAccountSystemProgram>, config?: { programAddress?: TProgramAddress } ): StartGameWithTicketInstruction<TProgramAddress, TAccountGameSession, TAccountPlayer, TAccountMatchTicket, TAccountSystemProgram> {
|
|
80
|
+
// Program address.
|
|
81
|
+
const programAddress = config?.programAddress ?? RPS_GAME_PROGRAM_ADDRESS;
|
|
82
|
+
|
|
83
|
+
// Original accounts.
|
|
84
|
+
const originalAccounts = { gameSession: { value: input.gameSession ?? null, isWritable: true }, player: { value: input.player ?? null, isWritable: true }, matchTicket: { value: input.matchTicket ?? null, isWritable: false }, systemProgram: { value: input.systemProgram ?? null, isWritable: false } }
|
|
85
|
+
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
// Original args.
|
|
89
|
+
const args = { ...input, };
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
// Resolve default values.
|
|
93
|
+
if (!accounts.systemProgram.value) {
|
|
94
|
+
accounts.systemProgram.value = '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
98
|
+
return Object.freeze({ accounts: [getAccountMeta("gameSession", accounts.gameSession), getAccountMeta("player", accounts.player), getAccountMeta("matchTicket", accounts.matchTicket), getAccountMeta("systemProgram", accounts.systemProgram)], data: getStartGameWithTicketInstructionDataEncoder().encode(args as StartGameWithTicketInstructionDataArgs), programAddress } as StartGameWithTicketInstruction<TProgramAddress, TAccountGameSession, TAccountPlayer, TAccountMatchTicket, TAccountSystemProgram>);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export type ParsedStartGameWithTicketInstruction<TProgram extends string = typeof RPS_GAME_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = { programAddress: Address<TProgram>;
|
|
102
|
+
accounts: {
|
|
103
|
+
gameSession: TAccountMetas[0];
|
|
104
|
+
player: TAccountMetas[1];
|
|
105
|
+
matchTicket: TAccountMetas[2];
|
|
106
|
+
systemProgram: TAccountMetas[3];
|
|
107
|
+
};
|
|
108
|
+
data: StartGameWithTicketInstructionData; };
|
|
109
|
+
|
|
110
|
+
export function parseStartGameWithTicketInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedStartGameWithTicketInstruction<TProgram, TAccountMetas> {
|
|
111
|
+
if (instruction.accounts.length < 4) {
|
|
112
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 4 });
|
|
113
|
+
}
|
|
114
|
+
let accountIndex = 0;
|
|
115
|
+
const getNextAccount = () => {
|
|
116
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
117
|
+
accountIndex += 1;
|
|
118
|
+
return accountMeta;
|
|
119
|
+
}
|
|
120
|
+
return { programAddress: instruction.programAddress, accounts: { gameSession: getNextAccount(), player: getNextAccount(), matchTicket: getNextAccount(), systemProgram: getNextAccount() }, data: getStartGameWithTicketInstructionDataDecoder().decode(instruction.data) };
|
|
121
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { assertIsInstructionWithAccounts, containsBytes, fixEncoderSize, getBytesEncoder, SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT, SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, SolanaError, type Address, type ClientWithPayer, type ClientWithRpc, type ClientWithTransactionPlanning, type ClientWithTransactionSending, type GetAccountInfoApi, type GetMultipleAccountsApi, type Instruction, type InstructionWithData, type ReadonlyUint8Array } from '@solana/kit';
|
|
10
|
+
import { addSelfFetchFunctions, addSelfPlanAndSendFunctions, type SelfFetchFunctions, type SelfPlanAndSendFunctions } from '@solana/program-client-core';
|
|
11
|
+
import { getGameSessionCodec, getPlayerProfileCodec, type GameSession, type GameSessionArgs, type PlayerProfile, type PlayerProfileArgs } from '../accounts';
|
|
12
|
+
import { getClosePlayerInstructionAsync, getDelegatePdaInstructionAsync, getInitializePlayerInstructionAsync, getMakeChoiceInstruction, getOnMatchFoundInstruction, getPersistResultsInstruction, getProcessUndelegationInstruction, getStartGameInstructionAsync, getStartGameWithTicketInstructionAsync, parseClosePlayerInstruction, parseDelegatePdaInstruction, parseInitializePlayerInstruction, parseMakeChoiceInstruction, parseOnMatchFoundInstruction, parsePersistResultsInstruction, parseProcessUndelegationInstruction, parseStartGameInstruction, parseStartGameWithTicketInstruction, type ClosePlayerAsyncInput, type DelegatePdaAsyncInput, type InitializePlayerAsyncInput, type MakeChoiceInput, type OnMatchFoundInput, type ParsedClosePlayerInstruction, type ParsedDelegatePdaInstruction, type ParsedInitializePlayerInstruction, type ParsedMakeChoiceInstruction, type ParsedOnMatchFoundInstruction, type ParsedPersistResultsInstruction, type ParsedProcessUndelegationInstruction, type ParsedStartGameInstruction, type ParsedStartGameWithTicketInstruction, type PersistResultsInput, type ProcessUndelegationInput, type StartGameAsyncInput, type StartGameWithTicketAsyncInput } from '../instructions';
|
|
13
|
+
|
|
14
|
+
export const RPS_GAME_PROGRAM_ADDRESS = '8ohu3RobXyZ2DebyJjbs2co9YCG275FUsVckEcmDbCos' as Address<'8ohu3RobXyZ2DebyJjbs2co9YCG275FUsVckEcmDbCos'>;
|
|
15
|
+
|
|
16
|
+
export enum RpsGameAccount { GameSession, PlayerProfile }
|
|
17
|
+
|
|
18
|
+
export function identifyRpsGameAccount(account: { data: ReadonlyUint8Array } | ReadonlyUint8Array): RpsGameAccount {
|
|
19
|
+
const data = 'data' in account ? account.data : account;
|
|
20
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([150, 116, 20, 197, 205, 121, 220, 240])), 0)) { return RpsGameAccount.GameSession; }
|
|
21
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([82, 226, 99, 87, 164, 130, 181, 80])), 0)) { return RpsGameAccount.PlayerProfile; }
|
|
22
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT, { accountData: data, programName: "rpsGame" });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export enum RpsGameInstruction { ClosePlayer, DelegatePda, InitializePlayer, MakeChoice, OnMatchFound, PersistResults, ProcessUndelegation, StartGame, StartGameWithTicket }
|
|
26
|
+
|
|
27
|
+
export function identifyRpsGameInstruction(instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array): RpsGameInstruction {
|
|
28
|
+
const data = 'data' in instruction ? instruction.data : instruction;
|
|
29
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([225, 227, 204, 63, 32, 122, 58, 227])), 0)) { return RpsGameInstruction.ClosePlayer; }
|
|
30
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([248, 217, 193, 46, 124, 191, 64, 135])), 0)) { return RpsGameInstruction.DelegatePda; }
|
|
31
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([79, 249, 88, 177, 220, 62, 56, 128])), 0)) { return RpsGameInstruction.InitializePlayer; }
|
|
32
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([207, 18, 251, 32, 135, 122, 160, 77])), 0)) { return RpsGameInstruction.MakeChoice; }
|
|
33
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([66, 209, 170, 159, 10, 195, 34, 214])), 0)) { return RpsGameInstruction.OnMatchFound; }
|
|
34
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([9, 175, 42, 217, 2, 48, 80, 81])), 0)) { return RpsGameInstruction.PersistResults; }
|
|
35
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([196, 28, 41, 206, 48, 37, 51, 167])), 0)) { return RpsGameInstruction.ProcessUndelegation; }
|
|
36
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([249, 47, 252, 172, 184, 162, 245, 14])), 0)) { return RpsGameInstruction.StartGame; }
|
|
37
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([2, 250, 253, 202, 51, 138, 80, 20])), 0)) { return RpsGameInstruction.StartGameWithTicket; }
|
|
38
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, { instructionData: data, programName: "rpsGame" });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type ParsedRpsGameInstruction<TProgram extends string = '8ohu3RobXyZ2DebyJjbs2co9YCG275FUsVckEcmDbCos'> =
|
|
42
|
+
| { instructionType: RpsGameInstruction.ClosePlayer } & ParsedClosePlayerInstruction<TProgram>
|
|
43
|
+
| { instructionType: RpsGameInstruction.DelegatePda } & ParsedDelegatePdaInstruction<TProgram>
|
|
44
|
+
| { instructionType: RpsGameInstruction.InitializePlayer } & ParsedInitializePlayerInstruction<TProgram>
|
|
45
|
+
| { instructionType: RpsGameInstruction.MakeChoice } & ParsedMakeChoiceInstruction<TProgram>
|
|
46
|
+
| { instructionType: RpsGameInstruction.OnMatchFound } & ParsedOnMatchFoundInstruction<TProgram>
|
|
47
|
+
| { instructionType: RpsGameInstruction.PersistResults } & ParsedPersistResultsInstruction<TProgram>
|
|
48
|
+
| { instructionType: RpsGameInstruction.ProcessUndelegation } & ParsedProcessUndelegationInstruction<TProgram>
|
|
49
|
+
| { instructionType: RpsGameInstruction.StartGame } & ParsedStartGameInstruction<TProgram>
|
|
50
|
+
| { instructionType: RpsGameInstruction.StartGameWithTicket } & ParsedStartGameWithTicketInstruction<TProgram>
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
export function parseRpsGameInstruction<TProgram extends string>(
|
|
54
|
+
instruction: Instruction<TProgram>
|
|
55
|
+
& InstructionWithData<ReadonlyUint8Array>
|
|
56
|
+
): ParsedRpsGameInstruction<TProgram> {
|
|
57
|
+
const instructionType = identifyRpsGameInstruction(instruction);
|
|
58
|
+
switch (instructionType) {
|
|
59
|
+
case RpsGameInstruction.ClosePlayer: { assertIsInstructionWithAccounts(instruction);
|
|
60
|
+
return { instructionType: RpsGameInstruction.ClosePlayer, ...parseClosePlayerInstruction(instruction) }; }
|
|
61
|
+
case RpsGameInstruction.DelegatePda: { assertIsInstructionWithAccounts(instruction);
|
|
62
|
+
return { instructionType: RpsGameInstruction.DelegatePda, ...parseDelegatePdaInstruction(instruction) }; }
|
|
63
|
+
case RpsGameInstruction.InitializePlayer: { assertIsInstructionWithAccounts(instruction);
|
|
64
|
+
return { instructionType: RpsGameInstruction.InitializePlayer, ...parseInitializePlayerInstruction(instruction) }; }
|
|
65
|
+
case RpsGameInstruction.MakeChoice: { assertIsInstructionWithAccounts(instruction);
|
|
66
|
+
return { instructionType: RpsGameInstruction.MakeChoice, ...parseMakeChoiceInstruction(instruction) }; }
|
|
67
|
+
case RpsGameInstruction.OnMatchFound: { assertIsInstructionWithAccounts(instruction);
|
|
68
|
+
return { instructionType: RpsGameInstruction.OnMatchFound, ...parseOnMatchFoundInstruction(instruction) }; }
|
|
69
|
+
case RpsGameInstruction.PersistResults: { assertIsInstructionWithAccounts(instruction);
|
|
70
|
+
return { instructionType: RpsGameInstruction.PersistResults, ...parsePersistResultsInstruction(instruction) }; }
|
|
71
|
+
case RpsGameInstruction.ProcessUndelegation: { assertIsInstructionWithAccounts(instruction);
|
|
72
|
+
return { instructionType: RpsGameInstruction.ProcessUndelegation, ...parseProcessUndelegationInstruction(instruction) }; }
|
|
73
|
+
case RpsGameInstruction.StartGame: { assertIsInstructionWithAccounts(instruction);
|
|
74
|
+
return { instructionType: RpsGameInstruction.StartGame, ...parseStartGameInstruction(instruction) }; }
|
|
75
|
+
case RpsGameInstruction.StartGameWithTicket: { assertIsInstructionWithAccounts(instruction);
|
|
76
|
+
return { instructionType: RpsGameInstruction.StartGameWithTicket, ...parseStartGameWithTicketInstruction(instruction) }; }
|
|
77
|
+
default: throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, { instructionType: instructionType as string, programName: "rpsGame" });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export type RpsGamePlugin = { accounts: RpsGamePluginAccounts; instructions: RpsGamePluginInstructions; }
|
|
82
|
+
|
|
83
|
+
export type RpsGamePluginAccounts = { gameSession: ReturnType<typeof getGameSessionCodec> & SelfFetchFunctions<GameSessionArgs, GameSession>; playerProfile: ReturnType<typeof getPlayerProfileCodec> & SelfFetchFunctions<PlayerProfileArgs, PlayerProfile>; }
|
|
84
|
+
|
|
85
|
+
export type RpsGamePluginInstructions = { closePlayer: (input: MakeOptional<ClosePlayerAsyncInput, "payer">) => ReturnType<typeof getClosePlayerInstructionAsync> & SelfPlanAndSendFunctions; delegatePda: (input: MakeOptional<DelegatePdaAsyncInput, "payer">) => ReturnType<typeof getDelegatePdaInstructionAsync> & SelfPlanAndSendFunctions; initializePlayer: (input: MakeOptional<InitializePlayerAsyncInput, "payer">) => ReturnType<typeof getInitializePlayerInstructionAsync> & SelfPlanAndSendFunctions; makeChoice: (input: MakeChoiceInput) => ReturnType<typeof getMakeChoiceInstruction> & SelfPlanAndSendFunctions; onMatchFound: (input: OnMatchFoundInput) => ReturnType<typeof getOnMatchFoundInstruction> & SelfPlanAndSendFunctions; persistResults: (input: MakeOptional<PersistResultsInput, "payer">) => ReturnType<typeof getPersistResultsInstruction> & SelfPlanAndSendFunctions; processUndelegation: (input: MakeOptional<ProcessUndelegationInput, "payer">) => ReturnType<typeof getProcessUndelegationInstruction> & SelfPlanAndSendFunctions; startGame: (input: StartGameAsyncInput) => ReturnType<typeof getStartGameInstructionAsync> & SelfPlanAndSendFunctions; startGameWithTicket: (input: StartGameWithTicketAsyncInput) => ReturnType<typeof getStartGameWithTicketInstructionAsync> & SelfPlanAndSendFunctions; }
|
|
86
|
+
|
|
87
|
+
export type RpsGamePluginRequirements = ClientWithRpc<GetAccountInfoApi & GetMultipleAccountsApi> & ClientWithPayer & ClientWithTransactionPlanning & ClientWithTransactionSending
|
|
88
|
+
|
|
89
|
+
export function rpsGameProgram() {
|
|
90
|
+
return <T extends RpsGamePluginRequirements>(client: T) => {
|
|
91
|
+
return { ...client, rpsGame: <RpsGamePlugin>{ accounts: { gameSession: addSelfFetchFunctions(client, getGameSessionCodec()), playerProfile: addSelfFetchFunctions(client, getPlayerProfileCodec()) }, instructions: { closePlayer: input => addSelfPlanAndSendFunctions(client, getClosePlayerInstructionAsync({ ...input, payer: input.payer ?? client.payer.address })), delegatePda: input => addSelfPlanAndSendFunctions(client, getDelegatePdaInstructionAsync({ ...input, payer: input.payer ?? client.payer })), initializePlayer: input => addSelfPlanAndSendFunctions(client, getInitializePlayerInstructionAsync({ ...input, payer: input.payer ?? client.payer })), makeChoice: input => addSelfPlanAndSendFunctions(client, getMakeChoiceInstruction(input)), onMatchFound: input => addSelfPlanAndSendFunctions(client, getOnMatchFoundInstruction(input)), persistResults: input => addSelfPlanAndSendFunctions(client, getPersistResultsInstruction({ ...input, payer: input.payer ?? client.payer })), processUndelegation: input => addSelfPlanAndSendFunctions(client, getProcessUndelegationInstruction({ ...input, payer: input.payer ?? client.payer.address })), startGame: input => addSelfPlanAndSendFunctions(client, getStartGameInstructionAsync(input)), startGameWithTicket: input => addSelfPlanAndSendFunctions(client, getStartGameWithTicketInstructionAsync(input)) } } };
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { combineCodec, getAddressDecoder, getAddressEncoder, getDiscriminatedUnionDecoder, getDiscriminatedUnionEncoder, getStructDecoder, getStructEncoder, getU64Decoder, getU64Encoder, type Address, type Codec, type Decoder, type Encoder, type GetDiscriminatedUnionVariant, type GetDiscriminatedUnionVariantContent } from '@solana/kit';
|
|
10
|
+
|
|
11
|
+
export type AccountType = { __kind: "PlayerProfile", player: Address; } | { __kind: "GameSession", p1: Address; p2: Address; id: bigint; };
|
|
12
|
+
|
|
13
|
+
export type AccountTypeArgs = { __kind: "PlayerProfile", player: Address; } | { __kind: "GameSession", p1: Address; p2: Address; id: number | bigint; };
|
|
14
|
+
|
|
15
|
+
export function getAccountTypeEncoder(): Encoder<AccountTypeArgs> {
|
|
16
|
+
return getDiscriminatedUnionEncoder([['PlayerProfile', getStructEncoder([['player', getAddressEncoder()]])], ['GameSession', getStructEncoder([['p1', getAddressEncoder()], ['p2', getAddressEncoder()], ['id', getU64Encoder()]])]]);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getAccountTypeDecoder(): Decoder<AccountType> {
|
|
20
|
+
return getDiscriminatedUnionDecoder([['PlayerProfile', getStructDecoder([['player', getAddressDecoder()]])], ['GameSession', getStructDecoder([['p1', getAddressDecoder()], ['p2', getAddressDecoder()], ['id', getU64Decoder()]])]]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function getAccountTypeCodec(): Codec<AccountTypeArgs, AccountType> {
|
|
24
|
+
return combineCodec(getAccountTypeEncoder(), getAccountTypeDecoder());
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Data Enum Helpers.
|
|
28
|
+
export function accountType(kind: 'PlayerProfile', data: GetDiscriminatedUnionVariantContent<AccountTypeArgs, '__kind', 'PlayerProfile'>): GetDiscriminatedUnionVariant<AccountTypeArgs, '__kind', 'PlayerProfile'>;
|
|
29
|
+
export function accountType(kind: 'GameSession', data: GetDiscriminatedUnionVariantContent<AccountTypeArgs, '__kind', 'GameSession'>): GetDiscriminatedUnionVariant<AccountTypeArgs, '__kind', 'GameSession'>;
|
|
30
|
+
export function accountType<K extends AccountTypeArgs['__kind'], Data>(kind: K, data?: Data) {
|
|
31
|
+
return Array.isArray(data) ? { __kind: kind, fields: data } : { __kind: kind, ...(data ?? {}) };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function isAccountType<K extends AccountType['__kind']>(kind: K, value: AccountType): value is AccountType & { __kind: K } {
|
|
35
|
+
return value.__kind === kind;
|
|
36
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { combineCodec, getEnumDecoder, getEnumEncoder, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder } from '@solana/kit';
|
|
10
|
+
|
|
11
|
+
export enum Choice { Rock, Paper, Scissors };
|
|
12
|
+
|
|
13
|
+
export type ChoiceArgs = Choice;
|
|
14
|
+
|
|
15
|
+
export function getChoiceEncoder(): FixedSizeEncoder<ChoiceArgs> {
|
|
16
|
+
return getEnumEncoder(Choice);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getChoiceDecoder(): FixedSizeDecoder<Choice> {
|
|
20
|
+
return getEnumDecoder(Choice);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function getChoiceCodec(): FixedSizeCodec<ChoiceArgs, Choice> {
|
|
24
|
+
return combineCodec(getChoiceEncoder(), getChoiceDecoder());
|
|
25
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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, getTupleDecoder, getTupleEncoder, getUnitDecoder, getUnitEncoder, type Address, type Codec, type Decoder, type Encoder, type GetDiscriminatedUnionVariant, type GetDiscriminatedUnionVariantContent } from '@solana/kit';
|
|
10
|
+
|
|
11
|
+
export type GameResult = { __kind: "Winner", fields: readonly [Address]; } | { __kind: "Tie" } | { __kind: "None" };
|
|
12
|
+
|
|
13
|
+
export type GameResultArgs = GameResult;
|
|
14
|
+
|
|
15
|
+
export function getGameResultEncoder(): Encoder<GameResultArgs> {
|
|
16
|
+
return getDiscriminatedUnionEncoder([['Winner', getStructEncoder([['fields', getTupleEncoder([getAddressEncoder()])]])], ['Tie', getUnitEncoder()], ['None', getUnitEncoder()]]);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getGameResultDecoder(): Decoder<GameResult> {
|
|
20
|
+
return getDiscriminatedUnionDecoder([['Winner', getStructDecoder([['fields', getTupleDecoder([getAddressDecoder()])]])], ['Tie', getUnitDecoder()], ['None', getUnitDecoder()]]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function getGameResultCodec(): Codec<GameResultArgs, GameResult> {
|
|
24
|
+
return combineCodec(getGameResultEncoder(), getGameResultDecoder());
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Data Enum Helpers.
|
|
28
|
+
export function gameResult(kind: 'Winner', data: GetDiscriminatedUnionVariantContent<GameResultArgs, '__kind', 'Winner'>['fields']): GetDiscriminatedUnionVariant<GameResultArgs, '__kind', 'Winner'>;
|
|
29
|
+
export function gameResult(kind: 'Tie'): GetDiscriminatedUnionVariant<GameResultArgs, '__kind', 'Tie'>;
|
|
30
|
+
export function gameResult(kind: 'None'): GetDiscriminatedUnionVariant<GameResultArgs, '__kind', 'None'>;
|
|
31
|
+
export function gameResult<K extends GameResultArgs['__kind'], Data>(kind: K, data?: Data) {
|
|
32
|
+
return Array.isArray(data) ? { __kind: kind, fields: data } : { __kind: kind, ...(data ?? {}) };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function isGameResult<K extends GameResult['__kind']>(kind: K, value: GameResult): value is GameResult & { __kind: K } {
|
|
36
|
+
return value.__kind === kind;
|
|
37
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export * from './accountType';
|
|
10
|
+
export * from './choice';
|
|
11
|
+
export * from './gameResult';
|
package/src/index.ts
CHANGED