Skip to content

Commit

Permalink
fix(mock): deposit_and_stake (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xdefacto committed Jul 31, 2023
1 parent 23a7bd2 commit a98461b
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions contracts/mock-staking-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,13 @@ impl StakingPool for MockStakingPool {
#[payable]
fn deposit(&mut self) {
require!(!self.panic, "Test Panic!");
self.internal_deposit()
self.internal_deposit();
}

#[payable]
fn deposit_and_stake(&mut self) {
require!(!self.panic, "Test Panic!");
let account_id = env::predecessor_account_id();

self.internal_deposit();

let amount = self.internal_get_unstaked_deposit(&account_id);
let amount = self.internal_deposit();
self.internal_stake(amount);
}

Expand Down Expand Up @@ -176,7 +172,7 @@ impl MockStakingPool {
}

impl MockStakingPool {
fn internal_deposit(&mut self) {
fn internal_deposit(&mut self) -> u128 {
let account_id = env::predecessor_account_id();
let amount = env::attached_deposit();
assert!(amount > 0);
Expand All @@ -185,6 +181,7 @@ impl MockStakingPool {
let new_deposit = current_deposit + amount;

self.deposits.insert(&account_id, &new_deposit);
amount
}

fn internal_stake(&mut self, amount: u128) {
Expand Down

0 comments on commit a98461b

Please sign in to comment.