Udapp: show fallback button only if its in the ABI

pull/1/head
Alex Beregszaszi 8 years ago
parent f6cf244d83
commit 78bb4e0f76
  1. 11
      src/universal-dapp.js

@ -316,6 +316,8 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
$instance.append($title)
// Add the fallback function
var fallback = self.getFallbackInterface(abi)
if (fallback) {
$instance.append(self.getCallButton({
abi: { constant: false, inputs: [], name: '(fallback)', outputs: [], type: 'function' },
encode: function (args) {
@ -323,6 +325,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
},
address: address
}))
}
$.each(abi, function (i, funABI) {
if (funABI.type !== 'function') {
@ -379,6 +382,14 @@ UniversalDApp.prototype.getConstructorInterface = function (abi) {
}
}
UniversalDApp.prototype.getFallbackInterface = function (abi) {
for (var i = 0; i < abi.length; i++) {
if (abi[i].type === 'fallback') {
return abi[i]
}
}
}
UniversalDApp.prototype.getCallButton = function (args) {
var self = this
// args.abi, args.encode, args.bytecode [constr only], args.address [fun only]

Loading…
Cancel
Save