UNPKG

@1hive/connect-core

Version:

Access and interact with Aragon Organizations and their apps.

27 lines 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.findMethodAbiFragment = void 0; function findMethodAbiFragment(abi, methodSignature) { if (methodSignature === 'fallback') { // Note that fallback functions in the ABI do not contain a `name` or `inputs` key return abi.find((method) => method.type === 'fallback'); } // Is the given method a full signature, e.g. 'foo(arg1,arg2,...)' const fullMethodSignature = Boolean(methodSignature) && methodSignature.includes('(') && methodSignature.includes(')'); const methodAbiFragment = abi .filter((method) => method.type === 'function') .find((method) => { // If the full signature isn't given, just find the first overload declared if (!fullMethodSignature) { return method.name === methodSignature; } const currentParameterTypes = method.inputs.map(({ type }) => type); const currentMethodSignature = `${method.name}(${currentParameterTypes.join(',')})`; return currentMethodSignature === methodSignature; }); return methodAbiFragment; } exports.findMethodAbiFragment = findMethodAbiFragment; //# sourceMappingURL=abi.js.map