From 8c16492f2cceef0e1ebc8a9ba70452e644efd135 Mon Sep 17 00:00:00 2001 From: mmaurello <93129175+mmaurello@users.noreply.github.com> Date: Fri, 13 Oct 2023 11:16:51 +0200 Subject: [PATCH] FIL integration with moonbeam and eq fix with xcm v3 (#144) * FIL integration with moonbeam and eq fix with xcm v3 * fix snapshot * add changeset --- .changeset/neat-buses-wash.md | 7 +++++++ .../__snapshots__/eqBalances.test.ts.snap | 4 ++-- .../extrinsic/pallets/eqBalances/eqBalances.ts | 4 ++-- packages/config/src/assets.ts | 6 ++++++ packages/config/src/chains.ts | 10 ++++++++++ packages/config/src/configs/bifrostPolkadot.ts | 18 +++++++++++++++++- packages/config/src/configs/moonbeam.ts | 16 ++++++++++++++++ packages/sdk/src/polkadot/PolkadotService.ts | 8 ++++++-- 8 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 .changeset/neat-buses-wash.md diff --git a/.changeset/neat-buses-wash.md b/.changeset/neat-buses-wash.md new file mode 100644 index 00000000..697b0502 --- /dev/null +++ b/.changeset/neat-buses-wash.md @@ -0,0 +1,7 @@ +--- +'@moonbeam-network/xcm-builder': patch +'@moonbeam-network/xcm-config': patch +'@moonbeam-network/xcm-sdk': patch +--- + +FIL integration and EQ fix diff --git a/packages/builder/src/extrinsic/pallets/eqBalances/__snapshots__/eqBalances.test.ts.snap b/packages/builder/src/extrinsic/pallets/eqBalances/__snapshots__/eqBalances.test.ts.snap index ed701eb4..4412b23f 100644 --- a/packages/builder/src/extrinsic/pallets/eqBalances/__snapshots__/eqBalances.test.ts.snap +++ b/packages/builder/src/extrinsic/pallets/eqBalances/__snapshots__/eqBalances.test.ts.snap @@ -28,7 +28,7 @@ exports[`eqBalances transferXcm should get correct arguments 1`] = ` { "AccountKey20": { "key": "0xeF46c7649270C912704fB09B75097f6E32208b85", - "network": "Any", + "network": null, }, }, ], @@ -60,7 +60,7 @@ exports[`eqBalances xcmTransfer should get correct arguments 1`] = ` { "AccountKey20": { "key": "0xeF46c7649270C912704fB09B75097f6E32208b85", - "network": "Any", + "network": null, }, }, ], diff --git a/packages/builder/src/extrinsic/pallets/eqBalances/eqBalances.ts b/packages/builder/src/extrinsic/pallets/eqBalances/eqBalances.ts index 68753d34..b66df2db 100644 --- a/packages/builder/src/extrinsic/pallets/eqBalances/eqBalances.ts +++ b/packages/builder/src/extrinsic/pallets/eqBalances/eqBalances.ts @@ -29,7 +29,7 @@ export function eqBalances() { }, { AccountKey20: { - network: 'Any', + network: null, key: address, }, }, @@ -60,7 +60,7 @@ export function eqBalances() { }, { AccountKey20: { - network: 'Any', + network: null, key: address, }, }, diff --git a/packages/config/src/assets.ts b/packages/config/src/assets.ts index f3c01f66..cd0dd3bf 100644 --- a/packages/config/src/assets.ts +++ b/packages/config/src/assets.ts @@ -75,6 +75,11 @@ export const dai = new Asset({ originSymbol: 'DAI', }); +export const fil = new Asset({ + key: 'fil', + originSymbol: 'FIL', +}); + export const glmr = new Asset({ key: 'glmr', originSymbol: 'GLMR', @@ -280,6 +285,7 @@ export const assetsList: Asset[] = [ dot, eq, eqd, + fil, glmr, hdx, hko, diff --git a/packages/config/src/chains.ts b/packages/config/src/chains.ts index ff0c1b59..490119e4 100644 --- a/packages/config/src/chains.ts +++ b/packages/config/src/chains.ts @@ -20,6 +20,7 @@ import { dot, eq, eqd, + fil, glmr, hdx, hko, @@ -191,6 +192,10 @@ export const bifrostPolkadot = new Parachain({ asset: bnc, id: { Native: bnc.originSymbol }, }, + { + asset: fil, + id: { Token2: 4 }, + }, { asset: vdot, id: { VToken2: 0 }, @@ -792,6 +797,11 @@ export const moonbeam = new EvmParachain({ asset: eqd, id: '187224307232923873519830480073807488153', }, + { + asset: fil, + id: '0xfFFfFFFF6C57e17D210DF507c82807149fFd70B2', + metadataId: 0, // no metadata for ERC20 tokens + }, { asset: glmr, id: '0x0000000000000000000000000000000000000802', diff --git a/packages/config/src/configs/bifrostPolkadot.ts b/packages/config/src/configs/bifrostPolkadot.ts index 02b7e896..f7542e73 100644 --- a/packages/config/src/configs/bifrostPolkadot.ts +++ b/packages/config/src/configs/bifrostPolkadot.ts @@ -4,7 +4,7 @@ import { ExtrinsicBuilder, FeeBuilder, } from '@moonbeam-network/xcm-builder'; -import { bnc, glmr, vdot, vfil, vglmr } from '../assets'; +import { bnc, fil, glmr, vdot, vfil, vglmr } from '../assets'; import { bifrostPolkadot, moonbeam } from '../chains'; import { AssetConfig } from '../types/AssetConfig'; import { ChainConfig } from '../types/ChainConfig'; @@ -22,6 +22,22 @@ export const bifrostPolkadotConfig = new ChainConfig({ }, extrinsic: ExtrinsicBuilder().xTokens().transfer(), }), + new AssetConfig({ + asset: fil, + balance: BalanceBuilder().substrate().tokens().accounts(), + destination: moonbeam, + destinationFee: { + amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + asset: bnc, + balance: BalanceBuilder().substrate().system().account(), + }, + extrinsic: ExtrinsicBuilder().xTokens().transferMultiCurrencies(), + fee: { + asset: bnc, + balance: BalanceBuilder().substrate().system().account(), + }, + min: AssetMinBuilder().assetRegistry().currencyMetadatas(), + }), new AssetConfig({ asset: glmr, balance: BalanceBuilder().substrate().tokens().accounts(), diff --git a/packages/config/src/configs/moonbeam.ts b/packages/config/src/configs/moonbeam.ts index 2e3d3849..4638224c 100644 --- a/packages/config/src/configs/moonbeam.ts +++ b/packages/config/src/configs/moonbeam.ts @@ -9,6 +9,7 @@ import { dot, eq, eqd, + fil, glmr, hdx, ibtc, @@ -485,6 +486,21 @@ export const moonbeamConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), }, }), + new AssetConfig({ + asset: fil, + balance: BalanceBuilder().evm().erc20(), + contract: ContractBuilder().Xtokens().transfer(), + destination: bifrostPolkadot, + destinationFee: { + amount: 0.00000001, + asset: fil, + balance: BalanceBuilder().evm().erc20(), + }, + fee: { + asset: glmr, + balance: BalanceBuilder().substrate().system().account(), + }, + }), ], chain: moonbeam, }); diff --git a/packages/sdk/src/polkadot/PolkadotService.ts b/packages/sdk/src/polkadot/PolkadotService.ts index 01368451..1d2b7643 100644 --- a/packages/sdk/src/polkadot/PolkadotService.ts +++ b/packages/sdk/src/polkadot/PolkadotService.ts @@ -8,6 +8,7 @@ import { IConfigService, darwiniaPangoro, eq, + equilibrium, equilibriumAlphanet, paring, } from '@moonbeam-network/xcm-config'; @@ -71,9 +72,12 @@ export class PolkadotService { const symbol = this.api.registry.chainTokens.at(0); const key = symbol?.toString().toLowerCase(); - // TODO: Remove this once Equilibrium Alphanet is updated + // TODO: Remove this once Equilibrium is updated // or find better way if issue appears on other chains - if (key === 'token' && this.chain.key === equilibriumAlphanet.key) { + if ( + key === 'token' && + [equilibriumAlphanet.key, equilibrium.key].includes(this.chain.key) + ) { return eq; }