Skip to content

Commit

Permalink
Update to new ic-agent version
Browse files Browse the repository at this point in the history
  • Loading branch information
adamspofford-dfinity committed Nov 15, 2023
1 parent e91c27c commit 1e9cf32
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 35 deletions.
92 changes: 79 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ rust-version = "1.71.1"
license = "Apache-2.0"

[workspace.dependencies]
candid = { version = "0.9.0", features = [ "parser" ] }
ic-agent = "0.29.0"
candid = { version = "0.9.0", features = ["parser"] }
ic-agent = "0.30.1"
ic-asset = { path = "src/canisters/frontend/ic-asset" }
ic-cdk = "0.10.0"
ic-identity-hsm = "0.29.0"
ic-utils = "0.29.0"
ic-identity-hsm = "0.30.1"
ic-utils = "0.30.1"

aes-gcm = "0.9.4"
anyhow = "1.0.56"
anstyle = "1.0.0"
argon2 = "0.4.0"
backoff = { version = "0.4.0", features = [ "futures", "tokio" ] }
backoff = { version = "0.4.0", features = ["futures", "tokio"] }
base64 = "0.13.0"
byte-unit = "4.0.14"
bytes = "1.2.1"
Expand Down Expand Up @@ -69,19 +69,19 @@ url = "2.1.0"
walkdir = "2.3.2"

[patch.crates-io.ic-agent]
version = "0.29.0"
version = "0.30.1"
git = "https://github.com/dfinity/agent-rs.git"
rev = "b91b85b7b6ba6bfaf9dfd616b7c7c8f966bf8f68"
rev = "5aa3ba7d8c38d44910900af7ed7d8a25402fa9d9"

[patch.crates-io.ic-identity-hsm]
version = "0.29.0"
version = "0.30.1"
git = "https://github.com/dfinity/agent-rs.git"
rev = "b91b85b7b6ba6bfaf9dfd616b7c7c8f966bf8f68"
rev = "5aa3ba7d8c38d44910900af7ed7d8a25402fa9d9"

[patch.crates-io.ic-utils]
version = "0.29.0"
version = "0.30.1"
git = "https://github.com/dfinity/agent-rs.git"
rev = "b91b85b7b6ba6bfaf9dfd616b7c7c8f966bf8f68"
rev = "5aa3ba7d8c38d44910900af7ed7d8a25402fa9d9"

[profile.release]
panic = 'abort'
Expand Down
6 changes: 3 additions & 3 deletions src/canisters/frontend/icx-asset/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ async fn main() -> anyhow::Result<()> {
let logger = support::new_logger();

let agent = Agent::builder()
.with_transport(
agent::http_transport::ReqwestHttpReplicaV2Transport::create(opts.replica.clone())?,
)
.with_transport(agent::http_transport::ReqwestTransport::create(
opts.replica.clone(),
)?)
.with_boxed_identity(create_identity(opts.pem))
.build()?;

Expand Down
2 changes: 1 addition & 1 deletion src/dfx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ mime.workspace = true
mime_guess.workspace = true
net2 = "0.2.34"
num-traits.workspace = true
os_str_bytes = "6.3.0"
os_str_bytes = { version = "6.3.0", features = ["conversions"] }
patch = "0.7.0"
pem.workspace = true
petgraph = "0.6.0"
Expand Down
6 changes: 3 additions & 3 deletions src/dfx/src/commands/canister/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use candid::Principal;
use clap::Parser;
use dfx_core::identity::CallSender;
use ic_agent::agent::Transport;
use ic_agent::{agent::http_transport::ReqwestHttpReplicaV2Transport, RequestId};
use ic_agent::{agent::http_transport::ReqwestTransport, RequestId};
use std::{fs::File, path::Path};
use std::{io::Read, str::FromStr};

Expand Down Expand Up @@ -40,8 +40,8 @@ pub async fn exec(
message.validate()?;

let network = message.network.clone();
let transport = ReqwestHttpReplicaV2Transport::create(network)
.context("Failed to create transport object.")?;
let transport =
ReqwestTransport::create(network).context("Failed to create transport object.")?;
let content = hex::decode(&message.content).context("Failed to decode message content.")?;
let canister_id = Principal::from_text(message.canister_id.clone())
.with_context(|| format!("Failed to parse canister id {:?}.", message.canister_id))?;
Expand Down
4 changes: 2 additions & 2 deletions src/dfx/src/lib/replica/status.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use crate::lib::error::DfxResult;
use anyhow::{bail, Context};
use ic_agent::agent::http_transport::ReqwestHttpReplicaV2Transport;
use ic_agent::agent::http_transport::ReqwestTransport;
use ic_agent::Agent;
use std::time::Duration;

pub async fn ping_and_wait(url: &str) -> DfxResult {
let agent = Agent::builder()
.with_transport(
ReqwestHttpReplicaV2Transport::create(url)
ReqwestTransport::create(url)
.with_context(|| format!("Failed to create replica transport from url {url}.",))?,
)
.build()
Expand Down
13 changes: 13 additions & 0 deletions src/dfx/src/lib/sign/sign_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ impl Transport for SignTransport {
Box::pin(run(self, envelope))
}

fn read_subnet_state(
&self,
_: Principal,
_: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, AgentError>> + Send + '_>> {
async fn run() -> Result<Vec<u8>, AgentError> {
Err(AgentError::MessageError(
"read_subnet_state calls not supported".to_string(),
))
}
Box::pin(run())
}

fn call<'a>(
&'a self,
_effective_canister_id: Principal,
Expand Down
4 changes: 2 additions & 2 deletions src/dfx/src/util/currency_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::lib::{
use anyhow::Context;
use dfx_core::config::model::dfinity::DEFAULT_IC_GATEWAY;
use fn_error_context::context;
use ic_agent::{agent::http_transport::ReqwestHttpReplicaV2Transport, Agent};
use ic_agent::{agent::http_transport::ReqwestTransport, Agent};
use rust_decimal::Decimal;

/// How many cycles you get per XDR when converting ICP to cycles
Expand All @@ -16,7 +16,7 @@ const CYCLES_PER_XDR: u128 = 1_000_000_000_000;
pub async fn as_cycles_with_current_exchange_rate(icpts: &ICPTs) -> DfxResult<u128> {
let agent = Agent::builder()
.with_transport(
ReqwestHttpReplicaV2Transport::create(DEFAULT_IC_GATEWAY)
ReqwestTransport::create(DEFAULT_IC_GATEWAY)
.context("Failed to create transport object to default ic gateway.")?,
)
.build()
Expand Down

0 comments on commit 1e9cf32

Please sign in to comment.