|
|
|
@ -1,11 +1,11 @@
|
|
|
|
|
import React, { useState } from 'react';
|
|
|
|
|
import { ethers, BigNumber } from 'ethers';
|
|
|
|
|
import { useAccount, useContractReads, usePrepareContractWrite, useContractWrite, useTransaction } from 'wagmi';
|
|
|
|
|
import { useAccount, useContractReads, usePrepareContractWrite, useContractWrite, useWaitForTransaction } from 'wagmi';
|
|
|
|
|
import Typewriter from 'react-ts-typewriter';
|
|
|
|
|
import Slider from 'rc-slider';
|
|
|
|
|
import { Parallax } from 'react-parallax';
|
|
|
|
|
import { animateScroll as scroll } from 'react-scroll'
|
|
|
|
|
|
|
|
|
|
import { NotificationContainer, NotificationManager } from 'react-notifications';
|
|
|
|
|
|
|
|
|
|
import { AwesomeButton } from 'react-awesome-button';
|
|
|
|
|
import Boomer from '../img/unaboomer.png';
|
|
|
|
@ -16,6 +16,7 @@ import SeizedItems from '../img/seizeditems.png';
|
|
|
|
|
import Map from '../img/map.png';
|
|
|
|
|
import MainABI from '../abi/main.json';
|
|
|
|
|
|
|
|
|
|
import 'react-notifications/lib/notifications.css';
|
|
|
|
|
import 'rc-slider/assets/index.css';
|
|
|
|
|
import '../styles/sections.css';
|
|
|
|
|
|
|
|
|
@ -48,8 +49,8 @@ export class Section1 extends React.Component {
|
|
|
|
|
<h1 id="heroText">
|
|
|
|
|
<Typewriter text={this.state.title} cursor={true} random={20} />
|
|
|
|
|
</h1>
|
|
|
|
|
<img src={Boomer} id="heroImage" className={this.state.showImage || "hidden"} alt="Pixelated police sketch of the Unabomber suspect." />
|
|
|
|
|
<div className={this.state.showImage || "hidden" }>
|
|
|
|
|
<img src={Boomer} id="heroImage" className={!this.state.showImage ? "hidden": "" } alt="Pixelated police sketch of the Unabomber suspect." />
|
|
|
|
|
<div className={!this.state.showImage ? "hidden": "" }>
|
|
|
|
|
<AwesomeButton type="secondary" ripple={true} onPress={() => scroll.scrollTo(window.scrollMaxY - '450', {duration: 5000})} className="fadeIn">
|
|
|
|
|
continue
|
|
|
|
|
</AwesomeButton>
|
|
|
|
@ -242,7 +243,7 @@ function Section3() {
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
watch: true,
|
|
|
|
|
cacheTime: 5,
|
|
|
|
|
cacheTime: 5000,
|
|
|
|
|
onSuccess(data) {
|
|
|
|
|
handleStateChange({
|
|
|
|
|
unaboomerPrice: data[0].toString(),
|
|
|
|
@ -283,22 +284,34 @@ function Section3() {
|
|
|
|
|
const sendBombsPrepare = usePrepareContractWrite({
|
|
|
|
|
address: contractAddress,
|
|
|
|
|
abi: MainABI,
|
|
|
|
|
enabled: isConnected,
|
|
|
|
|
enabled: isConnected && options.bombBalance > 0,
|
|
|
|
|
functionName: 'sendBombs',
|
|
|
|
|
args: [options.sendBombAmount]
|
|
|
|
|
});
|
|
|
|
|
const sendBombsWrite = useContractWrite(sendBombsPrepare.config);
|
|
|
|
|
const { data: tx } = useTransaction({ ...sendBombsWrite.data, enabled: sendBombsWrite.isSuccess });
|
|
|
|
|
if (tx) {
|
|
|
|
|
// let r;
|
|
|
|
|
useWaitForTransaction({
|
|
|
|
|
hash: sendBombsWrite.data?.hash,
|
|
|
|
|
enabled: sendBombsWrite.isSuccess,
|
|
|
|
|
onSuccess(data) {
|
|
|
|
|
const iface = new ethers.utils.Interface(MainABI);
|
|
|
|
|
console.log(tx)
|
|
|
|
|
// let txRes = iface.decodeFunctionResult("sendBombs", tx.data);
|
|
|
|
|
// console.log(txRes)
|
|
|
|
|
// const {0: results, 1: tokensKilled} = txRes.functionFragment.outputs;
|
|
|
|
|
// console.log(results);
|
|
|
|
|
// console.log(tokensKilled);
|
|
|
|
|
data.logs.filter(log =>
|
|
|
|
|
log.topics[0] === '0x38c7e2e8001cefb27535bd6bcc6363c6d6a6a83dbb77f092b78956334596f9ed'
|
|
|
|
|
).map((log) => {
|
|
|
|
|
const res = iface.decodeEventLog("SentBomb", log.data, log.topics);
|
|
|
|
|
console.log(res);
|
|
|
|
|
if (res.hit) {
|
|
|
|
|
if (res.owned) {
|
|
|
|
|
NotificationManager.error(`Your bomb exploded during assembly and killed your Unaboomer ${res.tokenId.toString()}`, 'oof', 10000);
|
|
|
|
|
} else {
|
|
|
|
|
NotificationManager.success(`Your bomb killed Unaboomer ${res.tokenId.toString()}`, 'Got em!', 10000);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
NotificationManager.warning(`Your bomb for Unaboomer ${res.tokenId.toString()} was a dud`, 'oof', 10000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return (
|
|
|
|
|
<section className="section" id="mintSection">
|
|
|
|
|
{isConnected &&
|
|
|
|
@ -341,6 +354,7 @@ function Section3() {
|
|
|
|
|
<Slider className="slider" min={1} max={30} onChange={(v) => handleStateChange({sendBombAmount: v})} />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<NotificationContainer/>
|
|
|
|
|
<GameMap
|
|
|
|
|
bombSupply={options.bombSupply}
|
|
|
|
|
bombBalance={options.bombBalance}
|
|
|
|
|