Skip to content

Commit

Permalink
chore: QoL improvements (#462)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyan-dfinity authored Aug 25, 2023
1 parent 523e93e commit b8f7dd8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

* Add `From` trait to coerce `candid::Error` into `ic_agent::AgentError`.
* Add `Agent::set_arc_identity` method to switch identity.

## [0.26.1] - 2023-08-22

Switched from rustls crate to rustls-webpki fork to address https://rustsec.org/advisories/RUSTSEC-2023-0052
Expand Down
6 changes: 6 additions & 0 deletions ic-agent/src/agent/agent_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ impl Display for RejectResponse {
}
}

impl From<candid::Error> for AgentError {
fn from(e: candid::Error) -> AgentError {
AgentError::CandidError(e.into())
}
}

/// A HTTP error from the replica.
pub struct HttpErrorPayload {
/// The HTTP status code.
Expand Down
8 changes: 8 additions & 0 deletions ic-agent/src/agent/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,14 @@ impl Agent {
{
self.identity = Arc::new(identity);
}
/// Set the arc identity provider for signing messages.
///
/// NOTE: if you change the identity while having update calls in
/// flight, you will not be able to [Agent::poll] the status of these
/// messages.
pub fn set_arc_identity(&mut self, identity: Arc<dyn Identity>) {
self.identity = identity;
}

/// By default, the agent is configured to talk to the main Internet Computer, and verifies
/// responses using a hard-coded public key.
Expand Down

0 comments on commit b8f7dd8

Please sign in to comment.