Skip to content

Commit

Permalink
Add the total token balance to the address of each token account
Browse files Browse the repository at this point in the history
  • Loading branch information
mariari committed Jun 5, 2023
1 parent 7fd7f3c commit db46ab5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions apps/src/lib/node/ledger/shell/init_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,7 @@ where
last_locked_ratio,
)
.unwrap();
// self.storage.write(&token::last_inflation(&address),
// last_inflation).unwrap();

let vp_code =
vp_code_cache.get_or_insert_with(vp_code_path.clone(), || {
wasm_loader::read_wasm(&self.wasm_dir, &vp_code_path)
Expand All @@ -292,10 +291,19 @@ where
.write_bytes(&Key::validity_predicate(&address), vp_code)
.unwrap();

let mut total_balance_for_token = token::Amount::default();
for (owner, amount) in balances {
total_balance_for_token += amount;
credit_tokens(&mut self.wl_storage, &address, &owner, amount)
.unwrap();
}
// Write the total amount of tokens for the ratio
self.wl_storage
.write(
&token::total_supply_key(&address),
total_balance_for_token,
)
.unwrap();
}

// Initialize genesis validator accounts
Expand Down

0 comments on commit db46ab5

Please sign in to comment.