feat: add upgradeability to CrossmintContractFactory - #11
Open
alberto-crossmint wants to merge 5 commits into
Open
feat: add upgradeability to CrossmintContractFactory#11alberto-crossmint wants to merge 5 commits into
alberto-crossmint wants to merge 5 commits into
Conversation
- Added custom upgrade function with admin role authorization - Removed OpenZeppelin upgradeable dependencies due to type compatibility issues - Implemented simple upgrade mechanism using env.deployer().update_current_contract_wasm() - All existing tests continue to pass Co-Authored-By: Alberto Garc\u00EDa <alberto@paella.dev>
Contributor
|
Original prompt from Alberto: |
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
⚙️ Control Options:
|
Comment on lines
+16
to
+17
| stellar-upgradeable = { git = "https://github.com/OpenZeppelin/stellar-contracts", tag = "v0.3.0" } | ||
| stellar-upgradeable-macros = { git = "https://github.com/OpenZeppelin/stellar-contracts", tag = "v0.3.0" } |
Collaborator
Author
There was a problem hiding this comment.
Are you using these libraries? If not, why not
Contributor
|
Good catch! You're absolutely right - I'm not using these libraries in the final implementation. I initially added them when attempting to use OpenZeppelin's upgradeable pattern, but had to switch to a custom implementation due to type compatibility issues (the I'll remove these unused dependencies now to clean up the Cargo.toml. Thanks for pointing this out! |
- Removed stellar-upgradeable and stellar-upgradeable-macros dependencies - These were added during initial OpenZeppelin implementation attempt but not used in final custom upgrade implementation - Addresses PR comment about unused dependencies Co-Authored-By: Alberto Garc\u00EDa <alberto@paella.dev>
Co-Authored-By: Alberto Garc\u00EDa <alberto@paella.dev>
- Add stellar-upgradeable and stellar-upgradeable-macros dependencies - Apply #[derive(Upgradeable)] macro to CrossmintContractFactory struct - Implement UpgradeableInternal trait with admin-only authorization - Update constructor to use Address by value instead of reference - Maintain existing access control functionality with set_admin and grant_role - All existing tests pass with new upgradeable implementation Co-Authored-By: Alberto Garc\u00EDa <alberto@paella.dev>
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.
feat: implement OpenZeppelin upgradeable pattern for factory contract
Summary
This PR adds upgradeability to the CrossmintContractFactory using OpenZeppelin's upgradeable contract pattern. The implementation includes:
stellar-upgradeableandstellar-upgradeable-macrosdependencies#[derive(Upgradeable)]macro to the contract structUpgradeableInternaltrait with admin-only upgrade authorizationAddressby value instead of referenceAll existing tests pass, maintaining backward compatibility for current functionality.
Test plan
The OpenZeppelin upgradeable implementation has been tested with the following approach:
#[derive(Upgradeable)]macro andUpgradeableInternaltrait are correctly implementedManual Testing Required: End-to-end upgrade functionality testing should be performed to verify the actual upgrade mechanism works correctly with new WASM deployment.
Review & Testing Checklist for Human
_require_authimplementation - Verify the manual authorization logic is secure and follows OpenZeppelin best practices#[derive(Upgradeable)]macro andUpgradeableInternaltrait are properly implemented according to OpenZeppelin docsDiagram
%%{ init : { "theme" : "default" }}%% graph TD CargoToml["contracts/crossmint-contract-factory/<br/>Cargo.toml"]:::minor-edit LibRs["contracts/crossmint-contract-factory/<br/>src/lib.rs"]:::major-edit TestRs["contracts/crossmint-contract-factory/<br/>src/test.rs"]:::context StellarUpgradeable["stellar-upgradeable<br/>(OpenZeppelin)"]:::context StellarUpgradeableMacros["stellar-upgradeable-macros<br/>(OpenZeppelin)"]:::context CargoToml -->|"adds dependencies"| StellarUpgradeable CargoToml -->|"adds dependencies"| StellarUpgradeableMacros LibRs -->|"derives Upgradeable"| StellarUpgradeableMacros LibRs -->|"implements UpgradeableInternal"| StellarUpgradeable TestRs -->|"tests contract"| LibRs subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
&AddresstoAddressparameter - potential breaking change_require_authmethod uses manual admin checking rather than full OpenZeppelin access control integrationSession Info: Requested by Alberto García (@alberto-crossmint)
Devin Session: https://app.devin.ai/sessions/91520156b52b4a838044b0dee20803fc