Browse Source

natspec.js updated to use sync api

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
23f83e42dd
  1. 2
      libjsqrc/ethereumjs/example/natspec_contract.html
  2. 30
      libjsqrc/natspec.js

2
libjsqrc/ethereumjs/example/natspec_contract.html

@ -56,7 +56,7 @@
// transaction does not return any result, cause it's not synchronous and we don't know,
// when it will be processed
contract.multiply(param).transact();
contract.transact().multiply(param);
document.getElementById('result').innerText = 'transaction made';
}

30
libjsqrc/natspec.js

@ -26,35 +26,7 @@ var getContractProperties = function (expression, abi) {
/// Function called to get all contract's methods
/// @returns hashmap with used contract's methods
var getContractMethods = function (address, abi) {
var contract = {};
var inputParser = web3.abi.inputParser(abi);
var outputParser = web3.abi.outputParser(abi);
abi.forEach(function (method) {
var displayName = web3.abi.methodDisplayName(method.name);
var typeName = web3.abi.methodTypeName(method.name);
var impl = function () {
var params = Array.prototype.slice.call(arguments);
var parsed = inputParser[displayName][typeName].apply(null, params);
var signature = web3.abi.methodSignature(method.name);
var output = _natspec.call(JSON.stringify({
to: address,
data: signature + parsed
}));
return outputParser[displayName][typeName](output);
};
if (contract[displayName] === undefined) {
contract[displayName] = impl;
}
contract[displayName][typeName] = impl;
});
return contract;
return web3.eth.contract(address, abi);
};
/// Should be called to evaluate single expression

Loading…
Cancel
Save