Skip to content

Commit 10c145d

Browse files
committed
XC-502: Update ic-cdk
1 parent cefeb12 commit 10c145d

File tree

18 files changed

+267
-354
lines changed

18 files changed

+267
-354
lines changed

Cargo.lock

Lines changed: 40 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ ic-metrics-encoder = { workspace = true }
3131
ic-stable-structures = { workspace = true }
3232
ic-canister-log = { workspace = true }
3333
ic-cdk = { workspace = true }
34-
ic-cdk-macros = { workspace = true }
3534
ic-management-canister-types = { workspace = true }
36-
maplit = "1.0"
35+
maplit = { workspace = true }
3736
minicbor = { workspace = true }
3837
serde = { workspace = true }
3938
serde_bytes = { workspace = true }
@@ -62,11 +61,11 @@ ic-error-types = { workspace = true }
6261
ic-management-canister-types = { workspace = true }
6362
ic-metrics-assert = { workspace = true }
6463
ic-test-utilities-load-wasm = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-26_01-31-base" }
65-
maplit = "1"
64+
maplit = { workspace = true }
6665
pocket-ic = { workspace = true }
6766
proptest = { workspace = true }
6867
rand = "0.8"
69-
tokio = "1.44.1"
68+
tokio = { workspace = true }
7069

7170
[workspace.dependencies]
7271
alloy-consensus = "1.0.26"
@@ -76,20 +75,16 @@ alloy-rpc-types = "1.0.23"
7675
assert_matches = "1.5.0"
7776
async-trait = "0.1.88"
7877
candid = { version = "0.10.13" }
79-
canhttp = { version = "0.2.0", features = ["json", "multi"] }
78+
canhttp = { git = "https://github.com/dfinity/canhttp/", features = ["json", "multi"], rev = "0b935a2ba6defb0265bb94bbfb5c5675975531a3" }
8079
canlog = { version = "0.2.0", features = ["derive"] }
8180
candid_parser = { version = "0.1.4" }
82-
ciborium = "0.2.2"
8381
derive_more = { version = "2.0.1", features = ["from", "into"] }
8482
ethnum = { version = "1.5.0", features = ["serde"] }
85-
futures = "0.3.31"
86-
futures-channel = "0.3.31"
87-
futures-util = "0.3.31"
8883
getrandom = { version = "0.2", features = ["custom"] }
8984
hex = "0.4.3"
9085
http = "1.3.1"
9186
ic-canister-log = "0.2.0"
92-
ic-cdk = "0.17.2"
87+
ic-cdk = "0.18.7"
9388
ic-cdk-bindgen = "0.1"
9489
ic-cdk-macros = "0.17.2"
9590
ic-certified-map = "0.4"
@@ -98,12 +93,9 @@ ic-management-canister-types = "0.3"
9893
ic-metrics-assert = { version = "0.1.1", features = ["pocket_ic"] }
9994
ic-metrics-encoder = "1.1"
10095
ic-stable-structures = "0.6.8"
101-
itertools = "0.14.0"
10296
maplit = "1.0.2"
10397
minicbor = { version = "1.0.0", features = ["alloc", "derive"] }
10498
num-bigint = "0.4.6"
105-
num-traits = "0.2.19"
106-
pin-project = "1.1.10"
10799
pocket-ic = "9.0.0"
108100
proptest = "1.6.0"
109101
serde = "1.0"
@@ -113,7 +105,6 @@ sha2 = "0.10.8"
113105
strum = { version = "0.27.1", features = ["derive"] }
114106
tokio = "1.44.1"
115107
tower = "0.5.2"
116-
tower-layer = "0.3.3"
117108
tower-http = "0.6.2"
118109
thiserror = "2.0.12"
119110
url = "2.5"

dfx.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"dfx": "0.23.0",
32
"canisters": {
43
"evm_rpc": {
54
"candid": "candid/evm_rpc.did",

e2e/motoko/main.mo

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ import Principal "mo:base/Principal";
99
import Text "mo:base/Text";
1010
import Evm "mo:evm";
1111

12-
shared ({ caller = installer }) actor class Main() {
12+
shared ({ caller = installer }) persistent actor class Main() {
1313
type TestCategory = { #staging; #production };
1414

1515
// (`subnet name`, `nodes in subnet`, `expected cycles for JSON-RPC call`)
1616
type SubnetTarget = (Text, Nat32, Nat);
17-
let fiduciarySubnet : SubnetTarget = ("fiduciary", 34, 540_545_600);
17+
transient let fiduciarySubnet : SubnetTarget = ("fiduciary", 34, 400_299_200);
1818

19-
let testTargets = [
19+
transient let testTargets = [
2020
// (`canister module`, `canister type`, `subnet`)
2121
(EvmRpc, #production, fiduciarySubnet),
2222
(EvmRpcStaging, #staging, fiduciarySubnet),
2323
];
2424

2525
// (`RPC service`, `method`)
26-
let ignoredTests = [
26+
transient let ignoredTests = [
2727
(#EthMainnet(#BlockPi), ?"eth_sendRawTransaction"), // "Private transaction replacement (same nonce) with gas price change lower than 10% is not allowed within 30 sec from the previous transaction."
2828
(#EthMainnet(#Llama), ?"eth_sendRawTransaction"), // Non-standard error message
2929
(#ArbitrumOne(#Ankr), null), // Need API key

e2e/rust/src/main.rs

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
use std::str::FromStr;
2-
31
use candid::{candid_method, Principal};
4-
use ic_cdk_macros::update;
5-
62
use evm_rpc_types::{
73
Block, BlockTag, ConsensusStrategy, EthMainnetService, Hex32, MultiRpcResult, ProviderError,
84
RpcConfig, RpcError, RpcResult, RpcService, RpcServices,
95
};
6+
use ic_cdk::{call::Call, update};
7+
use std::str::FromStr;
108

119
fn main() {}
1210

@@ -21,7 +19,7 @@ const CANISTER_ID: Option<&str> = None;
2119
#[update]
2220
#[candid_method(update)]
2321
pub async fn test() {
24-
assert!(ic_cdk::api::is_controller(&ic_cdk::caller()));
22+
assert!(ic_cdk::api::is_controller(&ic_cdk::api::msg_caller()));
2523

2624
let canister_id = Principal::from_str(CANISTER_ID.unwrap())
2725
.expect("Error parsing canister ID environment variable");
@@ -34,18 +32,22 @@ pub async fn test() {
3432
);
3533

3634
// Get cycles cost
37-
let (cycles_result,): (Result<u128, RpcError>,) =
38-
ic_cdk::api::call::call(canister_id, "requestCost", params.clone())
39-
.await
40-
.unwrap();
35+
let cycles_result = Call::unbounded_wait(canister_id, "requestCost")
36+
.with_args(&params)
37+
.await
38+
.unwrap()
39+
.candid::<Result<u128, RpcError>>()
40+
.unwrap();
4141
let cycles = cycles_result
4242
.unwrap_or_else(|e| ic_cdk::trap(&format!("error in `request_cost`: {:?}", e)));
4343

4444
// Call without sending cycles
45-
let (result_without_cycles,): (Result<String, RpcError>,) =
46-
ic_cdk::api::call::call(canister_id, "request", params.clone())
47-
.await
48-
.unwrap();
45+
let result_without_cycles = Call::unbounded_wait(canister_id, "request")
46+
.with_args(&params)
47+
.await
48+
.unwrap()
49+
.candid::<Result<String, RpcError>>()
50+
.unwrap();
4951
match result_without_cycles {
5052
Ok(s) => ic_cdk::trap(&format!("response from `request` without cycles: {:?}", s)),
5153
Err(RpcError::ProviderError(ProviderError::TooFewCycles { expected, .. })) => {
@@ -55,10 +57,13 @@ pub async fn test() {
5557
}
5658

5759
// Call with expected number of cycles
58-
let (result,): (Result<String, RpcError>,) =
59-
ic_cdk::api::call::call_with_payment128(canister_id, "request", params, cycles)
60-
.await
61-
.unwrap();
60+
let result: Result<String, RpcError> = Call::unbounded_wait(canister_id, "request")
61+
.with_args(&params)
62+
.with_cycles(cycles)
63+
.await
64+
.unwrap()
65+
.candid::<Result<String, RpcError>>()
66+
.unwrap();
6267
match result {
6368
Ok(response) => {
6469
// Check response structure around gas price
@@ -72,10 +77,8 @@ pub async fn test() {
7277
}
7378

7479
// Call a Candid-RPC method
75-
let (results,): (MultiRpcResult<Block>,) = ic_cdk::api::call::call_with_payment128(
76-
canister_id,
77-
"eth_getBlockByNumber",
78-
(
80+
let results = Call::unbounded_wait(canister_id, "eth_getBlockByNumber")
81+
.with_args(&(
7982
RpcServices::EthMainnet(Some(vec![
8083
// EthMainnetService::Ankr, // Need API key
8184
EthMainnetService::BlockPi,
@@ -90,11 +93,12 @@ pub async fn test() {
9093
..Default::default()
9194
}),
9295
BlockTag::Number(19709434_u32.into()),
93-
),
94-
10000000000,
95-
)
96-
.await
97-
.unwrap();
96+
))
97+
.with_cycles(10000000000)
98+
.await
99+
.unwrap()
100+
.candid::<MultiRpcResult<Block>>()
101+
.unwrap();
98102
match results {
99103
MultiRpcResult::Consistent(result) => match result {
100104
Ok(block) => {

evm_rpc_client/src/fixtures/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use crate::{ClientBuilder, Runtime};
66
use async_trait::async_trait;
77
use candid::{utils::ArgumentEncoder, CandidType, Decode, Encode, Principal};
8-
use ic_error_types::RejectCode;
8+
use ic_cdk::call::Error;
99
use serde::de::DeserializeOwned;
1010
use std::collections::BTreeMap;
1111

@@ -82,7 +82,7 @@ impl StubRuntime {
8282
self
8383
}
8484

85-
fn call<Out>(&self, method: &str) -> Result<Out, (RejectCode, String)>
85+
fn call<Out>(&self, method: &str) -> Result<Out, Error>
8686
where
8787
Out: CandidType + DeserializeOwned,
8888
{
@@ -109,7 +109,7 @@ impl Runtime for StubRuntime {
109109
method: &str,
110110
_args: In,
111111
_cycles: u128,
112-
) -> Result<Out, (RejectCode, String)>
112+
) -> Result<Out, Error>
113113
where
114114
In: ArgumentEncoder + Send,
115115
Out: CandidType + DeserializeOwned,
@@ -122,7 +122,7 @@ impl Runtime for StubRuntime {
122122
_id: Principal,
123123
method: &str,
124124
_args: In,
125-
) -> Result<Out, (RejectCode, String)>
125+
) -> Result<Out, Error>
126126
where
127127
In: ArgumentEncoder + Send,
128128
Out: CandidType + DeserializeOwned,

evm_rpc_client/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ use evm_rpc_types::{
127127
BlockTag, CallArgs, ConsensusStrategy, FeeHistoryArgs, GetLogsArgs, GetTransactionCountArgs,
128128
Hex, Hex32, RpcConfig, RpcServices,
129129
};
130-
use ic_error_types::RejectCode;
131130
#[cfg(feature = "alloy")]
132131
pub use request::alloy::AlloyResponseConverter;
133132
pub use request::CandidResponseConverter;
@@ -783,7 +782,7 @@ impl<R: Runtime, C> EvmRpcClient<R, C> {
783782
async fn try_execute_request<Config, Params, CandidOutput, Output>(
784783
&self,
785784
request: Request<Config, Params, CandidOutput, Output>,
786-
) -> Result<Output, (RejectCode, String)>
785+
) -> Result<Output, ic_cdk::call::Error>
787786
where
788787
Config: CandidType + Send,
789788
Params: CandidType + Send,

0 commit comments

Comments
 (0)