-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6814d0b
commit 44c6491
Showing
6 changed files
with
393 additions
and
4 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
...ests/snapshots/openzeppelin_macros__tests__test_with_components__with_access_control.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
source: src/tests/test_with_components.rs | ||
expression: result | ||
snapshot_kind: text | ||
--- | ||
TokenStream: | ||
|
||
#[starknet::contract] | ||
pub mod Contract { | ||
use openzeppelin_access::accesscontrol::DEFAULT_ADMIN_ROLE; | ||
use starknet::ContractAddress; | ||
|
||
#[storage] | ||
pub struct Storage { | ||
#[substorage(v0)] | ||
accesscontrol: AccessControlComponent::Storage, | ||
} | ||
|
||
#[constructor] | ||
fn constructor(ref self: ContractState, default_admin: ContractAddress) { | ||
self.accesscontrol.initializer(); | ||
|
||
self.accesscontrol._grant_role(DEFAULT_ADMIN_ROLE, default_admin); | ||
} | ||
|
||
use openzeppelin_access::accesscontrol::AccessControlComponent; | ||
|
||
component!(path: AccessControlComponent, storage: accesscontrol, event: AccessControlEvent); | ||
|
||
impl AccessControlInternalImpl = AccessControlComponent::InternalImpl<ContractState>; | ||
|
||
#[event] | ||
#[derive(Drop, starknet::Event)] | ||
enum Event { | ||
#[flat] | ||
AccessControlEvent: AccessControlComponent::Event, | ||
} | ||
} | ||
|
||
|
||
Diagnostics: | ||
|
||
None | ||
|
||
AuxData: | ||
|
||
None |
49 changes: 49 additions & 0 deletions
49
...openzeppelin_macros__tests__test_with_components__with_access_control_no_initializer.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
source: src/tests/test_with_components.rs | ||
expression: result | ||
snapshot_kind: text | ||
--- | ||
TokenStream: | ||
|
||
#[starknet::contract] | ||
pub mod Contract { | ||
use openzeppelin_access::accesscontrol::DEFAULT_ADMIN_ROLE; | ||
use starknet::ContractAddress; | ||
|
||
#[storage] | ||
pub struct Storage { | ||
#[substorage(v0)] | ||
accesscontrol: AccessControlComponent::Storage, | ||
} | ||
|
||
#[constructor] | ||
fn constructor(ref self: ContractState) {} | ||
|
||
use openzeppelin_access::accesscontrol::AccessControlComponent; | ||
|
||
component!(path: AccessControlComponent, storage: accesscontrol, event: AccessControlEvent); | ||
|
||
impl AccessControlInternalImpl = AccessControlComponent::InternalImpl<ContractState>; | ||
|
||
#[event] | ||
#[derive(Drop, starknet::Event)] | ||
enum Event { | ||
#[flat] | ||
AccessControlEvent: AccessControlComponent::Event, | ||
} | ||
} | ||
|
||
|
||
Diagnostics: | ||
|
||
==== | ||
Warning: It looks like the initilizers for the following components are missing: | ||
|
||
AccessControl | ||
|
||
This may lead to unexpected behavior. We recommend adding the corresponding initializer calls to the constructor. | ||
==== | ||
|
||
AuxData: | ||
|
||
None |
59 changes: 59 additions & 0 deletions
59
...s/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_vesting.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
source: src/tests/test_with_components.rs | ||
expression: result | ||
snapshot_kind: text | ||
--- | ||
TokenStream: | ||
|
||
#[starknet::contract] | ||
pub mod VestingWallet { | ||
use openzeppelin_finance::vesting::LinearVestingSchedule; | ||
use starknet::ContractAddress; | ||
|
||
#[storage] | ||
pub struct Storage { | ||
#[substorage(v0)] | ||
vesting: VestingComponent::Storage, | ||
#[substorage(v0)] | ||
ownable: OwnableComponent::Storage, | ||
} | ||
|
||
#[constructor] | ||
fn constructor( | ||
ref self: ContractState, | ||
beneficiary: ContractAddress, | ||
start: u64, | ||
duration: u64, | ||
cliff_duration: u64, | ||
) { | ||
self.ownable.initializer(beneficiary); | ||
self.vesting.initializer(start, duration, cliff_duration); | ||
} | ||
|
||
use openzeppelin_finance::vesting::VestingComponent; | ||
use openzeppelin_access::ownable::OwnableComponent; | ||
|
||
component!(path: VestingComponent, storage: vesting, event: VestingEvent); | ||
component!(path: OwnableComponent, storage: ownable, event: OwnableEvent); | ||
|
||
impl VestingInternalImpl = VestingComponent::InternalImpl<ContractState>; | ||
impl OwnableInternalImpl = OwnableComponent::InternalImpl<ContractState>; | ||
|
||
#[event] | ||
#[derive(Drop, starknet::Event)] | ||
enum Event { | ||
#[flat] | ||
VestingEvent: VestingComponent::Event, | ||
#[flat] | ||
OwnableEvent: OwnableComponent::Event, | ||
} | ||
} | ||
|
||
|
||
Diagnostics: | ||
|
||
None | ||
|
||
AuxData: | ||
|
||
None |
64 changes: 64 additions & 0 deletions
64
...pshots/openzeppelin_macros__tests__test_with_components__with_vesting_no_initializer.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
source: src/tests/test_with_components.rs | ||
expression: result | ||
snapshot_kind: text | ||
--- | ||
TokenStream: | ||
|
||
#[starknet::contract] | ||
pub mod VestingWallet { | ||
use openzeppelin_finance::vesting::LinearVestingSchedule; | ||
use starknet::ContractAddress; | ||
|
||
#[storage] | ||
pub struct Storage { | ||
#[substorage(v0)] | ||
vesting: VestingComponent::Storage, | ||
#[substorage(v0)] | ||
ownable: OwnableComponent::Storage, | ||
} | ||
|
||
#[constructor] | ||
fn constructor( | ||
ref self: ContractState, | ||
beneficiary: ContractAddress, | ||
start: u64, | ||
duration: u64, | ||
cliff_duration: u64, | ||
) { | ||
self.ownable.initializer(beneficiary); | ||
} | ||
|
||
use openzeppelin_finance::vesting::VestingComponent; | ||
use openzeppelin_access::ownable::OwnableComponent; | ||
|
||
component!(path: VestingComponent, storage: vesting, event: VestingEvent); | ||
component!(path: OwnableComponent, storage: ownable, event: OwnableEvent); | ||
|
||
impl VestingInternalImpl = VestingComponent::InternalImpl<ContractState>; | ||
impl OwnableInternalImpl = OwnableComponent::InternalImpl<ContractState>; | ||
|
||
#[event] | ||
#[derive(Drop, starknet::Event)] | ||
enum Event { | ||
#[flat] | ||
VestingEvent: VestingComponent::Event, | ||
#[flat] | ||
OwnableEvent: OwnableComponent::Event, | ||
} | ||
} | ||
|
||
|
||
Diagnostics: | ||
|
||
==== | ||
Warning: It looks like the initilizers for the following components are missing: | ||
|
||
Vesting | ||
|
||
This may lead to unexpected behavior. We recommend adding the corresponding initializer calls to the constructor. | ||
==== | ||
|
||
AuxData: | ||
|
||
None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.