Skip to content

Commit

Permalink
Stake: Fix migration issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ueco-jb committed Sep 3, 2024
1 parent 53f266b commit 9364fc8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
9 changes: 5 additions & 4 deletions contracts/stake/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,11 @@ impl Staking {
admin.require_auth();
env.deployer().update_current_contract_wasm(new_wasm_hash);

env.storage()
.persistent()
.set(&DistributionDataKey::TotalStakedHistory, &map![&env, (0, 0)]);

let current_timestamp = env.ledger().timestamp();
let total_staked_amount = get_total_staked_counter(&env);
let mut total_staked_history = map![&env];
total_staked_history.set(current_timestamp, total_staked_amount as u128);
save_total_staked_history(&env, total_staked_history);
}
}

Expand Down
9 changes: 3 additions & 6 deletions contracts/stake/src/tests/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ fn upgrade_stake_contract() {

let new_stake_wasm = install_stake_latest_wasm(&env);
stake_v_1_0_0_client.update(&new_stake_wasm);
stake_v_1_0_0_client.update(&new_stake_wasm);

let upgraded_stake_client = stake_latest::Client::new(&env, &stake_addr);

Expand All @@ -134,10 +135,6 @@ fn upgrade_stake_contract() {
);

upgraded_stake_client.create_distribution_flow(&owner, &token_client.address);
token_client.mint(&admin, &1_000);
dbg!("Query now:");
dbg!(upgraded_stake_client.query_total_staked_history());
// dbg!("here?");
// dbg!(upgraded_stake_client.query_total_staked_history());
// upgraded_stake_client.distribute_rewards(&owner, &1_000, &token_client.address);
token_client.mint(&owner, &1_000);
upgraded_stake_client.distribute_rewards(&owner, &1_000, &token_client.address);
}

0 comments on commit 9364fc8

Please sign in to comment.