OSDN Git Service

disable submittion when estimate gas fail v1.0.0
authorYongfeng LI <wliyongfeng@gmail.com>
Sat, 21 Apr 2018 04:48:15 +0000 (12:48 +0800)
committerYongfeng LI <wliyongfeng@gmail.com>
Sat, 21 Apr 2018 04:48:15 +0000 (12:48 +0800)
src/features/transactions/components/New/New.jsx

index 95b75a6..97b2078 100644 (file)
@@ -129,6 +129,10 @@ class Form extends React.Component {
   }
 
   disableSubmit(actions, normalTransaction) {
+    if (!this.state.showAdvanceTx) {
+      return !this.state.estimateGas
+    }
+
     if (this.state.showAdvanceTx) {
       return actions.length == 0 && !this.state.showAdvanced
     }
@@ -217,6 +221,7 @@ class Form extends React.Component {
     const body = {actions, ttl: 1}
     this.connection.request('/build-transaction', body).then(resp => {
       if (resp.status === 'fail') {
+        this.setState({estimateGas: null})
         this.props.showError(new Error(resp.msg))
         return
       }
@@ -225,6 +230,7 @@ class Form extends React.Component {
         transactionTemplate: resp.data
       }).then(resp => {
         if (resp.status === 'fail') {
+          this.setState({estimateGas: null})
           this.props.showError(new Error(resp.msg))
           return
         }