Skip to content

Commit

Permalink
LAOS alphanet integration initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaurello committed Jan 31, 2025
1 parent 555ea8b commit abaac98
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"ftmwh",
"fullnode",
"globalconsensus",
"gorengine",
"heiko",
"helikon",
"hydradx",
Expand All @@ -36,11 +37,13 @@
"kintsugi",
"kusama",
"kusd",
"laosalphanet",
"ldot",
"lefthook",
"liebi",
"litentry",
"mangata",
"maos",
"metadatas",
"mkdocs",
"mnemonic",
Expand Down
70 changes: 68 additions & 2 deletions packages/builder/src/extrinsic/pallets/polkadotXcm/polkadotXcm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export function polkadotXcm() {
const func = 'transferAssets';

return {
here: (): ExtrinsicConfigBuilder => ({
here: (parents = 0): ExtrinsicConfigBuilder => ({
build: (params) =>
new ExtrinsicConfig({
module: pallet,
Expand All @@ -210,7 +210,7 @@ export function polkadotXcm() {
asset: [
{
id: normalizeConcrete(version, {
parents: 1,
parents,
interior: 'Here',
}),
fun: {
Expand Down Expand Up @@ -274,6 +274,72 @@ export function polkadotXcm() {
transferAssetsUsingTypeAndThen: () => {
const func = 'transferAssetsUsingTypeAndThen';
return {
here: (): ExtrinsicConfigBuilder => ({
build: (params) =>
new ExtrinsicConfig({
module: pallet,
func,
getArgs: (extrinsicFunction) => {
const version = getExtrinsicArgumentVersion(extrinsicFunction);

return [
{
[version]: {
parents: 1,
interior: {
X1: [
{
Parachain: params.destination.parachainId,
},
],
},
},
},
{
[version]: [
{
id: {
parents: 0,
interior: 'Here',
},
fun: {
Fungible: params.asset.amount,
},
},
],
},
'LocalReserve',
{
[version]: {
parents: 0,
interior: 'Here',
},
},
'LocalReserve',
{
[version]: [
{
DepositAsset: {
assets: {
Wild: { AllCounted: 1 },
},
beneficiary: {
parents: 0,
interior: {
X1: [
getExtrinsicAccount(params.destinationAddress),
],
},
},
},
},
],
},
'Unlimited',
];
},
}),
}),
// TODO we could pass a parameter globalConsensus in the chain asset if we need a different one
globalConsensusEthereum: (): ExtrinsicConfigBuilder => ({
build: (params) =>
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 @@ -190,6 +190,11 @@ export const manta = new Asset({
originSymbol: 'MANTA',
});

export const maos = new Asset({
key: 'maos',
originSymbol: 'MAOS',
});

export const mgx = new Asset({
key: 'mgx',
originSymbol: 'MGX',
Expand Down Expand Up @@ -449,6 +454,7 @@ export const assetsList: Asset[] = [
ldot,
lit,
manta,
maos,
mgx,
movr,
neuro,
Expand Down
28 changes: 28 additions & 0 deletions packages/config/src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
ldot,
lit,
manta,
maos,
mgx,
movr,
neuro,
Expand Down Expand Up @@ -901,11 +902,30 @@ export const mantaParachain = new Parachain({
ws: ['wss://ws.manta.systems'],
});

export const laosAlphanet = new EvmParachain({
assets: [ChainAsset.fromAsset(maos, { decimals: 18 })],
ecosystem: Ecosystem.AlphanetRelay,
genesisHash:
'0x324e69fa1a64c0b3badec0016aca64878bc2f4b6146e6da26c7aaddee21947f7',
key: 'laos-alphanet',
name: 'Laos Alphanet',
id: 0, // TODO
isTestChain: true,
nativeAsset: maos,
parachainId: 4001,
rpc: 'https://rpc.laosalphanet.gorengine.com', // TODO
ss58Format: 42,
ws: ['wss://rpc.laosalphanet.gorengine.com'],
});

export const moonbaseAlpha = new EvmParachain({
assets: [
ChainAsset.fromAsset(alan, {
address: '0x9133c5a22024118804089f1fB752b7B2ce2a6351',
decimals: 18,
ids: {
palletInstance: 48,
},
}),
ChainAsset.fromAsset(ampe, {
address: '0xfFfFfffF7fee8415e1c2AC3A15C48D3546B95e16',
Expand Down Expand Up @@ -936,6 +956,13 @@ export const moonbaseAlpha = new EvmParachain({
id: '65216491554813189869575508812319036608',
},
}),
ChainAsset.fromAsset(maos, {
address: '0xffffffff06a14960bddc8610d0e694d39a3c682e',
decimals: 18,
ids: {
palletInstance: 48,
},
}),
ChainAsset.fromAsset(otp, {
address: '0xFfffffFfB3229c8E7657eABEA704d5e75246e544',
decimals: 12,
Expand Down Expand Up @@ -2301,6 +2328,7 @@ export const chainsList: AnyChain[] = [
kintsugi,
kusama,
kusamaAssetHub,
laosAlphanet,
mangataKusama,
mantaParachain,
moonbaseAlpha,
Expand Down
2 changes: 2 additions & 0 deletions packages/config/src/xcm-configs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { khalaRouts } from './khala';
import { kintsugiRoutes } from './kintsugi';
import { kusamaRoutes } from './kusama';
import { kusamaAssetHubRoutes } from './kusamaAssetHub';
import { laosAlphanetRoutes } from './laosAlphanet';
import { mangataKusamaRoutes } from './mangataKusama';
import { mantaParachainRoutes } from './mantaParachain';
import { moonbaseAlphaRoutes } from './moonbaseAlpha';
Expand Down Expand Up @@ -57,6 +58,7 @@ export const xcmRoutesList: ChainRoutes[] = [
crustShadowRoutes,
darwiniaRoutes,
darwiniaCrabRoutes,
laosAlphanetRoutes,
hydrationRoutes,
hydrationAlphanetRoutes,
integriteeRoutes,
Expand Down
37 changes: 37 additions & 0 deletions packages/config/src/xcm-configs/laosAlphanet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {
BalanceBuilder,
ExtrinsicBuilder,
} from '@moonbeam-network/xcm-builder';
import { maos } from '../assets';
import { laosAlphanet, moonbaseAlpha } from '../chains';
import { ChainRoutes } from '../types/ChainRoutes';

export const laosAlphanetRoutes = new ChainRoutes({
chain: laosAlphanet,
routes: [
{
source: {
asset: maos,
balance: BalanceBuilder().substrate().system().account(),
},
destination: {
asset: maos,
chain: moonbaseAlpha,
balance: BalanceBuilder().evm().erc20(),
fee: {
// TODO current configuration for xcmPaymentApi is not compatible with how the MAOS asset version Id works in Moonbase
// using fixed fee until future refactoring of xcmPaymentApi for generic chains
amount: 0.1,
// amount: FeeBuilder()
// .xcmPaymentApi()
// .xcmPaymentFee({ isAssetReserveChain: false }),
asset: maos,
},
},
extrinsic: ExtrinsicBuilder()
.polkadotXcm()
.transferAssetsUsingTypeAndThen()
.here(),
},
],
});
18 changes: 18 additions & 0 deletions packages/config/src/xcm-configs/moonbaseAlpha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
dev,
ftmwh,
hdx,
maos,
otp,
pica,
tt1,
Expand All @@ -22,6 +23,7 @@ import {
alphanetAssetHub,
alphanetRelay,
hydrationAlphanet,
laosAlphanet,
moonbaseAlpha,
moonbaseBeta,
originTrailAlphanet,
Expand Down Expand Up @@ -519,5 +521,21 @@ export const moonbaseAlphaRoutes = new ChainRoutes({
},
contract: ContractBuilder().Xtokens().transferWithEvmTo32(),
},
{
source: {
asset: maos,
balance: BalanceBuilder().evm().erc20(),
},
destination: {
asset: maos,
chain: laosAlphanet,
balance: BalanceBuilder().substrate().system().account(),
fee: {
amount: 0.1,
asset: maos,
},
},
contract: ContractBuilder().Xtokens().transfer(),
},
],
});
2 changes: 1 addition & 1 deletion packages/config/src/xcm-configs/polkadotAssetHub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const polkadotAssetHubRoutes = new ChainRoutes({
asset: dot,
},
},
extrinsic: ExtrinsicBuilder().polkadotXcm().transferAssets().here(),
extrinsic: ExtrinsicBuilder().polkadotXcm().transferAssets().here(1),
},
{
source: {
Expand Down

0 comments on commit abaac98

Please sign in to comment.