Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: upgraded near deps to 0.24 #370

Merged
merged 7 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ edition = "2018"
anyhow = "1.0"
maplit = "1.0"
near-units = "0.2.0"
near-gas = { version = "0.2.5", features = ["serde", "borsh", "schemars"] }
near-jsonrpc-primitives = "0.23.0"
near-primitives = "0.23.0"
near-gas = { version = "0.3", features = ["serde", "borsh", "schemars"] }
near-jsonrpc-primitives = "0.24"
near-primitives = "0.24"
serde = "1.0"
serde_with = "3.4"
serde_json = { version = "1.0" }
Expand Down
7 changes: 7 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[toolchain]
# This specifies the version of Rust we use to build.
# Individual crates in the workspace may support a lower version, as indicated by `rust-version` field in each crate's `Cargo.toml`.
# The version specified below, should be at least as high as the maximum `rust-version` within the workspace.
channel = "stable"
components = ["rustfmt", "clippy", "rust-analyzer"]
targets = ["wasm32-unknown-unknown"]
24 changes: 12 additions & 12 deletions workspaces/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async-trait = "0.1"
base64 = "0.22"
bs58 = "0.5"
cargo_metadata = { version = "0.18", optional = true }
cargo-near = { version = "0.6.3", default-features = false }
cargo-near = { version = "0.8", default-features = false }
chrono = "0.4.19"
fs2 = "0.4"
rand = "0.8.4"
Expand All @@ -31,27 +31,27 @@ tracing = "0.1"
url = { version = "2.2.2", features = ["serde"] }

near-abi-client = "0.1.1"
near-gas = { version = "0.2.5", features = ["serde", "borsh", "schemars"] }
near-token = { version = "0.2.0", features = ["serde"] }
near-sdk = { version = "5.2.0", optional = true }
near-gas = { version = "0.3", features = ["serde", "borsh", "schemars"] }
near-token = { version = "0.3", features = ["serde"] }
near-sdk = { version = "5.3", optional = true }
near-account-id = "1.0.0"
near-crypto = "0.23.0"
near-primitives = "0.23.0"
near-jsonrpc-primitives = "0.23.0"
near-jsonrpc-client = { version = "0.10.1", features = ["sandbox"] }
near-sandbox-utils = "0.9.0"
near-chain-configs = { version = "0.23.0", optional = true }
near-crypto = "0.24"
near-primitives = "0.24"
near-jsonrpc-primitives = "0.24"
near-jsonrpc-client = { version = "0.11", features = ["sandbox"] }
near-sandbox-utils = "0.10"
near-chain-configs = { version = "0.24", optional = true }

[build-dependencies]
near-sandbox-utils = "0.8.0"
near-sandbox-utils = "0.10"

[target.'cfg(unix)'.dependencies]
libc = "0.2"

[dev-dependencies]
anyhow = "1.0"
futures = "0.3"
near-sdk = "5.2.0"
near-sdk = "5.3"
test-log = { version = "0.2.8", default-features = false, features = ["trace"] }
tracing-subscriber = { version = "0.3.5", features = ["env-filter"] }

Expand Down
8 changes: 3 additions & 5 deletions workspaces/src/cargo/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use crate::error::ErrorKind;

use cargo_near::commands::build_command::{build, BuildCommand};

/// Builds the cargo project located at `project_path` and returns the generated wasm file contents.
///
/// NOTE: This function does not check whether the resulting wasm file is a valid smart
Expand All @@ -16,9 +14,10 @@ pub async fn compile_project(project_path: &str) -> crate::Result<Vec<u8>> {
_ => ErrorKind::Io.custom(e),
})?;

let cargo_near_build_command = BuildCommand {
let cargo_opts = cargo_near::BuildOpts {
no_release: false,
no_embed_abi: false,
no_locked: true,
no_doc: true,
color: None,
no_abi: true,
Expand All @@ -38,8 +37,7 @@ pub async fn compile_project(project_path: &str) -> crate::Result<Vec<u8>> {
no_default_features: false,
};

let compile_artifact =
build::run(cargo_near_build_command).map_err(|e| ErrorKind::Io.custom(e))?;
let compile_artifact = cargo_near::build(cargo_opts).map_err(|e| ErrorKind::Io.custom(e))?;

let file = compile_artifact
.path
Expand Down
23 changes: 16 additions & 7 deletions workspaces/src/rpc/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ use crate::{Network, Worker};

pub(crate) const DEFAULT_CALL_FN_GAS: NearGas = NearGas::from_tgas(10);
pub(crate) const DEFAULT_CALL_DEPOSIT: NearToken = NearToken::from_near(0);
pub(crate) const DEFAULT_PRIORITY_FEE: u64 = 0;

/// A client that wraps around [`JsonRpcClient`], and provides more capabilities such
/// as retry w/ exponential backoff and utility functions for sending transactions.
Expand Down Expand Up @@ -96,7 +97,7 @@ impl Client {
tracing::info!(
target: "workspaces",
"Submitting transaction with actions {:?} succeeded with status {:?}",
method.signed_transaction.transaction.actions,
method.signed_transaction.transaction.actions(),
response.status
);
}
Expand Down Expand Up @@ -560,8 +561,11 @@ pub(crate) async fn send_batch_tx_and_retry(
receiver_id: &AccountId,
actions: Vec<Action>,
) -> Result<FinalExecutionOutcomeView> {
let signer = signer.inner();
let cache_key = (signer.account_id.clone(), signer.secret_key.public_key());
let inner = signer.inner();
let cache_key = (
signer.account_id.clone(),
signer.secret_key.public_key().into(),
);
retry(|| async {
let (block_hash, nonce) = fetch_tx_nonce(client, &cache_key).await?;
send_tx(
Expand All @@ -571,9 +575,10 @@ pub(crate) async fn send_batch_tx_and_retry(
nonce,
signer.account_id.clone(),
receiver_id.clone(),
&signer as &dyn near_crypto::Signer,
&inner,
actions.clone(),
block_hash,
DEFAULT_PRIORITY_FEE,
),
)
.await
Expand All @@ -587,8 +592,11 @@ pub(crate) async fn send_batch_tx_async_and_retry(
receiver_id: &AccountId,
actions: Vec<Action>,
) -> Result<TransactionStatus> {
let signer = &signer.inner();
let cache_key = (signer.account_id.clone(), signer.secret_key.public_key());
let inner = signer.inner();
let cache_key = (
signer.account_id.clone(),
signer.secret_key.public_key().into(),
);
retry(|| async {
let (block_hash, nonce) = fetch_tx_nonce(worker.client(), &cache_key).await?;
let hash = worker
Expand All @@ -598,9 +606,10 @@ pub(crate) async fn send_batch_tx_async_and_retry(
nonce,
signer.account_id.clone(),
receiver_id.clone(),
signer as &dyn near_crypto::Signer,
&inner,
actions.clone(),
block_hash,
DEFAULT_PRIORITY_FEE,
),
})
.await
Expand Down
7 changes: 4 additions & 3 deletions workspaces/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use std::path::Path;
use std::str::FromStr;

pub use near_account_id::AccountId;
use near_crypto::Signer;
use near_primitives::borsh::{BorshDeserialize, BorshSerialize};

use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -292,11 +293,11 @@ impl InMemorySigner {
))
}

pub(crate) fn inner(&self) -> near_crypto::InMemorySigner {
near_crypto::InMemorySigner::from_secret_key(
pub(crate) fn inner(&self) -> Signer {
Signer::InMemory(near_crypto::InMemorySigner::from_secret_key(
self.account_id.clone(),
self.secret_key.0.clone(),
)
))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2018"
crate-type = ["cdylib"]

[dependencies]
near-sdk = "5.0.0-alpha.2"
near-sdk = "5.3.0"

[profile.release]
codegen-units = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ crate-type = ["cdylib"]

[dependencies]
bs58 = "0.5"
near-sdk = "5.0.0-alpha.2"
near-sdk = "5.3.0"

[profile.release]
codegen-units = 1
Expand Down
Loading