Skip to content

Commit

Permalink
Merge pull request #50 from JetonDAO/show-down
Browse files Browse the repository at this point in the history
Implement new onchain structure
  • Loading branch information
arssly authored Oct 14, 2024
2 parents 40bb51e + feea785 commit 0e09805
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/ts-sdk/src/Jeton/Jeton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,9 @@ export class Jeton extends EventEmitter<GameEventMap> {
if (onChainTableObject.state.__variant__ !== "Playing")
throw new Error("shuffle should only be called during playing");
const publicKeys = onChainTableObject.roster.players.map((p) =>
hexStringToUint8Array(p.public_key),
hexStringToUint8Array(p.public_key._0),
);
this.shuffle(hexStringToUint8Array(onChainTableObject.state.deck), publicKeys);
this.shuffle(hexStringToUint8Array(onChainTableObject.state.deck._0), publicKeys);
}
if (
onChainDataMapper.convertGameStatus(onChainTableObject.state) === GameStatus.BetPreFlop &&
Expand Down
4 changes: 2 additions & 2 deletions packages/ts-sdk/src/Jeton/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function getPrivateCardsIndexes(

export function getDeck(tableObject: OnChainTableObject) {
return (
tableObject.state.__variant__ === "Playing" && hexStringToUint8Array(tableObject.state.deck)
tableObject.state.__variant__ === "Playing" && hexStringToUint8Array(tableObject.state.deck._0)
);
}

Expand All @@ -40,7 +40,7 @@ export function getCardShares(tableObject: OnChainTableObject, indexes: number[]
export function getCardShares(tableObject: OnChainTableObject, indexes: number | number[]) {
if (tableObject.state.__variant__ !== "Playing") throw new Error("must be playing");
const arrayedShares = new Array(52);
const mapShares = tableObject.state.decryption_card_shares.data;
const mapShares = tableObject.state.decryption_share_store._0.data;
for (const mapShare of mapShares) {
arrayedShares[mapShare.key] = mapShare.value;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/ts-sdk/src/OnChainDataSource/onChainObjects.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type OnChainActivePlayer = {
stake: ChipStack;
is_folded: boolean;
is_last_hand: boolean;
public_key: string;
public_key: { _0: string };
};

export type OnChainPendingPlayer = {
Expand Down Expand Up @@ -66,8 +66,8 @@ export type RemovedState = {
export type PlayingState = {
__variant__: "Playing";
timeout: string;
deck: string;
decryption_card_shares: { data: { key: number; value: string }[] };
deck: { _0: string };
decryption_share_store: { _0: { data: { key: number; value: string }[] } };
phase: OnChainPhase;
};

Expand Down

0 comments on commit 0e09805

Please sign in to comment.