Skip to content

Commit

Permalink
refactor: update comments regarding components (#596)
Browse files Browse the repository at this point in the history
  • Loading branch information
pscott authored Oct 10, 2023
1 parent cc1ef75 commit ca5528b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
21 changes: 14 additions & 7 deletions starknet/src/space/space.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ mod Space {
);

// Checking that the contract is not already initialized
//TODO: temporary component syntax
// Migration to components planned ; disregard the `unsafe` keyword,
// it is actually safe.
let mut state: Reinitializable::ContractState =
Reinitializable::unsafe_new_contract_state();
Reinitializable::InternalImpl::initialize(ref state);
Expand All @@ -215,7 +216,8 @@ mod Space {
assert(authenticators.len() != 0, 'empty authenticators');
assert(voting_strategies.len() == voting_strategy_metadata_uris.len(), 'len mismatch');

//TODO: temporary component syntax
// Migration to components planned ; disregard the `unsafe` keyword,
// it is actually safe.
let mut state = Ownable::unsafe_new_contract_state();
Ownable::InternalImpl::initializer(ref state, owner);
self.set_dao_uri(dao_uri);
Expand Down Expand Up @@ -385,7 +387,8 @@ mod Space {
}

fn cancel(ref self: ContractState, proposal_id: u256) {
//TODO: temporary component syntax
// Migration to components planned ; disregard the `unsafe` keyword,
// it is actually safe.
let state = Ownable::unsafe_new_contract_state();
Ownable::InternalImpl::assert_only_owner(@state);

Expand Down Expand Up @@ -470,7 +473,8 @@ mod Space {
}

fn owner(self: @ContractState) -> ContractAddress {
//TODO: temporary component syntax
// Migration to components planned ; disregard the `unsafe` keyword,
// it is actually safe.
let state = Ownable::unsafe_new_contract_state();
Ownable::OwnableImpl::owner(@state)
}
Expand Down Expand Up @@ -532,7 +536,8 @@ mod Space {
}

fn update_settings(ref self: ContractState, input: UpdateSettingsCalldata) {
//TODO: temporary component syntax
// Migration to components planned ; disregard the `unsafe` keyword,
// it is actually safe.
let state = Ownable::unsafe_new_contract_state();
Ownable::InternalImpl::assert_only_owner(@state);

Expand Down Expand Up @@ -699,13 +704,15 @@ mod Space {
}

fn transfer_ownership(ref self: ContractState, new_owner: ContractAddress) {
//TODO: temporary component syntax
// Migration to components planned ; disregard the `unsafe` keyword,
// it is actually safe.
let mut state = Ownable::unsafe_new_contract_state();
Ownable::OwnableImpl::transfer_ownership(ref state, new_owner);
}

fn renounce_ownership(ref self: ContractState) {
//TODO: temporary component syntax
// Migration to components planned ; disregard the `unsafe` keyword,
// it is actually safe.
let mut state = Ownable::unsafe_new_contract_state();
Ownable::OwnableImpl::renounce_ownership(ref state);
}
Expand Down
3 changes: 2 additions & 1 deletion starknet/src/tests/mocks/space_v2.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ mod SpaceV2 {
#[external(v0)]
impl SpaceV2 of ISpaceV2<ContractState> {
fn initialize(ref self: ContractState, var: felt252) {
// TODO: Temp component syntax
// Migration to components planned ; disregard the `unsafe` keyword,
// it is actually safe.
let mut state = Reinitializable::unsafe_new_contract_state();
Reinitializable::InternalImpl::initialize(ref state);
self._var.write(var);
Expand Down
3 changes: 2 additions & 1 deletion starknet/src/tests/mocks/vanilla_execution_strategy.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ mod VanillaExecutionStrategy {

#[constructor]
fn constructor(ref self: ContractState, quorum: u256) {
// TODO: temporary until components are released
// Migration to components planned ; disregard the `unsafe` keyword,
// it is actually safe.
let mut state = SimpleQuorumExecutionStrategy::unsafe_new_contract_state();
SimpleQuorumExecutionStrategy::InternalImpl::initializer(ref state, quorum);
}
Expand Down
6 changes: 4 additions & 2 deletions starknet/src/voting_strategies/eth_balance_of.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ mod EthBalanceOfVotingStrategy {
.unwrap();

// Get the balance of the voter at the given block timestamp
// TODO: temporary until components are released
// Migration to components planned ; disregard the `unsafe` keyword,
// it is actually safe.
let state = SingleSlotProof::unsafe_new_contract_state();
let balance = SingleSlotProof::InternalImpl::get_storage_slot(
@state, timestamp, l1_account_address, slot_index, voter.into(), user_params
Expand All @@ -58,7 +59,8 @@ mod EthBalanceOfVotingStrategy {
timestamp_remappers: ContractAddress,
facts_registry: ContractAddress
) {
// TODO: temporary until components are released
// Migration to components planned ; disregard the `unsafe` keyword,
// it is actually safe.
let mut state = SingleSlotProof::unsafe_new_contract_state();
SingleSlotProof::InternalImpl::initializer(ref state, timestamp_remappers, facts_registry);
}
Expand Down

0 comments on commit ca5528b

Please sign in to comment.