-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pallet-identity state process (#124)
* Add types folder * Read storage out * Decimal update * Add remove subsOf and superOf * Remove useless file * Add README * Process in runtime side * Format * Add SUDO back * Fix doc link * Identity migrate * Fix runtime * Add tests * Add tests * Code clean * Remove sp-runtime * Code format * Delete useless reserve * Reset the judgements * Self review * Fix * Add identities runtime tests * Fix tests * Just format * Tiny updates * Update doc Co-authored-by: Xavier Lau <xavier@inv.cafe>
- Loading branch information
1 parent
a32342f
commit ed7da51
Showing
14 changed files
with
492 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
### Process steps | ||
1. take `Identity::IdentityOf`, `Identity::Registrars`, `Identity::SuperOf` and `Identity::SuperOf`. | ||
2. update identities's deposit decimal and reset judgements. | ||
3. update registrars fee decimal. | ||
4. update super_id's reserved balance. | ||
5. set `AccountMigration::IdentityOf` and`AccountMigration::Registrars`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// darwinia | ||
use crate::*; | ||
|
||
impl<S> Processor<S> { | ||
/// Only care about the solo chain, since parachains don't have identity now. | ||
pub fn process_identity(&mut self) -> &mut Self { | ||
let mut identities = <Map<Registration>>::default(); | ||
let mut registrars = Vec::<Option<RegistrarInfo>>::default(); | ||
let mut subs_of = Map::<(u128, Vec<[u8; 32]>)>::default(); | ||
|
||
log::info!("take `Identity::IdentityOf`, `Identity::Registrars`, `Identity::SuperOf` and `Identity::SuperOf`"); | ||
self.solo_state | ||
.take_map(b"Identity", b"IdentityOf", &mut identities, get_hashed_key) | ||
.take_value(b"Identity", b"Registrars", "", &mut registrars) | ||
.take_map(b"Identity", b"SubsOf", &mut subs_of, get_last_64_key); | ||
|
||
log::info!("update identities's deposit and judgement decimal"); | ||
identities.iter_mut().for_each(|(_k, v)| { | ||
v.adjust(); | ||
}); | ||
|
||
log::info!("update registrars fee decimal"); | ||
registrars.iter_mut().for_each(|o| { | ||
if let Some(r) = o { | ||
r.adjust() | ||
} | ||
}); | ||
|
||
log::info!("update super_id's reserved balance"); | ||
subs_of.into_iter().for_each(|(super_id, (mut subs_deposit, _))| { | ||
subs_deposit.adjust(); | ||
|
||
self.shell_state | ||
.unreserve(array_bytes::hex2array_unchecked::<_, 32>(super_id), subs_deposit); | ||
}); | ||
|
||
log::info!("set `AccountMigration::IdentityOf`"); | ||
{ | ||
let ik = item_key(b"AccountMigration", b"IdentityOf"); | ||
|
||
self.shell_state.insert_map(identities, |h| format!("{ik}{h}")); | ||
} | ||
|
||
log::info!("set `AccountMigration::Registrars`"); | ||
self.shell_state.insert_value(b"AccountMigration", b"Registrars", "", registrars); | ||
|
||
self | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.