From 1f61ffeebd423afe934228c054df8a531a8d1ca4 Mon Sep 17 00:00:00 2001 From: akorchyn Date: Wed, 3 Jul 2024 17:31:08 +0300 Subject: [PATCH 1/8] compilation v1 --- Cargo.toml | 8 ++++---- examples/Cargo.toml | 4 ++-- examples/src/gen/adder.rs | 11 ++++++++++- workspaces/Cargo.toml | 22 +++++++++++----------- workspaces/src/cargo/mod.rs | 6 +++--- workspaces/src/operations.rs | 9 +++++++-- workspaces/src/rpc/client.rs | 22 ++++++++++++++-------- workspaces/src/worker/impls.rs | 13 +++++++------ 8 files changed, 58 insertions(+), 37 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 299a6464..47567505 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = [ - "workspaces", - "examples", -] +members = ["workspaces", "examples"] + +[patch.crates-io] +near-sdk = { git = "https://github.com/near/near-sdk-rs", branch = "master" } diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 7e8f4552..1167db09 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -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.22.0" +near-primitives = "0.22.0" serde = "1.0" serde_with = "3.4" serde_json = { version = "1.0" } diff --git a/examples/src/gen/adder.rs b/examples/src/gen/adder.rs index 175ed801..a7430acd 100644 --- a/examples/src/gen/adder.rs +++ b/examples/src/gen/adder.rs @@ -1 +1,10 @@ -// No content here, it's to be generated on build. Here to allow cargofmt to work. +pub type Pair = Vec; +pub struct AbiClient { + pub contract: near_workspaces::Contract, +} +impl AbiClient { + pub async fn add(&self, a: Pair, b: Pair) -> anyhow::Result { + let result = self.contract.call("add").args_json([a, b]).view().await?; + Ok(result.json::()?) + } +} diff --git a/workspaces/Cargo.toml b/workspaces/Cargo.toml index daf6ac24..0b661ff5 100644 --- a/workspaces/Cargo.toml +++ b/workspaces/Cargo.toml @@ -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.2", 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"] } @@ -35,15 +35,15 @@ 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-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.7.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.8.0" +near-chain-configs = { version = "0.23.0", optional = true } [build-dependencies] -near-sandbox-utils = "0.7.0" +near-sandbox-utils = "0.8.0" [target.'cfg(unix)'.dependencies] libc = "0.2" diff --git a/workspaces/src/cargo/mod.rs b/workspaces/src/cargo/mod.rs index 75cb4f5e..cf318608 100644 --- a/workspaces/src/cargo/mod.rs +++ b/workspaces/src/cargo/mod.rs @@ -16,9 +16,9 @@ pub async fn compile_project(project_path: &str) -> crate::Result> { })?; 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, diff --git a/workspaces/src/operations.rs b/workspaces/src/operations.rs index b83ad370..55ded649 100644 --- a/workspaces/src/operations.rs +++ b/workspaces/src/operations.rs @@ -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 { .. }, diff --git a/workspaces/src/rpc/client.rs b/workspaces/src/rpc/client.rs index ac090776..115e1516 100644 --- a/workspaces/src/rpc/client.rs +++ b/workspaces/src/rpc/client.rs @@ -11,7 +11,7 @@ use tokio_retry::Retry; use near_jsonrpc_client::errors::{JsonRpcError, JsonRpcServerError}; use near_jsonrpc_client::methods::health::RpcStatusError; -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}; @@ -24,6 +24,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")] @@ -35,10 +36,7 @@ use { }, near_primitives::{ types::MaybeBlockId, - views::{ - validator_stake_view::ValidatorStakeView, FinalExecutionOutcomeWithReceiptView, - ReceiptView, StateChangesRequestView, - }, + views::{validator_stake_view::ValidatorStakeView, ReceiptView, StateChangesRequestView}, }, }; @@ -312,12 +310,14 @@ impl Client { &self, sender_id: &AccountId, tx_hash: CryptoHash, - ) -> Result> { + wait_until: TxExecutionStatus, + ) -> Result> { self.query(methods::tx::RpcTransactionStatusRequest { transaction_info: methods::tx::TransactionInfo::TransactionId { sender_account_id: sender_id.clone(), tx_hash, }, + wait_until, }) .await } @@ -426,10 +426,16 @@ impl Client { pub(crate) async fn tx_status( &self, transaction_info: TransactionInfo, - ) -> Result { + wait_until: TxExecutionStatus, + ) -> Result { 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) diff --git a/workspaces/src/worker/impls.rs b/workspaces/src/worker/impls.rs index 84485ca3..3174e8f0 100644 --- a/workspaces/src/worker/impls.rs +++ b/workspaces/src/worker/impls.rs @@ -1,3 +1,6 @@ +use near_jsonrpc_client::methods::tx::RpcTransactionResponse; +use near_primitives::views::TxExecutionStatus; + use crate::network::{AllowDevAccountCreation, NetworkClient, NetworkInfo}; use crate::network::{Info, Sandbox}; use crate::operations::{CallTransaction, Function}; @@ -22,10 +25,7 @@ use { }, near_primitives::{ types::{BlockReference, MaybeBlockId}, - views::{ - validator_stake_view::ValidatorStakeView, FinalExecutionOutcomeWithReceiptView, - ReceiptView, StateChangesRequestView, - }, + views::{validator_stake_view::ValidatorStakeView, ReceiptView, StateChangesRequestView}, }, }; @@ -240,8 +240,9 @@ where pub async fn tx_status( &self, transaction_info: TransactionInfo, - ) -> Result { - self.client().tx_status(transaction_info).await + wait_until: TxExecutionStatus, + ) -> Result { + self.client().tx_status(transaction_info, wait_until).await } /// Provides a list of validators ordered with respect to their stake. From c7755fdb54b6d47f32f00da68584c0b88517ae47 Mon Sep 17 00:00:00 2001 From: akorchyn Date: Fri, 5 Jul 2024 14:49:35 +0300 Subject: [PATCH 2/8] upgraded deps to the newer version --- examples/Cargo.toml | 4 ++-- examples/src/tx_status.rs | 4 +++- workspaces/Cargo.toml | 6 +++--- workspaces/src/cargo/mod.rs | 3 +++ workspaces/src/types/account.rs | 22 +++++++++++++++++++--- 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 1167db09..0172427a 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -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.22.0" -near-primitives = "0.22.0" +near-jsonrpc-primitives = "0.23.0" +near-primitives = "0.23.0" serde = "1.0" serde_with = "3.4" serde_json = { version = "1.0" } diff --git a/examples/src/tx_status.rs b/examples/src/tx_status.rs index 5daa4a0f..98fbf960 100644 --- a/examples/src/tx_status.rs +++ b/examples/src/tx_status.rs @@ -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: // diff --git a/workspaces/Cargo.toml b/workspaces/Cargo.toml index 0b661ff5..7e1485b5 100644 --- a/workspaces/Cargo.toml +++ b/workspaces/Cargo.toml @@ -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.2", default-features = false } +cargo-near = { version = "0.6.3", default-features = false } chrono = "0.4.19" fs2 = "0.4" rand = "0.8.4" @@ -33,7 +33,7 @@ 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.23.0" near-primitives = "0.23.0" @@ -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"] } diff --git a/workspaces/src/cargo/mod.rs b/workspaces/src/cargo/mod.rs index cf318608..58558263 100644 --- a/workspaces/src/cargo/mod.rs +++ b/workspaces/src/cargo/mod.rs @@ -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> { let project_path = std::fs::canonicalize(project_path).map_err(|e| match e.kind() { std::io::ErrorKind::NotFound => ErrorKind::Io.message(format!( @@ -33,6 +34,8 @@ pub async fn compile_project(project_path: &str) -> crate::Result> { )) })?, ), + features: None, + no_default_features: false, }; let compile_artifact = diff --git a/workspaces/src/types/account.rs b/workspaces/src/types/account.rs index 9d96819e..581e547a 100644 --- a/workspaces/src/types/account.rs +++ b/workspaces/src/types/account.rs @@ -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; @@ -329,7 +331,8 @@ pub struct AccountDetailsPatch { pub balance: Option, pub locked: Option, pub code_hash: Option, - pub storage_usage: Option, + pub storage_usage: Option, + pub permanent_storage_bytes: Option, pub(crate) storage_paid_at: Option, } @@ -367,10 +370,15 @@ 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 } + + pub fn permanent_storage_bytes(mut self, permanent_storage_bytes: StorageUsage) -> Self { + self.permanent_storage_bytes = Some(permanent_storage_bytes); + self + } } impl From for AccountDetailsPatch { @@ -381,6 +389,7 @@ impl From for AccountDetailsPatch { code_hash: Some(account.code_hash), storage_usage: Some(account.storage_usage), storage_paid_at: Some(account.storage_paid_at), + permanent_storage_bytes: Some(account.permanent_storage_bytes), } } } @@ -393,7 +402,8 @@ pub struct AccountDetails { pub balance: NearToken, pub locked: NearToken, pub code_hash: CryptoHash, - pub storage_usage: u64, + pub storage_usage: StorageUsage, + permanent_storage_bytes: StorageUsage, // Deprecated value. Mainly used to be able to convert back into an AccountView pub(crate) storage_paid_at: BlockHeight, } @@ -404,6 +414,7 @@ impl AccountDetails { balance: NearToken::from_near(0), locked: NearToken::from_near(0), code_hash: CryptoHash::default(), + permanent_storage_bytes: 0, storage_usage: 0, storage_paid_at: 0, } @@ -413,8 +424,10 @@ impl AccountDetails { near_primitives::account::Account::new( self.balance.as_yoctonear(), self.locked.as_yoctonear(), + self.permanent_storage_bytes, near_primitives::hash::CryptoHash(self.code_hash.0), self.storage_usage, + PROTOCOL_VERSION, ) } } @@ -431,6 +444,8 @@ impl From for AccountDetails { balance: NearToken::from_yoctonear(account.amount), locked: NearToken::from_yoctonear(account.locked), code_hash: CryptoHash(account.code_hash.0), + // TODO: protocol_feature_nonrefundable_transfer_nep491 is not supported by near-cli-rs + permanent_storage_bytes: 0, storage_usage: account.storage_usage, storage_paid_at: account.storage_paid_at, } @@ -445,6 +460,7 @@ impl From for AccountDetails { code_hash: value.code_hash.unwrap_or_default(), storage_usage: value.storage_usage.unwrap_or_default(), storage_paid_at: value.storage_paid_at.unwrap_or_default(), + permanent_storage_bytes: value.permanent_storage_bytes.unwrap_or_default(), } } } From 4b83618a80bede95d006dd498ea89b08a8095e65 Mon Sep 17 00:00:00 2001 From: akorchyn Date: Fri, 5 Jul 2024 14:54:38 +0300 Subject: [PATCH 3/8] self-review --- Cargo.toml | 8 ++++---- examples/src/gen/adder.rs | 11 +---------- workspaces/src/types/account.rs | 13 +++---------- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 47567505..ba6193d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["workspaces", "examples"] - -[patch.crates-io] -near-sdk = { git = "https://github.com/near/near-sdk-rs", branch = "master" } +members = [ + "workspaces", + "examples", +] \ No newline at end of file diff --git a/examples/src/gen/adder.rs b/examples/src/gen/adder.rs index a7430acd..053ac56b 100644 --- a/examples/src/gen/adder.rs +++ b/examples/src/gen/adder.rs @@ -1,10 +1 @@ -pub type Pair = Vec; -pub struct AbiClient { - pub contract: near_workspaces::Contract, -} -impl AbiClient { - pub async fn add(&self, a: Pair, b: Pair) -> anyhow::Result { - let result = self.contract.call("add").args_json([a, b]).view().await?; - Ok(result.json::()?) - } -} +// No content here, it's to be generated on build. Here to allow cargofmt to work. \ No newline at end of file diff --git a/workspaces/src/types/account.rs b/workspaces/src/types/account.rs index 581e547a..52516587 100644 --- a/workspaces/src/types/account.rs +++ b/workspaces/src/types/account.rs @@ -332,7 +332,6 @@ pub struct AccountDetailsPatch { pub locked: Option, pub code_hash: Option, pub storage_usage: Option, - pub permanent_storage_bytes: Option, pub(crate) storage_paid_at: Option, } @@ -374,11 +373,6 @@ impl AccountDetailsPatch { self.storage_usage = Some(storage_usage); self } - - pub fn permanent_storage_bytes(mut self, permanent_storage_bytes: StorageUsage) -> Self { - self.permanent_storage_bytes = Some(permanent_storage_bytes); - self - } } impl From for AccountDetailsPatch { @@ -389,7 +383,6 @@ impl From for AccountDetailsPatch { code_hash: Some(account.code_hash), storage_usage: Some(account.storage_usage), storage_paid_at: Some(account.storage_paid_at), - permanent_storage_bytes: Some(account.permanent_storage_bytes), } } } @@ -403,7 +396,8 @@ pub struct AccountDetails { pub locked: NearToken, pub code_hash: CryptoHash, pub storage_usage: StorageUsage, - permanent_storage_bytes: StorageUsage, + // TODO: protocol_feature_nonrefundable_transfer_nep491 is not supported by near-cli-rs + pub permanent_storage_bytes: StorageUsage, // Deprecated value. Mainly used to be able to convert back into an AccountView pub(crate) storage_paid_at: BlockHeight, } @@ -444,7 +438,6 @@ impl From for AccountDetails { balance: NearToken::from_yoctonear(account.amount), locked: NearToken::from_yoctonear(account.locked), code_hash: CryptoHash(account.code_hash.0), - // TODO: protocol_feature_nonrefundable_transfer_nep491 is not supported by near-cli-rs permanent_storage_bytes: 0, storage_usage: account.storage_usage, storage_paid_at: account.storage_paid_at, @@ -460,7 +453,7 @@ impl From for AccountDetails { code_hash: value.code_hash.unwrap_or_default(), storage_usage: value.storage_usage.unwrap_or_default(), storage_paid_at: value.storage_paid_at.unwrap_or_default(), - permanent_storage_bytes: value.permanent_storage_bytes.unwrap_or_default(), + permanent_storage_bytes: 0, } } } From 33db4c2c8e9b1d6f794235d19b98968260a6e4aa Mon Sep 17 00:00:00 2001 From: akorchyn Date: Fri, 5 Jul 2024 14:55:10 +0300 Subject: [PATCH 4/8] self-review --- Cargo.toml | 2 +- examples/src/gen/adder.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ba6193d5..299a6464 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,4 +2,4 @@ members = [ "workspaces", "examples", -] \ No newline at end of file +] diff --git a/examples/src/gen/adder.rs b/examples/src/gen/adder.rs index 053ac56b..175ed801 100644 --- a/examples/src/gen/adder.rs +++ b/examples/src/gen/adder.rs @@ -1 +1 @@ -// No content here, it's to be generated on build. Here to allow cargofmt to work. \ No newline at end of file +// No content here, it's to be generated on build. Here to allow cargofmt to work. From 8174babd507713981d317dcc21831b96bdeb5706 Mon Sep 17 00:00:00 2001 From: akorchyn Date: Fri, 5 Jul 2024 16:25:02 +0300 Subject: [PATCH 5/8] test-repo removal --- workspaces/src/network/sandbox.rs | 4 +--- workspaces/src/network/server.rs | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/workspaces/src/network/sandbox.rs b/workspaces/src/network/sandbox.rs index 4552fc5a..5f85ebab 100644 --- a/workspaces/src/network/sandbox.rs +++ b/workspaces/src/network/sandbox.rs @@ -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?, diff --git a/workspaces/src/network/server.rs b/workspaces/src/network/server.rs index f910105c..0693c3a4 100644 --- a/workspaces/src/network/server.rs +++ b/workspaces/src/network/server.rs @@ -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 { + pub(crate) fn new(rpc_addr: String, validator_key: ValidatorKey) -> Result { let rpc_addr = Url::parse(&rpc_addr).map_err(|e| { SandboxErrorCode::InitFailure.full(format!("Invalid rpc_url={rpc_addr}"), e) })?; From ab4530ef55d597d8bc23dfb072a809aa62269673 Mon Sep 17 00:00:00 2001 From: akorchyn Date: Fri, 5 Jul 2024 16:31:07 +0300 Subject: [PATCH 6/8] upgraded sandbox --- workspaces/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspaces/Cargo.toml b/workspaces/Cargo.toml index 1af8d303..2eccd300 100644 --- a/workspaces/Cargo.toml +++ b/workspaces/Cargo.toml @@ -39,7 +39,7 @@ 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.8.0" +near-sandbox-utils = "0.9.0" near-chain-configs = { version = "0.23.0", optional = true } [build-dependencies] From 0a8c0b23f93b6926e447a11be5739ff8ec1f4383 Mon Sep 17 00:00:00 2001 From: akorchyn Date: Fri, 5 Jul 2024 16:51:30 +0300 Subject: [PATCH 7/8] localizing error --- workspaces/tests/account.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/workspaces/tests/account.rs b/workspaces/tests/account.rs index 6f896cb1..8de64a5d 100644 --- a/workspaces/tests/account.rs +++ b/workspaces/tests/account.rs @@ -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; @@ -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(()) } From 0fe35159f86d27c85a83ad32d167e55a4a4c168d Mon Sep 17 00:00:00 2001 From: akorchyn Date: Fri, 5 Jul 2024 17:01:52 +0300 Subject: [PATCH 8/8] review --- workspaces/src/types/account.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/workspaces/src/types/account.rs b/workspaces/src/types/account.rs index 52516587..afe7df00 100644 --- a/workspaces/src/types/account.rs +++ b/workspaces/src/types/account.rs @@ -396,8 +396,6 @@ pub struct AccountDetails { pub locked: NearToken, pub code_hash: CryptoHash, pub storage_usage: StorageUsage, - // TODO: protocol_feature_nonrefundable_transfer_nep491 is not supported by near-cli-rs - pub permanent_storage_bytes: StorageUsage, // Deprecated value. Mainly used to be able to convert back into an AccountView pub(crate) storage_paid_at: BlockHeight, } @@ -408,7 +406,6 @@ impl AccountDetails { balance: NearToken::from_near(0), locked: NearToken::from_near(0), code_hash: CryptoHash::default(), - permanent_storage_bytes: 0, storage_usage: 0, storage_paid_at: 0, } @@ -418,7 +415,7 @@ impl AccountDetails { near_primitives::account::Account::new( self.balance.as_yoctonear(), self.locked.as_yoctonear(), - self.permanent_storage_bytes, + 0, near_primitives::hash::CryptoHash(self.code_hash.0), self.storage_usage, PROTOCOL_VERSION, @@ -438,7 +435,6 @@ impl From for AccountDetails { balance: NearToken::from_yoctonear(account.amount), locked: NearToken::from_yoctonear(account.locked), code_hash: CryptoHash(account.code_hash.0), - permanent_storage_bytes: 0, storage_usage: account.storage_usage, storage_paid_at: account.storage_paid_at, } @@ -453,7 +449,6 @@ impl From for AccountDetails { code_hash: value.code_hash.unwrap_or_default(), storage_usage: value.storage_usage.unwrap_or_default(), storage_paid_at: value.storage_paid_at.unwrap_or_default(), - permanent_storage_bytes: 0, } } }