refactor: convert get_deposit_address from query to update endpoint#183
Open
refactor: convert get_deposit_address from query to update endpoint#183
get_deposit_address from query to update endpoint#183Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR changes the get_deposit_address canister method from a query to an update so it can safely fetch and cache the Schnorr master key on-demand (via lazy_get_schnorr_master_key) rather than relying on a startup-timer cache warmup and potentially trapping during early initialization.
Changes:
- Converted
get_deposit_addressin the canister (minter/src/main.rs) to an#[ic_cdk::update] async fnthat callslazy_get_schnorr_master_keyand derives the address directly. - Removed the synchronous
get_deposit_addresswrapper (and its trap-behavior tests) fromminter/src/address. - Updated the Candid interface (
.did), integration test call path (query → update), and README CLI example accordingly.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
minter/src/main.rs |
Switches get_deposit_address to an async update endpoint and derives the address after lazily fetching/caching the master key. |
minter/src/address/mod.rs |
Removes the old synchronous wrapper that trapped when the key wasn’t cached. |
minter/src/address/tests.rs |
Removes unit tests that asserted the wrapper’s trap behavior. |
minter/cksol_minter.did |
Updates the service signature to remove the query annotation for get_deposit_address. |
integration_tests/src/lib.rs |
Updates the integration test helper to call get_deposit_address via update. |
README.md |
Updates the CLI example to remove --query for get_deposit_address. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
041fa82 to
c9be56f
Compare
The endpoint previously trapped if the master key was not yet cached, since query calls cannot make inter-canister calls to fetch it. As an update call it can use lazy_get_schnorr_master_key to fetch on demand, removing the initialization race. - Switch #[ic_cdk::query] to #[ic_cdk::update] + async in main.rs - Remove the synchronous get_deposit_address wrapper from address/mod.rs - Remove the now-obsolete unit tests for that wrapper - Update the .did file (drop the `query` annotation) - Update the integration test helper to use update_call - Remove --query from the README CLI example Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
c9be56f to
f6ce814
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
get_deposit_address from query to update endpoint
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.
Summary
Reverts
get_deposit_addressto anupdateendpoint to avoid a future breaking change. Switching fromquerytoupdatelater would break callers who hard-code the call type, and there are plausible extensions that would require it:update_balanceflag to start automated deposit monitoring in the same callAs a secondary benefit, the endpoint no longer traps if the Schnorr master key hasn't been cached yet — it fetches it lazily via
lazy_get_schnorr_master_key.🤖 Generated with Claude Code