diff --git a/docs/api/runtime-calls.md b/docs/api/runtime-calls.md index e7b44b9c3a06abe12d11223189de02f641bf7fe2..f6a2ddb8aa0aad99e8e3e4100924948699223373 100644 --- a/docs/api/runtime-calls.md +++ b/docs/api/runtime-calls.md @@ -687,7 +687,7 @@ new_key_sig: T::Signature Change identity owner key. - `new_key`: the new owner key. -- `new_key_sig`: the signature of the encoded form of `NewOwnerKeyPayload`. +- `new_key_sig`: the signature of the encoded form of `IdtyIndexAccountIdPayload`. Must be signed by `new_key`. The origin should be the old identity owner key. diff --git a/pallets/duniter-wot/src/tests.rs b/pallets/duniter-wot/src/tests.rs index 665b9e52ff6906004f60ebdbe268e474e2909aa4..6cefede1f13db6e67eedb9ed7efec3f694af8f7b 100644 --- a/pallets/duniter-wot/src/tests.rs +++ b/pallets/duniter-wot/src/tests.rs @@ -21,8 +21,8 @@ use codec::Encode; use frame_support::instances::{Instance1, Instance2}; use frame_support::{assert_noop, assert_ok}; use pallet_identity::{ - IdtyName, IdtyStatus, NewOwnerKeyPayload, RevocationPayload, NEW_OWNER_KEY_PAYLOAD_PREFIX, - REVOCATION_PAYLOAD_PREFIX, + IdtyIndexAccountIdPayload, IdtyName, IdtyStatus, RevocationPayload, + NEW_OWNER_KEY_PAYLOAD_PREFIX, REVOCATION_PAYLOAD_PREFIX, }; use sp_runtime::testing::TestSignature; @@ -123,7 +123,7 @@ fn test_smith_member_cant_change_its_idty_address() { run_to_block(2); let genesis_hash = System::block_hash(0); - let new_key_payload = NewOwnerKeyPayload { + let new_key_payload = IdtyIndexAccountIdPayload { genesis_hash: &genesis_hash, idty_index: 3u32, old_owner_key: &3u64, diff --git a/pallets/identity/src/benchmarking.rs b/pallets/identity/src/benchmarking.rs index 0f72bf76abf0c4d84764e97f3978544fdf19e54a..c3df1b542ab9f1e567e652cb8f79039968e185c9 100644 --- a/pallets/identity/src/benchmarking.rs +++ b/pallets/identity/src/benchmarking.rs @@ -161,7 +161,7 @@ benchmarks! { // Change key a first time to add an old-old key let genesis_hash = frame_system::Pallet::<T>::block_hash(T::BlockNumber::zero()); - let new_key_payload = NewOwnerKeyPayload { + let new_key_payload = IdtyIndexAccountIdPayload { genesis_hash: &genesis_hash, idty_index: account.index, old_owner_key: &account.key, @@ -176,7 +176,7 @@ benchmarks! { // The sufficients for the old_old key will drop to 0 during benchmark let caller_origin: <T as frame_system::Config>::RuntimeOrigin = RawOrigin::Signed(caller.clone()).into(); let genesis_hash = frame_system::Pallet::<T>::block_hash(T::BlockNumber::zero()); - let new_key_payload = NewOwnerKeyPayload { + let new_key_payload = IdtyIndexAccountIdPayload { genesis_hash: &genesis_hash, idty_index: account.index, old_owner_key: &caller_public, @@ -199,7 +199,7 @@ benchmarks! { // Change key // The sufficients for the old key will drop to 0 during benchmark let genesis_hash = frame_system::Pallet::<T>::block_hash(T::BlockNumber::zero()); - let new_key_payload = NewOwnerKeyPayload { + let new_key_payload = IdtyIndexAccountIdPayload { genesis_hash: &genesis_hash, idty_index: account.index, old_owner_key: &account.key, diff --git a/pallets/identity/src/lib.rs b/pallets/identity/src/lib.rs index e5b5623f600ba0c1b76044cef89a61092029a197..e0687da292aeefd3d901ff83b3c45128861fcc6a 100644 --- a/pallets/identity/src/lib.rs +++ b/pallets/identity/src/lib.rs @@ -417,7 +417,7 @@ pub mod pallet { /// Change identity owner key. /// /// - `new_key`: the new owner key. - /// - `new_key_sig`: the signature of the encoded form of `NewOwnerKeyPayload`. + /// - `new_key_sig`: the signature of the encoded form of `IdtyIndexAccountIdPayload`. /// Must be signed by `new_key`. /// /// The origin should be the old identity owner key. @@ -460,7 +460,7 @@ pub mod pallet { }; let genesis_hash = frame_system::Pallet::<T>::block_hash(T::BlockNumber::zero()); - let new_key_payload = NewOwnerKeyPayload { + let new_key_payload = IdtyIndexAccountIdPayload { genesis_hash: &genesis_hash, idty_index, old_owner_key: &idty_value.owner_key, @@ -622,7 +622,7 @@ pub mod pallet { let idty_index = IdentityIndexOf::<T>::get(&who).ok_or(Error::<T>::IdtyIndexNotFound)?; let genesis_hash = frame_system::Pallet::<T>::block_hash(T::BlockNumber::zero()); - let payload = NewOwnerKeyPayload { + let payload = IdtyIndexAccountIdPayload { genesis_hash: &genesis_hash, idty_index, old_owner_key: &account_id, diff --git a/pallets/identity/src/tests.rs b/pallets/identity/src/tests.rs index 01e24905bf5a3d9be25daddd467cca94e7f0f68e..38abd802f8c81a0b5207ae60a8d1457af3bcf42d 100644 --- a/pallets/identity/src/tests.rs +++ b/pallets/identity/src/tests.rs @@ -16,7 +16,7 @@ use crate::mock::*; use crate::{ - Error, GenesisIdty, IdtyName, IdtyValue, NewOwnerKeyPayload, RevocationPayload, + Error, GenesisIdty, IdtyIndexAccountIdPayload, IdtyName, IdtyValue, RevocationPayload, LINK_IDTY_PAYLOAD_PREFIX, NEW_OWNER_KEY_PAYLOAD_PREFIX, REVOCATION_PAYLOAD_PREFIX, }; use codec::Encode; @@ -211,7 +211,7 @@ fn test_change_owner_key() { .execute_with(|| { let genesis_hash = System::block_hash(0); let old_owner_key = account(1).id; - let mut new_key_payload = NewOwnerKeyPayload { + let mut new_key_payload = IdtyIndexAccountIdPayload { genesis_hash: &genesis_hash, idty_index: 1u64, old_owner_key: &old_owner_key, @@ -363,7 +363,7 @@ fn test_link_account() { .execute_with(|| { let genesis_hash = System::block_hash(0); let account_id = account(10).id; - let payload = NewOwnerKeyPayload { + let payload = IdtyIndexAccountIdPayload { genesis_hash: &genesis_hash, idty_index: 1u64, old_owner_key: &account_id, @@ -425,7 +425,7 @@ fn test_idty_revocation_with_old_key() { }) .execute_with(|| { let genesis_hash = System::block_hash(0); - let new_key_payload = NewOwnerKeyPayload { + let new_key_payload = IdtyIndexAccountIdPayload { genesis_hash: &genesis_hash, idty_index: 1u64, old_owner_key: &account(1).id, @@ -475,7 +475,7 @@ fn test_idty_revocation_with_old_key_after_old_key_expiration() { }) .execute_with(|| { let genesis_hash = System::block_hash(0); - let new_key_payload = NewOwnerKeyPayload { + let new_key_payload = IdtyIndexAccountIdPayload { genesis_hash: &genesis_hash, idty_index: 1u64, old_owner_key: &account(1).id, diff --git a/pallets/identity/src/types.rs b/pallets/identity/src/types.rs index 57d8001402638ad829fe4a247c2b4f11ab962a08..f497ac34d7a8b34e09e609143208949d380d846f 100644 --- a/pallets/identity/src/types.rs +++ b/pallets/identity/src/types.rs @@ -124,9 +124,9 @@ pub struct IdtyValue<BlockNumber, AccountId, IdtyData> { /// payload to define a new owner key #[derive(Clone, Copy, Encode, RuntimeDebug)] -pub struct NewOwnerKeyPayload<'a, AccountId, IdtyIndex, Hash> { +pub struct IdtyIndexAccountIdPayload<'a, AccountId, IdtyIndex, Hash> { /// hash of the genesis block - // Avoid replay attack between networks + // Avoid replay attack across networks pub genesis_hash: &'a Hash, /// identity index pub idty_index: IdtyIndex, @@ -137,7 +137,7 @@ pub struct NewOwnerKeyPayload<'a, AccountId, IdtyIndex, Hash> { #[derive(Clone, Copy, Encode, Decode, PartialEq, Eq, TypeInfo, RuntimeDebug)] pub struct RevocationPayload<IdtyIndex, Hash> { /// hash of the genesis block - // Avoid replay attack between networks + // Avoid replay attack across networks pub genesis_hash: Hash, /// identity index pub idty_index: IdtyIndex,