@ -120,14 +120,13 @@ class DropdownLogic {
}
}
// TODO: check if selectedContract and data can be joined
// 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 ) {
if ( data ) {
data . contractName = selectedContract . name
data . contractName = selectedContract . name
data . linkReferences = selectedContract . bytecodeLinkReferences
data . linkReferences = selectedContract . bytecodeLinkReferences
data . contractABI = selectedContract . abi
data . contractABI = selectedContract . abi
}
}
const confirmationCb = this . getConfirmationCb ( modalDialog , confirmDialog )
this . udapp . createContract ( data , confirmationCb , continueCb , promptCb ,
this . udapp . createContract ( data , confirmationCb , continueCb , promptCb ,
( error , txResult ) => {
( error , txResult ) => {
if ( error ) {
if ( error ) {
@ -184,39 +183,7 @@ class DropdownLogic {
} )
} )
}
}
getConfirmationCb ( modalDialog , confirmDialog ) {
runTransaction ( data , continueCb , promptCb , confirmationCb , finalCb ) {
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 )
this . udapp . runTx ( data , confirmationCb , continueCb , promptCb , finalCb )
this . udapp . runTx ( data , confirmationCb , continueCb , promptCb , finalCb )
}
}
@ -224,9 +191,8 @@ class DropdownLogic {
return this . compilersArtefacts [ '__last' ] . getData ( ) . contracts
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 { continueCb , promptCb , statusCb , finalCb } = callbacks
const { modalDialog , confirmDialog } = dialogs
var constructor = selectedContract . getConstructorInterface ( )
var constructor = selectedContract . getConstructorInterface ( )
if ( ! contractMetadata || ( contractMetadata && contractMetadata . autoDeployLib ) ) {
if ( ! contractMetadata || ( contractMetadata && contractMetadata . autoDeployLib ) ) {
@ -234,10 +200,10 @@ class DropdownLogic {
if ( error ) return statusCb ( ` creation of ${ selectedContract . name } errored: ` + error )
if ( error ) return statusCb ( ` creation of ${ selectedContract . name } errored: ` + error )
statusCb ( ` creation of ${ selectedContract . name } pending... ` )
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 ) => {
} , statusCb , ( data , runTxCallback ) => {
// called for libraries deployment
// 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' ) } ` )
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 )
if ( error ) return statusCb ( ` creation of ${ selectedContract . name } errored: ` + error )
statusCb ( ` creation of ${ selectedContract . name } pending... ` )
statusCb ( ` creation of ${ selectedContract . name } pending... ` )
this . createContract ( selectedContract , data , continueCb , promptCb , modalDialog , confirmDialog , finalCb )
this . createContract ( selectedContract , data , continueCb , promptCb , confirmationCb , finalCb )
} )
} )
}
}