diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 915c5e0..8d50000 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: toolchain: 1.72 @@ -27,7 +27,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: toolchain: 1.72 @@ -36,16 +36,24 @@ jobs: run: cargo clippy -- -D warnings test: runs-on: ubuntu-latest + env: + CARGO_TERM_COLOR: always steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: toolchain: 1.72 + - uses: taiki-e/install-action@v2 + with: + tool: nextest + - uses: Swatinem/rust-cache@v2 - name: Run unit and integration tests - run: cargo test --workspace --exclude workspaces-tests + run: cargo nextest run --workspace --exclude workspaces-tests workspaces-test: runs-on: ubuntu-latest + env: + CARGO_TERM_COLOR: always steps: - uses: actions/checkout@v3 @@ -53,8 +61,9 @@ jobs: with: toolchain: 1.72 targets: wasm32-unknown-unknown + - uses: taiki-e/install-action@v2 + with: + tool: cargo-make,nextest + - uses: Swatinem/rust-cache@v2 - name: Run workspaces tests - run: > - cd workspaces-tests; - cargo install cargo-make; - cargo make test; + run: cd workspaces-tests && cargo make nextest diff --git a/Cargo.toml b/Cargo.toml index dd63626..4b1768f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,14 +1,24 @@ [package] -authors = ["Jacob Lindahl "] +authors.workspace = true categories = ["wasm", "cryptography::cryptocurrencies"] description = """ Helpful functions and macros for developing smart contracts on NEAR Protocol. """ documentation = "https://docs.rs/near-sdk-contract-tools" -edition = "2021" +edition.workspace = true exclude = ["documents/"] -license = "GPL-3.0" +license.workspace = true name = "near-sdk-contract-tools" +repository.workspace = true +version.workspace = true + +[workspace] +members = [".", "macros", "workspaces-tests", "workspaces-tests-utils"] + +[workspace.package] +authors = ["Jacob Lindahl "] +edition = "2021" +license = "GPL-3.0" repository = "https://github.com/near/near-sdk-contract-tools" version = "1.1.0" @@ -16,18 +26,25 @@ version = "1.1.0" # normal dependencies near-sdk = { version = "4.1.1", default-features = false } near-sdk-contract-tools-macros = { version = "=1.1.0", path = "./macros" } -serde = "1.0.144" -serde_json = "1.0.85" -thiserror = "1.0.35" +thiserror = "1" + +darling = "0.20" +heck = "0.4" +proc-macro2 = "1" +quote = "1.0" +strum = "0.25" +strum_macros = "0.25" +syn = "2.0" # dev-dependencies -pretty_assertions = "1.4.0" +near-crypto = "0.15" +near-workspaces = "0.8" +pretty_assertions = "1" +tokio = "1" [dependencies] near-sdk.workspace = true near-sdk-contract-tools-macros.workspace = true -serde.workspace = true -serde_json.workspace = true thiserror.workspace = true [dev-dependencies] @@ -43,9 +60,6 @@ unstable = ["near-sdk/unstable"] all-features = true rustdoc-args = ["--cfg", "docsrs"] -[workspace] -members = [".", "macros", "workspaces-tests", "workspaces-tests-utils"] - [profile.release] codegen-units = 1 debug = false diff --git a/macros/Cargo.toml b/macros/Cargo.toml index 51d542e..20fd1fb 100644 --- a/macros/Cargo.toml +++ b/macros/Cargo.toml @@ -1,25 +1,24 @@ [package] -authors = ["Jacob Lindahl "] +authors.workspace = true categories = ["wasm"] description = """ Macros for `near-sdk-contract-tools` """ -edition = "2021" -license = "GPL-3.0" +documentation = "https://docs.rs/near-sdk-contract-tools-macros" +edition.workspace = true +license.workspace = true name = "near-sdk-contract-tools-macros" -version = "1.1.0" +repository.workspace = true +version.workspace = true [dependencies] -base64 = "0.13.0" -darling = "0.14.1" -heck = "0.4.0" -once_cell = "1.16.0" -proc-macro2 = "1.0.43" -quote = "1.0.21" -regex = "1.6.0" -strum = "0.24.1" -strum_macros = "0.24.3" -syn = "1.0.99" +darling.workspace = true +heck.workspace = true +proc-macro2.workspace = true +quote.workspace = true +strum.workspace = true +strum_macros.workspace = true +syn.workspace = true [lib] proc-macro = true diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 836d1e3..e4a86d6 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -1,8 +1,8 @@ //! Macros for near-sdk-contract-tools. -use darling::{FromDeriveInput, FromMeta}; +use darling::{ast::NestedMeta, FromDeriveInput, FromMeta}; use proc_macro::TokenStream; -use syn::{parse_macro_input, AttributeArgs, DeriveInput, Item}; +use syn::{parse_macro_input, DeriveInput, Item}; mod approval; mod escrow; @@ -27,7 +27,7 @@ fn default_near_sdk() -> syn::Path { } fn default_serde() -> syn::Path { - syn::parse_str("::serde").unwrap() + syn::parse_str("::near_sdk::serde").unwrap() } fn unitify(ty: Option) -> syn::Type { @@ -248,7 +248,12 @@ pub fn derive_simple_multisig(input: TokenStream) -> TokenStream { /// See documentation on the [`derive@Nep297`] derive macro for more details. #[proc_macro_attribute] pub fn event(attr: TokenStream, item: TokenStream) -> TokenStream { - let attr = parse_macro_input!(attr as AttributeArgs); + let attr = match NestedMeta::parse_meta_list(attr.into()) { + Ok(v) => v, + Err(e) => { + return TokenStream::from(darling::Error::from(e).write_errors()); + } + }; let item = parse_macro_input!(item as Item); standard::event::EventAttributeMeta::from_list(&attr) diff --git a/macros/src/upgrade.rs b/macros/src/upgrade.rs index e08a319..0fed6c4 100644 --- a/macros/src/upgrade.rs +++ b/macros/src/upgrade.rs @@ -1,8 +1,6 @@ use darling::{FromDeriveInput, FromMeta}; -use once_cell::sync::OnceCell; use proc_macro2::TokenStream; use quote::quote; -use regex::Regex; use syn::Expr; #[derive(Debug, Clone)] @@ -19,23 +17,21 @@ impl FromMeta for HookBody { } fn from_string(value: &str) -> darling::Result { - static REGEX: OnceCell = OnceCell::new(); - if value == "empty" { Ok(HookBody::Empty) } else if value == "owner" { Ok(HookBody::Owner) + } else if let Some(b) = value + .strip_prefix("role(") + .and_then(|s| s.strip_suffix(')')) + .and_then(|s| syn::parse_str::(s).ok()) + .map(|e| HookBody::Role(Box::new(e))) + { + Ok(b) } else { - let r = REGEX.get_or_init(|| Regex::new(r"^role\((.+)\)$").unwrap()); - r.captures(value) - .and_then(|c| c.get(1)) - .and_then(|s| syn::parse_str::(s.as_str()).ok()) - .map(|e| HookBody::Role(Box::new(e))) - .ok_or_else(|| { - darling::Error::custom(format!( - r#"Invalid value "{value}", expected "empty", "owner", or "role(...)""#, - )) - }) + Err(darling::Error::custom(format!( + r#"Invalid value "{value}", expected "empty", "owner", or "role(...)""#, + ))) } } } diff --git a/src/approval/mod.rs b/src/approval/mod.rs index e4045b4..95fe2c4 100644 --- a/src/approval/mod.rs +++ b/src/approval/mod.rs @@ -2,9 +2,10 @@ use near_sdk::{ borsh::{self, BorshDeserialize, BorshSerialize}, - env, require, AccountId, BorshStorageKey, + env, require, + serde::{Deserialize, Serialize}, + AccountId, BorshStorageKey, }; -use serde::{Deserialize, Serialize}; use thiserror::Error; use crate::{slot::Slot, DefaultStorageKey}; @@ -64,6 +65,7 @@ pub trait ApprovalConfiguration { /// An action request is composed of an action that will be executed when the /// associated approval state is satisfied #[derive(Serialize, Deserialize, BorshSerialize, BorshDeserialize, Debug)] +#[serde(crate = "near_sdk::serde")] pub struct ActionRequest { /// The action that will be executed when the approval state is /// fulfilled @@ -336,11 +338,11 @@ mod tests { use near_sdk::{ borsh::{self, BorshDeserialize, BorshSerialize}, near_bindgen, + serde::Serialize, test_utils::VMContextBuilder, testing_env, AccountId, BorshStorageKey, }; use near_sdk_contract_tools_macros::Rbac; - use serde::Serialize; use crate::{rbac::Rbac, slot::Slot}; @@ -405,6 +407,7 @@ mod tests { } #[derive(BorshSerialize, BorshDeserialize, Serialize, Default, Debug)] + #[serde(crate = "near_sdk::serde")] struct MultisigApprovalState { pub approved_by: Vec, } diff --git a/src/approval/native_transaction_action.rs b/src/approval/native_transaction_action.rs index 3058115..179ab9d 100644 --- a/src/approval/native_transaction_action.rs +++ b/src/approval/native_transaction_action.rs @@ -5,14 +5,15 @@ use near_sdk::{ borsh::{self, BorshDeserialize, BorshSerialize}, json_types::{Base64VecU8, U128, U64}, + serde::{Deserialize, Serialize}, AccountId, Gas, Promise, }; -use serde::{Deserialize, Serialize}; /// Every native NEAR action can be mapped to a Promise action. /// NOTE: The native ADD_KEY action is split into two: one for adding a /// full-access key, one for a function call access key. #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, BorshSerialize, BorshDeserialize)] +#[serde(crate = "near_sdk::serde")] pub enum PromiseAction { /// Native CREATE_ACCOUNT action CreateAccount, @@ -79,6 +80,7 @@ pub enum PromiseAction { /// A native protocol-level transaction that (de)serializes into many different /// formats #[derive(BorshSerialize, BorshDeserialize, Serialize, Deserialize, Eq, PartialEq, Clone, Debug)] +#[serde(crate = "near_sdk::serde")] pub struct NativeTransactionAction { /// Receiver of the transaction pub receiver_id: AccountId, diff --git a/src/approval/simple_multisig.rs b/src/approval/simple_multisig.rs index cdd0463..75c5b9b 100644 --- a/src/approval/simple_multisig.rs +++ b/src/approval/simple_multisig.rs @@ -5,9 +5,10 @@ use std::marker::PhantomData; use near_sdk::{ borsh::{self, BorshDeserialize, BorshSerialize}, - env, AccountId, + env, + serde::{Deserialize, Serialize}, + AccountId, }; -use serde::{Deserialize, Serialize}; use thiserror::Error; use super::{ActionRequest, ApprovalConfiguration}; @@ -24,6 +25,7 @@ pub trait AccountAuthorizer { /// M (threshold) of N approval scheme #[derive(BorshSerialize, BorshDeserialize, Serialize, Deserialize, Clone, Debug)] +#[serde(crate = "near_sdk::serde")] pub struct Configuration { /// How many approvals are required? pub threshold: u8, @@ -61,6 +63,7 @@ impl Configuration { /// Approval state for simple multisig #[derive(BorshSerialize, BorshDeserialize, Serialize, Deserialize, Debug)] +#[serde(crate = "near_sdk::serde")] pub struct ApprovalState { /// List of accounts that have approved an action thus far pub approved_by: Vec, diff --git a/src/standard/nep141/event.rs b/src/standard/nep141/event.rs index 53de6c1..7f6a8bb 100644 --- a/src/standard/nep141/event.rs +++ b/src/standard/nep141/event.rs @@ -6,7 +6,6 @@ use near_sdk_contract_tools_macros::event; #[event( crate = "crate", macros = "crate", - serde = "serde", standard = "nep141", version = "1.0.0" )] @@ -24,11 +23,11 @@ pub enum Nep141Event { /// Decrease in total_supply. FtBurn(Vec), } -use near_sdk::{json_types::U128, AccountId}; -use serde::Serialize; +use near_sdk::{json_types::U128, serde::Serialize, AccountId}; /// Individual mint metadata #[derive(Serialize, Debug, Clone)] +#[serde(crate = "near_sdk::serde")] pub struct FtMintData { /// Address to which new tokens were minted pub owner_id: AccountId, @@ -41,6 +40,7 @@ pub struct FtMintData { /// Individual transfer metadata #[derive(Serialize, Debug, Clone)] +#[serde(crate = "near_sdk::serde")] pub struct FtTransferData { /// Account ID of the sender pub old_owner_id: AccountId, @@ -55,6 +55,7 @@ pub struct FtTransferData { /// Individual burn metadata #[derive(Serialize, Debug, Clone)] +#[serde(crate = "near_sdk::serde")] pub struct FtBurnData { /// Account ID from which tokens were burned pub owner_id: AccountId, diff --git a/src/standard/nep141/mod.rs b/src/standard/nep141/mod.rs index 32b8af3..06d2df5 100644 --- a/src/standard/nep141/mod.rs +++ b/src/standard/nep141/mod.rs @@ -33,6 +33,7 @@ enum StorageKey { /// Transfer metadata generic over both types of transfer (`ft_transfer` and /// `ft_transfer_call`). #[derive(Serialize, BorshSerialize, PartialEq, Eq, Clone, Debug)] +#[serde(crate = "near_sdk::serde")] pub struct Nep141Transfer<'a> { /// Sender's account ID. pub sender_id: &'a AccountId, @@ -58,6 +59,7 @@ impl<'a> Nep141Transfer<'a> { /// Describes a mint operation. #[derive(Clone, Debug, Serialize, BorshSerialize, PartialEq, Eq)] +#[serde(crate = "near_sdk::serde")] pub struct Nep141Mint<'a> { /// Amount to mint. pub amount: u128, @@ -69,6 +71,7 @@ pub struct Nep141Mint<'a> { /// Describes a burn operation. #[derive(Clone, Debug, Serialize, BorshSerialize, PartialEq, Eq)] +#[serde(crate = "near_sdk::serde")] pub struct Nep141Burn<'a> { /// Amount to burn. pub amount: u128, diff --git a/src/standard/nep145/mod.rs b/src/standard/nep145/mod.rs index b095c61..4e7a117 100644 --- a/src/standard/nep145/mod.rs +++ b/src/standard/nep145/mod.rs @@ -72,6 +72,7 @@ enum StorageKey<'a> { /// Describes a force unregister action. #[derive(Clone, Debug, Serialize, BorshSerialize, PartialEq, Eq)] +#[serde(crate = "near_sdk::serde")] pub struct Nep145ForceUnregister<'a> { /// The account to be unregistered. pub account_id: &'a AccountId, diff --git a/src/standard/nep148.rs b/src/standard/nep148.rs index ebcebc8..4b38c53 100644 --- a/src/standard/nep148.rs +++ b/src/standard/nep148.rs @@ -5,9 +5,9 @@ use near_sdk::{ borsh::{self, BorshDeserialize, BorshSerialize}, env, json_types::Base64VecU8, + serde::{Deserialize, Serialize}, BorshStorageKey, }; -use serde::{Deserialize, Serialize}; use crate::{slot::Slot, DefaultStorageKey}; @@ -20,6 +20,7 @@ pub const ERR_METADATA_UNSET: &str = "NEP-148 metadata is not set"; /// NEP-148-compatible metadata struct #[derive(BorshDeserialize, BorshSerialize, Deserialize, Serialize, Eq, PartialEq, Clone, Debug)] +#[serde(crate = "near_sdk::serde")] pub struct FungibleTokenMetadata { /// Version of the NEP-148 spec pub spec: String, diff --git a/src/standard/nep171/action.rs b/src/standard/nep171/action.rs index 5d81240..d302fff 100644 --- a/src/standard/nep171/action.rs +++ b/src/standard/nep171/action.rs @@ -11,6 +11,7 @@ use near_sdk::{ /// NEP-171 mint action. #[derive(Clone, Debug, Serialize, BorshSerialize, PartialEq, Eq)] +#[serde(crate = "near_sdk::serde")] pub struct Nep171Mint<'a> { /// Token IDs to mint. pub token_ids: &'a [TokenId], @@ -22,6 +23,7 @@ pub struct Nep171Mint<'a> { /// NEP-171 burn action. #[derive(Clone, Debug, Serialize, BorshSerialize, PartialEq, Eq)] +#[serde(crate = "near_sdk::serde")] pub struct Nep171Burn<'a> { /// Token IDs to burn. pub token_ids: &'a [TokenId], @@ -34,6 +36,7 @@ pub struct Nep171Burn<'a> { /// Transfer metadata generic over both types of transfer (`nft_transfer` and /// `nft_transfer_call`). #[derive(Serialize, BorshSerialize, PartialEq, Eq, Clone, Debug, Hash)] +#[serde(crate = "near_sdk::serde")] pub struct Nep171Transfer<'a> { /// Why is this sender allowed to perform this transfer? pub authorization: Nep171TransferAuthorization, diff --git a/src/standard/nep171/event.rs b/src/standard/nep171/event.rs index 66179a2..ee6cd35 100644 --- a/src/standard/nep171/event.rs +++ b/src/standard/nep171/event.rs @@ -6,8 +6,7 @@ use near_sdk_contract_tools_macros::event; /// NEP-171 standard events. #[event( crate = "crate", - macros = "crate", - serde = "serde", + macros = "near_sdk_contract_tools_macros", standard = "nep171", version = "1.2.0" )] @@ -27,6 +26,7 @@ pub enum Nep171Event { /// Tokens minted to a single owner. #[derive(Serialize, Debug, Clone)] +#[serde(crate = "near_sdk::serde")] pub struct NftMintLog { /// To whom were the new tokens minted? pub owner_id: AccountId, @@ -39,6 +39,7 @@ pub struct NftMintLog { /// Tokens are transferred from one account to another. #[derive(Serialize, Debug, Clone)] +#[serde(crate = "near_sdk::serde")] pub struct NftTransferLog { /// NEP-178 authorized account ID. #[serde(skip_serializing_if = "Option::is_none")] @@ -56,6 +57,7 @@ pub struct NftTransferLog { /// Tokens are burned from a single holder. #[derive(Serialize, Debug, Clone)] +#[serde(crate = "near_sdk::serde")] pub struct NftBurnLog { /// What is the ID of the account from which the tokens were burned? pub owner_id: AccountId, @@ -71,6 +73,7 @@ pub struct NftBurnLog { /// Token metadata update. #[derive(Serialize, Debug, Clone)] +#[serde(crate = "near_sdk::serde")] pub struct NftMetadataUpdateLog { /// IDs of the updated tokens. pub token_ids: Vec, @@ -81,6 +84,7 @@ pub struct NftMetadataUpdateLog { /// Contract metadata update. #[derive(Serialize, Debug, Clone)] +#[serde(crate = "near_sdk::serde")] pub struct NftContractMetadataUpdateLog { /// Additional update information. #[serde(skip_serializing_if = "Option::is_none")] diff --git a/src/standard/nep171/mod.rs b/src/standard/nep171/mod.rs index b23d8ad..5a15179 100644 --- a/src/standard/nep171/mod.rs +++ b/src/standard/nep171/mod.rs @@ -181,6 +181,7 @@ pub trait Nep171Controller { /// Authorization for a transfer. #[derive(Serialize, BorshSerialize, PartialEq, Eq, Clone, Debug, Hash)] +#[serde(crate = "near_sdk::serde")] pub enum Nep171TransferAuthorization { /// The sender is the owner of the token. Owner, @@ -389,6 +390,7 @@ impl Nep171Controller for T { /// Token information structure. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[serde(crate = "near_sdk::serde")] pub struct Token { /// Token ID. pub token_id: TokenId, diff --git a/src/standard/nep178/action.rs b/src/standard/nep178/action.rs index e3e3ff2..2de869c 100644 --- a/src/standard/nep178/action.rs +++ b/src/standard/nep178/action.rs @@ -11,6 +11,7 @@ use near_sdk::{ /// NEP-178 approve action. #[derive(Clone, Debug, Serialize, BorshSerialize, PartialEq, Eq)] +#[serde(crate = "near_sdk::serde")] pub struct Nep178Approve<'a> { /// Token ID that the target account is being approved for. pub token_id: &'a TokenId, @@ -23,6 +24,7 @@ pub struct Nep178Approve<'a> { /// NEP-178 revoke action. #[derive(Clone, Debug, Serialize, BorshSerialize, PartialEq, Eq)] +#[serde(crate = "near_sdk::serde")] pub struct Nep178Revoke<'a> { /// Token ID that the target account will no longer be able to transfer /// (approval revoked). @@ -36,6 +38,7 @@ pub struct Nep178Revoke<'a> { /// NEP-178 revoke all action. #[derive(Clone, Debug, Serialize, BorshSerialize, PartialEq, Eq)] +#[serde(crate = "near_sdk::serde")] pub struct Nep178RevokeAll<'a> { /// Token ID that all approvals will be revoked from. pub token_id: &'a TokenId, diff --git a/src/standard/nep297.rs b/src/standard/nep297.rs index 79b2e06..572aa4c 100644 --- a/src/standard/nep297.rs +++ b/src/standard/nep297.rs @@ -1,6 +1,6 @@ //! Helpers for `#[derive(near_sdk_contract_tools::Nep297)]` -use near_sdk::serde::Serialize; +use near_sdk::{serde::Serialize, serde_json}; /// Emit events according to the [NEP-297 event standard](https://nomicon.io/Standards/EventsFormat). /// @@ -72,6 +72,7 @@ pub trait ToEventLog { /// NEP-297 Event Log Data /// #[derive(Serialize, Clone, Debug)] +#[serde(crate = "near_sdk::serde")] pub struct EventLog { /// Name of the event standard, e.g. "nep171" pub standard: &'static str, diff --git a/tests/macros/event.rs b/tests/macros/event.rs index f2ff513..b408ab7 100644 --- a/tests/macros/event.rs +++ b/tests/macros/event.rs @@ -3,16 +3,18 @@ use near_sdk_contract_tools::standard::nep297::{Event, ToEventLog}; use crate::macros::event::test_events::Nep171NftMintData; mod test_events { + use near_sdk::serde::Serialize; use near_sdk_contract_tools::Nep297; - use serde::Serialize; #[derive(Serialize)] + #[serde(crate = "near_sdk::serde")] pub struct Nep171NftMintData { pub owner_id: String, pub token_ids: Vec, } #[derive(Nep297, Serialize)] + #[serde(crate = "near_sdk::serde")] // Required fields #[nep297(standard = "nep171", version = "1.0.0")] // Optional. Default event name is the untransformed variant name, e.g. NftMint, AnotherEvent, CustomEvent @@ -20,14 +22,17 @@ mod test_events { pub struct NftMint(pub Vec); // Name will be "nft_mint" because rename = snake_case #[derive(Nep297, Serialize)] + #[serde(crate = "near_sdk::serde")] #[nep297(standard = "nep171", version = "1.0.0", name = "sneaky_event")] pub struct AnotherEvent; // Name will be "sneaky_event" #[derive(Nep297, Serialize)] + #[serde(crate = "near_sdk::serde")] #[nep297(standard = "nep171", version = "1.0.0", rename = "SHOUTY-KEBAB-CASE")] pub struct CustomEvent; // Name will be "CUSTOM-EVENT" #[derive(Nep297, Serialize)] + #[serde(crate = "near_sdk::serde")] #[nep297(standard = "enum-event", version = "1.0.0")] #[allow(clippy::enum_variant_names)] pub enum EnumEvent { @@ -45,6 +50,7 @@ mod test_events { } #[derive(Nep297, Serialize)] + #[serde(crate = "near_sdk::serde")] #[nep297(standard = "enum-event", version = "1.0.0", rename_all = "snake_case")] #[allow(clippy::enum_variant_names)] pub enum EnumEventRenameAll { diff --git a/tests/macros/mod.rs b/tests/macros/mod.rs index af229ee..48c9303 100644 --- a/tests/macros/mod.rs +++ b/tests/macros/mod.rs @@ -22,11 +22,11 @@ mod pause; mod standard; mod my_event { - use near_sdk::AccountId; + use near_sdk::{serde::Serialize, AccountId}; use near_sdk_contract_tools::Nep297; - use serde::Serialize; #[derive(Serialize, Nep297)] + #[serde(crate = "near_sdk::serde")] #[nep297(standard = "x-myevent", version = "1.0.0", rename = "snake_case")] pub struct ValueChanged { pub from: u32, @@ -34,6 +34,7 @@ mod my_event { } #[derive(Serialize, Nep297)] + #[serde(crate = "near_sdk::serde")] #[nep297(standard = "x-myevent", version = "1.0.0", rename = "snake_case")] pub struct PermissionGranted { pub to: AccountId, diff --git a/workspaces-tests/Cargo.toml b/workspaces-tests/Cargo.toml index 3bc1ecd..2b338cf 100644 --- a/workspaces-tests/Cargo.toml +++ b/workspaces-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] autobins = false -edition = "2021" +edition.workspace = true name = "workspaces-tests" publish = false version = "0.1.0" @@ -65,15 +65,15 @@ name = "upgrade_old_raw" [dependencies] near-sdk.workspace = true near-sdk-contract-tools = { path = "../", features = ["unstable"] } -strum = "0.24.1" -strum_macros = "0.24.3" +strum.workspace = true +strum_macros.workspace = true thiserror.workspace = true [dev-dependencies] -near-crypto = "0.15.0" -tokio = "1.21.1" +near-crypto.workspace = true +tokio.workspace = true pretty_assertions.workspace = true [target.'cfg(not(windows))'.dev-dependencies] -near-workspaces = "0.8" +near-workspaces.workspace = true workspaces-tests-utils = { path = "../workspaces-tests-utils" } diff --git a/workspaces-tests/Makefile.toml b/workspaces-tests/Makefile.toml index 98919a8..0691b41 100644 --- a/workspaces-tests/Makefile.toml +++ b/workspaces-tests/Makefile.toml @@ -15,6 +15,22 @@ set -e if [[ -n $1 ]]; then cargo test --package workspaces-tests --test "$1" "$2" -- --nocapture else - cargo test + cargo test --package workspaces-tests -- --nocapture +fi +""" + +[tasks.nextest] +clear = true +dependencies = ["build"] +script = """ +#!/usr/bin/env bash +set -e + +if [[ -n $2 ]]; then + cargo nextest run --package workspaces-tests --test "$1" -E "test($2)" +elif [[ -n $1 ]]; then + cargo nextest run --package workspaces-tests --test "$1" +else + cargo nextest run --package workspaces-tests fi """