From 2717c2210f7e3cf9e27fb863f8c9b479ea4486ef Mon Sep 17 00:00:00 2001 From: Sam Elamin Date: Wed, 20 Dec 2023 10:19:31 +0000 Subject: [PATCH] add cardano currency (#299) --- libs/common-types/src/tokens.rs | 15 ++++++++++++--- pallets/briefs/src/lib.rs | 2 +- pallets/grants/src/lib.rs | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/libs/common-types/src/tokens.rs b/libs/common-types/src/tokens.rs index d045a037..1dd71c2c 100644 --- a/libs/common-types/src/tokens.rs +++ b/libs/common-types/src/tokens.rs @@ -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, @@ -49,11 +51,12 @@ pub enum CurrencyId { pub enum ForeignAssetId { ETH, USDT, + ADA, } #[derive( Clone, - Copy, + // Copy, PartialOrd, Ord, PartialEq, @@ -70,6 +73,7 @@ pub enum ForeignAssetId { pub enum ForeignOwnedAccount { TRON([u8; 22]), ETH([u8; 20]), + ADA(BoundedVec>), } impl ForeignOwnedAccount { @@ -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, }, }, } diff --git a/pallets/briefs/src/lib.rs b/pallets/briefs/src/lib.rs index fe6892a8..e206b74e 100644 --- a/pallets/briefs/src/lib.rs +++ b/pallets/briefs/src/lib.rs @@ -200,7 +200,7 @@ pub mod pallet { Error::::EoaRequiredForForeignCurrencies ); } - if let Some(eoa) = external_owned_address { + if let Some(eoa) = external_owned_address.clone() { ensure!( eoa.ensure_supported_currency(currency_id), Error::::CurrencyAccountComboNotSupported diff --git a/pallets/grants/src/lib.rs b/pallets/grants/src/lib.rs index 54ee327b..33ed7d46 100644 --- a/pallets/grants/src/lib.rs +++ b/pallets/grants/src/lib.rs @@ -130,7 +130,7 @@ pub mod pallet { Error::::EoaRequiredForForeignCurrencies ); } - if let Some(eoa) = external_owned_address { + if let Some(eoa) = external_owned_address.clone() { ensure!( eoa.ensure_supported_currency(currency_id), Error::::CurrencyAccountComboNotSupported