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

Migrate Account to component #783

Merged
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
331844d
fix: link (#545)
ericnordelo Jan 20, 2023
2e7758e
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts
ericnordelo Oct 6, 2023
77cca2d
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts
ericnordelo Oct 10, 2023
4fc9be5
feat: update logic
ericnordelo Oct 10, 2023
ce91ed0
feat: add mocks
ericnordelo Oct 10, 2023
4a90358
docs: update
ericnordelo Oct 11, 2023
7f74150
feat: update docs
ericnordelo Oct 11, 2023
bff9179
Update src/account/account.cairo
ericnordelo Oct 18, 2023
4415191
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts into f…
ericnordelo Oct 18, 2023
100c483
feat: apply review updates
ericnordelo Oct 18, 2023
b3e2106
Merge branch 'feat/migrate-account-to-component' of github.com:ericno…
ericnordelo Oct 18, 2023
0570e44
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts into f…
ericnordelo Oct 18, 2023
52df8b1
feat: update overview
ericnordelo Oct 18, 2023
9705ce7
Update docs/modules/ROOT/pages/api/account.adoc
ericnordelo Oct 23, 2023
feeac44
feat: apply review updates
ericnordelo Oct 23, 2023
0f64992
Merge branch 'feat/migrate-account-to-component' of github.com:ericno…
ericnordelo Oct 23, 2023
f9ce9eb
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts into f…
ericnordelo Oct 24, 2023
fcdcdf7
feat: flatten events
ericnordelo Oct 24, 2023
d12a610
feat: add account preset
ericnordelo Oct 25, 2023
66c3fd7
feat: apply review updates
ericnordelo Oct 30, 2023
daa9d68
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts into f…
ericnordelo Oct 30, 2023
495ff94
feat: apply review updates
ericnordelo Oct 30, 2023
472b04c
feat: remove preset
ericnordelo Oct 30, 2023
a83b810
feat: apply review updates
ericnordelo Oct 31, 2023
cc8d2f9
feat: rename components
ericnordelo Oct 31, 2023
296122f
feat: update docs
ericnordelo Oct 31, 2023
2e16eaa
fix: remove failing macro
ericnordelo Oct 31, 2023
d53d1c9
fix: imports in docs
ericnordelo Oct 31, 2023
265faa7
docs: update section title
ericnordelo Oct 31, 2023
c89e8b6
fix: missing title update
ericnordelo Oct 31, 2023
4eeafa9
feat: use get component macro
ericnordelo Nov 1, 2023
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
72 changes: 36 additions & 36 deletions docs/modules/ROOT/pages/access.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,29 @@ xref:/api/access.adoc#AccessControl-initializer[`initializer`] like this:
----
#[starknet::contract]
mod MyContract {
use openzeppelin::access::ownable::Ownable as ownable_component;
use openzeppelin::access::ownable::OwnableComponent;
use starknet::ContractAddress;

component!(path: ownable_component, storage: ownable, event: OwnableEvent);
component!(path: OwnableComponent, storage: ownable, event: OwnableEvent);

#[abi(embed_v0)]
impl OwnableImpl = ownable_component::OwnableImpl<ContractState>;
impl OwnableImpl = OwnableComponent::OwnableImpl<ContractState>;
#[abi(embed_v0)]
impl OwnableCamelOnlyImpl =
ownable_component::OwnableCamelOnlyImpl<ContractState>;
impl InternalImpl = ownable_component::InternalImpl<ContractState>;
OwnableComponent::OwnableCamelOnlyImpl<ContractState>;
impl InternalImpl = OwnableComponent::InternalImpl<ContractState>;

#[storage]
struct Storage {
#[substorage(v0)]
ownable: ownable_component::Storage
ownable: OwnableComponent::Storage
}

#[event]
#[derive(Drop, starknet::Event)]
enum Event {
#[flat]
OwnableEvent: ownable_component::Event
OwnableEvent: OwnableComponent::Event
}

#[constructor]
Expand Down Expand Up @@ -137,37 +137,37 @@ const MINTER_ROLE: felt252 = selector!("MINTER_ROLE");

#[starknet::contract]
mod MyContract {
use openzeppelin::access::accesscontrol::AccessControl as accesscontrol_component;
use openzeppelin::introspection::src5::SRC5 as src5_component;
use openzeppelin::access::accesscontrol::AccessControlComponent;
use openzeppelin::introspection::src5::SRC5Component;
use openzeppelin::token::erc20::ERC20;
use starknet::ContractAddress;
use super::MINTER_ROLE;

component!(path: accesscontrol_component, storage: accesscontrol, event: AccessControlEvent);
component!(path: src5_component, storage: src5, event: SRC5Event);
component!(path: AccessControlComponent, storage: accesscontrol, event: AccessControlEvent);
component!(path: SRC5Component, storage: src5, event: SRC5Event);

#[abi(embed_v0)]
impl AccessControlImpl =
accesscontrol_component::AccessControlImpl<ContractState>;
AccessControlComponent::AccessControlImpl<ContractState>;
#[abi(embed_v0)]
impl SRC5Impl = src5_component::SRC5Impl<ContractState>;
impl AccessControlInternalImpl = accesscontrol_component::InternalImpl<ContractState>;
impl SRC5Impl = SRC5Component::SRC5Impl<ContractState>;
impl AccessControlInternalImpl = AccessControlComponent::InternalImpl<ContractState>;

#[storage]
struct Storage {
#[substorage(v0)]
accesscontrol: accesscontrol_component::Storage,
accesscontrol: AccessControlComponent::Storage,
#[substorage(v0)]
src5: src5_component::Storage,
src5: SRC5Component::Storage,
}

#[event]
#[derive(Drop, starknet::Event)]
enum Event {
#[flat]
AccessControlEvent: accesscontrol_component::Event,
AccessControlEvent: AccessControlComponent::Event,
#[flat]
SRC5Event: src5_component::Event
SRC5Event: SRC5Component::Event
}

#[constructor]
Expand Down Expand Up @@ -216,37 +216,37 @@ const BURNER_ROLE: felt252 = selector!("BURNER_ROLE");

#[starknet::contract]
mod MyContract {
use openzeppelin::access::accesscontrol::AccessControl as accesscontrol_component;
use openzeppelin::introspection::src5::SRC5 as src5_component;
use openzeppelin::access::accesscontrol::AccessControlComponent;
use openzeppelin::introspection::src5::SRC5Component;
use openzeppelin::token::erc20::ERC20;
use starknet::ContractAddress;
use super::{MINTER_ROLE, BURNER_ROLE};

component!(path: accesscontrol_component, storage: accesscontrol, event: AccessControlEvent);
component!(path: src5_component, storage: src5, event: SRC5Event);
component!(path: AccessControlComponent, storage: accesscontrol, event: AccessControlEvent);
component!(path: SRC5Component, storage: src5, event: SRC5Event);

#[abi(embed_v0)]
impl AccessControlImpl =
accesscontrol_component::AccessControlImpl<ContractState>;
AccessControlComponent::AccessControlImpl<ContractState>;
#[abi(embed_v0)]
impl SRC5Impl = src5_component::SRC5Impl<ContractState>;
impl AccessControlInternalImpl = accesscontrol_component::InternalImpl<ContractState>;
impl SRC5Impl = SRC5Component::SRC5Impl<ContractState>;
impl AccessControlInternalImpl = AccessControlComponent::InternalImpl<ContractState>;

#[storage]
struct Storage {
#[substorage(v0)]
accesscontrol: accesscontrol_component::Storage,
accesscontrol: AccessControlComponent::Storage,
#[substorage(v0)]
src5: src5_component::Storage,
src5: SRC5Component::Storage,
}

#[event]
#[derive(Drop, starknet::Event)]
enum Event {
#[flat]
AccessControlEvent: accesscontrol_component::Event,
AccessControlEvent: AccessControlComponent::Event,
#[flat]
SRC5Event: src5_component::Event
SRC5Event: SRC5Component::Event
}

#[constructor]
Expand Down Expand Up @@ -328,22 +328,22 @@ const BURNER_ROLE: felt252 = selector!("BURNER_ROLE");

#[starknet::contract]
mod MyContract {
use openzeppelin::access::accesscontrol::AccessControl as accesscontrol_component;
use openzeppelin::access::accesscontrol::AccessControlComponent;
use openzeppelin::access::accesscontrol::DEFAULT_ADMIN_ROLE;
use openzeppelin::introspection::src5::SRC5 as src5_component;
use openzeppelin::introspection::src5::SRC5Component;
use openzeppelin::token::erc20::ERC20;
use starknet::ContractAddress;
use super::{MINTER_ROLE, BURNER_ROLE};

component!(path: accesscontrol_component, storage: accesscontrol, event: AccessControlEvent);
component!(path: src5_component, storage: src5, event: SRC5Event);
component!(path: AccessControlComponent, storage: accesscontrol, event: AccessControlEvent);
component!(path: SRC5Component, storage: src5, event: SRC5Event);

#[abi(embed_v0)]
impl AccessControlImpl =
accesscontrol_component::AccessControlImpl<ContractState>;
AccessControlComponent::AccessControlImpl<ContractState>;
#[abi(embed_v0)]
impl SRC5Impl = src5_component::SRC5Impl<ContractState>;
impl AccessControlInternalImpl = accesscontrol_component::InternalImpl<ContractState>;
impl SRC5Impl = SRC5Component::SRC5Impl<ContractState>;
impl AccessControlInternalImpl = AccessControlComponent::InternalImpl<ContractState>;

(...)

Expand Down
16 changes: 8 additions & 8 deletions docs/modules/ROOT/pages/api/access.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ assigned each to multiple accounts.
=== `++Ownable++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.8.0-beta.0/src/access/ownable/ownable.cairo[{github-icon},role=heading-link]

```javascript
use openzeppelin::access::ownable::Ownable;
use openzeppelin::access::ownable::OwnableComponent;
```

`Ownable` provides a basic access control mechanism where an account
Expand All @@ -30,7 +30,7 @@ use openzeppelin::access::ownable::Ownable;
This module includes the internal `assert_only_owner` to restrict a function to be used only by the owner.

[.contract-index]
.Embeddable Functions
.Embeddable Implementations
--
.OwnableImpl

Expand All @@ -40,7 +40,7 @@ This module includes the internal `assert_only_owner` to restrict a function to
--

[.contract-index]
.camelCase Support
.Embeddable Implementations (camelCase)
--
.OwnableCamelOnlyImpl

Expand All @@ -49,7 +49,7 @@ This module includes the internal `assert_only_owner` to restrict a function to
--

[.contract-index]
.Internal Functions
.Internal Implementations
--
.InternalImpl

Expand Down Expand Up @@ -284,7 +284,7 @@ Emitted when `account` is revoked `role`.
:revoke_role: xref:#AccessControl-revoke_role[revoke_role]

```javascript
use openzeppelin::access::accesscontrol::AccessControl;
use openzeppelin::access::accesscontrol::AccessControlComponent;
```

Component that allows contracts to implement role-based access control mechanisms.
Expand Down Expand Up @@ -322,7 +322,7 @@ grant and revoke this role. Extra precautions should be taken to secure
accounts that have been granted it.

[.contract-index]
.Embeddable Functions
.Embeddable Implementations
--
.AccessControlImpl

Expand All @@ -337,7 +337,7 @@ accounts that have been granted it.
--

[.contract-index]
.camelCase Support
.Embeddable Implementations (camelCase)
--
.AccessControlCamelImpl

Expand All @@ -349,7 +349,7 @@ accounts that have been granted it.
--

[.contract-index]
.Internal Functions
.Internal Implementations
--
.InternalImpl

Expand Down
Loading