UNPKG

@1hive/connect-core

Version:

Access and interact with Aragon Organizations and their apps.

37 lines 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.decodeForwardingPath = void 0; const errors_1 = require("../../errors"); const callScript_1 = require("../callScript"); const forwarding_1 = require("../forwarding"); /** * Decodes an EVM callscript and returns the transaction path it describes. * * @return An array of Ethereum transactions that describe each step in the path */ function decodeForwardingPath(script) { // In the future we may support more EVMScripts, but for now let's just assume we're only // dealing with call scripts if (!callScript_1.isCallScript(script)) { throw new errors_1.ErrorInvalid(`Script could not be decoded: ${script}`); } const path = callScript_1.decodeCallScript(script); const decodedPath = path.map((step) => { const { data } = step; let children; if (forwarding_1.isValidForwardCall(data)) { const forwardedEvmScript = forwarding_1.parseForwardCall(data); try { children = decodeForwardingPath(forwardedEvmScript); } catch (err) { } } return { ...step, children, }; }); return decodedPath; } exports.decodeForwardingPath = decodeForwardingPath; //# sourceMappingURL=decode.js.map