Fix errors thrown on /send-transaction by adding a query string to the url (#291)
Fix errors thrown on /send-transaction by adding a query string to the url
This commit is contained in:
parent
b61056f172
commit
804f986cb5
|
@ -155,8 +155,8 @@ export class SendTransaction extends React.Component<Props, State> {
|
||||||
// TODO listen to gas price changes here
|
// TODO listen to gas price changes here
|
||||||
// TODO debounce the call
|
// TODO debounce the call
|
||||||
// handle gas estimation
|
// handle gas estimation
|
||||||
// if any relevant fields changed
|
|
||||||
return (
|
return (
|
||||||
|
// if any relevant fields changed
|
||||||
this.haveFieldsChanged(prevState) &&
|
this.haveFieldsChanged(prevState) &&
|
||||||
// if gas has not changed
|
// if gas has not changed
|
||||||
!this.state.gasChanged &&
|
!this.state.gasChanged &&
|
||||||
|
@ -215,7 +215,7 @@ export class SendTransaction extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public handleWalletStateOnUpdate(prevProps) {
|
public handleWalletStateOnUpdate(prevProps) {
|
||||||
if (this.props.wallet !== prevProps.wallet) {
|
if (this.props.wallet !== prevProps.wallet && !!prevProps.wallet) {
|
||||||
this.setState(initialState);
|
this.setState(initialState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -415,15 +415,15 @@ export class SendTransaction extends React.Component<Props, State> {
|
||||||
const query = queryString.parse(searchStr);
|
const query = queryString.parse(searchStr);
|
||||||
const to = getParam(query, 'to');
|
const to = getParam(query, 'to');
|
||||||
const data = getParam(query, 'data');
|
const data = getParam(query, 'data');
|
||||||
// FIXME validate token against presets
|
|
||||||
const unit = getParam(query, 'tokenSymbol');
|
const unit = getParam(query, 'tokenSymbol');
|
||||||
|
const token = this.props.tokens.find(x => x.symbol === unit);
|
||||||
const value = getParam(query, 'value');
|
const value = getParam(query, 'value');
|
||||||
let gasLimit = getParam(query, 'gas');
|
let gasLimit = getParam(query, 'gaslimit');
|
||||||
if (gasLimit === null) {
|
if (gasLimit === null) {
|
||||||
gasLimit = getParam(query, 'limit');
|
gasLimit = getParam(query, 'limit');
|
||||||
}
|
}
|
||||||
const readOnly = getParam(query, 'readOnly') != null;
|
const readOnly = getParam(query, 'readOnly') != null;
|
||||||
return { to, data, value, unit, gasLimit, readOnly };
|
return { to, token, data, value, unit, gasLimit, readOnly };
|
||||||
}
|
}
|
||||||
|
|
||||||
public isValidNonce() {
|
public isValidNonce() {
|
||||||
|
@ -488,21 +488,23 @@ export class SendTransaction extends React.Component<Props, State> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (this.props.wallet) {
|
||||||
const cachedFormattedTx = await this.getFormattedTxFromState();
|
try {
|
||||||
// Grab a reference to state. If it has changed by the time the estimateGas
|
const cachedFormattedTx = await this.getFormattedTxFromState();
|
||||||
// call comes back, we don't want to replace the gasLimit in state.
|
// Grab a reference to state. If it has changed by the time the estimateGas
|
||||||
const state = this.state;
|
// call comes back, we don't want to replace the gasLimit in state.
|
||||||
gasLimit = await nodeLib.estimateGas(cachedFormattedTx);
|
const state = this.state;
|
||||||
if (this.state === state) {
|
gasLimit = await nodeLib.estimateGas(cachedFormattedTx);
|
||||||
this.setState({ gasLimit: formatGasLimit(gasLimit, state.unit) });
|
if (this.state === state) {
|
||||||
} else {
|
this.setState({ gasLimit: formatGasLimit(gasLimit, state.unit) });
|
||||||
// state has changed, so try again from the start (with the hope that state won't change by the next time)
|
} else {
|
||||||
this.estimateGas();
|
// state has changed, so try again from the start (with the hope that state won't change by the next time)
|
||||||
|
this.estimateGas();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
this.setState({ generateDisabled: true });
|
||||||
|
this.props.showNotification('danger', error.message, 5000);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
this.setState({ generateDisabled: true });
|
|
||||||
this.props.showNotification('danger', error.message, 5000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13437,6 +13437,15 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"types-rlp": {
|
||||||
|
"version": "0.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/types-rlp/-/types-rlp-0.0.1.tgz",
|
||||||
|
"integrity": "sha512-UUn2x3z9aTItExmCg0fqPuaKBzLCt+pbNfxY2kQ4TRB/06QxrVShILANfBEvrVemg7GZqn9qCIMJK6WkWI+izA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"rlp": "2.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"typescript": {
|
"typescript": {
|
||||||
"version": "2.5.2",
|
"version": "2.5.2",
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-2.5.2.tgz",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-2.5.2.tgz",
|
||||||
|
|
Loading…
Reference in New Issue