Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bootstrap router #76

Merged
merged 23 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 55 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ GET /shouldRouteWormhole?originAddr=0x07865c6e87b9f70255377e024ace6630c1e00000&t

# ---------- when error ---------- #
GET /shouldRouteWormhole?originAddr=0x07865c6e87b9f70255377e024ace6630c1e00000&targetChainId=2&destAddr=0x0085560b24769dAC4ed057F1B2ae40746AA9aAb6
=>
=>
{
"error": ["fromParaId is a required field"],
"msg": "invalid request params!"
Expand Down Expand Up @@ -527,7 +527,7 @@ GET /shouldSwapAndRoute?recipient=0x0085560b24769dAC4ed057F1B2ae40746AA9aAb6&poo
```

### `/swapAndRoute`
swap token and airdrop targetAmount of targetToken to recipient, and route the quest, then returns the txhash
swap small amount of token and airdrop ACA to recipient, and route the quest, then returns the txhash
```
POST /swapAndRoute
data: {
Expand Down Expand Up @@ -556,6 +556,59 @@ data: {
// similar to /routeXcm
```

### `/shouldRouteDropAndBootstrap`
checks if the relayer can route this request, returns router address
```
GET /shouldRouteDropAndBootstrap
params: {
recipient: string; // dest evm address
gasDrop: boolean; // whether to perform gas drop, only available when feeToken is 'jitosol'
feeToken: string; // token to pay for router fee, either 'jitosol' or 'ldot'
}
```

example
```
GET /shouldRouteDropAndBootstrap?recipient=0x0085560b24769dAC4ed057F1B2ae40746AA9aAb6&gasDrop=1&feeToken=jitosol
=>
{
"data": {
"shouldRoute": true,
"routerAddr": "0xC3FaCa03c514C5e47cf267f971B50280E5ea780b"
}
}
```

### `/routeDropAndBootstrap`
- when calling for the first time: route and perform gas drop (if `gasDrop` is true)
- when calling for the second time: route only

returns the txhash

```
POST /routeDropAndBootstrap
params: {
recipient: string; // dest evm address
gasDrop: boolean; // whether to perform gas drop, only available when feeToken is 'jitosol'
feeToken: string; // token to pay for router fee, either 'jitosol' or 'ldot'
}
```

example
```
POST /routeDropAndBootstrap
{
"recipient":"0x0085560b24769dAC4ed057F1B2ae40746AA9aAb6",
"gasDrop": true,
"feeToken": "jitosol"
}

=> tx hash
{
data: '0xede191f4de90057d320c0d06388e7357edb7bcd6b437a5035dd63dfc8809ce7e'
}
```

## Routing Process
A complete working flow can be found in [routing e2e tests](./src/__tests__/route.test.ts).

Expand Down
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ coverage:

comment:
layout: "reach, diff, flags, files"
behavior: default
behavior: new
require_changes: false
require_base: false
require_head: false
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
volumes:
- ./src/__tests__/configs/acala.yml:/app/acala.yml
command:
bunx @acala-network/chopsticks@latest -c /app/acala.yml
bunx @acala-network/chopsticks@0.15.0 -c /app/acala.yml
ports:
- 8000:8000
healthcheck:
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "acala-wormhole-relayer",
"version": "1.8.5",
"version": "1.9.0-5",
"description": "",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand All @@ -22,7 +22,7 @@
},
"dependencies": {
"@acala-network/api": "~6.0.4",
"@acala-network/asset-router": "~1.0.18",
"@acala-network/asset-router": "~1.0.19-14",
"@acala-network/bodhi": "~2.7.13",
"@acala-network/contracts": "^4.5.0",
"@acala-network/eth-providers": "~2.7.14",
Expand Down
55 changes: 55 additions & 0 deletions src/__tests__/__snapshots__/bootstrap.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`/shouldRouteDropAndBootstrap > when should route > jitosol_gasDrop_false_lowercase 1`] = `
{
"data": {
"routerAddr": "0x7dD4A59B255e13F2eb5cF0297574e5fb9e89576b",
"shouldRoute": true,
},
}
`;

exports[`/shouldRouteDropAndBootstrap > when should route > jitosol_gasDrop_false_original 1`] = `
{
"data": {
"routerAddr": "0x7dD4A59B255e13F2eb5cF0297574e5fb9e89576b",
"shouldRoute": true,
},
}
`;

exports[`/shouldRouteDropAndBootstrap > when should route > jitosol_gasDrop_true_lowercase 1`] = `
{
"data": {
"routerAddr": "0x9A1100129688460930096d7E1204A2989321B113",
"shouldRoute": true,
},
}
`;

exports[`/shouldRouteDropAndBootstrap > when should route > jitosol_gasDrop_true_original 1`] = `
{
"data": {
"routerAddr": "0x9A1100129688460930096d7E1204A2989321B113",
"shouldRoute": true,
},
}
`;

exports[`/shouldRouteDropAndBootstrap > when should route > ldot_gasDrop_false_lowercase 1`] = `
{
"data": {
"routerAddr": "0x6046DD5F660818f9D64Af4536A061D8C3BCE01b9",
"shouldRoute": true,
},
}
`;

exports[`/shouldRouteDropAndBootstrap > when should route > ldot_gasDrop_false_original 1`] = `
{
"data": {
"routerAddr": "0x6046DD5F660818f9D64Af4536A061D8C3BCE01b9",
"shouldRoute": true,
},
}
`;
Loading
Loading