How to use the ethereum-types.OpCode.Create function in ethereum-types

To help you get started, we’ve selected a few ethereum-types 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-tracing-utils / src / revert_trace.ts View on Github external
// After contract execution, we look at all sub-calls to external contracts, and for each one, fetch
                // the bytecode and compute the coverage for the call. If the contract is destroyed with a call
                // to `selfdestruct`, we are unable to fetch it's bytecode and compute coverage.
                // TODO: Refactor this logic to fetch the sub-called contract bytecode before the selfdestruct is called
                // in order to handle this edge-case.
                logUtils.warn(
                    "Detected a selfdestruct. We currently do not support that scenario. We'll just skip the trace part for a destructed contract",
                );
            }
        } else if (structLog.op === OpCode.Revert) {
            evmCallStack.push({
                address: _.last(addressStack) as string,
                structLog,
            });
            return evmCallStack;
        } else if (structLog.op === OpCode.Create) {
            // TODO: Extract the new contract address from the stack and handle that scenario
            logUtils.warn(
                "Detected a contract created from within another contract. We currently do not support that scenario. We'll just skip that trace",
            );
            return [];
        } else {
            if (structLog !== _.last(normalizedStructLogs)) {
                const nextStructLog = normalizedStructLogs[i + 1];
                if (nextStructLog.depth === structLog.depth) {
                    continue;
                } else if (nextStructLog.depth === structLog.depth - 1) {
                    addressStack.pop();
                } else {
                    throw new Error('Malformed trace. Unexpected call depth change');
                }
            }
github 0xProject / 0x-monorepo / packages / sol-tracing-utils / src / trace.ts View on Github external
const currentAddress = addressStack.pop() as string;
            contractAddressToTraces[currentAddress] = (contractAddressToTraces[currentAddress] || []).concat(
                currentTraceSegment,
            );
            currentTraceSegment = [];
            if (structLog.op === OpCode.SelfDestruct) {
                // After contract execution, we look at all sub-calls to external contracts, and for each one, fetch
                // the bytecode and compute the coverage for the call. If the contract is destroyed with a call
                // to `selfdestruct`, we are unable to fetch it's bytecode and compute coverage.
                // TODO: Refactor this logic to fetch the sub-called contract bytecode before the selfdestruct is called
                // in order to handle this edge-case.
                logUtils.warn(
                    "Detected a selfdestruct. We currently do not support that scenario. We'll just skip the trace part for a destructed contract",
                );
            }
        } else if (structLog.op === OpCode.Create) {
            // TODO: Extract the new contract address from the stack and handle that scenario
            logUtils.warn(
                "Detected a contract created from within another contract. We currently do not support that scenario. We'll just skip that trace",
            );
            return contractAddressToTraces;
        } else {
            if (structLog !== _.last(normalizedStructLogs)) {
                const nextStructLog = normalizedStructLogs[i + 1];
                if (nextStructLog.depth === structLog.depth) {
                    continue;
                } else if (nextStructLog.depth === structLog.depth - 1) {
                    const currentAddress = addressStack.pop() as string;
                    contractAddressToTraces[currentAddress] = (contractAddressToTraces[currentAddress] || []).concat(
                        currentTraceSegment,
                    );
                    currentTraceSegment = [];