Skip to content

Commit

Permalink
Removed getters in token-issuer. (#1410)
Browse files Browse the repository at this point in the history
* Removed getters in channel-commission.

* Removed getters in flexible-fee.

* Removed getterd in parachain-staking.

* Removed getters in stable-asset.

* Removed getters in stable-asset.

* Removed getters in token-issuer.

---------

Co-authored-by: Edwin <lark930@gmail.com>
  • Loading branch information
MJLNSN and ark930 authored Sep 4, 2024
1 parent 0fcd3d7 commit 24bf5f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions pallets/token-issuer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,11 @@ pub mod pallet {

/// Accounts in the whitelist can issue the corresponding Currency.
#[pallet::storage]
#[pallet::getter(fn get_issue_whitelist)]
pub type IssueWhiteList<T: Config> =
StorageMap<_, Blake2_128Concat, CurrencyId, BoundedVec<AccountIdOf<T>, T::MaxLengthLimit>>;

/// Accounts in the whitelist can transfer the corresponding Currency.
#[pallet::storage]
#[pallet::getter(fn get_transfer_whitelist)]
pub type TransferWhiteList<T: Config> =
StorageMap<_, Blake2_128Concat, CurrencyId, BoundedVec<AccountIdOf<T>, T::MaxLengthLimit>>;

Expand All @@ -131,7 +129,7 @@ pub mod pallet {

let issue_whitelist_new: BoundedVec<AccountIdOf<T>, T::MaxLengthLimit>;
let mut issue_vec: Vec<AccountIdOf<T>>;
match Self::get_issue_whitelist(currency_id) {
match IssueWhiteList::<T>::get(currency_id) {
None => {
issue_vec = vec![account.clone()];
},
Expand Down Expand Up @@ -189,7 +187,7 @@ pub mod pallet {

let transfer_whitelist_new: BoundedVec<AccountIdOf<T>, T::MaxLengthLimit>;
let mut transfer_vec: Vec<AccountIdOf<T>>;
match Self::get_transfer_whitelist(currency_id) {
match TransferWhiteList::<T>::get(currency_id) {
None => {
transfer_vec = vec![account.clone()];
},
Expand Down Expand Up @@ -253,7 +251,7 @@ pub mod pallet {
let issuer = ensure_signed(origin)?;

let issue_whitelist =
Self::get_issue_whitelist(currency_id).ok_or(Error::<T>::NotAllowed)?;
IssueWhiteList::<T>::get(currency_id).ok_or(Error::<T>::NotAllowed)?;
ensure!(issue_whitelist.contains(&issuer), Error::<T>::NotAllowed);

T::MultiCurrency::deposit(currency_id, &dest, amount)?;
Expand All @@ -277,7 +275,7 @@ pub mod pallet {
let transferrer = ensure_signed(origin)?;

let transfer_whitelist =
Self::get_transfer_whitelist(currency_id).ok_or(Error::<T>::NotAllowed)?;
TransferWhiteList::<T>::get(currency_id).ok_or(Error::<T>::NotAllowed)?;
ensure!(transfer_whitelist.contains(&transferrer), Error::<T>::NotAllowed);

let balance = T::MultiCurrency::free_balance(currency_id, &transferrer);
Expand Down
4 changes: 2 additions & 2 deletions pallets/token-issuer/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn add_to_issue_whitelist_should_work() {
));

let bounded_list = BoundedVec::try_from(vec![CHARLIE]).unwrap();
assert_eq!(TokenIssuer::get_issue_whitelist(ZLK), Some(bounded_list));
assert_eq!(IssueWhiteList::<Runtime>::get(ZLK), Some(bounded_list));
// Charlie succuessfully issue 800 unit of ZLK to Alice account
assert_ok!(TokenIssuer::issue(RuntimeOrigin::signed(CHARLIE), ALICE, ZLK, 800));
assert_eq!(Tokens::free_balance(ZLK, &ALICE), 800);
Expand Down Expand Up @@ -112,7 +112,7 @@ fn add_to_transfer_whitelist_should_work() {
));

let bounded_list = BoundedVec::try_from(vec![CHARLIE]).unwrap();
assert_eq!(TokenIssuer::get_transfer_whitelist(ZLK), Some(bounded_list));
assert_eq!(TransferWhiteList::<Runtime>::get(ZLK), Some(bounded_list));
// Charlie succuessfully transfer 800 unit of ZLK to Alice account
assert_ok!(TokenIssuer::transfer(RuntimeOrigin::signed(CHARLIE), ALICE, ZLK, 800));
assert_eq!(Tokens::free_balance(ZLK, &ALICE), 800);
Expand Down

0 comments on commit 24bf5f8

Please sign in to comment.