Skip to content

Commit

Permalink
FIL integration with moonbeam and eq fix with xcm v3
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaurello committed Oct 13, 2023
1 parent 02dafc0 commit 25b56ec
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function eqBalances() {
},
{
AccountKey20: {
network: 'Any',
network: null,
key: address,
},
},
Expand Down Expand Up @@ -60,7 +60,7 @@ export function eqBalances() {
},
{
AccountKey20: {
network: 'Any',
network: null,
key: address,
},
},
Expand Down
6 changes: 6 additions & 0 deletions packages/config/src/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -280,6 +285,7 @@ export const assetsList: Asset[] = [
dot,
eq,
eqd,
fil,
glmr,
hdx,
hko,
Expand Down
10 changes: 10 additions & 0 deletions packages/config/src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
dot,
eq,
eqd,
fil,
glmr,
hdx,
hko,
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -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',
Expand Down
18 changes: 17 additions & 1 deletion packages/config/src/configs/bifrostPolkadot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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(),
Expand Down
16 changes: 16 additions & 0 deletions packages/config/src/configs/moonbeam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
dot,
eq,
eqd,
fil,
glmr,
hdx,
ibtc,
Expand Down Expand Up @@ -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,
});
8 changes: 6 additions & 2 deletions packages/sdk/src/polkadot/PolkadotService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
IConfigService,
darwiniaPangoro,
eq,
equilibrium,
equilibriumAlphanet,
paring,
} from '@moonbeam-network/xcm-config';
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 25b56ec

Please sign in to comment.