|
|
|
@ -16,7 +16,8 @@ import { toaster } from "src/App"; |
|
|
|
|
import { breakpoints } from "../../Responive/breakpoints"; |
|
|
|
|
import { useMediaQuery } from "react-responsive"; |
|
|
|
|
import { useHistory } from "react-router"; |
|
|
|
|
import { getQueryVariable } from "../../utils"; |
|
|
|
|
import { getAddress, getQueryVariable } from "../../utils"; |
|
|
|
|
import { getContractsByField, getTransactionByField } from "../../api/client"; |
|
|
|
|
|
|
|
|
|
const Field = styled(Box)``; |
|
|
|
|
|
|
|
|
@ -53,10 +54,49 @@ class VerifyContractBase extends React.Component< |
|
|
|
|
constructorArguments: "", |
|
|
|
|
contractName: "", |
|
|
|
|
isLoading: false, |
|
|
|
|
argsLoading: false, |
|
|
|
|
statusText: "", |
|
|
|
|
error: "", |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
getBytecode = async () => { |
|
|
|
|
this.setState({ ...this.state, argsLoading: true }); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
if (this.state.contractAddress) { |
|
|
|
|
const address = getAddress(this.state.contractAddress).basicHex; |
|
|
|
|
|
|
|
|
|
const contracts: any = await getContractsByField([ |
|
|
|
|
0, |
|
|
|
|
"address", |
|
|
|
|
address, |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
if (contracts?.transactionHash) { |
|
|
|
|
const trx = await getTransactionByField([ |
|
|
|
|
0, |
|
|
|
|
"hash", |
|
|
|
|
contracts.transactionHash, |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
if (trx?.input) { |
|
|
|
|
const argStart = trx.input.lastIndexOf("0033"); |
|
|
|
|
if (argStart) { |
|
|
|
|
this.setState({ |
|
|
|
|
...this.state, |
|
|
|
|
constructorArguments: trx.input.slice(argStart + 4), |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (e) { |
|
|
|
|
console.error(e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.setState({ ...this.state, argsLoading: false }); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
onClickSubmitBtn = async () => { |
|
|
|
|
this.setState({ |
|
|
|
|
...this.state, |
|
|
|
@ -200,7 +240,24 @@ class VerifyContractBase extends React.Component< |
|
|
|
|
</Field> |
|
|
|
|
|
|
|
|
|
<Field margin={"small"}> |
|
|
|
|
<Text>Constructor Arguments (ABI-encoded)</Text> |
|
|
|
|
<Box direction="row" justify="between"> |
|
|
|
|
<Box> |
|
|
|
|
<Text>Constructor Arguments (ABI-encoded)</Text> |
|
|
|
|
</Box> |
|
|
|
|
{this.state.argsLoading ? ( |
|
|
|
|
<Box |
|
|
|
|
style={{ width: "120px" }} |
|
|
|
|
direction="row" |
|
|
|
|
justify="center" |
|
|
|
|
> |
|
|
|
|
<Spinner size={"xsmall"} /> |
|
|
|
|
</Box> |
|
|
|
|
) : ( |
|
|
|
|
<Box onClick={() => this.getBytecode()}> |
|
|
|
|
<Text color="#00AEE9">paste arguments from tx input</Text> |
|
|
|
|
</Box> |
|
|
|
|
)} |
|
|
|
|
</Box> |
|
|
|
|
<TextArea |
|
|
|
|
style={{ minHeight: "80px", height: "80px" }} |
|
|
|
|
onChange={(evt: React.ChangeEvent<HTMLTextAreaElement>) => { |
|
|
|
@ -209,7 +266,7 @@ class VerifyContractBase extends React.Component< |
|
|
|
|
constructorArguments: evt.currentTarget.value, |
|
|
|
|
}); |
|
|
|
|
}} |
|
|
|
|
disabled={isLoading} |
|
|
|
|
disabled={isLoading || this.state.argsLoading} |
|
|
|
|
value={this.state.constructorArguments} |
|
|
|
|
/> |
|
|
|
|
</Field> |
|
|
|
|