Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add restricted balances to AccountInfoV2 #4048

Merged
merged 5 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading