|
18 | 18 | // callFrameTracer uses the new call frame tracing methods to report useful information |
19 | 19 | // about internal messages of a transaction. |
20 | 20 | { |
21 | | - callstack: [{}], |
22 | | - fault: function(log, db) { |
23 | | - var len = this.callstack.length |
24 | | - if (len > 1) { |
25 | | - var call = this.callstack.pop() |
26 | | - if (this.callstack[len-1].calls === undefined) { |
27 | | - this.callstack[len-1].calls = [] |
28 | | - } |
29 | | - this.callstack[len-1].calls.push(call) |
30 | | - } |
31 | | - }, |
32 | | - result: function(ctx, db) { |
33 | | - // Prepare outer message info |
34 | | - var result = { |
35 | | - type: ctx.type, |
36 | | - from: toHex(ctx.from), |
37 | | - to: toHex(ctx.to), |
38 | | - value: '0x' + ctx.value.toString(16), |
39 | | - gas: '0x' + bigInt(ctx.gas).toString(16), |
40 | | - gasUsed: '0x' + bigInt(ctx.gasUsed).toString(16), |
41 | | - input: toHex(ctx.input), |
42 | | - output: toHex(ctx.output), |
43 | | - } |
44 | | - if (this.callstack[0].calls !== undefined) { |
45 | | - result.calls = this.callstack[0].calls |
46 | | - } |
47 | | - if (this.callstack[0].error !== undefined) { |
48 | | - result.error = this.callstack[0].error |
49 | | - } else if (ctx.error !== undefined) { |
50 | | - result.error = ctx.error |
51 | | - } |
52 | | - if (result.error !== undefined && (result.error !== "execution reverted" || result.output ==="0x")) { |
53 | | - delete result.output |
54 | | - } |
| 21 | + callstack: [{}], |
| 22 | + fault: function(log, db) {}, |
| 23 | + result: function(ctx, db) { |
| 24 | + // Prepare outer message info |
| 25 | + var result = { |
| 26 | + type: ctx.type, |
| 27 | + from: toHex(ctx.from), |
| 28 | + to: toHex(ctx.to), |
| 29 | + value: '0x' + ctx.value.toString(16), |
| 30 | + gas: '0x' + bigInt(ctx.gas).toString(16), |
| 31 | + gasUsed: '0x' + bigInt(ctx.gasUsed).toString(16), |
| 32 | + input: toHex(ctx.input), |
| 33 | + output: toHex(ctx.output), |
| 34 | + } |
| 35 | + if (this.callstack[0].calls !== undefined) { |
| 36 | + result.calls = this.callstack[0].calls |
| 37 | + } |
| 38 | + if (this.callstack[0].error !== undefined) { |
| 39 | + result.error = this.callstack[0].error |
| 40 | + } else if (ctx.error !== undefined) { |
| 41 | + result.error = ctx.error |
| 42 | + } |
| 43 | + if (result.error !== undefined && (result.error !== "execution reverted" || result.output ==="0x")) { |
| 44 | + delete result.output |
| 45 | + } |
55 | 46 |
|
56 | | - return this.finalize(result) |
57 | | - }, |
58 | | - enter: function(frame) { |
59 | | - var call = { |
60 | | - type: frame.getType(), |
61 | | - from: toHex(frame.getFrom()), |
62 | | - to: toHex(frame.getTo()), |
63 | | - input: toHex(frame.getInput()), |
64 | | - gas: '0x' + bigInt(frame.getGas()).toString('16'), |
65 | | - } |
66 | | - if (frame.getValue() !== undefined){ |
67 | | - call.value='0x' + bigInt(frame.getValue()).toString(16) |
68 | | - } |
69 | | - this.callstack.push(call) |
70 | | - }, |
71 | | - exit: function(frameResult) { |
72 | | - var len = this.callstack.length |
73 | | - if (len > 1) { |
74 | | - var call = this.callstack.pop() |
75 | | - call.gasUsed = '0x' + bigInt(frameResult.getGasUsed()).toString('16') |
76 | | - var error = frameResult.getError() |
77 | | - if (error === undefined) { |
78 | | - call.output = toHex(frameResult.getOutput()) |
79 | | - } else { |
80 | | - call.error = error |
81 | | - if (call.type === 'CREATE' || call.type === 'CREATE2') { |
82 | | - delete call.to |
83 | | - } |
84 | | - } |
85 | | - len -= 1 |
86 | | - if (this.callstack[len-1].calls === undefined) { |
87 | | - this.callstack[len-1].calls = [] |
88 | | - } |
89 | | - this.callstack[len-1].calls.push(call) |
90 | | - } |
91 | | - }, |
| 47 | + return this.finalize(result) |
| 48 | + }, |
| 49 | + enter: function(frame) { |
| 50 | + var call = { |
| 51 | + type: frame.getType(), |
| 52 | + from: toHex(frame.getFrom()), |
| 53 | + to: toHex(frame.getTo()), |
| 54 | + input: toHex(frame.getInput()), |
| 55 | + gas: '0x' + bigInt(frame.getGas()).toString('16'), |
| 56 | + } |
| 57 | + if (frame.getValue() !== undefined){ |
| 58 | + call.value='0x' + bigInt(frame.getValue()).toString(16) |
| 59 | + } |
| 60 | + this.callstack.push(call) |
| 61 | + }, |
| 62 | + exit: function(frameResult) { |
| 63 | + var len = this.callstack.length |
| 64 | + if (len > 1) { |
| 65 | + var call = this.callstack.pop() |
| 66 | + call.gasUsed = '0x' + bigInt(frameResult.getGasUsed()).toString('16') |
| 67 | + var error = frameResult.getError() |
| 68 | + if (error === undefined) { |
| 69 | + call.output = toHex(frameResult.getOutput()) |
| 70 | + } else { |
| 71 | + call.error = error |
| 72 | + if (call.type === 'CREATE' || call.type === 'CREATE2') { |
| 73 | + delete call.to |
| 74 | + } |
| 75 | + } |
| 76 | + len -= 1 |
| 77 | + if (this.callstack[len-1].calls === undefined) { |
| 78 | + this.callstack[len-1].calls = [] |
| 79 | + } |
| 80 | + this.callstack[len-1].calls.push(call) |
| 81 | + } |
| 82 | + }, |
92 | 83 | // finalize recreates a call object using the final desired field oder for json |
93 | 84 | // serialization. This is a nicety feature to pass meaningfully ordered results |
94 | 85 | // to users who don't interpret it, just display it. |
|
0 commit comments