-
Notifications
You must be signed in to change notification settings - Fork 2
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
complete_setup
endpoint
#187
Changes from 9 commits
ed16358
8efb09e
6cd8b4a
1db480b
a3c96ac
77d446c
ad52f3e
06724ef
5d16078
35b679c
ec726c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,42 +4,29 @@ multiversx_sc::imports!(); | |
|
||
#[multiversx_sc::module] | ||
pub trait SetupPhaseModule { | ||
#[endpoint(endSetupPhase)] | ||
fn end_setup_phase(&self) { | ||
self.require_caller_initiator(); | ||
self.require_setup_phase(); | ||
|
||
self.setup_phase_complete().set(true); | ||
fn require_setup_complete(&self, caller_shard_id: u32) { | ||
require!( | ||
self.is_setup_phase_complete(), | ||
"The setup is not completed in shard {}", | ||
caller_shard_id | ||
); | ||
} | ||
|
||
fn require_caller_initiator(&self) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this function needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i made it an |
||
let caller = self.blockchain().get_caller(); | ||
let initiator_address = self.initiator_address().get(); | ||
require!(caller == initiator_address, "Invalid caller"); | ||
} | ||
|
||
fn require_setup_phase(&self) { | ||
require!( | ||
!self.is_setup_phase_complete(), | ||
"Setup phase complete already" | ||
); | ||
} | ||
let initiator = self.initiator_address().get(); | ||
|
||
fn require_setup_complete(&self) { | ||
require!( | ||
self.is_setup_phase_complete(), | ||
"Setup phase must be completed first" | ||
); | ||
require!(caller == initiator, "Invalid caller"); | ||
} | ||
|
||
#[inline] | ||
fn is_setup_phase_complete(&self) -> bool { | ||
self.setup_phase_complete().get() | ||
} | ||
|
||
#[storage_mapper("initiatorAddress")] | ||
fn initiator_address(&self) -> SingleValueMapper<ManagedAddress>; | ||
|
||
#[storage_mapper("setupPhaseComplete")] | ||
fn setup_phase_complete(&self) -> SingleValueMapper<bool>; | ||
|
||
#[storage_mapper("initiatorAddress")] | ||
fn initiator_address(&self) -> SingleValueMapper<ManagedAddress>; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don' need
caller_shard_id