forked from cerc-io/plugeth
getMethodWithName
This commit is contained in:
parent
f02368141f
commit
ad7c05778f
28
dist/ethereum.js
vendored
28
dist/ethereum.js
vendored
@ -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 string string to be padded
|
||||||
/// @param number of characters that result string should have
|
/// @param number of characters that result string should have
|
||||||
/// @param sign, by default 0
|
/// @param sign, by default 0
|
||||||
@ -159,13 +169,8 @@ var inputTypes = setupInputTypes();
|
|||||||
/// @returns bytes representation of input params
|
/// @returns bytes representation of input params
|
||||||
var toAbiInput = function (json, methodName, params) {
|
var toAbiInput = function (json, methodName, params) {
|
||||||
var bytes = "";
|
var bytes = "";
|
||||||
var index = findMethodIndex(json, methodName);
|
|
||||||
|
|
||||||
if (index === -1) {
|
var method = getMethodWithName(json, methodName);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var method = json[index];
|
|
||||||
var padding = ETH_PADDING * 2;
|
var padding = ETH_PADDING * 2;
|
||||||
|
|
||||||
/// first we iterate in search for dynamic
|
/// first we iterate in search for dynamic
|
||||||
@ -281,16 +286,10 @@ var outputTypes = setupOutputTypes();
|
|||||||
/// @param bytes representtion of output
|
/// @param bytes representtion of output
|
||||||
/// @returns array of output params
|
/// @returns array of output params
|
||||||
var fromAbiOutput = function (json, methodName, output) {
|
var fromAbiOutput = function (json, methodName, output) {
|
||||||
var index = findMethodIndex(json, methodName);
|
|
||||||
|
|
||||||
if (index === -1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
output = output.slice(2);
|
output = output.slice(2);
|
||||||
|
|
||||||
var result = [];
|
var result = [];
|
||||||
var method = json[index];
|
var method = getMethodWithName(json, methodName);
|
||||||
var padding = ETH_PADDING * 2;
|
var padding = ETH_PADDING * 2;
|
||||||
|
|
||||||
var dynamicPartLength = method.outputs.reduce(function (acc, curr) {
|
var dynamicPartLength = method.outputs.reduce(function (acc, curr) {
|
||||||
@ -404,7 +403,8 @@ module.exports = {
|
|||||||
outputParser: outputParser,
|
outputParser: outputParser,
|
||||||
methodSignature: methodSignature,
|
methodSignature: methodSignature,
|
||||||
methodDisplayName: methodDisplayName,
|
methodDisplayName: methodDisplayName,
|
||||||
methodTypeName: methodTypeName
|
methodTypeName: methodTypeName,
|
||||||
|
getMethodWithName: getMethodWithName
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
2
dist/ethereum.js.map
vendored
2
dist/ethereum.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/ethereum.min.js
vendored
2
dist/ethereum.min.js
vendored
File diff suppressed because one or more lines are too long
28
lib/abi.js
28
lib/abi.js
@ -55,6 +55,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 string string to be padded
|
||||||
/// @param number of characters that result string should have
|
/// @param number of characters that result string should have
|
||||||
/// @param sign, by default 0
|
/// @param sign, by default 0
|
||||||
@ -158,13 +168,8 @@ var inputTypes = setupInputTypes();
|
|||||||
/// @returns bytes representation of input params
|
/// @returns bytes representation of input params
|
||||||
var toAbiInput = function (json, methodName, params) {
|
var toAbiInput = function (json, methodName, params) {
|
||||||
var bytes = "";
|
var bytes = "";
|
||||||
var index = findMethodIndex(json, methodName);
|
|
||||||
|
|
||||||
if (index === -1) {
|
var method = getMethodWithName(json, methodName);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var method = json[index];
|
|
||||||
var padding = ETH_PADDING * 2;
|
var padding = ETH_PADDING * 2;
|
||||||
|
|
||||||
/// first we iterate in search for dynamic
|
/// first we iterate in search for dynamic
|
||||||
@ -280,16 +285,10 @@ var outputTypes = setupOutputTypes();
|
|||||||
/// @param bytes representtion of output
|
/// @param bytes representtion of output
|
||||||
/// @returns array of output params
|
/// @returns array of output params
|
||||||
var fromAbiOutput = function (json, methodName, output) {
|
var fromAbiOutput = function (json, methodName, output) {
|
||||||
var index = findMethodIndex(json, methodName);
|
|
||||||
|
|
||||||
if (index === -1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
output = output.slice(2);
|
output = output.slice(2);
|
||||||
|
|
||||||
var result = [];
|
var result = [];
|
||||||
var method = json[index];
|
var method = getMethodWithName(json, methodName);
|
||||||
var padding = ETH_PADDING * 2;
|
var padding = ETH_PADDING * 2;
|
||||||
|
|
||||||
var dynamicPartLength = method.outputs.reduce(function (acc, curr) {
|
var dynamicPartLength = method.outputs.reduce(function (acc, curr) {
|
||||||
@ -403,6 +402,7 @@ module.exports = {
|
|||||||
outputParser: outputParser,
|
outputParser: outputParser,
|
||||||
methodSignature: methodSignature,
|
methodSignature: methodSignature,
|
||||||
methodDisplayName: methodDisplayName,
|
methodDisplayName: methodDisplayName,
|
||||||
methodTypeName: methodTypeName
|
methodTypeName: methodTypeName,
|
||||||
|
getMethodWithName: getMethodWithName
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user