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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ homepage = "https://github.com/aurora-is-near/near-plugins"
keywords = ["near", "smart contract", "plugin"]

[workspace.dependencies]
bitflags = "1.3"
near-sdk = "4.0.0"
near-plugins-derive = { path = "near-plugins-derive" }
serde = "1"
Expand Down
4 changes: 3 additions & 1 deletion near-plugins-derive/src/access_control_role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
//! The last property aims to facilitate migrations which add or remove enum
//! variants.

use crate::utils::cratename;
use proc_macro::TokenStream;
use proc_macro2::{Ident, Span};
use quote::quote;
Expand All @@ -51,6 +52,7 @@ const DEFAULT_BOUNDCHECKER_TYPE_NAME: &str = "__AclBoundchecker";

pub fn derive_access_control_role(input: TokenStream) -> TokenStream {
// This derive doesn't take attributes, so no need to use `darling`.
let cratename = cratename();
let input: ItemEnum = parse_macro_input!(input);
let ItemEnum {
ident, variants, ..
Expand Down Expand Up @@ -175,7 +177,7 @@ pub fn derive_access_control_role(input: TokenStream) -> TokenStream {
}
}

::bitflags::bitflags! {
::#cratename::bitflags::bitflags! {
/// Encodes permissions for roles and admins.
#[derive(BorshDeserialize, BorshSerialize, Default)]
struct #bitflags_type_ident: u128 {
Expand Down
1 change: 1 addition & 0 deletions near-plugins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ version.workspace = true
crate-type = ["cdylib", "rlib"]

[dependencies]
bitflags.workspace = true
near-sdk.workspace = true
near-plugins-derive.workspace = true
serde.workspace = true
Expand Down
12 changes: 12 additions & 0 deletions near-plugins/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,15 @@ pub use near_plugins_derive::{
pub use ownable::Ownable;
pub use pausable::Pausable;
pub use upgradable::Upgradable;

// Re-exporting these dependencies avoids requiring contracts to depend on them.
// For example, without re-exporting `bitflags` a contract using the access
// control plugin would require:
//
// ```toml
// # Cargo.toml
// [dependencies]
// bitflags = "x.y"
// ```
#[doc(hidden)]
pub use bitflags;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ edition = "2018"
crate-type = ["cdylib", "rlib"]

[dependencies]
bitflags = "1.3"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer need to ask contract developers to do this.

near-plugins = { path = "../../../../near-plugins" }
near-sdk = "4.0.0"

Expand Down