diff --git a/packages/web/docs/core-schemas/programs/tracing-examples.ts b/packages/web/docs/core-schemas/programs/tracing-examples.ts new file mode 100644 index 000000000..19cd1b936 --- /dev/null +++ b/packages/web/docs/core-schemas/programs/tracing-examples.ts @@ -0,0 +1,53 @@ +export const counterIncrement = `name Counter; + +storage { + [0] count: uint256; +} + +create { + count = 0; +} + +code { + count = count + 1; +}`; + +export const thresholdCheck = `name ThresholdCounter; + +storage { + [0] count: uint256; + [1] threshold: uint256; +} + +create { + count = 0; + threshold = 5; +} + +code { + count = count + 1; + + if (count >= threshold) { + count = 0; + } +}`; + +export const multipleStorageSlots = `name MultiSlot; + +storage { + [0] a: uint256; + [1] b: uint256; + [2] sum: uint256; +} + +create { + a = 10; + b = 20; + sum = 0; +} + +code { + sum = a + b; + a = a + 1; + b = b + 1; +}`; diff --git a/packages/web/docs/core-schemas/programs/tracing.mdx b/packages/web/docs/core-schemas/programs/tracing.mdx index efbae0cfc..7d1fadc86 100644 --- a/packages/web/docs/core-schemas/programs/tracing.mdx +++ b/packages/web/docs/core-schemas/programs/tracing.mdx @@ -5,6 +5,11 @@ sidebar_position: 4 import SpecLink from "@site/src/components/SpecLink"; import SchemaExample from "@site/src/components/SchemaExample"; import { TracePlayground, TraceExample } from "@theme/ProgramExample"; +import { + counterIncrement, + thresholdCheck, + multipleStorageSlots, +} from "./tracing-examples"; # Tracing execution @@ -50,19 +55,7 @@ This example shows a basic counter that increments a storage variable: ### Storage with threshold check @@ -72,25 +65,7 @@ This example demonstrates conditional logic with storage variables: = threshold) { -count = 0; -} -}`} + source={thresholdCheck} /> ### Multiple storage slots @@ -100,25 +75,7 @@ This example shows working with multiple storage locations: ## Trace data structure