Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

feat: add support for extension-based code snippets in ContractFunction and CodeOverview components #2675

Merged
merged 1 commit into from
Jun 15, 2024

Conversation

jnsdls
Copy link
Member

@jnsdls jnsdls commented Jun 15, 2024

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.



PR-Codex overview

The focus of this PR is to introduce code snippets generation for different extensions based on contract functions.

Detailed summary

  • Added functions to build JavaScript and React code snippets for different extensions
  • Introduced mapping for extension namespaces and functions
  • Updated snippet formatting based on extension and function details

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

vercel bot commented Jun 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 15, 2024 6:29am

Copy link

graphite-app bot commented Jun 15, 2024

Your org requires the Graphite merge queue for merging into main

Add 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.

@jnsdls jnsdls requested a review from joaquim-verges June 15, 2024 05:58
Copy link
Member Author

jnsdls commented Jun 15, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @jnsdls and the rest of your teammates on Graphite Graphite

@jnsdls jnsdls marked this pull request as ready for review June 15, 2024 05:58
@jnsdls jnsdls requested a review from MananTank as a code owner June 15, 2024 05:58
@jnsdls jnsdls force-pushed the feat/update-extension-snippet-support branch from 2986aa4 to c2e39fd Compare June 15, 2024 06:01
Copy link

graphite-app bot commented 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 jnsdls force-pushed the feat/update-extension-snippet-support branch from c2e39fd to 1e1824f Compare June 15, 2024 06:18
@graphite-app graphite-app bot merged commit 1e1824f into main Jun 15, 2024
11 checks passed
@graphite-app graphite-app bot deleted the feat/update-extension-snippet-support branch June 15, 2024 06:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants