Skip to content

Commit

Permalink
stake-contract: add config management functions
Browse files Browse the repository at this point in the history
  • Loading branch information
herr-seppia committed Dec 19, 2024
1 parent cebcc54 commit d1471fa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions contracts/stake/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ unsafe fn get_version(arg_len: u32) -> u32 {
rusk_abi::wrap_call(arg_len, |_: ()| STATE.get_version())
}

#[no_mangle]
unsafe fn get_config(arg_len: u32) -> u32 {
rusk_abi::wrap_call(arg_len, |_: ()| STATE.config().clone())
}

// "Feeder" queries

#[no_mangle]
Expand All @@ -116,6 +121,14 @@ unsafe fn before_state_transition(arg_len: u32) -> u32 {
})
}

#[no_mangle]
unsafe fn set_config(arg_len: u32) -> u32 {
rusk_abi::wrap_call(arg_len, |config| {
assert_external_caller();
STATE.configure(config)
})
}

#[no_mangle]
unsafe fn insert_stake(arg_len: u32) -> u32 {
rusk_abi::wrap_call(arg_len, |(pk, stake_data)| {
Expand Down
8 changes: 8 additions & 0 deletions contracts/stake/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ impl StakeState {
}
}

pub fn config(&self) -> &StakeConfig {
&self.conf
}

pub fn configure(&mut self, conf: StakeConfig) {
self.conf = conf;
}

pub fn on_new_block(&mut self) {
self.previous_block_state.clear()
}
Expand Down

0 comments on commit d1471fa

Please sign in to comment.