Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit fc05f7d

Browse files
authored
Merge pull request #5391 from trufflesuite/raw-one-half
Enhancement: Include raw call data in txlog in all cases
2 parents 5affa18 + cf4b56c commit fc05f7d

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

packages/debugger/lib/txlog/reducers.js

+8
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@ function transactionLog(state = DEFAULT_TX_LOG, action) {
185185
(kind === "function" || kind === "library") &&
186186
action.absorbNextInternalCall;
187187
}
188+
//include raw data regardless
189+
call.raw = {};
190+
if (calldata) {
191+
call.raw.calldata = calldata;
192+
}
193+
if (binary) {
194+
call.raw.binary = binary;
195+
}
188196
return {
189197
byPointer: {
190198
...state.byPointer,

packages/debugger/test/txlog.js

+17
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from "./helpers";
1313
import Debugger from "lib/debugger";
1414
import * as Codec from "@truffle/codec";
15+
import Web3 from "web3";
1516

1617
import txlog from "lib/txlog/selectors";
1718

@@ -228,6 +229,15 @@ describe("Transaction log (visualizer)", function () {
228229
assert.equal(call.functionName, "testCall");
229230
assert.equal(call.contractName, "VizTest");
230231
assert.equal(call.returnKind, "return");
232+
const expectedSelector = Web3.utils
233+
.soliditySha3("testCall(uint256)")
234+
.slice(0, 2 + 2 * Codec.Evm.Utils.SELECTOR_SIZE);
235+
const expectedArgument = Codec.Conversion.toHexString(
236+
108,
237+
Codec.Evm.Utils.WORD_SIZE
238+
).slice(2);
239+
assert.equal(call.raw.calldata, expectedSelector + expectedArgument);
240+
assert.notProperty(call.raw, "binary");
231241
debug("arguments: %O", call.arguments);
232242
let inputs = Codec.Export.unsafeNativizeVariables(byName(call.arguments));
233243
debug("nativized: %O", inputs);
@@ -281,6 +291,13 @@ describe("Transaction log (visualizer)", function () {
281291
assert.isUndefined(call.functionName);
282292
assert.equal(call.contractName, "Secondary");
283293
assert.equal(call.returnKind, "return");
294+
const expectedBytecode = abstractions.Secondary.binary;
295+
const expectedArgument = Codec.Conversion.toHexString(
296+
108,
297+
Codec.Evm.Utils.WORD_SIZE
298+
).slice(2);
299+
assert.equal(call.raw.binary, expectedBytecode + expectedArgument);
300+
assert.notProperty(call.raw, "calldata");
284301
let inputs = Codec.Export.unsafeNativizeVariables(byName(call.arguments));
285302
assert.deepEqual(inputs, {
286303
y: 108

0 commit comments

Comments
 (0)