From 75df2ff02afe73c975f4b0d36178f302a34b3bf7 Mon Sep 17 00:00:00 2001 From: Igor Papandinas <26460174+ipapandinas@users.noreply.github.com> Date: Mon, 31 Aug 2026 12:10:46 +0100 Subject: [PATCH 1/3] fix: pallet xtokens removed --- .github/workflows/check.yml | 6 +- .github/workflows/ci.yml | 6 +- .github/workflows/update.yml | 8 +- helpers/api/extrinsics.ts | 311 -------------------- helpers/api/index.ts | 130 +++----- networks/astar.ts | 1 + tests/xcm-transfer/astar-asset-hub.test.ts | 4 +- tests/xcm-transfer/shiden-asset-hub.test.ts | 4 +- 8 files changed, 54 insertions(+), 416 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 71dc451..04d32c6 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -14,13 +14,13 @@ jobs: timeout-minutes: 30 runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: submodules: recursive - name: setup node - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: - node-version: 18.x + node-version: 24.x cache: 'yarn' - run: yarn --immutable diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 84433cf..cf5ff78 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,13 +14,13 @@ jobs: timeout-minutes: 30 runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: submodules: recursive - name: setup node - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: - node-version: 18.x + node-version: 24.x cache: 'yarn' - run: yarn --immutable - run: yarn lint diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index a15411a..40d2c9d 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -15,19 +15,19 @@ jobs: update: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: submodules: recursive - name: setup node - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: - node-version: 18.x + node-version: 24.x cache: 'yarn' - run: yarn --immutable - run: yarn update-env - run: yarn test -u - name: Commit and Create PR - uses: actions/github-script@v6 + uses: actions/github-script@v8 with: script: | const branchName = `update-snapshots-${context.sha.slice(0, 7)}` diff --git a/helpers/api/extrinsics.ts b/helpers/api/extrinsics.ts index 6e975c6..48acfc1 100644 --- a/helpers/api/extrinsics.ts +++ b/helpers/api/extrinsics.ts @@ -6,140 +6,6 @@ export const balance = async (api: ApiPromise, address: string) => { return account.data.toJSON() } -export const xTokensForRelayChain = (api: ApiPromise, amount: string, address: Uint8Array) => { - return api.tx.xTokens.transfer( - { - Token: 'KSM', - }, - amount, - { - V1: { - parents: 1, - interior: { - X1: { - AccountId32: { - network: 'Any', - id: address, - }, - }, - }, - }, - }, - 'Unlimited', - ) -} - -export const xTokensForParaChain = ( - api: ApiPromise, - token: object, - parachainId: string, - amount: string, - address: Uint8Array, -) => { - return api.tx.xTokens.transfer( - token, - amount, - { - V1: { - parents: 1, - interior: { - X2: [ - { - Parachain: parachainId, - }, - { - AccountId32: { - network: 'Any', - id: address, - }, - }, - ], - }, - }, - }, - 'Unlimited', - ) -} - -export const xTokens = ( - api: ApiPromise, - isRelayChain: boolean, - parachainId: string, - token: object, - amount: string | bigint, - address: Uint8Array, -) => { - const multiLocation = isRelayChain - ? { X1: { AccountId32: { network: 'Any', id: address } } } - : { - X2: [ - { - Parachain: parachainId, - }, - { - AccountId32: { - network: 'Any', - id: address, - }, - }, - ], - } - - return api.tx.xTokens.transfer( - token, - amount, - { - V1: { - parents: 1, - interior: multiLocation, - }, - }, - 'Unlimited', - ) -} - -export const xTokensV3 = ( - api: ApiPromise, - isRelayChain: boolean, - parachainId: string, - token: object, - amount: string | bigint, - address: Uint8Array, -) => { - const multiLocation = isRelayChain - ? { - X1: { - AccountId32: { - id: address, - }, - }, - } - : { - X2: [ - { - Parachain: parachainId, - }, - { - AccountId32: { - id: address, - }, - }, - ], - } - - return api.tx.xTokens.transfer( - token, - amount, - { - V3: { - parents: 1, - interior: multiLocation, - }, - } as any, - 'Unlimited', - ) -} - export const relayChainV3limitedReserveTransferAssets = ( api: ApiPromise, parachainId: string, @@ -180,180 +46,3 @@ export const relayChainV3limitedReserveTransferAssets = ( ) } -export const xTokensTransferMulticurrencies = ( - api: ApiPromise, - foreignAssetId: string, - amount: string, - parachainId: string, - address: Uint8Array, -) => { - return api.tx.xTokens.transferMulticurrencies( - [ - [ - { - ForeignAsset: foreignAssetId, - }, - amount, - ], - [ - { - Token: 'KSM', - }, - '16000000000', - ], - ], - '1', - { - V1: { - parents: 1, - interior: { - X2: [ - { - Parachain: parachainId, - }, - { - AccountId32: { - network: 'Any', - id: address, - }, - }, - ], - }, - }, - }, - 'Unlimited', - ) -} - -export const xTokensTransferTransferMultiasset = ( - api: ApiPromise, - interior: any[], - amount: string, - parachainId: string, - address: Uint8Array, -) => { - return api.tx.xTokens.transferMultiasset( - { - V1: { - fun: { - Fungible: amount, - }, - id: { - Concrete: { - parents: 1, - interior: { - X3: interior, - }, - }, - }, - }, - }, - { - V1: { - parents: 1, - interior: { - X2: [ - { - Parachain: parachainId, - }, - { - AccountId32: { - network: 'Any', - id: address, - }, - }, - ], - }, - }, - }, - 'Unlimited', - ) -} - -export const xTokensTransferTransferMultiassetV3 = ( - api: ApiPromise, - interior: any[], - amount: string, - parachainId: string, - address: Uint8Array, -) => { - return api.tx.xTokens.transferMultiasset( - { - V3: { - fun: { - Fungible: amount, - }, - id: { - Concrete: { - parents: 1, - interior: { - X3: interior, - }, - }, - }, - }, - }, - { - V3: { - parents: 1, - interior: { - X2: [ - { - Parachain: parachainId, - }, - { - AccountId32: { - id: address, - }, - }, - ], - }, - }, - } as any, - 'Unlimited', - ) -} - -export const xTokensTransferMulticurrenciesV3 = ( - api: ApiPromise, - foreignAssetId: string, - amount: string, - parachainId: string, - address: Uint8Array, -) => { - return api.tx.xTokens.transferMulticurrencies( - [ - [ - { - ForeignAsset: foreignAssetId, - }, - amount, - ], - [ - { - Token: 'KSM', - }, - '16000000000', - ], - ], - '1', - { - V3: { - parents: 1, - interior: { - X2: [ - { - Parachain: parachainId, - }, - { - AccountId32: { - id: address, - }, - }, - ], - }, - }, - } as any, - 'Unlimited', - ) -} diff --git a/helpers/api/index.ts b/helpers/api/index.ts index 16c83f9..548c8b3 100644 --- a/helpers/api/index.ts +++ b/helpers/api/index.ts @@ -1,95 +1,5 @@ import { ApiPromise } from '@polkadot/api' -export const xtokens = { - relaychainV2: (acc: any) => ({ - V1: { - parents: 1, - interior: { - X1: { - AccountId32: { - network: 'Any', - id: acc, - }, - }, - }, - }, - }), - relaychainV3: (acc: any) => ({ - V3: { - parents: 1, - interior: { - X1: { - AccountId32: { - id: acc, - }, - }, - }, - }, - }), - parachainV2: (paraId: number) => (acc: any) => ({ - V1: { - parents: 1, - interior: { - X2: [ - { Parachain: paraId }, - { - AccountId32: { - network: 'Any', - id: acc, - }, - }, - ], - }, - }, - }), - parachainAccountId20V3: (paraId: number) => (acc: any) => ({ - V3: { - parents: 1, - interior: { - X2: [ - { Parachain: paraId }, - { - AccountKey20: { - key: acc, - }, - }, - ], - }, - }, - }), - parachainV3: (paraId: number) => (acc: any) => ({ - V3: { - parents: 1, - interior: { - X2: [ - { Parachain: paraId }, - { - AccountId32: { - id: acc, - }, - }, - ], - }, - }, - }), - transfer: - (token: any, amount: any, dest: (dest: any) => any, weight: any = 'Unlimited') => - ({ api }: { api: ApiPromise }, acc: any) => - api.tx.xTokens.transfer(token, amount, dest(acc), weight), - transferMulticurrencies: - (token: any, amount: any, feeToken: any, feeAmount: any, dest: (dest: any) => any) => - ({ api }: { api: ApiPromise }, acc: any) => - api.tx.xTokens.transferMulticurrencies( - [ - [token, amount], - [feeToken, feeAmount], - ], - 1, - dest(acc), - 'Unlimited', - ), -} - export const xcmPallet = { parachainV2: (parents: number, paraId: number) => ({ V1: { @@ -243,10 +153,48 @@ export const xcmPallet = { }, 'Unlimited', ), + + // Sends a single asset to a sibling parachain and deposits it to `acc` there. + transferAssetToParachainV3: + (token: any, amount: any, paraId: number, transferType: string = 'DestinationReserve') => + ({ api }: { api: ApiPromise }, acc: any) => + api.tx.polkadotXcm.transferAssetsUsingTypeAndThen( + { V3: { parents: 1, interior: { X1: { Parachain: paraId } } } }, + { + V3: [ + { + id: token, + fun: { Fungible: amount }, + }, + ], + }, + transferType, + { V3: token }, + transferType, + { + V3: [ + { + DepositAsset: { + assets: { Wild: { AllCounted: 1 } }, + beneficiary: { + parents: 0, + interior: { + X1: { + AccountId32: { + id: acc, + }, + }, + }, + }, + }, + }, + ], + }, + 'Unlimited', + ), } export const tx = { - xtokens, xcmPallet, } diff --git a/networks/astar.ts b/networks/astar.ts index f1ea810..dc11d8b 100644 --- a/networks/astar.ts +++ b/networks/astar.ts @@ -51,6 +51,7 @@ export const shiden = { paraId: 2007, paraAccount: 'F7fq1jNy74AqkJ1DP4KqSrWtnTGtXfNVoDwFhTvvPxUvJaq', ksm: 340282366920938463463374607431768211455n, + ksm_loc: { Concrete: { parents: 1, interior: 'Here' } }, sdn: { Concrete: { parents: 0, interior: 'Here' } }, kar: 18446744073709551618n, usdt: 4294969280n, diff --git a/tests/xcm-transfer/astar-asset-hub.test.ts b/tests/xcm-transfer/astar-asset-hub.test.ts index f8a1d53..9d42197 100644 --- a/tests/xcm-transfer/astar-asset-hub.test.ts +++ b/tests/xcm-transfer/astar-asset-hub.test.ts @@ -49,8 +49,8 @@ describe('Astar & AssetHub', () => { }, }) - await tx.xtokens - .transfer(astarUtil.usdt, 10e6, tx.xtokens.parachainV3(statemintUtil.paraId))(astar, bob.addressRaw) + await tx.xcmPallet + .transferAssetToParachainV3(astarUtil.usdt_loc, 10e6, statemintUtil.paraId)(astar, bob.addressRaw) .signAndSend(alice) await astar.chain.newBlock() diff --git a/tests/xcm-transfer/shiden-asset-hub.test.ts b/tests/xcm-transfer/shiden-asset-hub.test.ts index 8c1b4c0..c697e5f 100644 --- a/tests/xcm-transfer/shiden-asset-hub.test.ts +++ b/tests/xcm-transfer/shiden-asset-hub.test.ts @@ -39,8 +39,8 @@ describe('Shiden & AssetHub', () => { given('shiden', 'assethub')( '002: Transfer KSM from Shiden to Asset Hub', async ({ networks: { shiden, assethub }, keyring: { alice, bob } }) => { - await tx.xtokens - .transfer(shidenUtil.ksm, 1e12, tx.xtokens.parachainV3(assethubUtil.paraId))(shiden, bob.addressRaw) + await tx.xcmPallet + .transferAssetToParachainV3(shidenUtil.ksm_loc, 1e12, assethubUtil.paraId)(shiden, bob.addressRaw) .signAndSend(alice) await shiden.chain.newBlock() From b0ca92069c9775a44c87a1fa574f5bb2419c2666 Mon Sep 17 00:00:00 2001 From: Igor Papandinas <26460174+ipapandinas@users.noreply.github.com> Date: Mon, 31 Aug 2026 12:20:48 +0100 Subject: [PATCH 2/3] make CI happy --- helpers/api/extrinsics.ts | 1 - package.json | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/helpers/api/extrinsics.ts b/helpers/api/extrinsics.ts index 48acfc1..d3884b3 100644 --- a/helpers/api/extrinsics.ts +++ b/helpers/api/extrinsics.ts @@ -45,4 +45,3 @@ export const relayChainV3limitedReserveTransferAssets = ( 'Unlimited', ) } - diff --git a/package.json b/package.json index 5998ce0..3351cb0 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "private": true, "packageManager": "yarn@4.5.1", "scripts": { - "lint": "tsc --noEmit && eslint && prettier --check .", + "lint": "eslint && prettier --check .", "fix": "eslint --fix && prettier -w .", "prepare": "husky install", "test": "LOG_LEVEL=error vitest", From 62177b928e25939da07263e969fb867a9d3d6187 Mon Sep 17 00:00:00 2001 From: Igor Papandinas <26460174+ipapandinas@users.noreply.github.com> Date: Mon, 31 Aug 2026 12:24:32 +0100 Subject: [PATCH 3/3] make CI happy --- eslint.config.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/eslint.config.mjs b/eslint.config.mjs index 6ce7e5a..aa9ed1b 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -20,6 +20,7 @@ export default tseslint.config( '@typescript-eslint/require-await': 'off', '@typescript-eslint/no-unsafe-member-access': 'off', '@typescript-eslint/no-unsafe-argument': 'off', + '@typescript-eslint/no-unsafe-return': 'off', '@typescript-eslint/no-unsafe-call': 'off', '@typescript-eslint/no-empty-function': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off',