@ -1,13 +1,10 @@
var yo = require ( 'yo-yo' )
var yo = require ( 'yo-yo' )
var css = require ( '../styles/run-tab-styles' )
var css = require ( '../styles/run-tab-styles' )
var executionContext = require ( '../../../execution-context' )
var modalDialogCustom = require ( '../../ui/modal-dialog-custom' )
var modalDialogCustom = require ( '../../ui/modal-dialog-custom' )
var remixLib = require ( 'remix-lib' )
var remixLib = require ( 'remix-lib' )
var txExecution = remixLib . execution . txExecution
var txExecution = remixLib . execution . txExecution
var txFormat = remixLib . execution . txFormat
var txFormat = remixLib . execution . txFormat
var txHelper = remixLib . execution . txHelper
var EventManager = remixLib . EventManager
var EventManager = remixLib . EventManager
var typeConversion = remixLib . execution . typeConversion
var confirmDialog = require ( '../../execution/confirmDialog' )
var confirmDialog = require ( '../../execution/confirmDialog' )
var modalDialog = require ( '../../ui/modaldialog' )
var modalDialog = require ( '../../ui/modaldialog' )
var MultiParamManager = require ( '../../../multiParamManager' )
var MultiParamManager = require ( '../../../multiParamManager' )
@ -100,11 +97,9 @@ class ContractDropdownUI {
}
}
var selectedContract = this . getSelectedContract ( )
var selectedContract = this . getSelectedContract ( )
var ctrabi = txHelper . getConstructorInterface ( selectedContract . abi )
var createConstructorInstance = new MultiParamManager ( 0 , selectedContract . getConstructorInterface ( ) , ( valArray , inputsValues ) => {
var ctrEVMbc = selectedContract . bytecodeObject
var createConstructorInstance = new MultiParamManager ( 0 , ctrabi , ( valArray , inputsValues ) => {
this . createInstance ( inputsValues , selectedContract . compiler )
this . createInstance ( inputsValues , selectedContract . compiler )
} , txHelper . inputParametersDeclarationToString ( ctrabi . inputs ) , 'Deploy' , ctrEVMbc )
} , selectedContract . getConstructorInputs ( ) , 'Deploy' , selectedContract . bytecodeObject )
this . createPanel . appendChild ( createConstructorInstance . render ( ) )
this . createPanel . appendChild ( createConstructorInstance . render ( ) )
}
}
@ -129,15 +124,15 @@ class ContractDropdownUI {
if ( network . name !== 'Main' ) {
if ( network . name !== 'Main' ) {
return continueTxExecution ( null )
return continueTxExecution ( null )
}
}
var amount = executionContext . web3 ( ) . fromWei ( typeConversion . toInt ( t x . value ) , 'ether' )
var amount = this . dropdownLogic . fromWei ( tx . value , true )
var content = confirmDialog ( tx , amount , gasEstimation , this . parentSelf ,
var content = confirmDialog ( tx , amount , gasEstimation , this . parentSelf ,
( gasPrice , cb ) => {
( gasPrice , cb ) => {
let txFeeText , priceStatus
let txFeeText , priceStatus
// TODO: this try catch feels like an anti pattern, can/should be
// TODO: this try catch feels like an anti pattern, can/should be
// removed, but for now keeping the original logic
// removed, but for now keeping the original logic
try {
try {
var fee = executionContext . web3 ( ) . toBigNumber ( tx . gas ) . mul ( executionContext . web3 ( ) . toBigNumber ( executionContext . web3 ( ) . toWei ( gasPrice . toString ( 10 ) , 'gwei' ) ) )
var fee = this . dropdownLogic . calculateFee ( tx . gas , gasPrice , 'gwei' )
txFeeText = ' ' + executionContext . web3 ( ) . fromWei ( fee . toString ( 10 ) , 'ether' ) + ' Ether'
txFeeText = ' ' + this . dropdownLogic . fromWei ( fee ) + ' Ether'
priceStatus = true
priceStatus = true
} catch ( e ) {
} catch ( e ) {
txFeeText = ' Please fix this issue before sending any transaction. ' + e . message
txFeeText = ' Please fix this issue before sending any transaction. ' + e . message
@ -146,13 +141,13 @@ class ContractDropdownUI {
cb ( txFeeText , priceStatus )
cb ( txFeeText , priceStatus )
} ,
} ,
( cb ) => {
( cb ) => {
executionContext . web3 ( ) . eth . getGasPrice ( ( error , gasPrice ) => {
this . dropdownLogic . getGasPrice ( ( error , gasPrice ) => {
var warnMessage = ' Please fix this issue before sending any transaction. '
var warnMessage = ' Please fix this issue before sending any transaction. '
if ( error ) {
if ( error ) {
return cb ( 'Unable to retrieve the current network gas price.' + warnMessage + error )
return cb ( 'Unable to retrieve the current network gas price.' + warnMessage + error )
}
}
try {
try {
var gasPriceValue = executionContext . web3 ( ) . fromWei ( gasPrice . toString ( 10 ) , 'gwei' )
var gasPriceValue = this . dropdownLogic . fromWei ( gasPrice , false , 'gwei' )
cb ( null , gasPriceValue )
cb ( null , gasPriceValue )
} catch ( e ) {
} catch ( e ) {
cb ( warnMessage + e . message , null , false )
cb ( warnMessage + e . message , null , false )
@ -168,7 +163,7 @@ class ContractDropdownUI {
if ( ! content . gasPriceStatus ) {
if ( ! content . gasPriceStatus ) {
cancelCb ( 'Given gas price is not correct' )
cancelCb ( 'Given gas price is not correct' )
} else {
} else {
var gasPrice = executionContext . web3 ( ) . toWei ( content . querySelector ( '#gasprice' ) . value , 'gwei' )
var gasPrice = this . dropdownLogic . toWei ( content . querySelector ( '#gasprice' ) . value , 'gwei' )
continueTxExecution ( gasPrice )
continueTxExecution ( gasPrice )
}
}
} } , {
} } , {
@ -206,17 +201,15 @@ class ContractDropdownUI {
if ( error ) {
if ( error ) {
return this . parentSelf . _deps . logCallback ( ` creation of ${ selectedContract . name } errored: ${ error } ` )
return this . parentSelf . _deps . logCallback ( ` creation of ${ selectedContract . name } errored: ${ error } ` )
}
}
var isVM = executionContext . isVM ( )
var isVM = this . dropdownLogic . isVM ( )
if ( isVM ) {
if ( isVM ) {
var vmError = txExecution . checkVMError ( txResult )
var vmError = txExecution . checkVMError ( txResult )
if ( vmError . error ) {
if ( vmError . error ) {
this . parentSelf . _deps . logCallback ( vmError . message )
return this . parentSelf . _deps . logCallback ( vmError . message )
return
}
}
}
}
if ( txResult . result . status && txResult . result . status === '0x0' ) {
if ( txResult . result . status && txResult . result . status === '0x0' ) {
this . parentSelf . _deps . logCallback ( ` creation of ${ selectedContract . name } errored: transaction execution failed ` )
return this . parentSelf . _deps . logCallback ( ` creation of ${ selectedContract . name } errored: transaction execution failed ` )
return
}
}
this . event . trigger ( 'clearInstance' )
this . event . trigger ( 'clearInstance' )
var address = isVM ? txResult . result . createdAddress : txResult . result . contractAddress
var address = isVM ? txResult . result . createdAddress : txResult . result . contractAddress
@ -234,7 +227,7 @@ class ContractDropdownUI {
}
}
var forceSend = ( ) => {
var forceSend = ( ) => {
var constructor = txHelper . getConstructorInterface ( selectedContract . abi )
var constructor = selectedContract . getConstructorInterface ( )
this . parentSelf . _deps . filePanel . compilerMetadata ( ) . deployMetadataOf ( selectedContract . name , ( error , contractMetadata ) => {
this . parentSelf . _deps . filePanel . compilerMetadata ( ) . deployMetadataOf ( selectedContract . name , ( error , contractMetadata ) => {
if ( error ) return this . parentSelf . _deps . logCallback ( ` creation of ${ selectedContract . name } errored: ` + error )
if ( error ) return this . parentSelf . _deps . logCallback ( ` creation of ${ selectedContract . name } errored: ` + error )
if ( ! contractMetadata || ( contractMetadata && contractMetadata . autoDeployLib ) ) {
if ( ! contractMetadata || ( contractMetadata && contractMetadata . autoDeployLib ) ) {
@ -250,15 +243,15 @@ class ContractDropdownUI {
if ( network . name !== 'Main' ) {
if ( network . name !== 'Main' ) {
return continueTxExecution ( null )
return continueTxExecution ( null )
}
}
var amount = executionContext . web3 ( ) . fromWei ( typeConversion . toInt ( tx . value ) , 'ether' )
var amount = this . dropdownLogic . fromWei ( tx . value , true , 'ether' )
var content = confirmDialog ( tx , amount , gasEstimation , this . parentSelf ,
var content = confirmDialog ( tx , amount , gasEstimation , this . parentSelf ,
( gasPrice , cb ) => {
( gasPrice , cb ) => {
let txFeeText , priceStatus
let txFeeText , priceStatus
// TODO: this try catch feels like an anti pattern, can/should be
// TODO: this try catch feels like an anti pattern, can/should be
// removed, but for now keeping the original logic
// removed, but for now keeping the original logic
try {
try {
var fee = executionContext . web3 ( ) . toBigNumber ( tx . gas ) . mul ( executionContext . web3 ( ) . toBigNumber ( executionContext . web3 ( ) . toWei ( gasPrice . toString ( 10 ) , 'gwei' ) ) )
var fee = this . dropdownLogic . calculateFee ( tx . gas , gasPrice )
txFeeText = ' ' + executionContext . web3 ( ) . fromWei ( fee . toString ( 10 ) , 'ether' ) + ' Ether'
txFeeText = ' ' + this . dropdownLogic . fromWei ( fee , false , 'ether' ) + ' Ether'
priceStatus = true
priceStatus = true
} catch ( e ) {
} catch ( e ) {
txFeeText = ' Please fix this issue before sending any transaction. ' + e . message
txFeeText = ' Please fix this issue before sending any transaction. ' + e . message
@ -267,13 +260,13 @@ class ContractDropdownUI {
cb ( txFeeText , priceStatus )
cb ( txFeeText , priceStatus )
} ,
} ,
( cb ) => {
( cb ) => {
executionContext . web3 ( ) . eth . getGasPrice ( ( error , gasPrice ) => {
this . dropdownLogic . getGasPrice ( ( error , gasPrice ) => {
var warnMessage = ' Please fix this issue before sending any transaction. '
var warnMessage = ' Please fix this issue before sending any transaction. '
if ( error ) {
if ( error ) {
return cb ( 'Unable to retrieve the current network gas price.' + warnMessage + error )
return cb ( 'Unable to retrieve the current network gas price.' + warnMessage + error )
}
}
try {
try {
var gasPriceValue = executionContext . web3 ( ) . fromWei ( gasPrice . toString ( 10 ) , 'gwei' )
var gasPriceValue = this . dropdownLogic . fromWei ( gasPrice , false , 'gwei' )
cb ( null , gasPriceValue )
cb ( null , gasPriceValue )
} catch ( e ) {
} catch ( e ) {
cb ( warnMessage + e . message , null , false )
cb ( warnMessage + e . message , null , false )
@ -289,7 +282,7 @@ class ContractDropdownUI {
if ( ! content . gasPriceStatus ) {
if ( ! content . gasPriceStatus ) {
cancelCb ( 'Given gas price is not correct' )
cancelCb ( 'Given gas price is not correct' )
} else {
} else {
var gasPrice = executionContext . web3 ( ) . toWei ( content . querySelector ( '#gasprice' ) . value , 'gwei' )
var gasPrice = this . dropdownLogic . toWei ( content . querySelector ( '#gasprice' ) . value , 'gwei' )
continueTxExecution ( gasPrice )
continueTxExecution ( gasPrice )
}
}
} } , {
} } , {
@ -314,7 +307,7 @@ class ContractDropdownUI {
} )
} )
}
}
if ( selectedContract . deployedBytecode && selectedContract . deployedBytecode . object . length / 2 > 24576 ) {
if ( selectedContract . isOverSizeLimit ( ) ) {
modalDialog ( 'Contract code size over limit' , yo ` <div>Contract creation initialization returns data with length of more than 24576 bytes. The deployment will likely fails. <br>
modalDialog ( 'Contract code size over limit' , yo ` <div>Contract creation initialization returns data with length of more than 24576 bytes. The deployment will likely fails. <br>
More info : < a href = "https://github.com/ethereum/EIPs/blob/master/EIPS/eip-170.md" target = "_blank" > eip - 170 < / a >
More info : < a href = "https://github.com/ethereum/EIPs/blob/master/EIPS/eip-170.md" target = "_blank" > eip - 170 < / a >
< / d i v > ` ,
< / d i v > ` ,