Skip to content

Commit c8a793a

Browse files
committed
docs: move 4th BUG example into tracing-examples.ts
Move the "Function call and return" (Adder) example into tracing-examples.ts with proper indentation, matching the pattern established for the other three examples.
1 parent 7802c8b commit c8a793a

2 files changed

Lines changed: 22 additions & 19 deletions

File tree

‎packages/web/docs/core-schemas/programs/tracing-examples.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,23 @@ code {
5151
a = a + 1;
5252
b = b + 1;
5353
}`;
54+
55+
export const functionCallAndReturn = `name Adder;
56+
57+
define {
58+
function add(a: uint256, b: uint256) -> uint256 {
59+
return a + b;
60+
};
61+
}
62+
63+
storage {
64+
[0] result: uint256;
65+
}
66+
67+
create {
68+
result = 0;
69+
}
70+
71+
code {
72+
result = add(3, 4);
73+
}`;

‎packages/web/docs/core-schemas/programs/tracing.mdx‎

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
counterIncrement,
1010
thresholdCheck,
1111
multipleStorageSlots,
12+
functionCallAndReturn,
1213
} from "./tracing-examples";
1314

1415
# Tracing execution
@@ -91,25 +92,7 @@ trace. Watch for **invoke** contexts on the JUMP into `add` and
9192
<TraceExample
9293
title="Function call and return"
9394
description="Calls an internal add function and stores the result"
94-
source={`name Adder;
95-
96-
define {
97-
function add(a: uint256, b: uint256) -> uint256 {
98-
return a + b;
99-
};
100-
}
101-
102-
storage {
103-
[0] result: uint256;
104-
}
105-
106-
create {
107-
result = 0;
108-
}
109-
110-
code {
111-
result = add(3, 4);
112-
}`}
95+
source={functionCallAndReturn}
11396
/>
11497

11598
As you step through, three phases are visible:

0 commit comments

Comments
 (0)