Skip to content

Commit

Permalink
polish
Browse files Browse the repository at this point in the history
  • Loading branch information
shunjizhan committed Oct 23, 2024
1 parent ef90e5f commit 2083e40
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 38 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ jobs:
- name: setup test env
run: cp .env.test .env

- name: check docker logs
run: docker compose logs
# - name: check docker logs
# run: docker compose logs

- name: setup test infra
run: yarn start:test-stack
run: yarn start:test-infra -d

- name: run tests with coverage
run: yarn test:coverage
Expand Down
49 changes: 25 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -668,14 +668,6 @@ data: {
// similar to /routeXcm
```

### `/routerInfo`
get router info

```
GET /routerInfo
{
routerAddr?: string; // router address
recipient?: string; // recipient address
### `/rescueSwapAndLp`
- perform gas drop
- rescue token to recipient
Expand All @@ -691,22 +683,6 @@ data: {
}
```

example
```
GET /routerInfo?routerAddr=0x1F191013BE290CD0A89074A3946f1aEF58Eacc7f

=>
data: [{
id: 6,
timestamp: "2024-09-12T04:53:53.501Z",
params: "{\"swapAmount\":\"100000000\",\"poolId\":\"7\",\"recipient\":\"0x0085560b24769dAC4ed057F1B2ae40746AA9aAb6\",\"minShareAmount\":\"10000000\"}",
factoryAddr: "0xB1DC04892c8346f61aF1A922A856D96e4A51a389",
feeAddr: "0x5Fc7261E168F6a8c1053F2208c7db4BCbef133b3",
recipient: "0x0085560b24769dAC4ed057F1B2ae40746AA9aAb6",
routerAddr: "0x1F191013BE290CD0A89074A3946f1aEF58Eacc7f"
}]
```
POST /rescueSwapAndLp
data: {
"poolId": 7,
Expand All @@ -724,6 +700,31 @@ data: {
// similar to /routeXcm
```
### `/routerInfo`
get router info
```
GET /routerInfo
{
routerAddr?: string; // router address
recipient?: string; // recipient address

example
```
GET /routerInfo?routerAddr=0x1F191013BE290CD0A89074A3946f1aEF58Eacc7f
=>
data: [{
id: 6,
timestamp: "2024-09-12T04:53:53.501Z",
params: "{\"swapAmount\":\"100000000\",\"poolId\":\"7\",\"recipient\":\"0x0085560b24769dAC4ed057F1B2ae40746AA9aAb6\",\"minShareAmount\":\"10000000\"}",
factoryAddr: "0xB1DC04892c8346f61aF1A922A856D96e4A51a389",
feeAddr: "0x5Fc7261E168F6a8c1053F2208c7db4BCbef133b3",
recipient: "0x0085560b24769dAC4ed057F1B2ae40746AA9aAb6",
routerAddr: "0x1F191013BE290CD0A89074A3946f1aEF58Eacc7f"
}]
```


## Routing Process
A complete working flow can be found in [routing e2e tests](./src/__tests__/route.test.ts).
Expand Down
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,23 @@
"repository": "https://github.com/AcalaNetwork/wormhole-relayer/",
"scripts": {
"build": "tsc",
"clean": "rm -rf coverage .nyc_output dist/",
"dev": "ts-node-dev --respawn src/index.ts | pino-pretty --singleLine --colorize --ignore time,hostname,ip",

"start": "node dist/index.js",
"start:db": "docker compose up -- db",
"start:test-stack": "docker compose up -d",
"dev": "ts-node-dev --respawn src/index.ts | pino-pretty --singleLine --colorize --ignore time,hostname,ip",
"relay": "ts-node src/scripts/manual-relay.ts",
"start:coverage": "pm2 start --name relayer 'nyc node -r ts-node/register src/index.ts' && ./scripts/health-check.sh",
"start:test-infra": "docker compose up",
"stop:coverage": "pm2 stop relayer && pm2 delete relayer",

"db:init": "prisma init",
"db:gen": "prisma generate",
"db:migrate:dev": "prisma migrate dev",
"db:migrate:prod": "prisma migrate deploy",
"start:coverage": "pm2 start --name relayer 'nyc node -r ts-node/register src/index.ts' && ./scripts/health-check.sh",
"stop:coverage": "pm2 stop relayer && pm2 delete relayer",
"start:test-infra": "docker compose up",

"test": "vitest src/__tests__/*.test.ts --singleThread --run",
"test:coverage": "yarn start:coverage && yarn test && yarn stop:coverage",
"test:ci": "yarn start:test-infra -d; yarn test:coverage",
"clean": "rm -rf coverage .nyc_output dist/"
"test:ci": "yarn start:test-infra -d; yarn test:coverage"
},
"dependencies": {
"@acala-network/api": "~6.0.4",
Expand Down
1 change: 1 addition & 0 deletions src/api/routerInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CHAIN_ID_ACALA } from '@certusone/wormhole-sdk';

import { RouterInfoQuery, RouterInfoUpdate, getChainConfig } from '../utils';
import { db } from '../db';

Expand Down
1 change: 0 additions & 1 deletion src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
import { ROUTER_TOKEN_INFO } from '@acala-network/asset-router/dist/consts';
import { parseUnits } from 'ethers/lib/utils';
import dotenv from 'dotenv';
import { BaseRouter__factory } from '@acala-network/asset-router/dist/typechain-types';

dotenv.config({ path: '.env' });

Expand Down
4 changes: 2 additions & 2 deletions src/middlewares/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
relayAndRoute,
relayAndRouteBatch,
rescueSwapAndLp,
routeDropAndBoostrap,
routeEuphrates,
routeHoma,
routeHomaAuto,
Expand All @@ -36,15 +37,14 @@ import {
routeXcm,
saveRouterInfo,
shouldRelay,
shouldRouteDropAndBoostrap,
shouldRouteEuphrates,
shouldRouteHoma,
shouldRouteSwapAndLp,
shouldRouteWormhole,
shouldRouteXcm,
shouldSwapAndRoute,
swapAndRoute,
shouldRouteDropAndBoostrap,
routeDropAndBoostrap,
} from '../api';

interface RouterConfig {
Expand Down

0 comments on commit 2083e40

Please sign in to comment.