Align the code to the newRust SDK#16
Open
smiasojed wants to merge 8 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR migrates the Rust contract examples, registry, and CDM tooling toward the new pvm-contract-sdk flow, replacing old CDM annotations with Cargo metadata and adding a new pvm-cdm reference macro layer.
Changes:
- Migrates contracts/templates from
pvm_contractstorage/macros topvm-contract-sdk. - Adds
pvm-cdmmacro crates and an import test harness forcdm::import!. - Updates contract detection/build paths and adds an ABI round-trip test.
Reviewed changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated 18 comments.
Show a summary per file
| File | Description |
|---|---|
Cargo.toml |
Updates workspace dependencies and members for the new SDK/CDM macro crates. |
src/contract/Cargo.toml |
Migrates registry crate dependencies and adds CDM package metadata. |
src/contract/src/lib.rs |
Rewrites the registry contract using the new SDK storage/API model. |
src/lib/cdm/import-test/.cargo/config.toml |
Adds test-specific Cargo environment configuration. |
src/lib/cdm/import-test/Cargo.toml |
Adds a Rust import-test contract crate. |
src/lib/cdm/import-test/cdm.json |
Adds fixture CDM dependency metadata. |
src/lib/cdm/import-test/fixtures/.cdm/test/contracts/@test/sample/1/abi.json |
Adds fixture ABI for import macro testing. |
src/lib/cdm/import-test/lib.rs |
Adds an end-to-end cdm::import! compile harness. |
src/lib/cdm/rust-macros/pvm-cdm-macros/Cargo.toml |
Adds the proc-macro crate manifest. |
src/lib/cdm/rust-macros/pvm-cdm-macros/src/lib.rs |
Implements the pvm_cdm::reference! macro. |
src/lib/cdm/rust-macros/pvm-cdm/Cargo.toml |
Adds the public pvm-cdm crate manifest. |
src/lib/cdm/rust-macros/pvm-cdm/src/lib.rs |
Re-exports the reference macro and documents usage. |
src/lib/cdm/rust-macros/pvm-cdm/tests/reference_shape.rs |
Adds a compile-shape test for generated reference methods. |
src/lib/cdm/rust-macros/src/lib.rs |
Updates cdm::import! to emit SDK ABI imports plus CDM references. |
src/lib/contracts/src/detection.ts |
Reads CDM package names from Cargo metadata. |
src/lib/contracts/src/index.ts |
Removes readCdmPackage from public exports. |
src/lib/contracts/src/pipeline.ts |
Updates Rust artifact paths and removes post-build CDM package discovery. |
src/lib/contracts/tests/install-roundtrip.test.ts |
Adds ABI/metadata save round-trip coverage. |
src/templates/guide/Cargo.toml |
Updates guide workspace dependencies to the new SDK/CDM crates. |
src/templates/guide/contracts/app-api/Cargo.toml |
Migrates app-api dependencies and CDM metadata. |
src/templates/guide/contracts/app-api/lib.rs |
Rewrites app-api counter contract with new SDK macros/storage. |
src/templates/guide/contracts/support-contract/Cargo.toml |
Migrates support contract dependencies and metadata. |
src/templates/guide/contracts/support-contract/lib.rs |
Rewrites support contract to call app-api via CDM import. |
src/templates/instagram/Cargo.toml |
Updates Instagram workspace dependencies. |
src/templates/instagram/contracts/instagram/Cargo.toml |
Migrates Instagram contract dependencies and metadata. |
src/templates/instagram/contracts/instagram/lib.rs |
Rewrites Instagram contract using new SDK storage patterns. |
src/templates/shared-counter/Cargo.toml |
Updates shared-counter workspace dependencies. |
src/templates/shared-counter/contracts/counter/Cargo.toml |
Migrates counter dependencies and CDM metadata. |
src/templates/shared-counter/contracts/counter/lib.rs |
Rewrites counter contract with new SDK storage/macros. |
src/templates/shared-counter/contracts/counter-reader/Cargo.toml |
Migrates reader dependencies and metadata. |
src/templates/shared-counter/contracts/counter-reader/lib.rs |
Rewrites reader to use CDM import and SDK calls. |
src/templates/shared-counter/contracts/counter-writer/Cargo.toml |
Migrates writer dependencies and metadata. |
src/templates/shared-counter/contracts/counter-writer/lib.rs |
Rewrites writer to use CDM import and SDK calls. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| [workspace] | ||
| resolver = "2" | ||
| members = ["src/contract", "src/lib/cdm/rust", "src/lib/cdm/rust-macros"] | ||
| members = ["src/contract", "src/lib/cdm/rust", "src/lib/cdm/rust-macros", "src/lib/cdm/import-test"] |
| [workspace] | ||
| resolver = "2" | ||
| members = ["src/contract", "src/lib/cdm/rust", "src/lib/cdm/rust-macros"] | ||
| members = ["src/contract", "src/lib/cdm/rust", "src/lib/cdm/rust-macros", "src/lib/cdm/import-test"] |
Comment on lines
+190
to
+198
| /// Returns `Address::ZERO` when the name is unregistered. | ||
| #[pvm_contract_sdk::method] | ||
| pub fn get_address(&self, contract_name: String) -> Address { | ||
| let info = self.info.get(&contract_name); | ||
| if info.version_count == 0 { | ||
| return Address::ZERO; | ||
| } | ||
| let latest = info.version_count - 1; | ||
| self.published_address.get(&(contract_name, latest)) |
Comment on lines
+201
to
+205
| /// Metadata URI of the latest published version of `contract_name`. | ||
| /// Returns the empty string when the name is unregistered. | ||
| #[pvm_contract_sdk::method] | ||
| pub fn get_metadata_uri(&self, contract_name: String) -> String { | ||
| let info = self.info.get(&contract_name); |
Comment on lines
+213
to
+217
| /// Address of a specific version of `contract_name`. | ||
| /// Returns `Address::ZERO` when the version is unregistered. | ||
| #[pvm_contract_sdk::method] | ||
| pub fn get_address_at_version(&self, contract_name: String, version: Version) -> Address { | ||
| self.published_address.get(&(contract_name, version)) |
| detectDeploymentOrder, | ||
| detectDeploymentOrderLayered, | ||
| readCdmPackage, | ||
| getGitRemoteUrl, |
Comment on lines
+9
to
+11
| [package.metadata.cdm-package] | ||
| name = "@cdm/contract-registry" | ||
|
|
| #![cfg_attr(not(feature = "abi-gen"), no_main, no_std)] | ||
|
|
||
| use pvm_contract as pvm; | ||
| cdm::import!("@example/counter"); |
| #![cfg_attr(not(feature = "abi-gen"), no_main, no_std)] | ||
|
|
||
| use pvm_contract as pvm; | ||
| cdm::import!("@example/counter"); |
| #![cfg_attr(not(feature = "abi-gen"), no_main, no_std)] | ||
|
|
||
| use pvm_contract as pvm; | ||
| cdm::import!("@example/app-api"); |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Open issues: