diff --git a/.gitignore b/.gitignore index fabb587..59fb25e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ /target Cargo.lock -near-plugins/tests/contracts/*/target +near-plugins-derive/tests/contracts/*/target examples/target # Ignore IDE data diff --git a/Cargo.toml b/Cargo.toml index 4d961bb..61feeb5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ keywords = ["near", "smart contract", "plugin"] [workspace.dependencies] bitflags = "1.3" near-sdk = "4.1.0" +near-plugins = { path = "near-plugins" } near-plugins-derive = { path = "near-plugins-derive" } serde = "1" anyhow = "1.0" diff --git a/README.md b/README.md index b1085c7..dca36bd 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,13 @@ are also described in the [source code](/near-plugins-derive/src/) of each macro The following sections provide an overview of all available plugins. More examples and usage patterns are available in: - [`examples/`](/examples/) -- [`near-plugins/tests/contracts/`](/near-plugins/tests/contracts/) +- [`near-plugins-derive/tests/contracts/`](/near-plugins-derive/tests/contracts/) ### [Ownable](/near-plugins/src/ownable.rs) Basic access control mechanism that allows _only_ an authorized account id to call certain methods. Note this account id can belong either to a regular user, or it could be a contract (a DAO for example). -[This contract](/near-plugins/tests/contracts/ownable/src/lib.rs) provides an example of using `Ownable`. It is compiled, deployed on chain and interacted with in [integration tests](/near-plugins/tests/ownable.rs). +[This contract](/near-plugins-derive/tests/contracts/ownable/src/lib.rs) provides an example of using `Ownable`. It is compiled, deployed on chain and interacted with in [integration tests](/near-plugins-derive/tests/ownable.rs). Documentation of all methods provided by the derived implementation of `Ownable` is available in the [definition of the trait](/near-plugins/src/ownable.rs). @@ -55,7 +55,7 @@ used granularly to only limit certain features. Using the `Pausable` plugin requires the contract to be _AccessControllable_ in order to manage permissions. Roles allowing accounts to call certain methods can be granted and revoked via the _AccessControllable_ plugin. -[This contract](/near-plugins/tests/contracts/pausable/src/lib.rs) provides an example of using `Pausable`. It is compiled, deployed on chain and interacted with in [integration tests](/near-plugins/tests/pausable.rs). +[This contract](/near-plugins-derive/tests/contracts/pausable/src/lib.rs) provides an example of using `Pausable`. It is compiled, deployed on chain and interacted with in [integration tests](/near-plugins-derive/tests/pausable.rs). Documentation of all methods provided by `Pausable` is available in the [definition of the trait](/near-plugins/src/pausable.rs). @@ -69,7 +69,7 @@ To upgrade the contract first call `up_stage_code` passing the binary as first a To set a staging duration, call `up_stage_init_staging_duration`. After initialization the staging duration can be updated by calling `up_stage_update_staging_duration` followed by `up_apply_update_staging_duration`. Updating the staging duration is itself subject to a delay: at least the currently set staging duration must pass before a staged update can be applied. The functions mentioned in this paragraph must be called by the owner of the contract. -[This contract](/near-plugins/tests/contracts/upgradable/src/lib.rs) provides an example of using `Upgradable`. It is compiled, deployed on chain and interacted with in [integration tests](/near-plugins/tests/upgradable.rs). +[This contract](/near-plugins-derive/tests/contracts/upgradable/src/lib.rs) provides an example of using `Upgradable`. It is compiled, deployed on chain and interacted with in [integration tests](/near-plugins-derive/tests/upgradable.rs). Documentation of all methods provided by `Upgradable` is available in the [definition of the trait](/near-plugins/src/upgradable.rs). @@ -79,7 +79,7 @@ Enables role-based access control for contract methods. A method with restricted Each role is managed by admins who may grant the role to accounts and revoke it from them. In addition, there are super admins that have admin permissions for every role. The sets of accounts that are (super) admins and grantees are stored in the contract's state. -[This contract](/near-plugins/tests/contracts/access_controllable/src/lib.rs) provides an example of using `AccessControllable`. It is compiled, deployed on chain and interacted with in [integration tests](/near-plugins/tests/access_controllable.rs). +[This contract](/near-plugins-derive/tests/contracts/access_controllable/src/lib.rs) provides an example of using `AccessControllable`. It is compiled, deployed on chain and interacted with in [integration tests](/near-plugins-derive/tests/access_controllable.rs). Documentation of all methods provided by `AccessControllable` is available in the [definition of the trait](/near-plugins/src/access_controllable.rs). @@ -93,8 +93,8 @@ The code that is generated for a trait implementation is based on `near-plugins- Tests should verify that once the macros provided by this crate are expanded, the contract they are used in has the intended functionality. Integration tests are utilized for that purpose: -- A contract using the plugin is contained in `near-plugins/tests/contracts//`. -- This contract is used in `near-plugins/tests/.rs` which: +- 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/). - Sends transactions to the deployed contract to verify plugin functionality. diff --git a/near-plugins-derive/Cargo.toml b/near-plugins-derive/Cargo.toml index aeee324..74d99b5 100644 --- a/near-plugins-derive/Cargo.toml +++ b/near-plugins-derive/Cargo.toml @@ -14,3 +14,12 @@ proc-macro2.workspace = true quote.workspace = true syn.workspace = true proc-macro-crate.workspace = true + +[dev-dependencies] +anyhow.workspace = true +borsh.workspace = true +near-plugins.workspace = true +near-sdk.workspace = true +tokio.workspace = true +workspaces.workspace = true +toml.workspace = true diff --git a/near-plugins/tests/access_controllable.rs b/near-plugins-derive/tests/access_controllable.rs similarity index 100% rename from near-plugins/tests/access_controllable.rs rename to near-plugins-derive/tests/access_controllable.rs diff --git a/near-plugins/tests/common/access_controllable_contract.rs b/near-plugins-derive/tests/common/access_controllable_contract.rs similarity index 100% rename from near-plugins/tests/common/access_controllable_contract.rs rename to near-plugins-derive/tests/common/access_controllable_contract.rs diff --git a/near-plugins/tests/common/full_access_key_fallback_contract.rs b/near-plugins-derive/tests/common/full_access_key_fallback_contract.rs similarity index 100% rename from near-plugins/tests/common/full_access_key_fallback_contract.rs rename to near-plugins-derive/tests/common/full_access_key_fallback_contract.rs diff --git a/near-plugins/tests/common/mod.rs b/near-plugins-derive/tests/common/mod.rs similarity index 100% rename from near-plugins/tests/common/mod.rs rename to near-plugins-derive/tests/common/mod.rs diff --git a/near-plugins/tests/common/ownable_contract.rs b/near-plugins-derive/tests/common/ownable_contract.rs similarity index 100% rename from near-plugins/tests/common/ownable_contract.rs rename to near-plugins-derive/tests/common/ownable_contract.rs diff --git a/near-plugins/tests/common/pausable_contract.rs b/near-plugins-derive/tests/common/pausable_contract.rs similarity index 100% rename from near-plugins/tests/common/pausable_contract.rs rename to near-plugins-derive/tests/common/pausable_contract.rs diff --git a/near-plugins/tests/common/repo.rs b/near-plugins-derive/tests/common/repo.rs similarity index 100% rename from near-plugins/tests/common/repo.rs rename to near-plugins-derive/tests/common/repo.rs diff --git a/near-plugins/tests/common/upgradable_contract.rs b/near-plugins-derive/tests/common/upgradable_contract.rs similarity index 100% rename from near-plugins/tests/common/upgradable_contract.rs rename to near-plugins-derive/tests/common/upgradable_contract.rs diff --git a/near-plugins/tests/common/utils.rs b/near-plugins-derive/tests/common/utils.rs similarity index 100% rename from near-plugins/tests/common/utils.rs rename to near-plugins-derive/tests/common/utils.rs diff --git a/near-plugins/tests/contracts/README.md b/near-plugins-derive/tests/contracts/README.md similarity index 100% rename from near-plugins/tests/contracts/README.md rename to near-plugins-derive/tests/contracts/README.md diff --git a/near-plugins/tests/contracts/access_controllable/Cargo.toml b/near-plugins-derive/tests/contracts/access_controllable/Cargo.toml similarity index 100% rename from near-plugins/tests/contracts/access_controllable/Cargo.toml rename to near-plugins-derive/tests/contracts/access_controllable/Cargo.toml diff --git a/near-plugins/tests/contracts/access_controllable/Makefile b/near-plugins-derive/tests/contracts/access_controllable/Makefile similarity index 100% rename from near-plugins/tests/contracts/access_controllable/Makefile rename to near-plugins-derive/tests/contracts/access_controllable/Makefile diff --git a/near-plugins/tests/contracts/access_controllable/rust-toolchain b/near-plugins-derive/tests/contracts/access_controllable/rust-toolchain similarity index 100% rename from near-plugins/tests/contracts/access_controllable/rust-toolchain rename to near-plugins-derive/tests/contracts/access_controllable/rust-toolchain diff --git a/near-plugins/tests/contracts/access_controllable/src/lib.rs b/near-plugins-derive/tests/contracts/access_controllable/src/lib.rs similarity index 100% rename from near-plugins/tests/contracts/access_controllable/src/lib.rs rename to near-plugins-derive/tests/contracts/access_controllable/src/lib.rs diff --git a/near-plugins/tests/contracts/full_access_key_fallback/Cargo.toml b/near-plugins-derive/tests/contracts/full_access_key_fallback/Cargo.toml similarity index 100% rename from near-plugins/tests/contracts/full_access_key_fallback/Cargo.toml rename to near-plugins-derive/tests/contracts/full_access_key_fallback/Cargo.toml diff --git a/near-plugins/tests/contracts/full_access_key_fallback/Makefile b/near-plugins-derive/tests/contracts/full_access_key_fallback/Makefile similarity index 100% rename from near-plugins/tests/contracts/full_access_key_fallback/Makefile rename to near-plugins-derive/tests/contracts/full_access_key_fallback/Makefile diff --git a/near-plugins/tests/contracts/full_access_key_fallback/rust-toolchain b/near-plugins-derive/tests/contracts/full_access_key_fallback/rust-toolchain similarity index 100% rename from near-plugins/tests/contracts/full_access_key_fallback/rust-toolchain rename to near-plugins-derive/tests/contracts/full_access_key_fallback/rust-toolchain diff --git a/near-plugins/tests/contracts/full_access_key_fallback/src/lib.rs b/near-plugins-derive/tests/contracts/full_access_key_fallback/src/lib.rs similarity index 100% rename from near-plugins/tests/contracts/full_access_key_fallback/src/lib.rs rename to near-plugins-derive/tests/contracts/full_access_key_fallback/src/lib.rs diff --git a/near-plugins/tests/contracts/ownable/Cargo.toml b/near-plugins-derive/tests/contracts/ownable/Cargo.toml similarity index 100% rename from near-plugins/tests/contracts/ownable/Cargo.toml rename to near-plugins-derive/tests/contracts/ownable/Cargo.toml diff --git a/near-plugins/tests/contracts/ownable/Makefile b/near-plugins-derive/tests/contracts/ownable/Makefile similarity index 100% rename from near-plugins/tests/contracts/ownable/Makefile rename to near-plugins-derive/tests/contracts/ownable/Makefile diff --git a/near-plugins/tests/contracts/ownable/rust-toolchain b/near-plugins-derive/tests/contracts/ownable/rust-toolchain similarity index 100% rename from near-plugins/tests/contracts/ownable/rust-toolchain rename to near-plugins-derive/tests/contracts/ownable/rust-toolchain diff --git a/near-plugins/tests/contracts/ownable/src/lib.rs b/near-plugins-derive/tests/contracts/ownable/src/lib.rs similarity index 100% rename from near-plugins/tests/contracts/ownable/src/lib.rs rename to near-plugins-derive/tests/contracts/ownable/src/lib.rs diff --git a/near-plugins/tests/contracts/pausable/Cargo.toml b/near-plugins-derive/tests/contracts/pausable/Cargo.toml similarity index 100% rename from near-plugins/tests/contracts/pausable/Cargo.toml rename to near-plugins-derive/tests/contracts/pausable/Cargo.toml diff --git a/near-plugins/tests/contracts/pausable/Makefile b/near-plugins-derive/tests/contracts/pausable/Makefile similarity index 100% rename from near-plugins/tests/contracts/pausable/Makefile rename to near-plugins-derive/tests/contracts/pausable/Makefile diff --git a/near-plugins/tests/contracts/pausable/rust-toolchain b/near-plugins-derive/tests/contracts/pausable/rust-toolchain similarity index 100% rename from near-plugins/tests/contracts/pausable/rust-toolchain rename to near-plugins-derive/tests/contracts/pausable/rust-toolchain diff --git a/near-plugins/tests/contracts/pausable/src/lib.rs b/near-plugins-derive/tests/contracts/pausable/src/lib.rs similarity index 100% rename from near-plugins/tests/contracts/pausable/src/lib.rs rename to near-plugins-derive/tests/contracts/pausable/src/lib.rs diff --git a/near-plugins/tests/contracts/upgradable/Cargo.toml b/near-plugins-derive/tests/contracts/upgradable/Cargo.toml similarity index 100% rename from near-plugins/tests/contracts/upgradable/Cargo.toml rename to near-plugins-derive/tests/contracts/upgradable/Cargo.toml diff --git a/near-plugins/tests/contracts/upgradable/Makefile b/near-plugins-derive/tests/contracts/upgradable/Makefile similarity index 100% rename from near-plugins/tests/contracts/upgradable/Makefile rename to near-plugins-derive/tests/contracts/upgradable/Makefile diff --git a/near-plugins/tests/contracts/upgradable/rust-toolchain b/near-plugins-derive/tests/contracts/upgradable/rust-toolchain similarity index 100% rename from near-plugins/tests/contracts/upgradable/rust-toolchain rename to near-plugins-derive/tests/contracts/upgradable/rust-toolchain diff --git a/near-plugins/tests/contracts/upgradable/src/lib.rs b/near-plugins-derive/tests/contracts/upgradable/src/lib.rs similarity index 100% rename from near-plugins/tests/contracts/upgradable/src/lib.rs rename to near-plugins-derive/tests/contracts/upgradable/src/lib.rs diff --git a/near-plugins/tests/full_access_key_fallback.rs b/near-plugins-derive/tests/full_access_key_fallback.rs similarity index 99% rename from near-plugins/tests/full_access_key_fallback.rs rename to near-plugins-derive/tests/full_access_key_fallback.rs index 71bc8d2..5595448 100644 --- a/near-plugins/tests/full_access_key_fallback.rs +++ b/near-plugins-derive/tests/full_access_key_fallback.rs @@ -30,6 +30,7 @@ fn pk_sdk_to_workspaces(public_key: near_sdk::PublicKey) -> PublicKey { // Going via json since there seems to be no direct conversion, see this issue: // https://github.com/near/workspaces-rs/issues/262 #[derive(Deserialize)] + #[serde(crate = "near_sdk::serde")] struct Wrapper { public_key: PublicKey, } diff --git a/near-plugins/tests/ownable.rs b/near-plugins-derive/tests/ownable.rs similarity index 100% rename from near-plugins/tests/ownable.rs rename to near-plugins-derive/tests/ownable.rs diff --git a/near-plugins/tests/pausable.rs b/near-plugins-derive/tests/pausable.rs similarity index 100% rename from near-plugins/tests/pausable.rs rename to near-plugins-derive/tests/pausable.rs diff --git a/near-plugins/tests/upgradable.rs b/near-plugins-derive/tests/upgradable.rs similarity index 100% rename from near-plugins/tests/upgradable.rs rename to near-plugins-derive/tests/upgradable.rs diff --git a/near-plugins/Cargo.toml b/near-plugins/Cargo.toml index fec73c0..f28d8fa 100644 --- a/near-plugins/Cargo.toml +++ b/near-plugins/Cargo.toml @@ -13,10 +13,3 @@ bitflags.workspace = true near-sdk.workspace = true near-plugins-derive.workspace = true serde.workspace = true - -[dev-dependencies] -anyhow.workspace = true -borsh.workspace = true -tokio.workspace = true -workspaces.workspace = true -toml.workspace = true