Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
14 changes: 14 additions & 0 deletions pallets/balances/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,13 @@ pub mod pallet {
/// Final argument indicates the destination balance type.
/// \[from, to, balance, destination_status]
ReserveRepatriated(T::AccountId, T::AccountId, Balance, Status),
/// Transfer with memo succeeded.
TransferWithMemo {
from: T::AccountId,
to: T::AccountId,
amount: Balance,
memo: Option<Memo>,
},
}

#[pallet::pallet]
Expand Down Expand Up @@ -878,6 +885,13 @@ impl<T: Config> Pallet<T> {
let transactor_id = T::IdentityFn::get_identity(transactor);
let dest_id = T::IdentityFn::get_identity(dest);

Self::deposit_event(Event::TransferWithMemo {
from: transactor.clone(),
to: dest.clone(),
amount: value,
memo: memo.clone(),
});

Self::deposit_event(Event::Transfer(
transactor_id,
transactor.clone(),
Expand Down
19 changes: 0 additions & 19 deletions pallets/relayer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,15 +457,6 @@ impl<T: Config> Pallet<T> {
Ok(auth_id)
}

/// Check if the `key` has a valid CDD.
fn key_has_valid_cdd(key: &T::AccountId) -> bool {
if let Some(did) = <Identity<T>>::get_identity(key) {
<Identity<T>>::has_valid_cdd(did)
} else {
false
}
}

/// Ensure that `paying_key` is the paying key for `user_key`.
fn ensure_is_paying_key(
user_key: &T::AccountId,
Expand Down Expand Up @@ -495,16 +486,6 @@ impl<T: Config> Pallet<T> {
Error::<T>::NotAuthorizedForPayingKey
);

// Ensure both user_key and paying_key have valid CDD.
ensure!(
<Identity<T>>::has_valid_cdd(user_did),
Error::<T>::UserKeyCddMissing
);
ensure!(
Self::key_has_valid_cdd(&paying_key),
Error::<T>::PayingKeyCddMissing
);

// Remove existing subsidy for the user_key, if it exists.
if let Some(subsidy) = <Subsidies<T>>::get(&user_key) {
// Decrease old paying key usage.
Expand Down
22 changes: 8 additions & 14 deletions pallets/runtime/tests/src/relayer_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,13 @@ fn do_user_remove_paying_key_test() {
}

#[test]
fn relayer_user_key_missing_cdd_test() {
fn relayer_user_key_without_cdd_test() {
ExtBuilder::default()
.monied(true)
.build()
.execute_with(&do_relayer_user_key_missing_cdd_test);
.execute_with(&do_relayer_user_key_without_cdd_test);
}
fn do_relayer_user_key_missing_cdd_test() {
fn do_relayer_user_key_without_cdd_test() {
let alice = User::new(AccountKeyring::Alice);
let bob_acc = AccountKeyring::Bob.to_account_id();
let (bob_sign, _) = make_account_without_cdd(bob_acc.clone()).unwrap();
Expand All @@ -377,20 +377,17 @@ fn do_relayer_user_key_missing_cdd_test() {

// Bob tries to accept the paying key, without having a CDD.
let auth_id = get_last_auth_id(&Signatory::Account(bob_acc.clone()));
assert_eq!(
Relayer::accept_paying_key(bob_sign, auth_id),
Err(Error::UserKeyCddMissing.into()),
);
assert_ok!(Relayer::accept_paying_key(bob_sign, auth_id),);
}

#[test]
fn relayer_paying_key_missing_cdd_test() {
fn relayer_paying_key_without_cdd_test() {
ExtBuilder::default()
.monied(true)
.build()
.execute_with(&do_relayer_paying_key_missing_cdd_test);
.execute_with(&do_relayer_paying_key_without_cdd_test);
}
fn do_relayer_paying_key_missing_cdd_test() {
fn do_relayer_paying_key_without_cdd_test() {
let alice = User::new(AccountKeyring::Alice);
let bob_acc = AccountKeyring::Bob.to_account_id();
let (bob_sign, _) = make_account_without_cdd(bob_acc.clone()).unwrap();
Expand All @@ -401,10 +398,7 @@ fn do_relayer_paying_key_missing_cdd_test() {
// Alice tries to accept the paying key, but the paying key
// is without a CDD.
let auth_id = get_last_auth_id(&Signatory::Account(alice.acc()));
assert_eq!(
Relayer::accept_paying_key(alice.origin(), auth_id),
Err(Error::PayingKeyCddMissing.into()),
);
assert_ok!(Relayer::accept_paying_key(alice.origin(), auth_id),);
}

#[test]
Expand Down
12 changes: 2 additions & 10 deletions pallets/runtime/tests/src/utility_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ fn batch_optimistic_failures_listed() {
);
// skip Balances::Transfer event.
events.pop().unwrap();
events.pop().unwrap();

assert_eq!(
events.pop().unwrap().event,
EventTest::Utility(Event::ItemFailed { error: ERROR })
Expand Down Expand Up @@ -284,16 +286,6 @@ fn _relay_unhappy_cases() {
Error::InvalidSignature
);

assert_noop!(
Utility::relay_tx(
origin.clone(),
bob.clone(),
AccountKeyring::Bob.sign(&transaction.encode()).into(),
transaction.clone()
),
Error::TargetCddMissing
);

let _ = register_keyring_account_with_balance(AccountKeyring::Bob, 1_000).unwrap();

let transaction = UniqueCall::new(
Expand Down
7 changes: 1 addition & 6 deletions pallets/utility/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ use pallet_balances::Config as BalancesConfig;
use pallet_identity::{Config as IdentityConfig, Context};
use pallet_permissions::with_call_metadata;
use polymesh_common_utilities::identity::AuthorizationNonce;
use polymesh_primitives::{crypto::verify_signature, traits::CheckCdd, IdentityId};
use polymesh_primitives::{crypto::verify_signature, IdentityId};

type Identity<T> = pallet_identity::Pallet<T>;

Expand Down Expand Up @@ -362,11 +362,6 @@ pub mod pallet {
Error::<T>::InvalidSignature
);

ensure!(
T::CddChecker::check_key_cdd(&target),
Error::<T>::TargetCddMissing
);

<Nonces<T>>::insert(target.clone(), target_nonce + 1);

let info = call.call.get_dispatch_info();
Expand Down