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

build!: update Rust version and near-* dependencies #118

Merged
merged 11 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ version = "0.15.0"
version = "0.1.0"
edition = "2021"
authors = ["Aurora Labs <[email protected]>"]
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"
Expand All @@ -22,14 +22,14 @@ 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"
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"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<plugin_name>/`.
- This contract is used in `near-plugins-derive/tests/<plugin_name>.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
Expand Down
2 changes: 1 addition & 1 deletion near-plugins-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions near-plugins-derive/tests/access_controllable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -48,7 +48,7 @@ impl Setup {
admins: HashMap<String, AccountId>,
grantees: HashMap<String, AccountId>,
) -> anyhow::Result<Self> {
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?);
Expand Down Expand Up @@ -110,7 +110,7 @@ impl Setup {
async fn call_increase_2(
contract: &Contract,
caller: &Account,
) -> workspaces::Result<ExecutionFinalResult> {
) -> near_workspaces::Result<ExecutionFinalResult> {
caller
.call(contract.id(), "increase_2")
.args_json(())
Expand Down
18 changes: 9 additions & 9 deletions near-plugins-derive/tests/common/access_controllable_contract.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -56,7 +56,7 @@ impl AccessControllableContract {
&self,
caller: &Account,
account_id: &AccountId,
) -> workspaces::Result<ExecutionFinalResult> {
) -> near_workspaces::Result<ExecutionFinalResult> {
caller
.call(self.contract.id(), "acl_init_super_admin")
.args_json(json!({
Expand Down Expand Up @@ -89,7 +89,7 @@ impl AccessControllableContract {
&self,
caller: &Account,
account_id: &AccountId,
) -> workspaces::Result<ExecutionFinalResult> {
) -> near_workspaces::Result<ExecutionFinalResult> {
caller
.call(self.contract.id(), "acl_add_super_admin_unchecked")
.args_json(json!({
Expand Down Expand Up @@ -140,7 +140,7 @@ impl AccessControllableContract {
&self,
caller: &Account,
account_id: &AccountId,
) -> workspaces::Result<ExecutionFinalResult> {
) -> near_workspaces::Result<ExecutionFinalResult> {
caller
.call(self.contract.id(), "acl_revoke_super_admin_unchecked")
.args_json(json!({
Expand Down Expand Up @@ -201,7 +201,7 @@ impl AccessControllableContract {
caller: &Account,
role: &str,
account_id: &AccountId,
) -> workspaces::Result<ExecutionFinalResult> {
) -> near_workspaces::Result<ExecutionFinalResult> {
caller
.call(self.contract.id(), "acl_add_admin_unchecked")
.args_json(json!({
Expand Down Expand Up @@ -252,7 +252,7 @@ impl AccessControllableContract {
caller: &Account,
role: &str,
account_id: &AccountId,
) -> workspaces::Result<ExecutionFinalResult> {
) -> near_workspaces::Result<ExecutionFinalResult> {
caller
.call(self.contract.id(), "acl_revoke_admin_unchecked")
.args_json(json!({
Expand Down Expand Up @@ -314,7 +314,7 @@ impl AccessControllableContract {
caller: &Account,
role: &str,
account_id: &AccountId,
) -> workspaces::Result<ExecutionFinalResult> {
) -> near_workspaces::Result<ExecutionFinalResult> {
caller
.call(self.contract.id(), "acl_grant_role_unchecked")
.args_json(json!({
Expand Down Expand Up @@ -365,7 +365,7 @@ impl AccessControllableContract {
caller: &Account,
role: &str,
account_id: &AccountId,
) -> workspaces::Result<ExecutionFinalResult> {
) -> near_workspaces::Result<ExecutionFinalResult> {
caller
.call(self.contract.id(), "acl_revoke_role_unchecked")
.args_json(json!({
Expand Down
8 changes: 4 additions & 4 deletions near-plugins-derive/tests/common/key.rs
Original file line number Diff line number Diff line change
@@ -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<ExecutionFinalResult> {
) -> near_workspaces::Result<ExecutionFinalResult> {
signer.batch(contract).delete_key(key).transact().await
}

Expand Down
6 changes: 3 additions & 3 deletions near-plugins-derive/tests/common/ownable_contract.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -26,7 +26,7 @@ impl OwnableContract {
&self,
caller: &Account,
owner: Option<AccountId>,
) -> workspaces::Result<ExecutionFinalResult> {
) -> near_workspaces::Result<ExecutionFinalResult> {
caller
.call(self.contract.id(), "owner_set")
.args_json(json!({ "owner": owner }))
Expand Down
8 changes: 4 additions & 4 deletions near-plugins-derive/tests/common/pausable_contract.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -33,7 +33,7 @@ impl PausableContract {
&self,
caller: &Account,
key: &str,
) -> workspaces::Result<ExecutionFinalResult> {
) -> near_workspaces::Result<ExecutionFinalResult> {
caller
.call(self.contract.id(), "pa_pause_feature")
.args_json(json!({ "key": key }))
Expand All @@ -46,7 +46,7 @@ impl PausableContract {
&self,
caller: &Account,
key: &str,
) -> workspaces::Result<ExecutionFinalResult> {
) -> near_workspaces::Result<ExecutionFinalResult> {
caller
.call(self.contract.id(), "pa_unpause_feature")
.args_json(json!({ "key": key }))
Expand Down
16 changes: 8 additions & 8 deletions near-plugins-derive/tests/common/upgradable_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -36,7 +36,7 @@ impl UpgradableContract {
&self,
caller: &Account,
code: Vec<u8>,
) -> workspaces::Result<ExecutionFinalResult> {
) -> near_workspaces::Result<ExecutionFinalResult> {
caller
.call(self.contract.id(), "up_stage_code")
.args_borsh(code)
Expand Down Expand Up @@ -66,13 +66,13 @@ impl UpgradableContract {
Ok(res.json::<Option<CryptoHash>>()?)
}

/// 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<FunctionCallArgs>,
) -> workspaces::Result<ExecutionFinalResult> {
) -> near_workspaces::Result<ExecutionFinalResult> {
caller
.call(self.contract.id(), "up_deploy_code")
.args_json(json!({
Expand All @@ -87,7 +87,7 @@ impl UpgradableContract {
&self,
caller: &Account,
staging_duration: Duration,
) -> workspaces::Result<ExecutionFinalResult> {
) -> near_workspaces::Result<ExecutionFinalResult> {
caller
.call(self.contract.id(), "up_init_staging_duration")
.args_json(json!({ "staging_duration": staging_duration }))
Expand All @@ -100,7 +100,7 @@ impl UpgradableContract {
&self,
caller: &Account,
staging_duration: Duration,
) -> workspaces::Result<ExecutionFinalResult> {
) -> near_workspaces::Result<ExecutionFinalResult> {
caller
.call(self.contract.id(), "up_stage_update_staging_duration")
.args_json(json!({ "staging_duration": staging_duration }))
Expand All @@ -112,7 +112,7 @@ impl UpgradableContract {
pub async fn up_apply_update_staging_duration(
&self,
caller: &Account,
) -> workspaces::Result<ExecutionFinalResult> {
) -> near_workspaces::Result<ExecutionFinalResult> {
caller
.call(self.contract.id(), "up_apply_update_staging_duration")
.max_gas()
Expand Down
12 changes: 6 additions & 6 deletions near-plugins-derive/tests/common/utils.rs
Original file line number Diff line number Diff line change
@@ -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.
///
Expand Down Expand Up @@ -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<ExecutionFinalResult, workspaces::error::Error>,
res: near_workspaces::Result<ExecutionFinalResult, near_workspaces::error::Error>,
) {
let err = res.expect_err("Transaction should not have been executed");

Expand Down Expand Up @@ -202,7 +202,7 @@ async fn block_timestamp(worker: &Worker<Sandbox>) -> u64 {
pub async fn get_transaction_block(
worker: &Worker<Sandbox>,
result: &ExecutionOutcome,
) -> workspaces::Result<Block> {
) -> near_workspaces::Result<Block> {
let block_hash = result.block_hash;
worker.view_block().block_hash(block_hash).await
}
Expand All @@ -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<Sandbox>, duration: Duration) {
let initial_timestamp = block_timestamp(worker).await;

Expand Down
2 changes: 1 addition & 1 deletion near-plugins-derive/tests/contracts/README.md
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[toolchain]
channel = "1.66.1"
channel = "1.70.0"
components = ["clippy", "rustfmt"]
targets = [ "wasm32-unknown-unknown" ]
2 changes: 1 addition & 1 deletion near-plugins-derive/tests/contracts/ownable/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion near-plugins-derive/tests/contracts/ownable/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[toolchain]
channel = "1.66.1"
channel = "1.70.0"
components = ["clippy", "rustfmt"]
targets = [ "wasm32-unknown-unknown" ]
2 changes: 1 addition & 1 deletion near-plugins-derive/tests/contracts/pausable/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion near-plugins-derive/tests/contracts/pausable/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[toolchain]
channel = "1.66.1"
channel = "1.70.0"
components = ["clippy", "rustfmt"]
targets = [ "wasm32-unknown-unknown" ]
2 changes: 1 addition & 1 deletion near-plugins-derive/tests/contracts/upgradable/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[toolchain]
channel = "1.66.1"
channel = "1.70.0"
components = ["clippy", "rustfmt"]
targets = [ "wasm32-unknown-unknown" ]
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Loading