adding stuff back

master
lza_menace 2 years ago
parent 055de1c1db
commit be4b71652d

@ -125,44 +125,6 @@
"stateMutability": "view", "stateMutability": "view",
"type": "function" "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": [ "inputs": [
{ {

@ -138,7 +138,7 @@
background-color: rgba(0,0,0,.6); background-color: rgba(0,0,0,.6);
padding: 2px; padding: 2px;
border-radius: 4px; border-radius: 4px;
text-align: right; text-align: center;
right: 0; right: 0;
padding: .75em; padding: .75em;
} }

@ -6,6 +6,7 @@ import Slider from 'rc-slider';
import { Parallax } from 'react-parallax'; import { Parallax } from 'react-parallax';
import { animateScroll as scroll } from 'react-scroll' import { animateScroll as scroll } from 'react-scroll'
import { NotificationContainer, NotificationManager } from 'react-notifications'; import { NotificationContainer, NotificationManager } from 'react-notifications';
import { publicProvider } from 'wagmi/providers/public';
import { AwesomeButton } from 'react-awesome-button'; import { AwesomeButton } from 'react-awesome-button';
import Boomer from '../img/unaboomer.png'; import Boomer from '../img/unaboomer.png';
@ -165,12 +166,12 @@ class GameMap extends React.Component {
<img src={Boomer} width="50px" /> <img src={Boomer} width="50px" />
<p className="nopad"> <p className="nopad">
Kill Leader:<br /> Kill Leader:<br />
? kills <a href="https://etherscan.io/address/xxx" target="_blank">
{this.shorten(this.props.leaderAddress)}
</a>
</p> </p>
<p className="nopad"> <p className="nopad">
<a href="https://etherscan.io/address/${this.props.killLeader}" target="_blank"> {this.props.leaderKillCount} kills
me
</a>
</p> </p>
</div> </div>
<div className="map"> <div className="map">
@ -197,10 +198,9 @@ function Section3() {
bombSupply: 0, bombSupply: 0,
bombsExploded: 0, bombsExploded: 0,
unaboomersKilled: 0, unaboomersKilled: 0,
leaderboardAddresses: [], leaderboardPointer: 0,
leaderboardAmounts: [], leaderAddress: '',
results: [], leaderKillCount: 0
tokensKilled: []
}); });
const handleStateChange = (obj) =>{ const handleStateChange = (obj) =>{
setOptions(preState => ({...preState , ...obj})) setOptions(preState => ({...preState , ...obj}))
@ -246,10 +246,14 @@ function Section3() {
{ {
...defOpt, ...defOpt,
functionName: 'unaboomersKilled' functionName: 'unaboomersKilled'
},
{
...defOpt,
functionName: 'leaderboardPointer'
} }
], ],
watch: true, watch: true,
cacheTime: 5000, cacheTime: 10_000,
onSuccess(data) { onSuccess(data) {
handleStateChange({ handleStateChange({
unaboomerPrice: data[0].toString(), unaboomerPrice: data[0].toString(),
@ -259,39 +263,36 @@ function Section3() {
unaboomerSupply: data[4].toString(), unaboomerSupply: data[4].toString(),
bombSupply: data[5].toString(), bombSupply: data[5].toString(),
bombsExploded: data[6].toString(), bombsExploded: data[6].toString(),
unaboomersKilled: data[7].toString() unaboomersKilled: data[7].toString(),
leaderboardPointer: data[8].toString(),
}); });
} }
}); });
useContractRead({ useContractRead({
address: contractAddress, address: contractAddress,
abi: MainABI, abi: MainABI,
enabled: options.unaboomersKilled > 0, enabled: options.leaderboardPointer > 0,
functionName: 'getLeaderboard', functionName: 'leaderboard',
args: [5], args: [options.leaderboardPointer],
watch: true, watch: true,
cacheTime: 10_000, cacheTime: 10_000,
onSuccess(data) { onSuccess: async (data) => {
console.log('get lb addresses')
console.log(data);
handleStateChange({ handleStateChange({
leaderboardAddresses: data, leaderAddress: data,
}); });
} }
}); });
useContractRead({ useContractRead({
address: contractAddress, address: contractAddress,
abi: MainABI, abi: MainABI,
enabled: options.leaderboardAddresses.length > 0, enabled: options.leaderAddress.length > 0,
functionName: 'getKillCounts', functionName: 'killCount',
args: [options.leaderboardAddresses], args: [options.leaderAddress],
watch: true, watch: true,
cacheTime: 10_000, cacheTime: 10_000,
onSuccess(data) { onSuccess(data) {
console.log('get kill counts')
console.log(data);
handleStateChange({ handleStateChange({
leaderboardAmounts: data, leaderKillCount: data.toString(),
}); });
} }
}); });
@ -332,7 +333,7 @@ function Section3() {
const sendBombsWrite = useContractWrite(sendBombsPrepare.config); const sendBombsWrite = useContractWrite(sendBombsPrepare.config);
useWaitForTransaction({ useWaitForTransaction({
hash: sendBombsWrite.data?.hash, hash: sendBombsWrite.data?.hash,
enabled: sendBombsWrite.isSuccess, enabled: sendBombsWrite.status === 'success',
onSuccess(data) { onSuccess(data) {
const iface = new ethers.utils.Interface(MainABI); const iface = new ethers.utils.Interface(MainABI);
data.logs.filter(log => data.logs.filter(log =>
@ -401,8 +402,8 @@ function Section3() {
bombsExploded={options.bombsExploded} bombsExploded={options.bombsExploded}
unaboomerSupply={options.unaboomerSupply} unaboomerSupply={options.unaboomerSupply}
unaboomersKilled={options.unaboomersKilled} unaboomersKilled={options.unaboomersKilled}
killLeader={options.killLeader} leaderAddress={options.leaderAddress}
killLeaderCount={options.killLeaderCount} leaderKillCount={options.leaderKillCount}
/> />
</> </>
|| ||

Loading…
Cancel
Save