Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cardano currency #299

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading