From 43b12e5c0d06d7d05d912ede03937d9fecde1cd2 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 1 Nov 2023 18:46:30 +0100 Subject: [PATCH 01/11] Update to rust-version to 1.70.0 --- Cargo.toml | 2 +- .../tests/contracts/access_controllable/rust-toolchain | 3 ++- near-plugins-derive/tests/contracts/ownable/rust-toolchain | 3 ++- near-plugins-derive/tests/contracts/pausable/rust-toolchain | 3 ++- near-plugins-derive/tests/contracts/upgradable/rust-toolchain | 3 ++- .../tests/contracts/upgradable_2/rust-toolchain | 3 ++- .../tests/contracts/upgradable_state_migration/rust-toolchain | 3 ++- rust-toolchain | 3 ++- 8 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 61feeb5..e529649 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ version = "0.15.0" version = "0.1.0" edition = "2021" authors = ["Aurora Labs "] -rust-version = "1.64.0" +rust-version = "1.70.0" description = "Ergonomic plugin system to extend NEAR contracts." license = "CC0-1.0" readme = "README.md" diff --git a/near-plugins-derive/tests/contracts/access_controllable/rust-toolchain b/near-plugins-derive/tests/contracts/access_controllable/rust-toolchain index 2f3cf78..1cba0df 100644 --- a/near-plugins-derive/tests/contracts/access_controllable/rust-toolchain +++ b/near-plugins-derive/tests/contracts/access_controllable/rust-toolchain @@ -1,3 +1,4 @@ [toolchain] -channel = "1.66.1" +channel = "1.70.0" components = ["clippy", "rustfmt"] +targets = [ "wasm32-unknown-unknown" ] diff --git a/near-plugins-derive/tests/contracts/ownable/rust-toolchain b/near-plugins-derive/tests/contracts/ownable/rust-toolchain index 2f3cf78..1cba0df 100644 --- a/near-plugins-derive/tests/contracts/ownable/rust-toolchain +++ b/near-plugins-derive/tests/contracts/ownable/rust-toolchain @@ -1,3 +1,4 @@ [toolchain] -channel = "1.66.1" +channel = "1.70.0" components = ["clippy", "rustfmt"] +targets = [ "wasm32-unknown-unknown" ] diff --git a/near-plugins-derive/tests/contracts/pausable/rust-toolchain b/near-plugins-derive/tests/contracts/pausable/rust-toolchain index 2f3cf78..1cba0df 100644 --- a/near-plugins-derive/tests/contracts/pausable/rust-toolchain +++ b/near-plugins-derive/tests/contracts/pausable/rust-toolchain @@ -1,3 +1,4 @@ [toolchain] -channel = "1.66.1" +channel = "1.70.0" components = ["clippy", "rustfmt"] +targets = [ "wasm32-unknown-unknown" ] diff --git a/near-plugins-derive/tests/contracts/upgradable/rust-toolchain b/near-plugins-derive/tests/contracts/upgradable/rust-toolchain index 2f3cf78..1cba0df 100644 --- a/near-plugins-derive/tests/contracts/upgradable/rust-toolchain +++ b/near-plugins-derive/tests/contracts/upgradable/rust-toolchain @@ -1,3 +1,4 @@ [toolchain] -channel = "1.66.1" +channel = "1.70.0" components = ["clippy", "rustfmt"] +targets = [ "wasm32-unknown-unknown" ] diff --git a/near-plugins-derive/tests/contracts/upgradable_2/rust-toolchain b/near-plugins-derive/tests/contracts/upgradable_2/rust-toolchain index 2f3cf78..1cba0df 100644 --- a/near-plugins-derive/tests/contracts/upgradable_2/rust-toolchain +++ b/near-plugins-derive/tests/contracts/upgradable_2/rust-toolchain @@ -1,3 +1,4 @@ [toolchain] -channel = "1.66.1" +channel = "1.70.0" components = ["clippy", "rustfmt"] +targets = [ "wasm32-unknown-unknown" ] diff --git a/near-plugins-derive/tests/contracts/upgradable_state_migration/rust-toolchain b/near-plugins-derive/tests/contracts/upgradable_state_migration/rust-toolchain index 2f3cf78..1cba0df 100644 --- a/near-plugins-derive/tests/contracts/upgradable_state_migration/rust-toolchain +++ b/near-plugins-derive/tests/contracts/upgradable_state_migration/rust-toolchain @@ -1,3 +1,4 @@ [toolchain] -channel = "1.66.1" +channel = "1.70.0" components = ["clippy", "rustfmt"] +targets = [ "wasm32-unknown-unknown" ] diff --git a/rust-toolchain b/rust-toolchain index 2f3cf78..1cba0df 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,4 @@ [toolchain] -channel = "1.66.1" +channel = "1.70.0" components = ["clippy", "rustfmt"] +targets = [ "wasm32-unknown-unknown" ] From e472e16de7e162020fa39434f4d8685488789ce2 Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 2 Nov 2023 10:48:24 +0100 Subject: [PATCH 02/11] Update workspaces, rename to near-workspaces --- Cargo.toml | 2 +- README.md | 2 +- near-plugins-derive/Cargo.toml | 2 +- .../tests/access_controllable.rs | 10 +-- .../common/access_controllable_contract.rs | 18 ++--- near-plugins-derive/tests/common/key.rs | 8 +-- .../tests/common/ownable_contract.rs | 6 +- .../tests/common/pausable_contract.rs | 8 +-- .../tests/common/upgradable_contract.rs | 16 ++--- near-plugins-derive/tests/common/utils.rs | 12 ++-- near-plugins-derive/tests/contracts/README.md | 2 +- near-plugins-derive/tests/ownable.rs | 36 +++++----- near-plugins-derive/tests/pausable.rs | 10 +-- near-plugins-derive/tests/upgradable.rs | 68 ++++++++++--------- 14 files changed, 103 insertions(+), 97 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e529649..19b60f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ serde = "1" anyhow = "1.0" borsh = "0.9" tokio = { version = "1", features = ["full"] } -workspaces = "0.7" +near-workspaces = "0.9" toml = "0.5" darling = "0.13.1" proc-macro2 = "1.0" diff --git a/README.md b/README.md index f9b9991..860bbfa 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ Tests should verify that once the macros provided by this crate are expanded, th - A contract using the plugin is contained in `near-plugins-derive/tests/contracts//`. - This contract is used in `near-plugins-derive/tests/.rs` which: - - Compiles and deploys the contract on chain via [NEAR `workspaces`](https://docs.rs/workspaces/0.7.0/workspaces/). + - Compiles and deploys the contract on chain via [`near-workspaces`](https://crates.io/crates/near-workspaces). - Sends transactions to the deployed contract to verify plugin functionality. ## Contributors Notes diff --git a/near-plugins-derive/Cargo.toml b/near-plugins-derive/Cargo.toml index 74d99b5..65fce97 100644 --- a/near-plugins-derive/Cargo.toml +++ b/near-plugins-derive/Cargo.toml @@ -21,5 +21,5 @@ borsh.workspace = true near-plugins.workspace = true near-sdk.workspace = true tokio.workspace = true -workspaces.workspace = true +near-workspaces.workspace = true toml.workspace = true diff --git a/near-plugins-derive/tests/access_controllable.rs b/near-plugins-derive/tests/access_controllable.rs index aba6b3e..d08af48 100644 --- a/near-plugins-derive/tests/access_controllable.rs +++ b/near-plugins-derive/tests/access_controllable.rs @@ -9,12 +9,12 @@ use common::utils::{ }; use near_plugins::access_controllable::{PermissionedAccounts, PermissionedAccountsPerRole}; use near_sdk::serde_json::json; +use near_workspaces::network::Sandbox; +use near_workspaces::result::ExecutionFinalResult; +use near_workspaces::{Account, AccountId, Contract, Worker}; use std::collections::{HashMap, HashSet}; use std::convert::TryFrom; use std::path::Path; -use workspaces::network::Sandbox; -use workspaces::result::ExecutionFinalResult; -use workspaces::{Account, AccountId, Contract, Worker}; const PROJECT_PATH: &str = "./tests/contracts/access_controllable"; @@ -48,7 +48,7 @@ impl Setup { admins: HashMap, grantees: HashMap, ) -> anyhow::Result { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let wasm = common::repo::compile_project(Path::new(PROJECT_PATH), "access_controllable").await?; let contract = AccessControllableContract::new(worker.dev_deploy(&wasm).await?); @@ -110,7 +110,7 @@ impl Setup { async fn call_increase_2( contract: &Contract, caller: &Account, -) -> workspaces::Result { +) -> near_workspaces::Result { caller .call(contract.id(), "increase_2") .args_json(()) diff --git a/near-plugins-derive/tests/common/access_controllable_contract.rs b/near-plugins-derive/tests/common/access_controllable_contract.rs index 4e52f26..6e8c1e5 100644 --- a/near-plugins-derive/tests/common/access_controllable_contract.rs +++ b/near-plugins-derive/tests/common/access_controllable_contract.rs @@ -1,8 +1,8 @@ use near_plugins::access_controllable::PermissionedAccounts; use near_sdk::serde_json::json; -use workspaces::result::ExecutionFinalResult; -use workspaces::{Account, AccountId, Contract}; +use near_workspaces::result::ExecutionFinalResult; +use near_workspaces::{Account, AccountId, Contract}; /// Wrapper for a contract that is `#[access_controllable]`. It allows /// implementing helpers for calling contract methods. @@ -56,7 +56,7 @@ impl AccessControllableContract { &self, caller: &Account, account_id: &AccountId, - ) -> workspaces::Result { + ) -> near_workspaces::Result { caller .call(self.contract.id(), "acl_init_super_admin") .args_json(json!({ @@ -89,7 +89,7 @@ impl AccessControllableContract { &self, caller: &Account, account_id: &AccountId, - ) -> workspaces::Result { + ) -> near_workspaces::Result { caller .call(self.contract.id(), "acl_add_super_admin_unchecked") .args_json(json!({ @@ -140,7 +140,7 @@ impl AccessControllableContract { &self, caller: &Account, account_id: &AccountId, - ) -> workspaces::Result { + ) -> near_workspaces::Result { caller .call(self.contract.id(), "acl_revoke_super_admin_unchecked") .args_json(json!({ @@ -201,7 +201,7 @@ impl AccessControllableContract { caller: &Account, role: &str, account_id: &AccountId, - ) -> workspaces::Result { + ) -> near_workspaces::Result { caller .call(self.contract.id(), "acl_add_admin_unchecked") .args_json(json!({ @@ -252,7 +252,7 @@ impl AccessControllableContract { caller: &Account, role: &str, account_id: &AccountId, - ) -> workspaces::Result { + ) -> near_workspaces::Result { caller .call(self.contract.id(), "acl_revoke_admin_unchecked") .args_json(json!({ @@ -314,7 +314,7 @@ impl AccessControllableContract { caller: &Account, role: &str, account_id: &AccountId, - ) -> workspaces::Result { + ) -> near_workspaces::Result { caller .call(self.contract.id(), "acl_grant_role_unchecked") .args_json(json!({ @@ -365,7 +365,7 @@ impl AccessControllableContract { caller: &Account, role: &str, account_id: &AccountId, - ) -> workspaces::Result { + ) -> near_workspaces::Result { caller .call(self.contract.id(), "acl_revoke_role_unchecked") .args_json(json!({ diff --git a/near-plugins-derive/tests/common/key.rs b/near-plugins-derive/tests/common/key.rs index badc504..17b6b27 100644 --- a/near-plugins-derive/tests/common/key.rs +++ b/near-plugins-derive/tests/common/key.rs @@ -1,13 +1,13 @@ -use workspaces::result::ExecutionFinalResult; -use workspaces::types::{AccessKeyInfo, PublicKey}; -use workspaces::{Account, AccountId, Contract}; +use near_workspaces::result::ExecutionFinalResult; +use near_workspaces::types::{AccessKeyInfo, PublicKey}; +use near_workspaces::{Account, AccountId, Contract}; /// Creates a transaction signed by `signer` to delete `key` from `contract`. pub async fn delete_access_key( signer: &Account, contract: &AccountId, key: PublicKey, -) -> workspaces::Result { +) -> near_workspaces::Result { signer.batch(contract).delete_key(key).transact().await } diff --git a/near-plugins-derive/tests/common/ownable_contract.rs b/near-plugins-derive/tests/common/ownable_contract.rs index 1d13d32..723601c 100644 --- a/near-plugins-derive/tests/common/ownable_contract.rs +++ b/near-plugins-derive/tests/common/ownable_contract.rs @@ -1,6 +1,6 @@ use near_sdk::serde_json::json; -use workspaces::result::ExecutionFinalResult; -use workspaces::{Account, AccountId, Contract}; +use near_workspaces::result::ExecutionFinalResult; +use near_workspaces::{Account, AccountId, Contract}; /// Wrapper for a contract that is `#[ownable]`. It allows implementing helpers for calling contract /// methods. @@ -26,7 +26,7 @@ impl OwnableContract { &self, caller: &Account, owner: Option, - ) -> workspaces::Result { + ) -> near_workspaces::Result { caller .call(self.contract.id(), "owner_set") .args_json(json!({ "owner": owner })) diff --git a/near-plugins-derive/tests/common/pausable_contract.rs b/near-plugins-derive/tests/common/pausable_contract.rs index 783cbf8..6c9c3fa 100644 --- a/near-plugins-derive/tests/common/pausable_contract.rs +++ b/near-plugins-derive/tests/common/pausable_contract.rs @@ -1,7 +1,7 @@ use near_sdk::serde_json::json; +use near_workspaces::result::ExecutionFinalResult; +use near_workspaces::{Account, Contract}; use std::collections::HashSet; -use workspaces::result::ExecutionFinalResult; -use workspaces::{Account, Contract}; /// Wrapper for a contract that is `#[pausable]`. It allows implementing helpers /// for calling contract methods. @@ -33,7 +33,7 @@ impl PausableContract { &self, caller: &Account, key: &str, - ) -> workspaces::Result { + ) -> near_workspaces::Result { caller .call(self.contract.id(), "pa_pause_feature") .args_json(json!({ "key": key })) @@ -46,7 +46,7 @@ impl PausableContract { &self, caller: &Account, key: &str, - ) -> workspaces::Result { + ) -> near_workspaces::Result { caller .call(self.contract.id(), "pa_unpause_feature") .args_json(json!({ "key": key })) diff --git a/near-plugins-derive/tests/common/upgradable_contract.rs b/near-plugins-derive/tests/common/upgradable_contract.rs index 16d39d8..999e10d 100644 --- a/near-plugins-derive/tests/common/upgradable_contract.rs +++ b/near-plugins-derive/tests/common/upgradable_contract.rs @@ -3,8 +3,8 @@ use near_plugins::upgradable::{FunctionCallArgs, UpgradableDurationStatus}; use near_sdk::serde_json::json; use near_sdk::CryptoHash; use near_sdk::Duration; -use workspaces::result::ExecutionFinalResult; -use workspaces::{Account, Contract}; +use near_workspaces::result::ExecutionFinalResult; +use near_workspaces::{Account, Contract}; /// Wrapper for a contract that derives `Upgradable`. It allows implementing helpers for calling /// contract methods provided by `Upgradable`. @@ -36,7 +36,7 @@ impl UpgradableContract { &self, caller: &Account, code: Vec, - ) -> workspaces::Result { + ) -> near_workspaces::Result { caller .call(self.contract.id(), "up_stage_code") .args_borsh(code) @@ -66,13 +66,13 @@ impl UpgradableContract { Ok(res.json::>()?) } - /// The `Promise` returned by trait method `up_deploy_code` is resolved in the `workspaces` + /// The `Promise` returned by trait method `up_deploy_code` is resolved in the `near_workspaces` /// transaction. pub async fn up_deploy_code( &self, caller: &Account, function_call_args: Option, - ) -> workspaces::Result { + ) -> near_workspaces::Result { caller .call(self.contract.id(), "up_deploy_code") .args_json(json!({ @@ -87,7 +87,7 @@ impl UpgradableContract { &self, caller: &Account, staging_duration: Duration, - ) -> workspaces::Result { + ) -> near_workspaces::Result { caller .call(self.contract.id(), "up_init_staging_duration") .args_json(json!({ "staging_duration": staging_duration })) @@ -100,7 +100,7 @@ impl UpgradableContract { &self, caller: &Account, staging_duration: Duration, - ) -> workspaces::Result { + ) -> near_workspaces::Result { caller .call(self.contract.id(), "up_stage_update_staging_duration") .args_json(json!({ "staging_duration": staging_duration })) @@ -112,7 +112,7 @@ impl UpgradableContract { pub async fn up_apply_update_staging_duration( &self, caller: &Account, - ) -> workspaces::Result { + ) -> near_workspaces::Result { caller .call(self.contract.id(), "up_apply_update_staging_duration") .max_gas() diff --git a/near-plugins-derive/tests/common/utils.rs b/near-plugins-derive/tests/common/utils.rs index 04a0f6b..2fb95a9 100644 --- a/near-plugins-derive/tests/common/utils.rs +++ b/near-plugins-derive/tests/common/utils.rs @@ -1,11 +1,11 @@ use near_sdk::serde::de::DeserializeOwned; use near_sdk::Duration; +use near_workspaces::network::Sandbox; +use near_workspaces::result::{ExecutionFinalResult, ExecutionOutcome}; +use near_workspaces::{AccountId, Block, Worker}; use std::cmp::PartialEq; use std::fmt::Debug; use std::str::FromStr; -use workspaces::network::Sandbox; -use workspaces::result::{ExecutionFinalResult, ExecutionOutcome}; -use workspaces::{AccountId, Block, Worker}; /// Converts `account_id` to a `near_sdk::AccountId` and panics on failure. /// @@ -172,7 +172,7 @@ pub fn assert_failure_with(res: ExecutionFinalResult, must_contain: &str) { } pub fn assert_access_key_not_found_error( - res: workspaces::Result, + res: near_workspaces::Result, ) { let err = res.expect_err("Transaction should not have been executed"); @@ -202,7 +202,7 @@ async fn block_timestamp(worker: &Worker) -> u64 { pub async fn get_transaction_block( worker: &Worker, result: &ExecutionOutcome, -) -> workspaces::Result { +) -> near_workspaces::Result { let block_hash = result.block_hash; worker.view_block().block_hash(block_hash).await } @@ -215,7 +215,7 @@ pub async fn get_transaction_block( /// forwarding provided by this function is reasonly fast in our tests for durations that correspond /// to less than 100 seconds. /// -/// [Time travels]: https://github.com/near/workspaces-rs#time-traveling +/// [Time travels]: https://github.com/near/near-workspaces-rs#time-traveling pub async fn fast_forward_beyond(worker: &Worker, duration: Duration) { let initial_timestamp = block_timestamp(worker).await; diff --git a/near-plugins-derive/tests/contracts/README.md b/near-plugins-derive/tests/contracts/README.md index 3721a53..83177aa 100644 --- a/near-plugins-derive/tests/contracts/README.md +++ b/near-plugins-derive/tests/contracts/README.md @@ -1,6 +1,6 @@ Contains contracts that use the plugins provided by `near-plugins`. -These contracts are compiled during tests via Near's `workspaces-rs` and may serve as examples for smart contract developers. +These contracts are compiled during tests via `near-workspaces` and may serve as examples for smart contract developers. # TODO: contract to test optional ACL arguments - `#[access_control]` has optional arguments, e.g. `storage_prefix`. diff --git a/near-plugins-derive/tests/ownable.rs b/near-plugins-derive/tests/ownable.rs index 395e4a4..cced1d1 100644 --- a/near-plugins-derive/tests/ownable.rs +++ b/near-plugins-derive/tests/ownable.rs @@ -10,10 +10,10 @@ use common::utils::{ assert_ownable_permission_failure, assert_owner_update_failure, assert_success_with, }; use near_sdk::serde_json::json; +use near_workspaces::network::Sandbox; +use near_workspaces::result::ExecutionFinalResult; +use near_workspaces::{Account, AccountId, Contract, Worker}; use std::path::Path; -use workspaces::network::Sandbox; -use workspaces::result::ExecutionFinalResult; -use workspaces::{Account, AccountId, Contract, Worker}; const PROJECT_PATH: &str = "./tests/contracts/ownable"; @@ -78,7 +78,7 @@ impl Setup { &self, caller: &Account, method_name: &str, - ) -> workspaces::Result { + ) -> near_workspaces::Result { caller .call(self.contract.id(), method_name) .max_gas() @@ -101,7 +101,7 @@ impl Setup { /// Smoke test of contract setup and basic functionality. #[tokio::test] async fn test_setup() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let setup = Setup::new(worker, None).await?; assert_eq!(setup.get_counter().await?, 0); @@ -116,7 +116,7 @@ async fn test_setup() -> anyhow::Result<()> { #[tokio::test] async fn test_owner_is() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let owner = worker.dev_create_account().await?; let setup = Setup::new(worker, Some(owner.id().clone())).await?; @@ -136,7 +136,7 @@ async fn test_owner_is() -> anyhow::Result<()> { #[tokio::test] async fn test_set_owner_ok() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let setup = Setup::new(worker, None).await?; setup.assert_owner_is(None).await; @@ -154,7 +154,7 @@ async fn test_set_owner_ok() -> anyhow::Result<()> { #[tokio::test] async fn test_set_owner_fail() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let owner = worker.dev_create_account().await?; let setup = Setup::new(worker, Some(owner.id().clone())).await?; @@ -173,7 +173,7 @@ async fn test_set_owner_fail() -> anyhow::Result<()> { #[tokio::test] async fn test_remove_owner() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let owner = worker.dev_create_account().await?; let setup = Setup::new(worker, Some(owner.id().clone())).await?; @@ -192,7 +192,7 @@ async fn test_remove_owner() -> anyhow::Result<()> { /// Contract itself may successfully call a method protected by `#[only(self)]`. #[tokio::test] async fn test_only_self_ok() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let setup = Setup::new(worker, None).await?; assert_eq!(setup.get_counter().await?, 0); @@ -208,7 +208,7 @@ async fn test_only_self_ok() -> anyhow::Result<()> { /// A method protected by `#[only(self)]` fails if called from another account. #[tokio::test] async fn test_only_self_fail_unauth() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let setup = Setup::new(worker, None).await?; let res = setup @@ -222,7 +222,7 @@ async fn test_only_self_fail_unauth() -> anyhow::Result<()> { /// A method protected by `#[only(self)]` fails if called by the owner. #[tokio::test] async fn test_only_self_fail_owner() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let owner = worker.dev_create_account().await?; let setup = Setup::new(worker, Some(owner.id().clone())).await?; @@ -235,7 +235,7 @@ async fn test_only_self_fail_owner() -> anyhow::Result<()> { /// Calling a method protected by `#[only(owner)]` from the owner succeeds. #[tokio::test] async fn test_only_owner_ok() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let owner = worker.dev_create_account().await?; let setup = Setup::new(worker, Some(owner.id().clone())).await?; @@ -250,7 +250,7 @@ async fn test_only_owner_ok() -> anyhow::Result<()> { /// A method protected by `#[only(owner)]` fails if called by the contract itself. #[tokio::test] async fn test_only_owner_fail_self() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let setup = Setup::new(worker, None).await?; let res = setup @@ -264,7 +264,7 @@ async fn test_only_owner_fail_self() -> anyhow::Result<()> { /// A method protected by `#[only(owner)]` fails if called by another account. #[tokio::test] async fn test_only_owner_fail() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let setup = Setup::new(worker, None).await?; let res = setup @@ -279,7 +279,7 @@ async fn test_only_owner_fail() -> anyhow::Result<()> { /// or by the owner. #[tokio::test] async fn test_only_self_owner_ok() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let owner = worker.dev_create_account().await?; let setup = Setup::new(worker, Some(owner.id().clone())).await?; @@ -300,7 +300,7 @@ async fn test_only_self_owner_ok() -> anyhow::Result<()> { /// Calling a method protected by `#[only(self, owner)]` fails if called by another account. #[tokio::test] async fn test_only_self_owner_fail() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let setup = Setup::new(worker, None).await?; let res = setup @@ -314,7 +314,7 @@ async fn test_only_self_owner_fail() -> anyhow::Result<()> { /// Verifies that the contract cannot set a new owner after its access keys are removed. #[tokio::test] async fn test_removing_contract_keys_freezes_owner() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let owner = worker.dev_create_account().await?; let setup = Setup::new(worker, Some(owner.id().clone())).await?; diff --git a/near-plugins-derive/tests/pausable.rs b/near-plugins-derive/tests/pausable.rs index 14fc229..6f5604a 100644 --- a/near-plugins-derive/tests/pausable.rs +++ b/near-plugins-derive/tests/pausable.rs @@ -9,11 +9,11 @@ use common::utils::{ assert_pausable_escape_hatch_is_closed, assert_success_with, assert_success_with_unit_return, }; use near_sdk::serde_json::json; +use near_workspaces::network::Sandbox; +use near_workspaces::result::ExecutionFinalResult; +use near_workspaces::{Account, AccountId, Contract, Worker}; use std::collections::HashSet; use std::path::Path; -use workspaces::network::Sandbox; -use workspaces::result::ExecutionFinalResult; -use workspaces::{Account, AccountId, Contract, Worker}; const PROJECT_PATH: &str = "./tests/contracts/pausable"; @@ -39,7 +39,7 @@ impl Setup { /// Deploys the contract in [`PROJECT_PATH`] and initializes `Setup`. async fn new() -> anyhow::Result { // Compile and deploy the contract. - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let wasm = common::repo::compile_project(Path::new(PROJECT_PATH), "pausable").await?; let contract = worker.dev_deploy(&wasm).await?; let pausable_contract = PausableContract::new(contract.clone()); @@ -99,7 +99,7 @@ impl Setup { &self, caller: &Account, method_name: &str, - ) -> workspaces::Result { + ) -> near_workspaces::Result { caller .call(self.pausable_contract.contract().id(), method_name) .max_gas() diff --git a/near-plugins-derive/tests/upgradable.rs b/near-plugins-derive/tests/upgradable.rs index fa85fd9..825049b 100644 --- a/near-plugins-derive/tests/upgradable.rs +++ b/near-plugins-derive/tests/upgradable.rs @@ -13,10 +13,10 @@ use common::utils::{ use near_plugins::upgradable::FunctionCallArgs; use near_sdk::serde_json::json; use near_sdk::{CryptoHash, Duration, Gas, Timestamp}; +use near_workspaces::network::Sandbox; +use near_workspaces::result::ExecutionFinalResult; +use near_workspaces::{Account, AccountId, Contract, Worker}; use std::path::Path; -use workspaces::network::Sandbox; -use workspaces::result::ExecutionFinalResult; -use workspaces::{Account, AccountId, Contract, Worker}; const PROJECT_PATH: &str = "./tests/contracts/upgradable"; const PROJECT_PATH_2: &str = "./tests/contracts/upgradable_2"; @@ -160,7 +160,10 @@ impl Setup { assert_eq!(status.new_staging_duration_timestamp, expected_timestamp); } - async fn call_is_upgraded(&self, caller: &Account) -> workspaces::Result { + async fn call_is_upgraded( + &self, + caller: &Account, + ) -> near_workspaces::Result { // `is_upgraded` could be called via `view`, however here it is called via `transact` so we // get an `ExecutionFinalResult` that can be passed to `assert_*` methods from // `common::utils`. It is acceptable since all we care about is whether the method exists. @@ -171,7 +174,10 @@ impl Setup { .await } - async fn call_is_migrated(&self, caller: &Account) -> workspaces::Result { + async fn call_is_migrated( + &self, + caller: &Account, + ) -> near_workspaces::Result { // `is_migrated` could be called via `view`, however here it is called via `transact` so we // get an `ExecutionFinalResult` that can be passed to `assert_*` methods from // `common::utils`. It is acceptable since all we care about is whether the method exists @@ -207,7 +213,7 @@ fn convert_code_to_crypto_hash(code: &[u8]) -> CryptoHash { /// Smoke test of contract setup. #[tokio::test] async fn test_setup() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let setup = Setup::new(worker, None, None).await?; setup.assert_is_set_up(&setup.unauth_account).await; @@ -216,7 +222,7 @@ async fn test_setup() -> anyhow::Result<()> { #[tokio::test] async fn test_stage_code_permission_failure() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let dao = worker.dev_create_account().await?; let setup = Setup::new( worker, @@ -245,7 +251,7 @@ async fn test_stage_code_permission_failure() -> anyhow::Result<()> { #[tokio::test] async fn test_stage_code_without_delay() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let dao = worker.dev_create_account().await?; let setup = Setup::new(worker, Some(dao.id().clone()), None).await?; @@ -276,7 +282,7 @@ async fn test_stage_code_without_delay() -> anyhow::Result<()> { #[tokio::test] async fn test_stage_code_with_delay() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let dao = worker.dev_create_account().await?; let staging_duration = sdk_duration_from_secs(42); let setup = Setup::new(worker, Some(dao.id().clone()), Some(staging_duration)).await?; @@ -310,7 +316,7 @@ async fn test_stage_code_with_delay() -> anyhow::Result<()> { #[tokio::test] async fn test_staging_empty_code_clears_storage() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let dao = worker.dev_create_account().await?; let setup = Setup::new( worker, @@ -344,7 +350,7 @@ async fn test_staging_empty_code_clears_storage() -> anyhow::Result<()> { #[tokio::test] async fn test_staged_code() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let dao = worker.dev_create_account().await?; let setup = Setup::new( worker, @@ -381,7 +387,7 @@ async fn test_staged_code() -> anyhow::Result<()> { #[tokio::test] async fn test_staged_code_hash() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let dao = worker.dev_create_account().await?; let setup = Setup::new( worker, @@ -419,7 +425,7 @@ async fn test_staged_code_hash() -> anyhow::Result<()> { #[tokio::test] async fn test_deploy_code_without_delay() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let dao = worker.dev_create_account().await?; let setup = Setup::new(worker.clone(), Some(dao.id().clone()), None).await?; @@ -444,7 +450,7 @@ async fn test_deploy_code_without_delay() -> anyhow::Result<()> { /// explicit state migration. #[tokio::test] async fn test_deploy_code_and_call_method() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let dao = worker.dev_create_account().await?; let setup = Setup::new(worker.clone(), Some(dao.id().clone()), None).await?; @@ -477,7 +483,7 @@ async fn test_deploy_code_and_call_method() -> anyhow::Result<()> { /// succeeded. #[tokio::test] async fn test_deploy_code_with_migration() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let dao = worker.dev_create_account().await?; let setup = Setup::new(worker.clone(), Some(dao.id().clone()), None).await?; @@ -524,7 +530,7 @@ async fn test_deploy_code_with_migration() -> anyhow::Result<()> { /// code remains active. #[tokio::test] async fn test_deploy_code_with_migration_failure_rollback() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let dao = worker.dev_create_account().await?; let setup = Setup::new(worker.clone(), Some(dao.id().clone()), None).await?; @@ -570,7 +576,7 @@ async fn test_deploy_code_with_migration_failure_rollback() -> anyhow::Result<() /// and 2 executes anyway. #[tokio::test] async fn test_deploy_code_in_batch_transaction_pitfall() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let dao = worker.dev_create_account().await?; let setup = Setup::new(worker.clone(), Some(dao.id().clone()), None).await?; @@ -589,7 +595,7 @@ async fn test_deploy_code_in_batch_transaction_pitfall() -> anyhow::Result<()> { // Construct the function call actions to be executed in a batch transaction. // Note that we are attaching a call to `migrate_with_failure`, which will fail. - let fn_call_deploy = workspaces::operations::Function::new("up_deploy_code") + let fn_call_deploy = near_workspaces::operations::Function::new("up_deploy_code") .args_json(json!({ "function_call_args": FunctionCallArgs { function_name: "migrate_with_failure".to_string(), arguments: Vec::new(), @@ -597,7 +603,7 @@ async fn test_deploy_code_in_batch_transaction_pitfall() -> anyhow::Result<()> { gas: Gas::ONE_TERA, } })) .gas(Gas::ONE_TERA.0 * 200); - let fn_call_remove_code = workspaces::operations::Function::new("up_stage_code") + let fn_call_remove_code = near_workspaces::operations::Function::new("up_stage_code") .args_borsh(Vec::::new()) .gas(Gas::ONE_TERA.0 * 90); @@ -635,7 +641,7 @@ async fn test_deploy_code_in_batch_transaction_pitfall() -> anyhow::Result<()> { #[tokio::test] async fn test_deploy_code_with_delay() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let dao = worker.dev_create_account().await?; let staging_duration = sdk_duration_from_secs(3); let setup = Setup::new( @@ -666,7 +672,7 @@ async fn test_deploy_code_with_delay() -> anyhow::Result<()> { #[tokio::test] async fn test_deploy_code_with_delay_failure_too_early() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let dao = worker.dev_create_account().await?; let setup = Setup::new( worker.clone(), @@ -700,7 +706,7 @@ async fn test_deploy_code_with_delay_failure_too_early() -> anyhow::Result<()> { #[tokio::test] async fn test_deploy_code_permission_failure() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let dao = worker.dev_create_account().await?; let setup = Setup::new(worker, Some(dao.id().clone()), None).await?; @@ -735,7 +741,7 @@ async fn test_deploy_code_permission_failure() -> anyhow::Result<()> { /// `up_deploy_code` fails if there's no code staged. #[tokio::test] async fn test_deploy_code_empty_failure() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let dao = worker.dev_create_account().await?; let setup = Setup::new( worker, @@ -764,7 +770,7 @@ async fn test_deploy_code_empty_failure() -> anyhow::Result<()> { #[tokio::test] async fn test_init_staging_duration_permission_failure() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let dao = worker.dev_create_account().await?; let setup = Setup::new(worker, Some(dao.id().clone()), None).await?; @@ -787,7 +793,7 @@ async fn test_init_staging_duration_permission_failure() -> anyhow::Result<()> { #[tokio::test] async fn test_init_staging_duration() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let dao = worker.dev_create_account().await?; let setup = Setup::new(worker, Some(dao.id().clone()), None).await?; @@ -810,7 +816,7 @@ async fn test_init_staging_duration() -> anyhow::Result<()> { #[tokio::test] async fn test_stage_update_staging_duration_permission_failure() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let dao = worker.dev_create_account().await?; let staging_duration = sdk_duration_from_secs(42); let setup = Setup::new(worker, Some(dao.id().clone()), Some(staging_duration)).await?; @@ -835,7 +841,7 @@ async fn test_stage_update_staging_duration_permission_failure() -> anyhow::Resu #[tokio::test] async fn test_stage_update_staging_duration() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let dao = worker.dev_create_account().await?; let staging_duration = sdk_duration_from_secs(42); let setup = Setup::new(worker, Some(dao.id().clone()), Some(staging_duration)).await?; @@ -870,7 +876,7 @@ async fn test_stage_update_staging_duration() -> anyhow::Result<()> { #[tokio::test] async fn test_apply_update_staging_duration_permission_failure() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let dao = worker.dev_create_account().await?; let staging_duration = sdk_duration_from_secs(21); let setup = Setup::new(worker, Some(dao.id().clone()), Some(staging_duration)).await?; @@ -912,7 +918,7 @@ async fn test_apply_update_staging_duration_permission_failure() -> anyhow::Resu #[tokio::test] async fn test_apply_update_staging_duration() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let dao = worker.dev_create_account().await?; let staging_duration = sdk_duration_from_secs(21); let setup = Setup::new(worker, Some(dao.id().clone()), Some(staging_duration)).await?; @@ -946,7 +952,7 @@ async fn test_apply_update_staging_duration() -> anyhow::Result<()> { #[tokio::test] async fn test_apply_update_staging_duration_failure_too_early() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let dao = worker.dev_create_account().await?; let staging_duration = sdk_duration_from_secs(1024); let setup = Setup::new(worker, Some(dao.id().clone()), Some(staging_duration)).await?; @@ -979,7 +985,7 @@ async fn test_apply_update_staging_duration_failure_too_early() -> anyhow::Resul /// that whitelists only roles other than `r`. #[tokio::test] async fn test_acl_permission_scope() -> anyhow::Result<()> { - let worker = workspaces::sandbox().await?; + let worker = near_workspaces::sandbox().await?; let setup = Setup::new(worker.clone(), None, None).await?; // Create an account and grant it `Role::CodeStager`. From aab3242ca362745eecedbc8ff655dcfe1cae2b43 Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 2 Nov 2023 11:26:04 +0100 Subject: [PATCH 03/11] Use new Gas type in some test internals --- near-plugins-derive/tests/upgradable.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/near-plugins-derive/tests/upgradable.rs b/near-plugins-derive/tests/upgradable.rs index 825049b..3ae57da 100644 --- a/near-plugins-derive/tests/upgradable.rs +++ b/near-plugins-derive/tests/upgradable.rs @@ -602,10 +602,10 @@ async fn test_deploy_code_in_batch_transaction_pitfall() -> anyhow::Result<()> { amount: 0, gas: Gas::ONE_TERA, } })) - .gas(Gas::ONE_TERA.0 * 200); + .gas(near_workspaces::types::Gas::from_tgas(200)); let fn_call_remove_code = near_workspaces::operations::Function::new("up_stage_code") .args_borsh(Vec::::new()) - .gas(Gas::ONE_TERA.0 * 90); + .gas(near_workspaces::types::Gas::from_tgas(90)); let res = dao .batch(setup.contract.id()) From d3c54045bd59fcbe34508664c14f3c63b240068b Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 2 Nov 2023 12:38:41 +0100 Subject: [PATCH 04/11] Update near-sdk --- Cargo.toml | 2 +- .../tests/contracts/access_controllable/Cargo.toml | 2 +- near-plugins-derive/tests/contracts/ownable/Cargo.toml | 2 +- near-plugins-derive/tests/contracts/pausable/Cargo.toml | 2 +- near-plugins-derive/tests/contracts/upgradable/Cargo.toml | 2 +- near-plugins-derive/tests/contracts/upgradable_2/Cargo.toml | 2 +- .../tests/contracts/upgradable_state_migration/Cargo.toml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 19b60f8..6b82640 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ keywords = ["near", "smart contract", "plugin"] [workspace.dependencies] bitflags = "1.3" -near-sdk = "4.1.0" +near-sdk = "4.1.1" near-plugins = { path = "near-plugins" } near-plugins-derive = { path = "near-plugins-derive" } serde = "1" diff --git a/near-plugins-derive/tests/contracts/access_controllable/Cargo.toml b/near-plugins-derive/tests/contracts/access_controllable/Cargo.toml index 133101f..9e5ab96 100644 --- a/near-plugins-derive/tests/contracts/access_controllable/Cargo.toml +++ b/near-plugins-derive/tests/contracts/access_controllable/Cargo.toml @@ -8,7 +8,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] near-plugins = { path = "../../../../near-plugins" } -near-sdk = "4.0.0" +near-sdk = "4.1.1" [profile.release] codegen-units = 1 diff --git a/near-plugins-derive/tests/contracts/ownable/Cargo.toml b/near-plugins-derive/tests/contracts/ownable/Cargo.toml index 4937efa..c4e3643 100644 --- a/near-plugins-derive/tests/contracts/ownable/Cargo.toml +++ b/near-plugins-derive/tests/contracts/ownable/Cargo.toml @@ -8,7 +8,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] near-plugins = { path = "../../../../near-plugins" } -near-sdk = "4.1.0" +near-sdk = "4.1.1" [profile.release] codegen-units = 1 diff --git a/near-plugins-derive/tests/contracts/pausable/Cargo.toml b/near-plugins-derive/tests/contracts/pausable/Cargo.toml index 72def35..4869ee8 100644 --- a/near-plugins-derive/tests/contracts/pausable/Cargo.toml +++ b/near-plugins-derive/tests/contracts/pausable/Cargo.toml @@ -8,7 +8,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] near-plugins = { path = "../../../../near-plugins" } -near-sdk = "4.1.0" +near-sdk = "4.1.1" [profile.release] codegen-units = 1 diff --git a/near-plugins-derive/tests/contracts/upgradable/Cargo.toml b/near-plugins-derive/tests/contracts/upgradable/Cargo.toml index bf2f034..e1c3e9e 100644 --- a/near-plugins-derive/tests/contracts/upgradable/Cargo.toml +++ b/near-plugins-derive/tests/contracts/upgradable/Cargo.toml @@ -8,7 +8,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] near-plugins = { path = "../../../../near-plugins" } -near-sdk = "4.1.0" +near-sdk = "4.1.1" [profile.release] codegen-units = 1 diff --git a/near-plugins-derive/tests/contracts/upgradable_2/Cargo.toml b/near-plugins-derive/tests/contracts/upgradable_2/Cargo.toml index e7a0bc5..bc73531 100644 --- a/near-plugins-derive/tests/contracts/upgradable_2/Cargo.toml +++ b/near-plugins-derive/tests/contracts/upgradable_2/Cargo.toml @@ -8,7 +8,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] near-plugins = { path = "../../../../near-plugins" } -near-sdk = "4.1.0" +near-sdk = "4.1.1" [profile.release] codegen-units = 1 diff --git a/near-plugins-derive/tests/contracts/upgradable_state_migration/Cargo.toml b/near-plugins-derive/tests/contracts/upgradable_state_migration/Cargo.toml index 19c14d4..b756334 100644 --- a/near-plugins-derive/tests/contracts/upgradable_state_migration/Cargo.toml +++ b/near-plugins-derive/tests/contracts/upgradable_state_migration/Cargo.toml @@ -8,7 +8,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] near-plugins = { path = "../../../../near-plugins" } -near-sdk = "4.1.0" +near-sdk = "4.1.1" [profile.release] codegen-units = 1 From 01afdbddbb386788d336b9cf33846d4adfc0fee5 Mon Sep 17 00:00:00 2001 From: Moritz Date: Sat, 4 Nov 2023 16:24:34 +0100 Subject: [PATCH 05/11] Set MSRV to 1.69.0 --- Cargo.toml | 2 +- .../tests/contracts/access_controllable/rust-toolchain | 2 +- near-plugins-derive/tests/contracts/ownable/rust-toolchain | 2 +- near-plugins-derive/tests/contracts/pausable/rust-toolchain | 2 +- near-plugins-derive/tests/contracts/upgradable/rust-toolchain | 2 +- near-plugins-derive/tests/contracts/upgradable_2/rust-toolchain | 2 +- .../tests/contracts/upgradable_state_migration/rust-toolchain | 2 +- rust-toolchain | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6b82640..178de3d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ version = "0.15.0" version = "0.1.0" edition = "2021" authors = ["Aurora Labs "] -rust-version = "1.70.0" +rust-version = "1.69.0" description = "Ergonomic plugin system to extend NEAR contracts." license = "CC0-1.0" readme = "README.md" diff --git a/near-plugins-derive/tests/contracts/access_controllable/rust-toolchain b/near-plugins-derive/tests/contracts/access_controllable/rust-toolchain index 1cba0df..6649306 100644 --- a/near-plugins-derive/tests/contracts/access_controllable/rust-toolchain +++ b/near-plugins-derive/tests/contracts/access_controllable/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "1.70.0" +channel = "1.69.0" components = ["clippy", "rustfmt"] targets = [ "wasm32-unknown-unknown" ] diff --git a/near-plugins-derive/tests/contracts/ownable/rust-toolchain b/near-plugins-derive/tests/contracts/ownable/rust-toolchain index 1cba0df..6649306 100644 --- a/near-plugins-derive/tests/contracts/ownable/rust-toolchain +++ b/near-plugins-derive/tests/contracts/ownable/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "1.70.0" +channel = "1.69.0" components = ["clippy", "rustfmt"] targets = [ "wasm32-unknown-unknown" ] diff --git a/near-plugins-derive/tests/contracts/pausable/rust-toolchain b/near-plugins-derive/tests/contracts/pausable/rust-toolchain index 1cba0df..6649306 100644 --- a/near-plugins-derive/tests/contracts/pausable/rust-toolchain +++ b/near-plugins-derive/tests/contracts/pausable/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "1.70.0" +channel = "1.69.0" components = ["clippy", "rustfmt"] targets = [ "wasm32-unknown-unknown" ] diff --git a/near-plugins-derive/tests/contracts/upgradable/rust-toolchain b/near-plugins-derive/tests/contracts/upgradable/rust-toolchain index 1cba0df..6649306 100644 --- a/near-plugins-derive/tests/contracts/upgradable/rust-toolchain +++ b/near-plugins-derive/tests/contracts/upgradable/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "1.70.0" +channel = "1.69.0" components = ["clippy", "rustfmt"] targets = [ "wasm32-unknown-unknown" ] diff --git a/near-plugins-derive/tests/contracts/upgradable_2/rust-toolchain b/near-plugins-derive/tests/contracts/upgradable_2/rust-toolchain index 1cba0df..6649306 100644 --- a/near-plugins-derive/tests/contracts/upgradable_2/rust-toolchain +++ b/near-plugins-derive/tests/contracts/upgradable_2/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "1.70.0" +channel = "1.69.0" components = ["clippy", "rustfmt"] targets = [ "wasm32-unknown-unknown" ] diff --git a/near-plugins-derive/tests/contracts/upgradable_state_migration/rust-toolchain b/near-plugins-derive/tests/contracts/upgradable_state_migration/rust-toolchain index 1cba0df..6649306 100644 --- a/near-plugins-derive/tests/contracts/upgradable_state_migration/rust-toolchain +++ b/near-plugins-derive/tests/contracts/upgradable_state_migration/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "1.70.0" +channel = "1.69.0" components = ["clippy", "rustfmt"] targets = [ "wasm32-unknown-unknown" ] diff --git a/rust-toolchain b/rust-toolchain index 1cba0df..6649306 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "1.70.0" +channel = "1.69.0" components = ["clippy", "rustfmt"] targets = [ "wasm32-unknown-unknown" ] From c603b1c5b81f8a2c784c0b963e133d5d8522efbb Mon Sep 17 00:00:00 2001 From: Moritz Date: Sat, 4 Nov 2023 16:29:02 +0100 Subject: [PATCH 06/11] ci: downgrade some dev-dependencies --- .github/workflows/test.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 99f41cf..b1464a9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,14 @@ jobs: - uses: Swatinem/rust-cache@v1 with: - cache-on-failure: true + key: rust-version-1.69.0-msrv + + - name: downgrade some dev-dependencies for msrv, see https://github.com/near/near-workspaces-rs/issues/336 + run: | + cargo update -p anstyle@1.0.4 --precise 1.0.2 + cargo update -p anstyle-parse@0.2.2 --precise 0.2.1 + cargo update -p clap@4.4.7 --precise 4.3.24 + cargo update -p clap_lex@0.6.0 --precise 0.5.0 - name: add wasm32-unknown-unknown run: rustup target add wasm32-unknown-unknown From fea7e81fa6c251066e16cb4a591ea371804fe9d3 Mon Sep 17 00:00:00 2001 From: Moritz Date: Sat, 4 Nov 2023 16:38:32 +0100 Subject: [PATCH 07/11] Fix version of `clap_lex` --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b1464a9..c8b166b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,7 +28,7 @@ jobs: cargo update -p anstyle@1.0.4 --precise 1.0.2 cargo update -p anstyle-parse@0.2.2 --precise 0.2.1 cargo update -p clap@4.4.7 --precise 4.3.24 - cargo update -p clap_lex@0.6.0 --precise 0.5.0 + cargo update -p clap_lex@0.5.1 --precise 0.5.0 - name: add wasm32-unknown-unknown run: rustup target add wasm32-unknown-unknown From 4454ba02df6d294d4164125f884767bb043cf1a5 Mon Sep 17 00:00:00 2001 From: Moritz Date: Sun, 5 Nov 2023 00:41:36 +0100 Subject: [PATCH 08/11] Add `scripts/fix_dependencies.sh` --- .github/workflows/test.yml | 6 +----- scripts/fix_dependencies.sh | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) create mode 100755 scripts/fix_dependencies.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c8b166b..d1fb8bf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,11 +24,7 @@ jobs: key: rust-version-1.69.0-msrv - name: downgrade some dev-dependencies for msrv, see https://github.com/near/near-workspaces-rs/issues/336 - run: | - cargo update -p anstyle@1.0.4 --precise 1.0.2 - cargo update -p anstyle-parse@0.2.2 --precise 0.2.1 - cargo update -p clap@4.4.7 --precise 4.3.24 - cargo update -p clap_lex@0.5.1 --precise 0.5.0 + run: ./scripts/fix_dependencies.sh - name: add wasm32-unknown-unknown run: rustup target add wasm32-unknown-unknown diff --git a/scripts/fix_dependencies.sh b/scripts/fix_dependencies.sh new file mode 100755 index 0000000..531c85b --- /dev/null +++ b/scripts/fix_dependencies.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# Due to upgrades of dependencies of `near-workspaces`, the compilation of tests using the MSRV (min +# supported Rust version) may fail. This can be fixed be downgrading these dependencies to a version +# that supports our MRSV, which is what this script does. +# +# Reference: https://github.com/near/near-workspaces-rs/issues/336 +# +# For some packages, `near-workspaces@0.9` depends on two different versions, requiring below +# downgrade commands to specify the full semver version as in `-p clap@4.4.7`. I assume once a new +# version of `clap` is released, say 4.4.8, then below must be updated to `-p clap@4.4.8`. Even +# though this is flaky, it seems to be cleanest approach that works in with CI (see #119 for some +# other attempts and how they failed in CI). +cargo update -p anstyle@1.0.4 --precise 1.0.2 +cargo update -p anstyle-parse@0.2.2 --precise 0.2.1 +cargo update -p clap@4.4.7 --precise 4.3.24 +cargo update -p clap_lex@0.5.1 --precise 0.5.0 From 109228f09b1566d7204723a50c996bd73e45eafb Mon Sep 17 00:00:00 2001 From: Moritz Date: Sun, 5 Nov 2023 18:25:06 +0100 Subject: [PATCH 09/11] ci: downgrade deps in `lint` job --- .github/workflows/test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d1fb8bf..621e314 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -47,7 +47,10 @@ jobs: - uses: Swatinem/rust-cache@v1 with: - cache-on-failure: true + key: rust-version-1.69.0-msrv + + - name: downgrade some dev-dependencies for msrv, see https://github.com/near/near-workspaces-rs/issues/336 + run: ./scripts/fix_dependencies.sh - name: cargo fmt run: cargo fmt --all -- --check From 8d95f01004a06b80b96b680540861a695febe92c Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 6 Nov 2023 11:47:28 +0100 Subject: [PATCH 10/11] Mention scripts/fix-dependencies.sh in README --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 860bbfa..efd5dc2 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ Tests should verify that once the macros provided by this crate are expanded, th - Compiles and deploys the contract on chain via [`near-workspaces`](https://crates.io/crates/near-workspaces). - Sends transactions to the deployed contract to verify plugin functionality. -## Contributors Notes +## Traits and their implementations Traits doesn't contain any implementation, even though some interfaces are self-contained enough to have it. It is this way since `near_bindgen` macro from near-sdk-rs will only expose as public methods those that are implemented @@ -77,6 +77,11 @@ during the trait implementation for the contract. In the documentation all comments under Default Implementation makes remarks about the current implementation derived automatically from macros. They can be changed if the trait is manually implemented rather than deriving the macro. +## Contributor Notes + +When compiling tests for the first time on a machine using the MSRV 1.69.0, an error might occur due to some dependencies of `near-workspaces` requiring a higher version of Rust. You can execute [./script/fix-dependencies.sh](./scripts/fix_dependencies.sh) to install a compatible version of these dependencies. The comments in that script provide additional information. + + ## Roadmap - Factory upgrades: Allow upgrading all deployed contracts from the factory fetching binary upstream. From ffd0ec39ff0e0018d589beddd681bedf1850ec0c Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 8 Nov 2023 16:37:49 +0100 Subject: [PATCH 11/11] Fix language in comments --- scripts/fix_dependencies.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/fix_dependencies.sh b/scripts/fix_dependencies.sh index 531c85b..6130537 100755 --- a/scripts/fix_dependencies.sh +++ b/scripts/fix_dependencies.sh @@ -1,16 +1,16 @@ #!/usr/bin/env bash -# Due to upgrades of dependencies of `near-workspaces`, the compilation of tests using the MSRV (min -# supported Rust version) may fail. This can be fixed be downgrading these dependencies to a version -# that supports our MRSV, which is what this script does. +# Due to upgrades of dependencies of `near-workspaces`, the compilation of tests with the MSRV (min +# supported Rust version) may fail. This can be fixed by downgrading these dependencies to a version +# that supports our MRSV, which is the purpose of this script. # # Reference: https://github.com/near/near-workspaces-rs/issues/336 # # For some packages, `near-workspaces@0.9` depends on two different versions, requiring below # downgrade commands to specify the full semver version as in `-p clap@4.4.7`. I assume once a new -# version of `clap` is released, say 4.4.8, then below must be updated to `-p clap@4.4.8`. Even -# though this is flaky, it seems to be cleanest approach that works in with CI (see #119 for some -# other attempts and how they failed in CI). +# version of `clap` is released, say 4.4.8, then below must be changed to `-p clap@4.4.8`. Even +# though this requires maintenance, it seems to be cleanest approach that works with CI (see #119 +# for some other attempts and how they failed in CI). cargo update -p anstyle@1.0.4 --precise 1.0.2 cargo update -p anstyle-parse@0.2.2 --precise 0.2.1 cargo update -p clap@4.4.7 --precise 4.3.24