From d52c7538b25b90358438180984064f0850187301 Mon Sep 17 00:00:00 2001 From: mmaurello <93129175+mmaurello@users.noreply.github.com> Date: Fri, 14 Oct 2022 13:37:20 +0200 Subject: [PATCH] Darwinia integration for Moonbeam, fix for Crab in Moonriver (#33) --- .../config/src/config/moonbeam/assets/ring.ts | 38 +++++++++++++++++++ .../src/config/moonbeam/moonbeam.assets.ts | 6 +++ .../src/config/moonbeam/moonbeam.chains.ts | 8 ++++ .../config/src/config/moonbeam/moonbeam.ts | 2 + .../src/config/moonriver/assets/crab.ts | 4 +- .../src/config/moonriver/moonriver.chains.ts | 6 +-- packages/config/src/constants/assets.ts | 1 + packages/config/src/constants/chains.ts | 1 + 8 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 packages/config/src/config/moonbeam/assets/ring.ts diff --git a/packages/config/src/config/moonbeam/assets/ring.ts b/packages/config/src/config/moonbeam/assets/ring.ts new file mode 100644 index 00000000..c5350f6c --- /dev/null +++ b/packages/config/src/config/moonbeam/assets/ring.ts @@ -0,0 +1,38 @@ +import { AssetSymbol, ChainKey } from '../../../constants'; +import { PolkadotXcmExtrinsicSuccessEvent } from '../../../extrinsic'; +import { + assets, + balance, + chains, + extrinsic, + withdraw, +} from '../moonbeam.common'; +import { MoonbeamXcmConfig } from '../moonbeam.interfaces'; + +const asset = assets[AssetSymbol.RING]; +const origin = chains[ChainKey.Darwinia]; + +export const RING: MoonbeamXcmConfig = { + asset, + origin, + deposit: { + [origin.key]: { + origin, + balance: balance.system(), + extrinsic: extrinsic + .polkadotXcm() + .limitedReserveTransferAssets() + .successEvent(PolkadotXcmExtrinsicSuccessEvent.Attempted) + .origin(origin) + .V1() + .X1(), + }, + }, + withdraw: { + [origin.key]: withdraw.xTokens({ + balance: balance.system(), + destination: origin, + feePerWeight: 1_000_000_000, + }), + }, +}; diff --git a/packages/config/src/config/moonbeam/moonbeam.assets.ts b/packages/config/src/config/moonbeam/moonbeam.assets.ts index 21773fbd..c0aaf1b4 100644 --- a/packages/config/src/config/moonbeam/moonbeam.assets.ts +++ b/packages/config/src/config/moonbeam/moonbeam.assets.ts @@ -12,6 +12,7 @@ export const MOONBEAM_ASSETS = [ AssetSymbol.INTR, AssetSymbol.PARA, AssetSymbol.PHA, + AssetSymbol.RING, AssetSymbol.USDT, ]; @@ -62,6 +63,11 @@ export const MOONBEAM_ASSETS_MAP: AssetsMap = { erc20Id: '0xffffffff63d24ecc8eb8a7b5d0803e900f7b6ced', originSymbol: AssetSymbol.PHA, }, + [AssetSymbol.RING]: { + id: '125699734534028342599692732320197985871', + erc20Id: '0xffffffff5e90e365edca87fb4c8306df1e91464f', + originSymbol: AssetSymbol.RING, + }, [AssetSymbol.USDT]: { id: '311091173110107856861649819128533077277', erc20Id: '0xffffffffea09fb06d082fd1275cd48b191cbcd1d', diff --git a/packages/config/src/config/moonbeam/moonbeam.chains.ts b/packages/config/src/config/moonbeam/moonbeam.chains.ts index 1008d284..3c38dbb6 100644 --- a/packages/config/src/config/moonbeam/moonbeam.chains.ts +++ b/packages/config/src/config/moonbeam/moonbeam.chains.ts @@ -5,6 +5,7 @@ import { MoonbeamChains } from './moonbeam.interfaces'; export const MOONBEAM_CHAINS = [ ChainKey.Acala, ChainKey.Astar, + ChainKey.Darwinia, ChainKey.Interlay, ChainKey.Parallel, ChainKey.Phala, @@ -30,6 +31,13 @@ export const MOONBEAM_CHAINS_MAP: ChainsMap = { moonAssetId: 18446744073709551619n, palletInstance: 10, }, + [ChainKey.Darwinia]: { + key: ChainKey.Darwinia, + name: 'Darwinia', + ws: 'wss://parachain-rpc.darwinia.network', + weight: 1_000_000_000, + parachainId: 2046, + }, [ChainKey.Interlay]: { key: ChainKey.Interlay, name: 'Interlay', diff --git a/packages/config/src/config/moonbeam/moonbeam.ts b/packages/config/src/config/moonbeam/moonbeam.ts index 280435b4..cdcbfb26 100644 --- a/packages/config/src/config/moonbeam/moonbeam.ts +++ b/packages/config/src/config/moonbeam/moonbeam.ts @@ -10,6 +10,7 @@ import { IBTC } from './assets/ibtc'; import { INTR } from './assets/intr'; import { PARA } from './assets/para'; import { PHA } from './assets/pha'; +import { RING } from './assets/ring'; import { USDT } from './assets/usdt'; export const MOONBEAM_CONFIGS: MoonbeamXcmConfigs = { @@ -22,5 +23,6 @@ export const MOONBEAM_CONFIGS: MoonbeamXcmConfigs = { [AssetSymbol.INTR]: INTR, [AssetSymbol.PARA]: PARA, [AssetSymbol.PHA]: PHA, + [AssetSymbol.RING]: RING, [AssetSymbol.USDT]: USDT, }; diff --git a/packages/config/src/config/moonriver/assets/crab.ts b/packages/config/src/config/moonriver/assets/crab.ts index f08dde71..28765155 100644 --- a/packages/config/src/config/moonriver/assets/crab.ts +++ b/packages/config/src/config/moonriver/assets/crab.ts @@ -10,7 +10,7 @@ import { import { MoonriverXcmConfig } from '../moonriver.interfaces'; const asset = assets[AssetSymbol.CRAB]; -const origin = chains[ChainKey.Darwinia]; +const origin = chains[ChainKey.Crab]; export const CRAB: MoonriverXcmConfig = { asset, @@ -32,7 +32,7 @@ export const CRAB: MoonriverXcmConfig = { [origin.key]: withdraw.xTokens({ balance: balance.system(), destination: origin, - feePerWeight: 8, + feePerWeight: 1_000_000_000, }), }, }; diff --git a/packages/config/src/config/moonriver/moonriver.chains.ts b/packages/config/src/config/moonriver/moonriver.chains.ts index 4598ce1b..d46b2b9c 100644 --- a/packages/config/src/config/moonriver/moonriver.chains.ts +++ b/packages/config/src/config/moonriver/moonriver.chains.ts @@ -6,7 +6,7 @@ export const MOONRIVER_CHAINS = [ ChainKey.Bifrost, ChainKey.Calamari, ChainKey.CrustShadow, - ChainKey.Darwinia, + ChainKey.Crab, ChainKey.Integritee, ChainKey.Karura, ChainKey.Khala, @@ -40,8 +40,8 @@ export const MOONRIVER_CHAINS_MAP: ChainsMap = { weight: 1_000_000_000, parachainId: 2012, }, - [ChainKey.Darwinia]: { - key: ChainKey.Darwinia, + [ChainKey.Crab]: { + key: ChainKey.Crab, name: 'Darwinia Crab', ws: 'wss://crab-parachain-rpc.darwinia.network', weight: 1_000_000_000, diff --git a/packages/config/src/constants/assets.ts b/packages/config/src/constants/assets.ts index baabfca3..90da4d2a 100644 --- a/packages/config/src/constants/assets.ts +++ b/packages/config/src/constants/assets.ts @@ -23,6 +23,7 @@ export enum AssetSymbol { MOVR = 'MOVR', PARA = 'PARA', PHA = 'PHA', + RING = 'RING', RMRK = 'RMRK', SDN = 'SDN', TEER = 'TEER', diff --git a/packages/config/src/constants/chains.ts b/packages/config/src/constants/chains.ts index 63887dac..5f4ecce6 100644 --- a/packages/config/src/constants/chains.ts +++ b/packages/config/src/constants/chains.ts @@ -42,6 +42,7 @@ export enum ChainKey { Bifrost = 'Bifrost', Calamari = 'Calamari', CloverAlphanet = 'CloverAlphanet', + Crab = 'Crab', CrustShadow = 'CrustShadow', CrustShadowAlphanet = 'CrustShadowAlphanet', Darwinia = 'Darwinia',