diff --git a/src/abi/main.json b/src/abi/main.json index ea13fb6..32492a4 100644 --- a/src/abi/main.json +++ b/src/abi/main.json @@ -125,44 +125,6 @@ "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/styles/sections.css b/src/styles/sections.css index 9cfbd5d..b5cd642 100644 --- a/src/styles/sections.css +++ b/src/styles/sections.css @@ -138,7 +138,7 @@ background-color: rgba(0,0,0,.6); padding: 2px; border-radius: 4px; - text-align: right; + text-align: center; right: 0; padding: .75em; } diff --git a/src/template/Sections.jsx b/src/template/Sections.jsx index d53528a..8275c0d 100644 --- a/src/template/Sections.jsx +++ b/src/template/Sections.jsx @@ -6,6 +6,7 @@ import Slider from 'rc-slider'; import { Parallax } from 'react-parallax'; import { animateScroll as scroll } from 'react-scroll' import { NotificationContainer, NotificationManager } from 'react-notifications'; +import { publicProvider } from 'wagmi/providers/public'; import { AwesomeButton } from 'react-awesome-button'; import Boomer from '../img/unaboomer.png'; @@ -165,12 +166,12 @@ class GameMap extends React.Component {

Kill Leader:
- ? kills + + {this.shorten(this.props.leaderAddress)} +

- - me - + {this.props.leaderKillCount} kills

@@ -197,10 +198,9 @@ function Section3() { bombSupply: 0, bombsExploded: 0, unaboomersKilled: 0, - leaderboardAddresses: [], - leaderboardAmounts: [], - results: [], - tokensKilled: [] + leaderboardPointer: 0, + leaderAddress: '', + leaderKillCount: 0 }); const handleStateChange = (obj) =>{ setOptions(preState => ({...preState , ...obj})) @@ -246,10 +246,14 @@ function Section3() { { ...defOpt, functionName: 'unaboomersKilled' + }, + { + ...defOpt, + functionName: 'leaderboardPointer' } ], watch: true, - cacheTime: 5000, + cacheTime: 10_000, onSuccess(data) { handleStateChange({ unaboomerPrice: data[0].toString(), @@ -259,39 +263,36 @@ function Section3() { unaboomerSupply: data[4].toString(), bombSupply: data[5].toString(), bombsExploded: data[6].toString(), - unaboomersKilled: data[7].toString() + unaboomersKilled: data[7].toString(), + leaderboardPointer: data[8].toString(), }); } }); useContractRead({ address: contractAddress, abi: MainABI, - enabled: options.unaboomersKilled > 0, - functionName: 'getLeaderboard', - args: [5], + enabled: options.leaderboardPointer > 0, + functionName: 'leaderboard', + args: [options.leaderboardPointer], watch: true, cacheTime: 10_000, - onSuccess(data) { - console.log('get lb addresses') - console.log(data); + onSuccess: async (data) => { handleStateChange({ - leaderboardAddresses: data, + leaderAddress: data, }); } }); useContractRead({ address: contractAddress, abi: MainABI, - enabled: options.leaderboardAddresses.length > 0, - functionName: 'getKillCounts', - args: [options.leaderboardAddresses], + enabled: options.leaderAddress.length > 0, + functionName: 'killCount', + args: [options.leaderAddress], watch: true, cacheTime: 10_000, onSuccess(data) { - console.log('get kill counts') - console.log(data); handleStateChange({ - leaderboardAmounts: data, + leaderKillCount: data.toString(), }); } }); @@ -332,7 +333,7 @@ function Section3() { const sendBombsWrite = useContractWrite(sendBombsPrepare.config); useWaitForTransaction({ hash: sendBombsWrite.data?.hash, - enabled: sendBombsWrite.isSuccess, + enabled: sendBombsWrite.status === 'success', onSuccess(data) { const iface = new ethers.utils.Interface(MainABI); data.logs.filter(log => @@ -401,8 +402,8 @@ function Section3() { bombsExploded={options.bombsExploded} unaboomerSupply={options.unaboomerSupply} unaboomersKilled={options.unaboomersKilled} - killLeader={options.killLeader} - killLeaderCount={options.killLeaderCount} + leaderAddress={options.leaderAddress} + leaderKillCount={options.leaderKillCount} /> ||