Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
abi,
contractAddress,
method: selectedFunction,
gasPrice,
gasLimit
})},`,
...args,
")"
);
try {
// TODO(tian): what if multiple values returned?
const result = await antenna.iotx.readContractByMethod(
{
from: fromAddress,
amount: toRau(amount, "Iotx"),
abi,
contractAddress,
method: selectedFunction,
gasPrice,
gasLimit
},
...args
);
window.console.log(
`readContractByMethod result=${JSON.stringify(result)}`
);
this.setState({ outputValues: [].concat(result) });
} catch (e) {
notification.error({
message: e.message
});
const {
recipient,
amount,
gasLimit,
gasPrice,
symbol,
dataInHex
} = form.getFieldsValue();
const tokenSymbol = symbol === "iotx" ? "IOTX" : tokens[symbol].symbol;
const dataSource: { [index: string]: string } = {
address: address,
toAddress: recipient,
amount: `${new BigNumber(amount).toString()} ${tokenSymbol}`,
limit: gasLimit,
price: `${toRau(gasPrice, "Qev")} (${gasPrice} Qev)`
};
if (tokenSymbol.match(/iotx/i)) {
dataSource.dataInHex = `${dataInHex || " "}`; // Fix undefined and always display Data field in modal if it is needed.
}
return (
);
};
return this.setState({
showConfirmTransfer: false
});
}
const {
recipient,
amount,
gasLimit,
gasPrice,
dataInHex,
symbol
} = value;
const customToken = symbol.match(/iotx/) ? null : Token.getToken(symbol);
const price = gasPrice ? toRau(gasPrice, "Qev") : undefined;
this.setState({ sending: true, showConfirmTransfer: false });
let txHash = "";
if (!customToken) {
window.console.log(
`antenna.iotx.sendTransfer(${JSON.stringify({
from: address,
to: recipient,
value: toRau(amount, "Iotx"),
payload: dataInHex,
gasLimit: gasLimit || undefined,
gasPrice: price
})})`
);
try {
txHash = await antenna.iotx.sendTransfer({
this.props.form.validateFields(async (err, values) => {
if (err) {
return;
}
const {
contractAddress,
amount,
gasPrice,
gasLimit,
abi,
selectedFunction,
args
} = values;
const price = gasPrice ? toRau(gasPrice, "Qev") : undefined;
window.console.log(
`antenna.iotx.executeContract(${JSON.stringify({
from: fromAddress,
amount,
abi,
contractAddress,
method: selectedFunction,
gasPrice: price,
gasLimit
})},`,
...(args || []),
")"
);
try {
if (!customToken) {
window.console.log(
`antenna.iotx.sendTransfer(${JSON.stringify({
from: address,
to: recipient,
value: toRau(amount, "Iotx"),
payload: dataInHex,
gasLimit: gasLimit || undefined,
gasPrice: price
})})`
);
try {
txHash = await antenna.iotx.sendTransfer({
from: address,
to: recipient,
value: toRau(amount, "Iotx"),
payload: dataInHex,
gasLimit: gasLimit || undefined,
gasPrice: price
});
} catch (error) {
notification.error({
message: `${error.message}`,
duration: 3
});
}
} else {
const tokenInfo = tokens[symbol];
const tokenAmount = new BigNumber(amount).multipliedBy(
new BigNumber(`1e${tokenInfo.decimals.toNumber()}`)
);
const gasPriceRau = toRau(gasPrice, "Qev");
public updateGasCostLimit = (form: WrappedFormUtils) => {
const { gasLimit, gasPrice } = form.getFieldsValue();
const gasCostLimit = fromRau(
`${Number(toRau(gasPrice, "Qev")) * gasLimit}`,
"IoTx"
);
this.setState({ gasCostLimit });
};
public renderConfirmation = () => {
const { form, address } = this.props;
const { showConfirmation } = this.state;
const { byteCode, gasLimit, gasPrice, amount } = form.getFieldsValue();
const dataSource = {
address: address,
data: byteCode,
amount: `${Number(amount).toLocaleString()} IOTX`,
price: toRau(gasPrice, "Qev"),
limit: gasLimit
};
return (
);
};
public confirmTransfer = () => {
const { address, form } = this.props;
const { showConfirmTransfer } = this.state;
const { recipient, amount, gasLimit, gasPrice } = form.getFieldsValue();
const dataSource = {
address: address,
toAddress: recipient,
amount: toRau(amount, "Iotx"),
limit: gasLimit,
price: toRau(gasPrice, "Qev")
};
return (
);
};
public confirmTransfer = () => {
const { address, form } = this.props;
const { showConfirmTransfer } = this.state;
const { recipient, amount, gasLimit, gasPrice } = form.getFieldsValue();
const dataSource = {
address: address,
toAddress: recipient,
amount: toRau(amount, "Iotx"),
limit: gasLimit,
price: toRau(gasPrice, "Qev")
};
return (
);
};
transform: (value: string) => {
return new BigNumber(toRau(value, "IoTx"));
},
validator: async (_, value: BigNumber, callback) => {