Skip to content

Commit

Permalink
Support hydradx user call slpx (#1141)
Browse files Browse the repository at this point in the history
  • Loading branch information
hqwangningbo authored Jan 9, 2024
1 parent e1f6ea0 commit a97916a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
16 changes: 11 additions & 5 deletions pallets/slpx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -854,11 +854,17 @@ impl<T: Config> Pallet<T> {
SupportChain::Interlay
},
};
let whitelist_account_ids = WhitelistAccountId::<T>::get(&support_chain);
ensure!(
whitelist_account_ids.contains(&evm_contract_account_id),
Error::<T>::AccountIdNotInWhitelist
);

match target_chain {
TargetChain::Hydradx(_) => {},
_ => {
let whitelist_account_ids = WhitelistAccountId::<T>::get(&support_chain);
ensure!(
whitelist_account_ids.contains(&evm_contract_account_id),
Error::<T>::AccountIdNotInWhitelist
);
},
};
Ok((evm_contract_account_id, evm_caller_account_id))
}

Expand Down
7 changes: 1 addition & 6 deletions pallets/slpx/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,14 @@ fn test_whitelist_work() {
assert_eq!(evm_contract_account_id, BOB);
assert_eq!(evm_caller_account_id, Slpx::h160_to_account_id(evm_caller));

// Hydradx
assert_ok!(Slpx::add_whitelist(RuntimeOrigin::root(), SupportChain::Hydradx, ALICE));
// Hydradx No whitelist checking
let target_chain = TargetChain::Hydradx(ALICE);
let (evm_contract_account_id, evm_caller_account_id) = Slpx::ensure_singer_on_whitelist(
RuntimeOrigin::signed(ALICE),
evm_caller,
&target_chain,
)
.unwrap();
assert_noop!(
Slpx::ensure_singer_on_whitelist(RuntimeOrigin::signed(BOB), evm_caller, &target_chain),
Error::<Test>::AccountIdNotInWhitelist
);
assert_eq!(evm_contract_account_id, ALICE);
assert_eq!(evm_caller_account_id, ALICE);
});
Expand Down

0 comments on commit a97916a

Please sign in to comment.