From b76a5e6493884d3c16022c5501bc14864f29a638 Mon Sep 17 00:00:00 2001 From: Adam Spofford <93943719+adamspofford-dfinity@users.noreply.github.com> Date: Thu, 21 Sep 2023 14:38:26 -0700 Subject: [PATCH] chore: update to agent-rs 0.28 (#3378) --- Cargo.lock | 40 ++++++++++++++----- Cargo.toml | 18 ++++----- src/dfx-core/src/identity/mod.rs | 16 +++++++- .../src/commands/canister/request_status.rs | 6 +-- 4 files changed, 56 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a3d07f31eb..cae09245f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1362,7 +1362,7 @@ dependencies = [ "ic-agent", "ic-asset", "ic-identity-hsm", - "ic-utils 0.27.0", + "ic-utils 0.28.0", "ic-wasm", "indicatif", "itertools 0.10.5", @@ -1431,7 +1431,7 @@ dependencies = [ "humantime-serde", "ic-agent", "ic-identity-hsm", - "ic-utils 0.27.0", + "ic-utils 0.28.0", "k256 0.11.6", "keyring", "lazy_static", @@ -2386,8 +2386,8 @@ dependencies = [ [[package]] name = "ic-agent" -version = "0.27.0" -source = "git+https://github.com/dfinity/agent-rs.git?rev=eaba57b6cda43abc04581d61d19c1f2809cc6b90#eaba57b6cda43abc04581d61d19c1f2809cc6b90" +version = "0.28.0" +source = "git+https://github.com/dfinity/agent-rs.git?rev=9c4db330d96938d95eda69bbf5878db91aae0aa1#9c4db330d96938d95eda69bbf5878db91aae0aa1" dependencies = [ "backoff", "candid 0.9.6", @@ -2396,6 +2396,7 @@ dependencies = [ "http", "http-body", "ic-certification 0.27.0", + "ic-transport-types", "ic-verify-bls-signature", "k256 0.13.1", "leb128", @@ -2432,7 +2433,7 @@ dependencies = [ "globset", "hex", "ic-agent", - "ic-utils 0.27.0", + "ic-utils 0.28.0", "itertools 0.10.5", "json5", "mime", @@ -2532,7 +2533,8 @@ dependencies = [ [[package]] name = "ic-certification" version = "0.27.0" -source = "git+https://github.com/dfinity/agent-rs.git?rev=eaba57b6cda43abc04581d61d19c1f2809cc6b90#eaba57b6cda43abc04581d61d19c1f2809cc6b90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1120544357d4d2f7540dd5290b952c6305afe24c9620d423e2239560adca2535" dependencies = [ "hex", "serde", @@ -2750,8 +2752,8 @@ dependencies = [ [[package]] name = "ic-identity-hsm" -version = "0.27.0" -source = "git+https://github.com/dfinity/agent-rs.git?rev=eaba57b6cda43abc04581d61d19c1f2809cc6b90#eaba57b6cda43abc04581d61d19c1f2809cc6b90" +version = "0.28.0" +source = "git+https://github.com/dfinity/agent-rs.git?rev=9c4db330d96938d95eda69bbf5878db91aae0aa1#9c4db330d96938d95eda69bbf5878db91aae0aa1" dependencies = [ "hex", "ic-agent", @@ -2844,6 +2846,22 @@ dependencies = [ "wsl", ] +[[package]] +name = "ic-transport-types" +version = "0.28.0" +source = "git+https://github.com/dfinity/agent-rs.git?rev=9c4db330d96938d95eda69bbf5878db91aae0aa1#9c4db330d96938d95eda69bbf5878db91aae0aa1" +dependencies = [ + "candid 0.9.6", + "hex", + "ic-certification 0.27.0", + "leb128", + "serde", + "serde_bytes", + "serde_repr", + "sha2 0.10.7", + "thiserror", +] + [[package]] name = "ic-types" version = "0.8.0" @@ -2905,8 +2923,8 @@ dependencies = [ [[package]] name = "ic-utils" -version = "0.27.0" -source = "git+https://github.com/dfinity/agent-rs.git?rev=eaba57b6cda43abc04581d61d19c1f2809cc6b90#eaba57b6cda43abc04581d61d19c1f2809cc6b90" +version = "0.28.0" +source = "git+https://github.com/dfinity/agent-rs.git?rev=9c4db330d96938d95eda69bbf5878db91aae0aa1#9c4db330d96938d95eda69bbf5878db91aae0aa1" dependencies = [ "async-trait", "candid 0.9.6", @@ -2982,7 +3000,7 @@ dependencies = [ "humantime", "ic-agent", "ic-asset", - "ic-utils 0.27.0", + "ic-utils 0.28.0", "libflate", "num-traits", "pem 1.1.1", diff --git a/Cargo.toml b/Cargo.toml index efa78f4c66..e0bff1eb37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,11 +19,11 @@ license = "Apache-2.0" [workspace.dependencies] candid = "0.9.0" -ic-agent = "0.27.0" +ic-agent = "0.28.0" ic-asset = { path = "src/canisters/frontend/ic-asset" } ic-cdk = "0.10.0" -ic-identity-hsm = "0.27.0" -ic-utils = "0.27.0" +ic-identity-hsm = "0.28.0" +ic-utils = "0.28.0" aes-gcm = "0.9.4" anyhow = "1.0.56" @@ -69,19 +69,19 @@ url = "2.1.0" walkdir = "2.3.2" [patch.crates-io.ic-agent] -version = "0.27.0" +version = "0.28.0" git = "https://github.com/dfinity/agent-rs.git" -rev = "eaba57b6cda43abc04581d61d19c1f2809cc6b90" +rev = "9c4db330d96938d95eda69bbf5878db91aae0aa1" [patch.crates-io.ic-identity-hsm] -version = "0.27.0" +version = "0.28.0" git = "https://github.com/dfinity/agent-rs.git" -rev = "eaba57b6cda43abc04581d61d19c1f2809cc6b90" +rev = "9c4db330d96938d95eda69bbf5878db91aae0aa1" [patch.crates-io.ic-utils] -version = "0.27.0" +version = "0.28.0" git = "https://github.com/dfinity/agent-rs.git" -rev = "eaba57b6cda43abc04581d61d19c1f2809cc6b90" +rev = "9c4db330d96938d95eda69bbf5878db91aae0aa1" [profile.release] panic = 'abort' diff --git a/src/dfx-core/src/identity/mod.rs b/src/dfx-core/src/identity/mod.rs index a888f42464..ccee470205 100644 --- a/src/dfx-core/src/identity/mod.rs +++ b/src/dfx-core/src/identity/mod.rs @@ -16,7 +16,9 @@ use crate::identity::identity_file_locations::IdentityFileLocations; use crate::json::{load_json_file, save_json_file}; use candid::Principal; use ic_agent::agent::EnvelopeContent; -use ic_agent::identity::{AnonymousIdentity, BasicIdentity, Secp256k1Identity}; +use ic_agent::identity::{ + AnonymousIdentity, BasicIdentity, Delegation, Secp256k1Identity, SignedDelegation, +}; use ic_agent::Signature; use ic_identity_hsm::HardwareIdentity; pub use identity_manager::{ @@ -253,9 +255,21 @@ impl ic_agent::Identity for Identity { self.inner.public_key() } + fn delegation_chain(&self) -> Vec { + self.inner.delegation_chain() + } + fn sign(&self, content: &EnvelopeContent) -> Result { self.inner.sign(content) } + + fn sign_arbitrary(&self, content: &[u8]) -> Result { + self.inner.sign_arbitrary(content) + } + + fn sign_delegation(&self, content: &Delegation) -> Result { + self.inner.sign_delegation(content) + } } impl AsRef for Identity { diff --git a/src/dfx/src/commands/canister/request_status.rs b/src/dfx/src/commands/canister/request_status.rs index b28f82e064..ba20dcccc6 100644 --- a/src/dfx/src/commands/canister/request_status.rs +++ b/src/dfx/src/commands/canister/request_status.rs @@ -8,7 +8,7 @@ use backoff::backoff::Backoff; use backoff::ExponentialBackoff; use candid::Principal; use clap::Parser; -use ic_agent::agent::{Replied, RequestStatusResponse}; +use ic_agent::agent::RequestStatusResponse; use ic_agent::{AgentError, RequestId}; use std::str::FromStr; @@ -49,7 +49,7 @@ pub async fn exec(env: &dyn Environment, opts: RequestStatusOpts) -> DfxResult { .or_else(|_| canister_id_store.get(callee_canister))?; let mut retry_policy = ExponentialBackoff::default(); - let Replied::CallReplied(blob) = async { + let blob = async { let mut request_accepted = false; loop { match agent @@ -57,7 +57,7 @@ pub async fn exec(env: &dyn Environment, opts: RequestStatusOpts) -> DfxResult { .await .context("Failed to fetch request status.")? { - RequestStatusResponse::Replied { reply } => return Ok(reply), + RequestStatusResponse::Replied(reply) => return Ok(reply.arg), RequestStatusResponse::Rejected(response) => { return Err(DfxError::new(AgentError::ReplicaError(response))) }