Browse Source

updated eth.js

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
3342a69cf4
  1. 49
      libethrpc/eth.js

49
libethrpc/eth.js

@ -102,18 +102,6 @@ window.eth = (function ethScope() {
return p;
};
var setupProperties = function (root, spec) {
var properties = [
{ name: "coinbase", getter: "coinbase", setter: "setCoinbase" },
{ name: "listening", getter: "listening", setter: "setListening" },
{ name: "mining", getter: "mining", setter: "setMining" },
{ name: "gasPrice", getter: "gasPrice"},
{ name: "key", getter: "key" },
{ name: "keys", getter: "keys" },
{ name: "peerCount", getter: "peerCount" },
{ name: "defaultBlock", getter: "defaultBlock" },
{ name: "number", getter: "number" }];
var addPrefix = function (s, prefix) {
if (!s) {
return s;
@ -129,6 +117,18 @@ window.eth = (function ethScope() {
return addPrefix(s, "set");
};
var setupProperties = function (root, spec) {
var properties = [
{ name: "coinbase", getter: "coinbase", setter: "setCoinbase" },
{ name: "listening", getter: "listening", setter: "setListening" },
{ name: "mining", getter: "mining", setter: "setMining" },
{ name: "gasPrice", getter: "gasPrice"},
{ name: "key", getter: "key" },
{ name: "keys", getter: "keys" },
{ name: "peerCount", getter: "peerCount" },
{ name: "defaultBlock", getter: "defaultBlock" },
{ name: "number", getter: "number" }];
properties.forEach(function (property) {
var p = {};
if (property.getter) {
@ -152,7 +152,32 @@ window.eth = (function ethScope() {
});
};
var setupMethods = function (root, spec) {
var methods = [
{ name: "balanceAt", async: "getBalanceAt" },
{ name: "stateAt", async: "getStateAt" },
{ name: "countAt", async: "getCountAt" },
{ name: "codeAt", async: "getCodeAt" },
{ name: "transact", async: "makeTransact" },
{ name: "call", async: "makeCall" },
{ name: "messages", async: "getMessages" },
{ name: "transaction", async: "getTransaction" }
];
methods.forEach(function (method) {
root[method.name] = function () {
return reqSync(method.name, getParams(spec, method.name, arguments));
};
if (method.async) {
root[method.async] = function () {
return reqAsync(method.name, getParams(spec, method.name, arguments), arguments[arguments.length - 1]);
};
};
});
};
setupProperties(ret, window.spec);
setupMethods(ret, window.spec);
/*

Loading…
Cancel
Save