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:
James Prado 2017-10-18 19:49:10 -04:00 committed by Daniel Ternyak
parent b61056f172
commit 804f986cb5
2 changed files with 30 additions and 19 deletions

View File

@ -155,8 +155,8 @@ export class SendTransaction extends React.Component<Props, State> {
// TODO listen to gas price changes here
// TODO debounce the call
// handle gas estimation
// if any relevant fields changed
return (
// if any relevant fields changed
this.haveFieldsChanged(prevState) &&
// if gas has not changed
!this.state.gasChanged &&
@ -215,7 +215,7 @@ export class SendTransaction extends React.Component<Props, State> {
}
public handleWalletStateOnUpdate(prevProps) {
if (this.props.wallet !== prevProps.wallet) {
if (this.props.wallet !== prevProps.wallet && !!prevProps.wallet) {
this.setState(initialState);
}
}
@ -415,15 +415,15 @@ export class SendTransaction extends React.Component<Props, State> {
const query = queryString.parse(searchStr);
const to = getParam(query, 'to');
const data = getParam(query, 'data');
// FIXME validate token against presets
const unit = getParam(query, 'tokenSymbol');
const token = this.props.tokens.find(x => x.symbol === unit);
const value = getParam(query, 'value');
let gasLimit = getParam(query, 'gas');
let gasLimit = getParam(query, 'gaslimit');
if (gasLimit === null) {
gasLimit = getParam(query, 'limit');
}
const readOnly = getParam(query, 'readOnly') != null;
return { to, data, value, unit, gasLimit, readOnly };
return { to, token, data, value, unit, gasLimit, readOnly };
}
public isValidNonce() {
@ -488,6 +488,7 @@ export class SendTransaction extends React.Component<Props, State> {
return;
}
if (this.props.wallet) {
try {
const cachedFormattedTx = await this.getFormattedTxFromState();
// Grab a reference to state. If it has changed by the time the estimateGas
@ -505,6 +506,7 @@ export class SendTransaction extends React.Component<Props, State> {
this.props.showNotification('danger', error.message, 5000);
}
}
}
public onAddressChange = (value: string) => {
this.setState({

9
package-lock.json generated
View File

@ -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": {
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-2.5.2.tgz",