How to use the @0x/sol-tracing-utils.getSourceRangeSnippet function in @0x/sol-tracing-utils

To help you get started, we’ve selected a few @0x/sol-tracing-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 0xProject / 0x-monorepo / packages / sol-trace / src / revert_trace_subprovider.ts View on Github external
while (_.isUndefined(sourceRange) && pc > 0) {
                sourceRange = pcToSourceRange[pc];
                pc -= 1;
            }
            if (_.isUndefined(sourceRange)) {
                this._logger.warn(
                    `could not find matching sourceRange for structLog: ${JSON.stringify(
                        _.omit(evmCallStackEntry.structLog, 'stack'),
                    )}`,
                );
                continue;
            }

            const fileNameToFileIndex = _.invert(contractData.sources);
            const fileIndex = _.parseInt(fileNameToFileIndex[sourceRange.fileName]);
            const sourceSnippet = getSourceRangeSnippet(sourceRange, contractData.sourceCodes[fileIndex]);
            sourceSnippets.push(sourceSnippet);
        }
        const filteredSnippets = filterSnippets(sourceSnippets);
        if (filteredSnippets.length > 0) {
            this._logger.error('\n\nStack trace for REVERT:\n');
            _.forEach(_.reverse(filteredSnippets), snippet => {
                const traceString = getStackTraceString(snippet);
                this._logger.error(traceString);
            });
            this._logger.error('\n');
        } else {
            this._logger.error('REVERT detected but could not determine stack trace');
        }
    }
}