Skip to content

refactor: convert get_deposit_address from query to update endpoint#183

Open
lpahlavi wants to merge 2 commits intomainfrom
lpahlavi/get-deposit-address-update
Open

refactor: convert get_deposit_address from query to update endpoint#183
lpahlavi wants to merge 2 commits intomainfrom
lpahlavi/get-deposit-address-update

Conversation

@lpahlavi
Copy link
Copy Markdown
Contributor

@lpahlavi lpahlavi commented Apr 27, 2026

Summary

Reverts get_deposit_address to an update endpoint to avoid a future breaking change. Switching from query to update later would break callers who hard-code the call type, and there are plausible extensions that would require it:

  • An optional update_balance flag to start automated deposit monitoring in the same call
  • SPL token support may need to consult on-chain state at address-derivation time

As 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

Copilot AI review requested due to automatic review settings April 27, 2026 09:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_address in the canister (minter/src/main.rs) to an #[ic_cdk::update] async fn that calls lazy_get_schnorr_master_key and derives the address directly.
  • Removed the synchronous get_deposit_address wrapper (and its trap-behavior tests) from minter/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.

@lpahlavi lpahlavi force-pushed the lpahlavi/get-deposit-address-update branch from 041fa82 to c9be56f Compare April 27, 2026 10:02
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>
Copilot AI review requested due to automatic review settings April 27, 2026 10:56
@lpahlavi lpahlavi force-pushed the lpahlavi/get-deposit-address-update branch from c9be56f to f6ce814 Compare April 27, 2026 10:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread minter/src/address/mod.rs
@lpahlavi lpahlavi changed the title fix: convert get_deposit_address from query to update endpoint refactor: convert get_deposit_address from query to update endpoint Apr 27, 2026
@lpahlavi lpahlavi marked this pull request as ready for review April 27, 2026 14:18
Copilot AI review requested due to automatic review settings April 27, 2026 14:18
@lpahlavi lpahlavi requested a review from a team as a code owner April 27, 2026 14:18
@lpahlavi lpahlavi requested review from THLO and maciejdfinity April 27, 2026 14:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants