Udapp: show fallback button only if its in the ABI

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

@ -316,13 +316,16 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
$instance.append($title) $instance.append($title)
// Add the fallback function // Add the fallback function
$instance.append(self.getCallButton({ var fallback = self.getFallbackInterface(abi)
abi: { constant: false, inputs: [], name: '(fallback)', outputs: [], type: 'function' }, if (fallback) {
encode: function (args) { $instance.append(self.getCallButton({
return '' abi: { constant: false, inputs: [], name: '(fallback)', outputs: [], type: 'function' },
}, encode: function (args) {
address: address return ''
})) },
address: address
}))
}
$.each(abi, function (i, funABI) { $.each(abi, function (i, funABI) {
if (funABI.type !== 'function') { 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) { UniversalDApp.prototype.getCallButton = function (args) {
var self = this var self = this
// args.abi, args.encode, args.bytecode [constr only], args.address [fun only] // args.abi, args.encode, args.bytecode [constr only], args.address [fun only]

Loading…
Cancel
Save