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

feat: finalize call api #557

Draft
wants to merge 8 commits into
base: next
Choose a base branch
from
Draft

Conversation

lwshang
Copy link
Contributor

@lwshang lwshang commented Feb 14, 2025

SDK-1950

Description

For maintainable better user experience, this PR made some fundamental changes to the inter-canister call API (call.rs).

Constructors

Replaced Call::new() with Call::bounded_wait() and Call::unbounded_wait().

Execution

  • impl IntoFuture for Call. So that a Call can be .await directly instead of invoking the call* method. No awkward Call::new().call() syntax.

  • Replaced the oneway execution with the shorter and clearer Call::oneway() method.

  • After a Call is executed by await , a candid()/candid_tuple() method can be chained to decode the response.

Errors

  • Error: The top-level error type encapsulating all possible errors.
  • CallFailed: Errors related to the execution of the call itself.
  • CallRejected: Errors when an inter-canister call is rejected.
  • CallPerformFailed: Errors when the ic0.call_perform operation fails.
  • CandidDecodeFailed: Errors when the response cannot be decoded as Candid.
Error
├── CallFailed
│   ├── CallPerformFailed
│   └── CallRejected
└── CandidDecodeFailed

Also a CallErrorExt trait is added and implemented for all error types above.
The trait has two methods:

  • is_clean_reject()
  • is_immediately_retryable()

Note

The CallErrorExt trait must be explicitly imported to access its methods.

How Has This Been Tested?

e2e tests: call.rs

Checklist:

  • The title of this PR complies with Conventional Commits.
  • I have edited the CHANGELOG accordingly.
  • I have made corresponding changes to the documentation.

@lwshang lwshang changed the base branch from main to next February 14, 2025 17:02
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.

1 participant