From a5ba9e8527cfe59af6c7ff6d40403f1fb3f5c275 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:42:36 +0800 Subject: [PATCH 01/15] first iteration --- src/assets/img/token/pen.png | Bin 0 -> 5582 bytes src/modules/xcm/index.ts | 11 +++ src/modules/xcm/tokens/index.ts | 11 +++ src/v2/models/XcmModels.ts | 2 + src/v2/repositories/implementations/index.ts | 1 + .../xcm/PendulumXcmRepository.ts | 93 ++++++++++++++++++ 6 files changed, 118 insertions(+) create mode 100644 src/assets/img/token/pen.png create mode 100644 src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts diff --git a/src/assets/img/token/pen.png b/src/assets/img/token/pen.png new file mode 100644 index 0000000000000000000000000000000000000000..1ec53172e89173275aee2441d55facf851aac41c GIT binary patch literal 5582 zcmXw-c{o)4|NoDDFc?fSqhU;n5jEMjDPv|V*(JA-LSxI8HOq~x!xW<|St5fXWKfZH z?8}X;Nyri+Ny%0z-_!4N{r))1bzwy_y&li!c_vwy83^zp`2YYAFft@rf!p4{ z3xpe7SK2^ltoxZu_och=@NL~)LHaGNxPQ4j&0?5R(QnDpgdyGCqv&aARMNw^&V+aT>|0&v z)bIwaT!dXt_8M{xDKE1ubJFb;Tvm3a_%VIq6gvR#hKbdR!z7e(I7I?gy1iEB1%tEG zAKQP%u)k{9^6P-{8{$YoEA@8U;;G>~ypZbRY$$Zv9w9E{Bi(5o?bI{Z&SGvv_)k64o57rc-$7YI zEh>kHQowB^hqCT=nG^tkTN{xG*0=ID9-5j+Ol9^Q-gP~4T-DbJZc}EsA)r%sHv@O- z&SgCVPYh)h#TINx7b+=fGLsoapRhFk4%fp}f4DITwQ|RLyC!xvIfxt`u zzLyULx}Ls1WWUBtjj(wQZ#@u=7j0pP&4)Or-C|$iI8-!ImRTJK04topcOH|mV!5t; z6ooEEB`+dPIG}ARYO&9No$HwULJ-!@l9r)uI1!j%ul8J8o`kL8yY70;UD$09B{9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redTokens); + super(defaultApi, apiFactory, registeredTokens); + } + + public async getTransferCall( + from: XcmChain, + to: XcmChain, + recipientAddress: string, + token: Asset, + amount: BN, + endpoint: string + ): Promise { + if (!to.parachainId) { + throw `Parachain id for ${to.name} is not defined`; + } + if (token.id !== '18446744073709551634') { + throw 'Token must be PEN'; + } + const tokenData = { Token: token.originAssetId }; + + const instance = 10; + const destination = { + V3: { + parents: '1', + interior: { + X2: [ + { + Parachain: to.parachainId, + }, + { + PalletInstance: instance + } + ] + } + }, + }; + + const destWeight = { Unlimited: null }; + + return await this.buildTxCall( + from, + endpoint, + 'xTokens', + 'transfer', + tokenData, + amount, + destination, + destWeight + ); + } + + public async getTokenBalance( + address: string, + chain: XcmChain, + token: Asset, + isNativeToken: boolean, + endpoint: string + ): Promise { + const symbol = token.metadata.symbol; + const api = await this.apiFactory.get(endpoint); + + try { + const bal = await api.query.tokens.accounts(address,{ + Token: token.originAssetId + }); + + return bal.free.toString() + } catch (e) { + console.error(e); + return '0'; + } + } +} + + From fa2776f48ffe6a8da3d9658a05233fcaa73c5317 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:54:30 +0800 Subject: [PATCH 02/15] add PendulumXcmRepository.ts --- src/v2/config/xcm/XcmRepositoryConfiguration.ts | 3 ++- .../repositories/implementations/xcm/PendulumXcmRepository.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/v2/config/xcm/XcmRepositoryConfiguration.ts b/src/v2/config/xcm/XcmRepositoryConfiguration.ts index ce634d71c..36da741dd 100644 --- a/src/v2/config/xcm/XcmRepositoryConfiguration.ts +++ b/src/v2/config/xcm/XcmRepositoryConfiguration.ts @@ -9,7 +9,7 @@ import { PhalaXcmRepository, BifrostXcmRepository, EquilibriumXcmRepository, - UniqueXcmRepository, + UniqueXcmRepository, PendulumXcmRepository } from 'src/v2/repositories/implementations'; import { Chain } from 'src/v2/models/XcmModels'; import { TypeMapping } from 'src/v2/config/types'; @@ -34,6 +34,7 @@ export const XcmRepositoryConfiguration: TypeMapping = { [Chain.BIFROST_KUSAMA]: BifrostXcmRepository, [Chain.EQUILIBRIUM]: EquilibriumXcmRepository, [Chain.UNIQUE]: UniqueXcmRepository, + [Chain.PENDULUM]: PendulumXcmRepository, }; export type AstarToken = 'ASTR' | 'SDN'; diff --git a/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts b/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts index bf61a3d1d..55a3a2c7b 100644 --- a/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts +++ b/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts @@ -12,7 +12,7 @@ import { TokensAccounts } from 'src/v2/repositories/implementations/xcm/AcalaXcm * Used to transfer assets from Pendulum */ -export class BifrostXcmRepository extends XcmRepository { +export class PendulumXcmRepository extends XcmRepository { constructor() { const defaultApi = container.get(Symbols.DefaultApi); const apiFactory = container.get(Symbols.ApiFactory); From a85e9f0237893ac98e4a0ae0e32b844a5ba44b33 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Thu, 13 Jun 2024 18:50:41 +0800 Subject: [PATCH 03/15] fix build issues --- src/modules/xcm/index.ts | 10 ++++------ src/modules/xcm/tokens/index.ts | 1 - src/v2/config/xcm/XcmRepositoryConfiguration.ts | 3 ++- src/v2/models/XcmModels.ts | 4 ++-- .../implementations/xcm/PendulumXcmRepository.ts | 16 +++++++--------- 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/modules/xcm/index.ts b/src/modules/xcm/index.ts index f6adab3d6..799f7f4f1 100644 --- a/src/modules/xcm/index.ts +++ b/src/modules/xcm/index.ts @@ -350,17 +350,15 @@ export let xcmChainObj: XcmChainObj = { subscan: 'https://unique.subscan.io', isAstarNativeToken: false, }, - [Chain.PENDULUM] : { + [Chain.PENDULUM]: { name: Chain.PENDULUM, relayChain: Chain.POLKADOT, img: require('/src/assets/img/token/pen.png'), parachainId: parachainIds.PENDULUM, - endpoints:[ - 'wss://rpc-pendulum.prd.pendulumchain.tech:443' - ], + endpoints: ['wss://rpc-pendulum.prd.pendulumchain.tech:443'], subscan: 'https://pendulum.subscan.io/', - isAstarNativeToken: false - } + isAstarNativeToken: false, + }, }; export const xcmChains = objToArray(xcmChainObj); diff --git a/src/modules/xcm/tokens/index.ts b/src/modules/xcm/tokens/index.ts index fd2ff07a8..da69aa79b 100644 --- a/src/modules/xcm/tokens/index.ts +++ b/src/modules/xcm/tokens/index.ts @@ -175,7 +175,6 @@ export const xcmToken = { originChain: Chain.PENDULUM, minBridgeAmount: '0.1', }, - ], [endpointKey.SHIDEN]: [ { diff --git a/src/v2/config/xcm/XcmRepositoryConfiguration.ts b/src/v2/config/xcm/XcmRepositoryConfiguration.ts index 36da741dd..484968438 100644 --- a/src/v2/config/xcm/XcmRepositoryConfiguration.ts +++ b/src/v2/config/xcm/XcmRepositoryConfiguration.ts @@ -9,7 +9,8 @@ import { PhalaXcmRepository, BifrostXcmRepository, EquilibriumXcmRepository, - UniqueXcmRepository, PendulumXcmRepository + UniqueXcmRepository, + PendulumXcmRepository, } from 'src/v2/repositories/implementations'; import { Chain } from 'src/v2/models/XcmModels'; import { TypeMapping } from 'src/v2/config/types'; diff --git a/src/v2/models/XcmModels.ts b/src/v2/models/XcmModels.ts index 2965c16f6..37aae14ae 100644 --- a/src/v2/models/XcmModels.ts +++ b/src/v2/models/XcmModels.ts @@ -21,7 +21,7 @@ export enum Chain { BIFROST_KUSAMA = 'Bifrost', EQUILIBRIUM = 'Equilibrium', UNIQUE = 'Unique', - PENDULUM = 'Pendulum' + PENDULUM = 'Pendulum', } export enum parachainIds { @@ -42,7 +42,7 @@ export enum parachainIds { BIFROST_KUSAMA = 2001, EQUILIBRIUM = 2011, UNIQUE = 2037, - PENDULUM = 2094 + PENDULUM = 2094, } export interface XcmChain { diff --git a/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts b/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts index 55a3a2c7b..122e14aed 100644 --- a/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts +++ b/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts @@ -46,10 +46,10 @@ export class PendulumXcmRepository extends XcmRepository { Parachain: to.parachainId, }, { - PalletInstance: instance - } - ] - } + PalletInstance: instance, + }, + ], + }, }, }; @@ -78,16 +78,14 @@ export class PendulumXcmRepository extends XcmRepository { const api = await this.apiFactory.get(endpoint); try { - const bal = await api.query.tokens.accounts(address,{ - Token: token.originAssetId + const bal = await api.query.tokens.accounts(address, { + Token: token.originAssetId, }); - return bal.free.toString() + return bal.free.toString(); } catch (e) { console.error(e); return '0'; } } } - - From d48e6f436a9a0ae9313b142c26b1f3078fd495a3 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 14 Jun 2024 13:23:57 +0800 Subject: [PATCH 04/15] update PEN png --- src/modules/xcm/tokens/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/xcm/tokens/index.ts b/src/modules/xcm/tokens/index.ts index da69aa79b..e49d0a01f 100644 --- a/src/modules/xcm/tokens/index.ts +++ b/src/modules/xcm/tokens/index.ts @@ -167,10 +167,10 @@ export const xcmToken = { }, { symbol: 'PEN', - isNativeToken: true, + isNativeToken: false, assetId: '18446744073709551634', originAssetId: 'PEN', - logo: require('/src/assets/img/token/kusama.png'), + logo: require('/src/assets/img/token/pen.png'), isXcmCompatible: true, originChain: Chain.PENDULUM, minBridgeAmount: '0.1', From 1f44acfd482b26dd1b03490a50ea707c56ae8243 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 14 Jun 2024 14:03:27 +0800 Subject: [PATCH 05/15] PEN is native, so use `getNativeBalance` --- src/modules/xcm/tokens/index.ts | 2 +- .../implementations/xcm/PendulumXcmRepository.ts | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/modules/xcm/tokens/index.ts b/src/modules/xcm/tokens/index.ts index e49d0a01f..69dbaba84 100644 --- a/src/modules/xcm/tokens/index.ts +++ b/src/modules/xcm/tokens/index.ts @@ -167,7 +167,7 @@ export const xcmToken = { }, { symbol: 'PEN', - isNativeToken: false, + isNativeToken: true, assetId: '18446744073709551634', originAssetId: 'PEN', logo: require('/src/assets/img/token/pen.png'), diff --git a/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts b/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts index 122e14aed..36f0fe8f5 100644 --- a/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts +++ b/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts @@ -76,13 +76,16 @@ export class PendulumXcmRepository extends XcmRepository { ): Promise { const symbol = token.metadata.symbol; const api = await this.apiFactory.get(endpoint); + console.log('THE SYMBOL: ', symbol); try { - const bal = await api.query.tokens.accounts(address, { - Token: token.originAssetId, - }); - - return bal.free.toString(); + if (token.originAssetId == 'PEN') { + return (await this.getNativeBalance(address, chain, endpoint)).toString(); + } else { + let asset_id = token.originAssetId; + const bal = await api.query.tokens.accounts(address, asset_id); + return bal.free.toString(); + } } catch (e) { console.error(e); return '0'; From 348d65257911152f8440c608e5143e528e582618 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 14 Jun 2024 14:03:42 +0800 Subject: [PATCH 06/15] remove console.log --- src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts b/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts index 36f0fe8f5..fd4d6e479 100644 --- a/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts +++ b/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts @@ -76,7 +76,6 @@ export class PendulumXcmRepository extends XcmRepository { ): Promise { const symbol = token.metadata.symbol; const api = await this.apiFactory.get(endpoint); - console.log('THE SYMBOL: ', symbol); try { if (token.originAssetId == 'PEN') { From b7b8cf439c31c21acdbd996f2618e6904af283c6 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 14 Jun 2024 18:41:13 +0800 Subject: [PATCH 07/15] use '0' instead of 'PEN' --- src/modules/xcm/tokens/index.ts | 2 +- .../implementations/xcm/PendulumXcmRepository.ts | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/modules/xcm/tokens/index.ts b/src/modules/xcm/tokens/index.ts index 69dbaba84..6e47c42c4 100644 --- a/src/modules/xcm/tokens/index.ts +++ b/src/modules/xcm/tokens/index.ts @@ -169,7 +169,7 @@ export const xcmToken = { symbol: 'PEN', isNativeToken: true, assetId: '18446744073709551634', - originAssetId: 'PEN', + originAssetId: '0', logo: require('/src/assets/img/token/pen.png'), isXcmCompatible: true, originChain: Chain.PENDULUM, diff --git a/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts b/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts index fd4d6e479..3ef127689 100644 --- a/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts +++ b/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts @@ -7,11 +7,14 @@ import { Symbols } from 'src/v2/symbols'; import { XcmRepository } from '../XcmRepository'; import { XcmChain } from 'src/v2/models/XcmModels'; import { TokensAccounts } from 'src/v2/repositories/implementations/xcm/AcalaXcmRepository'; +import { decodeAddress } from '@polkadot/util-crypto'; /** * Used to transfer assets from Pendulum */ +const PEN = 'Native'; + export class PendulumXcmRepository extends XcmRepository { constructor() { const defaultApi = container.get(Symbols.DefaultApi); @@ -34,9 +37,7 @@ export class PendulumXcmRepository extends XcmRepository { if (token.id !== '18446744073709551634') { throw 'Token must be PEN'; } - const tokenData = { Token: token.originAssetId }; - - const instance = 10; + let tokenData = PEN; const destination = { V3: { parents: '1', @@ -46,7 +47,9 @@ export class PendulumXcmRepository extends XcmRepository { Parachain: to.parachainId, }, { - PalletInstance: instance, + AccountId32: { + id: decodeAddress(recipientAddress), + }, }, ], }, @@ -74,11 +77,11 @@ export class PendulumXcmRepository extends XcmRepository { isNativeToken: boolean, endpoint: string ): Promise { - const symbol = token.metadata.symbol; const api = await this.apiFactory.get(endpoint); try { - if (token.originAssetId == 'PEN') { + // PEN + if (token.originAssetId == '0') { return (await this.getNativeBalance(address, chain, endpoint)).toString(); } else { let asset_id = token.originAssetId; From 61f757ffb98a819fde97687f9a2ec111cc933b1d Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Mon, 17 Jun 2024 17:23:21 +0800 Subject: [PATCH 08/15] add XLM and EURC --- src/assets/img/token/EURC.svg | 17 ++++++++++++ src/assets/img/token/PEN.svg | 23 ++++++++++++++++ src/assets/img/token/XLM.svg | 20 ++++++++++++++ src/assets/img/token/pen.png | Bin 5582 -> 0 bytes src/modules/xcm/index.ts | 2 +- src/modules/xcm/tokens/index.ts | 24 +++++++++++++++-- .../implementations/XcmRepository.ts | 1 + .../xcm/PendulumXcmRepository.ts | 25 +++++++++++++----- 8 files changed, 102 insertions(+), 10 deletions(-) create mode 100644 src/assets/img/token/EURC.svg create mode 100644 src/assets/img/token/PEN.svg create mode 100644 src/assets/img/token/XLM.svg delete mode 100644 src/assets/img/token/pen.png diff --git a/src/assets/img/token/EURC.svg b/src/assets/img/token/EURC.svg new file mode 100644 index 000000000..d9c1163ff --- /dev/null +++ b/src/assets/img/token/EURC.svg @@ -0,0 +1,17 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/assets/img/token/PEN.svg b/src/assets/img/token/PEN.svg new file mode 100644 index 000000000..7b8b9d536 --- /dev/null +++ b/src/assets/img/token/PEN.svg @@ -0,0 +1,23 @@ + + \ No newline at end of file diff --git a/src/assets/img/token/XLM.svg b/src/assets/img/token/XLM.svg new file mode 100644 index 000000000..dfd233676 --- /dev/null +++ b/src/assets/img/token/XLM.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + diff --git a/src/assets/img/token/pen.png b/src/assets/img/token/pen.png deleted file mode 100644 index 1ec53172e89173275aee2441d55facf851aac41c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5582 zcmXw-c{o)4|NoDDFc?fSqhU;n5jEMjDPv|V*(JA-LSxI8HOq~x!xW<|St5fXWKfZH z?8}X;Nyri+Ny%0z-_!4N{r))1bzwy_y&li!c_vwy83^zp`2YYAFft@rf!p4{ z3xpe7SK2^ltoxZu_och=@NL~)LHaGNxPQ4j&0?5R(QnDpgdyGCqv&aARMNw^&V+aT>|0&v z)bIwaT!dXt_8M{xDKE1ubJFb;Tvm3a_%VIq6gvR#hKbdR!z7e(I7I?gy1iEB1%tEG zAKQP%u)k{9^6P-{8{$YoEA@8U;;G>~ypZbRY$$Zv9w9E{Bi(5o?bI{Z&SGvv_)k64o57rc-$7YI zEh>kHQowB^hqCT=nG^tkTN{xG*0=ID9-5j+Ol9^Q-gP~4T-DbJZc}EsA)r%sHv@O- z&SgCVPYh)h#TINx7b+=fGLsoapRhFk4%fp}f4DITwQ|RLyC!xvIfxt`u zzLyULx}Ls1WWUBtjj(wQZ#@u=7j0pP&4)Or-C|$iI8-!ImRTJK04topcOH|mV!5t; z6ooEEB`+dPIG}ARYO&9No$HwULJ-!@l9r)uI1!j%ul8J8o`kL8yY70;UD$09B{9-#X-_AaG zEM9a8qo56_)r7ew+VUW7D?=poOxslw^vk*o#OtZ@+?DVa&Te$Ip$^~tIg1LtH zt-6l8>kM1>F*t8~(d_7IHMPylSVe%U2g3ADdC>qs!2OipH-FD#g}jPQV|<=Msd zDaIs2FxrUQ{IplQgu zbJC?#%S$?t(@EL-^|c`@?2-%bO1fW~tpPDk6(V8P9Q!Wvw00;^M@IScYIZ(FT9G|6 zMx@xw$D3 zGfbLNUP0s|;x-2Iwm<#k<8m4O?+PnlX3fj@Q2WfYN(+_wmq(Z59n`5g)inn7Pb3z~ zowj!mQ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OOo=z3pY#U;gO zh`4Hi(6FrbX||0cNdMs-9fy1s{|U6$*%dX;UIXYX8ar6qxZ`+9tFRDK3pk7n(i%{N zxPF7rYKwvV<%qj6oReEAo(}2|i#~(iNdwS))SqLrZEhI!#pH$>sOF1v0=6$2f~ubR zW-Yx5KW+4V_fuv+-rd&M1~G!o5=#lVpdj*^5bbze+1w4U-JAY?wxj=hUA}|;NIDo* zY=?)&>I($UTo-3aQcY{N4itwDt3HQW#t$y5%J8}ku$xG()GlN54PcL~KB)6NqV@dF z8JV6-%zjdv5^|8g%5CG=WcjPbU5{N;f4g6KC7nX|N9o%``teFxZ_08!}_XYk@2_$6& z(2(GSjmb>Jg*OPdc;*{ghd+&DK!#QT2sqSNB;F5BxF*Qz2%@_(4@aCJ%oAj39WpGN z1FZykWWr#Qh2y|W1=y`kMuiB$z^OQlP=LI;IW|Uyrwj}lLI}}aq1$jFeoQt8Od-bhZ>?{>dp6pw~;<2{O>yaX?E2V2rjpBgXwfqU3 zd&$=me%xgVl|?gLIQ?>xZ7|@qAByV0-d3Y>*&8EbH92Wkp2E>Ory1ll8$NtLT9qmN zRy=xBIIlC3M;FO58&0suDuj-5id`0|$I<>5eAQaCwtbd$EQTLf>PIWG7{=@@*g&D} z|4+;wOaCt~>y-9-c!F=<{((l { const api = await this.apiFactory.get(endpoint); const call = api.tx[extrinsic][method](...args); + console.log('build call: ', call.toHex(false)); if (call) { return call; } diff --git a/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts b/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts index 3ef127689..8e59235c8 100644 --- a/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts +++ b/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts @@ -14,6 +14,15 @@ import { decodeAddress } from '@polkadot/util-crypto'; */ const PEN = 'Native'; +const XLM = { Stellar: 'StellarNative' }; +const EURC = { + Stellar: { + AlphaNum4: { + code: 'EURC', + issuer: 'GAQRF3UGHBT6JYQZ7YSUYCIYWAF4T2SAA5237Q5LIQYJOHHFAWDXZ7NM', + }, + }, +}; export class PendulumXcmRepository extends XcmRepository { constructor() { @@ -34,10 +43,14 @@ export class PendulumXcmRepository extends XcmRepository { if (!to.parachainId) { throw `Parachain id for ${to.name} is not defined`; } - if (token.id !== '18446744073709551634') { - throw 'Token must be PEN'; + var tokenData; + if (token.originAssetId == 'PEN') { + tokenData = PEN; + } else if (token.originAssetId == 'XLM') { + tokenData = XLM; + } else if (token.originAssetId == 'EURC') { + tokenData = EURC; } - let tokenData = PEN; const destination = { V3: { parents: '1', @@ -80,12 +93,10 @@ export class PendulumXcmRepository extends XcmRepository { const api = await this.apiFactory.get(endpoint); try { - // PEN - if (token.originAssetId == '0') { + if (isNativeToken) { return (await this.getNativeBalance(address, chain, endpoint)).toString(); } else { - let asset_id = token.originAssetId; - const bal = await api.query.tokens.accounts(address, asset_id); + const bal = await api.query.tokens.accounts(address, token.originAssetId); return bal.free.toString(); } } catch (e) { From 29c073e514a216d9485313abbaad5945978b9a0f Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Mon, 17 Jun 2024 17:24:49 +0800 Subject: [PATCH 09/15] use triple '=' --- .../implementations/xcm/PendulumXcmRepository.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts b/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts index 8e59235c8..0fc757484 100644 --- a/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts +++ b/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts @@ -44,11 +44,11 @@ export class PendulumXcmRepository extends XcmRepository { throw `Parachain id for ${to.name} is not defined`; } var tokenData; - if (token.originAssetId == 'PEN') { + if (token.originAssetId === 'PEN') { tokenData = PEN; - } else if (token.originAssetId == 'XLM') { + } else if (token.originAssetId === 'XLM') { tokenData = XLM; - } else if (token.originAssetId == 'EURC') { + } else if (token.originAssetId === 'EURC') { tokenData = EURC; } const destination = { From 1f39211e7953d1d388253248cde532351e31caad Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Thu, 20 Jun 2024 22:16:59 +0800 Subject: [PATCH 10/15] update symbols and issuers --- src/modules/xcm/tokens/index.ts | 8 +++---- .../xcm/PendulumXcmRepository.ts | 22 +++++++++++++------ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/modules/xcm/tokens/index.ts b/src/modules/xcm/tokens/index.ts index 0df13f180..0b92b48ca 100644 --- a/src/modules/xcm/tokens/index.ts +++ b/src/modules/xcm/tokens/index.ts @@ -176,20 +176,20 @@ export const xcmToken = { minBridgeAmount: '0.1', }, { - symbol: 'XLM', + symbol: 'XLM.s', isNativeToken: false, assetId: '18446744073709551635', - originAssetId: 'XLM', + originAssetId: 'XLM.s', logo: require('/src/assets/img/token/XLM.svg'), isXcmCompatible: true, originChain: Chain.PENDULUM, minBridgeAmount: '0.1', }, { - symbol: 'EURC', + symbol: 'mEURC.s', isNativeToken: false, assetId: '18446744073709551636', - originAssetId: 'EURC', + originAssetId: 'mEURC.s', logo: require('/src/assets/img/token/EURC.svg'), isXcmCompatible: true, originChain: Chain.PENDULUM, diff --git a/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts b/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts index 0fc757484..98a1aa61b 100644 --- a/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts +++ b/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts @@ -15,11 +15,11 @@ import { decodeAddress } from '@polkadot/util-crypto'; const PEN = 'Native'; const XLM = { Stellar: 'StellarNative' }; -const EURC = { +const StellarEURCMykobo = { Stellar: { AlphaNum4: { code: 'EURC', - issuer: 'GAQRF3UGHBT6JYQZ7YSUYCIYWAF4T2SAA5237Q5LIQYJOHHFAWDXZ7NM', + issuer: '0x2112ee863867e4e219fe254c0918b00bc9ea400775bfc3ab4430971ce505877c', }, }, }; @@ -46,10 +46,10 @@ export class PendulumXcmRepository extends XcmRepository { var tokenData; if (token.originAssetId === 'PEN') { tokenData = PEN; - } else if (token.originAssetId === 'XLM') { + } else if (token.originAssetId === 'XLM.s') { tokenData = XLM; - } else if (token.originAssetId === 'EURC') { - tokenData = EURC; + } else if (token.originAssetId === 'mEURC.s') { + tokenData = StellarEURCMykobo; } const destination = { V3: { @@ -95,10 +95,18 @@ export class PendulumXcmRepository extends XcmRepository { try { if (isNativeToken) { return (await this.getNativeBalance(address, chain, endpoint)).toString(); + } + let currencyId; + if (token.originAssetId === 'XLM.s') { + currencyId = XLM; + } else if (token.originAssetId === 'mEURC.s') { + currencyId = StellarEURCMykobo; } else { - const bal = await api.query.tokens.accounts(address, token.originAssetId); - return bal.free.toString(); + console.error('Unsupported token: ', token.originAssetId); + return '0'; } + const bal = await api.query.tokens.accounts(address, currencyId); + return bal.free.toString(); } catch (e) { console.error(e); return '0'; From 7f3eb7c2d756a147e3ac3d4feeccb2a545879441 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Tue, 2 Jul 2024 18:56:17 +0800 Subject: [PATCH 11/15] remove EURC --- src/assets/img/token/EURC.svg | 17 ----------------- src/modules/xcm/tokens/index.ts | 10 ---------- .../xcm/PendulumXcmRepository.ts | 12 ------------ 3 files changed, 39 deletions(-) delete mode 100644 src/assets/img/token/EURC.svg diff --git a/src/assets/img/token/EURC.svg b/src/assets/img/token/EURC.svg deleted file mode 100644 index d9c1163ff..000000000 --- a/src/assets/img/token/EURC.svg +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/modules/xcm/tokens/index.ts b/src/modules/xcm/tokens/index.ts index 0b92b48ca..cdf6d63a5 100644 --- a/src/modules/xcm/tokens/index.ts +++ b/src/modules/xcm/tokens/index.ts @@ -185,16 +185,6 @@ export const xcmToken = { originChain: Chain.PENDULUM, minBridgeAmount: '0.1', }, - { - symbol: 'mEURC.s', - isNativeToken: false, - assetId: '18446744073709551636', - originAssetId: 'mEURC.s', - logo: require('/src/assets/img/token/EURC.svg'), - isXcmCompatible: true, - originChain: Chain.PENDULUM, - minBridgeAmount: '0.1', - }, ], [endpointKey.SHIDEN]: [ { diff --git a/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts b/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts index 98a1aa61b..a87efcd0c 100644 --- a/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts +++ b/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts @@ -15,14 +15,6 @@ import { decodeAddress } from '@polkadot/util-crypto'; const PEN = 'Native'; const XLM = { Stellar: 'StellarNative' }; -const StellarEURCMykobo = { - Stellar: { - AlphaNum4: { - code: 'EURC', - issuer: '0x2112ee863867e4e219fe254c0918b00bc9ea400775bfc3ab4430971ce505877c', - }, - }, -}; export class PendulumXcmRepository extends XcmRepository { constructor() { @@ -48,8 +40,6 @@ export class PendulumXcmRepository extends XcmRepository { tokenData = PEN; } else if (token.originAssetId === 'XLM.s') { tokenData = XLM; - } else if (token.originAssetId === 'mEURC.s') { - tokenData = StellarEURCMykobo; } const destination = { V3: { @@ -99,8 +89,6 @@ export class PendulumXcmRepository extends XcmRepository { let currencyId; if (token.originAssetId === 'XLM.s') { currencyId = XLM; - } else if (token.originAssetId === 'mEURC.s') { - currencyId = StellarEURCMykobo; } else { console.error('Unsupported token: ', token.originAssetId); return '0'; From 079ec0d61c6f12d39582a41ad67999da59fc6c1a Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Tue, 2 Jul 2024 19:37:51 +0800 Subject: [PATCH 12/15] remove console --- src/v2/repositories/implementations/XcmRepository.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/v2/repositories/implementations/XcmRepository.ts b/src/v2/repositories/implementations/XcmRepository.ts index dc141d11b..b2373e5bc 100644 --- a/src/v2/repositories/implementations/XcmRepository.ts +++ b/src/v2/repositories/implementations/XcmRepository.ts @@ -275,7 +275,6 @@ export class XcmRepository implements IXcmRepository { ): Promise { const api = await this.apiFactory.get(endpoint); const call = api.tx[extrinsic][method](...args); - console.log('build call: ', call.toHex(false)); if (call) { return call; } From ec960db241156954f602d03f9ed51264dd559c61 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Thu, 18 Jul 2024 15:47:45 +0800 Subject: [PATCH 13/15] xcPEN instead of PEN --- src/modules/xcm/tokens/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/xcm/tokens/index.ts b/src/modules/xcm/tokens/index.ts index a3a465b8f..1903766fb 100644 --- a/src/modules/xcm/tokens/index.ts +++ b/src/modules/xcm/tokens/index.ts @@ -176,7 +176,7 @@ export const xcmToken = { minBridgeAmount: '5', }, { - symbol: 'PEN', + symbol: 'xcPEN', isNativeToken: true, assetId: '18446744073709551634', originAssetId: 'PEN', From 854d115a1de6c2fe62108e7121cc267acaa5fe59 Mon Sep 17 00:00:00 2001 From: Marcel Ebert Date: Mon, 22 Jul 2024 20:33:22 +0200 Subject: [PATCH 14/15] Add refactoring --- .../xcm/PendulumXcmRepository.ts | 45 ++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts b/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts index a87efcd0c..b1510ded5 100644 --- a/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts +++ b/src/v2/repositories/implementations/xcm/PendulumXcmRepository.ts @@ -9,12 +9,11 @@ import { XcmChain } from 'src/v2/models/XcmModels'; import { TokensAccounts } from 'src/v2/repositories/implementations/xcm/AcalaXcmRepository'; import { decodeAddress } from '@polkadot/util-crypto'; -/** - * Used to transfer assets from Pendulum - */ - -const PEN = 'Native'; -const XLM = { Stellar: 'StellarNative' }; +// Mapping object for token IDs +const TOKEN_IDS: Record = { + PEN: 'Native', + 'XLM.s': { Stellar: 'StellarNative' }, +}; export class PendulumXcmRepository extends XcmRepository { constructor() { @@ -35,14 +34,20 @@ export class PendulumXcmRepository extends XcmRepository { if (!to.parachainId) { throw `Parachain id for ${to.name} is not defined`; } - var tokenData; - if (token.originAssetId === 'PEN') { - tokenData = PEN; - } else if (token.originAssetId === 'XLM.s') { - tokenData = XLM; + + const tokenData = TOKEN_IDS[token.originAssetId]; + if (!tokenData) { + throw `Token name for ${token.originAssetId} is not defined`; } + + const version = 'V3'; + + const AccountId32 = { + id: decodeAddress(recipientAddress), + }; + const destination = { - V3: { + [version]: { parents: '1', interior: { X2: [ @@ -50,9 +55,7 @@ export class PendulumXcmRepository extends XcmRepository { Parachain: to.parachainId, }, { - AccountId32: { - id: decodeAddress(recipientAddress), - }, + AccountId32, }, ], }, @@ -84,13 +87,13 @@ export class PendulumXcmRepository extends XcmRepository { try { if (isNativeToken) { - return (await this.getNativeBalance(address, chain, endpoint)).toString(); + const nativeBalance = await this.getNativeBalance(address, chain, endpoint); + return nativeBalance.toString(); } - let currencyId; - if (token.originAssetId === 'XLM.s') { - currencyId = XLM; - } else { - console.error('Unsupported token: ', token.originAssetId); + + const currencyId = TOKEN_IDS[token.originAssetId]; + if (!currencyId) { + console.error(`Token name for ${token.originAssetId} is not defined`); return '0'; } const bal = await api.query.tokens.accounts(address, currencyId); From 3e7e676082aa50d1496c7672c4f2c21875216888 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Thu, 25 Jul 2024 22:46:51 +0800 Subject: [PATCH 15/15] changing minimum amount --- src/modules/xcm/tokens/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/xcm/tokens/index.ts b/src/modules/xcm/tokens/index.ts index 1903766fb..34b6b6e16 100644 --- a/src/modules/xcm/tokens/index.ts +++ b/src/modules/xcm/tokens/index.ts @@ -183,7 +183,7 @@ export const xcmToken = { logo: require('/src/assets/img/token/PEN.svg'), isXcmCompatible: true, originChain: Chain.PENDULUM, - minBridgeAmount: '0.1', + minBridgeAmount: '2', }, { symbol: 'XLM.s', @@ -193,7 +193,7 @@ export const xcmToken = { logo: require('/src/assets/img/token/XLM.svg'), isXcmCompatible: true, originChain: Chain.PENDULUM, - minBridgeAmount: '0.1', + minBridgeAmount: '1', }, ], [endpointKey.SHIDEN]: [