Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Smart Contract Upgradability Documentation: Addressing Field Changes and Migration #1408

Open
sczembor opened this issue Mar 6, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@sczembor
Copy link
Contributor

sczembor commented Mar 6, 2024

The current section on smart contract upgradability in the documentation contains information on adding new functions. However, it is missing any info regarding the following:

  1. Adding New Fields: How can developers incorporate new fields (storage variables) into an existing smart contract after deployment?
struct contract {
   users: Vec<address>,
}

migrate to ↓

struct contract {
   users: Vec<address>,
   funds: Vec<u64>, // new field
}
  1. Migrating Existing Fields: In scenarios where modifications are required to existing fields (e.g., changing data types, renaming)
struct contract {
   users: Vec<address>,
   funds: Vec<u64>,
}

migrate to ↓

struct contract {
   user_funds: Map<address, u64>
}
@sczembor sczembor added the enhancement New feature or request label Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant