From c0cb492202ab9bf07e29c3aab8ecd0c33ef6b792 Mon Sep 17 00:00:00 2001 From: Shunji Zhan Date: Thu, 19 Sep 2024 00:12:56 +0800 Subject: [PATCH] wrap in api namespace --- src/__tests__/euphrates.test.ts | 17 +++++++-------- src/__tests__/homa.test.ts | 31 ++++++++++++--------------- src/__tests__/misc.test.ts | 10 ++++----- src/__tests__/relay.test.ts | 27 +++++++++++------------ src/__tests__/testUtils.ts | 38 +++++++++++++++++---------------- src/__tests__/wormhole.test.ts | 21 +++++++++--------- src/__tests__/xcm.test.ts | 31 ++++++++++++--------------- src/middlewares/router.ts | 2 +- 8 files changed, 85 insertions(+), 92 deletions(-) diff --git a/src/__tests__/euphrates.test.ts b/src/__tests__/euphrates.test.ts index 662b350..0ddf9f0 100644 --- a/src/__tests__/euphrates.test.ts +++ b/src/__tests__/euphrates.test.ts @@ -18,9 +18,8 @@ import { TEST_KEY, } from './testConsts'; import { + api, expectError, - routeEuphrates, - shouldRouteEuphrates, transferToken, } from './testUtils'; @@ -41,11 +40,11 @@ describe.concurrent('/shouldRouteEuphrates', () => { const recipient = '0x0085560b24769dAC4ed057F1B2ae40746AA9aAb6'; const testShouldRouteEuphrates = async (params: RouteParamsEuphrates) => { - let res = await shouldRouteEuphrates(params); + let res = await api.shouldRouteEuphrates(params); expect(res).toMatchSnapshot(); // should be case insensitive - res = await shouldRouteEuphrates({ + res = await api.shouldRouteEuphrates({ ...params, recipient: params.recipient.toLocaleLowerCase(), }); @@ -64,7 +63,7 @@ describe.concurrent('/shouldRouteEuphrates', () => { describe('when should not route', () => { it('when missing params', async () => { try { - await shouldRouteEuphrates({ + await api.shouldRouteEuphrates({ recipient, }); expect.fail('did not throw an err'); @@ -73,7 +72,7 @@ describe.concurrent('/shouldRouteEuphrates', () => { } try { - await shouldRouteEuphrates({ + await api.shouldRouteEuphrates({ poolId: 0, }); expect.fail('did not throw an err'); @@ -83,7 +82,7 @@ describe.concurrent('/shouldRouteEuphrates', () => { }); it('when bad params', async () => { - const res = await shouldRouteEuphrates({ + const res = await api.shouldRouteEuphrates({ recipient, poolId: 520, }); @@ -159,7 +158,7 @@ describe('/routeEuphrates', () => { recipient: user.address, poolId, }; - const res = await shouldRouteEuphrates(routeArgs); + const res = await api.shouldRouteEuphrates(routeArgs); ({ routerAddr } = res.data); // make sure user has enough DOT/LCDOT to transfer to router @@ -180,7 +179,7 @@ describe('/routeEuphrates', () => { await transferToken(routerAddr, user, inTokenAddr, stakeAmount); console.log('routing ...'); - const routeRes = await routeEuphrates({ + const routeRes = await api.routeEuphrates({ ...routeArgs, token: inTokenAddr, }); diff --git a/src/__tests__/homa.test.ts b/src/__tests__/homa.test.ts index d8655e3..ca5e0c1 100644 --- a/src/__tests__/homa.test.ts +++ b/src/__tests__/homa.test.ts @@ -21,11 +21,8 @@ import { TEST_KEY, } from './testConsts'; import { + api, expectError, - routeHoma, - routeHomaAuto, - routeStatus, - shouldRouteHoma, transferToken, } from './testUtils'; @@ -41,7 +38,7 @@ describe.concurrent('/shouldRouteHoma', () => { it('to evm address', async () => { // for (const network of [Object.values(Mainnet)]) { // TODO: enable this after deploying contract to karura for (const chain of ['acala']) { - let res = await shouldRouteHoma({ + let res = await api.shouldRouteHoma({ destAddr, chain, }); @@ -56,7 +53,7 @@ describe.concurrent('/shouldRouteHoma', () => { `); // should be case insensitive - res = await shouldRouteHoma({ + res = await api.shouldRouteHoma({ destAddr: destAddr.toLocaleLowerCase(), chain, }); @@ -75,7 +72,7 @@ describe.concurrent('/shouldRouteHoma', () => { it('to substrate address', async () => { // for (const network of [Object.values(Mainnet)]) { // TODO: enable this after deploying contract to karura for (const chain of ['acala']) { - const res = await shouldRouteHoma({ + const res = await api.shouldRouteHoma({ destAddr: destAddrSubstrate, chain, }); @@ -95,7 +92,7 @@ describe.concurrent('/shouldRouteHoma', () => { describe('when should not route', () => { it('when missing params', async () => { try { - await shouldRouteHoma({ + await api.shouldRouteHoma({ destAddr, }); expect.fail('did not throw an err'); @@ -104,7 +101,7 @@ describe.concurrent('/shouldRouteHoma', () => { } try { - await shouldRouteHoma({ + await api.shouldRouteHoma({ chain: Mainnet.Acala, }); expect.fail('did not throw an err'); @@ -113,7 +110,7 @@ describe.concurrent('/shouldRouteHoma', () => { } try { - await shouldRouteHoma({ + await api.shouldRouteHoma({ chain: 'mandala', destAddr, }); @@ -124,7 +121,7 @@ describe.concurrent('/shouldRouteHoma', () => { }); it('when bad params', async () => { - const res = await shouldRouteHoma({ + const res = await api.shouldRouteHoma({ chain: Mainnet.Acala, destAddr: '0xaaaaaaaaaa', }); @@ -197,7 +194,7 @@ describe('/routeHoma', () => { destAddr, chain: 'acala', }; - const res = await shouldRouteHoma(routeArgs); + const res = await api.shouldRouteHoma(routeArgs); ({ routerAddr } = res.data); // make sure user has enough DOT to transfer to router @@ -217,7 +214,7 @@ describe('/routeHoma', () => { await transferToken(routerAddr, user, DOT, stakeAmount); console.log('routing ...'); - const routeRes = await routeHoma({ + const routeRes = await api.routeHoma({ ...routeArgs, token: DOT, }); @@ -253,7 +250,7 @@ describe('/routeHoma', () => { destAddr, chain: 'acala', }; - const res = await shouldRouteHoma(routeArgs); + const res = await api.shouldRouteHoma(routeArgs); ({ routerAddr } = res.data); // make sure user has enough DOT to transfer to router @@ -270,7 +267,7 @@ describe('/routeHoma', () => { const bal0 = await fetchTokenBalances(); console.log('sending auto routing request ...'); - const routeRes = await routeHomaAuto({ + const routeRes = await api.routeHomaAuto({ ...routeArgs, token: DOT, }); @@ -279,7 +276,7 @@ describe('/routeHoma', () => { const waitForRoute = new Promise((resolve, reject) => { const pollRouteStatus = setInterval(async () => { - const res = await routeStatus({ id: reqId }); + const res = await api.routeStatus({ id: reqId }); const { status } = res.data[0]; console.log(`current status: ${status}`); @@ -299,7 +296,7 @@ describe('/routeHoma', () => { await waitForRoute; // query status by destAddr should also returns same result - const { data } = await routeStatus({ destAddr }); + const { data } = await api.routeStatus({ destAddr }); const reqInfo = data.find(info => info.reqId === reqId); expect(reqInfo).not.to.be.undefined; expect(reqInfo.status).to.eq(RouteStatus.Complete); diff --git a/src/__tests__/misc.test.ts b/src/__tests__/misc.test.ts index b8bf19c..f6b8327 100644 --- a/src/__tests__/misc.test.ts +++ b/src/__tests__/misc.test.ts @@ -1,11 +1,11 @@ +import { api, expectError } from './testUtils'; import { describe, expect, it } from 'vitest'; -import { expectError, health, noRoute, testTimeout, version } from './testUtils'; describe.concurrent('/miscellaneous', () => { describe('when no route for the request', () => { it('throws correct error', async () => { try { - await noRoute({}); + await api.noRoute({}); expect.fail('/noRoute did not throw when it should!'); } catch (err) { @@ -16,7 +16,7 @@ describe.concurrent('/miscellaneous', () => { describe('/version', () => { it('works', async () => { - const res = await version({}); + const res = await api.version({}); expect(res).to.not.be.undefined; }); }); @@ -24,7 +24,7 @@ describe.concurrent('/miscellaneous', () => { describe('/testTimeout', () => { it('works', async () => { const startTime = Date.now(); - await testTimeout({ + await api.testTimeout({ timeout: 1000, }); const endTime = Date.now(); @@ -35,7 +35,7 @@ describe.concurrent('/miscellaneous', () => { describe('/health', () => { it('works', async () => { - const res = await health({}); + const res = await api.health({}); expect(Number(res.data.relayerBalAcala)).to.be.gt(0); // expect(Number(res.data.relayerBalKarura)).to.be.gt(0); diff --git a/src/__tests__/relay.test.ts b/src/__tests__/relay.test.ts index 9171feb..11f24ca 100644 --- a/src/__tests__/relay.test.ts +++ b/src/__tests__/relay.test.ts @@ -7,7 +7,7 @@ import { describe, expect, it } from 'vitest'; import { ETH_RPC, RELAY_CONFIG } from '../consts'; import { PROD_ADDR } from './testConsts'; import { VAA_10_USDC_ETH_TO_ACALA, VAA_ALREADY_COMPLETED, VAA_TINY_JITOSOL_SOL_TO_ACALA } from './vaa'; -import { expectError, relay, shouldRelay } from './testUtils'; +import { api, expectError } from './testUtils'; const provider = new AcalaJsonRpcProvider(ETH_RPC.LOCAL); @@ -20,7 +20,7 @@ describe('/shouldRelay', () => { const supported = RELAY_CONFIG[targetChain]; for (const [token, minTransfer] of Object.entries(supported)) { - const res = await shouldRelay({ + const res = await api.shouldRelay({ targetChain, originAsset: token, amount: minTransfer, @@ -31,7 +31,7 @@ describe('/shouldRelay', () => { // if not lower case address for (const [token, minTransfer] of Object.entries(supported)) { - const res = await shouldRelay({ + const res = await api.shouldRelay({ targetChain, originAsset: token.toUpperCase(), amount: minTransfer, @@ -48,7 +48,7 @@ describe('/shouldRelay', () => { it('when missing params', async () => { try { - await shouldRelay({ + await api.shouldRelay({ originAsset: '0xddb64fe46a91d46ee29420539fc25fd07c5fea3e', amount: '10000', }); @@ -59,7 +59,7 @@ describe('/shouldRelay', () => { } try { - await shouldRelay({ + await api.shouldRelay({ targetChain, amount: '10000', }); @@ -70,7 +70,7 @@ describe('/shouldRelay', () => { } try { - await shouldRelay({ + await api.shouldRelay({ targetChain, originAsset: '0xddb64fe46a91d46ee29420539fc25fd07c5fea3e', }); @@ -82,7 +82,7 @@ describe('/shouldRelay', () => { }); it('when relay condition not met', async () => { - let res = await shouldRelay({ + let res = await api.shouldRelay({ targetChain: 3104, originAsset: '0xddb64fe46a91d46ee29420539fc25fd07c5fea3e', amount: '10000', @@ -95,7 +95,7 @@ describe('/shouldRelay', () => { `); const originAsset = '0x111111111191d46ee29420539fc25f0000000000'; - res = await shouldRelay({ + res = await api.shouldRelay({ targetChain, originAsset, amount: '10000', @@ -107,7 +107,7 @@ describe('/shouldRelay', () => { } `); - res = await shouldRelay({ + res = await api.shouldRelay({ targetChain, originAsset: JITOSOL, amount: '10', @@ -121,7 +121,7 @@ describe('/shouldRelay', () => { }); it('when amount is not number', async () => { - const res = await shouldRelay({ + const res = await api.shouldRelay({ targetChain, originAsset: JITOSOL, amount: '{"type":"BigNumber","hex":"0xe8d4a51000"}', @@ -136,14 +136,13 @@ describe('/shouldRelay', () => { }); }); - describe('/relay', () => { it('relay USDC to user', async () => { const usdc = ERC20__factory.connect(USDC_ADDR, provider); const curBalRelayer = (await usdc.balanceOf(PROD_ADDR)).toBigInt(); console.log({ curBalRelayer }); - const result = await relay({ + const result = await api.relay({ targetChain: CHAIN_ID_ACALA, signedVAA: VAA_10_USDC_ETH_TO_ACALA, }); @@ -157,7 +156,7 @@ describe('/relay', () => { it('when amount too small', async () => { try { - await relay({ + await api.relay({ targetChain: CHAIN_ID_ACALA, signedVAA: VAA_TINY_JITOSOL_SOL_TO_ACALA, }); @@ -170,7 +169,7 @@ describe('/relay', () => { it('when contract throws', async () => { try { - await relay({ + await api.relay({ targetChain: CHAIN_ID_ACALA, signedVAA: VAA_ALREADY_COMPLETED, }); diff --git a/src/__tests__/testUtils.ts b/src/__tests__/testUtils.ts index 8f19a78..8cee75a 100644 --- a/src/__tests__/testUtils.ts +++ b/src/__tests__/testUtils.ts @@ -106,21 +106,23 @@ const _axiosPost = (url: string) => async (params: any) => { return res.data; }; -export const shouldRouteXcm = _axiosGet(RELAYER_URL.SHOULD_ROUTE_XCM); -export const shouldRouteWormhole = _axiosGet(RELAYER_URL.SHOULD_ROUTE_WORMHOLE); -export const shouldRelay = _axiosGet(RELAYER_URL.SHOULD_RELAY); -export const relay = _axiosPost(RELAYER_URL.RELAY); -export const routeXcm = _axiosPost(RELAYER_URL.ROUTE_XCM); -export const relayAndRoute = _axiosPost(RELAYER_URL.RELAY_AND_ROUTE); -export const relayAndRouteBatch = _axiosPost(RELAYER_URL.RELAY_AND_ROUTE_BATCH); -export const routeWormhole = _axiosPost(RELAYER_URL.ROUTE_WORMHOLE); -export const noRoute = _axiosPost(RELAYER_URL.NO_ROUTE); -export const version = _axiosGet(RELAYER_URL.VERSION); -export const testTimeout = _axiosPost(RELAYER_URL.TEST_TIMEOUT); -export const health = _axiosGet(RELAYER_URL.HEALTH); -export const shouldRouteHoma = _axiosGet(RELAYER_URL.SHOULD_ROUTER_HOMA); -export const routeHoma = _axiosPost(RELAYER_URL.ROUTE_HOMA); -export const routeHomaAuto = _axiosPost(RELAYER_URL.ROUTE_HOMA_AUTO); -export const routeStatus = _axiosGet(RELAYER_URL.ROUTE_STATUS); -export const shouldRouteEuphrates = _axiosGet(RELAYER_URL.SHOULD_ROUTER_EUPHRATES); -export const routeEuphrates = _axiosPost(RELAYER_URL.ROUTE_EUPHRATES); +export const api = { + shouldRouteXcm: _axiosGet(RELAYER_URL.SHOULD_ROUTE_XCM), + shouldRouteWormhole: _axiosGet(RELAYER_URL.SHOULD_ROUTE_WORMHOLE), + shouldRelay: _axiosGet(RELAYER_URL.SHOULD_RELAY), + relay: _axiosPost(RELAYER_URL.RELAY), + routeXcm: _axiosPost(RELAYER_URL.ROUTE_XCM), + relayAndRoute: _axiosPost(RELAYER_URL.RELAY_AND_ROUTE), + relayAndRouteBatch: _axiosPost(RELAYER_URL.RELAY_AND_ROUTE_BATCH), + routeWormhole: _axiosPost(RELAYER_URL.ROUTE_WORMHOLE), + noRoute: _axiosPost(RELAYER_URL.NO_ROUTE), + version: _axiosGet(RELAYER_URL.VERSION), + testTimeout: _axiosPost(RELAYER_URL.TEST_TIMEOUT), + health: _axiosGet(RELAYER_URL.HEALTH), + shouldRouteHoma: _axiosGet(RELAYER_URL.SHOULD_ROUTER_HOMA), + routeHoma: _axiosPost(RELAYER_URL.ROUTE_HOMA), + routeHomaAuto: _axiosPost(RELAYER_URL.ROUTE_HOMA_AUTO), + routeStatus: _axiosGet(RELAYER_URL.ROUTE_STATUS), + shouldRouteEuphrates: _axiosGet(RELAYER_URL.SHOULD_ROUTER_EUPHRATES), + routeEuphrates: _axiosPost(RELAYER_URL.ROUTE_EUPHRATES), +}; diff --git a/src/__tests__/wormhole.test.ts b/src/__tests__/wormhole.test.ts index c8f1673..2b90bfd 100644 --- a/src/__tests__/wormhole.test.ts +++ b/src/__tests__/wormhole.test.ts @@ -11,9 +11,8 @@ import { TEST_ADDR_USER, } from './testConsts'; import { + api, expectError, - routeWormhole, - shouldRouteWormhole, sudoTransferToken, } from './testUtils'; import { parseUnits } from 'ethers/lib/utils'; @@ -25,7 +24,7 @@ const provider = new AcalaJsonRpcProvider(ETH_RPC.LOCAL); describe.concurrent('/shouldRouteWormhole', () => { it('when should route', async () => { - const res = await shouldRouteWormhole({ + const res = await api.shouldRouteWormhole({ originAddr: USDC_ORIGIN_ADDR, targetChainId: String(CHAIN_ID_ETH), destAddr: '0x0085560b24769dAC4ed057F1B2ae40746AA9aAb6', @@ -46,7 +45,7 @@ describe.concurrent('/shouldRouteWormhole', () => { describe('when should not route', () => { it('when missing params', async () => { try { - await shouldRouteWormhole({ + await api.shouldRouteWormhole({ targetChainId: String(CHAIN_ID_ETH), destAddr: '0x0085560b24769dAC4ed057F1B2ae40746AA9aAb6', fromParaId: PARA_ID.HYDRA, @@ -57,7 +56,7 @@ describe.concurrent('/shouldRouteWormhole', () => { } try { - await shouldRouteWormhole({ + await api.shouldRouteWormhole({ originAddr: USDC_ORIGIN_ADDR, destAddr: '0x0085560b24769dAC4ed057F1B2ae40746AA9aAb6', fromParaId: PARA_ID.HYDRA, @@ -68,7 +67,7 @@ describe.concurrent('/shouldRouteWormhole', () => { } try { - await shouldRouteWormhole({ + await api.shouldRouteWormhole({ originAddr: USDC_ORIGIN_ADDR, targetChainId: String(CHAIN_ID_ETH), fromParaId: PARA_ID.HYDRA, @@ -79,7 +78,7 @@ describe.concurrent('/shouldRouteWormhole', () => { } try { - await shouldRouteWormhole({ + await api.shouldRouteWormhole({ originAddr: USDC_ORIGIN_ADDR, targetChainId: String(CHAIN_ID_ETH), destAddr: '0x0085560b24769dAC4ed057F1B2ae40746AA9aAb6', @@ -98,7 +97,7 @@ describe.concurrent('/shouldRouteWormhole', () => { fromParaId: PARA_ID.HYDRA, }; - let res = await shouldRouteWormhole({ + let res = await api.shouldRouteWormhole({ ...validArgs, fromParaId: 1111, }); @@ -110,7 +109,7 @@ describe.concurrent('/shouldRouteWormhole', () => { }); const unsupportedToken = '0x07865c6e87b9f70255377e024ace6630c1e00000'; - res = await shouldRouteWormhole({ + res = await api.shouldRouteWormhole({ ...validArgs, originAddr: '0x07865c6e87b9f70255377e024ace6630c1e00000', }); @@ -135,7 +134,7 @@ describe('/routeWormhole', () => { originAddr: USDC_ORIGIN_ADDR, }; - const res = await shouldRouteWormhole(routeWhArgs); + const res = await api.shouldRouteWormhole(routeWhArgs); const { routerAddr } = res.data; expect(routerAddr).toBeDefined(); @@ -146,7 +145,7 @@ describe('/routeWormhole', () => { console.log({ curBalRelayer }); console.log('routing ...'); - const routeRes = await routeWormhole(routeWhArgs); + const routeRes = await api.routeWormhole(routeWhArgs); const txHash = routeRes.data; console.log(`route finished! txHash: ${txHash}`); diff --git a/src/__tests__/xcm.test.ts b/src/__tests__/xcm.test.ts index 83fd595..93591f9 100644 --- a/src/__tests__/xcm.test.ts +++ b/src/__tests__/xcm.test.ts @@ -15,12 +15,9 @@ import { VAA_TINY_AMOUNT_DAI_BSC_TO_ACALA, } from './vaa'; import { + api, expectError, expectErrorData, - relayAndRoute, - relayAndRouteBatch, - routeXcm, - shouldRouteXcm, sudoTransferToken, } from './testUtils'; import { parseUnits } from 'ethers/lib/utils'; @@ -40,7 +37,7 @@ describe.concurrent('/shouldRouteXcm', () => { const dest = '0x03010200a9200100d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d'; it('when should route', async () => { - const res = await shouldRouteXcm(routeXcmArgs); + const res = await api.shouldRouteXcm(routeXcmArgs); expect(res).toMatchInlineSnapshot(` { "data": { @@ -55,7 +52,7 @@ describe.concurrent('/shouldRouteXcm', () => { describe('when should not route', () => { it('when missing params', async () => { try { - await shouldRouteXcm({ + await api.shouldRouteXcm({ destParaId: PARA_ID.BASILISK, originAddr: '0x07865c6e87b9f70255377e024ace6630c1eaa37f', }); @@ -65,7 +62,7 @@ describe.concurrent('/shouldRouteXcm', () => { } try { - await shouldRouteXcm({ + await api.shouldRouteXcm({ dest, originAddr: '0x07865c6e87b9f70255377e024ace6630c1eaa37f', }); @@ -75,7 +72,7 @@ describe.concurrent('/shouldRouteXcm', () => { } try { - await shouldRouteXcm({ + await api.shouldRouteXcm({ dest, destParaId: PARA_ID.BASILISK, }); @@ -92,7 +89,7 @@ describe.concurrent('/shouldRouteXcm', () => { originAddr: '0x07865c6e87b9f70255377e024ace6630c1eaa37f', }; - let res = await shouldRouteXcm({ + let res = await api.shouldRouteXcm({ ...validArgs, destParaId: 1111, }); @@ -104,7 +101,7 @@ describe.concurrent('/shouldRouteXcm', () => { }); const unsupportedToken = '0x07865c6e87b9f70255377e024ace6630c1e00000'; - res = await shouldRouteXcm({ + res = await api.shouldRouteXcm({ ...validArgs, originAddr: unsupportedToken, }); @@ -128,7 +125,7 @@ describe.concurrent('/shouldRouteXcm', () => { describe('/routeXcm', () => { it('when should route', async () => { - const res = await shouldRouteXcm(routeXcmArgs); + const res = await api.shouldRouteXcm(routeXcmArgs); const { routerAddr } = res.data; console.log('transferring to router ...'); @@ -139,7 +136,7 @@ describe('/routeXcm', () => { console.log({ curBalRelayer }); console.log('routing ...'); - const routeRes = await routeXcm(routeXcmArgs); + const routeRes = await api.routeXcm(routeXcmArgs); console.log(`route finished! txHash: ${routeRes.data}`); const afterBalRelayer = (await dai.balanceOf(TEST_ADDR_RELAYER)).toBigInt(); @@ -158,7 +155,7 @@ describe('/routeXcm', () => { describe('/relayAndRoute', () => { it('when should route', async () => { - const { routerAddr } = (await shouldRouteXcm(routeXcmArgs)).data; + const { routerAddr } = (await api.shouldRouteXcm(routeXcmArgs)).data; console.log({ routerAddr }); const relayAndRouteXcmArgs = { @@ -178,7 +175,7 @@ describe('/relayAndRoute', () => { console.log(`relay finished! txHash: ${event.transactionHash}`); }); - const res = await relayAndRoute(relayAndRouteXcmArgs); + const res = await api.relayAndRoute(relayAndRouteXcmArgs); console.log(`route finished! txHash: ${res.data}`); const afterBalRelayer = (await dai.balanceOf(TEST_ADDR_RELAYER)).toBigInt(); @@ -194,7 +191,7 @@ describe('/relayAndRoute', () => { it('when should not route', async () => { try { - await relayAndRoute({ + await api.relayAndRoute({ ...routeXcmArgs, signedVAA: VAA_TINY_AMOUNT_DAI_BSC_TO_ACALA, // bridge 0.000001 DAI }); @@ -205,7 +202,7 @@ describe('/relayAndRoute', () => { } try { - await relayAndRoute({ + await api.relayAndRoute({ ...routeXcmArgs, signedVAA: VAA_RANDOM_TOKEN_BSC_TO_ACALA, }); @@ -216,7 +213,7 @@ describe('/relayAndRoute', () => { } try { - await relayAndRouteBatch({ + await api.relayAndRouteBatch({ ...routeXcmArgs, signedVAA: VAA_10_USDC_ETH_TO_ACALA + '12345', // invalid VAA }); diff --git a/src/middlewares/router.ts b/src/middlewares/router.ts index 8bffbaf..dae708f 100644 --- a/src/middlewares/router.ts +++ b/src/middlewares/router.ts @@ -32,8 +32,8 @@ import { shouldRouteWormhole, shouldRouteXcm, } from '../api'; -import { shouldSwapAndRoute, swapAndRoute } from '../api/swapAndRoute'; import { parseIp } from '../utils/formatter'; +import { shouldSwapAndRoute, swapAndRoute } from '../api/swapAndRoute'; interface RouterConfig { schema?: Schema;