Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
19 changes: 9 additions & 10 deletions frame/identity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,15 @@ impl <
}
}

impl<
Balance: Encode + Decode + Clone + Debug + Eq + PartialEq,
> Decode for Registration<Balance> {
fn decode<I: codec::Input>(input: &mut I) -> sp_std::result::Result<Self, codec::Error> {
let (judgements, deposit, info) = Decode::decode(&mut AppendZerosInput::new(input))?;
Ok(Self { judgements, deposit, info })
}
}

/// Information concerning a registrar.
#[derive(Clone, Encode, Eq, PartialEq, RuntimeDebug)]
pub struct RegistrarInfo<
Expand All @@ -365,16 +374,6 @@ pub struct RegistrarInfo<
pub fields: IdentityFields,
}

impl<
Balance: Encode + Decode + Clone + Debug + Eq + PartialEq,
AccountId: Encode + Decode + Clone + Debug + Eq + PartialEq
> Decode for RegistrarInfo<Balance, AccountId> {
fn decode<I: codec::Input>(input: &mut I) -> sp_std::result::Result<Self, codec::Error> {
let (account, fee, fields) = Decode::decode(&mut AppendZerosInput::new(input))?;
Ok(Self { account, fee, fields })
}
}

decl_storage! {
trait Store for Module<T: Trait> as Sudo {
/// Information that is pertinent to identify the entity behind an account.
Expand Down
40 changes: 20 additions & 20 deletions frame/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -985,26 +985,6 @@ decl_module! {
}
}

/// Rebond a portion of the stash scheduled to be unlocked.
///
/// # <weight>
/// - Time complexity: O(1). Bounded by `MAX_UNLOCKING_CHUNKS`.
/// - Storage changes: Can't increase storage, only decrease it.
/// # </weight>
#[weight = SimpleDispatchInfo::FixedNormal(500_000)]
fn rebond(origin, #[compact] value: BalanceOf<T>) {
let controller = ensure_signed(origin)?;
let ledger = Self::ledger(&controller).ok_or(Error::<T>::NotController)?;
ensure!(
ledger.unlocking.len() > 0,
Error::<T>::NoUnlockChunk,
);

let ledger = ledger.rebond(value);

Self::update_ledger(&controller, &ledger);
}

/// Remove any unlocked chunks from the `unlocking` queue from our management.
///
/// This essentially frees up that balance to be used by the stash account to do
Expand Down Expand Up @@ -1256,6 +1236,26 @@ decl_module! {

<Self as Store>::UnappliedSlashes::insert(&era, &unapplied);
}

/// Rebond a portion of the stash scheduled to be unlocked.
///
/// # <weight>
/// - Time complexity: O(1). Bounded by `MAX_UNLOCKING_CHUNKS`.
/// - Storage changes: Can't increase storage, only decrease it.
/// # </weight>
#[weight = SimpleDispatchInfo::FixedNormal(500_000)]
fn rebond(origin, #[compact] value: BalanceOf<T>) {
let controller = ensure_signed(origin)?;
let ledger = Self::ledger(&controller).ok_or(Error::<T>::NotController)?;
ensure!(
ledger.unlocking.len() > 0,
Error::<T>::NoUnlockChunk,
);

let ledger = ledger.rebond(value);

Self::update_ledger(&controller, &ledger);
}
}
}

Expand Down