docs(intelligent-contracts): add best practices and common patterns guide#352
docs(intelligent-contracts): add best practices and common patterns guide#352luch91 wants to merge 1 commit intogenlayerlabs:mainfrom
Conversation
|
@luch91 is attempting to deploy a commit to the YeagerAI Team on Vercel. A member of the Team first needs to authorize it. |
✅ Deploy Preview for genlayer-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
📝 WalkthroughWalkthroughA new documentation page on intelligent contract best practices and common patterns was added, covering non-deterministic blocks, prompt engineering, access control, storage patterns, event indexing, and upgrade patterns, registered in the site metadata. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
pages/developers/intelligent-contracts/security-and-best-practices/best-practices.mdx (1)
3-8: Consider making helper/example references clickable and repo-scoped.Many references are plain filenames/paths; converting them to explicit links (and naming the target repo where relevant) would improve navigation and reduce ambiguity for readers.
Also applies to: 33-34, 54-55, 71-73, 76-83, 115-116, 122-123, 142-143, 155-163
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pages/developers/intelligent-contracts/security-and-best-practices/best-practices.mdx` around lines 3 - 8, The document best-practices.mdx contains many plain filenames/paths used as helper/example references; replace each plain filename/path with an explicit clickable link pointing to the appropriate repo/file (use full GitHub URLs or repo-scoped relative links) and include the target repo name in the link text for clarity. Update the occurrences referenced (around lines 33-34, 54-55, 71-73, 76-83, 115-116, 122-123, 142-143, 155-163) so every helper/example mention becomes a descriptive link (e.g., "genlayer-utils: path/to/file" linking to the file), and ensure links open in the same docs/site convention used elsewhere in the project. Ensure link formatting is valid MDX and preserves current surrounding wording and emphasis.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@pages/developers/intelligent-contracts/security-and-best-practices/best-practices.mdx`:
- Line 99: Update the table row wording to be precise: change "Calling
`gl.nondet` outside equivalent" to something like "Calling `gl.nondet` outside
an equivalence-principle wrapper (e.g., outside `gl.eq_principle.*`)" so it
clearly indicates the operator must be used within an equivalence-principle
wrapper; update the cell that currently suggests "Wrap in `gl.eq_principle.*`
function" to match the new phrasing for consistency.
---
Nitpick comments:
In
`@pages/developers/intelligent-contracts/security-and-best-practices/best-practices.mdx`:
- Around line 3-8: The document best-practices.mdx contains many plain
filenames/paths used as helper/example references; replace each plain
filename/path with an explicit clickable link pointing to the appropriate
repo/file (use full GitHub URLs or repo-scoped relative links) and include the
target repo name in the link text for clarity. Update the occurrences referenced
(around lines 33-34, 54-55, 71-73, 76-83, 115-116, 122-123, 142-143, 155-163) so
every helper/example mention becomes a descriptive link (e.g., "genlayer-utils:
path/to/file" linking to the file), and ensure links open in the same docs/site
convention used elsewhere in the project. Ensure link formatting is valid MDX
and preserves current surrounding wording and emphasis.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
pages/developers/intelligent-contracts/security-and-best-practices/_meta.jsonpages/developers/intelligent-contracts/security-and-best-practices/best-practices.mdx
| | Forgetting `sort_keys=True` | Always `json.dumps(result, sort_keys=True)` before `strict_eq` | | ||
| | Using `dict`/`list` for storage | Use `TreeMap` / `DynArray` instead | | ||
| | Missing `@allow_storage @dataclass` | Required on every stored custom class | | ||
| | Calling `gl.nondet` outside equivalent | Wrap in `gl.eq_principle.*` function | |
There was a problem hiding this comment.
Clarify wording in the common-mistakes row.
Calling gl.nondet outside equivalent is unclear; use outside an equivalence-principle wrapper (or similar) for precision.
✏️ Proposed wording fix
-| Calling `gl.nondet` outside equivalent | Wrap in `gl.eq_principle.*` function |
+| Calling `gl.nondet` outside an equivalence-principle wrapper | Wrap in a `gl.eq_principle.*` function |📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| | Calling `gl.nondet` outside equivalent | Wrap in `gl.eq_principle.*` function | | |
| | Calling `gl.nondet` outside an equivalence-principle wrapper | Wrap in a `gl.eq_principle.*` function | |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@pages/developers/intelligent-contracts/security-and-best-practices/best-practices.mdx`
at line 99, Update the table row wording to be precise: change "Calling
`gl.nondet` outside equivalent" to something like "Calling `gl.nondet` outside
an equivalence-principle wrapper (e.g., outside `gl.eq_principle.*`)" so it
clearly indicates the operator must be used within an equivalence-principle
wrapper; update the cell that currently suggests "Wrap in `gl.eq_principle.*`
function" to match the new phrasing for consistency.
Description
Add a best-practices guide for GenLayer contract development under the Intelligent Contracts documentation.
This page is based on the community-maintained
genlayer-utilspatterns library and is intended to complement the existing primitive/API documentation with a more practical, workflow-oriented guide.It adds guidance on:
This PR is documentation-only and does not attempt to introduce SDK or Studio features.
Closes #345
Summary by CodeRabbit