Skip to content

Commit

Permalink
feat: added restricted balance to AccountInfoV2
Browse files Browse the repository at this point in the history
  • Loading branch information
j4m1ef0rd committed Sep 26, 2023
1 parent 3e47468 commit ff53206
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions state-chain/custom-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub struct RpcAccountInfoV2 {
pub is_online: bool,
pub is_bidding: bool,
pub bound_redeem_address: Option<EthereumAddress>,
pub restricted_balance: NumberOrHex,
}

#[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -471,6 +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(),
})
}
fn cf_penalties(
Expand Down
2 changes: 2 additions & 0 deletions state-chain/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,7 @@ impl_runtime_apis! {
let is_bidding = pallet_cf_funding::ActiveBidder::<Runtime>::get(&account_id);
let account_info_v1 = Self::cf_account_info(account_id.clone());
let bound_redeem_address = pallet_cf_funding::BoundRedeemAddress::<Runtime>::get(&account_id);
let restricted_balance = pallet_cf_flip::PendingRedemptionsReserve::<Runtime>::get(&account_id).unwrap_or(0);
RuntimeApiAccountInfoV2 {
balance: account_info_v1.balance,
bond: account_info_v1.bond,
Expand All @@ -948,6 +949,7 @@ impl_runtime_apis! {
is_online: account_info_v1.is_live,
is_bidding,
bound_redeem_address,
restricted_balance,
}
}
fn cf_account_info(account_id: AccountId) -> RuntimeApiAccountInfo {
Expand Down
1 change: 1 addition & 0 deletions state-chain/runtime/src/runtime_apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub struct RuntimeApiAccountInfoV2 {
pub is_online: bool,
pub is_bidding: bool,
pub bound_redeem_address: Option<EthereumAddress>,
pub restricted_balance: u128,
}

#[derive(Encode, Decode, Eq, PartialEq, TypeInfo)]
Expand Down
4 changes: 2 additions & 2 deletions state-chain/traits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ pub trait OnAccountFunded {
type ValidatorId;
type Amount;

/// A callback that is triggered after some validator's balance has changed signigicantly,
/// either by funding it with more Flip, or by executing a redemption.
/// A callback that is triggered after some validator's balance has changed significantly,
/// either by funding it with more Flip, or by initiating/reverting a redemption.
///
/// Note this does not trigger on small changes like transaction fees.
///
Expand Down

0 comments on commit ff53206

Please sign in to comment.