Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/target
Cargo.lock
near-plugins/tests/contracts/*/target
near-plugins-derive/tests/contracts/*/target
examples/target

# Ignore IDE data
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down Expand Up @@ -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).

Expand All @@ -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).

Expand All @@ -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).

Expand All @@ -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/<plugin_name>/`.
- This contract is used in `near-plugins/tests/<plugin_name>.rs` which:
- 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/).
- Sends transactions to the deployed contract to verify plugin functionality.

Expand Down
9 changes: 9 additions & 0 deletions near-plugins-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
File renamed without changes.
File renamed without changes.
7 changes: 0 additions & 7 deletions near-plugins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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