diff --git a/src/abi/main.json b/src/abi/main.json index 32492a4..ea13fb6 100644 --- a/src/abi/main.json +++ b/src/abi/main.json @@ -125,6 +125,44 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "addresses", + "type": "address[]" + } + ], + "name": "getKillCounts", + "outputs": [ + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "getLeaderboard", + "outputs": [ + { + "internalType": "address[]", + "name": "addresses", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { diff --git a/src/template/Sections.jsx b/src/template/Sections.jsx index d684abb..d53528a 100644 --- a/src/template/Sections.jsx +++ b/src/template/Sections.jsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { ethers, BigNumber } from 'ethers'; -import { useAccount, useContractReads, usePrepareContractWrite, useContractWrite, useWaitForTransaction } from 'wagmi'; +import { useAccount, useContractReads, useContractRead, usePrepareContractWrite, useContractWrite, useWaitForTransaction } from 'wagmi'; import Typewriter from 'react-ts-typewriter'; import Slider from 'rc-slider'; import { Parallax } from 'react-parallax'; @@ -165,11 +165,11 @@ class GameMap extends React.Component {

Kill Leader:
- {this.props.killLeaderCount} kills + ? kills

- {this.shorten(this.props.killLeader)} + me

@@ -197,9 +197,8 @@ function Section3() { bombSupply: 0, bombsExploded: 0, unaboomersKilled: 0, - leaderboardPointer: 0, - killLeader: '', - killLeaderCount: 0, + leaderboardAddresses: [], + leaderboardAmounts: [], results: [], tokensKilled: [] }); @@ -247,10 +246,6 @@ function Section3() { { ...defOpt, functionName: 'unaboomersKilled' - }, - { - ...defOpt, - functionName: 'leaderboardPointer' } ], watch: true, @@ -264,42 +259,39 @@ function Section3() { unaboomerSupply: data[4].toString(), bombSupply: data[5].toString(), bombsExploded: data[6].toString(), - unaboomersKilled: data[7].toString(), - leaderboardPointer: data[8].toString() + unaboomersKilled: data[7].toString() }); } }); - useContractReads({ - contracts: [ - { - ...defOpt, - enabled: options.leaderboardPointer > 0, - functionName: 'leaderboard', - args: [options.leaderboardPointer] - } - ], + useContractRead({ + address: contractAddress, + abi: MainABI, + enabled: options.unaboomersKilled > 0, + functionName: 'getLeaderboard', + args: [5], watch: true, - cacheTime: 10000, + cacheTime: 10_000, onSuccess(data) { + console.log('get lb addresses') + console.log(data); handleStateChange({ - killLeader: data[0].toString(), + leaderboardAddresses: data, }); } }); - useContractReads({ - contracts: [ - { - ...defOpt, - enabled: options.killLeader.length > 0, - functionName: 'killCount', - args: [options.killLeader] - } - ], + useContractRead({ + address: contractAddress, + abi: MainABI, + enabled: options.leaderboardAddresses.length > 0, + functionName: 'getKillCounts', + args: [options.leaderboardAddresses], watch: true, - cacheTime: 10000, + cacheTime: 10_000, onSuccess(data) { + console.log('get kill counts') + console.log(data); handleStateChange({ - killLeaderCount: data[0].toString(), + leaderboardAmounts: data, }); } }); @@ -332,7 +324,10 @@ function Section3() { abi: MainABI, enabled: isConnected && options.bombBalance > 0, functionName: 'sendBombs', - args: [options.sendBombAmount] + args: [options.sendBombAmount], + onError(err) { + console.log(err); + } }); const sendBombsWrite = useContractWrite(sendBombsPrepare.config); useWaitForTransaction({