-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: upgradeability with initializer (#497)
* refactor: replace constructor with initializer and call when upgrading * chore: updated tests * chore: test reinitialization * refactor: moved reinitializeable logic to component * feat: add initializer params to upgrade event * refactor: use reinitializable in spacev2 --------- Co-authored-by: Orlando <[email protected]>
- Loading branch information
Showing
11 changed files
with
331 additions
and
120 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
mod proposal_validation_always_fail; | ||
mod executor; | ||
mod space_v2; |
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,30 @@ | ||
#[starknet::interface] | ||
trait ISpaceV2<TContractState> { | ||
fn initialize(ref self: TContractState, var: felt252); | ||
fn get_var(self: @TContractState) -> felt252; | ||
} | ||
|
||
#[starknet::contract] | ||
mod SpaceV2 { | ||
use super::ISpaceV2; | ||
use sx::utils::reinitializable::Reinitializable; | ||
use sx::utils::ReinitializableImpl; | ||
#[storage] | ||
struct Storage { | ||
_var: felt252 | ||
} | ||
|
||
#[external(v0)] | ||
impl SpaceV2 of ISpaceV2<ContractState> { | ||
fn initialize(ref self: ContractState, var: felt252) { | ||
// 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 { | ||
self._var.read() | ||
} | ||
} | ||
} |
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
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.