Skip to content

Commit 943e1a2

Browse files
committed
Warn user at deploy time if contract size above ethereum/EIPs#170
1 parent 69ea9d5 commit 943e1a2

File tree

1 file changed

+39
-18
lines changed

1 file changed

+39
-18
lines changed

src/app/tabs/run-tab.js

+39-18
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var Recorder = require('../../recorder')
1818
var addTooltip = require('../ui/tooltip')
1919
var css = require('./styles/run-tab-styles')
2020
var MultiParamManager = require('../../multiParamManager')
21+
var modalDialog = require('../ui/modaldialog')
2122

2223
function runTab (opts, localRegistry) {
2324
/* -------------------------
@@ -421,24 +422,44 @@ function contractDropdown (events, self) {
421422
return
422423
}
423424

424-
var constructor = txHelper.getConstructorInterface(selectedContract.contract.object.abi)
425-
self._deps.filePanel.compilerMetadata().metadataOf(selectedContract.name, (error, contractMetadata) => {
426-
if (error) return self._deps.logCallback(`creation of ${selectedContract.name} errored: ` + error)
427-
if (contractMetadata.autoDeployLib) {
428-
txFormat.buildData(selectedContract.name, selectedContract.contract.object, self._deps.compiler.getContracts(), true, constructor, args, (error, data) => {
429-
createInstanceCallback(error, selectedContract, data)
430-
}, (msg) => {
431-
self._deps.logCallback(msg)
432-
}, (data, runTxCallback) => {
433-
// called for libraries deployment
434-
self._deps.udapp.runTx(data, runTxCallback)
435-
})
436-
} else {
437-
txFormat.encodeConstructorCallAndLinkLibraries(selectedContract.contract.object, args, constructor, contractMetadata.linkReferences, selectedContract.contract.object.evm.bytecode.linkReferences, (error, data) => {
438-
createInstanceCallback(error, selectedContract, data)
439-
})
440-
}
441-
})
425+
var forceSend = () => {
426+
var constructor = txHelper.getConstructorInterface(selectedContract.contract.object.abi)
427+
self._deps.filePanel.compilerMetadata().metadataOf(selectedContract.name, (error, contractMetadata) => {
428+
if (error) return self._deps.logCallback(`creation of ${selectedContract.name} errored: ` + error)
429+
if (contractMetadata.autoDeployLib) {
430+
txFormat.buildData(selectedContract.name, selectedContract.contract.object, self._deps.compiler.getContracts(), true, constructor, args, (error, data) => {
431+
createInstanceCallback(error, selectedContract, data)
432+
}, (msg) => {
433+
self._deps.logCallback(msg)
434+
}, (data, runTxCallback) => {
435+
// called for libraries deployment
436+
self._deps.udapp.runTx(data, runTxCallback)
437+
})
438+
} else {
439+
txFormat.encodeConstructorCallAndLinkLibraries(selectedContract.contract.object, args, constructor, contractMetadata.linkReferences, selectedContract.contract.object.evm.bytecode.linkReferences, (error, data) => {
440+
createInstanceCallback(error, selectedContract, data)
441+
})
442+
}
443+
})
444+
}
445+
446+
if (selectedContract.contract.object.evm.deployedBytecode.object.length / 2 > 24576) {
447+
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>
448+
More info: <a href="https://github.com/ethereum/EIPs/blob/master/EIPS/eip-170.md" target="_blank">eip-170</a>
449+
</div>`,
450+
{
451+
label: 'Force Send',
452+
fn: () => {
453+
forceSend()
454+
}}, {
455+
label: 'Cancel',
456+
fn: () => {
457+
self._deps.logCallback(`creation of ${selectedContract.name} canceled by user.`)
458+
}
459+
})
460+
} else {
461+
forceSend()
462+
}
442463
}
443464

444465
// ACCESS DEPLOYED INSTANCE

0 commit comments

Comments
 (0)