Commit f6cf244d authored by Alex Beregszaszi's avatar Alex Beregszaszi

Udapp: rely on constructor ABI to be supplied

parent b5ac39fb
...@@ -196,6 +196,10 @@ UniversalDApp.prototype.getCreateInterface = function ($container, contract) { ...@@ -196,6 +196,10 @@ UniversalDApp.prototype.getCreateInterface = function ($container, contract) {
$createInterface.append($atButton) $createInterface.append($atButton)
var $newButton = self.getInstanceInterface(contract) var $newButton = self.getInstanceInterface(contract)
if (!$newButton) {
return $createInterface
}
$createInterface.append($newButton) $createInterface.append($newButton)
// Only display creation interface for non-abstract contracts. // Only display creation interface for non-abstract contracts.
...@@ -228,7 +232,12 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar ...@@ -228,7 +232,12 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
return 1 return 1
} }
}) })
var funABI = self.getConstructorInterface(abi) var funABI = self.getConstructorInterface(abi)
if (!funABI) {
return
}
var $createInterface = $('<div class="createContract"/>') var $createInterface = $('<div class="createContract"/>')
var appendFunctions = function (address, $el) { var appendFunctions = function (address, $el) {
...@@ -362,16 +371,12 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar ...@@ -362,16 +371,12 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
return $createInterface return $createInterface
} }
// either return the supplied constructor or a mockup (we assume everything can be instantiated)
UniversalDApp.prototype.getConstructorInterface = function (abi) { UniversalDApp.prototype.getConstructorInterface = function (abi) {
var funABI = { 'name': '', 'inputs': [], 'type': 'constructor', 'outputs': [] }
for (var i = 0; i < abi.length; i++) { for (var i = 0; i < abi.length; i++) {
if (abi[i].type === 'constructor') { if (abi[i].type === 'constructor') {
funABI.inputs = abi[i].inputs || [] return abi[i]
break
} }
} }
return funABI
} }
UniversalDApp.prototype.getCallButton = function (args) { UniversalDApp.prototype.getCallButton = function (args) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment