Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
qtumweiyu committed Sep 11, 2019
1 parent 993dd20 commit aa0e3e1
Show file tree
Hide file tree
Showing 3 changed files with 218 additions and 194 deletions.
125 changes: 67 additions & 58 deletions src/controllers/CreateContract.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
v-model.trim="code"
multiLine
required
></v-text-field>
<a href="https://ethereum.github.io/browser-solidity/" target="_blank" style="float: right;">{{ $t('create_contract.compiler') }}</a>
></v-text-field>
<a href="https://ethereum.github.io/browser-solidity/" target="_blank"
style="float: right;">{{ $t('create_contract.compiler') }}</a>
<v-text-field
label="Gas Price (1e-8 QTUM/gas)"
v-model.trim="gasPrice"
Expand All @@ -26,7 +27,7 @@
label="Fee"
v-model.trim="fee"
required
></v-text-field>
></v-text-field>
</v-form>
</v-card-text>
<v-card-actions>
Expand All @@ -51,8 +52,12 @@
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn class="blue--text darken-1" flat @click="confirmSend" v-show="canSend && !sending">{{ $t('common.confirm') }}</v-btn>
<v-btn class="red--text darken-1" flat @click.native="confirmSendDialog = false" :v-show="!sending">{{ $t('common.cancel') }}</v-btn>
<v-btn class="blue--text darken-1" flat @click="confirmSend" v-show="canSend && !sending">
{{ $t('common.confirm') }}
</v-btn>
<v-btn class="red--text darken-1" flat @click.native="confirmSendDialog = false" :v-show="!sending">
{{ $t('common.cancel') }}
</v-btn>
<v-progress-circular indeterminate :size="50" v-show="sending" class="primary--text"></v-progress-circular>
</v-card-actions>
</v-card>
Expand All @@ -61,62 +66,66 @@
</template>

<script>
import webWallet from 'libs/web-wallet'
import server from 'libs/server'
import webWallet from 'libs/web-wallet'
import server from 'libs/server'
export default {
data () {
return {
code: '',
gasPrice: '40',
gasLimit: '2500000',
fee: '0.01',
confirmSendDialog: false,
rawTx: 'loading...',
canSend: false,
sending: false
}
},
computed: {
notValid: function() {
//@todo valid the address
const gasPriceCheck = /^\d+\.?\d*$/.test(this.gasPrice) && this.gasPrice > 0
const gasLimitCheck = /^\d+\.?\d*$/.test(this.gasLimit) && this.gasLimit > 0
const feeCheck = /^\d+\.?\d*$/.test(this.fee) && this.fee > 0.0001
return !(gasPriceCheck && gasLimitCheck && feeCheck)
}
},
methods: {
async send() {
this.confirmSendDialog = true
const wallet = webWallet.getWallet()
try {
this.rawTx = await wallet.generateCreateContractTx(this.code, this.gasLimit, this.gasPrice, this.fee)
this.canSend = true
} catch (e) {
alert(e.message || e)
this.$root.log.error('create_contract_generate_error', e.stack || e.toString() || e)
this.confirmSendDialog = false
return false
export default {
data() {
return {
code: '',
gasPrice: '40',
gasLimit: '2500000',
fee: '0.01',
confirmSendDialog: false,
rawTx: 'loading...',
canSend: false,
sending: false,
}
},
computed: {
notValid: function () {
//@todo valid the address
const gasPriceCheck = /^\d+\.?\d*$/.test(this.gasPrice) && this.gasPrice > 0
const gasLimitCheck = /^\d+\.?\d*$/.test(this.gasLimit) && this.gasLimit > 0
const feeCheck = /^\d+\.?\d*$/.test(this.fee) && this.fee > 0.0001
return !(gasPriceCheck && gasLimitCheck && feeCheck)
},
},
methods: {
async send() {
this.confirmSendDialog = true
const wallet = webWallet.getWallet()
try {
this.rawTx = await wallet.generateCreateContractTx(this.code, this.gasLimit, this.gasPrice, this.fee)
this.canSend = true
} catch (e) {
alert(e.message || e)
this.$root.log.error('create_contract_generate_error', e.stack || e.toString() || e)
this.confirmSendDialog = false
return false
}
},
async confirmSend() {
const wallet = webWallet.getWallet()
this.sending = true
try {
const txId = await wallet.sendRawTx(this.rawTx)
this.confirmSendDialog = false
this.sending = false
const txViewUrl = server.currentNode().getTxExplorerUrl(txId)
this.$root.success(`Successful send. You can view at <a href="${txViewUrl}" target="_blank">${txViewUrl}</a>`, true, 0)
this.$emit('send')
} catch (e) {
alert(e.message || e)
this.$root.log.error('create_contract_post_raw_tx_error', e.response || e.stack || e.toString() || e)
this.confirmSendDialog = false
}
}
async confirmSend() {
const wallet = webWallet.getWallet()
this.sending = true
try {
const res = await wallet.sendRawTx(this.rawTx)
this.confirmSendDialog = false
this.sending = false
if (res.txId) {
const txViewUrl = server.currentNode().getTxExplorerUrl(res.txId)
this.$root.success(`Successful send. You can view at <a href="${txViewUrl}" target="_blank">${txViewUrl}</a>`, true, 0)
} else {
this.$root.error(`Send Failed : ${res.message}`, true, 0)
}
this.$emit('send')
} catch (e) {
alert(e.message || e)
this.$root.log.error('create_contract_post_raw_tx_error', e.response || e.stack || e.toString() || e)
this.confirmSendDialog = false
}
},
},
}
}
</script>
10 changes: 7 additions & 3 deletions src/controllers/CreateToken.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,15 @@ export default {
const wallet = webWallet.getWallet()
this.sending = true
try {
const txId = await wallet.sendRawTx(this.rawTx)
const res = await wallet.sendRawTx(this.rawTx)
this.confirmSendDialog = false
this.sending = false
const txViewUrl = server.currentNode().getTxExplorerUrl(txId)
this.$root.success(`Successful send. You can view at <a href="${txViewUrl}" target="_blank">${txViewUrl}</a>`, true, 0)
if (res.txId) {
const txViewUrl = server.currentNode().getTxExplorerUrl(res.txId)
this.$root.success(`Successful send. You can view at <a href="${txViewUrl}" target="_blank">${txViewUrl}</a>`, true, 0)
} else {
this.$root.error(`Send Failed : ${res.message}`, true, 0)
}
this.$emit('send')
} catch (e) {
alert(e.message || e)
Expand Down
Loading

0 comments on commit aa0e3e1

Please sign in to comment.