Skip to content

Commit

Permalink
rename function
Browse files Browse the repository at this point in the history
  • Loading branch information
0xripleys committed Oct 15, 2024
1 parent 4f2a105 commit f9dd7cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions contracts/sources/hooks/weight.move
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module liquid_staking::weight {

public struct WeightHook<phantom P> has key, store {
id: UID,
validator_address_and_weights: VecMap<address, u64>,
validator_addresses_and_weights: VecMap<address, u64>,
total_weight: u64,
admin_cap: AdminCap<P>,
version: Version,
Expand All @@ -30,7 +30,7 @@ module liquid_staking::weight {
(
WeightHook {
id: object::new(ctx),
validator_address_and_weights: vec_map::empty(),
validator_addresses_and_weights: vec_map::empty(),
total_weight: 0,
admin_cap,
version: version::new(CURRENT_VERSION),
Expand All @@ -40,17 +40,17 @@ module liquid_staking::weight {
)
}

public fun set_validator_address_and_weights<P>(
public fun set_validator_addresses_and_weights<P>(
self: &mut WeightHook<P>,
_: &WeightHookAdminCap<P>,
validator_address_and_weights: VecMap<address, u64>,
validator_addresses_and_weights: VecMap<address, u64>,
) {
self.version.assert_version_and_upgrade(CURRENT_VERSION);
self.validator_address_and_weights = validator_address_and_weights;
self.validator_addresses_and_weights = validator_addresses_and_weights;

let mut total_weight = 0;
self.validator_address_and_weights.keys().length().do!(|i| {
let (_, weight) = self.validator_address_and_weights.get_entry_by_idx(i);
self.validator_addresses_and_weights.keys().length().do!(|i| {
let (_, weight) = self.validator_addresses_and_weights.get_entry_by_idx(i);
total_weight = total_weight + *weight;
});

Expand All @@ -70,7 +70,7 @@ module liquid_staking::weight {

liquid_staking_info.refresh(system_state, ctx);

let mut validator_addresses_and_weights = self.validator_address_and_weights;
let mut validator_addresses_and_weights = self.validator_addresses_and_weights;

// 1. add all validators that exist in lst_info.validators() to the validator_address_to_weight map if they don't already exist
liquid_staking_info.storage().validators().do_ref!(|validator| {
Expand Down
4 changes: 2 additions & 2 deletions contracts/tests/weight_tests.move
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ module liquid_staking::weight_tests {

let (mut weight_hook, weight_hook_admin_cap) = weight::new(admin_cap, scenario.ctx());

weight_hook.set_validator_address_and_weights(
weight_hook.set_validator_addresses_and_weights(
&weight_hook_admin_cap,
{
let mut map = vec_map::empty();
Expand All @@ -88,7 +88,7 @@ module liquid_staking::weight_tests {
assert!(lst_info.storage().validators().borrow(0).total_sui_amount() == 25 * MIST_PER_SUI, 0);
assert!(lst_info.storage().validators().borrow(1).total_sui_amount() == 75 * MIST_PER_SUI, 0);

weight_hook.set_validator_address_and_weights(
weight_hook.set_validator_addresses_and_weights(
&weight_hook_admin_cap,
{
let mut map = vec_map::empty();
Expand Down

0 comments on commit f9dd7cd

Please sign in to comment.