How to use the @0x/sol-tracing-utils.constants.opCodeToParamToStackOffset 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-profiler / src / cost_utils.ts View on Github external
const memoryLocationsAccessed = _.map(memoryLogs, structLog => {
            if (_.includes(CALL_DATA_OPCODES, structLog.op)) {
                const memoryOffsetStackOffset = constants.opCodeToParamToStackOffset[structLog.op as any].memoryOffset;
                const lengthStackOffset = constants.opCodeToParamToStackOffset[structLog.op as any].length;
                const memOffset = parseInt(
                    structLog.stack[structLog.stack.length - memoryOffsetStackOffset - 1],
                    HEX_BASE,
                );
                const length = parseInt(structLog.stack[structLog.stack.length - lengthStackOffset - 1], HEX_BASE);
                return memOffset + length;
            } else {
                const memoryLocationStackOffset = constants.opCodeToParamToStackOffset[structLog.op].offset;
                return parseInt(structLog.stack[structLog.stack.length - memoryLocationStackOffset - 1], HEX_BASE);
            }
        });
        const highestMemoryLocationAccessed = _.max(memoryLocationsAccessed);
github 0xProject / 0x-monorepo / packages / sol-profiler / src / cost_utils.ts View on Github external
const memoryLocationsAccessed = _.map(memoryLogs, structLog => {
            if (_.includes(CALL_DATA_OPCODES, structLog.op)) {
                const memoryOffsetStackOffset = constants.opCodeToParamToStackOffset[structLog.op as any].memoryOffset;
                const lengthStackOffset = constants.opCodeToParamToStackOffset[structLog.op as any].length;
                const memOffset = parseInt(
                    structLog.stack[structLog.stack.length - memoryOffsetStackOffset - 1],
                    HEX_BASE,
                );
                const length = parseInt(structLog.stack[structLog.stack.length - lengthStackOffset - 1], HEX_BASE);
                return memOffset + length;
            } else {
                const memoryLocationStackOffset = constants.opCodeToParamToStackOffset[structLog.op].offset;
                return parseInt(structLog.stack[structLog.stack.length - memoryLocationStackOffset - 1], HEX_BASE);
            }
        });
        const highestMemoryLocationAccessed = _.max(memoryLocationsAccessed);