diff --git a/packages/networks/src/chains/hydraDX.ts b/packages/networks/src/chains/hydration.ts similarity index 75% rename from packages/networks/src/chains/hydraDX.ts rename to packages/networks/src/chains/hydration.ts index 010bb306..2bbc4dad 100644 --- a/packages/networks/src/chains/hydraDX.ts +++ b/packages/networks/src/chains/hydration.ts @@ -2,9 +2,10 @@ import { defaultAccounts } from '../defaultAccounts.js' import { defineChain } from '../defineChain.js' const custom = { - hydraDX: { + hydration: { dai: 2, relayToken: 5, + glmr: 16, }, basilisk: { bsx: 0, @@ -13,7 +14,7 @@ const custom = { }, } -const getInitStorages = (config: typeof custom.hydraDX | typeof custom.basilisk) => ({ +const getInitStorages = (config: typeof custom.hydration | typeof custom.basilisk) => ({ System: { Account: [[[defaultAccounts.alice.address], { providers: 1, data: { free: 10n ** 18n } }]], }, @@ -25,12 +26,12 @@ const getInitStorages = (config: typeof custom.hydraDX | typeof custom.basilisk) }, }) -export const hydraDX = defineChain({ - name: 'hydraDX', +export const hydration = defineChain({ + name: 'hydration', paraId: 2034, endpoint: 'wss://rpc.hydradx.cloud', - custom: custom.hydraDX, - initStorages: getInitStorages(custom.hydraDX), + custom: custom.hydration, + initStorages: getInitStorages(custom.hydration), }) export const basilisk = defineChain({ diff --git a/packages/networks/src/chains/index.ts b/packages/networks/src/chains/index.ts index 734d7488..c7b4f9f0 100644 --- a/packages/networks/src/chains/index.ts +++ b/packages/networks/src/chains/index.ts @@ -1,6 +1,6 @@ export * from './acala.js' export * from './assethub.js' export * from './astar.js' -export * from './hydraDX.js' +export * from './hydration.js' export * from './moonbeam.js' export * from './polkadot.js' diff --git a/packages/polkadot/src/__snapshots__/hydration.moonbeam.test.ts.snap b/packages/polkadot/src/__snapshots__/hydration.moonbeam.test.ts.snap new file mode 100644 index 00000000..e8117aad --- /dev/null +++ b/packages/polkadot/src/__snapshots__/hydration.moonbeam.test.ts.snap @@ -0,0 +1,621 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`hydration & moonbeam > hydration transfer DOT to moonbeam > balance on from chain 1`] = ` +{ + "free": 998000000000000, + "frozen": 0, + "reserved": 0, +} +`; + +exports[`hydration & moonbeam > hydration transfer DOT to moonbeam > balance on to chain 1`] = ` +{ + "balance": "(rounded 2000000000000)", + "extra": null, + "reason": { + "sufficient": null, + }, + "status": "Liquid", +} +`; + +exports[`hydration & moonbeam > hydration transfer DOT to moonbeam > from chain ump messages 1`] = ` +[ + { + "v3": [ + { + "withdrawAsset": [ + { + "fun": { + "fungible": 2000000000000, + }, + "id": { + "concrete": { + "interior": { + "here": null, + }, + "parents": 0, + }, + }, + }, + ], + }, + { + "clearOrigin": null, + }, + { + "buyExecution": { + "fees": { + "fun": { + "fungible": 1000000000000, + }, + "id": { + "concrete": { + "interior": { + "here": null, + }, + "parents": 0, + }, + }, + }, + "weightLimit": { + "unlimited": null, + }, + }, + }, + { + "depositReserveAsset": { + "assets": { + "wild": { + "allCounted": 1, + }, + }, + "dest": { + "interior": { + "x1": { + "parachain": 2004, + }, + }, + "parents": 0, + }, + "xcm": [ + { + "buyExecution": { + "fees": { + "fun": { + "fungible": 1000000000000, + }, + "id": { + "concrete": { + "interior": { + "here": null, + }, + "parents": 1, + }, + }, + }, + "weightLimit": { + "unlimited": null, + }, + }, + }, + { + "depositAsset": { + "assets": { + "wild": { + "allCounted": 1, + }, + }, + "beneficiary": { + "interior": { + "x1": { + "accountKey20": { + "key": "0xf24ff3a9cf04c71dbc94d0b566f7a27b94566cac", + "network": null, + }, + }, + }, + "parents": 0, + }, + }, + }, + ], + }, + }, + ], + }, +] +`; + +exports[`hydration & moonbeam > hydration transfer DOT to moonbeam > route chain xcm events 1`] = ` +[ + { + "data": { + "id": "(hash)", + "origin": { + "Ump": { + "Para": "(rounded 2000)", + }, + }, + "success": true, + "weightUsed": { + "proofSize": "(rounded 7200)", + "refTime": "(rounded 540000000)", + }, + }, + "method": "Processed", + "section": "messageQueue", + }, +] +`; + +exports[`hydration & moonbeam > hydration transfer DOT to moonbeam > to chain xcm events 1`] = ` +[ + { + "data": { + "id": "(hash)", + "origin": "Parent", + "success": true, + "weightUsed": { + "proofSize": "(rounded 26000)", + "refTime": "(rounded 690000000)", + }, + }, + "method": "Processed", + "section": "messageQueue", + }, +] +`; + +exports[`hydration & moonbeam > hydration transfer DOT to moonbeam > tx events 1`] = ` +[ + { + "data": { + "assets": [ + { + "fun": { + "Fungible": 2000000000000, + }, + "id": { + "interior": "Here", + "parents": 1, + }, + }, + ], + "dest": { + "interior": { + "X2": [ + { + "Parachain": "(rounded 2000)", + }, + { + "AccountKey20": { + "key": "0xf24ff3a9cf04c71dbc94d0b566f7a27b94566cac", + "network": null, + }, + }, + ], + }, + "parents": 1, + }, + "fee": { + "fun": { + "Fungible": 2000000000000, + }, + "id": { + "interior": "Here", + "parents": 1, + }, + }, + "sender": "7Lh1DEaxk8TNVU7snC3UkSv7N7NHb7BUuEkYZBwrzfrPNQE3", + }, + "method": "TransferredAssets", + "section": "xTokens", + }, +] +`; + +exports[`hydration & moonbeam > hydration transfer GLMR to moonbeam > balance on from chain 1`] = ` +{ + "free": 4.98e+22, + "frozen": 0, + "reserved": 0, +} +`; + +exports[`hydration & moonbeam > hydration transfer GLMR to moonbeam > balance on to chain 1`] = ` +{ + "consumers": 0, + "data": { + "flags": "0x80000000000000000000000000000000", + "free": "(rounded 200000000000000000000)", + "frozen": 0, + "reserved": 0, + }, + "nonce": 1, + "providers": 1, + "sufficients": 0, +} +`; + +exports[`hydration & moonbeam > hydration transfer GLMR to moonbeam > from chain hrmp messages 1`] = ` +[ + { + "data": [ + "ConcatenatedVersionedXcm", + { + "v3": [ + { + "withdrawAsset": [ + { + "fun": { + "fungible": "0x000000000000000ad78ebc5ac6200000", + }, + "id": { + "concrete": { + "interior": { + "x1": { + "palletInstance": 10, + }, + }, + "parents": 0, + }, + }, + }, + ], + }, + { + "clearOrigin": null, + }, + { + "buyExecution": { + "fees": { + "fun": { + "fungible": "0x000000000000000ad78ebc5ac6200000", + }, + "id": { + "concrete": { + "interior": { + "x1": { + "palletInstance": 10, + }, + }, + "parents": 0, + }, + }, + }, + "weightLimit": { + "unlimited": null, + }, + }, + }, + { + "depositAsset": { + "assets": { + "wild": { + "allCounted": 1, + }, + }, + "beneficiary": { + "interior": { + "x1": { + "accountKey20": { + "key": "0x3cd0a705a2dc65e5b1e1205896baa2be8a07c6e0", + "network": null, + }, + }, + }, + "parents": 0, + }, + }, + }, + ], + }, + ], + "recipient": 2004, + }, +] +`; + +exports[`hydration & moonbeam > hydration transfer GLMR to moonbeam > route chain xcm events 1`] = `[]`; + +exports[`hydration & moonbeam > hydration transfer GLMR to moonbeam > to chain xcm events 1`] = ` +[ + { + "data": { + "id": "(hash)", + "origin": { + "Sibling": "(rounded 2000)", + }, + "success": true, + "weightUsed": { + "proofSize": "(rounded 34000)", + "refTime": "(rounded 690000000)", + }, + }, + "method": "Processed", + "section": "messageQueue", + }, +] +`; + +exports[`hydration & moonbeam > hydration transfer GLMR to moonbeam > tx events 1`] = ` +[ + { + "data": { + "assets": [ + { + "fun": { + "Fungible": 200000000000000000000, + }, + "id": { + "interior": { + "X2": [ + { + "Parachain": "(rounded 2000)", + }, + { + "PalletInstance": 10, + }, + ], + }, + "parents": 1, + }, + }, + ], + "dest": { + "interior": { + "X2": [ + { + "Parachain": "(rounded 2000)", + }, + { + "AccountKey20": { + "key": "0x3cd0a705a2dc65e5b1e1205896baa2be8a07c6e0", + "network": null, + }, + }, + ], + }, + "parents": 1, + }, + "fee": { + "fun": { + "Fungible": 200000000000000000000, + }, + "id": { + "interior": { + "X2": [ + { + "Parachain": "(rounded 2000)", + }, + { + "PalletInstance": 10, + }, + ], + }, + "parents": 1, + }, + }, + "sender": "7Lh1DEaxk8TNVU7snC3UkSv7N7NHb7BUuEkYZBwrzfrPNQE3", + }, + "method": "TransferredAssets", + "section": "xTokens", + }, +] +`; + +exports[`hydration & moonbeam > moonbeam transfer DOT to hydration > balance on from chain 1`] = ` +{ + "balance": 9980000000000, + "extra": null, + "reason": { + "consumer": null, + }, + "status": "Liquid", +} +`; + +exports[`hydration & moonbeam > moonbeam transfer DOT to hydration > balance on to chain 1`] = ` +{ + "free": "(rounded 19600000000)", + "frozen": 0, + "reserved": 0, +} +`; + +exports[`hydration & moonbeam > moonbeam transfer DOT to hydration > from chain ump messages 1`] = ` +[ + { + "v3": [ + { + "withdrawAsset": [ + { + "fun": { + "fungible": 20000000000, + }, + "id": { + "concrete": { + "interior": { + "here": null, + }, + "parents": 0, + }, + }, + }, + ], + }, + { + "clearOrigin": null, + }, + { + "buyExecution": { + "fees": { + "fun": { + "fungible": 10000000000, + }, + "id": { + "concrete": { + "interior": { + "here": null, + }, + "parents": 0, + }, + }, + }, + "weightLimit": { + "unlimited": null, + }, + }, + }, + { + "depositReserveAsset": { + "assets": { + "wild": { + "allCounted": 1, + }, + }, + "dest": { + "interior": { + "x1": { + "parachain": 2034, + }, + }, + "parents": 0, + }, + "xcm": [ + { + "buyExecution": { + "fees": { + "fun": { + "fungible": 10000000000, + }, + "id": { + "concrete": { + "interior": { + "here": null, + }, + "parents": 1, + }, + }, + }, + "weightLimit": { + "unlimited": null, + }, + }, + }, + { + "depositAsset": { + "assets": { + "wild": { + "allCounted": 1, + }, + }, + "beneficiary": { + "interior": { + "x1": { + "accountId32": { + "id": "0xd17c2d7823ebf260fd138f2d7e27d114c0145d968b5ff5006125f2414fadae69", + "network": null, + }, + }, + }, + "parents": 0, + }, + }, + }, + ], + }, + }, + ], + }, +] +`; + +exports[`hydration & moonbeam > moonbeam transfer DOT to hydration > route chain xcm events 1`] = ` +[ + { + "data": { + "id": "(hash)", + "origin": { + "Ump": { + "Para": "(rounded 2000)", + }, + }, + "success": true, + "weightUsed": { + "proofSize": "(rounded 7200)", + "refTime": "(rounded 540000000)", + }, + }, + "method": "Processed", + "section": "messageQueue", + }, +] +`; + +exports[`hydration & moonbeam > moonbeam transfer DOT to hydration > to chain xcm events 1`] = ` +[ + { + "data": { + "id": "(hash)", + "origin": "Parent", + "success": true, + "weightUsed": { + "proofSize": 0, + "refTime": 500000000, + }, + }, + "method": "Processed", + "section": "messageQueue", + }, +] +`; + +exports[`hydration & moonbeam > moonbeam transfer DOT to hydration > tx events 1`] = ` +[ + { + "data": { + "assets": [ + { + "fun": { + "Fungible": 20000000000, + }, + "id": { + "interior": "Here", + "parents": 1, + }, + }, + ], + "dest": { + "interior": { + "X2": [ + { + "Parachain": "(rounded 2000)", + }, + { + "AccountId32": { + "id": "(hash)", + "network": null, + }, + }, + ], + }, + "parents": 1, + }, + "fee": { + "fun": { + "Fungible": 20000000000, + }, + "id": { + "interior": "Here", + "parents": 1, + }, + }, + "sender": "0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac", + }, + "method": "TransferredAssets", + "section": "xTokens", + }, +] +`; diff --git a/packages/polkadot/src/hydration.moonbeam.test.ts b/packages/polkadot/src/hydration.moonbeam.test.ts new file mode 100644 index 00000000..c8619076 --- /dev/null +++ b/packages/polkadot/src/hydration.moonbeam.test.ts @@ -0,0 +1,75 @@ +import { describe } from 'vitest' + +import { defaultAccounts } from '@e2e-test/networks' +import { hydration, moonbeam, polkadot } from '@e2e-test/networks/chains' +import { query, tx } from '@e2e-test/shared/api' +import { runXtokenstHorizontal } from '@e2e-test/shared/xcm' +import { setupNetworks } from '@e2e-test/shared' + +describe('hydration & moonbeam', async () => { + const [hydrationClient, moonbeamClient, polkadotClient] = await setupNetworks(hydration, moonbeam, polkadot) + + const hydrationDot = hydration.custom.relayToken + const moonbeamDot = moonbeam.custom.dot + const glmr = hydration.custom.glmr + + runXtokenstHorizontal('hydration transfer DOT to moonbeam', async () => { + return { + fromChain: hydrationClient, + fromBalance: query.tokens(hydrationDot), + fromAccount: defaultAccounts.alice, + + toChain: moonbeamClient, + toBalance: query.assets(moonbeamDot), + toAccount: defaultAccounts.alith, + + routeChain: polkadotClient, + isCheckUmp: true, + + tx: tx.xtokens.transfer(hydrationDot, 2e12, tx.xtokens.parachainAccountId20V3(moonbeam.paraId!)), + } + }) + + runXtokenstHorizontal('moonbeam transfer DOT to hydration', async () => { + await moonbeamClient.dev.setStorage({ + Assets: { + account: [[[moonbeamDot, defaultAccounts.alith.address], { balance: 10e12 }]], + }, + }) + + return { + fromChain: moonbeamClient, + fromBalance: query.assets(moonbeamDot), + fromAccount: defaultAccounts.alith, + + toChain: hydrationClient, + toBalance: query.tokens(hydrationDot), + toAccount: defaultAccounts.bob, + + routeChain: polkadotClient, + isCheckUmp: true, + + tx: tx.xtokens.transfer({ ForeignAsset: moonbeamDot }, 2e10, tx.xtokens.parachainV3(hydration.paraId!)), + } + }) + + runXtokenstHorizontal('hydration transfer GLMR to moonbeam', async () => { + await hydrationClient.dev.setStorage({ + Tokens: { + Accounts: [[[defaultAccounts.alice.address, glmr], { free: '50000000000000000000000' }]], + }, + }) + + return { + fromChain: hydrationClient, + fromBalance: query.tokens(glmr), + fromAccount: defaultAccounts.alice, + routeChain: polkadotClient, + toChain: moonbeamClient, + toBalance: query.balances, + toAccount: defaultAccounts.baltathar, + + tx: tx.xtokens.transfer(glmr, '200000000000000000000', tx.xtokens.parachainAccountId20V3(moonbeam.paraId!)), + } + }) +})