From 896f27f115aee1db0230d876e83e524a63ac5bcf Mon Sep 17 00:00:00 2001 From: Jamie Ford Date: Wed, 27 Sep 2023 16:51:35 +1000 Subject: [PATCH] refactor: use different storage item --- state-chain/custom-rpc/src/lib.rs | 6 +++--- state-chain/pallets/cf-funding/README.md | 2 +- state-chain/runtime/src/lib.rs | 4 ++-- state-chain/runtime/src/runtime_apis.rs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/state-chain/custom-rpc/src/lib.rs b/state-chain/custom-rpc/src/lib.rs index 80eb8f4f36..e5e2ae6130 100644 --- a/state-chain/custom-rpc/src/lib.rs +++ b/state-chain/custom-rpc/src/lib.rs @@ -23,7 +23,7 @@ use state_chain_runtime::{ constants::common::TX_FEE_MULTIPLIER, runtime_apis::{ChainflipAccountStateWithPassive, CustomRuntimeApi, Environment}, }; -use std::{marker::PhantomData, sync::Arc}; +use std::{collections::BTreeMap, marker::PhantomData, sync::Arc}; #[derive(Serialize, Deserialize)] pub struct RpcAccountInfo { @@ -51,7 +51,7 @@ pub struct RpcAccountInfoV2 { pub is_online: bool, pub is_bidding: bool, pub bound_redeem_address: Option, - pub restricted_balance: NumberOrHex, + pub restricted_balances: BTreeMap, } #[derive(Serialize, Deserialize)] @@ -472,7 +472,7 @@ where is_online: account_info.is_online, is_bidding: account_info.is_bidding, bound_redeem_address: account_info.bound_redeem_address, - restricted_balance: account_info.restricted_balance.into(), + restricted_balances: account_info.restricted_balances.into(), }) } fn cf_penalties( diff --git a/state-chain/pallets/cf-funding/README.md b/state-chain/pallets/cf-funding/README.md index c03b865bc0..a93c28e09b 100644 --- a/state-chain/pallets/cf-funding/README.md +++ b/state-chain/pallets/cf-funding/README.md @@ -32,7 +32,7 @@ A validator can have at most one open redemption at any given time. They must ei ### Redemption Restrictions -Redemptions can be subject to certain rules and restrictions. The following categories apply simulataneously, that is, all of the following restrictions are checked on every redemption request. +Redemptions can be subject to certain rules and restrictions. The following categories apply simultaneously, that is, all of the following restrictions are checked on every redemption request. #### Bonded Funds diff --git a/state-chain/runtime/src/lib.rs b/state-chain/runtime/src/lib.rs index f39cfc83f1..e53690ad6e 100644 --- a/state-chain/runtime/src/lib.rs +++ b/state-chain/runtime/src/lib.rs @@ -935,7 +935,7 @@ impl_runtime_apis! { let is_bidding = pallet_cf_funding::ActiveBidder::::get(&account_id); let account_info_v1 = Self::cf_account_info(account_id.clone()); let bound_redeem_address = pallet_cf_funding::BoundRedeemAddress::::get(&account_id); - let restricted_balance = pallet_cf_flip::PendingRedemptionsReserve::::get(&account_id).unwrap_or(0); + let restricted_balances = pallet_cf_funding::RestrictedBalances::::get(&account_id); RuntimeApiAccountInfoV2 { balance: account_info_v1.balance, bond: account_info_v1.bond, @@ -949,7 +949,7 @@ impl_runtime_apis! { is_online: account_info_v1.is_live, is_bidding, bound_redeem_address, - restricted_balance, + restricted_balances, } } fn cf_account_info(account_id: AccountId) -> RuntimeApiAccountInfo { diff --git a/state-chain/runtime/src/runtime_apis.rs b/state-chain/runtime/src/runtime_apis.rs index 92032915f2..869ac9f266 100644 --- a/state-chain/runtime/src/runtime_apis.rs +++ b/state-chain/runtime/src/runtime_apis.rs @@ -14,7 +14,7 @@ use scale_info::TypeInfo; use serde::{Deserialize, Serialize}; use sp_api::decl_runtime_apis; use sp_runtime::DispatchError; -use sp_std::vec::Vec; +use sp_std::{collections::btree_map::BTreeMap, vec::Vec}; type VanityName = Vec; @@ -57,7 +57,7 @@ pub struct RuntimeApiAccountInfoV2 { pub is_online: bool, pub is_bidding: bool, pub bound_redeem_address: Option, - pub restricted_balance: u128, + pub restricted_balances: BTreeMap, } #[derive(Encode, Decode, Eq, PartialEq, TypeInfo)]