Repository navigation
Update contract constructor documentation - #2741
Conversation
There was a problem hiding this comment.
Pull request overview
Updates Soroban documentation to use atomic contract constructors instead of post-deployment initialization.
Changes:
- Renames initialization functions to
__constructor. - Passes constructor arguments through
register,deploy_v2, and CLI deployment. - Updates deployment guidance and examples.
Recommendation: NEEDS-CHANGES — complete the migration in the remaining BLS signature and authorization examples.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
docs/learn/migrate/evm/smart-contract-deployment.mdx |
Migrates vault deployment to constructor arguments. |
docs/learn/fundamentals/contract-development/contract-interactions/cross-contract.mdx |
Documents constructor deployment APIs. |
docs/build/guides/storage/choosing-the-right-storage.mdx |
Converts storage initialization to a constructor. |
docs/build/guides/auth/check-auth-tutorials.mdx |
Passes account signers during registration. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
ElliotFriend
left a comment
There was a problem hiding this comment.
this looks great! thank you for submitting the changes!
i left one question, but it's more a reflection of my own curiosity. certainly, it's not a blocker, and you are welcome to merge whenever you're ready.
|
|
||
| let client = create_client(&env); | ||
| client.init(&pk); | ||
| let contract_id = env.register(IncrementContract, IncrementContractArgs::__constructor(&pk)); |
There was a problem hiding this comment.
question about this one: doesn't the "normal" register pattern go more like env.register(IncrementContract, (&pk,));?
I see that this change does indeed reflect the source code in the examples repo, but I'm curious why this pattern is used here, but not in other places?
There was a problem hiding this comment.
The pattern was introduced or the feature was introduced at some time and people people can use either approach. The advantage of using the args is that it gives you a typed function to pass the values through so you know you're gonna get the types right and the number of parameters right whereas you're sort of winging it when you're using a tuple but the tuple approach is very valid valid too
There was a problem hiding this comment.
The pattern was introduced or the feature was introduced at some time and people people can use either approach. The advantage of using the args is that it gives you a typed function to pass the values through so you know you're gonna get the types right and the number of parameters right whereas you're sort of winging it when you're using a tuple but the tuple approach is very valid valid too
There was a problem hiding this comment.
I'm gonna leave this as is because this is what's used in the example that's being referenced. We should probably think about maybe normalizing the examples and the docs usage of it. Or you, know this, is also minor enough that it it maybe doesn't matter.
What
Update Soroban documentation and examples to use
__constructordeployment arguments anddeploy_v2orregisterinstead of post-deployment initialization.Why
The existing examples describe the pre-constructor initialization flow, which no longer matches current practices.
Related stellar/soroban-examples#412