diff --git a/apps/web/src/app/games/[id]/components/PlayerActions.tsx b/apps/web/src/app/games/[id]/components/PlayerActions.tsx index fb87123..c16d3b9 100644 --- a/apps/web/src/app/games/[id]/components/PlayerActions.tsx +++ b/apps/web/src/app/games/[id]/components/PlayerActions.tsx @@ -18,10 +18,10 @@ export default function PlayerActions() { const [queuedAction, setQueuedAction] = useState(null); const [isActionQueued, setIsActionQueued] = useState(false); const { account } = useWallet(); + const [address, setInAppAddress] = useState(); const mainPlayer = useMemo(() => { - const [address, _] = finalAddress(account?.address || ""); return players?.find((player) => player?.id === address); - }, [players, account]); + }, [players, address]); const isPlayerTurn = awaitingBetFrom?.id === mainPlayer?.id; const actions: PlacingBettingActions[] = [ PlacingBettingActions.FOLD, @@ -29,6 +29,10 @@ export default function PlayerActions() { PlacingBettingActions.RAISE, ]; + useEffect(() => { + setInAppAddress(finalAddress(account?.address || "")); + }, [account]); + useEffect(() => { if (isPlayerTurn && queuedAction) { console.log(`Player turn, executing queued action: ${queuedAction}`); diff --git a/packages/ts-sdk/src/Jeton/Jeton.ts b/packages/ts-sdk/src/Jeton/Jeton.ts index 457414a..d3781d2 100644 --- a/packages/ts-sdk/src/Jeton/Jeton.ts +++ b/packages/ts-sdk/src/Jeton/Jeton.ts @@ -117,11 +117,14 @@ export class Jeton extends EventEmitter { if (!this.gameState) throw new Error(" must exist"); const players = this.gameState.players; const eventData: ShowDownEvent = {}; + const privateCards = hexStringToUint8Array(data.privateCards); + const publicCards = hexStringToUint8Array(data.privateCards); + console.log("show down results", privateCards, publicCards, data.winningAmounts); for (const [index, player] of players.entries()) { eventData[player.id] = { player, winAmount: data.winningAmounts[index]!, - cards: [data.privateCards[index * 2]!, data.privateCards[index * 2 + 1]!], + cards: [privateCards[index * 2]!, privateCards[index * 2 + 1]!], }; } this.emit(GameEventTypes.SHOW_DOWN, eventData); diff --git a/packages/ts-sdk/src/OnChainDataSource/AptosOnChainDataSource.ts b/packages/ts-sdk/src/OnChainDataSource/AptosOnChainDataSource.ts index cbd2ec5..fdc8c14 100644 --- a/packages/ts-sdk/src/OnChainDataSource/AptosOnChainDataSource.ts +++ b/packages/ts-sdk/src/OnChainDataSource/AptosOnChainDataSource.ts @@ -106,8 +106,8 @@ export class AptosOnChainDataSource console.log("publishing", OnChainEventTypes.SHOW_DOWN); const data = (event as ShowDownEvent).data; this.emit(OnChainEventTypes.SHOW_DOWN, { - publicCards: data.public_cards.map((p) => Number(p)), - privateCards: data.private_cards.map((p) => Number(p)), + publicCards: data.public_cards, + privateCards: data.private_cards, winningAmounts: data.winning_amounts.map((a) => Number(a)), }); } diff --git a/packages/ts-sdk/src/OnChainDataSource/onChainEvents.types.ts b/packages/ts-sdk/src/OnChainDataSource/onChainEvents.types.ts index 4035376..bf2d055 100644 --- a/packages/ts-sdk/src/OnChainDataSource/onChainEvents.types.ts +++ b/packages/ts-sdk/src/OnChainDataSource/onChainEvents.types.ts @@ -26,8 +26,8 @@ export type OnChainPlayerPlacedBetData = { }; export type OnChainShowDownData = { - privateCards: number[]; - publicCards: number[]; + privateCards: string; + publicCards: string; winningAmounts: number[]; }; diff --git a/packages/ts-sdk/src/contracts/contractInteractions.ts b/packages/ts-sdk/src/contracts/contractInteractions.ts index e757343..02546bd 100644 --- a/packages/ts-sdk/src/contracts/contractInteractions.ts +++ b/packages/ts-sdk/src/contracts/contractInteractions.ts @@ -35,7 +35,7 @@ export interface GeneralEvent extends BaseEvent { } export interface ShowDownEvent extends BaseEvent { - data: { private_cards: number[]; public_cards: number[]; winning_amounts: number[] }; + data: { private_cards: number[]; public_cards: string; winning_amounts: string }; indexed_type: typeof contractShowDownEventType; transaction_block_height: number; }