aboutsummaryrefslogtreecommitdiffstats
path: root/dist/ethereum.js
diff options
context:
space:
mode:
authorMarek Kotewicz <marek.kotewicz@gmail.com>2015-01-27 21:05:06 +0800
committerMarek Kotewicz <marek.kotewicz@gmail.com>2015-01-27 21:05:30 +0800
commitad7c05778f3aa2d4b42c9fa401f57b24370f65ad (patch)
tree46ac4543f0ae4b3508956d56dd48068598555dfc /dist/ethereum.js
parentf02368141f11511c06306184df0eda372382c2bf (diff)
downloadgo-tangerine-ad7c05778f3aa2d4b42c9fa401f57b24370f65ad.tar
go-tangerine-ad7c05778f3aa2d4b42c9fa401f57b24370f65ad.tar.gz
go-tangerine-ad7c05778f3aa2d4b42c9fa401f57b24370f65ad.tar.bz2
go-tangerine-ad7c05778f3aa2d4b42c9fa401f57b24370f65ad.tar.lz
go-tangerine-ad7c05778f3aa2d4b42c9fa401f57b24370f65ad.tar.xz
go-tangerine-ad7c05778f3aa2d4b42c9fa401f57b24370f65ad.tar.zst
go-tangerine-ad7c05778f3aa2d4b42c9fa401f57b24370f65ad.zip
getMethodWithName
Diffstat (limited to 'dist/ethereum.js')
-rw-r--r--dist/ethereum.js30
1 files changed, 15 insertions, 15 deletions
diff --git a/dist/ethereum.js b/dist/ethereum.js
index ef71e32ad..7bcf86c81 100644
--- a/dist/ethereum.js
+++ b/dist/ethereum.js
@@ -56,6 +56,16 @@ var findMethodIndex = function (json, methodName) {
});
};
+/// @returns method with given method name
+var getMethodWithName = function (json, methodName) {
+ var index = findMethodIndex(json, methodName);
+ if (index === -1) {
+ console.error('method ' + methodName + ' not found in the abi');
+ return undefined;
+ }
+ return json[index];
+};
+
/// @param string string to be padded
/// @param number of characters that result string should have
/// @param sign, by default 0
@@ -159,13 +169,8 @@ var inputTypes = setupInputTypes();
/// @returns bytes representation of input params
var toAbiInput = function (json, methodName, params) {
var bytes = "";
- var index = findMethodIndex(json, methodName);
-
- if (index === -1) {
- return;
- }
- var method = json[index];
+ var method = getMethodWithName(json, methodName);
var padding = ETH_PADDING * 2;
/// first we iterate in search for dynamic
@@ -281,16 +286,10 @@ var outputTypes = setupOutputTypes();
/// @param bytes representtion of output
/// @returns array of output params
var fromAbiOutput = function (json, methodName, output) {
- var index = findMethodIndex(json, methodName);
-
- if (index === -1) {
- return;
- }
-
+
output = output.slice(2);
-
var result = [];
- var method = json[index];
+ var method = getMethodWithName(json, methodName);
var padding = ETH_PADDING * 2;
var dynamicPartLength = method.outputs.reduce(function (acc, curr) {
@@ -404,7 +403,8 @@ module.exports = {
outputParser: outputParser,
methodSignature: methodSignature,
methodDisplayName: methodDisplayName,
- methodTypeName: methodTypeName
+ methodTypeName: methodTypeName,
+ getMethodWithName: getMethodWithName
};