This repository has been archived by the owner on Jun 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 128
feat: add support for extension-based code snippets in ContractFunction and CodeOverview components #2675
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Your org requires the Graphite merge queue for merging into mainAdd the label “merge-queue” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix. You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link. |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
jnsdls
force-pushed
the
feat/update-extension-snippet-support
branch
from
June 15, 2024 06:01
2986aa4
to
c2e39fd
Compare
joaquim-verges
approved these changes
Jun 15, 2024
Merge activity
|
…on and CodeOverview components (#2675) ### What changed? This PR introduces several key enhancements to the `ContractFunction` and `CodeOverview` components: 1. **Environment Selection**: A new `extensionNamespace` state is added based on the enabled extensions in the contract ABI (`ERC20`, `ERC721`, `ERC1155`). This state determines the namespace used for different contract extensions. 2. **Code Snippets Generation**: Functions `buildJavascriptSnippet` and `buildReactSnippet` are added to dynamically generate code snippets based on the extension namespace and contract function type (read, write, event). 3. **Snippet Formatting**: The `formatSnippet` function is modified to include the newly generated code snippets, replacing placeholders with actual values. ### How to test? 1. **Setup**: Ensure you have a contract with varying enabled extensions (`ERC20`, `ERC721`, `ERC1155`). 2. **Test Snippet Generation**: For each contract, navigate to the code overview and ensure the generated snippets correspond to the contract's extensions and function types. 3. **Verify Placeholder Replacement**: Confirm that placeholders in the code (`{{contract_address}}`, `{{wallet_address}}`, etc.) are correctly replaced with real values. ### Why make this change? This update enhances the flexibility and readability of the code snippets provided to developers, making it easier to interact with contract functions by displaying relevant code based on the contract's supported extensions and environment. --- <!-- start pr-codex --> --- ## PR-Codex overview The focus of this PR is to enhance code snippets generation for different contract extensions based on enabled extensions. ### Detailed summary - Added logic to determine extension namespace based on enabled extensions - Implemented functions to build JavaScript and React code snippets - Created mapping for extension namespaces and functions - Updated snippet formatting to include extension-specific code generation based on function and extension namespace > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
jnsdls
force-pushed
the
feat/update-extension-snippet-support
branch
from
June 15, 2024 06:18
c2e39fd
to
1e1824f
Compare
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changed?
This PR introduces several key enhancements to the
ContractFunction
andCodeOverview
components:Environment Selection: A new
extensionNamespace
state is added based on the enabled extensions in the contract ABI (ERC20
,ERC721
,ERC1155
). This state determines the namespace used for different contract extensions.Code Snippets Generation: Functions
buildJavascriptSnippet
andbuildReactSnippet
are added to dynamically generate code snippets based on the extension namespace and contract function type (read, write, event).Snippet Formatting: The
formatSnippet
function is modified to include the newly generated code snippets, replacing placeholders with actual values.How to test?
Setup: Ensure you have a contract with varying enabled extensions (
ERC20
,ERC721
,ERC1155
).Test Snippet Generation: For each contract, navigate to the code overview and ensure the generated snippets correspond to the contract's extensions and function types.
Verify Placeholder Replacement: Confirm that placeholders in the code (
{{contract_address}}
,{{wallet_address}}
, etc.) are correctly replaced with real values.Why make this change?
This update enhances the flexibility and readability of the code snippets provided to developers, making it easier to interact with contract functions by displaying relevant code based on the contract's supported extensions and environment.
PR-Codex overview
The focus of this PR is to introduce code snippets generation for different extensions based on contract functions.
Detailed summary