Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
302bf39
Implemented initial draft code for the conversion between ZenlinkAsse…
adelarja Jun 14, 2023
9988ad4
added PARA_CHAIN_ID constant
adelarja Jun 14, 2023
d9f5b03
Fixed shifting issue
adelarja Jun 14, 2023
c003c2b
Improved format and added hard-coded values for Stellar assets
adelarja Jun 14, 2023
fe5b292
Added BRL, TZS and USDC issuers
adelarja Jun 15, 2023
94282f4
Added StellarNative
adelarja Jun 15, 2023
81fa633
Added Err(()) return to match statement
adelarja Jun 15, 2023
6f1ff80
Fixed type issues
adelarja Jun 15, 2023
b63df99
Added TryFrom for WrappedCurrency to CurrencyId. Improved format
adelarja Jun 16, 2023
82cb978
changed 'zenlink_id_to_currency_id' function
adelarja Jun 16, 2023
aaa621d
Added unit tests for the conversion functions
adelarja Jun 16, 2023
73c7e81
Abstracted methods into separate file
adelarja Jun 19, 2023
5bf9a43
Changed module
adelarja Jun 19, 2023
a5564d3
Refactored runtime configuration of zenlink
adelarja Jun 19, 2023
19abbde
Improved code format. Added unit tests
adelarja Jun 20, 2023
e573c15
Update Cargo.toml
adelarja Jun 20, 2023
d8c0655
Update Cargo.toml
adelarja Jun 20, 2023
901d3c4
Extended statement to check also the issuer in the match of conversio…
adelarja Jun 21, 2023
2a53682
Merge branch '241-update-spacewalk-dependencies-and-configure-the-lp-…
adelarja Jun 21, 2023
db97794
Renamed test varible and test name.
adelarja Jun 21, 2023
1239e98
Refactored zenlink_id_to_currency_id function. Now it checks that the…
adelarja Jun 21, 2023
c8ce574
Added unit test for Err result when converting between zenlink asset …
adelarja Jun 21, 2023
c34634e
Asset type is checked now. renamed variables
adelarja Jul 6, 2023
7f45510
Added stellar module with issuer definitions.
adelarja Jul 6, 2023
ee098ab
Changed spacewalk dependency commit hash
adelarja Jul 6, 2023
b4733f5
Fixed spacewalk dependencies in node
adelarja Jul 7, 2023
6d3df88
Implemented GenerateLpAssetId to change the generate_lp_asset_id func…
adelarja Jul 10, 2023
b58616f
Refactored zenlink stuffs in runtime common. Added zenlink configurat…
adelarja Jul 11, 2023
8aa58dd
Merge branch 'main' of github.com:pendulum-chain/pendulum into 241-up…
adelarja Jul 14, 2023
190f2e8
Added zenlink protocol runtime api configuration for pendulum.
adelarja Jul 14, 2023
51ff2d6
Fixed primite issue
adelarja Jul 14, 2023
6817a12
Deleted unnecessary brackets
adelarja Jul 14, 2023
c57c37c
Updated spacewalk dependencies hash
adelarja Jul 14, 2023
6cf7d2e
Added comment with USDC issuer address.
adelarja Jul 17, 2023
e0717ef
Added comment with BRL issuer address.
adelarja Jul 17, 2023
55a8a15
Added comment with TZS issuer address.
adelarja Jul 17, 2023
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
Prev Previous commit
Next Next commit
Added TryFrom for WrappedCurrency to CurrencyId. Improved format
  • Loading branch information
adelarja committed Jun 16, 2023
commit b63df99cb59e6db3908f52f61761295723c7589d
51 changes: 31 additions & 20 deletions runtime/foucoco/src/zenlink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use orml_traits::MultiCurrency;
use sp_runtime::{DispatchError, DispatchResult};
use sp_std::marker::PhantomData;

use spacewalk_primitives::{CurrencyId, Asset};
use spacewalk_primitives::{Asset, CurrencyId};

use zenlink_protocol::{
AssetId, Config as ZenlinkConfig, LocalAssetHandler, PairLpGenerate, ZenlinkMultiAssets, LOCAL,
Expand Down Expand Up @@ -174,7 +174,7 @@ impl TryFrom<WrappedCurrencyId> for ZenlinkAssetId {
b"USDC" => 1u64,
b"TZS\0" => 2u64,
b"BRL\0" => 3u64,
_ => return Err(())
_ => return Err(()),
},
_ => return Err(()),
};
Expand Down Expand Up @@ -210,23 +210,21 @@ impl TryFrom<ZenlinkAssetId> for WrappedCurrencyId {
match disc {
0 => Ok(WrappedCurrencyId(CurrencyId::Native)),
1 => Ok(WrappedCurrencyId(CurrencyId::XCM(symbol))),
2 => {
match symbol {
0 => Ok(WrappedCurrencyId(CurrencyId::Stellar(Asset::StellarNative))),
1 => Ok(WrappedCurrencyId(CurrencyId::Stellar(Asset::AlphaNum4 {
code: *b"USDC",
issuer: USDC_ISSUER,
}))),
2 => Ok(WrappedCurrencyId(CurrencyId::Stellar(Asset::AlphaNum4 {
code: *b"TZS\0",
issuer: TZS_ISSUER,
}))),
3 => Ok(WrappedCurrencyId(CurrencyId::Stellar(Asset::AlphaNum4 {
code: *b"BRL\0",
issuer: BRL_ISSUER,
}))),
_ => return Err(()),
}
2 => match symbol {
0 => Ok(WrappedCurrencyId(CurrencyId::Stellar(Asset::StellarNative))),
1 => Ok(WrappedCurrencyId(CurrencyId::Stellar(Asset::AlphaNum4 {
code: *b"USDC",
issuer: USDC_ISSUER,
}))),
2 => Ok(WrappedCurrencyId(CurrencyId::Stellar(Asset::AlphaNum4 {
code: *b"TZS\0",
issuer: TZS_ISSUER,
}))),
3 => Ok(WrappedCurrencyId(CurrencyId::Stellar(Asset::AlphaNum4 {
code: *b"BRL\0",
issuer: BRL_ISSUER,
}))),
_ => return Err(()),
},
6 => {
let token1_id = ((_index & 0x0000_0000_00FF_0000) >> 16) as u8;
Expand All @@ -235,13 +233,26 @@ impl TryFrom<ZenlinkAssetId> for WrappedCurrencyId {
let token2_id = ((_index & 0x0000_00FF_0000_0000) >> 32) as u8;
let token2_type = ((_index & 0x0000_FF00_0000_0000) >> 40) as u8;

Ok(WrappedCurrencyId(CurrencyId::ZenlinkLPToken(token1_id, token1_type, token2_id, token2_type)))
Ok(WrappedCurrencyId(CurrencyId::ZenlinkLPToken(
token1_id,
token1_type,
token2_id,
token2_type,
)))
},
_ => Err(()),
}
}
}

impl TryFrom<WrappedCurrencyId> for CurrencyId {
type Error = ();

fn try_from(wrapped_currency: WrappedCurrencyId) -> Result<Self, Self::Error> {
Ok(wrapped_currency.0)
}
}

fn zenlink_id_to_currency_id(asset_id: ZenlinkAssetId) -> Result<CurrencyId, ()> {
let para_chain_id: u32 = ParachainInfo::parachain_id().into();
if asset_id.chain_id != para_chain_id {
Expand Down