diff --git a/apps/playground/src/App.tsx b/apps/playground/src/App.tsx
index 91504e7c..db3e93ac 100644
--- a/apps/playground/src/App.tsx
+++ b/apps/playground/src/App.tsx
@@ -21,10 +21,11 @@ import {
IconRoute,
} from "@tabler/icons-react";
import {
- BrowserRouter,
+ Navigate,
Route,
NavLink as RouterNavLink,
Routes,
+ useLocation,
} from "react-router-dom";
import "./App.css";
import { useWallet } from "./hooks/useWallet";
@@ -40,6 +41,7 @@ import {
import type { TApiType, WalletAccount } from "./types";
import PolkadotWalletSelectModal from "./components/PolkadotWalletSelectModal";
import { STORAGE_ADDRESS_KEY } from "./providers/WalletProvider";
+import { useEffect } from "react";
const App = () => {
const [opened, { toggle }] = useDisclosure();
@@ -132,8 +134,15 @@ const App = () => {
const onChangeAccountClick = () => void changeAccount();
+ const location = useLocation();
+
+ useEffect(() => {
+ if (location.pathname === "/xcm-router" && apiType === "PAPI") {
+ handleApiSwitch("PJS");
+ }
+ }, [location.pathname, apiType]);
+
const handleApiSwitch = (value: string) => {
- console.log("handleApiSwitch", value);
setApiType(value as TApiType);
setSelectedAccount(undefined);
setAccounts([]);
@@ -179,139 +188,135 @@ const App = () => {
};
return (
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
- PJS
-
- ),
- },
- {
- value: "PAPI",
- label: (
-
-
- PAPI
-
- ),
- },
- ]}
- />
-
- {selectedAccount ? (
-
- ) : (
-
- )}
-
-
-
-
-
- {({ isActive }) => (
- }
- style={{ borderRadius: 4 }}
- />
- )}
-
-
- {({ isActive }) => (
- }
- style={{ borderRadius: 4 }}
- />
- )}
-
-
- {({ isActive }) => (
- }
- style={{ borderRadius: 4 }}
+
+
+ PJS
+
+ ),
+ },
+ {
+ value: "PAPI",
+ disabled:
+ location.pathname === "/xcm-router" || !isInitialized,
+ label: (
+
+
+ PAPI
+
+ ),
+ },
+ ]}
/>
+
+ {selectedAccount ? (
+
+ ) : (
+
)}
-
-
-
-
-
-
-
+
+
+
+
+ {({ isActive }) => (
+ }
+ style={{ borderRadius: 4 }}
+ />
+ )}
+
+
+ {({ isActive }) => (
+ }
+ style={{ borderRadius: 4 }}
+ />
+ )}
+
+
+
+ {({ isActive }) => (
+ }
+ style={{ borderRadius: 4 }}
/>
-
-
-
-
-
+ )}
+
+
+
+
+ } />
+
+
+
+
+
+
+
);
};
diff --git a/apps/playground/src/components/TransferInfo.tsx b/apps/playground/src/components/TransferInfo.tsx
index ab82cb01..fad558bb 100644
--- a/apps/playground/src/components/TransferInfo.tsx
+++ b/apps/playground/src/components/TransferInfo.tsx
@@ -53,7 +53,7 @@ const TransferInfo = () => {
const originAddress = formValues.address;
const currency = resolveCurrency(formValues);
if (useApi) {
- return await fetchFromApi(
+ return fetchFromApi(
{
origin: formValues.from,
destination: formValues.to,
@@ -72,7 +72,7 @@ const TransferInfo = () => {
? await import("@paraspell/sdk/papi")
: await import("@paraspell/sdk");
- return await Sdk.getTransferInfo({
+ return Sdk.getTransferInfo({
origin: formValues.from,
destination: formValues.to,
accountOrigin: originAddress,
diff --git a/apps/playground/src/components/XcmTransfer.tsx b/apps/playground/src/components/XcmTransfer.tsx
index 1164ba63..61cdce1e 100644
--- a/apps/playground/src/components/XcmTransfer.tsx
+++ b/apps/playground/src/components/XcmTransfer.tsx
@@ -128,7 +128,7 @@ const XcmTransfer = () => {
currency: determineCurrency(formValues),
},
api,
- apiType === "PJS" ? "/x-transfer-hash" : "/x-transfer-papi",
+ apiType === "PJS" ? "/x-transfer" : "/x-transfer-papi",
selectedAccount.address,
apiType,
"POST",
diff --git a/apps/playground/src/components/asset-claim/AssetClaim.tsx b/apps/playground/src/components/asset-claim/AssetClaim.tsx
index 5568b0f1..bddc0d5e 100644
--- a/apps/playground/src/components/asset-claim/AssetClaim.tsx
+++ b/apps/playground/src/components/asset-claim/AssetClaim.tsx
@@ -72,7 +72,7 @@ const AssetClaim = () => {
],
},
api,
- apiType === "PJS" ? "/asset-claim-hash" : "/asset-claim-papi",
+ apiType === "PJS" ? "/asset-claim" : "/asset-claim-papi",
selectedAccount.address,
apiType,
"POST",
diff --git a/apps/playground/src/components/assets/AssetsQueries.tsx b/apps/playground/src/components/assets/AssetsQueries.tsx
index 71d80151..00f51963 100644
--- a/apps/playground/src/components/assets/AssetsQueries.tsx
+++ b/apps/playground/src/components/assets/AssetsQueries.tsx
@@ -116,7 +116,7 @@ const AssetsQueries = () => {
case "HAS_SUPPORT":
return `/assets/${node}/has-support`;
case "PARA_ID":
- return `/assets/${node}/para-id`;
+ return `/nodes/${node}/para-id`;
case "BALANCE_NATIVE":
return apiType === "PAPI"
? `/balance/${node}/native-papi`
@@ -147,10 +147,12 @@ const AssetsQueries = () => {
const getQueryResult = async (formValues: FormValues): Promise => {
const { useApi, func, address } = formValues;
const isBalanceQuery =
- func === "BALANCE_FOREIGN" || func === "BALANCE_NATIVE";
+ func === "BALANCE_FOREIGN" ||
+ func === "BALANCE_NATIVE" ||
+ func === "ASSET_BALANCE";
const resolvedCurrency = resolveCurrency(formValues);
if (useApi) {
- return await fetchFromApi(
+ return fetchFromApi(
isBalanceQuery
? {
address,
@@ -162,7 +164,7 @@ const AssetsQueries = () => {
isBalanceQuery,
);
} else {
- return await submitUsingSdk(formValues);
+ return submitUsingSdk(formValues);
}
};
diff --git a/apps/playground/src/components/eth-bridge/EthBridgeTransfer.tsx b/apps/playground/src/components/eth-bridge/EthBridgeTransfer.tsx
index 8c20c67f..2a943910 100644
--- a/apps/playground/src/components/eth-bridge/EthBridgeTransfer.tsx
+++ b/apps/playground/src/components/eth-bridge/EthBridgeTransfer.tsx
@@ -42,7 +42,6 @@ const EthBridgeTransfer = () => {
const handleAccountsChanged = (accounts: string[]) => {
if (accounts.length === 0) {
- console.log("Please connect to a wallet.");
setSelectedAccount(null);
setAccounts([]);
} else {
@@ -123,8 +122,6 @@ const EthBridgeTransfer = () => {
const onAccountSelect = (account: string) => {
setIsAccountModalOpen(false);
setSelectedAccount(account);
-
- console.log("Account selected:", account);
};
useEffect(() => {
diff --git a/apps/playground/src/components/pallets/PalletsQueries.tsx b/apps/playground/src/components/pallets/PalletsQueries.tsx
index 2f578a6a..b9487f5d 100644
--- a/apps/playground/src/components/pallets/PalletsQueries.tsx
+++ b/apps/playground/src/components/pallets/PalletsQueries.tsx
@@ -52,10 +52,7 @@ const PalletsQueries = () => {
const getQueryResult = async (formValues: FormValues): Promise => {
const { useApi } = formValues;
if (useApi) {
- return await fetchFromApi(
- formValues,
- `/pallets/${getEndpoint(formValues)}`,
- );
+ return fetchFromApi(formValues, `/pallets/${getEndpoint(formValues)}`);
} else {
return submitUsingSdk(formValues);
}
diff --git a/apps/playground/src/main.tsx b/apps/playground/src/main.tsx
index baa24754..8e85b934 100644
--- a/apps/playground/src/main.tsx
+++ b/apps/playground/src/main.tsx
@@ -2,11 +2,14 @@ import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import WalletProvider from "./providers/WalletProvider";
+import { BrowserRouter } from "react-router-dom";
ReactDOM.createRoot(document.getElementById("root")!).render(
-
+
+
+
,
);
diff --git a/apps/playground/src/providers/WalletProvider.tsx b/apps/playground/src/providers/WalletProvider.tsx
index 2b8c2dfd..f39b2723 100644
--- a/apps/playground/src/providers/WalletProvider.tsx
+++ b/apps/playground/src/providers/WalletProvider.tsx
@@ -66,7 +66,6 @@ const WalletProvider: React.FC> = ({ children }) => {
if (selectedAccount) {
localStorage.setItem(STORAGE_ADDRESS_KEY, selectedAccount.address);
} else {
- console.log("selectedAccount removed", selectedAccount);
localStorage.removeItem(STORAGE_ADDRESS_KEY);
}
}, [selectedAccount]);
diff --git a/apps/playground/src/routes/RouterTransferPage.tsx b/apps/playground/src/routes/RouterTransferPage.tsx
index 8c0f1345..df2017fa 100644
--- a/apps/playground/src/routes/RouterTransferPage.tsx
+++ b/apps/playground/src/routes/RouterTransferPage.tsx
@@ -27,7 +27,7 @@ import TransferStepper from "../components/TransferStepper";
import Confetti from "react-confetti";
import type { Signer } from "@polkadot/api/types";
import axios, { AxiosError } from "axios";
-import { buildTx, submitTransaction } from "../utils";
+import { submitTransaction } from "../utils";
import ErrorAlert from "../components/ErrorAlert";
import { useWallet } from "../hooks/useWallet";
import { API_URL } from "../consts";
@@ -38,7 +38,7 @@ import type { MultiAddressStruct } from "@snowbridge/contract-types/dist/IGatewa
import { u8aToHex } from "@polkadot/util";
import { decodeAddress } from "@polkadot/keyring";
import { ApiPromise, WsProvider } from "@polkadot/api";
-import { isForeignAsset, type TSerializedApiCall } from "@paraspell/sdk";
+import { isForeignAsset } from "@paraspell/sdk";
import { Web3 } from "web3";
import type { EIP6963ProviderDetail } from "../types";
@@ -242,14 +242,14 @@ const RouterTransferPage = () => {
// When submitting to exchange, prioritize the evmSigner if available
await submitTransaction(
api,
- buildTx(api, txInfo.tx as unknown as TSerializedApiCall),
+ api.tx(txInfo.tx),
formValues.evmSigner ?? signer,
formValues.evmInjectorAddress ?? injectorAddress,
);
} else {
await submitTransaction(
api,
- buildTx(api, txInfo.tx as unknown as TSerializedApiCall),
+ api.tx(txInfo.tx),
signer,
injectorAddress,
);
diff --git a/apps/playground/src/routes/XcmAnalyserSandbox.tsx b/apps/playground/src/routes/XcmAnalyserSandbox.tsx
index f7a02372..fa6b62c0 100644
--- a/apps/playground/src/routes/XcmAnalyserSandbox.tsx
+++ b/apps/playground/src/routes/XcmAnalyserSandbox.tsx
@@ -46,7 +46,7 @@ const XcmAnalyserSandbox = () => {
const convert = async ({ useApi, input }: FormValues) => {
if (useApi) {
- return await convertUsingApi(input);
+ return convertUsingApi(input);
}
return convertUsingSdk(input);
};
diff --git a/apps/playground/src/utils.ts b/apps/playground/src/utils.ts
index f51a0fb6..1dba8b83 100644
--- a/apps/playground/src/utils.ts
+++ b/apps/playground/src/utils.ts
@@ -1,4 +1,4 @@
-import type { Extrinsic, TSerializedApiCall } from "@paraspell/sdk";
+import type { Extrinsic } from "@paraspell/sdk";
import type { TPapiTransaction } from "@paraspell/sdk/papi";
import type { ApiPromise } from "@polkadot/api";
import type { Signer } from "@polkadot/api/types";
@@ -25,7 +25,7 @@ export const submitTransactionPapi = async (
tx: TPapiTransaction,
signer: PolkadotSigner,
): Promise => {
- return await tx.signAndSubmit(signer);
+ return tx.signAndSubmit(signer);
};
export const submitTransaction = async (
@@ -35,7 +35,7 @@ export const submitTransaction = async (
injectorAddress: string,
): Promise => {
await tx.signAsync(injectorAddress, { signer });
- return await new Promise((resolve, reject) => {
+ return new Promise((resolve, reject) => {
void tx.send(({ status, dispatchError, txHash }) => {
if (status.isFinalized) {
// Check if there are any dispatch errors
@@ -56,10 +56,3 @@ export const submitTransaction = async (
});
});
};
-
-export const buildTx = (
- api: ApiPromise,
- { module, section, parameters }: TSerializedApiCall,
-) => {
- return api.tx[module][section](...parameters);
-};
diff --git a/apps/playground/src/utils/submitUsingApi.ts b/apps/playground/src/utils/submitUsingApi.ts
index 613b7a5e..23a1f043 100644
--- a/apps/playground/src/utils/submitUsingApi.ts
+++ b/apps/playground/src/utils/submitUsingApi.ts
@@ -4,14 +4,11 @@ import type { PolkadotClient } from "polkadot-api";
import { Binary } from "polkadot-api";
import type { TApiType } from "../types";
import type { ApiPromise } from "@polkadot/api";
-import type {
- TNodeDotKsmWithRelayChains,
- TSerializedApiCall,
-} from "@paraspell/sdk";
+import type { TNodeDotKsmWithRelayChains } from "@paraspell/sdk";
import { createApiInstanceForNode, type Extrinsic } from "@paraspell/sdk";
import type { TPapiTransaction } from "@paraspell/sdk/papi";
import type { Signer } from "@polkadot/api/types";
-import { buildTx, submitTransaction } from "../utils";
+import { submitTransaction } from "../utils";
export const fetchFromApi = async (
params: T,
@@ -26,7 +23,7 @@ export const fetchFromApi = async (
data: useBody ? params : undefined,
});
- return await response.data;
+ return response.data;
} catch (error) {
if (error instanceof AxiosError) {
console.error(error);
@@ -70,9 +67,7 @@ export const getTxFromApi = async (
return (api as ApiPromise).tx(txHash as string);
} else {
const callData = Binary.fromHex(txHash as string);
- return await (api as PolkadotClient)
- .getUnsafeApi()
- .txFromCallData(callData);
+ return (api as PolkadotClient).getUnsafeApi().txFromCallData(callData);
}
};
@@ -85,17 +80,12 @@ export const submitTxUsingApi = async (
method: string = "GET",
useBody = false,
) => {
- const serializedTx = await fetchFromApi(
+ const txHash = (await fetchFromApi(
{ ...params, injectorAddress },
endpoint,
method,
useBody,
- );
+ )) as string;
const api = await createApiInstanceForNode(fromNode);
- await submitTransaction(
- api,
- buildTx(api, serializedTx as TSerializedApiCall),
- signer,
- injectorAddress,
- );
+ await submitTransaction(api, api.tx(txHash), signer, injectorAddress);
};
diff --git a/apps/visualizator-be/test/app.e2e-spec.ts b/apps/visualizator-be/test/app.e2e-spec.ts
index a5aebf16..dd278598 100644
--- a/apps/visualizator-be/test/app.e2e-spec.ts
+++ b/apps/visualizator-be/test/app.e2e-spec.ts
@@ -479,8 +479,6 @@ describe('XCM API (e2e)', () => {
})
.expect(200);
- console.log(response.body);
-
expect(response.body.data.totalMessageCounts).toBeInstanceOf(Array);
expect(response.body.data.totalMessageCounts.length).toBeGreaterThan(0);
response.body.data.totalMessageCounts.forEach((count) => {
diff --git a/apps/visualizator-fe/src/components/SendXcm/utils.ts b/apps/visualizator-fe/src/components/SendXcm/utils.ts
index 0379540f..a4c3fa34 100644
--- a/apps/visualizator-fe/src/components/SendXcm/utils.ts
+++ b/apps/visualizator-fe/src/components/SendXcm/utils.ts
@@ -12,7 +12,7 @@ export const submitTransaction = async (
injectorAddress: string
): Promise => {
await tx.signAsync(injectorAddress, { signer });
- return await new Promise((resolve, reject) => {
+ return new Promise((resolve, reject) => {
void tx.send(({ status, dispatchError, txHash }) => {
if (status.isFinalized) {
// Check if there are any dispatch errors
diff --git a/apps/xcm-api/src/analytics/EventName.ts b/apps/xcm-api/src/analytics/EventName.ts
index 6d3e3e7d..0f154811 100644
--- a/apps/xcm-api/src/analytics/EventName.ts
+++ b/apps/xcm-api/src/analytics/EventName.ts
@@ -13,20 +13,18 @@ export enum EventName {
GET_PARA_ID = 'Get Para Id',
GET_DEFAULT_PALLET = 'Get Default Pallet',
GET_SUPPORTED_PALLETS = 'Get Supported Pallets',
+ GET_ASSET_BALANCE = 'Get Asset Balance',
GET_BALANCE_NATIVE = 'Get Balance Native',
GET_BALANCE_NATIVE_PAPI = 'Get Balance Native Papi',
GET_BALANCE_FOREIGN = 'Get Balance Foreign',
GENERATE_XCM_CALL = 'Generate XCM Call',
- GENERATE_XCM_CALL_HASH = 'Generate XCM Call Hash',
- GENERATE_XCM_CALL_BATCH_HASH = 'Generate XCM Call Batch Hash',
+ GENERATE_XCM_CALL_BATCH = 'Generate XCM Call Batch',
GENERATE_XCM_CALL_BATCH_PAPI = 'Generate XCM Call Batch Papi',
GENERATE_ETH_CALL = 'Generate ETH Call',
GENERATE_API_KEY = 'Generate API Key',
GENERATE_ROUTER_EXTRINSICS = 'Generate router extrinsics',
- GENERATE_ROUTER_EXTRINSICS_HASH = 'Generate router extrinsics hash',
CLAIM_ASSETS = 'Claim assets',
CLAIM_ASSETS_PAPI = 'Claim assets papi',
- CLAIM_ASSETS_HASH = 'Claim assets hash',
GET_TRANSFER_INFO = 'Get Transfer Info',
GET_TRANSFER_INFO_PAPI = 'Get Transfer Info papi',
XCM_ANALYSER = 'XCM Analyser',
diff --git a/apps/xcm-api/src/asset-claim/asset-claim.controller.test.ts b/apps/xcm-api/src/asset-claim/asset-claim.controller.test.ts
index 36de3e89..4736ceb0 100644
--- a/apps/xcm-api/src/asset-claim/asset-claim.controller.test.ts
+++ b/apps/xcm-api/src/asset-claim/asset-claim.controller.test.ts
@@ -5,7 +5,7 @@ import type { AnalyticsService } from '../analytics/analytics.service.js';
import { EventName } from '../analytics/EventName.js';
import type { AssetClaimDto } from './dto/asset-claim.dto.js';
import type { RequestWithUser } from '../types/types.js';
-import type { Extrinsic, TTransferReturn } from '@paraspell/sdk';
+import type { Extrinsic } from '@paraspell/sdk';
describe('AssetClaimController', () => {
let controller: AssetClaimController;
@@ -27,8 +27,7 @@ describe('AssetClaimController', () => {
beforeEach(() => {
assetClaimService = {
- claimAssetsPjs: vi.fn(),
- claimAssetsPapi: vi.fn(),
+ claimAssets: vi.fn(),
} as unknown as AssetClaimService;
analyticsService = {
@@ -49,13 +48,13 @@ describe('AssetClaimController', () => {
} as unknown as RequestWithUser;
const spyClaimAssets = vi
- .spyOn(assetClaimService, 'claimAssetsPjs')
- .mockResolvedValue('success' as unknown as TTransferReturn);
+ .spyOn(assetClaimService, 'claimAssets')
+ .mockResolvedValue('success' as unknown as Extrinsic);
const spyTrack = vi.spyOn(analyticsService, 'track');
const result = await controller.claimAssets(bodyParams, req);
- expect(spyClaimAssets).toHaveBeenCalledWith(bodyParams);
+ expect(spyClaimAssets).toHaveBeenCalledWith(bodyParams, false);
expect(spyTrack).toHaveBeenCalledWith(EventName.CLAIM_ASSETS, req, {
from: 'address1',
@@ -67,7 +66,7 @@ describe('AssetClaimController', () => {
});
describe('claimAssetsHash', () => {
- it('should call trackAnalytics and claimAssets with hashEnabled set to true', async () => {
+ it('should call trackAnalytics and claimAssets', async () => {
const req = {
headers: {
'user-agent': 'Mozilla/5.0',
@@ -77,15 +76,15 @@ describe('AssetClaimController', () => {
} as unknown as RequestWithUser;
const spyClaimAssets = vi
- .spyOn(assetClaimService, 'claimAssetsPjs')
- .mockResolvedValue('success' as unknown as TTransferReturn);
+ .spyOn(assetClaimService, 'claimAssets')
+ .mockResolvedValue('success' as unknown as Extrinsic);
const spyTrack = vi.spyOn(analyticsService, 'track');
- const result = await controller.claimAssetsHash(bodyParams, req);
+ const result = await controller.claimAssets(bodyParams, req);
- expect(spyClaimAssets).toHaveBeenCalledWith(bodyParams, true);
+ expect(spyClaimAssets).toHaveBeenCalledWith(bodyParams, false);
- expect(spyTrack).toHaveBeenCalledWith(EventName.CLAIM_ASSETS_HASH, req, {
+ expect(spyTrack).toHaveBeenCalledWith(EventName.CLAIM_ASSETS, req, {
from: 'address1',
assetLength: 1,
});
@@ -105,13 +104,13 @@ describe('AssetClaimController', () => {
} as unknown as RequestWithUser;
const spyClaimAssets = vi
- .spyOn(assetClaimService, 'claimAssetsPapi')
- .mockResolvedValue('success' as unknown as TTransferReturn);
+ .spyOn(assetClaimService, 'claimAssets')
+ .mockResolvedValue('success' as unknown as Extrinsic);
const spyTrack = vi.spyOn(analyticsService, 'track');
const result = await controller.claimAssetsPapi(bodyParams, req);
- expect(spyClaimAssets).toHaveBeenCalledWith(bodyParams);
+ expect(spyClaimAssets).toHaveBeenCalledWith(bodyParams, true);
expect(spyTrack).toHaveBeenCalledWith(EventName.CLAIM_ASSETS_PAPI, req, {
from: 'address1',
diff --git a/apps/xcm-api/src/asset-claim/asset-claim.controller.ts b/apps/xcm-api/src/asset-claim/asset-claim.controller.ts
index d5ebf093..0894e16c 100644
--- a/apps/xcm-api/src/asset-claim/asset-claim.controller.ts
+++ b/apps/xcm-api/src/asset-claim/asset-claim.controller.ts
@@ -28,20 +28,13 @@ export class AssetClaimController {
@UsePipes(new ZodValidationPipe(AssetClaimSchema))
claimAssets(@Body() bodyParams: AssetClaimDto, @Req() req: Request) {
this.trackAnalytics(EventName.CLAIM_ASSETS, req, bodyParams);
- return this.xTransferService.claimAssetsPjs(bodyParams);
- }
-
- @Post('asset-claim-hash')
- @UsePipes(new ZodValidationPipe(AssetClaimSchema))
- claimAssetsHash(@Body() bodyParams: AssetClaimDto, @Req() req: Request) {
- this.trackAnalytics(EventName.CLAIM_ASSETS_HASH, req, bodyParams);
- return this.xTransferService.claimAssetsPjs(bodyParams, true);
+ return this.xTransferService.claimAssets(bodyParams, false);
}
@Post('asset-claim-papi')
@UsePipes(new ZodValidationPipe(AssetClaimSchema))
claimAssetsPapi(@Body() bodyParams: AssetClaimDto, @Req() req: Request) {
this.trackAnalytics(EventName.CLAIM_ASSETS_PAPI, req, bodyParams);
- return this.xTransferService.claimAssetsPapi(bodyParams);
+ return this.xTransferService.claimAssets(bodyParams, true);
}
}
diff --git a/apps/xcm-api/src/asset-claim/asset-claim.service.test.ts b/apps/xcm-api/src/asset-claim/asset-claim.service.test.ts
index afb3e85d..0a6c9a63 100644
--- a/apps/xcm-api/src/asset-claim/asset-claim.service.test.ts
+++ b/apps/xcm-api/src/asset-claim/asset-claim.service.test.ts
@@ -24,7 +24,6 @@ vi.mock('@paraspell/sdk', async () => {
fungible: vi.fn().mockReturnThis(),
account: vi.fn().mockReturnThis(),
build: vi.fn().mockResolvedValue('hash'),
- buildSerializedApiCall: vi.fn().mockResolvedValue('success'),
disconnect: vi.fn(),
})),
};
@@ -46,7 +45,6 @@ vi.mock('@paraspell/sdk/papi', async () => {
asHex: vi.fn().mockReturnValue('hash'),
}),
}),
- buildSerializedApiCall: vi.fn().mockResolvedValue('success'),
disconnect: vi.fn(),
})),
};
@@ -72,15 +70,13 @@ describe('AssetClaimService', () => {
sdk.NODES_WITH_RELAY_CHAINS.includes = vi.fn().mockReturnValue(false);
vi.mocked(utils.isValidWalletAddress).mockReturnValue(true);
- await expect(service.claimAssetsPjs(dto)).rejects.toThrow(
- BadRequestException,
- );
+ await expect(service.claimAssets(dto)).rejects.toThrow(BadRequestException);
});
it('throws BadRequestException when fromNode is undefined', async () => {
const dto = { from: undefined, fungible: [], address: 'validAddress' };
- await expect(service.claimAssetsPjs(dto)).rejects.toThrow(
+ await expect(service.claimAssets(dto)).rejects.toThrow(
new BadRequestException("You need to provide a 'from' parameter"),
);
});
@@ -90,9 +86,7 @@ describe('AssetClaimService', () => {
sdk.NODES_WITH_RELAY_CHAINS.includes = vi.fn().mockReturnValue(true);
vi.mocked(utils.isValidWalletAddress).mockReturnValue(false);
- await expect(service.claimAssetsPjs(dto)).rejects.toThrow(
- BadRequestException,
- );
+ await expect(service.claimAssets(dto)).rejects.toThrow(BadRequestException);
});
it('successfully claims assets when parameters are valid', async () => {
@@ -117,9 +111,9 @@ describe('AssetClaimService', () => {
disconnect: vi.fn(),
} as unknown as ApiPromise);
- const result = await service.claimAssetsPjs(dto);
+ const result = await service.claimAssets(dto);
- expect(result).toEqual('success');
+ expect(result).toEqual('hash');
expect(sdk.createApiInstanceForNode).toHaveBeenCalledWith('Acala');
});
@@ -145,7 +139,7 @@ describe('AssetClaimService', () => {
disconnect: vi.fn(),
} as unknown as ApiPromise);
- const result = await service.claimAssetsPjs(dto, true);
+ const result = await service.claimAssets(dto);
expect(result).toEqual('hash');
expect(sdk.createApiInstanceForNode).toHaveBeenCalledWith('Acala');
@@ -163,7 +157,7 @@ describe('AssetClaimService', () => {
disconnect: vi.fn(),
} as unknown as ApiPromise);
- await expect(service.claimAssetsPjs(dto)).rejects.toThrow(
+ await expect(service.claimAssets(dto)).rejects.toThrow(
new BadRequestException('Invalid currency error'),
);
});
@@ -180,7 +174,7 @@ describe('AssetClaimService', () => {
disconnect: vi.fn(),
} as unknown as ApiPromise);
- await expect(service.claimAssetsPjs(dto)).rejects.toThrow(
+ await expect(service.claimAssets(dto)).rejects.toThrow(
new InternalServerErrorException('Some internal error'),
);
});
@@ -207,7 +201,7 @@ describe('AssetClaimService', () => {
destroy: vi.fn(),
} as unknown as PolkadotClient);
- const result = await service.claimAssetsPapi(dto);
+ const result = await service.claimAssets(dto, true);
expect(result).toEqual('hash');
expect(sdkPapi.createApiInstanceForNode).toHaveBeenCalledWith('Acala');
diff --git a/apps/xcm-api/src/asset-claim/asset-claim.service.ts b/apps/xcm-api/src/asset-claim/asset-claim.service.ts
index 61876337..e5fdfafe 100644
--- a/apps/xcm-api/src/asset-claim/asset-claim.service.ts
+++ b/apps/xcm-api/src/asset-claim/asset-claim.service.ts
@@ -17,17 +17,8 @@ import { TPapiTransaction } from '@paraspell/sdk/papi';
@Injectable()
export class AssetClaimService {
- async claimAssetsPjs(options: AssetClaimDto, hashEnabled = false) {
- return await this.claimAssets(options, hashEnabled);
- }
-
- async claimAssetsPapi(options: AssetClaimDto) {
- return await this.claimAssets(options, false, true);
- }
-
- private async claimAssets(
+ async claimAssets(
{ from, fungible, address }: AssetClaimDto,
- hashEnabled = false,
usePapi = false,
) {
const fromNode = from as TNodeDotKsmWithRelayChains | undefined;
@@ -63,9 +54,7 @@ export class AssetClaimService {
return (await (tx as TPapiTransaction).getEncodedData()).asHex();
}
- return hashEnabled
- ? await builder.build()
- : await builder.buildSerializedApiCall();
+ return await builder.build();
} catch (e) {
if (e instanceof InvalidCurrencyError) {
throw new BadRequestException(e.message);
diff --git a/apps/xcm-api/src/balance/balance.controller.test.ts b/apps/xcm-api/src/balance/balance.controller.test.ts
index 132b504b..1e8c9a30 100644
--- a/apps/xcm-api/src/balance/balance.controller.test.ts
+++ b/apps/xcm-api/src/balance/balance.controller.test.ts
@@ -20,10 +20,9 @@ describe('BalanceController', () => {
{
provide: BalanceService,
useValue: {
- getBalanceNativePjs: vi.fn(),
- getBalanceNativePapi: vi.fn(),
- getBalanceForeignPjs: vi.fn(),
- getBalanceForeignPapi: vi.fn(),
+ getBalanceNative: vi.fn(),
+ getBalanceForeign: vi.fn(),
+ getAssetBalance: vi.fn(),
},
},
{
@@ -50,7 +49,7 @@ describe('BalanceController', () => {
const balanceNativeMock = 1000n;
const balanceServiceSpy = vi
- .spyOn(balanceService, 'getBalanceNativePjs')
+ .spyOn(balanceService, 'getBalanceNative')
.mockResolvedValue(balanceNativeMock);
const analyticsServiceSpy = vi.spyOn(analyticsService, 'track');
@@ -78,7 +77,7 @@ describe('BalanceController', () => {
const balanceNativeMock = 1000n;
const balanceServiceSpy = vi
- .spyOn(balanceService, 'getBalanceNativePapi')
+ .spyOn(balanceService, 'getBalanceNative')
.mockResolvedValue(balanceNativeMock);
const analyticsServiceSpy = vi.spyOn(analyticsService, 'track');
@@ -93,7 +92,7 @@ describe('BalanceController', () => {
req,
{ node },
);
- expect(balanceServiceSpy).toHaveBeenCalledWith(node, params);
+ expect(balanceServiceSpy).toHaveBeenCalledWith(node, params, true);
expect(result).toEqual(balanceNativeMock);
});
});
@@ -109,7 +108,7 @@ describe('BalanceController', () => {
const balanceForeignMock = '500';
const balanceServiceSpy = vi
- .spyOn(balanceService, 'getBalanceForeignPjs')
+ .spyOn(balanceService, 'getBalanceForeign')
.mockResolvedValue(balanceForeignMock);
const analyticsServiceSpy = vi.spyOn(analyticsService, 'track');
@@ -138,7 +137,7 @@ describe('BalanceController', () => {
const balanceForeignMock = '500';
const balanceServiceSpy = vi
- .spyOn(balanceService, 'getBalanceForeignPapi')
+ .spyOn(balanceService, 'getBalanceForeign')
.mockResolvedValue(balanceForeignMock);
const analyticsServiceSpy = vi.spyOn(analyticsService, 'track');
@@ -153,6 +152,33 @@ describe('BalanceController', () => {
req,
{ node },
);
+ expect(balanceServiceSpy).toHaveBeenCalledWith(node, params, true);
+ expect(result).toEqual(balanceForeignMock);
+ });
+ });
+
+ describe('getAssetBalance', () => {
+ it('should track analytics and call BalanceService for asset balance', async () => {
+ const node = 'Acala';
+ const params: BalanceForeignDto = {
+ address: '0x1234567890',
+ currency: { symbol: 'UNQ' },
+ };
+ const req = {} as Request;
+
+ const balanceForeignMock = '500';
+ const balanceServiceSpy = vi
+ .spyOn(balanceService, 'getAssetBalance')
+ .mockResolvedValue(balanceForeignMock);
+ const analyticsServiceSpy = vi.spyOn(analyticsService, 'track');
+
+ const result = await balanceController.getAssetBalance(node, params, req);
+
+ expect(analyticsServiceSpy).toHaveBeenCalledWith(
+ EventName.GET_ASSET_BALANCE,
+ req,
+ { node },
+ );
expect(balanceServiceSpy).toHaveBeenCalledWith(node, params);
expect(result).toEqual(balanceForeignMock);
});
diff --git a/apps/xcm-api/src/balance/balance.controller.ts b/apps/xcm-api/src/balance/balance.controller.ts
index 39df9971..b0ee945d 100644
--- a/apps/xcm-api/src/balance/balance.controller.ts
+++ b/apps/xcm-api/src/balance/balance.controller.ts
@@ -29,7 +29,7 @@ export class BalanceController {
this.analyticsService.track(EventName.GET_BALANCE_NATIVE, req, {
node,
});
- return this.balanceService.getBalanceNativePjs(node, params);
+ return this.balanceService.getBalanceNative(node, params);
}
@Post(':node/native-papi')
@@ -42,7 +42,7 @@ export class BalanceController {
this.analyticsService.track(EventName.GET_BALANCE_NATIVE_PAPI, req, {
node,
});
- return this.balanceService.getBalanceNativePapi(node, params);
+ return this.balanceService.getBalanceNative(node, params, true);
}
@Post(':node/foreign')
@@ -55,7 +55,7 @@ export class BalanceController {
this.analyticsService.track(EventName.GET_BALANCE_FOREIGN, req, {
node,
});
- return this.balanceService.getBalanceForeignPjs(node, params);
+ return this.balanceService.getBalanceForeign(node, params);
}
@Post(':node/foreign-papi')
@@ -68,6 +68,19 @@ export class BalanceController {
this.analyticsService.track(EventName.GET_BALANCE_FOREIGN, req, {
node,
});
- return this.balanceService.getBalanceForeignPapi(node, params);
+ return this.balanceService.getBalanceForeign(node, params, true);
+ }
+
+ @Post(':node/asset')
+ getAssetBalance(
+ @Param('node') node: string,
+ @Body(new ZodValidationPipe(BalanceForeignDtoSchema))
+ params: BalanceForeignDto,
+ @Req() req: Request,
+ ) {
+ this.analyticsService.track(EventName.GET_ASSET_BALANCE, req, {
+ node,
+ });
+ return this.balanceService.getAssetBalance(node, params);
}
}
diff --git a/apps/xcm-api/src/balance/balance.service.test.ts b/apps/xcm-api/src/balance/balance.service.test.ts
index 7db87005..6e427ae6 100644
--- a/apps/xcm-api/src/balance/balance.service.test.ts
+++ b/apps/xcm-api/src/balance/balance.service.test.ts
@@ -47,7 +47,7 @@ describe('BalanceService', () => {
const params: BalanceNativeDto = { address: '0x1234567890' };
await expect(
- balanceService.getBalanceNativePjs(invalidNode, params),
+ balanceService.getBalanceNative(invalidNode, params),
).rejects.toThrow(BadRequestException);
});
@@ -64,10 +64,7 @@ describe('BalanceService', () => {
const disconnectSpy = vi.spyOn(mockApiInstance, 'disconnect');
- const result = await balanceService.getBalanceNativePjs(
- validNode,
- params,
- );
+ const result = await balanceService.getBalanceNative(validNode, params);
expect(createApiInstanceForNode).toHaveBeenCalledWith(validNode);
expect(getBalanceNative).toHaveBeenCalledWith({
@@ -94,9 +91,10 @@ describe('BalanceService', () => {
const disconnectSpy = vi.spyOn(mockApiInstance, 'destroy');
- const result = await balanceService.getBalanceNativePapi(
+ const result = await balanceService.getBalanceNative(
validNode,
params,
+ true,
);
expect(createApiInstanceForNode).toHaveBeenCalledWith(validNode);
@@ -120,7 +118,7 @@ describe('BalanceService', () => {
};
await expect(
- balanceService.getBalanceForeignPjs(invalidNode, params),
+ balanceService.getBalanceForeign(invalidNode, params),
).rejects.toThrow(BadRequestException);
});
@@ -140,10 +138,7 @@ describe('BalanceService', () => {
const disconnectSpy = vi.spyOn(mockApiInstance, 'disconnect');
- const result = await balanceService.getBalanceForeignPjs(
- validNode,
- params,
- );
+ const result = await balanceService.getBalanceForeign(validNode, params);
expect(createApiInstanceForNode).toHaveBeenCalledWith(validNode);
expect(getBalanceForeign).toHaveBeenCalledWith({
@@ -171,10 +166,7 @@ describe('BalanceService', () => {
const disconnectSpy = vi.spyOn(mockApiInstance, 'disconnect');
- const result = await balanceService.getBalanceForeignPjs(
- validNode,
- params,
- );
+ const result = await balanceService.getBalanceForeign(validNode, params);
expect(createApiInstanceForNode).toHaveBeenCalledWith(validNode);
expect(getBalanceForeign).toHaveBeenCalledWith({
@@ -205,9 +197,10 @@ describe('BalanceService', () => {
const disconnectSpy = vi.spyOn(mockApiInstance, 'destroy');
- const result = await balanceService.getBalanceForeignPapi(
+ const result = await balanceService.getBalanceForeign(
validNode,
params,
+ true,
);
expect(createApiInstanceForNodePapi).toHaveBeenCalledWith(validNode);
@@ -222,4 +215,75 @@ describe('BalanceService', () => {
expect(result).toEqual(mockBalance.toString());
});
});
+
+ describe('getAssetBalance', () => {
+ it('should throw BadRequestException for an invalid node', async () => {
+ const invalidNode = 'invalid-node';
+ const params: BalanceForeignDto = {
+ address: '0x1234567890',
+ currency: { symbol: 'UNQ' },
+ };
+
+ await expect(
+ balanceService.getBalanceForeign(invalidNode, params),
+ ).rejects.toThrow(BadRequestException);
+ });
+
+ it('should return foreign balance as a string for a valid node', async () => {
+ const validNode = 'valid-node';
+ const params: BalanceForeignDto = {
+ address: '0x1234567890',
+ currency: { symbol: 'UNQ' },
+ };
+ const mockApiInstance = {
+ disconnect: vi.fn(),
+ } as unknown as ApiPromise;
+ const mockBalance = 500n;
+
+ vi.mocked(createApiInstanceForNode).mockResolvedValue(mockApiInstance);
+ vi.mocked(getBalanceForeign).mockResolvedValue(mockBalance);
+
+ const disconnectSpy = vi.spyOn(mockApiInstance, 'disconnect');
+
+ const result = await balanceService.getBalanceForeign(validNode, params);
+
+ expect(createApiInstanceForNode).toHaveBeenCalledWith(validNode);
+ expect(getBalanceForeign).toHaveBeenCalledWith({
+ address: params.address,
+ node: validNode,
+ currency: params.currency,
+ api: mockApiInstance,
+ });
+ expect(disconnectSpy).toHaveBeenCalled();
+ expect(result).toEqual(mockBalance.toString());
+ });
+
+ it('should return "null" if foreign balance is null', async () => {
+ const validNode = 'valid-node';
+ const params: BalanceForeignDto = {
+ address: '0x1234567890',
+ currency: { symbol: 'UNQ' },
+ };
+ const mockApiInstance = {
+ disconnect: vi.fn(),
+ } as unknown as ApiPromise;
+
+ vi.mocked(createApiInstanceForNode).mockResolvedValue(mockApiInstance);
+ vi.mocked(getBalanceForeign).mockResolvedValue(BigInt(0));
+
+ const disconnectSpy = vi.spyOn(mockApiInstance, 'disconnect');
+
+ const result = await balanceService.getBalanceForeign(validNode, params);
+
+ expect(createApiInstanceForNode).toHaveBeenCalledWith(validNode);
+ expect(getBalanceForeign).toHaveBeenCalledWith({
+ address: params.address,
+ node: validNode,
+ currency: params.currency,
+ api: mockApiInstance,
+ });
+ expect(disconnectSpy).toHaveBeenCalled();
+ expect(result).toEqual('0');
+ });
+ });
});
diff --git a/apps/xcm-api/src/balance/balance.service.ts b/apps/xcm-api/src/balance/balance.service.ts
index 5c542d76..8a3db202 100644
--- a/apps/xcm-api/src/balance/balance.service.ts
+++ b/apps/xcm-api/src/balance/balance.service.ts
@@ -12,15 +12,7 @@ import { PolkadotClient } from 'polkadot-api';
@Injectable()
export class BalanceService {
- async getBalanceNativePjs(node: string, params: BalanceNativeDto) {
- return await this.getBalanceNative(node, params);
- }
-
- async getBalanceNativePapi(node: string, params: BalanceNativeDto) {
- return await this.getBalanceNative(node, params, true);
- }
-
- private async getBalanceNative(
+ async getBalanceNative(
node: string,
{ address }: BalanceNativeDto,
usePapi = false,
@@ -47,15 +39,35 @@ export class BalanceService {
return balance;
}
- async getBalanceForeignPjs(node: string, params: BalanceForeignDto) {
- return await this.getBalanceForeign(node, params);
- }
+ async getBalanceForeign(
+ node: string,
+ { address, currency }: BalanceForeignDto,
+ usePapi = false,
+ ) {
+ const nodeTyped = node as TNodePolkadotKusama;
+ if (!NODE_NAMES_DOT_KSM.includes(nodeTyped)) {
+ throw new BadRequestException(
+ `Node ${node} is not valid. Check docs for valid nodes.`,
+ );
+ }
- async getBalanceForeignPapi(node: string, params: BalanceForeignDto) {
- return await this.getBalanceForeign(node, params, true);
+ const Sdk = usePapi
+ ? await import('@paraspell/sdk/papi')
+ : await import('@paraspell/sdk');
+
+ const api = await Sdk.createApiInstanceForNode(nodeTyped);
+ const balance = await Sdk.getBalanceForeign({
+ address,
+ currency,
+ node: nodeTyped,
+ api: api as ApiPromise & PolkadotClient,
+ });
+ if ('disconnect' in api) await api.disconnect();
+ else api.destroy();
+ return balance === null ? 'null' : balance.toString();
}
- private async getBalanceForeign(
+ async getAssetBalance(
node: string,
{ address, currency }: BalanceForeignDto,
usePapi = false,
@@ -72,7 +84,7 @@ export class BalanceService {
: await import('@paraspell/sdk');
const api = await Sdk.createApiInstanceForNode(nodeTyped);
- const balance = await Sdk.getBalanceForeign({
+ const balance = await Sdk.getAssetBalance({
address,
currency,
node: nodeTyped,
diff --git a/apps/xcm-api/src/router/router.controller.test.ts b/apps/xcm-api/src/router/router.controller.test.ts
index a4c68c02..a9de5882 100644
--- a/apps/xcm-api/src/router/router.controller.test.ts
+++ b/apps/xcm-api/src/router/router.controller.test.ts
@@ -59,34 +59,7 @@ describe('RouterController', () => {
expect(spy).toHaveBeenCalledWith(queryParams);
});
- it('should call generateExtrinsics service method with correct parameters and return result - hash', async () => {
- const queryParams: RouterDto = {
- from: 'Astar',
- exchange: 'AcalaDex',
- to: 'Moonbeam',
- currencyFrom: { symbol: 'ASTR' },
- currencyTo: { symbol: 'GLMR' },
- amount: '1000000000000000000',
- injectorAddress: '5F5586mfsnM6durWRLptYt3jSUs55KEmahdodQ5tQMr9iY96',
- recipientAddress: '5F5586mfsnM6durWRLptYt3jSUs55KEmahdodQ5tQMr9iY96',
- };
-
- const mockResult: Awaited> =
- [];
- const spy = vi
- .spyOn(service, 'generateExtrinsics')
- .mockResolvedValue(mockResult);
-
- const result = await controller.generateExtrinsicsV2Hash(
- queryParams,
- {} as unknown as Request,
- );
-
- expect(result).toBe(mockResult);
- expect(spy).toHaveBeenCalledWith(queryParams, true);
- });
-
- it('should call generateExtrinsics service method with correct parameters and return result - V2 POST', async () => {
+ it('should call generateExtrinsics service method with correct parameters and return result', async () => {
const queryParams: RouterDto = {
from: 'Astar',
exchange: 'AcalaDex',
@@ -104,7 +77,7 @@ describe('RouterController', () => {
.spyOn(service, 'generateExtrinsics')
.mockResolvedValue(mockResult);
- const result = await controller.generateExtrinsicsV2(
+ const result = await controller.generateExtrinsics(
queryParams,
{} as unknown as Request,
);
diff --git a/apps/xcm-api/src/router/router.controller.ts b/apps/xcm-api/src/router/router.controller.ts
index 4d356521..75c9844b 100644
--- a/apps/xcm-api/src/router/router.controller.ts
+++ b/apps/xcm-api/src/router/router.controller.ts
@@ -1,12 +1,4 @@
-import {
- Body,
- Controller,
- Get,
- Post,
- Query,
- Req,
- Request,
-} from '@nestjs/common';
+import { Body, Controller, Post, Req, Request } from '@nestjs/common';
import { RouterService } from './router.service.js';
import { RouterDto } from './dto/RouterDto.js';
import { AnalyticsService } from '../analytics/analytics.service.js';
@@ -36,28 +28,9 @@ export class RouterController {
});
}
- @Get('router')
- generateExtrinsics(@Query() queryParams: RouterDto, @Req() req: Request) {
- this.trackAnalytics(EventName.GENERATE_ROUTER_EXTRINSICS, req, queryParams);
- return this.routerService.generateExtrinsics(queryParams);
- }
-
@Post('router')
- generateExtrinsicsV2(@Body() queryParams: RouterDto, @Req() req: Request) {
+ generateExtrinsics(@Body() queryParams: RouterDto, @Req() req: Request) {
this.trackAnalytics(EventName.GENERATE_ROUTER_EXTRINSICS, req, queryParams);
return this.routerService.generateExtrinsics(queryParams);
}
-
- @Post('router-hash')
- generateExtrinsicsV2Hash(
- @Body() queryParams: RouterDto,
- @Req() req: Request,
- ) {
- this.trackAnalytics(
- EventName.GENERATE_ROUTER_EXTRINSICS_HASH,
- req,
- queryParams,
- );
- return this.routerService.generateExtrinsics(queryParams, true);
- }
}
diff --git a/apps/xcm-api/src/router/router.service.test.ts b/apps/xcm-api/src/router/router.service.test.ts
index f23e21df..4e29b96b 100644
--- a/apps/xcm-api/src/router/router.service.test.ts
+++ b/apps/xcm-api/src/router/router.service.test.ts
@@ -1,16 +1,14 @@
import type { TestingModule } from '@nestjs/testing';
import { Test } from '@nestjs/testing';
import { RouterService } from './router.service.js';
-import * as utils from '../utils.js';
import * as spellRouter from '@paraspell/xcm-router';
import type { RouterDto } from './dto/RouterDto.js';
import {
BadRequestException,
InternalServerErrorException,
} from '@nestjs/common';
-import type { MockInstance } from 'vitest';
import { vi, describe, beforeEach, it, expect } from 'vitest';
-import type { Extrinsic, TNode, TSerializedApiCall } from '@paraspell/sdk';
+import type { TNode } from '@paraspell/sdk';
import { InvalidCurrencyError } from '@paraspell/sdk';
vi.mock('@paraspell/xcm-router', async () => {
@@ -20,19 +18,19 @@ vi.mock('@paraspell/xcm-router', async () => {
buildTransferExtrinsics: vi.fn().mockReturnValue([
{
node: 'Ethereum',
- tx: 'serialized-api-call',
+ tx: '0x123',
type: 'ETH_TRANSFER',
statusType: 'TO_EXCHANGE',
},
{
node: 'AssetHubPolkadot',
- tx: 'serialized-api-call',
+ tx: '0x123',
type: 'EXTRINSIC',
statusType: 'SWAP',
},
{
node: 'Astar',
- tx: 'serialized-api-call',
+ tx: '0x123',
type: 'EXTRINSIC',
statusType: 'TO_DESTINATION',
},
@@ -42,9 +40,6 @@ vi.mock('@paraspell/xcm-router', async () => {
describe('RouterService', () => {
let service: RouterService;
- let serializeExtrinsicSpy: MockInstance<
- (tx: Extrinsic) => TSerializedApiCall
- >;
const options: RouterDto = {
from: 'Astar',
@@ -60,7 +55,8 @@ describe('RouterService', () => {
const invalidNode = 'Astarr';
- const serializedTx = 'serialized-api-call';
+ const serializedTx = '0x123';
+
const serializedExtrinsics = [
{
node: 'Ethereum',
@@ -88,10 +84,6 @@ describe('RouterService', () => {
}).compile();
service = module.get(RouterService);
-
- serializeExtrinsicSpy = vi
- .spyOn(utils, 'serializeExtrinsic')
- .mockReturnValue(serializedTx as unknown as TSerializedApiCall);
});
it('should be defined', () => {
@@ -102,23 +94,7 @@ describe('RouterService', () => {
it('should generate 3 extrinsics with manual exchange selection', async () => {
const spy = vi.spyOn(spellRouter, 'buildTransferExtrinsics');
- const result = await service.generateExtrinsics({
- ...options,
- type: undefined,
- });
-
- expect(result).toStrictEqual(serializedExtrinsics);
- expect(spy).toHaveBeenCalledWith({
- ...options,
- slippagePct: '1',
- type: undefined,
- });
- });
-
- it('should generate 3 extrinsics with manual exchange selection - hash', async () => {
- const spy = vi.spyOn(spellRouter, 'buildTransferExtrinsics');
-
- const result = await service.generateExtrinsics(options, true);
+ const result = await service.generateExtrinsics(options);
expect(result).toStrictEqual(serializedExtrinsics);
expect(spy).toHaveBeenCalledWith({
@@ -139,7 +115,6 @@ describe('RouterService', () => {
BadRequestException,
);
expect(spy).not.toHaveBeenCalled();
- expect(serializeExtrinsicSpy).not.toHaveBeenCalled();
});
it('should throw BadRequestException for invalid to node', async () => {
@@ -154,7 +129,6 @@ describe('RouterService', () => {
BadRequestException,
);
expect(spy).not.toHaveBeenCalled();
- expect(serializeExtrinsicSpy).not.toHaveBeenCalled();
});
it('should throw BadRequestException for invalid exchange node', async () => {
@@ -169,7 +143,6 @@ describe('RouterService', () => {
BadRequestException,
);
expect(spy).not.toHaveBeenCalled();
- expect(serializeExtrinsicSpy).not.toHaveBeenCalled();
});
it('should throw BadRequestException for invalid injector address', async () => {
@@ -184,7 +157,6 @@ describe('RouterService', () => {
BadRequestException,
);
expect(spy).not.toHaveBeenCalled();
- expect(serializeExtrinsicSpy).not.toHaveBeenCalled();
});
it('should throw BadRequestException for invalid recipient address', async () => {
@@ -199,7 +171,6 @@ describe('RouterService', () => {
BadRequestException,
);
expect(spy).not.toHaveBeenCalled();
- expect(serializeExtrinsicSpy).not.toHaveBeenCalled();
});
it('should throw InternalServerError when uknown error occures in the spell router', async () => {
diff --git a/apps/xcm-api/src/router/router.service.ts b/apps/xcm-api/src/router/router.service.ts
index c3984bba..19e2bf69 100644
--- a/apps/xcm-api/src/router/router.service.ts
+++ b/apps/xcm-api/src/router/router.service.ts
@@ -9,7 +9,7 @@ import {
TNodeWithRelayChains,
} from '@paraspell/sdk';
import { RouterDto } from './dto/RouterDto.js';
-import { isValidWalletAddress, serializeExtrinsic } from '../utils.js';
+import { isValidWalletAddress } from '../utils.js';
import {
EXCHANGE_NODES,
TExchangeNode,
@@ -19,7 +19,7 @@ import {
@Injectable()
export class RouterService {
- async generateExtrinsics(options: RouterDto, hashEnabled = false) {
+ async generateExtrinsics(options: RouterDto) {
const {
from,
exchange,
@@ -72,15 +72,7 @@ export class RouterService {
slippagePct,
});
- return hashEnabled
- ? txs
- : txs.map((extrinsic) => ({
- ...extrinsic,
- tx:
- extrinsic.type === 'EXTRINSIC'
- ? serializeExtrinsic(extrinsic.tx)
- : extrinsic.tx,
- }));
+ return txs;
} catch (e) {
if (e instanceof InvalidCurrencyError) {
throw new BadRequestException(e.message);
diff --git a/apps/xcm-api/src/transfer-info/transfer-info.controller.test.ts b/apps/xcm-api/src/transfer-info/transfer-info.controller.test.ts
index 5579d714..f27d25c3 100644
--- a/apps/xcm-api/src/transfer-info/transfer-info.controller.test.ts
+++ b/apps/xcm-api/src/transfer-info/transfer-info.controller.test.ts
@@ -44,7 +44,7 @@ describe('TransferInfoController', () => {
};
const mockResult = {} as TTransferInfo;
const spy = vi
- .spyOn(service, 'getTransferInfoPjs')
+ .spyOn(service, 'getTransferInfo')
.mockResolvedValue(mockResult);
const result = await controller.getTransferInfo(
@@ -67,7 +67,7 @@ describe('TransferInfoController', () => {
};
const mockResult = {} as TTransferInfo;
const spy = vi
- .spyOn(service, 'getTransferInfoPapi')
+ .spyOn(service, 'getTransferInfo')
.mockResolvedValue(mockResult);
const result = await controller.getTransferInfoPapi(
@@ -76,7 +76,7 @@ describe('TransferInfoController', () => {
);
expect(result).toBe(mockResult);
- expect(spy).toHaveBeenCalledWith(queryParams);
+ expect(spy).toHaveBeenCalledWith(queryParams, true);
});
});
});
diff --git a/apps/xcm-api/src/transfer-info/transfer-info.controller.ts b/apps/xcm-api/src/transfer-info/transfer-info.controller.ts
index f7efeeba..dab06544 100644
--- a/apps/xcm-api/src/transfer-info/transfer-info.controller.ts
+++ b/apps/xcm-api/src/transfer-info/transfer-info.controller.ts
@@ -33,7 +33,7 @@ export class TransferInfoController {
@UsePipes(new ZodValidationPipe(TransferInfoSchema))
async getTransferInfo(@Body() params: TransferInfoDto, @Req() req: Request) {
this.trackAnalytics(EventName.GET_TRANSFER_INFO, req, params);
- return await this.transferInfoService.getTransferInfoPjs(params);
+ return this.transferInfoService.getTransferInfo(params);
}
@Post('transfer-info-papi')
@@ -43,6 +43,6 @@ export class TransferInfoController {
@Req() req: Request,
) {
this.trackAnalytics(EventName.GET_TRANSFER_INFO_PAPI, req, params);
- return await this.transferInfoService.getTransferInfoPapi(params);
+ return this.transferInfoService.getTransferInfo(params, true);
}
}
diff --git a/apps/xcm-api/src/transfer-info/transfer-info.service.test.ts b/apps/xcm-api/src/transfer-info/transfer-info.service.test.ts
index 669b2c8f..c8e6e04c 100644
--- a/apps/xcm-api/src/transfer-info/transfer-info.service.test.ts
+++ b/apps/xcm-api/src/transfer-info/transfer-info.service.test.ts
@@ -33,7 +33,7 @@ describe('TransferInfoService', () => {
it('throws BadRequestException if the origin node is not valid', async () => {
await expect(
- service.getTransferInfoPjs({
+ service.getTransferInfo({
origin: 'InvalidNode',
destination: 'Kusama',
accountOrigin: '0x123',
@@ -46,7 +46,7 @@ describe('TransferInfoService', () => {
it('throws BadRequestException if the destination node is not valid', async () => {
await expect(
- service.getTransferInfoPjs({
+ service.getTransferInfo({
origin: 'Polkadot',
destination: 'InvalidNode',
accountOrigin: '0x123',
@@ -60,7 +60,7 @@ describe('TransferInfoService', () => {
it('throws BadRequestException if the origin wallet address is invalid', async () => {
vi.mocked(isValidWalletAddress).mockReturnValueOnce(false);
await expect(
- service.getTransferInfoPjs({
+ service.getTransferInfo({
origin: 'Polkadot',
destination: 'Kusama',
accountOrigin: '0x123',
@@ -101,7 +101,7 @@ describe('TransferInfoService', () => {
},
};
vi.mocked(getTransferInfo).mockResolvedValue(mockTransferInfo);
- const result = await service.getTransferInfoPjs({
+ const result = await service.getTransferInfo({
origin: 'Polkadot',
destination: 'Kusama',
accountOrigin: '0x123',
@@ -142,14 +142,17 @@ describe('TransferInfoService', () => {
},
};
vi.mocked(getTransferInfoPapi).mockResolvedValue(mockTransferInfo);
- const result = await service.getTransferInfoPapi({
- origin: 'Polkadot',
- destination: 'Kusama',
- accountOrigin: '0x123',
- accountDestination: '0x456',
- currency: { symbol: 'DOT' },
- amount: '1000',
- });
+ const result = await service.getTransferInfo(
+ {
+ origin: 'Polkadot',
+ destination: 'Kusama',
+ accountOrigin: '0x123',
+ accountDestination: '0x456',
+ currency: { symbol: 'DOT' },
+ amount: '1000',
+ },
+ true,
+ );
expect(result).toEqual(mockTransferInfo);
});
@@ -158,7 +161,7 @@ describe('TransferInfoService', () => {
new InvalidCurrencyError('Invalid currency.'),
);
await expect(
- service.getTransferInfoPjs({
+ service.getTransferInfo({
origin: 'Polkadot',
destination: 'Kusama',
accountOrigin: '0x123',
@@ -172,7 +175,7 @@ describe('TransferInfoService', () => {
it('handles unknown errors by throwing InternalServerErrorException', async () => {
vi.mocked(getTransferInfo).mockRejectedValue(new Error('Unknown error.'));
await expect(
- service.getTransferInfoPjs({
+ service.getTransferInfo({
origin: 'Polkadot',
destination: 'Kusama',
accountOrigin: '0x123',
@@ -188,7 +191,7 @@ describe('TransferInfoService', () => {
return address === '0x123';
});
await expect(
- service.getTransferInfoPjs({
+ service.getTransferInfo({
origin: 'Polkadot',
destination: 'Kusama',
accountOrigin: '0x123',
diff --git a/apps/xcm-api/src/transfer-info/transfer-info.service.ts b/apps/xcm-api/src/transfer-info/transfer-info.service.ts
index 046c681a..9893b549 100644
--- a/apps/xcm-api/src/transfer-info/transfer-info.service.ts
+++ b/apps/xcm-api/src/transfer-info/transfer-info.service.ts
@@ -13,15 +13,7 @@ import { TransferInfoDto } from './dto/transfer-info.dto.js';
@Injectable()
export class TransferInfoService {
- async getTransferInfoPjs(options: TransferInfoDto) {
- return await this.getTransferInfo(options);
- }
-
- async getTransferInfoPapi(options: TransferInfoDto) {
- return await this.getTransferInfo(options, true);
- }
-
- private async getTransferInfo(
+ async getTransferInfo(
{
origin,
destination,
diff --git a/apps/xcm-api/src/utils.ts b/apps/xcm-api/src/utils.ts
index 09cbcf44..15b578b7 100644
--- a/apps/xcm-api/src/utils.ts
+++ b/apps/xcm-api/src/utils.ts
@@ -1,9 +1,5 @@
import { BadRequestException } from '@nestjs/common';
-import type {
- Extrinsic,
- TNodePolkadotKusama,
- TSerializedApiCall,
-} from '@paraspell/sdk';
+import type { TNodePolkadotKusama } from '@paraspell/sdk';
import {
NODE_NAMES,
NODE_NAMES_DOT_KSM,
@@ -44,11 +40,3 @@ export const isValidEthereumAddress = (address: string) => isAddress(address);
export const isValidWalletAddress = (address: string) =>
isValidPolkadotAddress(address) || isValidEthereumAddress(address);
-
-export const serializeExtrinsic = (tx: Extrinsic): TSerializedApiCall => {
- return {
- module: tx.method.section,
- section: tx.method.method,
- parameters: tx.method.args.map((arg) => arg.toJSON()),
- };
-};
diff --git a/apps/xcm-api/src/x-transfer/x-transfer.controller.test.ts b/apps/xcm-api/src/x-transfer/x-transfer.controller.test.ts
index 00c3f2e1..60fc4f5c 100644
--- a/apps/xcm-api/src/x-transfer/x-transfer.controller.test.ts
+++ b/apps/xcm-api/src/x-transfer/x-transfer.controller.test.ts
@@ -36,7 +36,7 @@ describe('XTransferController', () => {
describe('generateXcmCall', () => {
it('should call generateXcmCall service method with correct parameters and return result', async () => {
- const queryParams: XTransferDto = {
+ const bodyParams: XTransferDto = {
from: 'Acala',
to: 'Basilisk',
amount: 100,
@@ -45,34 +45,10 @@ describe('XTransferController', () => {
};
const mockResult = {} as Extrinsic;
const spy = vi
- .spyOn(service, 'generateXcmCallPjs')
+ .spyOn(service, 'generateXcmCall')
.mockResolvedValue(mockResult);
const result = await controller.generateXcmCall(
- queryParams,
- mockRequestObject,
- );
-
- expect(result).toBe(mockResult);
- expect(spy).toHaveBeenCalledWith(queryParams);
- });
- });
-
- describe('generateXcmCallV2', () => {
- it('should call generateXcmCall service method with correct parameters and return result', async () => {
- const bodyParams: XTransferDto = {
- from: 'Acala',
- to: 'Basilisk',
- amount: '100',
- address: '5F5586mfsnM6durWRLptYt3jSUs55KEmahdodQ5tQMr9iY96',
- currency: { symbol: 'DOT' },
- };
- const mockResult = {} as Extrinsic;
- const spy = vi
- .spyOn(service, 'generateXcmCallPjs')
- .mockResolvedValue(mockResult);
-
- const result = await controller.generateXcmCallV2(
bodyParams,
mockRequestObject,
);
@@ -80,30 +56,6 @@ describe('XTransferController', () => {
expect(result).toBe(mockResult);
expect(spy).toHaveBeenCalledWith(bodyParams);
});
- });
-
- describe('generateXcmCallV2Hash', () => {
- it('should call generateXcmCall service method with correct parameters and return result', async () => {
- const bodyParams: XTransferDto = {
- from: 'Acala',
- to: 'Basilisk',
- amount: 100,
- address: '5F5586mfsnM6durWRLptYt3jSUs55KEmahdodQ5tQMr9iY96',
- currency: { symbol: 'DOT' },
- };
- const mockResult = {} as Extrinsic;
- const spy = vi
- .spyOn(service, 'generateXcmCallPjs')
- .mockResolvedValue(mockResult);
-
- const result = await controller.generateXcmCallV2Hash(
- bodyParams,
- mockRequestObject,
- );
-
- expect(result).toBe(mockResult);
- expect(spy).toHaveBeenCalledWith(bodyParams, true);
- });
it('should use papi service method if papi flag is set', async () => {
const bodyParams: XTransferDto = {
@@ -115,7 +67,7 @@ describe('XTransferController', () => {
};
const mockResult = {} as Extrinsic;
const spy = vi
- .spyOn(service, 'generateXcmCallPapi')
+ .spyOn(service, 'generateXcmCall')
.mockResolvedValue(mockResult);
const result = await controller.generateXcmCallPapi(
@@ -124,7 +76,7 @@ describe('XTransferController', () => {
);
expect(result).toBe(mockResult);
- expect(spy).toHaveBeenCalledWith(bodyParams);
+ expect(spy).toHaveBeenCalledWith(bodyParams, true);
});
});
@@ -151,10 +103,10 @@ describe('XTransferController', () => {
};
const mockResult = {} as Extrinsic;
const spy = vi
- .spyOn(service, 'generateBatchXcmCallPjs')
+ .spyOn(service, 'generateBatchXcmCall')
.mockResolvedValue(mockResult);
- const result = await controller.generateXcmCallBatchHash(
+ const result = await controller.generateXcmCallBatch(
bodyParams,
mockRequestObject,
);
@@ -185,7 +137,7 @@ describe('XTransferController', () => {
};
const mockResult = {} as Extrinsic;
const spy = vi
- .spyOn(service, 'generateBatchXcmCallPapi')
+ .spyOn(service, 'generateBatchXcmCall')
.mockResolvedValue(mockResult);
const result = await controller.generateXcmCallBatchPapi(
@@ -194,7 +146,7 @@ describe('XTransferController', () => {
);
expect(result).toBe(mockResult);
- expect(spy).toHaveBeenCalledWith(bodyParams);
+ expect(spy).toHaveBeenCalledWith(bodyParams, true);
});
});
});
diff --git a/apps/xcm-api/src/x-transfer/x-transfer.controller.ts b/apps/xcm-api/src/x-transfer/x-transfer.controller.ts
index 7fa8f151..c7bada0d 100644
--- a/apps/xcm-api/src/x-transfer/x-transfer.controller.ts
+++ b/apps/xcm-api/src/x-transfer/x-transfer.controller.ts
@@ -1,13 +1,4 @@
-import {
- Body,
- Controller,
- Request,
- Get,
- Post,
- Query,
- Req,
- UsePipes,
-} from '@nestjs/common';
+import { Body, Controller, Request, Post, Req, UsePipes } from '@nestjs/common';
import { XTransferService } from './x-transfer.service.js';
import { AnalyticsService } from '../analytics/analytics.service.js';
import { EventName } from '../analytics/EventName.js';
@@ -54,46 +45,32 @@ export class XTransferController {
});
}
- @Get('x-transfer')
- @UsePipes(new ZodValidationPipe(XTransferDtoSchema))
- generateXcmCall(@Query() queryParams: XTransferDto, @Req() req: Request) {
- this.trackAnalytics(EventName.GENERATE_XCM_CALL, req, queryParams);
- return this.xTransferService.generateXcmCallPjs(queryParams);
- }
-
@Post('x-transfer')
@UsePipes(new ZodValidationPipe(XTransferDtoSchema))
- generateXcmCallV2(@Body() bodyParams: XTransferDto, @Req() req: Request) {
+ generateXcmCall(@Body() bodyParams: XTransferDto, @Req() req: Request) {
this.trackAnalytics(EventName.GENERATE_XCM_CALL, req, bodyParams);
- return this.xTransferService.generateXcmCallPjs(bodyParams);
- }
-
- @Post('x-transfer-hash')
- @UsePipes(new ZodValidationPipe(XTransferDtoSchema))
- generateXcmCallV2Hash(@Body() bodyParams: XTransferDto, @Req() req: Request) {
- this.trackAnalytics(EventName.GENERATE_XCM_CALL_HASH, req, bodyParams);
- return this.xTransferService.generateXcmCallPjs(bodyParams, true);
+ return this.xTransferService.generateXcmCall(bodyParams);
}
@Post('x-transfer-papi')
@UsePipes(new ZodValidationPipe(XTransferDtoSchema))
generateXcmCallPapi(@Body() bodyParams: XTransferDto, @Req() req: Request) {
this.trackAnalytics(EventName.GENERATE_XCM_CALL, req, bodyParams);
- return this.xTransferService.generateXcmCallPapi(bodyParams);
+ return this.xTransferService.generateXcmCall(bodyParams, true);
}
@Post('x-transfer-batch')
@UsePipes(new ZodValidationPipe(BatchXTransferDtoSchema))
- generateXcmCallBatchHash(
+ generateXcmCallBatch(
@Body() bodyParams: BatchXTransferDto,
@Req() req: Request,
) {
this.trackAnalyticsBatch(
- EventName.GENERATE_XCM_CALL_BATCH_HASH,
+ EventName.GENERATE_XCM_CALL_BATCH,
req,
bodyParams,
);
- return this.xTransferService.generateBatchXcmCallPjs(bodyParams);
+ return this.xTransferService.generateBatchXcmCall(bodyParams);
}
@Post('x-transfer-batch-papi')
@@ -107,6 +84,6 @@ export class XTransferController {
req,
bodyParams,
);
- return this.xTransferService.generateBatchXcmCallPapi(bodyParams);
+ return this.xTransferService.generateBatchXcmCall(bodyParams, true);
}
}
diff --git a/apps/xcm-api/src/x-transfer/x-transfer.service.test.ts b/apps/xcm-api/src/x-transfer/x-transfer.service.test.ts
index f1cbaae4..9ae8a022 100644
--- a/apps/xcm-api/src/x-transfer/x-transfer.service.test.ts
+++ b/apps/xcm-api/src/x-transfer/x-transfer.service.test.ts
@@ -23,11 +23,8 @@ const builderMock = {
addToBatch: vi.fn().mockReturnThis(),
buildBatch: vi.fn().mockReturnValue('batch-transaction'),
build: vi.fn().mockResolvedValue({
- getEncodedData: vi.fn().mockResolvedValue({
- asHex: vi.fn().mockReturnValue('hash'),
- }),
+ toHex: vi.fn().mockReturnValue('hash'),
}),
- buildSerializedApiCall: vi.fn().mockReturnValue('serialized-api-call'),
};
vi.mock('@paraspell/sdk', async () => {
@@ -80,7 +77,7 @@ describe('XTransferService', () => {
const currency = { symbol: 'DOT' };
const batchTransaction = 'batch-transaction';
const invalidNode = 'InvalidNode';
- const serializedApiCall = 'serialized-api-call';
+ const txHash = '0x123';
beforeEach(async () => {
vi.clearAllMocks();
@@ -103,16 +100,16 @@ describe('XTransferService', () => {
currency,
};
- const result = await service.generateXcmCallPjs(xTransferDto);
+ const result = await service.generateXcmCall(xTransferDto);
- expect(result).toBe(serializedApiCall);
+ expect(result).toHaveProperty('toHex');
expect(createApiInstanceForNode).toHaveBeenCalledWith(from);
expect(builderMock.from).toHaveBeenCalledWith(from);
expect(builderMock.to).toHaveBeenCalledWith(to);
expect(builderMock.currency).toHaveBeenCalledWith(currency);
expect(builderMock.amount).toHaveBeenCalledWith(amount);
expect(builderMock.address).toHaveBeenCalledWith(address, undefined);
- expect(builderMock.buildSerializedApiCall).toHaveBeenCalled();
+ expect(builderMock.build).toHaveBeenCalled();
});
it('should generate XCM call for parachain to relaychain transfer', async () => {
@@ -125,14 +122,14 @@ describe('XTransferService', () => {
currency,
};
- const result = await service.generateXcmCallPjs(xTransferDto);
+ const result = await service.generateXcmCall(xTransferDto);
- expect(result).toBe(serializedApiCall);
+ expect(result).toHaveProperty('toHex');
expect(createApiInstanceForNode).toHaveBeenCalledWith(from);
expect(builderMock.from).toHaveBeenCalledWith(from);
expect(builderMock.amount).toHaveBeenCalledWith(amount);
expect(builderMock.address).toHaveBeenCalledWith(address);
- expect(builderMock.buildSerializedApiCall).toHaveBeenCalled();
+ expect(builderMock.build).toHaveBeenCalled();
});
it('should generate XCM call for relaychain to parachain transfer', async () => {
@@ -143,14 +140,14 @@ describe('XTransferService', () => {
address,
};
- const result = await service.generateXcmCallPjs(xTransferDto);
+ const result = await service.generateXcmCall(xTransferDto);
- expect(result).toBe(serializedApiCall);
- expect(createApiInstanceForNode).toHaveBeenCalledWith(to);
+ expect(result).toHaveProperty('toHex');
+ expect(createApiInstanceForNode).toHaveBeenCalledWith('Polkadot');
expect(builderMock.to).toHaveBeenCalledWith(to);
expect(builderMock.amount).toHaveBeenCalledWith(amount);
expect(builderMock.address).toHaveBeenCalledWith(address);
- expect(builderMock.buildSerializedApiCall).toHaveBeenCalled();
+ expect(builderMock.build).toHaveBeenCalled();
});
it('should use papi service method if papi flag is set', async () => {
@@ -163,7 +160,7 @@ describe('XTransferService', () => {
currency,
};
- const result = await service.generateXcmCallPapi(xTransferDto);
+ const result = await service.generateXcmCall(xTransferDto, true);
expect(result).toBe('hash');
expect(paraspellSdkPapi.createApiInstanceForNode).toHaveBeenCalledWith(
@@ -179,7 +176,7 @@ describe('XTransferService', () => {
currency,
};
- await expect(service.generateXcmCallPjs(xTransferDto)).rejects.toThrow(
+ await expect(service.generateXcmCall(xTransferDto)).rejects.toThrow(
BadRequestException,
);
expect(createApiInstanceForNode).not.toHaveBeenCalled();
@@ -193,7 +190,7 @@ describe('XTransferService', () => {
currency,
};
- await expect(service.generateXcmCallPjs(xTransferDto)).rejects.toThrow(
+ await expect(service.generateXcmCall(xTransferDto)).rejects.toThrow(
BadRequestException,
);
expect(createApiInstanceForNode).not.toHaveBeenCalled();
@@ -206,7 +203,7 @@ describe('XTransferService', () => {
currency,
};
- await expect(service.generateXcmCallPjs(xTransferDto)).rejects.toThrow(
+ await expect(service.generateXcmCall(xTransferDto)).rejects.toThrow(
BadRequestException,
);
expect(createApiInstanceForNode).not.toHaveBeenCalled();
@@ -221,7 +218,7 @@ describe('XTransferService', () => {
currency: undefined,
};
- await expect(service.generateXcmCallPjs(xTransferDto)).rejects.toThrow(
+ await expect(service.generateXcmCall(xTransferDto)).rejects.toThrow(
BadRequestException,
);
expect(createApiInstanceForNode).not.toHaveBeenCalled();
@@ -245,7 +242,7 @@ describe('XTransferService', () => {
xcmVersion: vi.fn().mockReturnThis(),
addToBatch: vi.fn().mockReturnThis(),
buildBatch: vi.fn().mockReturnValue('batch-transaction'),
- buildSerializedApiCall: vi
+ build: vi
.fn()
.mockRejectedValue(new InvalidCurrencyError('Incompatible nodes')),
};
@@ -254,7 +251,7 @@ describe('XTransferService', () => {
builderMock as unknown as ReturnType,
);
- await expect(service.generateXcmCallPjs(xTransferDto)).rejects.toThrow(
+ await expect(service.generateXcmCall(xTransferDto)).rejects.toThrow(
BadRequestException,
);
expect(createApiInstanceForNode).toHaveBeenCalled();
@@ -278,16 +275,14 @@ describe('XTransferService', () => {
xcmVersion: vi.fn().mockReturnThis(),
addToBatch: vi.fn().mockReturnThis(),
buildBatch: vi.fn().mockReturnValue('batch-transaction'),
- buildSerializedApiCall: vi
- .fn()
- .mockRejectedValue(new Error('Unknown error')),
+ build: vi.fn().mockRejectedValue(new Error('Unknown error')),
};
vi.spyOn(paraspellSdk, 'Builder').mockReturnValue(
builderMock as unknown as ReturnType,
);
- await expect(service.generateXcmCallPjs(xTransferDto)).rejects.toThrow(
+ await expect(service.generateXcmCall(xTransferDto)).rejects.toThrow(
InternalServerErrorException,
);
expect(createApiInstanceForNode).toHaveBeenCalled();
@@ -302,7 +297,7 @@ describe('XTransferService', () => {
currency,
};
- await expect(service.generateXcmCallPjs(xTransferDto)).rejects.toThrow(
+ await expect(service.generateXcmCall(xTransferDto)).rejects.toThrow(
BadRequestException,
);
expect(createApiInstanceForNode).not.toHaveBeenCalled();
@@ -325,13 +320,13 @@ describe('XTransferService', () => {
amount: vi.fn().mockReturnThis(),
address: vi.fn().mockReturnThis(),
xcmVersion: vi.fn().mockReturnThis(),
- build: vi.fn().mockReturnValue('serialized-api-call'),
+ build: vi.fn().mockReturnValue(txHash),
};
vi.spyOn(paraspellSdk, 'Builder').mockReturnValue(
builderMock as unknown as ReturnType,
);
- await service.generateXcmCallPjs(xTransferDto, true);
+ await service.generateXcmCall(xTransferDto);
expect(builderMock.xcmVersion).toHaveBeenCalledWith(
paraspellSdk.Version.V2,
@@ -347,7 +342,7 @@ describe('XTransferService', () => {
currency,
};
- await expect(service.generateXcmCallPjs(xTransferDto)).rejects.toThrow(
+ await expect(service.generateXcmCall(xTransferDto)).rejects.toThrow(
BadRequestException,
);
});
@@ -368,7 +363,7 @@ describe('XTransferService', () => {
xcmVersion: vi.fn().mockReturnThis(),
addToBatch: vi.fn().mockReturnThis(),
buildBatch: vi.fn().mockReturnValue('batch-transaction'),
- buildSerializedApiCall: vi.fn().mockReturnValue('serialized-api-call'),
+ build: vi.fn().mockReturnValue(txHash),
};
vi.spyOn(paraspellSdk, 'Builder').mockReturnValue(
@@ -397,7 +392,7 @@ describe('XTransferService', () => {
},
};
- const result = await service.generateBatchXcmCallPjs(batchDto);
+ const result = await service.generateBatchXcmCall(batchDto);
expect(result).toBe(batchTransaction);
expect(createApiInstanceForNode).toHaveBeenCalledWith(from);
@@ -421,7 +416,7 @@ describe('XTransferService', () => {
xcmVersion: vi.fn().mockReturnThis(),
addToBatch: vi.fn().mockReturnThis(),
buildBatch: vi.fn().mockReturnValue('batch-transaction'),
- buildSerializedApiCall: vi.fn().mockReturnValue('serialized-api-call'),
+ build: vi.fn().mockReturnValue(txHash),
};
vi.spyOn(paraspellSdk, 'Builder').mockReturnValue(
@@ -441,7 +436,7 @@ describe('XTransferService', () => {
},
};
- const result = await service.generateBatchXcmCallPjs(batchDto);
+ const result = await service.generateBatchXcmCall(batchDto);
expect(result).toBe(batchTransaction);
expect(createApiInstanceForNode).toHaveBeenCalledWith('Polkadot');
@@ -460,7 +455,7 @@ describe('XTransferService', () => {
},
};
- await expect(service.generateBatchXcmCallPjs(batchDto)).rejects.toThrow(
+ await expect(service.generateBatchXcmCall(batchDto)).rejects.toThrow(
BadRequestException,
);
expect(createApiInstanceForNode).not.toHaveBeenCalled();
@@ -477,7 +472,7 @@ describe('XTransferService', () => {
],
};
- await expect(service.generateBatchXcmCallPjs(batchDto)).rejects.toThrow(
+ await expect(service.generateBatchXcmCall(batchDto)).rejects.toThrow(
BadRequestException,
);
expect(createApiInstanceForNode).not.toHaveBeenCalled();
@@ -507,7 +502,7 @@ describe('XTransferService', () => {
],
};
- await expect(service.generateBatchXcmCallPjs(batchDto)).rejects.toThrow(
+ await expect(service.generateBatchXcmCall(batchDto)).rejects.toThrow(
BadRequestException,
);
expect(createApiInstanceForNode).not.toHaveBeenCalled();
@@ -528,7 +523,7 @@ describe('XTransferService', () => {
],
};
- await expect(service.generateBatchXcmCallPjs(batchDto)).rejects.toThrow(
+ await expect(service.generateBatchXcmCall(batchDto)).rejects.toThrow(
BadRequestException,
);
expect(createApiInstanceForNode).not.toHaveBeenCalled();
@@ -549,7 +544,7 @@ describe('XTransferService', () => {
],
};
- await expect(service.generateBatchXcmCallPjs(batchDto)).rejects.toThrow(
+ await expect(service.generateBatchXcmCall(batchDto)).rejects.toThrow(
BadRequestException,
);
expect(createApiInstanceForNode).not.toHaveBeenCalled();
@@ -571,7 +566,7 @@ describe('XTransferService', () => {
],
};
- await expect(service.generateBatchXcmCallPjs(batchDto)).rejects.toThrow(
+ await expect(service.generateBatchXcmCall(batchDto)).rejects.toThrow(
BadRequestException,
);
});
@@ -592,7 +587,7 @@ describe('XTransferService', () => {
],
} as unknown as BatchXTransferDto;
- await expect(service.generateBatchXcmCallPjs(batchDto)).rejects.toThrow(
+ await expect(service.generateBatchXcmCall(batchDto)).rejects.toThrow(
BadRequestException,
);
});
@@ -613,7 +608,7 @@ describe('XTransferService', () => {
],
};
- const result = await service.generateBatchXcmCallPapi(batchDto);
+ const result = await service.generateBatchXcmCall(batchDto, true);
expect(result).toBe('hash');
expect(paraspellSdkPapi.createApiInstanceForNode).toHaveBeenCalledWith(
@@ -655,7 +650,7 @@ describe('XTransferService', () => {
],
};
- await expect(service.generateBatchXcmCallPjs(batchDto)).rejects.toThrow(
+ await expect(service.generateBatchXcmCall(batchDto)).rejects.toThrow(
BadRequestException,
);
expect(createApiInstanceForNode).toHaveBeenCalledWith(from);
@@ -695,7 +690,7 @@ describe('XTransferService', () => {
],
};
- await expect(service.generateBatchXcmCallPjs(batchDto)).rejects.toThrow(
+ await expect(service.generateBatchXcmCall(batchDto)).rejects.toThrow(
InternalServerErrorException,
);
expect(createApiInstanceForNode).toHaveBeenCalledWith(from);
@@ -717,7 +712,7 @@ describe('XTransferService', () => {
],
} as unknown as BatchXTransferDto;
- await expect(service.generateBatchXcmCallPjs(batchDto)).rejects.toThrow(
+ await expect(service.generateBatchXcmCall(batchDto)).rejects.toThrow(
BadRequestException,
);
@@ -747,7 +742,7 @@ describe('XTransferService', () => {
],
};
- await expect(service.generateBatchXcmCallPjs(batchDto)).rejects.toThrow(
+ await expect(service.generateBatchXcmCall(batchDto)).rejects.toThrow(
BadRequestException,
);
@@ -783,7 +778,7 @@ describe('XTransferService', () => {
options: undefined,
} as unknown as BatchXTransferDto;
- const result = await service.generateBatchXcmCallPjs(batchDto);
+ const result = await service.generateBatchXcmCall(batchDto);
expect(result).toBe(batchTransaction);
expect(createApiInstanceForNode).toHaveBeenCalledWith(from);
@@ -826,7 +821,7 @@ describe('XTransferService', () => {
builderMock as unknown as ReturnType,
);
- const result = await service.generateBatchXcmCallPjs(batchDto);
+ const result = await service.generateBatchXcmCall(batchDto);
expect(result).toBe(batchTransaction);
expect(builderMock.xcmVersion).toHaveBeenCalledWith(
diff --git a/apps/xcm-api/src/x-transfer/x-transfer.service.ts b/apps/xcm-api/src/x-transfer/x-transfer.service.ts
index 8ba4aa6e..9ecb9205 100644
--- a/apps/xcm-api/src/x-transfer/x-transfer.service.ts
+++ b/apps/xcm-api/src/x-transfer/x-transfer.service.ts
@@ -23,15 +23,7 @@ import { TPapiTransaction } from '@paraspell/sdk/papi';
@Injectable()
export class XTransferService {
- async generateXcmCallPjs(options: XTransferDto, hashEnabled = false) {
- return await this.generateXcmCall(options, hashEnabled);
- }
-
- async generateXcmCallPapi(options: XTransferDto) {
- return await this.generateXcmCall(options, true, true);
- }
-
- private async generateXcmCall(
+ async generateXcmCall(
{
from,
to,
@@ -41,7 +33,6 @@ export class XTransferService {
currency,
xcmVersion,
}: XTransferDto,
- hashEnabled: boolean,
usePapi = false,
) {
const fromNode = from as TNodePolkadotKusama | undefined;
@@ -83,7 +74,9 @@ export class XTransferService {
? await import('@paraspell/sdk/papi')
: await import('@paraspell/sdk');
- const node = fromNode ?? toNode;
+ const node = !fromNode
+ ? determineRelayChain(toNode as TNodePolkadotKusama)
+ : fromNode;
const api = await Sdk.createApiInstanceForNode(node as TNodePolkadotKusama);
const builder = Sdk.Builder(api as PolkadotClient & ApiPromise);
@@ -121,9 +114,7 @@ export class XTransferService {
return (await (tx as TPapiTransaction).getEncodedData()).asHex();
}
- return hashEnabled
- ? await finalBuilder.build()
- : await finalBuilder.buildSerializedApiCall();
+ return await finalBuilder.build();
} catch (e) {
if (
e instanceof InvalidCurrencyError ||
@@ -140,18 +131,7 @@ export class XTransferService {
}
}
- async generateBatchXcmCallPjs(batchDto: BatchXTransferDto) {
- return await this.generateBatchXcmCall(batchDto);
- }
-
- async generateBatchXcmCallPapi(batchDto: BatchXTransferDto) {
- return await this.generateBatchXcmCall(batchDto, true);
- }
-
- private async generateBatchXcmCall(
- batchDto: BatchXTransferDto,
- usePapi = false,
- ) {
+ async generateBatchXcmCall(batchDto: BatchXTransferDto, usePapi = false) {
const { transfers, options } = batchDto;
if (!transfers || transfers.length === 0) {
@@ -276,10 +256,8 @@ export class XTransferService {
e instanceof IncompatibleNodesError ||
e instanceof BadRequestException
) {
- console.error(e);
throw new BadRequestException(e.message);
}
- console.log(e);
throw new InternalServerErrorException((e as Error).message);
} finally {
diff --git a/apps/xcm-api/src/zod-validation-pipe.test.ts b/apps/xcm-api/src/zod-validation-pipe.test.ts
index bb61e0db..99c7edbd 100644
--- a/apps/xcm-api/src/zod-validation-pipe.test.ts
+++ b/apps/xcm-api/src/zod-validation-pipe.test.ts
@@ -1,6 +1,6 @@
-import { describe, it, expect, vi } from 'vitest';
+import { describe, it, expect } from 'vitest';
import { BadRequestException } from '@nestjs/common';
-import { z, ZodError } from 'zod';
+import { z } from 'zod';
import { ZodValidationPipe } from './zod-validation-pipe.js';
describe('ZodValidationPipe', () => {
@@ -30,18 +30,4 @@ describe('ZodValidationPipe', () => {
BadRequestException,
);
});
-
- it('should log an error message when validation fails', () => {
- const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
- const pipe = new ZodValidationPipe(invalidSchema);
- const invalidValue = { age: -10 };
-
- try {
- pipe.transform(invalidValue);
- } catch (_error) {
- expect(consoleSpy).toHaveBeenCalledWith('error', expect.any(ZodError));
- }
-
- consoleSpy.mockRestore();
- });
});
diff --git a/apps/xcm-api/src/zod-validation-pipe.ts b/apps/xcm-api/src/zod-validation-pipe.ts
index 87c30f78..ab4a5ff2 100644
--- a/apps/xcm-api/src/zod-validation-pipe.ts
+++ b/apps/xcm-api/src/zod-validation-pipe.ts
@@ -10,7 +10,6 @@ export class ZodValidationPipe implements PipeTransform {
try {
return this.schema.parse(value) as unknown;
} catch (error) {
- console.log('error', error);
if (error instanceof ZodError) {
throw new BadRequestException({
message: error.errors,
diff --git a/apps/xcm-api/test/app.e2e-spec.ts b/apps/xcm-api/test/app.e2e-spec.ts
index 55b0275a..48bc87e5 100644
--- a/apps/xcm-api/test/app.e2e-spec.ts
+++ b/apps/xcm-api/test/app.e2e-spec.ts
@@ -16,7 +16,6 @@ import {
TMultiLocation,
TNode,
Version,
- createApiInstanceForNode,
getAllAssetsSymbols,
getAssetsObject,
getDefaultPallet,
@@ -338,25 +337,22 @@ describe('XCM API (e2e)', () => {
const amount = '1000000000';
const address = 'FagnR7YW9N2PZfxC3dwSqQjb59Jsz3x35UZ24MqtA4eTVZR';
const xTransferUrl = '/x-transfer';
- const xTransferHashUrl = '/x-transfer-hash';
const xTransferBatchUrl = '/x-transfer-batch';
- const routerUrl = '/router';
- const routerHashUrl = '/router-hash';
- it(`Generate XCM call - No from or to provided - ${xTransferUrl} (GET)`, () => {
+ it(`Generate XCM call - No from or to provided - ${xTransferUrl}`, () => {
return request(app.getHttpServer())
- .get(xTransferUrl)
- .query({
+ .post(xTransferUrl)
+ .send({
amount,
address,
})
.expect(400);
});
- it(`Generate XCM call - Invalid from - ${xTransferUrl} (GET)`, () => {
+ it(`Generate XCM call - Invalid from - ${xTransferUrl}`, () => {
return request(app.getHttpServer())
- .get(xTransferUrl)
- .query({
+ .post(xTransferUrl)
+ .send({
from: unknownNode,
amount,
address,
@@ -364,10 +360,10 @@ describe('XCM API (e2e)', () => {
.expect(400);
});
- it(`Generate XCM call - Invalid to - ${xTransferUrl} (GET)`, () => {
+ it(`Generate XCM call - Invalid to - ${xTransferUrl}`, () => {
return request(app.getHttpServer())
- .get(xTransferUrl)
- .query({
+ .post(xTransferUrl)
+ .send({
to: unknownNode,
amount,
address,
@@ -375,10 +371,10 @@ describe('XCM API (e2e)', () => {
.expect(400);
});
- it(`Generate XCM call - Parachain to parachain missing currency - ${xTransferUrl} (GET)`, () => {
+ it(`Generate XCM call - Parachain to parachain missing currency - ${xTransferUrl}`, () => {
return request(app.getHttpServer())
- .get(xTransferUrl)
- .query({
+ .post(xTransferUrl)
+ .send({
from: 'Acala',
to: 'Basilisk',
amount,
@@ -387,10 +383,10 @@ describe('XCM API (e2e)', () => {
.expect(400);
});
- it(`Generate XCM call - Parachain to parachain invalid currency - ${xTransferUrl} (GET)`, () => {
+ it(`Generate XCM call - Parachain to parachain invalid currency - ${xTransferUrl}`, () => {
return request(app.getHttpServer())
- .get(xTransferUrl)
- .query({
+ .post(xTransferUrl)
+ .send({
from: 'Acala',
to: 'Basilisk',
amount,
@@ -400,47 +396,19 @@ describe('XCM API (e2e)', () => {
.expect(400);
});
- it(`Generate XCM call - Parachain to parachain all valid - ${xTransferUrl} (POST)`, async () => {
- const from: TNode = 'Acala';
- const to: TNode = 'Hydration';
- const currency = { symbol: 'HDX' };
- const api = await createApiInstanceForNode(from);
- const serializedApiCall = await Builder(api)
- .from(from)
- .to(to)
- .currency(currency)
- .amount(amount)
- .address(address)
- .buildSerializedApiCall();
- await api.disconnect();
- return request(app.getHttpServer())
- .post(xTransferUrl)
- .send({
- from,
- to,
- amount,
- address,
- currency,
- })
- .expect(201)
- .expect(serializedApiCall);
- });
-
- it(`Generate XCM call - Parachain to parachain Native() selector - ${xTransferUrl} (POST)`, async () => {
+ it(`Generate XCM call - Parachain to parachain Native() selector - ${xTransferUrl}`, async () => {
const from: TNode = 'Acala';
const to: TNode = 'Astar';
const currency = { symbol: Native('DOT') };
- const api = await createApiInstanceForNode(from);
- const tx = await Builder(api)
+ const tx = await Builder()
.from(from)
.to(to)
.currency(currency)
.amount(amount)
.address(address)
.build();
- await api.disconnect();
return request(app.getHttpServer())
- .post(xTransferHashUrl)
+ .post(xTransferUrl)
.send({
from,
to,
@@ -452,21 +420,19 @@ describe('XCM API (e2e)', () => {
.expect(JSON.stringify(tx.toHex()));
});
- it(`Generate XCM call - Parachain to parachain Foreign() selector - ${xTransferUrl} (POST)`, async () => {
+ it(`Generate XCM call - Parachain to parachain Foreign() selector - ${xTransferUrl}`, async () => {
const from: TNode = 'Astar';
const to: TNode = 'Acala';
const currency = { symbol: Foreign('HDX') };
- const api = await createApiInstanceForNode(from);
- const tx = await Builder(api)
+ const tx = await Builder()
.from(from)
.to(to)
.currency(currency)
.amount(amount)
.address(address)
.build();
- await api.disconnect();
return request(app.getHttpServer())
- .post(xTransferHashUrl)
+ .post(xTransferUrl)
.send({
from,
to,
@@ -478,12 +444,12 @@ describe('XCM API (e2e)', () => {
.expect(JSON.stringify(tx.toHex()));
});
- it(`Generate XCM call - Parachain to parachain invalid scenario - ${xTransferHashUrl} (POST)`, async () => {
+ it(`Generate XCM call - Parachain to parachain invalid scenario - ${xTransferUrl}`, async () => {
const from: TNode = 'AssetHubKusama';
const to: TNode = 'Basilisk';
const currency = { symbol: 'KSM' };
return request(app.getHttpServer())
- .post(xTransferHashUrl)
+ .post(xTransferUrl)
.send({
from,
to,
@@ -494,7 +460,7 @@ describe('XCM API (e2e)', () => {
.expect(500);
});
- it(`Generate Batch XCM call - Parachain to parachain all valid - ${xTransferBatchUrl} (POST)`, async () => {
+ it(`Generate Batch XCM call - Parachain to parachain all valid - ${xTransferBatchUrl}`, async () => {
const from: TNode = 'AssetHubKusama';
const to1: TNode = 'Basilisk';
const to2: TNode = 'Moonriver';
@@ -502,7 +468,7 @@ describe('XCM API (e2e)', () => {
const amount1 = '1000';
const amount2 = '2000';
const address1 = 'FagnR7YW9N2PZfxC3dwSqQjb59Jsz3x35UZ24MqtA4eTVZR';
- const address2 = 'FagnR7YW9N2PZfxC3dwSqQjb59Jsz3x35UZ24MqtA4eTVZR';
+ const address2 = '0x1501C1413e4178c38567Ada8945A80351F7B8496';
const builder = Builder()
.from(from)
@@ -547,7 +513,7 @@ describe('XCM API (e2e)', () => {
.expect(JSON.stringify(tx.toHex()));
});
- it(`Generate Batch XCM call - Invalid Currency Symbol - ${xTransferBatchUrl} (POST)`, async () => {
+ it(`Generate Batch XCM call - Invalid Currency Symbol - ${xTransferBatchUrl}`, async () => {
const from: TNode = 'AssetHubKusama';
const to: TNode = 'Basilisk';
const invalidCurrency = { symbol: 'INVALID' };
@@ -576,7 +542,7 @@ describe('XCM API (e2e)', () => {
});
});
- it(`Generate Batch XCM call - Different 'from' Nodes - ${xTransferBatchUrl} (POST)`, async () => {
+ it(`Generate Batch XCM call - Different 'from' Nodes - ${xTransferBatchUrl}`, async () => {
const from1: TNode = 'AssetHubKusama';
const from2: TNode = 'Moonriver';
const to: TNode = 'Basilisk';
@@ -615,7 +581,7 @@ describe('XCM API (e2e)', () => {
});
});
- it(`Generate Batch XCM call - Invalid Addresses - ${xTransferBatchUrl} (POST)`, async () => {
+ it(`Generate Batch XCM call - Invalid Addresses - ${xTransferBatchUrl}`, async () => {
const from: TNode = 'AssetHubKusama';
const to: TNode = 'Basilisk';
const currency = { symbol: 'USDT' };
@@ -644,7 +610,7 @@ describe('XCM API (e2e)', () => {
});
});
- it(`Generate Batch XCM call - Empty Transfers Array - ${xTransferBatchUrl} (POST)`, async () => {
+ it(`Generate Batch XCM call - Empty Transfers Array - ${xTransferBatchUrl}`, async () => {
return request(app.getHttpServer())
.post(xTransferBatchUrl)
.send({
@@ -661,7 +627,7 @@ describe('XCM API (e2e)', () => {
});
});
- it(`Generate Batch XCM call - Empty Transfers Array - ${xTransferBatchUrl} (POST)`, async () => {
+ it(`Generate Batch XCM call - Empty Transfers Array - ${xTransferBatchUrl}`, async () => {
return request(app.getHttpServer())
.post(xTransferBatchUrl)
.send({
@@ -678,7 +644,7 @@ describe('XCM API (e2e)', () => {
});
});
- it(`Generate Batch XCM call - Empty Transfers Array - ${xTransferBatchUrl} (POST)`, async () => {
+ it(`Generate Batch XCM call - Empty Transfers Array - ${xTransferBatchUrl}`, async () => {
return request(app.getHttpServer())
.post(xTransferBatchUrl)
.send({
@@ -695,7 +661,7 @@ describe('XCM API (e2e)', () => {
});
});
- it(`Generate Batch XCM call - Invalid Batch Mode - ${xTransferBatchUrl} (POST)`, async () => {
+ it(`Generate Batch XCM call - Invalid Batch Mode - ${xTransferBatchUrl}`, async () => {
const from: TNode = 'AssetHubKusama';
const to: TNode = 'Basilisk';
const currency = { symbol: 'USDT' };
@@ -722,7 +688,7 @@ describe('XCM API (e2e)', () => {
.expect(400); // Expect Bad Request due to invalid batch mode
});
- it(`Generate Batch XCM call - Missing Required Fields - ${xTransferBatchUrl} (POST)`, async () => {
+ it(`Generate Batch XCM call - Missing Required Fields - ${xTransferBatchUrl}`, async () => {
const from: TNode = 'AssetHubKusama';
const currency = { symbol: 'USDT' };
@@ -741,10 +707,10 @@ describe('XCM API (e2e)', () => {
mode: BatchMode.BATCH_ALL,
},
})
- .expect(400); // Expect Bad Request due to missing required field
+ .expect(400);
});
- it(`Generate Batch XCM call - Zero or Negative Amounts - ${xTransferBatchUrl} (POST)`, async () => {
+ it(`Generate Batch XCM call - Zero or Negative Amounts - ${xTransferBatchUrl}`, async () => {
const from: TNode = 'AssetHubKusama';
const to: TNode = 'Basilisk';
const currency = { symbol: 'USDT' };
@@ -770,7 +736,7 @@ describe('XCM API (e2e)', () => {
.expect(400);
});
- it(`Generate Batch XCM call - Batch Mode 'BATCH' - ${xTransferBatchUrl} (POST)`, async () => {
+ it(`Generate Batch XCM call - Batch Mode 'BATCH' - ${xTransferBatchUrl}`, async () => {
const from: TNode = 'AssetHubKusama';
const to1: TNode = 'Basilisk';
const to2: TNode = 'Moonriver';
@@ -778,7 +744,7 @@ describe('XCM API (e2e)', () => {
const amount1 = '1000';
const amount2 = '2000';
const address1 = 'FagnR7YW9N2PZfxC3dwSqQjb59Jsz3x35UZ24MqtA4eTVZR';
- const address2 = 'FagnR7YW9N2PZfxC3dwSqQjb59Jsz3x35UZ24MqtA4eTVZR';
+ const address2 = '0x1501C1413e4178c38567Ada8945A80351F7B8496';
const builder = Builder()
.from(from)
@@ -823,7 +789,7 @@ describe('XCM API (e2e)', () => {
.expect(JSON.stringify(tx.toHex()));
});
- it(`Generate Batch XCM call - Single Transfer in Batch - ${xTransferBatchUrl} (POST)`, async () => {
+ it(`Generate Batch XCM call - Single Transfer in Batch - ${xTransferBatchUrl}`, async () => {
const from: TNode = 'AssetHubKusama';
const to: TNode = 'Basilisk';
const currency = { symbol: 'USDT' };
@@ -859,7 +825,7 @@ describe('XCM API (e2e)', () => {
.expect(JSON.stringify(tx.toHex()));
});
- it(`Generate Batch XCM call - Specifying XCM Version - ${xTransferBatchUrl} (POST)`, async () => {
+ it(`Generate Batch XCM call - Specifying XCM Version - ${xTransferBatchUrl}`, async () => {
const from: TNode = 'AssetHubKusama';
const to: TNode = 'Basilisk';
const currency = { symbol: 'USDT' };
@@ -898,7 +864,7 @@ describe('XCM API (e2e)', () => {
.expect(JSON.stringify(tx.toHex()));
});
- it(`Generate Batch XCM call - Parachain to Relay Chain - ${xTransferBatchUrl} (POST)`, async () => {
+ it(`Generate Batch XCM call - Parachain to Relay Chain - ${xTransferBatchUrl}`, async () => {
const from: TNode = 'Acala';
const amount = '1000';
@@ -928,7 +894,7 @@ describe('XCM API (e2e)', () => {
.expect(JSON.stringify(tx.toHex()));
});
- it(`Generate Batch XCM call - Relay Chain to Parachain - ${xTransferBatchUrl} (POST)`, async () => {
+ it(`Generate Batch XCM call - Relay Chain to Parachain - ${xTransferBatchUrl}`, async () => {
const to: TNode = 'Basilisk';
const amount = '1000';
@@ -958,21 +924,19 @@ describe('XCM API (e2e)', () => {
.expect(JSON.stringify(tx.toHex()));
});
- it(`Generate XCM call - Parachain to parachain all valid - ${xTransferHashUrl} (POST)`, async () => {
+ it(`Generate XCM call - Parachain to parachain all valid - ${xTransferUrl}`, async () => {
const from: TNode = 'AssetHubKusama';
const to: TNode = 'Basilisk';
const currency = { symbol: 'USDT' };
- const api = await createApiInstanceForNode(from);
- const tx = await Builder(api)
+ const tx = await Builder()
.from(from)
.to(to)
.currency(currency)
.amount(amount)
.address(address)
.build();
- await api.disconnect();
return request(app.getHttpServer())
- .post(xTransferHashUrl)
+ .post(xTransferUrl)
.send({
from,
to,
@@ -984,9 +948,9 @@ describe('XCM API (e2e)', () => {
.expect(JSON.stringify(tx.toHex()));
});
- it(`Generate XCM call - Parachain to parachain override currency - ${xTransferUrl} (GET)`, async () => {
- const from: TNode = 'Karura';
- const to: TNode = 'Basilisk';
+ it(`Generate XCM call - Parachain to parachain override currency - ${xTransferUrl}`, async () => {
+ const from: TNode = 'AssetHubPolkadot';
+ const to: TNode = 'Hydration';
const currency: TMultiLocation = {
parents: '0',
interior: {
@@ -995,15 +959,13 @@ describe('XCM API (e2e)', () => {
},
},
};
- const api = await createApiInstanceForNode(from);
- const serializedApiCall = await Builder(api)
+ const tx = await Builder()
.from(from)
.to(to)
.currency({ multilocation: Override(currency) })
.amount(amount)
.address(address)
- .buildSerializedApiCall();
- await api.disconnect();
+ .build();
return request(app.getHttpServer())
.post(xTransferUrl)
.send({
@@ -1014,10 +976,10 @@ describe('XCM API (e2e)', () => {
currency: { multilocation: Override(currency) },
})
.expect(201)
- .expect(serializedApiCall);
+ .expect(JSON.stringify(tx.toHex()));
});
- it(`Generate XCM call - Parachain to parachain override currency as multi asset - ${xTransferUrl} (POST)`, async () => {
+ it(`Generate XCM call - Parachain to parachain override currency as multi asset - ${xTransferUrl}`, async () => {
const from: TNode = 'AssetHubPolkadot';
const to: TNode = 'Acala';
const currency: TMultiAsset = {
@@ -1035,15 +997,13 @@ describe('XCM API (e2e)', () => {
Fungible: '1000000000',
},
};
- const api = await createApiInstanceForNode(from);
- const serializedApiCall = await Builder(api)
+ const tx = await Builder()
.from(from)
.to(to)
.currency({ multiasset: [currency] })
.amount(amount)
.address(address)
- .buildSerializedApiCall();
- await api.disconnect();
+ .build();
return request(app.getHttpServer())
.post(xTransferUrl)
.send({
@@ -1054,76 +1014,66 @@ describe('XCM API (e2e)', () => {
currency: { multiasset: [currency] },
})
.expect(201)
- .expect(serializedApiCall);
+ .expect(JSON.stringify(tx.toHex()));
});
- it(`Generate XCM call - Parachain to relaychain all valid - ${xTransferUrl} (GET)`, async () => {
+ it(`Generate XCM call - Parachain to relaychain all valid - ${xTransferUrl}`, async () => {
const from: TNode = 'AssetHubKusama';
- const api = await createApiInstanceForNode(from);
- const serializedApiCall = await Builder(api)
+ const tx = await Builder()
.from(from)
.amount(amount)
.address(address)
- .buildSerializedApiCall();
- await api.disconnect();
+ .build();
return request(app.getHttpServer())
- .get(xTransferUrl)
- .query({
+ .post(xTransferUrl)
+ .send({
from,
amount,
address,
})
- .expect(200)
- .expect(serializedApiCall);
+ .expect(201)
+ .expect(JSON.stringify(tx.toHex()));
});
- it(`Generate XCM call - Relaychain to parachain all valid - ${xTransferUrl} (GET)`, async () => {
+ it(`Generate XCM call - Relaychain to parachain all valid - ${xTransferUrl}`, async () => {
const to: TNode = 'AssetHubKusama';
- const api = await createApiInstanceForNode(to);
- const serializedApiCall = await Builder(api)
- .to(to)
- .amount(amount)
- .address(address)
- .buildSerializedApiCall();
- await api.disconnect();
+ const tx = await Builder().to(to).amount(amount).address(address).build();
return request(app.getHttpServer())
- .get(xTransferUrl)
- .query({
+ .post(xTransferUrl)
+ .send({
to,
amount,
address,
})
- .expect(200)
- .expect(serializedApiCall);
+ .expect(201)
+ .expect(JSON.stringify(tx.toHex()));
});
- it(`Generate XCM call - Parachain to relaychain all valid - ${xTransferUrl} (GET)`, async () => {
+ it(`Generate XCM call - Parachain to relaychain all valid - ${xTransferUrl}`, async () => {
const from: TNode = 'AssetHubKusama';
- const api = await createApiInstanceForNode(from);
- const serializedApiCall = await Builder(api)
+ const tx = await Builder()
.from(from)
.amount(amount)
.address(address)
.xcmVersion(Version.V3)
- .buildSerializedApiCall();
- await api.disconnect();
+ .build();
return request(app.getHttpServer())
- .get(xTransferUrl)
- .query({
+ .post(xTransferUrl)
+ .send({
from,
amount,
address,
xcmVersion: Version.V3,
})
- .expect(200)
- .expect(serializedApiCall);
+ .expect(201)
+ .expect(JSON.stringify(tx.toHex()));
});
- it(`Generate XCM call - Parachain to relaychain invalid version - ${xTransferUrl} (GET)`, async () => {
+ it(`Generate XCM call - Parachain to relaychain invalid version - ${xTransferUrl}`, async () => {
const from: TNode = 'AssetHubKusama';
return request(app.getHttpServer())
- .get(xTransferUrl)
- .query({
+ .post(xTransferUrl)
+ .send({
from,
amount,
address,
@@ -1131,303 +1081,305 @@ describe('XCM API (e2e)', () => {
})
.expect(400);
});
+ });
- describe('Router controller', () => {
- const routerOptions: RouterDto = {
- from: 'Astar',
- exchange: 'HydrationDex',
- to: 'BifrostPolkadot',
- currencyFrom: { symbol: 'ASTR' },
- currencyTo: { symbol: 'BNC' },
- amount: '10000000000000000000',
- injectorAddress: '5F5586mfsnM6durWRLptYt3jSUs55KEmahdodQ5tQMr9iY96',
- recipientAddress: '5F5586mfsnM6durWRLptYt3jSUs55KEmahdodQ5tQMr9iY96',
- slippagePct: '1',
- };
+ describe('Router controller', () => {
+ const amount = '1000000000';
+ const address = 'FagnR7YW9N2PZfxC3dwSqQjb59Jsz3x35UZ24MqtA4eTVZR';
+ const routerUrl = '/router';
- it(`Generate router call - manual exchange select - ${routerUrl} (GET)`, async () => {
- return request(app.getHttpServer())
- .get(routerUrl)
- .query(routerOptions)
- .expect(200)
- .expect((res) => {
- const data = JSON.parse(res.text);
- expect(Array.isArray(data)).toBeTruthy();
- expect(data).toHaveLength(3);
- data.forEach((txInfo: any) => {
- expect(txInfo).toHaveProperty('tx');
- expect(txInfo).toHaveProperty('node');
- expect(txInfo).toHaveProperty('type');
- expect(txInfo).toHaveProperty('statusType');
- expect(txInfo.tx).toBeTypeOf('object');
- });
+ const routerOptions: RouterDto = {
+ from: 'Astar',
+ exchange: 'HydrationDex',
+ to: 'BifrostPolkadot',
+ currencyFrom: { symbol: 'ASTR' },
+ currencyTo: { symbol: 'BNC' },
+ amount: '10000000000000000000',
+ injectorAddress: '5F5586mfsnM6durWRLptYt3jSUs55KEmahdodQ5tQMr9iY96',
+ recipientAddress: '5F5586mfsnM6durWRLptYt3jSUs55KEmahdodQ5tQMr9iY96',
+ slippagePct: '1',
+ };
+
+ it(`Generate router call - manual exchange select - ${routerUrl}`, async () => {
+ return request(app.getHttpServer())
+ .post(routerUrl)
+ .send(routerOptions)
+ .expect(201)
+ .expect((res) => {
+ const data = JSON.parse(res.text);
+ expect(Array.isArray(data)).toBeTruthy();
+ expect(data).toHaveLength(3);
+ data.forEach((txInfo: any) => {
+ expect(txInfo).toHaveProperty('tx');
+ expect(txInfo).toHaveProperty('node');
+ expect(txInfo).toHaveProperty('type');
+ expect(txInfo).toHaveProperty('statusType');
+ expect(txInfo.tx).toBeTypeOf('string');
});
- });
+ });
+ });
- it(`Generate router call - manual exchange select - ${routerHashUrl} (POST)`, async () => {
- return request(app.getHttpServer())
- .post(routerHashUrl)
- .send(routerOptions)
- .expect(201)
- .expect((res) => {
- const data = JSON.parse(res.text);
- expect(Array.isArray(data)).toBeTruthy();
- expect(data).toHaveLength(3);
- data.forEach((txInfo: any) => {
- expect(txInfo).toHaveProperty('tx');
- expect(txInfo).toHaveProperty('node');
- expect(txInfo).toHaveProperty('type');
- expect(txInfo).toHaveProperty('statusType');
- expect(txInfo.tx).toBeTypeOf('string');
- });
+ it(`Generate router call - manual exchange select - ${routerUrl}`, async () => {
+ return request(app.getHttpServer())
+ .post(routerUrl)
+ .send(routerOptions)
+ .expect(201)
+ .expect((res) => {
+ const data = JSON.parse(res.text);
+ expect(Array.isArray(data)).toBeTruthy();
+ expect(data).toHaveLength(3);
+ data.forEach((txInfo: any) => {
+ expect(txInfo).toHaveProperty('tx');
+ expect(txInfo).toHaveProperty('node');
+ expect(txInfo).toHaveProperty('type');
+ expect(txInfo).toHaveProperty('statusType');
+ expect(txInfo.tx).toBeTypeOf('string');
});
- });
+ });
+ });
- it(`Generate router call - automatic exchange select - ${routerUrl} (GET)`, async () => {
- const automaticSelectOptions = {
- ...routerOptions,
- exchange: undefined,
- };
+ it(`Generate router call - automatic exchange select - ${routerUrl}`, async () => {
+ const automaticSelectOptions = {
+ ...routerOptions,
+ exchange: undefined,
+ };
- return request(app.getHttpServer())
- .get(routerUrl)
- .query(automaticSelectOptions)
- .expect(200)
- .expect((res) => {
- const data = JSON.parse(res.text);
- expect(Array.isArray(data)).toBeTruthy();
- expect(data).toHaveLength(3);
- data.forEach((txInfo: any) => {
- expect(txInfo).toHaveProperty('tx');
- expect(txInfo).toHaveProperty('node');
- expect(txInfo).toHaveProperty('type');
- expect(txInfo).toHaveProperty('statusType');
- expect(txInfo.tx).toBeTypeOf('object');
- });
+ return request(app.getHttpServer())
+ .post(routerUrl)
+ .send(automaticSelectOptions)
+ .expect(201)
+ .expect((res) => {
+ const data = JSON.parse(res.text);
+ expect(Array.isArray(data)).toBeTruthy();
+ expect(data).toHaveLength(3);
+ data.forEach((txInfo: any) => {
+ expect(txInfo).toHaveProperty('tx');
+ expect(txInfo).toHaveProperty('node');
+ expect(txInfo).toHaveProperty('type');
+ expect(txInfo).toHaveProperty('statusType');
+ expect(txInfo.tx).toBeTypeOf('string');
});
- });
+ });
});
+ });
- describe('Asset claim controller', () => {
- it('Generate asset claim call - no from provided - /asset-claim (GET)', () => {
- return request(app.getHttpServer())
- .post('/asset-claim')
- .send({
- address,
- })
- .expect(400);
- });
+ describe('Asset claim controller', () => {
+ const address = 'FagnR7YW9N2PZfxC3dwSqQjb59Jsz3x35UZ24MqtA4eTVZR';
- it('Generate asset claim call - invalid from provided - /asset-claim (GET)', () => {
- return request(app.getHttpServer())
- .post('/asset-claim')
- .send({
- from: unknownNode,
- address,
- })
- .expect(400);
- });
+ it('Generate asset claim call - no from provided - /asset-claim', () => {
+ return request(app.getHttpServer())
+ .post('/asset-claim')
+ .send({
+ address,
+ })
+ .expect(400);
+ });
- it('Generate asset claim call - invalid wallet address - /asset-claim (GET)', () => {
- return request(app.getHttpServer())
- .post('/asset-claim')
- .send({
- from: mockNode,
- address: 'InvalidWalletAddress',
- })
- .expect(400);
- });
+ it('Generate asset claim call - invalid from provided - /asset-claim', () => {
+ return request(app.getHttpServer())
+ .post('/asset-claim')
+ .send({
+ from: unknownNode,
+ address,
+ })
+ .expect(400);
+ });
- it('Generate asset claim call - all valid - /asset-claim (GET)', async () => {
- const from: TNode = 'AssetHubKusama';
- const api = await createApiInstanceForNode(from);
- const fungible = [
- {
- id: {
- Concrete: {
- parents: 0,
- interior: {
- X1: {
- Parachain: '2000',
- },
+ it('Generate asset claim call - invalid wallet address - /asset-claim', () => {
+ return request(app.getHttpServer())
+ .post('/asset-claim')
+ .send({
+ from: mockNode,
+ address: 'InvalidWalletAddress',
+ })
+ .expect(400);
+ });
+
+ it('Generate asset claim call - all valid - /asset-claim', async () => {
+ const from: TNode = 'AssetHubKusama';
+ const fungible = [
+ {
+ id: {
+ Concrete: {
+ parents: 0,
+ interior: {
+ X1: {
+ Parachain: '2000',
},
},
},
- fun: {
- Fungible: '1000000000',
- },
},
- ];
- const serializedApiCall = await Builder(api)
- .claimFrom(from)
- .fungible(fungible)
- .account(address)
- .buildSerializedApiCall();
- await api.disconnect();
- return request(app.getHttpServer())
- .post('/asset-claim')
- .send({
- from,
- fungible,
- address,
- })
- .expect(201)
- .expect(serializedApiCall);
- });
+ fun: {
+ Fungible: '1000000000',
+ },
+ },
+ ];
+ const tx = await Builder()
+ .claimFrom(from)
+ .fungible(fungible)
+ .account(address)
+ .build();
+ return request(app.getHttpServer())
+ .post('/asset-claim')
+ .send({
+ from,
+ fungible,
+ address,
+ })
+ .expect(201)
+ .expect(JSON.stringify(tx.toHex()));
+ });
- it('Generate asset claim call - all valid - /asset-claim-hash (GET)', async () => {
- const from: TNode = 'AssetHubKusama';
- const api = await createApiInstanceForNode(from);
- const fungible = [
- {
- id: {
- Concrete: {
- parents: 0,
- interior: {
- X1: {
- Parachain: '2000',
- },
+ it('Generate asset claim call - all valid - /asset-claim', async () => {
+ const from: TNode = 'AssetHubKusama';
+ const fungible = [
+ {
+ id: {
+ Concrete: {
+ parents: 0,
+ interior: {
+ X1: {
+ Parachain: '2000',
},
},
},
- fun: {
- Fungible: '1000000000',
- },
},
- ];
- const tx = await Builder(api)
- .claimFrom(from)
- .fungible(fungible)
- .account(address)
- .build();
- await api.disconnect();
- return request(app.getHttpServer())
- .post('/asset-claim-hash')
- .send({
- from,
- fungible,
- address,
- })
- .expect(201)
- .expect(JSON.stringify(tx.toHex()));
- });
+ fun: {
+ Fungible: '1000000000',
+ },
+ },
+ ];
+ const tx = await Builder()
+ .claimFrom(from)
+ .fungible(fungible)
+ .account(address)
+ .build();
+ return request(app.getHttpServer())
+ .post('/asset-claim')
+ .send({
+ from,
+ fungible,
+ address,
+ })
+ .expect(201)
+ .expect(JSON.stringify(tx.toHex()));
});
+ });
- describe('Transfer info controller', () => {
- const transferInfo: TransferInfoDto = {
- origin: 'Acala',
- destination: 'Astar',
- accountOrigin: '5F5586mfsnM6durWRLptYt3jSUs55KEmahdodQ5tQMr9iY96',
- accountDestination: '5F5586mfsnM6durWRLptYt3jSUs55KEmahdodQ5tQMr9iY96',
- currency: { symbol: 'DOT' },
- amount: '100000000',
- };
-
- it('Generate transfer info call - invalid origin provided - /transfer-info (POST)', () => {
- return request(app.getHttpServer())
- .post('/transfer-info')
- .send({
- ...transferInfo,
- origin: unknownNode,
- })
- .expect(400);
- });
+ describe('Transfer info controller', () => {
+ const transferInfo: TransferInfoDto = {
+ origin: 'Acala',
+ destination: 'Astar',
+ accountOrigin: '5F5586mfsnM6durWRLptYt3jSUs55KEmahdodQ5tQMr9iY96',
+ accountDestination: '5F5586mfsnM6durWRLptYt3jSUs55KEmahdodQ5tQMr9iY96',
+ currency: { symbol: 'DOT' },
+ amount: '100000000',
+ };
+
+ it('Generate transfer info call - invalid origin provided - /transfer-info', () => {
+ return request(app.getHttpServer())
+ .post('/transfer-info')
+ .send({
+ ...transferInfo,
+ origin: unknownNode,
+ })
+ .expect(400);
+ });
- it('Generate transfer info call - invalid destination provided - /transfer-info (POST)', () => {
- return request(app.getHttpServer())
- .post('/transfer-info')
- .send({
- ...transferInfo,
- destination: unknownNode,
- })
- .expect(400);
- });
+ it('Generate transfer info call - invalid destination provided - /transfer-info', () => {
+ return request(app.getHttpServer())
+ .post('/transfer-info')
+ .send({
+ ...transferInfo,
+ destination: unknownNode,
+ })
+ .expect(400);
+ });
- it('Generate transfer info call - invalid wallet address origin - /transfer-info (POST)', () => {
- return request(app.getHttpServer())
- .post('/transfer-info')
- .send({
- ...transferInfo,
- accountOrigin: 'InvalidWalletAddress',
- })
- .expect(400);
- });
+ it('Generate transfer info call - invalid wallet address origin - /transfer-info', () => {
+ return request(app.getHttpServer())
+ .post('/transfer-info')
+ .send({
+ ...transferInfo,
+ accountOrigin: 'InvalidWalletAddress',
+ })
+ .expect(400);
+ });
- it('Generate transfer info call - invalid wallet address destination - /transfer-info (POST)', () => {
- return request(app.getHttpServer())
- .post('/transfer-info')
- .send({
- ...transferInfo,
- accountDestination: 'InvalidWalletAddress',
- })
- .expect(400);
- });
+ it('Generate transfer info call - invalid wallet address destination - /transfer-info', () => {
+ return request(app.getHttpServer())
+ .post('/transfer-info')
+ .send({
+ ...transferInfo,
+ accountDestination: 'InvalidWalletAddress',
+ })
+ .expect(400);
+ });
- it('Generate transfer info call - all valid - /transfer-info (POST)', async () => {
- return request(app.getHttpServer())
- .post('/transfer-info')
- .send(transferInfo)
- .expect(201);
- });
+ it('Generate transfer info call - all valid - /transfer-info', async () => {
+ return request(app.getHttpServer())
+ .post('/transfer-info')
+ .send(transferInfo)
+ .expect(201);
});
+ });
- describe('XCM Analyser controller', () => {
- it('Get MultiLocation paths - No multilocation or xcm provided - /xcm-analyser (POST)', () => {
- return request(app.getHttpServer()).post('/xcm-analyser').expect(400);
- });
+ describe('XCM Analyser controller', () => {
+ it('Get MultiLocation paths - No multilocation or xcm provided - /xcm-analyser', () => {
+ return request(app.getHttpServer()).post('/xcm-analyser').expect(400);
+ });
- it('Get MultiLocation paths - Invalid multilocation provided - /xcm-analyser (POST)', () => {
- return request(app.getHttpServer())
- .post('/xcm-analyser')
- .send({
- multilocation: {
- parents: '0',
- exterior: {
- X1: {
- Parachain: '2000',
- },
+ it('Get MultiLocation paths - Invalid multilocation provided - /xcm-analyser', () => {
+ return request(app.getHttpServer())
+ .post('/xcm-analyser')
+ .send({
+ multilocation: {
+ parents: '0',
+ exterior: {
+ X1: {
+ Parachain: '2000',
},
},
- })
- .expect(400);
- });
+ },
+ })
+ .expect(400);
+ });
- it('Get MultiLocation paths - XCM without any multilocations provided - /xcm-analyser (POST)', () => {
- return request(app.getHttpServer())
- .post('/xcm-analyser')
- .send({
- xcm: ['0x123'],
- })
- .expect(201)
- .expect('[]');
- });
+ it('Get MultiLocation paths - XCM without any multilocations provided - /xcm-analyser', () => {
+ return request(app.getHttpServer())
+ .post('/xcm-analyser')
+ .send({
+ xcm: ['0x123'],
+ })
+ .expect(201)
+ .expect('[]');
+ });
- it('Get MultiLocation paths - Valid MultiLocation - /xcm-analyser (POST)', () => {
- return request(app.getHttpServer())
- .post('/xcm-analyser')
- .send({
- multilocation: {
- parents: '0',
- interior: {
- X1: {
- Parachain: '2000',
- },
+ it('Get MultiLocation paths - Valid MultiLocation - /xcm-analyser', () => {
+ return request(app.getHttpServer())
+ .post('/xcm-analyser')
+ .send({
+ multilocation: {
+ parents: '0',
+ interior: {
+ X1: {
+ Parachain: '2000',
},
},
- })
- .expect(201)
- .expect('"./Parachain(2000)"');
- });
+ },
+ })
+ .expect(201)
+ .expect('"./Parachain(2000)"');
+ });
- it('Get MultiLocation paths - Valid XCM - /xcm-analyser (POST)', () => {
- return request(app.getHttpServer())
- .post('/xcm-analyser')
- .send({
- xcm: ['0x123'],
- })
- .expect(201)
- .expect('[]');
- });
+ it('Get MultiLocation paths - Valid XCM - /xcm-analyser', () => {
+ return request(app.getHttpServer())
+ .post('/xcm-analyser')
+ .send({
+ xcm: ['0x123'],
+ })
+ .expect(201)
+ .expect('[]');
});
});
});
diff --git a/packages/sdk/scripts/scriptUtils.ts b/packages/sdk/scripts/scriptUtils.ts
index d54fb4c6..e1a33b0f 100644
--- a/packages/sdk/scripts/scriptUtils.ts
+++ b/packages/sdk/scripts/scriptUtils.ts
@@ -50,7 +50,7 @@ export const fetchWithTimeout = async (
): Promise => {
const TIMEOUT_MS = 10000
try {
- return await new Promise((resolve, reject) => {
+ return new Promise((resolve, reject) => {
const wsProvider = new WsProvider(wsUrl)
const timeoutHandle = setTimeout(() => {
@@ -76,8 +76,8 @@ export const fetchTryMultipleProvidersWithTimeout = async (
node: TNodePolkadotKusama,
fetcher: (api: ApiPromise) => T
) => {
- return await fetchTryMultipleProviders(node, async wsUrl => {
- return await fetchWithTimeout(wsUrl, api => fetcher(api))
+ return fetchTryMultipleProviders(node, async wsUrl => {
+ return fetchWithTimeout(wsUrl, api => fetcher(api))
})
}
diff --git a/packages/sdk/src/api/IPolkadotApi.ts b/packages/sdk/src/api/IPolkadotApi.ts
index b29bd442..e149b039 100644
--- a/packages/sdk/src/api/IPolkadotApi.ts
+++ b/packages/sdk/src/api/IPolkadotApi.ts
@@ -3,7 +3,7 @@ import type {
TAsset,
TMultiLocation,
TNodeWithRelayChains,
- TSerializedApiCallV2
+ TSerializedApiCall
} from '../types'
import type { TApiOrUrl } from '../types/TApi'
@@ -13,7 +13,7 @@ export interface IPolkadotApi {
init(node: TNodeWithRelayChains): Promise
createApiInstance: (wsUrl: string) => Promise
createAccountId(address: string): HexString
- callTxMethod(serializedCall: TSerializedApiCallV2): TRes
+ callTxMethod(serializedCall: TSerializedApiCall): TRes
calculateTransactionFee(tx: TRes, address: string): Promise
getBalanceNative(address: string): Promise
getBalanceForeignPolkadotXcm(address: string, id?: string): Promise
diff --git a/packages/sdk/src/builder/builders/AssetClaimBuilder.ts b/packages/sdk/src/builder/builders/AssetClaimBuilder.ts
index def4c6a7..b53dcf5d 100644
--- a/packages/sdk/src/builder/builders/AssetClaimBuilder.ts
+++ b/packages/sdk/src/builder/builders/AssetClaimBuilder.ts
@@ -2,7 +2,6 @@ import {
type TMultiAsset,
type TNodeWithRelayChains,
type TAddress,
- type TSerializedApiCall,
type TVersionClaimAssets
} from '../../types'
import { type TAssetClaimOptions } from '../../types/TAssetClaim'
@@ -92,19 +91,6 @@ class AssetClaimBuilder
const options = this.buildOptions()
return (await claimAssets(options)) as TRes
}
-
- /**
- * Builds and returns a serialized API call for the asset claim.
- *
- * @returns A Promise that resolves to the serialized API call.
- */
- async buildSerializedApiCall(): Promise {
- const options = this.buildOptions()
- return claimAssets({
- ...options,
- serializedApiCallEnabled: true
- }) as Promise
- }
}
export default AssetClaimBuilder
diff --git a/packages/sdk/src/builder/builders/Builder.test.ts b/packages/sdk/src/builder/builders/Builder.test.ts
index 5980804f..038b06da 100644
--- a/packages/sdk/src/builder/builders/Builder.test.ts
+++ b/packages/sdk/src/builder/builders/Builder.test.ts
@@ -14,10 +14,7 @@ import type { Extrinsic } from '../../pjs/types'
vi.mock('../../pallets/xcmPallet/transfer', () => ({
send: vi.fn(),
- sendSerializedApiCall: vi.fn(),
- transferRelayToParaCommon: vi.fn(),
- transferRelayToPara: vi.fn(),
- transferRelayToParaSerializedApiCall: vi.fn()
+ transferRelayToPara: vi.fn()
}))
const NODE: TNode = 'Acala'
@@ -40,12 +37,10 @@ describe('Builder', () => {
})
} as unknown as IPolkadotApi
const destApi = {} as ApiPromise
- const mockExtrinsic = {} as Extrinsic
- const mockSerializedApiCall = {
- module: 'polkadotXcm',
- section: 'send',
- parameters: []
- }
+ const mockExtrinsic = {
+ method: 'transfer',
+ args: []
+ } as unknown as Extrinsic
beforeEach(() => {
vi.resetAllMocks()
@@ -58,13 +53,9 @@ describe('Builder', () => {
describe('Para to para/relay transfer', () => {
let sendSpy: MockInstance
- let sendSerializedApiCallSpy: MockInstance
beforeEach(() => {
sendSpy = vi.spyOn(xcmPallet, 'send').mockResolvedValue(mockExtrinsic)
- sendSerializedApiCallSpy = vi
- .spyOn(xcmPallet, 'sendSerializedApiCall')
- .mockResolvedValue(mockSerializedApiCall)
})
it('should initiate a para to para transfer with currency symbol', async () => {
@@ -87,16 +78,16 @@ describe('Builder', () => {
})
})
- it('should initiate a serialized para to para transfer with currency symbol', async () => {
- const serializedCall = await Builder(mockApi)
+ it('should initiate a para to para transfer with currency symbol', async () => {
+ const tx = await Builder(mockApi)
.from(NODE)
.to(NODE_2)
.currency(CURRENCY)
.amount(AMOUNT)
.address(ADDRESS)
- .buildSerializedApiCall()
+ .build()
- expect(sendSerializedApiCallSpy).toHaveBeenCalledWith({
+ expect(sendSpy).toHaveBeenCalledWith({
api: mockApi,
origin: NODE,
currency: CURRENCY,
@@ -105,7 +96,7 @@ describe('Builder', () => {
destination: NODE_2,
destApiForKeepAlive: expect.any(Object)
})
- expect(serializedCall).toEqual(mockSerializedApiCall)
+ expect(tx).toEqual(mockExtrinsic)
})
it('should initiate a para to para transfer with custom paraId', async () => {
@@ -400,14 +391,10 @@ describe('Builder', () => {
})
})
- it('should initiate a serialized para to relay transfer', async () => {
- const serializedCall = await Builder(mockApi)
- .from(NODE)
- .amount(AMOUNT)
- .address(ADDRESS)
- .buildSerializedApiCall()
+ it('should initiate a para to relay transfer', async () => {
+ const tx = await Builder(mockApi).from(NODE).amount(AMOUNT).address(ADDRESS).build()
- expect(sendSerializedApiCallSpy).toHaveBeenCalledWith({
+ expect(sendSpy).toHaveBeenCalledWith({
api: mockApi,
origin: NODE,
currency: {
@@ -417,7 +404,7 @@ describe('Builder', () => {
address: ADDRESS,
destApiForKeepAlive: expect.any(Object)
})
- expect(serializedCall).toEqual(mockSerializedApiCall)
+ expect(tx).toEqual(mockExtrinsic)
})
it('should throw if a para to relay amount is null', async () => {
@@ -520,22 +507,18 @@ describe('Builder', () => {
})
})
- it('should request a para to para transfer serialized api call with currency id', async () => {
- const serializedApiCall = await Builder(mockApi)
+ it('should request a para to para transfer api call with currency id', async () => {
+ const txHash = await Builder(mockApi)
.from(NODE)
.to(NODE_2)
.currency({ symbol: 'DOT' })
.amount(AMOUNT)
.address(ADDRESS)
- .buildSerializedApiCall()
+ .build()
- expect(serializedApiCall).toHaveProperty('module')
- expect(serializedApiCall).toHaveProperty('section')
- expect(serializedApiCall).toHaveProperty('parameters')
- expect(serializedApiCall.module).toBeTypeOf('string')
- expect(serializedApiCall.section).toBeTypeOf('string')
- expect(Array.isArray(serializedApiCall.parameters)).toBe(true)
- expect(sendSerializedApiCallSpy).toHaveBeenCalledTimes(1)
+ expect(txHash.method).toBeTypeOf('string')
+ expect(Array.isArray(txHash.args)).toBe(true)
+ expect(sendSpy).toHaveBeenCalledTimes(1)
})
it('should initiate a para to relay transfer using batching', async () => {
@@ -637,17 +620,11 @@ describe('Builder', () => {
describe('Relay to para transfer', () => {
let transferRelayToParaSpy: MockInstance
- let transferRelayToParaSerializedApiCallSpy: MockInstance<
- typeof xcmPallet.transferRelayToParaSerializedApiCall
- >
beforeEach(() => {
transferRelayToParaSpy = vi
.spyOn(xcmPallet, 'transferRelayToPara')
.mockResolvedValue(mockExtrinsic)
- transferRelayToParaSerializedApiCallSpy = vi
- .spyOn(xcmPallet, 'transferRelayToParaSerializedApiCall')
- .mockResolvedValue(mockSerializedApiCall)
})
it('should initiate a relay to para transfer', async () => {
@@ -742,20 +719,12 @@ describe('Builder', () => {
).toThrow()
})
- it('should request a relay to para transfer serialized api call', async () => {
- const serializedApiCall = await Builder(mockApi)
- .to(NODE_2)
- .amount(AMOUNT)
- .address(ADDRESS)
- .buildSerializedApiCall()
+ it('should request a relay to para transfer api call', async () => {
+ const tx = await Builder(mockApi).to(NODE_2).amount(AMOUNT).address(ADDRESS).build()
- expect(serializedApiCall).toHaveProperty('module')
- expect(serializedApiCall).toHaveProperty('section')
- expect(serializedApiCall).toHaveProperty('parameters')
- expect(serializedApiCall.module).toBeTypeOf('string')
- expect(serializedApiCall.section).toBeTypeOf('string')
- expect(Array.isArray(serializedApiCall.parameters)).toBe(true)
- expect(transferRelayToParaSerializedApiCallSpy).toHaveBeenCalledTimes(1)
+ expect(tx.method).toBeTypeOf('string')
+ expect(Array.isArray(tx.args)).toBe(true)
+ expect(transferRelayToParaSpy).toHaveBeenCalledTimes(1)
})
it('should initiate a double relay to para transfer using batching', async () => {
@@ -796,25 +765,20 @@ describe('Builder', () => {
})
})
- it('should create a serialized claim asset tx with valid output', async () => {
+ it('should create a claim asset tx with valid output', async () => {
const spy = vi.spyOn(claimAssets, 'default').mockResolvedValue({
- module: 'polkadotXcm',
- section: 'claimAssets',
- parameters: []
+ method: 'claim',
+ args: []
})
- const serializedApiCall = await Builder(mockApi)
+ const tx = await Builder(mockApi)
.claimFrom(NODE)
.fungible([])
.account(ADDRESS)
.xcmVersion(Version.V3)
- .buildSerializedApiCall()
-
- expect(serializedApiCall).toHaveProperty('module')
- expect(serializedApiCall).toHaveProperty('section')
- expect(serializedApiCall).toHaveProperty('parameters')
- expect(serializedApiCall.module).toBeTypeOf('string')
- expect(serializedApiCall.section).toBeTypeOf('string')
- expect(Array.isArray(serializedApiCall.parameters)).toBe(true)
+ .build()
+
+ expect(tx).toHaveProperty('method')
+ expect(tx).toHaveProperty('args')
expect(spy).toHaveBeenCalledTimes(1)
})
})
diff --git a/packages/sdk/src/builder/builders/Builder.ts b/packages/sdk/src/builder/builders/Builder.ts
index 409f7fc7..df7a5be2 100644
--- a/packages/sdk/src/builder/builders/Builder.ts
+++ b/packages/sdk/src/builder/builders/Builder.ts
@@ -3,7 +3,6 @@
import type {
TAmount,
TNode,
- TSerializedApiCall,
TCurrencyInput,
TDestination,
TAddress,
@@ -182,14 +181,12 @@ export const Builder = (api: IPolkadotApi): GeneralBuild
export interface FinalBuilder {
build: () => Promise
- buildSerializedApiCall: () => Promise
}
export interface UseKeepAliveFinalBuilder extends IAddToBatchBuilder {
useKeepAlive: (destApi: TApi) => this
xcmVersion: (version: Version) => this
build: () => Promise
- buildSerializedApiCall: () => Promise
}
export interface AddressBuilder {
diff --git a/packages/sdk/src/builder/builders/ParaToParaBuilder.ts b/packages/sdk/src/builder/builders/ParaToParaBuilder.ts
index be077a2d..5c654441 100644
--- a/packages/sdk/src/builder/builders/ParaToParaBuilder.ts
+++ b/packages/sdk/src/builder/builders/ParaToParaBuilder.ts
@@ -1,7 +1,6 @@
// Implements builder pattern for XCM message creation operations operation
import type {
- TSerializedApiCall,
TSendOptions,
TCurrencyInput,
TAmount,
@@ -15,7 +14,7 @@ import type { AddressBuilder, UseKeepAliveFinalBuilder } from './Builder'
import { GeneralBuilder, type AmountBuilder, type AmountOrFeeAssetBuilder } from './Builder'
import type BatchTransactionManager from './BatchTransactionManager'
import type { IPolkadotApi } from '../../api/IPolkadotApi'
-import { send, sendSerializedApiCall } from '../../pallets/xcmPallet/transfer'
+import { send } from '../../pallets/xcmPallet/transfer'
/**
* Builder class for constructing transactions between parachains.
@@ -168,16 +167,6 @@ class ParaToParaBuilder
const options = this.buildOptions()
return send(options)
}
-
- /**
- * Builds and returns a serialized API call for the transfer.
- *
- * @returns A Promise that resolves to the serialized API call.
- */
- async buildSerializedApiCall(): Promise {
- const options = this.buildOptions()
- return sendSerializedApiCall(options)
- }
}
export default ParaToParaBuilder
diff --git a/packages/sdk/src/builder/builders/ParaToRelayBuilder.ts b/packages/sdk/src/builder/builders/ParaToRelayBuilder.ts
index aa04784e..c5e2ff8f 100644
--- a/packages/sdk/src/builder/builders/ParaToRelayBuilder.ts
+++ b/packages/sdk/src/builder/builders/ParaToRelayBuilder.ts
@@ -1,8 +1,7 @@
// Implements builder pattern for XCM message creation operations operation
-import { send, sendSerializedApiCall } from '../../pallets/xcmPallet/transfer'
+import { send } from '../../pallets/xcmPallet/transfer'
import type {
- TSerializedApiCall,
TSendOptions,
TAmount,
TAddress,
@@ -96,12 +95,7 @@ class ParaToRelayBuilder
async build() {
const options = this.buildOptions()
- return await send(options)
- }
-
- async buildSerializedApiCall(): Promise {
- const options = this.buildOptions()
- return await sendSerializedApiCall(options)
+ return send(options)
}
}
diff --git a/packages/sdk/src/builder/builders/RelayToParaBuilder.ts b/packages/sdk/src/builder/builders/RelayToParaBuilder.ts
index 23e5bc80..401db324 100644
--- a/packages/sdk/src/builder/builders/RelayToParaBuilder.ts
+++ b/packages/sdk/src/builder/builders/RelayToParaBuilder.ts
@@ -1,16 +1,8 @@
// Implements builder pattern for Relay chain to Parachain transfer operation
-import {
- transferRelayToPara,
- transferRelayToParaSerializedApiCall
-} from '../../pallets/xcmPallet/transfer'
+import { transferRelayToPara } from '../../pallets/xcmPallet/transfer'
import type { TRelayToParaDestination } from '../../types'
-import {
- type TSerializedApiCall,
- type TRelayToParaOptions,
- type TAddress,
- type Version
-} from '../../types'
+import { type TRelayToParaOptions, type TAddress, type Version } from '../../types'
import {
type UseKeepAliveFinalBuilder,
type AddressBuilder,
@@ -135,17 +127,7 @@ class RelayToParaBuilder
*/
async build() {
const options = this.buildOptions()
- return await transferRelayToPara(options)
- }
-
- /**
- * Builds and returns a serialized API call for the transfer.
- *
- * @returns A Promise that resolves to the serialized API call.
- */
- async buildSerializedApiCall(): Promise {
- const options = this.buildOptions()
- return await transferRelayToParaSerializedApiCall(options)
+ return transferRelayToPara(options)
}
}
diff --git a/packages/sdk/src/nodes/ParachainNode.test.ts b/packages/sdk/src/nodes/ParachainNode.test.ts
index 35659ad5..e2fa0d40 100644
--- a/packages/sdk/src/nodes/ParachainNode.test.ts
+++ b/packages/sdk/src/nodes/ParachainNode.test.ts
@@ -247,7 +247,7 @@ describe('ParachainNode', () => {
expect(result).toBe('transferXTokens called')
})
- it('should return correct serialized API call from transferRelayToPara', () => {
+ it('should return correct API call from transferRelayToPara', () => {
const options = {} as TRelayToParaOptions
const result = node.transferRelayToPara(options)
diff --git a/packages/sdk/src/nodes/ParachainNode.ts b/packages/sdk/src/nodes/ParachainNode.ts
index 7603aa17..be4e605a 100644
--- a/packages/sdk/src/nodes/ParachainNode.ts
+++ b/packages/sdk/src/nodes/ParachainNode.ts
@@ -13,11 +13,10 @@ import type {
TDestination,
TCurrencySelectionHeaderArr,
TNodePolkadotKusama,
- TTransferReturn,
TMultiAsset,
TMultiLocation,
TMultiLocationHeader,
- TSerializedApiCallV2,
+ TSerializedApiCall,
TAsset,
XTokensTransferInput
} from '../types'
@@ -90,7 +89,7 @@ abstract class ParachainNode {
return true
}
- async transfer(options: TSendInternalOptions): Promise> {
+ async transfer(options: TSendInternalOptions): Promise {
const {
api,
asset,
@@ -101,8 +100,7 @@ abstract class ParachainNode {
overridedCurrencyMultiLocation,
feeAsset,
version,
- ahAddress,
- serializedApiCallEnabled = false
+ ahAddress
} = options
const scenario: TScenario = destination !== undefined ? 'ParaToPara' : 'ParaToRelay'
const paraId =
@@ -139,8 +137,7 @@ abstract class ParachainNode {
paraIdTo: paraId,
destination,
overridedCurrencyMultiLocation,
- feeAsset,
- serializedApiCallEnabled
+ feeAsset
}
if (shouldUseMultiasset) {
@@ -157,11 +154,10 @@ abstract class ParachainNode {
paraId,
origin: this.node,
destination,
- overridedCurrencyMultiLocation,
- serializedApiCallEnabled
+ overridedCurrencyMultiLocation
})
} else if (supportsPolkadotXCM(this)) {
- return await this.transferPolkadotXCM({
+ return this.transferPolkadotXCM({
api,
header: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, paraId),
addressSelection: generateAddressPayload(
@@ -187,7 +183,6 @@ abstract class ParachainNode {
destination,
paraIdTo: paraId,
overridedCurrency: overridedCurrencyMultiLocation,
- serializedApiCallEnabled,
version,
ahAddress
})
@@ -196,7 +191,7 @@ abstract class ParachainNode {
}
}
- transferRelayToPara(options: TRelayToParaOptions): TSerializedApiCallV2 {
+ transferRelayToPara(options: TRelayToParaOptions): TSerializedApiCall {
const { version = Version.V3 } = options
return {
module: 'XcmPallet',
diff --git a/packages/sdk/src/nodes/polkadotXcm/PolkadotXCMTransferImpl.test.ts b/packages/sdk/src/nodes/polkadotXcm/PolkadotXCMTransferImpl.test.ts
index 9cee4fba..1a689619 100644
--- a/packages/sdk/src/nodes/polkadotXcm/PolkadotXCMTransferImpl.test.ts
+++ b/packages/sdk/src/nodes/polkadotXcm/PolkadotXCMTransferImpl.test.ts
@@ -53,34 +53,7 @@ const mockFeeAsset = 1
const mockSection: PolkadotXcmSection = 'limited_reserve_transfer_assets'
describe('PolkadotXCMTransferImpl.transferPolkadotXCM', () => {
- it('should return serialized call structure when serializedApiCallEnabled is true', () => {
- const result = PolkadotXCMTransferImpl.transferPolkadotXCM(
- {
- api: mockApi,
- header: mockHeader,
- addressSelection: mockAddressSelection,
- currencySelection: mockCurrencySelection,
- feeAsset: mockFeeAsset,
- serializedApiCallEnabled: true
- } as unknown as PolkadotXCMTransferInput,
- mockSection,
- { Limited: '1000' }
- )
-
- expect(result).toEqual({
- module: 'PolkadotXcm',
- section: mockSection,
- parameters: [
- mockHeader,
- mockAddressSelection,
- mockCurrencySelection,
- mockFeeAsset,
- { Limited: '1000' }
- ]
- })
- })
-
- it('should call api.tx[module][section] with correct parameters when serializedApiCallEnabled is false and fees is undefined', () => {
+ it('should call api.tx[module][section] with correct parameters when fees is undefined', () => {
const callSpy = vi.spyOn(mockApi, 'callTxMethod')
PolkadotXCMTransferImpl.transferPolkadotXCM(
@@ -89,8 +62,7 @@ describe('PolkadotXCMTransferImpl.transferPolkadotXCM', () => {
header: mockHeader,
addressSelection: mockAddressSelection,
currencySelection: mockCurrencySelection,
- feeAsset: mockFeeAsset,
- serializedApiCallEnabled: false
+ feeAsset: mockFeeAsset
} as unknown as PolkadotXCMTransferInput,
mockSection,
undefined
@@ -122,7 +94,7 @@ describe('PolkadotXCMTransferImpl.transferPolkadotXCM', () => {
})
})
- it('should call api.tx[module][section] with correct parameters when serializedApiCallEnabled is false and fees is "Unlimited"', () => {
+ it('should call api.tx[module][section] with correct parameters when fees is "Unlimited"', () => {
const callSpy = vi.spyOn(mockApi, 'callTxMethod')
PolkadotXCMTransferImpl.transferPolkadotXCM(
@@ -131,8 +103,7 @@ describe('PolkadotXCMTransferImpl.transferPolkadotXCM', () => {
header: mockHeader,
addressSelection: mockAddressSelection,
currencySelection: mockCurrencySelection,
- feeAsset: mockFeeAsset,
- serializedApiCallEnabled: false
+ feeAsset: mockFeeAsset
} as unknown as PolkadotXCMTransferInput,
mockSection,
'Unlimited'
@@ -165,7 +136,7 @@ describe('PolkadotXCMTransferImpl.transferPolkadotXCM', () => {
})
})
- it('should call api.tx[module][section] with correct parameters when serializedApiCallEnabled is false and fees is Limited', () => {
+ it('should call api.tx[module][section] with correct parameters when fees is Limited', () => {
const callSpy = vi.spyOn(mockApi, 'callTxMethod')
PolkadotXCMTransferImpl.transferPolkadotXCM(
@@ -174,8 +145,7 @@ describe('PolkadotXCMTransferImpl.transferPolkadotXCM', () => {
header: mockHeader,
addressSelection: mockAddressSelection,
currencySelection: mockCurrencySelection,
- feeAsset: mockFeeAsset,
- serializedApiCallEnabled: false
+ feeAsset: mockFeeAsset
} as unknown as PolkadotXCMTransferInput,
mockSection,
{ Limited: '1000' }
diff --git a/packages/sdk/src/nodes/polkadotXcm/PolkadotXCMTransferImpl.ts b/packages/sdk/src/nodes/polkadotXcm/PolkadotXCMTransferImpl.ts
index 82125580..a9b4fcc8 100644
--- a/packages/sdk/src/nodes/polkadotXcm/PolkadotXCMTransferImpl.ts
+++ b/packages/sdk/src/nodes/polkadotXcm/PolkadotXCMTransferImpl.ts
@@ -1,12 +1,7 @@
// Contains basic structure of polkadotXCM call
import { DEFAULT_FEE_ASSET } from '../../const'
-import type {
- PolkadotXcmSection,
- TPallet,
- TSerializedApiCallV2,
- TTransferReturn
-} from '../../types'
+import type { PolkadotXcmSection, TPallet, TSerializedApiCall } from '../../types'
import { type PolkadotXCMTransferInput } from '../../types'
class PolkadotXCMTransferImpl {
@@ -16,15 +11,14 @@ class PolkadotXCMTransferImpl {
header,
addressSelection,
currencySelection,
- feeAsset = DEFAULT_FEE_ASSET,
- serializedApiCallEnabled
+ feeAsset = DEFAULT_FEE_ASSET
}: PolkadotXCMTransferInput,
section: PolkadotXcmSection,
fees: 'Unlimited' | { Limited: string } | undefined = undefined
- ): TTransferReturn {
+ ): TRes {
const module: TPallet = 'PolkadotXcm'
- const call: TSerializedApiCallV2 = {
+ const call: TSerializedApiCall = {
module,
section,
parameters: {
@@ -36,14 +30,6 @@ class PolkadotXCMTransferImpl {
}
}
- if (serializedApiCallEnabled === true) {
- // Keep compatible with old serialized call type
- return {
- ...call,
- parameters: Object.values(call.parameters)
- }
- }
-
return api.callTxMethod(call)
}
}
diff --git a/packages/sdk/src/nodes/supported/AssetHubKusama.ts b/packages/sdk/src/nodes/supported/AssetHubKusama.ts
index 45fe8cf8..007c558d 100644
--- a/packages/sdk/src/nodes/supported/AssetHubKusama.ts
+++ b/packages/sdk/src/nodes/supported/AssetHubKusama.ts
@@ -2,12 +2,12 @@
import { ScenarioNotSupportedError } from '../../errors'
import { constructRelayToParaParameters } from '../../pallets/xcmPallet/utils'
-import type { TAsset, TTransferReturn } from '../../types'
+import type { TAsset } from '../../types'
import {
type IPolkadotXCMTransfer,
type PolkadotXCMTransferInput,
Version,
- type TSerializedApiCallV2,
+ type TSerializedApiCall,
type TScenario,
type TRelayToParaOptions,
type TMultiAsset,
@@ -23,9 +23,7 @@ class AssetHubKusama extends ParachainNode implements IP
super('AssetHubKusama', 'KusamaAssetHub', 'kusama', Version.V3)
}
- transferPolkadotXCM(
- input: PolkadotXCMTransferInput
- ): Promise> {
+ transferPolkadotXCM(input: PolkadotXCMTransferInput): Promise {
const { destination, asset, scenario } = input
// TESTED https://kusama.subscan.io/xcm_message/kusama-ddc2a48f0d8e0337832d7aae26f6c3053e1f4ffd
// TESTED https://kusama.subscan.io/xcm_message/kusama-8e423130a4d8b61679af95dbea18a55124f99672
@@ -55,7 +53,7 @@ class AssetHubKusama extends ParachainNode implements IP
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'))
}
- transferRelayToPara(options: TRelayToParaOptions): TSerializedApiCallV2 {
+ transferRelayToPara(options: TRelayToParaOptions): TSerializedApiCall {
const { version = Version.V3 } = options
return {
module: 'XcmPallet',
diff --git a/packages/sdk/src/nodes/supported/AssetHubPolkadot.ts b/packages/sdk/src/nodes/supported/AssetHubPolkadot.ts
index 09500f2d..d178c064 100644
--- a/packages/sdk/src/nodes/supported/AssetHubPolkadot.ts
+++ b/packages/sdk/src/nodes/supported/AssetHubPolkadot.ts
@@ -14,8 +14,7 @@ import type {
PolkadotXcmSection,
TAsset,
TDestination,
- TSerializedApiCallV2,
- TTransferReturn
+ TSerializedApiCall
} from '../../types'
import {
type IPolkadotXCMTransfer,
@@ -210,9 +209,7 @@ class AssetHubPolkadot
)
}
- handleBifrostEthTransfer = (
- input: PolkadotXCMTransferInput
- ): TTransferReturn => {
+ handleBifrostEthTransfer = (input: PolkadotXCMTransferInput): TRes => {
const { api, amount, scenario, version, destination, asset } = input
if (!isForeignAsset(asset)) {
@@ -223,7 +220,7 @@ class AssetHubPolkadot
const ethereumTokenLocation = createEthereumTokenLocation(asset.assetId ?? '')
- const call: TSerializedApiCallV2 = {
+ const call: TSerializedApiCall = {
module: 'PolkadotXcm',
section: 'transfer_assets_using_type_and_then',
parameters: {
@@ -318,9 +315,7 @@ class AssetHubPolkadot
return scenario === 'ParaToPara' ? 'limited_reserve_transfer_assets' : 'limited_teleport_assets'
}
- transferPolkadotXCM(
- input: PolkadotXCMTransferInput
- ): Promise> {
+ transferPolkadotXCM(input: PolkadotXCMTransferInput): Promise {
const { scenario, asset, destination } = input
if (destination === 'AssetHubKusama') {
@@ -376,7 +371,7 @@ class AssetHubPolkadot
)
}
- transferRelayToPara(options: TRelayToParaOptions): TSerializedApiCallV2 {
+ transferRelayToPara(options: TRelayToParaOptions): TSerializedApiCall {
const { version = Version.V3 } = options
return {
module: 'XcmPallet',
diff --git a/packages/sdk/src/nodes/supported/Astar.ts b/packages/sdk/src/nodes/supported/Astar.ts
index c1360f8b..6afc01a3 100644
--- a/packages/sdk/src/nodes/supported/Astar.ts
+++ b/packages/sdk/src/nodes/supported/Astar.ts
@@ -1,6 +1,5 @@
// Contains detailed structure of XCM call construction for Astar Parachain
-import type { TTransferReturn } from '../../types'
import {
Version,
type IPolkadotXCMTransfer,
@@ -22,9 +21,7 @@ class Astar
super('Astar', 'astar', 'polkadot', Version.V3)
}
- transferPolkadotXCM(
- input: PolkadotXCMTransferInput
- ): Promise> {
+ transferPolkadotXCM(input: PolkadotXCMTransferInput): Promise {
// TESTED https://polkadot.subscan.io/xcm_message/polkadot-f2b697df74ebe4b62853fe81b8b7d0522464972d
return Promise.resolve(
PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'reserve_transfer_assets')
diff --git a/packages/sdk/src/nodes/supported/Bajun.ts b/packages/sdk/src/nodes/supported/Bajun.ts
index 516929ba..331518d7 100644
--- a/packages/sdk/src/nodes/supported/Bajun.ts
+++ b/packages/sdk/src/nodes/supported/Bajun.ts
@@ -7,7 +7,7 @@ import {
} from '../../errors'
import {
type IXTokensTransfer,
- type TSerializedApiCallV2,
+ type TSerializedApiCall,
Version,
type XTokensTransferInput
} from '../../types'
@@ -33,7 +33,7 @@ class Bajun extends ParachainNode implements IXTokensTra
return XTokensTransferImpl.transferXTokens(input, asset.symbol)
}
- transferRelayToPara(): TSerializedApiCallV2 {
+ transferRelayToPara(): TSerializedApiCall {
throw new NodeNotSupportedError()
}
}
diff --git a/packages/sdk/src/nodes/supported/BifrostKusama.ts b/packages/sdk/src/nodes/supported/BifrostKusama.ts
index 3f9951f1..412e6265 100644
--- a/packages/sdk/src/nodes/supported/BifrostKusama.ts
+++ b/packages/sdk/src/nodes/supported/BifrostKusama.ts
@@ -1,6 +1,5 @@
// Contains detailed structure of XCM call construction for Bifrost Parachain on Kusama
-import type { TTransferReturn } from '../../types'
import { type IXTokensTransfer, Version, type XTokensTransferInput } from '../../types'
import { getNode } from '../../utils'
import { getNodeProviders } from '../config'
@@ -11,7 +10,7 @@ class BifrostKusama extends ParachainNode implements IXT
super('BifrostKusama', 'bifrost', 'kusama', Version.V3)
}
- transferXTokens(input: XTokensTransferInput): TTransferReturn {
+ transferXTokens(input: XTokensTransferInput): TRes {
return getNode('BifrostPolkadot').transferXTokens(input)
}
diff --git a/packages/sdk/src/nodes/supported/BifrostPolkadot.ts b/packages/sdk/src/nodes/supported/BifrostPolkadot.ts
index 5fc82c77..cb95bb71 100644
--- a/packages/sdk/src/nodes/supported/BifrostPolkadot.ts
+++ b/packages/sdk/src/nodes/supported/BifrostPolkadot.ts
@@ -6,8 +6,7 @@ import type {
IPolkadotXCMTransfer,
PolkadotXCMTransferInput,
TAsset,
- TSendInternalOptions,
- TTransferReturn
+ TSendInternalOptions
} from '../../types'
import { type IXTokensTransfer, Parents, Version, type XTokensTransferInput } from '../../types'
import ParachainNode from '../ParachainNode'
@@ -55,9 +54,7 @@ export class BifrostPolkadot
}
// Handles DOT, WETH transfers to AssetHubPolkadot
- transferPolkadotXCM(
- input: PolkadotXCMTransferInput
- ): Promise> {
+ transferPolkadotXCM(input: PolkadotXCMTransferInput): Promise {
const { amount, overridedCurrency, asset } = input
return Promise.resolve(
diff --git a/packages/sdk/src/nodes/supported/BridgeHubKusama.ts b/packages/sdk/src/nodes/supported/BridgeHubKusama.ts
index 844b4974..1e4c73fe 100644
--- a/packages/sdk/src/nodes/supported/BridgeHubKusama.ts
+++ b/packages/sdk/src/nodes/supported/BridgeHubKusama.ts
@@ -2,12 +2,11 @@
import { ScenarioNotSupportedError } from '../../errors'
import { constructRelayToParaParameters } from '../../pallets/xcmPallet/utils'
-import type { TTransferReturn } from '../../types'
import {
type IPolkadotXCMTransfer,
type PolkadotXCMTransferInput,
Version,
- type TSerializedApiCallV2,
+ type TSerializedApiCall,
type TRelayToParaOptions
} from '../../types'
import ParachainNode from '../ParachainNode'
@@ -23,9 +22,7 @@ class BridgeHubKusama
_assetCheckEnabled = false
- transferPolkadotXCM(
- input: PolkadotXCMTransferInput
- ): Promise> {
+ transferPolkadotXCM(input: PolkadotXCMTransferInput): Promise {
const { scenario } = input
if (scenario === 'ParaToPara') {
throw new ScenarioNotSupportedError(
@@ -38,7 +35,7 @@ class BridgeHubKusama
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'))
}
- transferRelayToPara(options: TRelayToParaOptions): TSerializedApiCallV2 {
+ transferRelayToPara(options: TRelayToParaOptions): TSerializedApiCall {
const { version = Version.V3 } = options
return {
module: 'XcmPallet',
diff --git a/packages/sdk/src/nodes/supported/BridgeHubPolkadot.ts b/packages/sdk/src/nodes/supported/BridgeHubPolkadot.ts
index d9934f13..cc4184b2 100644
--- a/packages/sdk/src/nodes/supported/BridgeHubPolkadot.ts
+++ b/packages/sdk/src/nodes/supported/BridgeHubPolkadot.ts
@@ -2,12 +2,11 @@
import { ScenarioNotSupportedError } from '../../errors'
import { constructRelayToParaParameters } from '../../pallets/xcmPallet/utils'
-import type { TTransferReturn } from '../../types'
import {
type IPolkadotXCMTransfer,
type PolkadotXCMTransferInput,
Version,
- type TSerializedApiCallV2,
+ type TSerializedApiCall,
type TRelayToParaOptions
} from '../../types'
import ParachainNode from '../ParachainNode'
@@ -23,9 +22,7 @@ class BridgeHubPolkadot
_assetCheckEnabled = false
- transferPolkadotXCM(
- input: PolkadotXCMTransferInput
- ): Promise> {
+ transferPolkadotXCM(input: PolkadotXCMTransferInput): Promise {
const { scenario } = input
if (scenario === 'ParaToPara') {
throw new ScenarioNotSupportedError(
@@ -38,7 +35,7 @@ class BridgeHubPolkadot
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'))
}
- transferRelayToPara(options: TRelayToParaOptions): TSerializedApiCallV2 {
+ transferRelayToPara(options: TRelayToParaOptions): TSerializedApiCall {
const { version = Version.V3 } = options
return {
module: 'XcmPallet',
diff --git a/packages/sdk/src/nodes/supported/Collectives.ts b/packages/sdk/src/nodes/supported/Collectives.ts
index 4316a470..8e8d0a8d 100644
--- a/packages/sdk/src/nodes/supported/Collectives.ts
+++ b/packages/sdk/src/nodes/supported/Collectives.ts
@@ -2,12 +2,12 @@
import { ScenarioNotSupportedError } from '../../errors'
import { constructRelayToParaParameters } from '../../pallets/xcmPallet/utils'
-import type { TAsset, TTransferReturn } from '../../types'
+import type { TAsset } from '../../types'
import {
type IPolkadotXCMTransfer,
type PolkadotXCMTransferInput,
Version,
- type TSerializedApiCallV2,
+ type TSerializedApiCall,
type TScenario,
type TRelayToParaOptions
} from '../../types'
@@ -19,9 +19,7 @@ class Collectives extends ParachainNode implements IPolk
super('Collectives', 'polkadotCollectives', 'polkadot', Version.V3)
}
- transferPolkadotXCM(
- input: PolkadotXCMTransferInput
- ): Promise> {
+ transferPolkadotXCM(input: PolkadotXCMTransferInput): Promise {
const { scenario } = input
if (scenario === 'ParaToPara') {
throw new ScenarioNotSupportedError(this.node, scenario)
@@ -31,7 +29,7 @@ class Collectives extends ParachainNode implements IPolk
)
}
- transferRelayToPara(options: TRelayToParaOptions): TSerializedApiCallV2 {
+ transferRelayToPara(options: TRelayToParaOptions): TSerializedApiCall {
const { version = Version.V3 } = options
return {
module: 'XcmPallet',
diff --git a/packages/sdk/src/nodes/supported/CoretimeKusama.ts b/packages/sdk/src/nodes/supported/CoretimeKusama.ts
index 61f1b045..a5fcc6b6 100644
--- a/packages/sdk/src/nodes/supported/CoretimeKusama.ts
+++ b/packages/sdk/src/nodes/supported/CoretimeKusama.ts
@@ -1,12 +1,11 @@
// Contains detailed structure of XCM call construction for CoretimeKusama Parachain
import { constructRelayToParaParameters } from '../../pallets/xcmPallet/utils'
-import type { TTransferReturn } from '../../types'
import {
type IPolkadotXCMTransfer,
type PolkadotXCMTransferInput,
Version,
- type TSerializedApiCallV2,
+ type TSerializedApiCall,
type TRelayToParaOptions
} from '../../types'
import ParachainNode from '../ParachainNode'
@@ -19,9 +18,7 @@ class CoretimeKusama extends ParachainNode implements IP
_assetCheckEnabled = false
- transferPolkadotXCM(
- input: PolkadotXCMTransferInput
- ): Promise> {
+ transferPolkadotXCM(input: PolkadotXCMTransferInput): Promise {
// TESTED block hash on Rococo: 0x78ace0f1bf7cac9a42e56143321b617d98327e2750f795efb0abb833025c9082
const { scenario } = input
const section =
@@ -29,7 +26,7 @@ class CoretimeKusama extends ParachainNode implements IP
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'))
}
- transferRelayToPara(options: TRelayToParaOptions): TSerializedApiCallV2 {
+ transferRelayToPara(options: TRelayToParaOptions): TSerializedApiCall {
// TESTED block hash on Rococo: 0x28929f7b2aeadbf3333f05d35bed18214a4b23dd270bd072f99e8a0131d22456
// https://rococo.subscan.io/extrinsic/0x469eec7dccb22696b0c95cf4f5eec4b367ad3dc23243a346cc2aad3cc9522800
const { version = Version.V3 } = options
diff --git a/packages/sdk/src/nodes/supported/CoretimePolkadot.ts b/packages/sdk/src/nodes/supported/CoretimePolkadot.ts
index c2c066e8..08e7f2fe 100644
--- a/packages/sdk/src/nodes/supported/CoretimePolkadot.ts
+++ b/packages/sdk/src/nodes/supported/CoretimePolkadot.ts
@@ -1,12 +1,11 @@
// Contains detailed structure of XCM call construction for CoretimePolkadot Parachain
import { constructRelayToParaParameters } from '../../pallets/xcmPallet/utils'
-import type { TTransferReturn } from '../../types'
import {
type IPolkadotXCMTransfer,
type PolkadotXCMTransferInput,
Version,
- type TSerializedApiCallV2,
+ type TSerializedApiCall,
type TRelayToParaOptions
} from '../../types'
import ParachainNode from '../ParachainNode'
@@ -22,16 +21,14 @@ class CoretimePolkadot
_assetCheckEnabled = false
- transferPolkadotXCM(
- input: PolkadotXCMTransferInput
- ): Promise> {
+ transferPolkadotXCM(input: PolkadotXCMTransferInput): Promise {
const { scenario } = input
const section =
scenario === 'ParaToPara' ? 'limited_reserve_transfer_assets' : 'limited_teleport_assets'
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, section, 'Unlimited'))
}
- transferRelayToPara(options: TRelayToParaOptions): TSerializedApiCallV2 {
+ transferRelayToPara(options: TRelayToParaOptions): TSerializedApiCall {
const { version = Version.V3 } = options
return {
module: 'XcmPallet',
diff --git a/packages/sdk/src/nodes/supported/Crab.ts b/packages/sdk/src/nodes/supported/Crab.ts
index 38a9b2aa..a11f3ac2 100644
--- a/packages/sdk/src/nodes/supported/Crab.ts
+++ b/packages/sdk/src/nodes/supported/Crab.ts
@@ -1,11 +1,11 @@
// Contains detailed structure of XCM call construction for Crab Parachain
-import type { TAsset, TCurrencySelectionHeaderArr, TTransferReturn } from '../../types'
+import type { TAsset, TCurrencySelectionHeaderArr } from '../../types'
import {
type IPolkadotXCMTransfer,
type PolkadotXCMTransferInput,
Version,
- type TSerializedApiCallV2,
+ type TSerializedApiCall,
type TScenario
} from '../../types'
import { ScenarioNotSupportedError } from '../../errors/ScenarioNotSupportedError'
@@ -19,9 +19,7 @@ class Crab extends ParachainNode implements IPolkadotXCM
super('Crab', 'crab', 'kusama', Version.V3)
}
- transferPolkadotXCM(
- input: PolkadotXCMTransferInput
- ): Promise> {
+ transferPolkadotXCM(input: PolkadotXCMTransferInput): Promise {
// TESTED https://kusama.subscan.io/xcm_message/kusama-ce7396ec470ba0c6516a50075046ee65464572dc
if (input.scenario === 'ParaToPara') {
return Promise.resolve(
@@ -31,7 +29,7 @@ class Crab extends ParachainNode implements IPolkadotXCM
throw new ScenarioNotSupportedError(this.node, input.scenario)
}
- transferRelayToPara(): TSerializedApiCallV2 {
+ transferRelayToPara(): TSerializedApiCall {
throw new NodeNotSupportedError()
}
diff --git a/packages/sdk/src/nodes/supported/Darwinia.ts b/packages/sdk/src/nodes/supported/Darwinia.ts
index ec3f01a7..c476fe5d 100644
--- a/packages/sdk/src/nodes/supported/Darwinia.ts
+++ b/packages/sdk/src/nodes/supported/Darwinia.ts
@@ -3,7 +3,7 @@
import type { TAsset } from '../../types'
import {
Version,
- type TSerializedApiCallV2,
+ type TSerializedApiCall,
type IXTokensTransfer,
type XTokensTransferInput,
type TScenario,
@@ -42,7 +42,7 @@ class Darwinia extends ParachainNode implements IXTokens
return XTokensTransferImpl.transferXTokens(input, currencySelection)
}
- transferRelayToPara(): TSerializedApiCallV2 {
+ transferRelayToPara(): TSerializedApiCall {
throw new NodeNotSupportedError()
}
diff --git a/packages/sdk/src/nodes/supported/Encointer.ts b/packages/sdk/src/nodes/supported/Encointer.ts
index 6627d9f5..11445011 100644
--- a/packages/sdk/src/nodes/supported/Encointer.ts
+++ b/packages/sdk/src/nodes/supported/Encointer.ts
@@ -1,11 +1,10 @@
// Contains detailed structure of XCM call construction for Encoiter Parachain
-import type { TTransferReturn } from '../../types'
import {
type IPolkadotXCMTransfer,
type PolkadotXCMTransferInput,
Version,
- type TSerializedApiCallV2,
+ type TSerializedApiCall,
type TRelayToParaOptions
} from '../../types'
import { ScenarioNotSupportedError } from '../../errors/ScenarioNotSupportedError'
@@ -18,9 +17,7 @@ class Encointer extends ParachainNode implements IPolkad
super('Encointer', 'encointer', 'kusama', Version.V3)
}
- transferPolkadotXCM(
- input: PolkadotXCMTransferInput
- ): Promise> {
+ transferPolkadotXCM(input: PolkadotXCMTransferInput): Promise {
// NO PARA TO PARA SCENARIOS ON SUBSCAN
// TESTED https://encointer.subscan.io/xcm_message/kusama-418501e86e947b16c4e4e9040694017e64f9b162
if (input.scenario === 'ParaToRelay') {
@@ -31,7 +28,7 @@ class Encointer extends ParachainNode implements IPolkad
throw new ScenarioNotSupportedError(this.node, input.scenario)
}
- transferRelayToPara(options: TRelayToParaOptions): TSerializedApiCallV2 {
+ transferRelayToPara(options: TRelayToParaOptions): TSerializedApiCall {
const { version = Version.V1 } = options
return {
module: 'XcmPallet',
diff --git a/packages/sdk/src/nodes/supported/Hydration.ts b/packages/sdk/src/nodes/supported/Hydration.ts
index 93379c9d..3bb971b7 100644
--- a/packages/sdk/src/nodes/supported/Hydration.ts
+++ b/packages/sdk/src/nodes/supported/Hydration.ts
@@ -5,8 +5,7 @@ import type {
IPolkadotXCMTransfer,
PolkadotXCMTransferInput,
TSendInternalOptions,
- TSerializedApiCallV2,
- TTransferReturn
+ TSerializedApiCall
} from '../../types'
import { type IXTokensTransfer, Parents, Version, type XTokensTransferInput } from '../../types'
import ParachainNode from '../ParachainNode'
@@ -141,9 +140,7 @@ class Hydration
super('Hydration', 'hydradx', 'polkadot', Version.V3)
}
- async transferToEthereum(
- input: PolkadotXCMTransferInput
- ): Promise> {
+ async transferToEthereum(input: PolkadotXCMTransferInput): Promise {
const { api, address, asset, scenario, version, destination, amount, ahAddress } = input
if (!ethers.isAddress(address)) {
throw new Error('Only Ethereum addresses are supported for Ethereum transfers')
@@ -176,7 +173,7 @@ class Hydration
const fee = await calculateFee(api)
- const call: TSerializedApiCallV2 = {
+ const call: TSerializedApiCall = {
module: 'PolkadotXcm',
section: 'transfer_assets_using_type_and_then',
parameters: {
@@ -208,14 +205,12 @@ class Hydration
return api.callTxMethod(call)
}
- transferToAssetHub(
- input: PolkadotXCMTransferInput
- ): TTransferReturn {
+ transferToAssetHub(input: PolkadotXCMTransferInput): TRes {
const { api, scenario, version, destination, amount } = input
const versionOrDefault = version ?? Version.V3
- const call: TSerializedApiCallV2 = {
+ const call: TSerializedApiCall = {
module: 'PolkadotXcm',
section: 'transfer_assets_using_type_and_then',
parameters: {
@@ -251,7 +246,7 @@ class Hydration
// Handles WETH Ethereum transfers
async transferPolkadotXCM(
input: PolkadotXCMTransferInput
- ): Promise> {
+ ): Promise {
const { destination } = input
if (destination === 'Ethereum') {
return this.transferToEthereum(input)
diff --git a/packages/sdk/src/nodes/supported/Integritee.ts b/packages/sdk/src/nodes/supported/Integritee.ts
index 80665fbc..8eaf8041 100644
--- a/packages/sdk/src/nodes/supported/Integritee.ts
+++ b/packages/sdk/src/nodes/supported/Integritee.ts
@@ -5,7 +5,7 @@ import {
type IXTokensTransfer,
Version,
type XTokensTransferInput,
- type TSerializedApiCallV2
+ type TSerializedApiCall
} from '../../types'
import ParachainNode from '../ParachainNode'
import XTokensTransferImpl from '../xTokens'
@@ -22,7 +22,7 @@ class Integritee extends ParachainNode implements IXToke
return XTokensTransferImpl.transferXTokens(input, asset.symbol)
}
- transferRelayToPara(): TSerializedApiCallV2 {
+ transferRelayToPara(): TSerializedApiCall {
throw new NodeNotSupportedError()
}
}
diff --git a/packages/sdk/src/nodes/supported/Karura.ts b/packages/sdk/src/nodes/supported/Karura.ts
index 96d48888..b3953b60 100644
--- a/packages/sdk/src/nodes/supported/Karura.ts
+++ b/packages/sdk/src/nodes/supported/Karura.ts
@@ -1,6 +1,5 @@
// Contains detailed structure of XCM call construction for Karura Parachain
-import type { TTransferReturn } from '../../types'
import { type IXTokensTransfer, Version, type XTokensTransferInput } from '../../types'
import { getNode } from '../../utils'
import { getNodeProviders } from '../config'
@@ -11,7 +10,7 @@ class Karura extends ParachainNode implements IXTokensTr
super('Karura', 'karura', 'kusama', Version.V3)
}
- transferXTokens(input: XTokensTransferInput): TTransferReturn {
+ transferXTokens(input: XTokensTransferInput): TRes {
return getNode('Acala').transferXTokens(input)
}
diff --git a/packages/sdk/src/nodes/supported/KiltSpiritnet.ts b/packages/sdk/src/nodes/supported/KiltSpiritnet.ts
index 5d19134e..27f5e62e 100644
--- a/packages/sdk/src/nodes/supported/KiltSpiritnet.ts
+++ b/packages/sdk/src/nodes/supported/KiltSpiritnet.ts
@@ -1,12 +1,11 @@
// Contains detailed structure of XCM call construction for KiltSpiritnet Parachain
import { NodeNotSupportedError, ScenarioNotSupportedError } from '../../errors'
-import type { TTransferReturn } from '../../types'
import {
Version,
type IPolkadotXCMTransfer,
type PolkadotXCMTransferInput,
- type TSerializedApiCallV2
+ type TSerializedApiCall
} from '../../types'
import { getNodeProviders } from '../config'
import ParachainNode from '../ParachainNode'
@@ -17,9 +16,7 @@ class KiltSpiritnet extends ParachainNode implements IPo
super('KiltSpiritnet', 'kilt', 'polkadot', Version.V2)
}
- transferPolkadotXCM(
- input: PolkadotXCMTransferInput
- ): Promise> {
+ transferPolkadotXCM(input: PolkadotXCMTransferInput): Promise {
if (input.scenario !== 'ParaToPara') {
throw new ScenarioNotSupportedError(this.node, input.scenario)
}
@@ -28,7 +25,7 @@ class KiltSpiritnet extends ParachainNode implements IPo
)
}
- transferRelayToPara(): TSerializedApiCallV2 {
+ transferRelayToPara(): TSerializedApiCall {
throw new NodeNotSupportedError()
}
diff --git a/packages/sdk/src/nodes/supported/Moonbeam.ts b/packages/sdk/src/nodes/supported/Moonbeam.ts
index 64967196..ad6df6d7 100644
--- a/packages/sdk/src/nodes/supported/Moonbeam.ts
+++ b/packages/sdk/src/nodes/supported/Moonbeam.ts
@@ -2,7 +2,7 @@
import { InvalidCurrencyError } from '../../errors'
import { constructRelayToParaParameters } from '../../pallets/xcmPallet/utils'
-import type { TAsset, TSerializedApiCallV2 } from '../../types'
+import type { TAsset, TSerializedApiCall } from '../../types'
import {
type IXTokensTransfer,
Version,
@@ -37,7 +37,7 @@ class Moonbeam extends ParachainNode implements IXTokens
return XTokensTransferImpl.transferXTokens(input, currencySelection)
}
- transferRelayToPara(options: TRelayToParaOptions): TSerializedApiCallV2 {
+ transferRelayToPara(options: TRelayToParaOptions): TSerializedApiCall {
const { version = Version.V3 } = options
return {
module: 'XcmPallet',
diff --git a/packages/sdk/src/nodes/supported/Moonriver.ts b/packages/sdk/src/nodes/supported/Moonriver.ts
index 8f217a98..7bbca106 100644
--- a/packages/sdk/src/nodes/supported/Moonriver.ts
+++ b/packages/sdk/src/nodes/supported/Moonriver.ts
@@ -7,7 +7,7 @@ import {
type IXTokensTransfer,
Version,
type XTokensTransferInput,
- type TSerializedApiCallV2,
+ type TSerializedApiCall,
type TRelayToParaOptions,
type TXcmForeignAsset,
type TSelfReserveAsset
@@ -38,7 +38,7 @@ class Moonriver extends ParachainNode implements IXToken
return XTokensTransferImpl.transferXTokens(input, currencySelection)
}
- transferRelayToPara(options: TRelayToParaOptions): TSerializedApiCallV2 {
+ transferRelayToPara(options: TRelayToParaOptions): TSerializedApiCall {
const { version = Version.V3 } = options
return {
module: 'XcmPallet',
diff --git a/packages/sdk/src/nodes/supported/Mythos.ts b/packages/sdk/src/nodes/supported/Mythos.ts
index c5ba5a7e..27518bdb 100644
--- a/packages/sdk/src/nodes/supported/Mythos.ts
+++ b/packages/sdk/src/nodes/supported/Mythos.ts
@@ -5,12 +5,11 @@ import {
NodeNotSupportedError,
ScenarioNotSupportedError
} from '../../errors'
-import type { TTransferReturn } from '../../types'
import {
type IPolkadotXCMTransfer,
type PolkadotXCMTransferInput,
Version,
- type TSerializedApiCallV2
+ type TSerializedApiCall
} from '../../types'
import ParachainNode from '../ParachainNode'
import PolkadotXCMTransferImpl from '../polkadotXcm'
@@ -20,9 +19,7 @@ class Mythos