diff --git a/Cargo.lock b/Cargo.lock index 0af7940ae..d470cee6d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -965,6 +965,7 @@ version = "0.1.0" dependencies = [ "calimero-primitives", "calimero-sdk", + "near-account-id", "serde", "serde_json", "serde_with", diff --git a/Cargo.toml b/Cargo.toml index bd24e0d6b..9fba2acb5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,6 +53,7 @@ multiaddr = "0.18.1" near-jsonrpc-client = "0.8.0" near-jsonrpc-primitives = "0.20.0" near-primitives = "0.20.0" +near-account-id = "1.0.0" near-sdk = "5.0.0" near-workspaces = "0.10.0" ouroboros = "0.18.3" diff --git a/crates/sdk/libs/near/Cargo.toml b/crates/sdk/libs/near/Cargo.toml index 96513d17a..fce2ba1b1 100644 --- a/crates/sdk/libs/near/Cargo.toml +++ b/crates/sdk/libs/near/Cargo.toml @@ -7,6 +7,7 @@ repository.workspace = true license.workspace = true [dependencies] +near-account-id = { workspace = true } serde = { workspace = true, features = ["derive"] } serde_json.workspace = true serde_with = {workspace = true, features = ["base64"]} diff --git a/crates/sdk/libs/near/src/jsonrpc.rs b/crates/sdk/libs/near/src/jsonrpc.rs index bc2f80f11..3803be50e 100644 --- a/crates/sdk/libs/near/src/jsonrpc.rs +++ b/crates/sdk/libs/near/src/jsonrpc.rs @@ -25,8 +25,8 @@ impl Client { *self.id.borrow_mut() += 1; let body = serde_json::to_vec(&Request { jsonrpc: "2.0", - id: self.id.borrow().to_string(), - method: method.to_string(), + id: &*self.id.borrow().to_string(), + method, params, }) .map_err(|err| format!("Cannot serialize request: {:?}", err))?; @@ -38,10 +38,10 @@ impl Client { } #[derive(Debug, Clone, Serialize)] -pub struct Request { - pub jsonrpc: &'static str, - pub id: String, - pub method: String, +struct Request<'a, P: Serialize> { + pub jsonrpc: &'a str, + pub id: &'a str, + pub method: &'a str, pub params: P, } diff --git a/crates/sdk/libs/near/src/types.rs b/crates/sdk/libs/near/src/types.rs index 9c9fe67bc..72d6dcc77 100644 --- a/crates/sdk/libs/near/src/types.rs +++ b/crates/sdk/libs/near/src/types.rs @@ -2,8 +2,8 @@ use serde_with::base64::Base64; use serde_with::serde_as; pub type BlockHeight = u64; -pub type BlockHash = String; -pub type AccountId = String; +pub type BlockHash = calimero_primitives::hash::Hash; +pub type AccountId = near_account_id::AccountId; pub type StorageUsage = u64; pub type Nonce = u64; diff --git a/crates/sdk/libs/near/src/views.rs b/crates/sdk/libs/near/src/views.rs index b7acd5451..01ac54612 100644 --- a/crates/sdk/libs/near/src/views.rs +++ b/crates/sdk/libs/near/src/views.rs @@ -32,7 +32,7 @@ pub enum QueryRequest { }, CallFunction { account_id: AccountId, - method_name: String, + method_name: Box, #[serde(rename = "args_base64")] args: FunctionArgs, }, @@ -52,7 +52,7 @@ pub struct AccountView { pub struct ContractCodeView { #[serde(rename = "code_base64")] #[serde_as(as = "Base64")] - pub code: Vec, + pub code: Box<[u8]>, pub hash: String, }