diff --git a/src/app/tabs/runTab/contractDropdown.js b/src/app/tabs/runTab/contractDropdown.js
index 7c35e771f5..b6341144ba 100644
--- a/src/app/tabs/runTab/contractDropdown.js
+++ b/src/app/tabs/runTab/contractDropdown.js
@@ -183,6 +183,7 @@ class ContractDropdownUI {
}
const compilerContracts = this.dropdownLogic.getCompilerContracts()
+ const confirmationCb = this.getConfirmationCb(modalDialog, confirmDialog)
if (selectedContract.isOverSizeLimit()) {
return modalDialog('Contract code size over limit', yo`
Contract creation initialization returns data with length of more than 24576 bytes. The deployment will likely fails.
@@ -191,7 +192,7 @@ class ContractDropdownUI {
{
label: 'Force Send',
fn: () => {
- this.dropdownLogic.deployContract(selectedContract, args, contractMetadata, compilerContracts, {continueCb, promptCb, statusCb, finalCb}, {modalDialog, confirmDialog})
+ this.dropdownLogic.deployContract(selectedContract, args, contractMetadata, compilerContracts, {continueCb, promptCb, statusCb, finalCb}, confirmationCb)
}}, {
label: 'Cancel',
fn: () => {
@@ -199,7 +200,38 @@ class ContractDropdownUI {
}
})
}
- this.dropdownLogic.deployContract(selectedContract, args, contractMetadata, compilerContracts, {continueCb, promptCb, statusCb, finalCb}, {modalDialog, confirmDialog})
+ this.dropdownLogic.deployContract(selectedContract, args, contractMetadata, compilerContracts, {continueCb, promptCb, statusCb, finalCb}, confirmationCb)
+ }
+
+ getConfirmationCb (modalDialog, confirmDialog) {
+ const confirmationCb = (network, tx, gasEstimation, continueTxExecution, cancelCb) => {
+ if (network.name !== 'Main') {
+ return continueTxExecution(null)
+ }
+ const amount = this.dropdownLogic.fromWei(tx.value, true, 'ether')
+ const content = confirmDialog(tx, amount, gasEstimation, null, this.dropdownLogic.determineGasFees(tx), this.dropdownLogic.determineGasPrice)
+
+ modalDialog('Confirm transaction', content,
+ { label: 'Confirm',
+ fn: () => {
+ this.config.setUnpersistedProperty('doNotShowTransactionConfirmationAgain', content.querySelector('input#confirmsetting').checked)
+ // TODO: check if this is check is still valid given the refactor
+ if (!content.gasPriceStatus) {
+ cancelCb('Given gas price is not correct')
+ } else {
+ var gasPrice = this.dropdownLogic.toWei(content.querySelector('#gasprice').value, 'gwei')
+ continueTxExecution(gasPrice)
+ }
+ }}, {
+ label: 'Cancel',
+ fn: () => {
+ return cancelCb('Transaction canceled by user.')
+ }
+ }
+ )
+ }
+
+ return confirmationCb
}
loadFromAddress () {
@@ -222,7 +254,6 @@ class ContractDropdownUI {
}
)
}
-
}
module.exports = ContractDropdownUI
diff --git a/src/app/tabs/runTab/model/dropdownlogic.js b/src/app/tabs/runTab/model/dropdownlogic.js
index ca81e4ac2f..524655b6be 100644
--- a/src/app/tabs/runTab/model/dropdownlogic.js
+++ b/src/app/tabs/runTab/model/dropdownlogic.js
@@ -120,14 +120,13 @@ class DropdownLogic {
}
// TODO: check if selectedContract and data can be joined
- createContract (selectedContract, data, continueCb, promptCb, modalDialog, confirmDialog, finalCb) {
+ createContract (selectedContract, data, continueCb, promptCb, confirmationCb, finalCb) {
if (data) {
data.contractName = selectedContract.name
data.linkReferences = selectedContract.bytecodeLinkReferences
data.contractABI = selectedContract.abi
}
- const confirmationCb = this.getConfirmationCb(modalDialog, confirmDialog)
this.udapp.createContract(data, confirmationCb, continueCb, promptCb,
(error, txResult) => {
if (error) {
@@ -184,39 +183,7 @@ class DropdownLogic {
})
}
- getConfirmationCb (modalDialog, confirmDialog) {
- const confirmationCb = (network, tx, gasEstimation, continueTxExecution, cancelCb) => {
- if (network.name !== 'Main') {
- return continueTxExecution(null)
- }
- const amount = this.fromWei(tx.value, true, 'ether')
- const content = confirmDialog(tx, amount, gasEstimation, null, this.determineGasFees(tx), this.determineGasPrice)
-
- modalDialog('Confirm transaction', content,
- { label: 'Confirm',
- fn: () => {
- this.config.setUnpersistedProperty('doNotShowTransactionConfirmationAgain', content.querySelector('input#confirmsetting').checked)
- // TODO: check if this is check is still valid given the refactor
- if (!content.gasPriceStatus) {
- cancelCb('Given gas price is not correct')
- } else {
- var gasPrice = this.toWei(content.querySelector('#gasprice').value, 'gwei')
- continueTxExecution(gasPrice)
- }
- }}, {
- label: 'Cancel',
- fn: () => {
- return cancelCb('Transaction canceled by user.')
- }
- }
- )
- }
-
- return confirmationCb
- }
-
- runTransaction (data, continueCb, promptCb, modalDialog, confirmDialog, finalCb) {
- const confirmationCb = this.getConfirmationCb(modalDialog, confirmDialog)
+ runTransaction (data, continueCb, promptCb, confirmationCb, finalCb) {
this.udapp.runTx(data, confirmationCb, continueCb, promptCb, finalCb)
}
@@ -224,9 +191,8 @@ class DropdownLogic {
return this.compilersArtefacts['__last'].getData().contracts
}
- async deployContract (selectedContract, args, contractMetadata, compilerContracts, callbacks, dialogs) {
+ async deployContract (selectedContract, args, contractMetadata, compilerContracts, callbacks, confirmationCb) {
const {continueCb, promptCb, statusCb, finalCb} = callbacks
- const {modalDialog, confirmDialog} = dialogs
var constructor = selectedContract.getConstructorInterface()
if (!contractMetadata || (contractMetadata && contractMetadata.autoDeployLib)) {
@@ -234,10 +200,10 @@ class DropdownLogic {
if (error) return statusCb(`creation of ${selectedContract.name} errored: ` + error)
statusCb(`creation of ${selectedContract.name} pending...`)
- this.createContract(selectedContract, data, continueCb, promptCb, modalDialog, confirmDialog, finalCb)
+ this.createContract(selectedContract, data, continueCb, promptCb, confirmationCb, finalCb)
}, statusCb, (data, runTxCallback) => {
// called for libraries deployment
- this.runTransaction(data, continueCb, promptCb, modalDialog, confirmDialog, runTxCallback)
+ this.runTransaction(data, continueCb, promptCb, confirmationCb, runTxCallback)
})
}
if (Object.keys(selectedContract.bytecodeLinkReferences).length) statusCb(`linking ${JSON.stringify(selectedContract.bytecodeLinkReferences, null, '\t')} using ${JSON.stringify(contractMetadata.linkReferences, null, '\t')}`)
@@ -245,7 +211,7 @@ class DropdownLogic {
if (error) return statusCb(`creation of ${selectedContract.name} errored: ` + error)
statusCb(`creation of ${selectedContract.name} pending...`)
- this.createContract(selectedContract, data, continueCb, promptCb, modalDialog, confirmDialog, finalCb)
+ this.createContract(selectedContract, data, continueCb, promptCb, confirmationCb, finalCb)
})
}