diff --git a/deployed-addresses.json b/deployed-addresses.json index 274b519..0f112f9 100644 --- a/deployed-addresses.json +++ b/deployed-addresses.json @@ -67,51 +67,72 @@ "80001": { "contracts": { "WegaERC20Escrow": { - "address": "0xCEBc6b24362cA2F4fA625d340BeF8Af4F91DB5bB", - "legacyAddresses": [], - "deploymentBlock": "263113a", - "implementation": "0x0993a07880aD59E02e72E745dC5b623409Ad24af" + "address": "0x4B4e9126b1701385dc5b0D02b12360635D57F12C", + "legacyAddresses": [ + "0x0993a07880aD59E02e72E745dC5b623409Ad24af" + ], + "deploymentBlock": null, + "implementation": "0xB08555B946a2fcef22074a9115250a6666A3b901" }, "WegaERC20Dummy": { - "address": "0x802361100a4772847DBc29BC59F76FD1F186E002", + "address": "0x1CdB8176Ad8579aE748703f40864BB2E65e68529", "legacyAddresses": [], "deploymentBlock": "263112e" }, "WegaGameController": { - "address": "0xe4da6EE02D91b7C03DB000B9295A815D6BEeC4ca", + "address": "0x39e851282C11AefE20B149F4509702B2DC8aEB73", "legacyAddresses": [ + "0x21A8Eda1B590268410e520B70635467720B41418", "0x760D87Ce891F301d19F608044D42356De2D50D14", "0x740e1416aE865E2bff8f95aa5776F5Fa0a3706e7", "0x02D7EF0f678BCd9323f2FA88e7197528D113f24a", "0x0000000000000000000000000000000000000000" ], - "deploymentBlock": "272c37b", - "implementation": "0x21A8Eda1B590268410e520B70635467720B41418" + "deploymentBlock": null, + "implementation": "0x6215002028eA5Ec1F89D5bc5D553ce83Fed6Cd1b" }, "WegaRandomizerController": { - "address": "0xcd44090c1BC8DC05298540488ca6FA058d27Ac70", + "address": "0xC757438A9eF34020FEBB7E25336e4eC20dE55fD1", "legacyAddresses": [], - "implementation": "0x24F9E5E74976661E3784E258986Ee9ee6AAe8132" + "implementation": "0x24F9E5E74976661E3784E258986Ee9ee6AAe8132", + "deploymentBlock": null }, "WegaDiceGame": { - "address": "0x5581147651B29D44d4eD95099F1a53aAE052f797", - "legacyAddresses": [], - "deploymentBlock": "263116f", - "implementation": "0x4f2Fe30D48961581d65C0a486AE5e83A9b8356b0" + "address": "0xd806555f94769bEeAF1d60858f3963C095434aA1", + "legacyAddresses": [ + "0x4f2Fe30D48961581d65C0a486AE5e83A9b8356b0" + ], + "deploymentBlock": null, + "implementation": "0x3C119E7148071Ea0e7B2abBa63eae2f097a4cEdf" }, "WegaCoinFlipGame": { - "address": "0x24133b29067AC3858B4F58112bCAC243941538c8", - "legacyAddresses": [], - "deploymentBlock": "2631158", - "implementation": "0x0C438E3C3B7b629044573e7cc3B0FBe55DB1b8b6" + "address": "0x57aB2987CBa91f08Db532c57Cfa7478cd5D009b2", + "legacyAddresses": [ + "0x0C438E3C3B7b629044573e7cc3B0FBe55DB1b8b6" + ], + "deploymentBlock": null, + "implementation": "0x1fC17Ca1b3e702E0D93D3BA5FEA2573079e60Af0" }, "FeeManager": { - "address": "0xe2cDC641b8AF26a208402a3e218EE022E954Afd0", + "address": "0xc392D90803D462Ac5395A76d59AB942a8d9DCe69", "legacyAddresses": [], - "implementation": "0x30D1C9b043014820cC878ea023bd9Ae53238B395" + "implementation": "0x30D1C9b043014820cC878ea023bd9Ae53238B395", + "deploymentBlock": null }, "WegaRandomizer": { "address": "0x0000000000000000000000000000000000000000" + }, + "WegaChanceGame": { + "address": "0x85c5165800E4f43489912beEc115a77E312142ca", + "legacyAddresses": [], + "deploymentBlock": "25e6a43", + "implementation": "0x945Fbb4138040e2ab766CB59A7Aa6D882AfBCcF4" + }, + "WegaRandomNumberController": { + "address": "0xaBC8837A5756aF9a915a8cC77b80b06c1997e17e", + "legacyAddresses": [], + "deploymentBlock": "2631148", + "implementation": "0xCC6e334201974DF201EBb4bd84b97ac232fE7380" } } }, diff --git a/package.json b/package.json index f398066..3af974f 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ }, "scripts": { "app": "export GSAP_TOKEN=$(grep 'GSAP_TOKEN=' .env | cut -d'=' -f2) && vite --mode", + "export:env": "export GSAP_TOKEN=$(grep 'GSAP_TOKEN=' .env | cut -d'=' -f2)", "build": "tsc && vite build", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "lint:fix": "eslint \"src/**/*.{ts,tsx}\" --fix", diff --git a/src/app/store.ts b/src/app/store.ts index 8750993..cbe2fb7 100644 --- a/src/app/store.ts +++ b/src/app/store.ts @@ -3,14 +3,12 @@ import walletConnectionReducer from '../components/RainBowConnectButton/connecti import { blockchainApiSlice } from './blockchainApiSlice'; import { appApiSlice } from './apiSlice'; import intlReducer from '../containers/LanguageProvider/intlSlice' -import blockchainReducer from '../api/blockchain/blockchainSlice' export const store = configureStore({ reducer: { connection: walletConnectionReducer, [appApiSlice.reducerPath]: appApiSlice.reducer, [blockchainApiSlice.reducerPath]: blockchainApiSlice.reducer, - blockchain: blockchainReducer, language: intlReducer, }, middleware: (getDefaultMiddleware) => getDefaultMiddleware({ diff --git a/src/assets/icons/ArrowDownIconV2.tsx b/src/assets/icons/ArrowDownIconV2.tsx index efac394..14b9907 100644 --- a/src/assets/icons/ArrowDownIconV2.tsx +++ b/src/assets/icons/ArrowDownIconV2.tsx @@ -4,7 +4,7 @@ const SvgComponent = (props: SVGProps) => ( diff --git a/src/assets/icons/arrow-down-icon.png b/src/assets/icons/arrow-down-icon.png new file mode 100644 index 0000000..bde91f7 Binary files /dev/null and b/src/assets/icons/arrow-down-icon.png differ diff --git a/src/common/modals/ClaimModal.tsx b/src/common/modals/ClaimModal.tsx index 60635ab..4df24c2 100644 --- a/src/common/modals/ClaimModal.tsx +++ b/src/common/modals/ClaimModal.tsx @@ -2,14 +2,17 @@ import { formatEther } from 'ethers'; import tw, { styled } from 'twin.macro'; import { WinnerDeclarationContainer } from './types'; import { NormalText, SmallText } from '../../components/CreateGameCard/types'; -import { ArrowDownIconV2, DownloadIcon } from '../../assets/icons'; +import { DownloadIcon } from '../../assets/icons'; +import arrowDown from '../../assets/icons/arrow-down-icon.png'; import { BadgeIcon, renderWagerBadge } from "../GameBar"; -import { HexishString, Wega } from '../../models'; -import { useBlockchainApiHooks, useTokenUSDValue } from '../../hooks'; -import { miniWalletAddress, capitalize } from '../../utils'; +import { HexishString, Wega, WegaState} from '../../models'; +import { useTokenUSDValue } from '../../hooks'; +import { useWithdrawMutation, useGetClaimAmountQuery } from './blockchainApiSlice'; +import { useUpdateGameMutation } from '../../components/PlayGameSection/apiSlice'; +import { miniWalletAddress, capitalize, toastSettings } from '../../utils'; import Button from '../Button'; import WalletAvatar from "../../common/WalletAvatar"; - +import toast from 'react-hot-toast'; // TODO add gas costs @@ -19,15 +22,25 @@ export interface ClaimModalProps { wallet: any; } + export const ClaimModal = ({ hide, game, wallet }: ClaimModalProps) => { - const {useClaimMutation} = useBlockchainApiHooks; - const {claim, isLoading: isClaimingLoading} = useClaimMutation(); + const [feeAmountIndex, sendAmountIndex] = [0, 1] + const [claim, claimQuery] = useWithdrawMutation(); + const [updateGame, ] = useUpdateGameMutation(); + + const calculateFeesQuery = useGetClaimAmountQuery({ + escrowHash: game.wager.wagerHash as HexishString, + account: wallet.address + }); const handleClaimClick = async () => { - await claim(game.wager.wagerHash as HexishString).unwrap(); - hide(); + await claim({ escrowHash: game.wager.wagerHash as HexishString }).unwrap(); + await updateGame({ uuid: game.uuid, state: WegaState.SETTLED }).unwrap(); + toast.success('Withdraw success', { ...toastSettings('success', 'top-center') as any }); + return hide(); }; const wagerUSDValue = useTokenUSDValue(game.wager.wagerCurrency, Number(formatEther(game.wager.wagerAmount))); + // console.log(feeTaker) // console.log(game.wager) return ( @@ -58,9 +71,7 @@ export const ClaimModal = ({ hide, game, wallet
-
- -
+ arrow
{/* bottom */} @@ -94,7 +105,11 @@ export const ClaimModal = ({ hide, game, wallet
Total claim before fees - {formatEther(game.wager.wagerAmount)} {game.wager.wagerCurrency} + { + !calculateFeesQuery.data ? 'calculating...' : { + Number(formatEther(calculateFeesQuery.data[feeAmountIndex])) + Number(formatEther(calculateFeesQuery.data[sendAmountIndex])) + } {game.wager.wagerCurrency} + }
{/*
@@ -107,23 +122,35 @@ export const ClaimModal = ({ hide, game, wallet
Platform fee (5%) - 00.00 {game.wager.wagerCurrency} + { + !calculateFeesQuery.data ? 'calculating...' : { + formatEther(calculateFeesQuery.data[feeAmountIndex]) + } {game.wager.wagerCurrency} + }
-
+
You pay - {formatEther(game.wager.wagerAmount)} {game.wager.wagerCurrency} + { + !calculateFeesQuery.data ? 'calculating...' : { + formatEther(calculateFeesQuery.data[feeAmountIndex]) + } {game.wager.wagerCurrency} + }
You receive - {formatEther(game.wager.wagerAmount)} {game.wager.wagerCurrency} + { + !calculateFeesQuery.data ? 'calculating...' : { + formatEther(calculateFeesQuery.data[sendAmountIndex]) + } {game.wager.wagerCurrency} + }
diff --git a/src/common/modals/apiSlice.ts b/src/common/modals/apiSlice.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/common/modals/blockchainApiSlice.ts b/src/common/modals/blockchainApiSlice.ts index e69de29..02c9aea 100644 --- a/src/common/modals/blockchainApiSlice.ts +++ b/src/common/modals/blockchainApiSlice.ts @@ -0,0 +1,39 @@ +import { blockchainApiSlice } from '../../app/blockchainApiSlice'; +import { HexishString } from '../../models'; +import { ContractTypes } from '../../libs/wagmi'; + + +// Todo + // write function names with type safety +export const modalsBlockchainApiSlice = blockchainApiSlice.injectEndpoints({ + endpoints: (builder) => ({ + calculateFeesForTransfer: builder.query({ + query: ({ feeApplier, transferAmount }) => ({ + functionName: 'calculateFeesForTransfer', + contract: ContractTypes.FEE_MANAGER, + method: 'READ', + args: [feeApplier, transferAmount] + }) + }), + withdraw: builder.mutation({ + query: ({ escrowHash }) => ({ + functionName: 'withdraw', + contract: ContractTypes.ERC20ESCROW, + method: 'WRITE', + args: [escrowHash] + }) + }), + getClaimAmount: builder.query({ + query: ({ escrowHash, account }) => ({ + functionName: 'getClaimAmount', + contract: ContractTypes.ERC20ESCROW, + method: 'READ', + args: [escrowHash, account] + }) + }) + }) +}); + +export const { useCalculateFeesForTransferQuery, useWithdrawMutation, useGetClaimAmountQuery } = modalsBlockchainApiSlice; + + \ No newline at end of file diff --git a/src/components/CoinFlip/animations.ts b/src/components/CoinFlip/animations.ts index 510defb..b7a8ae4 100644 --- a/src/components/CoinFlip/animations.ts +++ b/src/components/CoinFlip/animations.ts @@ -20,7 +20,7 @@ export function useRoll(coinRef: any, gameOver: boolean) { } const tl = gsap.timeline({ repeatDelay: 0, onComplete: callb }) tl.to("g#all-sides", { - repeat: 10, + repeat: 5, ease: "none", y: "300", }) @@ -36,14 +36,14 @@ export function useRoll(coinRef: any, gameOver: boolean) { roll(animationTarget); } if(gameOver) { - setTimeout(() => setRolled(true), 2000); + setTimeout(() => setRolled(true), 4000); } }, coinRef); return () => ctx.revert(); }, [trigger, gameOver]); return { triggerRoll, - rolled + rolled, } } diff --git a/src/components/Dice/animations.ts b/src/components/Dice/animations.ts index 432b575..365091b 100644 --- a/src/components/Dice/animations.ts +++ b/src/components/Dice/animations.ts @@ -13,7 +13,6 @@ export function useRoll(diceRef: any, onBegin?: Callback, onEnd?: Callback) { function roll(to: string) { - console.log('ROLLING TO', to); if(onBegin) onBegin(); const callb = () => { gsap.fromTo("g#all-sides", { diff --git a/src/containers/Navigation/index.tsx b/src/containers/Navigation/index.tsx index 54c7ece..b49457f 100644 --- a/src/containers/Navigation/index.tsx +++ b/src/containers/Navigation/index.tsx @@ -24,7 +24,7 @@ const Navigation = () => { return ( -
+
diff --git a/src/containers/Navigation/types.ts b/src/containers/Navigation/types.ts index 46a9e6e..399dfcb 100644 --- a/src/containers/Navigation/types.ts +++ b/src/containers/Navigation/types.ts @@ -58,7 +58,7 @@ export const NavigationBar = styled.nav` right: 0; left: 0; transition: transform 500ms ease-out 100ms; - z-index: 10000; + z-index: 1000; &.nav-show { transform: initial; &::after { @@ -76,7 +76,7 @@ export const NavigationBar = styled.nav` right: 0; width: 100%; height: 100%; - ${tw`bg-pretu bg-opacity-90 z-[7500] shadow-wega-nav`} + ${tw`bg-pretu bg-opacity-90 z-[750] shadow-wega-nav`} // filter: blur(1rem); // -webkit-filter: blur(1rem); opacity: 0; @@ -93,7 +93,7 @@ export const NavigationBar = styled.nav` opacity: 0; // filter: blur(1rem); // -webkit-filter: blur(1rem); - ${tw`z-[7450] bg-pretu bg-opacity-95`} + ${tw`z-[745] bg-pretu bg-opacity-95`} transition: all 500ms ease-out 60ms; } &.nav-hide { diff --git a/src/containers/WinsPage/index.tsx b/src/containers/WinsPage/index.tsx index 7259444..9cf3837 100644 --- a/src/containers/WinsPage/index.tsx +++ b/src/containers/WinsPage/index.tsx @@ -27,6 +27,7 @@ const WinsPage = () => {
Claim wins @@ -39,14 +40,14 @@ const WinsPage = () => {
{ wallet && wallet?.isConnected && network && network.id ? - (
+ (
) : ( <> - + ) diff --git a/src/hooks/useCreateGameParams.ts b/src/hooks/useCreateGameParams.ts index 16ce403..44b32ce 100644 --- a/src/hooks/useCreateGameParams.ts +++ b/src/hooks/useCreateGameParams.ts @@ -17,13 +17,13 @@ export function useCreateGameParams({ useEffect(() => { if(wallet && wallet.isConnected && user && network) { if(!(getTokenAddress() && getPlayerAddress() && getUserUuid())) { - setTokenAddress(SupportedWagerTokenAddresses(network?.id as number)[currencyType]); + setTokenAddress(SupportedWagerTokenAddresses[currencyType][network?.id as number] as HexishString); setPlayerAddress(wallet.address as HexishString); setUserUuid(user.uuid as string); } } else { if(getTokenAddress() && getPlayerAddress() && getUserUuid()) { - setTokenAddress(SupportedWagerTokenAddresses(network?.id as number)[currencyType]); + setTokenAddress(SupportedWagerTokenAddresses[currencyType][network?.id as number] as HexishString); setPlayerAddress(undefined); setUserUuid(undefined); } diff --git a/src/libs/wagmi/index.ts b/src/libs/wagmi/index.ts index 7490576..991c7d3 100644 --- a/src/libs/wagmi/index.ts +++ b/src/libs/wagmi/index.ts @@ -7,6 +7,7 @@ import { alchemyProvider } from 'wagmi/providers/alchemy'; import { publicProvider } from 'wagmi/providers/public'; import { HexishString } from '../../models'; import { tokenConfig, escrowConfig, gameControllerConfig, wegaRandomizerControllerConfig } from "../../utils"; +import { feeManagerConfig } from '../../utils/abis'; @@ -52,7 +53,8 @@ export const ContractTypes = { 'TOKEN': 'wegaErc20Dummy', 'ERC20ESCROW': 'wegaErc20Escrow', 'GAMECONTROLLER': 'wegaGameController', - 'RADNOMIZER_CONTROLLER': 'wegaRandomizerController' + 'RADNOMIZER_CONTROLLER': 'wegaRandomizerController', + 'FEE_MANAGER': 'feeManager' } as const; export const ContractConfig = { @@ -63,6 +65,7 @@ export const ContractConfig = { }, [ContractTypes.GAMECONTROLLER]: gameControllerConfig, [ContractTypes.RADNOMIZER_CONTROLLER]: wegaRandomizerControllerConfig, + [ContractTypes.FEE_MANAGER]: feeManagerConfig, } as const; export type AllContractTypes = typeof ContractTypes[keyof typeof ContractTypes]; diff --git a/src/main.tsx b/src/main.tsx index 5c77116..625ab64 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -7,6 +7,8 @@ import './themes/index.css' import GlobalStyles from "./themes/GlobalStyles.tsx"; import WalletProvider from './containers/WalletProvider/index.tsx' +// TODO + // remove old api files ReactDOM.createRoot(document.getElementById("root")!).render( diff --git a/src/models/constants.ts b/src/models/constants.ts index c92bb3f..9d7fd3e 100644 --- a/src/models/constants.ts +++ b/src/models/constants.ts @@ -2,13 +2,18 @@ import { CurrencyTypes, CurrencyTypesEnum } from "."; import { tokenConfig } from "../utils"; import { polygon, polygonMumbai } from "wagmi/chains"; -export const SupportedWagerTokenAddresses = (id: number) => ({ - [CurrencyTypes[CurrencyTypesEnum.USDC]]: tokenConfig.address[id as keyof typeof tokenConfig.address], - [CurrencyTypes[CurrencyTypesEnum.USDT]]: tokenConfig.address[id as keyof typeof tokenConfig.address], - [CurrencyTypes[CurrencyTypesEnum.USD]]: tokenConfig.address[id as keyof typeof tokenConfig.address] -}) +export const SupportedWagerTokenAddresses = { + [CurrencyTypes[CurrencyTypesEnum.USDC]]: { + [polygon.id as number ?? 137]: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359", + [polygonMumbai.id as number ?? 80001]: tokenConfig.address[80001] + }, + [CurrencyTypes[CurrencyTypesEnum.USDT]]: { + [polygon.id as number ?? 137]: '0xc2132D05D31c914a87C6611C10748AEb04B58e8F', + [polygonMumbai.id as number ?? 80001]: tokenConfig.address[80001], + }, +} export const SupportedBlockExplorers = new Map([ [polygon.id ?? 137, 'https://polygonscan.com/tx/'], [polygonMumbai.id ?? 80001, 'https://mumbai.polygonscan.com/tx/'] -]) \ No newline at end of file +]) diff --git a/src/models/currency.ts b/src/models/currency.ts index dc04aae..203dab5 100644 --- a/src/models/currency.ts +++ b/src/models/currency.ts @@ -3,7 +3,6 @@ export enum CurrencyTypesEnum { USDC, USDT, USD }; export const CurrencyTypes = { [CurrencyTypesEnum.USDC]: 'USDC', [CurrencyTypesEnum.USDT]: 'USDT', - [CurrencyTypesEnum.USD]: 'USD', } as const; export type AllPossibleCurrencyTypes = typeof CurrencyTypes[keyof typeof CurrencyTypes]; \ No newline at end of file diff --git a/src/models/wega.ts b/src/models/wega.ts index 9d0a604..357b614 100644 --- a/src/models/wega.ts +++ b/src/models/wega.ts @@ -42,7 +42,8 @@ export const WegaState = { 'PLAYING': 'PLAYING', 'PENDING': 'PENDING', 'COMPLETED': 'COMPLETED', - 'CANCELED': 'CANCELED' + 'CANCELED': 'CANCELED', + 'SETTLED': 'SETTLED' } as const; export type AllPossibleWegaStates = typeof WegaState[keyof typeof WegaState]; diff --git a/src/utils/abis.ts b/src/utils/abis.ts index a160a4d..728e2db 100644 --- a/src/utils/abis.ts +++ b/src/utils/abis.ts @@ -1,4 +1,4 @@ -// Generated by @wagmi/cli@1.3.0 on 11/29/2023 at 12:47:05 PM +// Generated by @wagmi/cli@1.3.0 on 12/1/2023 at 4:31:48 PM ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // AccessControlUpgradeable @@ -522,7 +522,7 @@ export const enumerableMapABI = [ /** * - - * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0xe2cDC641b8AF26a208402a3e218EE022E954Afd0) + * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0xc392D90803D462Ac5395A76d59AB942a8d9DCe69) * - [__View Contract on Skale Calypso Nft Hub Testnet Skale Explorer__](https://staging-utter-unripe-menkar.explorer.staging-v3.skalenodes.com/address/0x0000000000000000000000000000000000000000) */ export const feeManagerABI = [ @@ -872,18 +872,18 @@ export const feeManagerABI = [ /** * - - * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0xe2cDC641b8AF26a208402a3e218EE022E954Afd0) + * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0xc392D90803D462Ac5395A76d59AB942a8d9DCe69) * - [__View Contract on Skale Calypso Nft Hub Testnet Skale Explorer__](https://staging-utter-unripe-menkar.explorer.staging-v3.skalenodes.com/address/0x0000000000000000000000000000000000000000) */ export const feeManagerAddress = { 1337: "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0", - 80001: "0xe2cDC641b8AF26a208402a3e218EE022E954Afd0", + 80001: "0xc392D90803D462Ac5395A76d59AB942a8d9DCe69", 344106930: "0x0000000000000000000000000000000000000000" } as const /** * - - * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0xe2cDC641b8AF26a208402a3e218EE022E954Afd0) + * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0xc392D90803D462Ac5395A76d59AB942a8d9DCe69) * - [__View Contract on Skale Calypso Nft Hub Testnet Skale Explorer__](https://staging-utter-unripe-menkar.explorer.staging-v3.skalenodes.com/address/0x0000000000000000000000000000000000000000) */ export const feeManagerConfig = { address: feeManagerAddress, abi: feeManagerABI } as const @@ -1431,7 +1431,7 @@ export const ierc721ErrorsABI = [ export const iFeeManagerABI = [ { - stateMutability: "nonpayable", + stateMutability: "view", type: "function", inputs: [ { name: "applier", internalType: "address", type: "address" }, @@ -1671,6 +1671,19 @@ export const iWegaErc20EscrowABI = [ name: "depositOf", outputs: [{ name: "", internalType: "uint256", type: "uint256" }] }, + { + stateMutability: "view", + type: "function", + inputs: [ + { name: "escrowHash", internalType: "bytes32", type: "bytes32" }, + { name: "account", internalType: "address", type: "address" } + ], + name: "getClaimAmount", + outputs: [ + { name: "feeAmount", internalType: "uint256", type: "uint256" }, + { name: "claimAmount", internalType: "uint256", type: "uint256" } + ] + }, { stateMutability: "view", type: "function", @@ -1749,6 +1762,13 @@ export const iWegaErc20EscrowABI = [ inputs: [{ name: "escrowHash", internalType: "bytes32", type: "bytes32" }], name: "wagerBalance", outputs: [{ name: "", internalType: "uint256", type: "uint256" }] + }, + { + stateMutability: "nonpayable", + type: "function", + inputs: [{ name: "escrowHash", internalType: "bytes32", type: "bytes32" }], + name: "withdraw", + outputs: [] } ] as const @@ -2645,7 +2665,7 @@ export const wegaABI = [ /** * - - * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0x24133b29067AC3858B4F58112bCAC243941538c8) + * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0x57aB2987CBa91f08Db532c57Cfa7478cd5D009b2) * - [__View Contract on Skale Calypso Nft Hub Testnet Skale Explorer__](https://staging-utter-unripe-menkar.explorer.staging-v3.skalenodes.com/address/0x0000000000000000000000000000000000000000) */ export const wegaCoinFlipGameABI = [ @@ -3009,18 +3029,18 @@ export const wegaCoinFlipGameABI = [ /** * - - * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0x24133b29067AC3858B4F58112bCAC243941538c8) + * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0x57aB2987CBa91f08Db532c57Cfa7478cd5D009b2) * - [__View Contract on Skale Calypso Nft Hub Testnet Skale Explorer__](https://staging-utter-unripe-menkar.explorer.staging-v3.skalenodes.com/address/0x0000000000000000000000000000000000000000) */ export const wegaCoinFlipGameAddress = { 1337: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e", - 80001: "0x24133b29067AC3858B4F58112bCAC243941538c8", + 80001: "0x57aB2987CBa91f08Db532c57Cfa7478cd5D009b2", 344106930: "0x0000000000000000000000000000000000000000" } as const /** * - - * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0x24133b29067AC3858B4F58112bCAC243941538c8) + * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0x57aB2987CBa91f08Db532c57Cfa7478cd5D009b2) * - [__View Contract on Skale Calypso Nft Hub Testnet Skale Explorer__](https://staging-utter-unripe-menkar.explorer.staging-v3.skalenodes.com/address/0x0000000000000000000000000000000000000000) */ export const wegaCoinFlipGameConfig = { @@ -3034,7 +3054,7 @@ export const wegaCoinFlipGameConfig = { /** * - - * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0x5581147651B29D44d4eD95099F1a53aAE052f797) + * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0xd806555f94769bEeAF1d60858f3963C095434aA1) * - [__View Contract on Skale Calypso Nft Hub Testnet Skale Explorer__](https://staging-utter-unripe-menkar.explorer.staging-v3.skalenodes.com/address/0x0000000000000000000000000000000000000000) */ export const wegaDiceGameABI = [ @@ -3398,18 +3418,18 @@ export const wegaDiceGameABI = [ /** * - - * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0x5581147651B29D44d4eD95099F1a53aAE052f797) + * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0xd806555f94769bEeAF1d60858f3963C095434aA1) * - [__View Contract on Skale Calypso Nft Hub Testnet Skale Explorer__](https://staging-utter-unripe-menkar.explorer.staging-v3.skalenodes.com/address/0x0000000000000000000000000000000000000000) */ export const wegaDiceGameAddress = { 1337: "0x9A676e781A523b5d0C0e43731313A708CB607508", - 80001: "0x5581147651B29D44d4eD95099F1a53aAE052f797", + 80001: "0xd806555f94769bEeAF1d60858f3963C095434aA1", 344106930: "0x0000000000000000000000000000000000000000" } as const /** * - - * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0x5581147651B29D44d4eD95099F1a53aAE052f797) + * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0xd806555f94769bEeAF1d60858f3963C095434aA1) * - [__View Contract on Skale Calypso Nft Hub Testnet Skale Explorer__](https://staging-utter-unripe-menkar.explorer.staging-v3.skalenodes.com/address/0x0000000000000000000000000000000000000000) */ export const wegaDiceGameConfig = { address: wegaDiceGameAddress, abi: wegaDiceGameABI } as const @@ -3420,7 +3440,7 @@ export const wegaDiceGameConfig = { address: wegaDiceGameAddress, abi: wegaDiceG /** * - - * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0x802361100a4772847DBc29BC59F76FD1F186E002) + * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0x1CdB8176Ad8579aE748703f40864BB2E65e68529) * - [__View Contract on Skale Calypso Nft Hub Testnet Skale Explorer__](https://staging-utter-unripe-menkar.explorer.staging-v3.skalenodes.com/address/0x0000000000000000000000000000000000000000) */ export const wegaErc20DummyABI = [ @@ -3617,18 +3637,18 @@ export const wegaErc20DummyABI = [ /** * - - * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0x802361100a4772847DBc29BC59F76FD1F186E002) + * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0x1CdB8176Ad8579aE748703f40864BB2E65e68529) * - [__View Contract on Skale Calypso Nft Hub Testnet Skale Explorer__](https://staging-utter-unripe-menkar.explorer.staging-v3.skalenodes.com/address/0x0000000000000000000000000000000000000000) */ export const wegaErc20DummyAddress = { 1337: "0x5FbDB2315678afecb367f032d93F642f64180aa3", - 80001: "0x802361100a4772847DBc29BC59F76FD1F186E002", + 80001: "0x1CdB8176Ad8579aE748703f40864BB2E65e68529", 344106930: "0x0000000000000000000000000000000000000000" } as const /** * - - * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0x802361100a4772847DBc29BC59F76FD1F186E002) + * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0x1CdB8176Ad8579aE748703f40864BB2E65e68529) * - [__View Contract on Skale Calypso Nft Hub Testnet Skale Explorer__](https://staging-utter-unripe-menkar.explorer.staging-v3.skalenodes.com/address/0x0000000000000000000000000000000000000000) */ export const wegaErc20DummyConfig = { @@ -3642,7 +3662,7 @@ export const wegaErc20DummyConfig = { /** * - - * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0xCEBc6b24362cA2F4fA625d340BeF8Af4F91DB5bB) + * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0x4B4e9126b1701385dc5b0D02b12360635D57F12C) * - [__View Contract on Skale Calypso Nft Hub Testnet Skale Explorer__](https://staging-utter-unripe-menkar.explorer.staging-v3.skalenodes.com/address/0x0000000000000000000000000000000000000000) */ export const wegaErc20EscrowABI = [ @@ -3924,6 +3944,19 @@ export const wegaErc20EscrowABI = [ name: "depositOf", outputs: [{ name: "", internalType: "uint256", type: "uint256" }] }, + { + stateMutability: "view", + type: "function", + inputs: [ + { name: "escrowHash", internalType: "bytes32", type: "bytes32" }, + { name: "account", internalType: "address", type: "address" } + ], + name: "getClaimAmount", + outputs: [ + { name: "feeAmount", internalType: "uint256", type: "uint256" }, + { name: "claimAmount", internalType: "uint256", type: "uint256" } + ] + }, { stateMutability: "view", type: "function", @@ -4156,18 +4189,18 @@ export const wegaErc20EscrowABI = [ /** * - - * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0xCEBc6b24362cA2F4fA625d340BeF8Af4F91DB5bB) + * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0x4B4e9126b1701385dc5b0D02b12360635D57F12C) * - [__View Contract on Skale Calypso Nft Hub Testnet Skale Explorer__](https://staging-utter-unripe-menkar.explorer.staging-v3.skalenodes.com/address/0x0000000000000000000000000000000000000000) */ export const wegaErc20EscrowAddress = { 1337: "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707", - 80001: "0xCEBc6b24362cA2F4fA625d340BeF8Af4F91DB5bB", + 80001: "0x4B4e9126b1701385dc5b0D02b12360635D57F12C", 344106930: "0x0000000000000000000000000000000000000000" } as const /** * - - * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0xCEBc6b24362cA2F4fA625d340BeF8Af4F91DB5bB) + * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0x4B4e9126b1701385dc5b0D02b12360635D57F12C) * - [__View Contract on Skale Calypso Nft Hub Testnet Skale Explorer__](https://staging-utter-unripe-menkar.explorer.staging-v3.skalenodes.com/address/0x0000000000000000000000000000000000000000) */ export const wegaErc20EscrowConfig = { @@ -4617,7 +4650,7 @@ export const wegaFeeAdminRoleABI = [ /** * - - * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0xe4da6EE02D91b7C03DB000B9295A815D6BEeC4ca) + * - [__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 wegaGameControllerABI = [ @@ -5175,18 +5208,18 @@ export const wegaGameControllerABI = [ /** * - - * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0xe4da6EE02D91b7C03DB000B9295A815D6BEeC4ca) + * - [__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 = { 1337: "0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE", - 80001: "0xe4da6EE02D91b7C03DB000B9295A815D6BEeC4ca", + 80001: "0x39e851282C11AefE20B149F4509702B2DC8aEB73", 344106930: "0x0000000000000000000000000000000000000000" } as const /** * - - * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0xe4da6EE02D91b7C03DB000B9295A815D6BEeC4ca) + * - [__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 wegaGameControllerConfig = { @@ -5762,7 +5795,7 @@ export const wegaRandomizerConfig = { /** * - - * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0xcd44090c1BC8DC05298540488ca6FA058d27Ac70) + * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0xC757438A9eF34020FEBB7E25336e4eC20dE55fD1) * - [__View Contract on Skale Calypso Nft Hub Testnet Skale Explorer__](https://staging-utter-unripe-menkar.explorer.staging-v3.skalenodes.com/address/0x0000000000000000000000000000000000000000) */ export const wegaRandomizerControllerABI = [ @@ -6105,18 +6138,18 @@ export const wegaRandomizerControllerABI = [ /** * - - * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0xcd44090c1BC8DC05298540488ca6FA058d27Ac70) + * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0xC757438A9eF34020FEBB7E25336e4eC20dE55fD1) * - [__View Contract on Skale Calypso Nft Hub Testnet Skale Explorer__](https://staging-utter-unripe-menkar.explorer.staging-v3.skalenodes.com/address/0x0000000000000000000000000000000000000000) */ export const wegaRandomizerControllerAddress = { 1337: "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6", - 80001: "0xcd44090c1BC8DC05298540488ca6FA058d27Ac70", + 80001: "0xC757438A9eF34020FEBB7E25336e4eC20dE55fD1", 344106930: "0x0000000000000000000000000000000000000000" } as const /** * - - * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0xcd44090c1BC8DC05298540488ca6FA058d27Ac70) + * - [__View Contract on Polygon Mumbai Polygon Scan__](https://mumbai.polygonscan.com/address/0xC757438A9eF34020FEBB7E25336e4eC20dE55fD1) * - [__View Contract on Skale Calypso Nft Hub Testnet Skale Explorer__](https://staging-utter-unripe-menkar.explorer.staging-v3.skalenodes.com/address/0x0000000000000000000000000000000000000000) */ export const wegaRandomizerControllerConfig = { diff --git a/src/utils/errors.ts b/src/utils/errors.ts new file mode 100644 index 0000000..47539fb --- /dev/null +++ b/src/utils/errors.ts @@ -0,0 +1,10 @@ +export function handleError(error: any, customMessage: string){ + if (error.message){ + if(error.message.split("\n\n") && error.message.split("\n\n").length > 0) { + return error.message.split("\n\n")[0]; + } + return error.message + } else { + return customMessage; + } +} \ No newline at end of file diff --git a/src/utils/index.ts b/src/utils/index.ts index b6c6484..e9aa87d 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -16,7 +16,8 @@ export { wegaErc20DummyConfig as tokenConfig, wegaErc20EscrowConfig as escrowConfig, wegaGameControllerConfig as gameControllerConfig, - wegaRandomizerControllerConfig as randomizerControllerConfig + wegaRandomizerControllerConfig as randomizerControllerConfig, + feeManagerConfig } from './abis.ts' export { wegaErc20DummyConfig,