Merge pull request #239 from ethereum/remove-legacy

Remove legacy
pull/1/head
chriseth 8 years ago committed by GitHub
commit 719a77ad7a
  1. 51
      src/universal-dapp.js

@ -147,24 +147,19 @@ UniversalDApp.prototype.render = function () {
self.$el.append($legend); self.$el.append($legend);
// NOTE: this might be used in the future for (var c in self.contracts) {
if (self.contracts.length === 0) { var $contractEl = $('<div class="contract"/>');
self.$el.append(self.getABIInputForm());
} else {
for (var c in self.contracts) {
var $contractEl = $('<div class="contract"/>');
if (self.contracts[c].address) { if (self.contracts[c].address) {
self.getInstanceInterface(self.contracts[c], self.contracts[c].address, $contractEl); self.getInstanceInterface(self.contracts[c], self.contracts[c].address, $contractEl);
} else { } else {
var $title = $('<span class="title"/>').text(self.contracts[c].name); var $title = $('<span class="title"/>').text(self.contracts[c].name);
if (self.contracts[c].bytecode) { if (self.contracts[c].bytecode) {
$title.append($('<div class="size"/>').text((self.contracts[c].bytecode.length / 2) + ' bytes')); $title.append($('<div class="size"/>').text((self.contracts[c].bytecode.length / 2) + ' bytes'));
}
$contractEl.append($title).append(self.getCreateInterface($contractEl, self.contracts[c]));
} }
self.$el.append(self.renderOutputModifier(self.contracts[c].name, $contractEl)); $contractEl.append($title).append(self.getCreateInterface($contractEl, self.contracts[c]));
} }
self.$el.append(self.renderOutputModifier(self.contracts[c].name, $contractEl));
} }
return self.$el; return self.$el;
@ -180,31 +175,6 @@ UniversalDApp.prototype.getContractByName = function (contractName) {
return null; return null;
}; };
UniversalDApp.prototype.getABIInputForm = function (cb) {
var self = this;
var $el = $('<div class="udapp-setup" />');
var $jsonInput = $('<textarea class="json" placeholder=\'[ { "name": name, "bytecode": bytecode, "interface": abi }, { ... } ]\'/>');
var $createButton = $('<button class="udapp-create"/>').text('Render ABI');
$createButton.click(function (ev) {
var contracts = $.parseJSON($jsonInput.val());
if (cb) {
var err = null;
var dapp = null;
try {
dapp = new UniversalDApp(contracts, self.options);
} catch (e) {
err = e;
}
cb(err, dapp);
} else {
self.contracts = contracts;
self.$el.empty().append(self.render());
}
});
$el.append($jsonInput).append($createButton);
return $el;
};
UniversalDApp.prototype.getCreateInterface = function ($container, contract) { UniversalDApp.prototype.getCreateInterface = function ($container, contract) {
var self = this; var self = this;
var $createInterface = $('<div class="create"/>'); var $createInterface = $('<div class="create"/>');
@ -381,6 +351,7 @@ 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': [] }; var funABI = { 'name': '', 'inputs': [], 'type': 'constructor', 'outputs': [] };
for (var i = 0; i < abi.length; i++) { for (var i = 0; i < abi.length; i++) {

Loading…
Cancel
Save