import { ErrorInvalid } from '../../errors' ; import { StepDecoded } from '../../types' ; import { isCallScript , decodeCallScript } from '../callScript' ; import { isValidForwardCall , parseForwardCall } from '../forwarding' ; return export function decodeForwardingPath ( script ) { if ( ! isCallScript ( script ) ) { throw new ErrorInvalid ( `Script could not be decoded: ${ script }` ) ; } const path = decodeCallScript ( script ) ; const decodedPath = path . map ( ( step ) => { const { data } = step ; let children ; if ( isValidForwardCall ( data ) ) { const forwardedEvmScript = parseForwardCall ( data ) ; try { children = decodeForwardingPath ( forwardedEvmScript ) ; } catch ( err ) { } } return { ... step , children , } ; } ) ; return decodedPath ; }