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 deps #363

Merged
merged 9 commits into from
Jul 5, 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
4 changes: 2 additions & 2 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ 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.20.0"
near-primitives = "0.20.0"
near-jsonrpc-primitives = "0.23.0"
near-primitives = "0.23.0"
serde = "1.0"
serde_with = "3.4"
serde_json = { version = "1.0" }
Expand Down
4 changes: 3 additions & 1 deletion examples/src/tx_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ async fn main() -> anyhow::Result<()> {
};

// NOTE: this API is under the "experimental" flag and no guarantees are given.
let resp = worker.tx_status(tx_info).await?;
let resp = worker
.tx_status(tx_info, near_primitives::views::TxExecutionStatus::Final)
.await?;

// Example outcome:
//
Expand Down
24 changes: 12 additions & 12 deletions workspaces/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ Library for automating workflows and testing NEAR smart contracts.

[dependencies]
async-trait = "0.1"
base64 = "0.21"
base64 = "0.22"
bs58 = "0.5"
cargo_metadata = { version = "0.18", optional = true }
cargo-near = { version = "0.5.2", default-features = false }
cargo-near = { version = "0.6.3", default-features = false }
chrono = "0.4.19"
fs2 = "0.4"
rand = "0.8.4"
reqwest = { version = "0.11", features = ["json"] }
reqwest = { version = "0.12", features = ["json"] }
sha2 = "0.10"
serde = "1.0"
serde_json = "1.0"
json-patch = "1.0"
json-patch = "2.0"
tempfile = "3.3"
thiserror = "1.0"
tokio = { version = "1", features = ["full"] }
Expand All @@ -33,14 +33,14 @@ 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.0.0-alpha.2", optional = true }
near-sdk = { version = "5.2.0", optional = true }
near-account-id = "1.0.0"
near-crypto = "0.20.0"
near-primitives = "0.20.0"
near-jsonrpc-primitives = "0.20.0"
near-jsonrpc-client = { version = "0.8", features = ["sandbox"] }
near-sandbox-utils = "0.8.0"
near-chain-configs = { version = "0.20.0", optional = true }
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 }

[build-dependencies]
near-sandbox-utils = "0.8.0"
Expand All @@ -51,7 +51,7 @@ libc = "0.2"
[dev-dependencies]
anyhow = "1.0"
futures = "0.3"
near-sdk = "5.0.0-alpha.2"
near-sdk = "5.2.0"
test-log = { version = "0.2.8", default-features = false, features = ["trace"] }
tracing-subscriber = { version = "0.3.5", features = ["env-filter"] }

Expand Down
9 changes: 6 additions & 3 deletions workspaces/src/cargo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use cargo_near::commands::build_command::{build, BuildCommand};
///
/// NOTE: This function does not check whether the resulting wasm file is a valid smart
/// contract or not.
/// NOTE: This function builds the project using default features
pub async fn compile_project(project_path: &str) -> crate::Result<Vec<u8>> {
let project_path = std::fs::canonicalize(project_path).map_err(|e| match e.kind() {
std::io::ErrorKind::NotFound => ErrorKind::Io.message(format!(
Expand All @@ -16,9 +17,9 @@ pub async fn compile_project(project_path: &str) -> crate::Result<Vec<u8>> {
})?;

let cargo_near_build_command = BuildCommand {
release: true,
embed_abi: true,
doc: false,
no_release: false,
no_embed_abi: false,
no_doc: true,
color: None,
no_abi: true,
out_dir: None,
Expand All @@ -33,6 +34,8 @@ pub async fn compile_project(project_path: &str) -> crate::Result<Vec<u8>> {
))
})?,
),
features: None,
no_default_features: false,
};

let compile_artifact =
Expand Down
4 changes: 1 addition & 3 deletions workspaces/src/network/sandbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ impl Sandbox {
// Check the conditions of the provided rpc_url and validator_key
let mut server = match (build.rpc_addr, build.validator_key) {
// Connect to a provided sandbox:
(Some(rpc_url), Some(validator_key)) => {
SandboxServer::connect(rpc_url, validator_key).await?
}
(Some(rpc_url), Some(validator_key)) => SandboxServer::new(rpc_url, validator_key)?,

// Spawn a new sandbox since rpc_url and home_dir weren't specified:
(None, None) => SandboxServer::run_new_with_version(version).await?,
Expand Down
2 changes: 1 addition & 1 deletion workspaces/src/network/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub struct SandboxServer {
impl SandboxServer {
/// Connect a sandbox server that's already been running, provided we know the rpc_addr
/// and home_dir pointing to the sandbox process.
pub(crate) async fn connect(rpc_addr: String, validator_key: ValidatorKey) -> Result<Self> {
pub(crate) fn new(rpc_addr: String, validator_key: ValidatorKey) -> Result<Self> {
let rpc_addr = Url::parse(&rpc_addr).map_err(|e| {
SandboxErrorCode::InitFailure.full(format!("Invalid rpc_url={rpc_addr}"), e)
})?;
Expand Down
9 changes: 7 additions & 2 deletions workspaces/src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,12 +519,17 @@ impl TransactionStatus {
.tx_async_status(
&self.sender_id,
near_primitives::hash::CryptoHash(self.hash.0),
near_primitives::views::TxExecutionStatus::Final,
)
.await
.map(ExecutionFinalResult::from_view);
.map(|o| {
o.final_execution_outcome
.map(|e| ExecutionFinalResult::from_view(e.into_outcome()))
});

match result {
Ok(result) => Ok(Poll::Ready(result)),
Ok(Some(result)) => Ok(Poll::Ready(result)),
Ok(None) => Ok(Poll::Pending),
Err(err) => match err {
JsonRpcError::ServerError(JsonRpcServerError::HandlerError(
RpcTransactionError::UnknownTransaction { .. },
Expand Down
22 changes: 14 additions & 8 deletions workspaces/src/rpc/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use tokio_retry::strategy::{jitter, ExponentialBackoff};
use tokio_retry::Retry;

use near_jsonrpc_client::errors::{JsonRpcError, JsonRpcServerError};
use near_jsonrpc_client::methods::tx::RpcTransactionError;
use near_jsonrpc_client::methods::tx::{RpcTransactionError, RpcTransactionResponse};
use near_jsonrpc_client::{methods, JsonRpcClient, MethodCallResult};
use near_jsonrpc_primitives::types::query::QueryResponseKind;
use near_primitives::account::{AccessKey, AccessKeyPermission};
Expand All @@ -23,6 +23,7 @@ use near_primitives::transaction::{
use near_primitives::types::{BlockReference, Finality, Gas};
use near_primitives::views::{
AccessKeyView, BlockView, FinalExecutionOutcomeView, QueryRequest, StatusResponse,
TxExecutionStatus,
};

#[cfg(feature = "experimental")]
Expand All @@ -34,10 +35,7 @@ use {
},
near_primitives::{
types::MaybeBlockId,
views::{
validator_stake_view::ValidatorStakeView, FinalExecutionOutcomeWithReceiptView,
ReceiptView, StateChangesRequestView,
},
views::{validator_stake_view::ValidatorStakeView, ReceiptView, StateChangesRequestView},
},
};

Expand Down Expand Up @@ -306,12 +304,14 @@ impl Client {
&self,
sender_id: &AccountId,
tx_hash: CryptoHash,
) -> Result<FinalExecutionOutcomeView, JsonRpcError<RpcTransactionError>> {
wait_until: TxExecutionStatus,
) -> Result<RpcTransactionResponse, JsonRpcError<RpcTransactionError>> {
self.query(methods::tx::RpcTransactionStatusRequest {
transaction_info: methods::tx::TransactionInfo::TransactionId {
sender_account_id: sender_id.clone(),
tx_hash,
},
wait_until,
})
.await
}
Expand Down Expand Up @@ -420,10 +420,16 @@ impl Client {
pub(crate) async fn tx_status(
&self,
transaction_info: TransactionInfo,
) -> Result<FinalExecutionOutcomeWithReceiptView> {
wait_until: TxExecutionStatus,
) -> Result<RpcTransactionResponse> {
let resp = self
.rpc_client
.call(methods::EXPERIMENTAL_tx_status::RpcTransactionStatusRequest { transaction_info })
.call(
methods::EXPERIMENTAL_tx_status::RpcTransactionStatusRequest {
transaction_info,
wait_until,
},
)
.await
.map_err(|e| RpcErrorCode::QueryFailure.custom(e))?;
Ok(resp)
Expand Down
10 changes: 7 additions & 3 deletions workspaces/src/types/account.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::fmt;
use std::path::Path;

use near_primitives::types::StorageUsage;
use near_primitives::version::PROTOCOL_VERSION;
use near_primitives::views::AccountView;

use crate::error::ErrorKind;
Expand Down Expand Up @@ -329,7 +331,7 @@ pub struct AccountDetailsPatch {
pub balance: Option<NearToken>,
pub locked: Option<NearToken>,
pub code_hash: Option<CryptoHash>,
pub storage_usage: Option<u64>,
pub storage_usage: Option<StorageUsage>,
pub(crate) storage_paid_at: Option<BlockHeight>,
}

Expand Down Expand Up @@ -367,7 +369,7 @@ impl AccountDetailsPatch {
self
}

pub fn storage_usage(mut self, storage_usage: u64) -> Self {
pub fn storage_usage(mut self, storage_usage: StorageUsage) -> Self {
self.storage_usage = Some(storage_usage);
self
}
Expand All @@ -393,7 +395,7 @@ pub struct AccountDetails {
pub balance: NearToken,
pub locked: NearToken,
pub code_hash: CryptoHash,
pub storage_usage: u64,
pub storage_usage: StorageUsage,
// Deprecated value. Mainly used to be able to convert back into an AccountView
pub(crate) storage_paid_at: BlockHeight,
}
Expand All @@ -413,8 +415,10 @@ impl AccountDetails {
near_primitives::account::Account::new(
self.balance.as_yoctonear(),
self.locked.as_yoctonear(),
0,
near_primitives::hash::CryptoHash(self.code_hash.0),
self.storage_usage,
PROTOCOL_VERSION,
)
}
}
Expand Down
12 changes: 6 additions & 6 deletions workspaces/src/worker/impls.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use near_jsonrpc_client::methods::tx::RpcTransactionResponse;
use near_primitives::views::StatusResponse;
use near_primitives::views::TxExecutionStatus;

use crate::network::{AllowDevAccountCreation, NetworkClient, NetworkInfo};
use crate::network::{Info, Sandbox};
Expand All @@ -24,10 +26,7 @@ use {
},
near_primitives::{
types::{BlockReference, MaybeBlockId},
views::{
validator_stake_view::ValidatorStakeView, FinalExecutionOutcomeWithReceiptView,
ReceiptView, StateChangesRequestView,
},
views::{validator_stake_view::ValidatorStakeView, ReceiptView, StateChangesRequestView},
},
};

Expand Down Expand Up @@ -247,8 +246,9 @@ where
pub async fn tx_status(
&self,
transaction_info: TransactionInfo,
) -> Result<FinalExecutionOutcomeWithReceiptView> {
self.client().tx_status(transaction_info).await
wait_until: TxExecutionStatus,
) -> Result<RpcTransactionResponse> {
self.client().tx_status(transaction_info, wait_until).await
}

/// Provides a list of validators ordered with respect to their stake.
Expand Down
8 changes: 4 additions & 4 deletions workspaces/tests/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ async fn test_delete_account() -> anyhow::Result<()> {

_ = alice.clone().delete_account(bob.id()).await?;

// All sandbox accounts start with a balance of 100 NEAR tokens.
// On account deletion, alice's balance is debited to bob as beneficiary.
assert!(bob.view_account().await?.balance > NearToken::from_near(100));

// Alice's account should be deleted.
let res = alice.view_account().await;

Expand All @@ -92,5 +88,9 @@ async fn test_delete_account() -> anyhow::Result<()> {
.to_string()
.contains(&format!("{} does not exist while viewing", alice.id())),);

// All sandbox accounts start with a balance of 100 NEAR tokens.
// On account deletion, alice's balance is debited to bob as beneficiary.
assert!(bob.view_account().await?.balance > NearToken::from_near(100));

Ok(())
}
Loading