@@ -3,6 +3,28 @@ import { NestedScope } from '@remix-project/remix-debug'
33import * as helper from './helper'
44
55module . exports = async function ( st , privateKey , contractBytecode , compilationResult , contractCode ) {
6+ // Traverse the call tree to verify call types
7+ let callCount = 0
8+ let staticCallCount = 0
9+ let delegateCallCount = 0
10+ let contractBFunctionTotalCount = 0
11+ let contractCFunctionTotalCount = 0
12+ function traverseScopes ( scope : NestedScope , parent ?: NestedScope ) {
13+ if ( scope . functionDefinition && scope . functionDefinition . name && scope . functionDefinition . name . includes ( 'contractBFunction' ) ) contractBFunctionTotalCount ++
14+ if ( scope . functionDefinition && scope . functionDefinition . name && scope . functionDefinition . name . includes ( 'contractCFunction' ) ) contractCFunctionTotalCount ++
15+
16+ if ( parent && parent . opcodeInfo . op === 'CALL' && scope . functionDefinition && scope . functionDefinition . name && scope . functionDefinition . name . includes ( 'contractBFunction' ) ) {
17+ callCount ++
18+ } else if ( parent && parent . opcodeInfo . op === 'STATICCALL' && scope . functionDefinition && scope . functionDefinition . name && scope . functionDefinition . name . includes ( 'contractCFunction' ) ) {
19+ staticCallCount ++
20+ } else if ( parent && parent . opcodeInfo . op === 'DELEGATECALL' && scope . functionDefinition && scope . functionDefinition . name && scope . functionDefinition . name . includes ( 'contractBFunction' ) ) {
21+ delegateCallCount ++
22+ }
23+
24+ if ( scope . children ) {
25+ scope . children . forEach ( child => traverseScopes ( child , scope ) )
26+ }
27+ }
628 try {
729 // Deploy the contract first (constructor deployment)
830 const { traceManager : deployTraceManager , callTree : deployCallTree , waitForCallTree : waitForDeployCallTree } = await helper . setupDebugger ( privateKey , contractBytecode , compilationResult , contractCode )
@@ -24,29 +46,6 @@ module.exports = async function (st, privateKey, contractBytecode, compilationRe
2446 // Get the nested JSON representation of scopes
2547 const nestedScopes : NestedScope [ ] = callTree . getScopesAsNestedJSON ( )
2648
27- // Traverse the call tree to verify call types
28- let callCount = 0
29- let staticCallCount = 0
30- let delegateCallCount = 0
31- let contractBFunctionTotalCount = 0
32- let contractCFunctionTotalCount = 0
33- function traverseScopes ( scope : NestedScope , parent ?: NestedScope ) {
34- if ( scope . functionDefinition && scope . functionDefinition . name && scope . functionDefinition . name . includes ( 'contractBFunction' ) ) contractBFunctionTotalCount ++
35- if ( scope . functionDefinition && scope . functionDefinition . name && scope . functionDefinition . name . includes ( 'contractCFunction' ) ) contractCFunctionTotalCount ++
36-
37- if ( parent && parent . opcodeInfo . op === 'CALL' && scope . functionDefinition && scope . functionDefinition . name && scope . functionDefinition . name . includes ( 'contractBFunction' ) ) {
38- callCount ++
39- } else if ( parent && parent . opcodeInfo . op === 'STATICCALL' && scope . functionDefinition && scope . functionDefinition . name && scope . functionDefinition . name . includes ( 'contractCFunction' ) ) {
40- staticCallCount ++
41- } else if ( parent && parent . opcodeInfo . op === 'DELEGATECALL' && scope . functionDefinition && scope . functionDefinition . name && scope . functionDefinition . name . includes ( 'contractBFunction' ) ) {
42- delegateCallCount ++
43- }
44-
45- if ( scope . children ) {
46- scope . children . forEach ( child => traverseScopes ( child , scope ) )
47- }
48- }
49-
5049 traverseScopes ( nestedScopes [ 0 ] )
5150
5251 // Verify we found the expected call types
0 commit comments