Skip to content

Commit

Permalink
Fix bonded prefix (#155)
Browse files Browse the repository at this point in the history
* Fix bonded prefix

* Restore

* Fix
  • Loading branch information
AurevoirXavier authored Dec 22, 2022
1 parent 5138fd0 commit 49ff38c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions precompile/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ where
<Runtime::RuntimeCall as Dispatchable>::RuntimeOrigin: From<Option<Runtime::AccountId>>,
<Runtime as frame_system::Config>::AccountId: From<H160>,
<<Runtime as frame_system::Config>::RuntimeCall as Dispatchable>::RuntimeOrigin: OriginTrait,
<<Runtime as darwinia_staking::Config>::Deposit as Stake>::Item: From<u16>,
<<Runtime as darwinia_staking::Config>::Deposit as Stake>::Item: From<u8>,
{
#[precompile::public("stake(uint256,uint256,uint8[])")]
fn stake(
handle: &mut impl PrecompileHandle,
ring_amount: U256,
kton_amount: U256,
deposits: Vec<u16>,
deposits: Vec<u8>,
) -> EvmResult<bool> {
let origin = handle.context().caller.into();
let deposits = deposits.into_iter().map(|i| i.into()).collect();
Expand All @@ -79,7 +79,7 @@ where
handle: &mut impl PrecompileHandle,
ring_amount: U256,
kton_amount: U256,
deposits: Vec<u16>,
deposits: Vec<u8>,
) -> EvmResult<bool> {
let origin = handle.context().caller.into();
let deposits = deposits.into_iter().map(|i| i.into()).collect();
Expand Down
4 changes: 3 additions & 1 deletion tool/state-processor/src/staking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ impl Processor {

log::info!("take solo `Staking::Bonded`, `Staking::Ledger`, `Staking::RingPool`, `Staking::KtonPool` and `Staking::LivingTime`");
self.solo_state
.take_raw_map(&item_key(b"Staking", b"Bonded"), &mut bonded, get_identity_key)
.take_raw_map(&item_key(b"Staking", b"Bonded"), &mut bonded, |key, from| {
replace_first_match(key, from, &item_key(b"AccountMigration", b"Bonded"))
})
.take_map(b"Staking", b"Ledger", &mut ledgers, get_identity_key)
.take_value(b"Staking", b"RingPool", "", &mut ring_pool_storage)
.take_value(b"Staking", b"KtonPool", "", &mut kton_pool_storage)
Expand Down
4 changes: 2 additions & 2 deletions tool/state-processor/src/type_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ pub struct Unbonding {
pub struct Ledger {
pub staked_ring: u128,
pub staked_kton: u128,
pub staked_deposits: Vec<u8>,
pub staked_deposits: Vec<u16>,
pub unstaking_ring: Vec<(u128, u32)>,
pub unstaking_kton: Vec<(u128, u32)>,
pub unstaking_deposits: Vec<(u8, u32)>,
pub unstaking_deposits: Vec<(u16, u32)>,
}

0 comments on commit 49ff38c

Please sign in to comment.