From a356dc382d409d35bfff94a966f2974b67c58d2d Mon Sep 17 00:00:00 2001 From: rasguy92 Date: Tue, 5 Dec 2023 15:09:32 +0700 Subject: [PATCH] feat: redploy and configure game controller --- deployed-addresses.json | 4 ++-- .../CreateGameCard/CreateCoinFlipGameCard.tsx | 2 +- .../CreateGameCard/CreateDiceGameCard.tsx | 4 +++- .../JoinGameCard/JoinCoinFlipGameCard.tsx | 2 +- .../JoinGameCard/JoinDiceGamecard.tsx | 2 +- src/hooks/useCreateGameParams.ts | 17 +++++++---------- src/utils/abis.ts | 10 +++++----- 7 files changed, 20 insertions(+), 21 deletions(-) diff --git a/deployed-addresses.json b/deployed-addresses.json index 26faec3..3d2cf79 100644 --- a/deployed-addresses.json +++ b/deployed-addresses.json @@ -13,10 +13,10 @@ "address": "0x0000000000000000000000000000000000000000" }, "WegaGameController": { - "address": "0x4114E9Fcb0D2Ba2480A6041CDEaBe315dc5063b4", + "address": "0x15aeA3c65Cec3F7525e611fd12D6476439aF789b", "legacyAddresses": [], "deploymentBlock": null, - "implementation": "0x5911a010941F892FB150AA83A65A327bAa7c12C0" + "implementation": "0x721059fe3dd1c18d1926Eb36Ed792008339e4Ba9" }, "WegaRandomizerController": { "address": "0x724611c7dEB9a9D753aDDFF2f305c902FCbA02C8", diff --git a/src/components/CreateGameCard/CreateCoinFlipGameCard.tsx b/src/components/CreateGameCard/CreateCoinFlipGameCard.tsx index 51847da..b8f7936 100644 --- a/src/components/CreateGameCard/CreateCoinFlipGameCard.tsx +++ b/src/components/CreateGameCard/CreateCoinFlipGameCard.tsx @@ -189,7 +189,7 @@ export const CreateCoinFlipGameCard = ({ /> {wagerUSDValue.loading ? 'loading...' : wagerUSDValue.value} USD Balance: { - isWagerbalanceLoading ? "Retrieving balance..." : userWagerBalance?.formatted + isWagerbalanceLoading ? "Retrieving balance..." : parseFloat(userWagerBalance?.formatted as string).toFixed(2) } {/* useBalance from wagmi can be used here */} diff --git a/src/components/CreateGameCard/CreateDiceGameCard.tsx b/src/components/CreateGameCard/CreateDiceGameCard.tsx index 83ccff0..1c79bcb 100644 --- a/src/components/CreateGameCard/CreateDiceGameCard.tsx +++ b/src/components/CreateGameCard/CreateDiceGameCard.tsx @@ -156,6 +156,8 @@ export const CreateDiceGameCard = ({ const navigateToGameUi = useNavigateTo() useEffect(() => { + console.log(userWagerBalance) + if(playerAddress && tokenAddress){ allowanceQuery.refetch(); if(createGameStatus === 'fulfilled' && createGameResponse) { @@ -194,7 +196,7 @@ export const CreateDiceGameCard = ({ {/* should receive wager amount as input */} {wagerUSDValue.loading ? 'loading...' : wagerUSDValue.value} USD Balance: { - isWagerbalanceLoading ? "Retrieving balance..." : userWagerBalance ? userWagerBalance?.formatted : String(0) + isWagerbalanceLoading ? "Retrieving balance..." : userWagerBalance ? parseFloat(userWagerBalance?.formatted as string).toFixed(2) : String(0) } {/* useBalance from wagmi can be used here */} diff --git a/src/components/JoinGameCard/JoinCoinFlipGameCard.tsx b/src/components/JoinGameCard/JoinCoinFlipGameCard.tsx index d61ea57..8ed5a49 100644 --- a/src/components/JoinGameCard/JoinCoinFlipGameCard.tsx +++ b/src/components/JoinGameCard/JoinCoinFlipGameCard.tsx @@ -186,7 +186,7 @@ const JoinCoinFlipGameCard = ({ /> {wagerUSDValue.loading ? 'loading...' : wagerUSDValue.value} USD Balance: { - isWagerbalanceLoading ? "Retrieving balance..." : userWagerBalance?.formatted + ' ' + userWagerBalance?.symbol + isWagerbalanceLoading ? "Retrieving balance..." : parseFloat(userWagerBalance?.formatted as string).toFixed(2) } {/* useBalance from wagmi can be used here */} diff --git a/src/components/JoinGameCard/JoinDiceGamecard.tsx b/src/components/JoinGameCard/JoinDiceGamecard.tsx index fb8a334..d2a6da0 100644 --- a/src/components/JoinGameCard/JoinDiceGamecard.tsx +++ b/src/components/JoinGameCard/JoinDiceGamecard.tsx @@ -148,7 +148,7 @@ const JoinGameDiceCard: React.FC = ({ /> {wagerUSDValue.loading ? 'loading...' : wagerUSDValue.value} USD Balance: { - isWagerbalanceLoading ? "Retrieving balance..." : userWagerBalance?.formatted + ' ' + userWagerBalance?.symbol + isWagerbalanceLoading ? "Retrieving balance..." : parseFloat(userWagerBalance?.formatted as string).toFixed(2) } {/* useBalance from wagmi can be used here */} diff --git a/src/hooks/useCreateGameParams.ts b/src/hooks/useCreateGameParams.ts index 44b32ce..a7dae03 100644 --- a/src/hooks/useCreateGameParams.ts +++ b/src/hooks/useCreateGameParams.ts @@ -16,17 +16,14 @@ export function useCreateGameParams({ useEffect(() => { if(wallet && wallet.isConnected && user && network) { - if(!(getTokenAddress() && getPlayerAddress() && getUserUuid())) { - setTokenAddress(SupportedWagerTokenAddresses[currencyType][network?.id as number] as HexishString); - setPlayerAddress(wallet.address as HexishString); - setUserUuid(user.uuid as string); - } + setTokenAddress(SupportedWagerTokenAddresses[currencyType][network?.id as number] as HexishString); + setPlayerAddress(wallet.address as HexishString); + setUserUuid(user.uuid as string); + setTokenAddress(SupportedWagerTokenAddresses[currencyType][network?.id as number] as HexishString); } else { - if(getTokenAddress() && getPlayerAddress() && getUserUuid()) { - setTokenAddress(SupportedWagerTokenAddresses[currencyType][network?.id as number] as HexishString); - setPlayerAddress(undefined); - setUserUuid(undefined); - } + setTokenAddress(SupportedWagerTokenAddresses[currencyType][network?.id as number] as HexishString); + setPlayerAddress(undefined); + setUserUuid(undefined); } }, [network?.id, wallet?.isConnected, user?.uuid, currencyType]); return { diff --git a/src/utils/abis.ts b/src/utils/abis.ts index 427cb19..85a090e 100644 --- a/src/utils/abis.ts +++ b/src/utils/abis.ts @@ -1,4 +1,4 @@ -// Generated by @wagmi/cli@1.3.0 on 12/5/2023 at 1:37:37 PM +// Generated by @wagmi/cli@1.3.0 on 12/5/2023 at 3:08:33 PM ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // AccessControlUpgradeable @@ -4649,7 +4649,7 @@ export const wegaFeeAdminRoleABI = [ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** - * - [__View Contract on Polygon Polygon Scan__](https://polygonscan.com/address/0x4114E9Fcb0D2Ba2480A6041CDEaBe315dc5063b4) + * - [__View Contract on Polygon Polygon Scan__](https://polygonscan.com/address/0x15aeA3c65Cec3F7525e611fd12D6476439aF789b) * - * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0x39e851282C11AefE20B149F4509702B2DC8aEB73) * - [__View Contract on Skale Calypso Nft Hub Testnet Skale Explorer__](https://staging-utter-unripe-menkar.explorer.staging-v3.skalenodes.com/address/0x0000000000000000000000000000000000000000) @@ -5164,20 +5164,20 @@ export const wegaGameControllerABI = [ ] as const /** - * - [__View Contract on Polygon Polygon Scan__](https://polygonscan.com/address/0x4114E9Fcb0D2Ba2480A6041CDEaBe315dc5063b4) + * - [__View Contract on Polygon Polygon Scan__](https://polygonscan.com/address/0x15aeA3c65Cec3F7525e611fd12D6476439aF789b) * - * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0x39e851282C11AefE20B149F4509702B2DC8aEB73) * - [__View Contract on Skale Calypso Nft Hub Testnet Skale Explorer__](https://staging-utter-unripe-menkar.explorer.staging-v3.skalenodes.com/address/0x0000000000000000000000000000000000000000) */ export const wegaGameControllerAddress = { - 137: "0x4114E9Fcb0D2Ba2480A6041CDEaBe315dc5063b4", + 137: "0x15aeA3c65Cec3F7525e611fd12D6476439aF789b", 1337: "0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE", 80001: "0x39e851282C11AefE20B149F4509702B2DC8aEB73", 344106930: "0x0000000000000000000000000000000000000000" } as const /** - * - [__View Contract on Polygon Polygon Scan__](https://polygonscan.com/address/0x4114E9Fcb0D2Ba2480A6041CDEaBe315dc5063b4) + * - [__View Contract on Polygon Polygon Scan__](https://polygonscan.com/address/0x15aeA3c65Cec3F7525e611fd12D6476439aF789b) * - * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0x39e851282C11AefE20B149F4509702B2DC8aEB73) * - [__View Contract on Skale Calypso Nft Hub Testnet Skale Explorer__](https://staging-utter-unripe-menkar.explorer.staging-v3.skalenodes.com/address/0x0000000000000000000000000000000000000000)