Skip to content

Commit

Permalink
refactor: use reinitializable in spacev2
Browse files Browse the repository at this point in the history
  • Loading branch information
Orlando committed Aug 18, 2023
1 parent b2eea03 commit 18b4b76
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions starknet/src/tests/mocks/space_v2.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ trait ISpaceV2<TContractState> {
#[starknet::contract]
mod SpaceV2 {
use super::ISpaceV2;
use sx::utils::reinitializable::Reinitializable;
use sx::utils::ReinitializableImpl;
#[storage]
struct Storage {
_initialized: bool,
_var: felt252
}

#[external(v0)]
impl SpaceV2 of ISpaceV2<ContractState> {
fn initialize(ref self: ContractState, var: felt252) {
assert(self._initialized.read() == false, 'Contract already initialized');
self._initialized.write(true);
// TODO: Temp component syntax
let mut state: Reinitializable::ContractState =
Reinitializable::unsafe_new_contract_state();
ReinitializableImpl::initialize(ref state);
self._var.write(var);
}
fn get_var(self: @ContractState) -> felt252 {
Expand Down

0 comments on commit 18b4b76

Please sign in to comment.