Skip to content

Commit

Permalink
add cardano currency (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
samelamin authored Dec 20, 2023
1 parent 859f683 commit 2717c22
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions libs/common-types/src/tokens.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_std::vec::Vec;

use frame_support::traits::ConstU32;
use serde::{Deserialize, Serialize};

use sp_runtime::BoundedVec;
#[derive(
Clone,
Copy,
Expand Down Expand Up @@ -49,11 +51,12 @@ pub enum CurrencyId {
pub enum ForeignAssetId {
ETH,
USDT,
ADA,
}

#[derive(
Clone,
Copy,
// Copy,
PartialOrd,
Ord,
PartialEq,
Expand All @@ -70,6 +73,7 @@ pub enum ForeignAssetId {
pub enum ForeignOwnedAccount {
TRON([u8; 22]),
ETH([u8; 20]),
ADA(BoundedVec<u8, ConstU32<104>>),
}

impl ForeignOwnedAccount {
Expand All @@ -85,12 +89,17 @@ impl ForeignOwnedAccount {
CurrencyId::MGX => false,
CurrencyId::ForeignAsset(asset) => match &self {
ForeignOwnedAccount::TRON(_) => match asset {
ForeignAssetId::ETH => false,
ForeignAssetId::USDT => true,
default => false,
},
ForeignOwnedAccount::ETH(_) => match asset {
ForeignAssetId::ETH => true,
ForeignAssetId::USDT => true,
default => false,
},
ForeignOwnedAccount::ADA(_) => match asset {
ForeignAssetId::ADA => true,
default => false,
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion pallets/briefs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ pub mod pallet {
Error::<T>::EoaRequiredForForeignCurrencies
);
}
if let Some(eoa) = external_owned_address {
if let Some(eoa) = external_owned_address.clone() {
ensure!(
eoa.ensure_supported_currency(currency_id),
Error::<T>::CurrencyAccountComboNotSupported
Expand Down
2 changes: 1 addition & 1 deletion pallets/grants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub mod pallet {
Error::<T>::EoaRequiredForForeignCurrencies
);
}
if let Some(eoa) = external_owned_address {
if let Some(eoa) = external_owned_address.clone() {
ensure!(
eoa.ensure_supported_currency(currency_id),
Error::<T>::CurrencyAccountComboNotSupported
Expand Down

0 comments on commit 2717c22

Please sign in to comment.