Skip to content

Commit 2128e98

Browse files
committed
adding statuser and relayer
1 parent 7a6df7a commit 2128e98

16 files changed

+1007
-28
lines changed

bun.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@
7777

7878
"body-parser": ["[email protected]", "", { "dependencies": { "bytes": "^3.1.2", "content-type": "^1.0.5", "debug": "^4.4.0", "http-errors": "^2.0.0", "iconv-lite": "^0.6.3", "on-finished": "^2.4.1", "qs": "^6.14.0", "raw-body": "^3.0.0", "type-is": "^2.0.0" } }, "sha512-02qvAaxv8tp7fBa/mw1ga98OGm+eCbqzJOKoRt70sLmfEEi+jyBYVTDGfCL/k06/4EMk/z01gCe7HoCH/f2LTg=="],
7979

80+
"bufferutil": ["[email protected]", "", { "dependencies": { "node-gyp-build": "^4.3.0" } }, "sha512-WDtdLmJvAuNNPzByAYpRo2rF1Mmradw6gvWsQKf63476DDXmomT9zUiGypLcG4ibIM67vhAj8jJRdbmEws2Aqw=="],
81+
8082
"bun-types": ["[email protected]", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-04+Eha5NP7Z0A9YgDAzMk5PHR16ZuLVa83b26kH5+cp1qZW4F6FmAURngE7INf4tKOvCE69vYvDEwoNl1tGiWw=="],
8183

8284
"bytes": ["[email protected]", "", {}, "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg=="],
@@ -165,6 +167,8 @@
165167

166168
"negotiator": ["[email protected]", "", {}, "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg=="],
167169

170+
"node-gyp-build": ["[email protected]", "", { "bin": { "node-gyp-build": "bin.js", "node-gyp-build-optional": "optional.js", "node-gyp-build-test": "build-test.js" } }, "sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ=="],
171+
168172
"object-assign": ["[email protected]", "", {}, "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg=="],
169173

170174
"object-inspect": ["[email protected]", "", {}, "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew=="],
@@ -221,6 +225,8 @@
221225

222226
"unpipe": ["[email protected]", "", {}, "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ=="],
223227

228+
"utf-8-validate": ["[email protected]", "", { "dependencies": { "node-gyp-build": "^4.3.0" } }, "sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ=="],
229+
224230
"vary": ["[email protected]", "", {}, "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg=="],
225231

226232
"viem": ["[email protected]", "", { "dependencies": { "@noble/curves": "1.9.2", "@noble/hashes": "1.8.0", "@scure/bip32": "1.7.0", "@scure/bip39": "1.6.0", "abitype": "1.0.8", "isows": "1.0.7", "ox": "0.8.1", "ws": "8.18.2" }, "peerDependencies": { "typescript": ">=5.0.4" }, "optionalPeers": ["typescript"] }, "sha512-mpB8Hp6xK77E/b/yJmpAIQcxcOfpbrwWNItjnXaIA8lxZYt4JS433Pge2gg6Hp3PwyFtaUMh01j5L8EXnLTjQQ=="],

src/abis/requestForExecutionLog.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
export const RequestForExecutionLogABI = [
2+
{
3+
type: "event",
4+
name: "RequestForExecution",
5+
inputs: [
6+
{
7+
name: "quoterAddress",
8+
type: "address",
9+
indexed: true,
10+
internalType: "address",
11+
},
12+
{
13+
name: "amtPaid",
14+
type: "uint256",
15+
indexed: false,
16+
internalType: "uint256",
17+
},
18+
{
19+
name: "dstChain",
20+
type: "uint16",
21+
indexed: false,
22+
internalType: "uint16",
23+
},
24+
{
25+
name: "dstAddr",
26+
type: "bytes32",
27+
indexed: false,
28+
internalType: "bytes32",
29+
},
30+
{
31+
name: "refundAddr",
32+
type: "address",
33+
indexed: false,
34+
internalType: "address",
35+
},
36+
{
37+
name: "signedQuote",
38+
type: "bytes",
39+
indexed: false,
40+
internalType: "bytes",
41+
},
42+
{
43+
name: "requestBytes",
44+
type: "bytes",
45+
indexed: false,
46+
internalType: "bytes",
47+
},
48+
{
49+
name: "relayInstructions",
50+
type: "bytes",
51+
indexed: false,
52+
internalType: "bytes",
53+
},
54+
],
55+
anonymous: false,
56+
},
57+
] as const;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
export const vaaV1ReceiveWithGasDropAbi = [
2+
{
3+
type: "function",
4+
name: "VERSION",
5+
inputs: [],
6+
outputs: [{ name: "", type: "string", internalType: "string" }],
7+
stateMutability: "view",
8+
},
9+
{
10+
type: "function",
11+
name: "receiveMessage",
12+
inputs: [
13+
{ name: "contractAddr", type: "address", internalType: "address" },
14+
{ name: "message", type: "bytes", internalType: "bytes" },
15+
{ name: "payeeAddress", type: "address", internalType: "address" },
16+
{ name: "dropOffValue", type: "uint256", internalType: "uint256" },
17+
],
18+
outputs: [],
19+
stateMutability: "payable",
20+
},
21+
{
22+
type: "error",
23+
name: "DropOffFailed",
24+
inputs: [
25+
{ name: "", type: "address", internalType: "address" },
26+
{ name: "", type: "uint256", internalType: "uint256" },
27+
],
28+
},
29+
{
30+
type: "error",
31+
name: "InvalidMsgValue",
32+
inputs: [
33+
{ name: "msgValue", type: "uint256", internalType: "uint256" },
34+
{ name: "dropOffValue", type: "uint256", internalType: "uint256" },
35+
],
36+
},
37+
] as const;

src/api/quote.ts

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { type Request, type Response } from "express";
2-
import { enabledChains, type ChainConfig } from "../chains";
3-
import { createPublicClient, http, isHex, padHex, toBytes } from "viem";
2+
import { enabledChains } from "../chains";
3+
import { isHex, padHex, toBytes } from "viem";
44
import type { Quote } from "@wormhole-foundation/sdk-definitions";
55
import {
66
PAYEE_PUBLIC_KEY,
@@ -12,25 +12,7 @@ import {
1212
getTotalGasLimitAndMsgValue,
1313
signQuote,
1414
} from "../utils";
15-
import { anvil } from "viem/chains";
16-
17-
function getChainConfig(chainId: string): ChainConfig | undefined {
18-
const numericId = parseInt(chainId);
19-
return enabledChains[numericId];
20-
}
21-
22-
async function getGasPrice(chainConfig: ChainConfig): Promise<bigint> {
23-
try {
24-
const transport = http(chainConfig.rpc);
25-
const client = createPublicClient({
26-
chain: anvil,
27-
transport,
28-
});
29-
return await client.getGasPrice();
30-
} catch (e) {
31-
throw new Error(`unable to determine gas price`);
32-
}
33-
}
15+
import { EvmHandler } from "../relay/platform/evm";
3416

3517
export const quoteHandler = async (req: Request, res: Response) => {
3618
const enabledChainIds = Object.keys(enabledChains);
@@ -66,8 +48,8 @@ export const quoteHandler = async (req: Request, res: Response) => {
6648
return;
6749
}
6850

69-
const srcChain = getChainConfig(srcChainId);
70-
const dstChain = getChainConfig(dstChainId);
51+
const srcChain = enabledChains[parseInt(srcChainId)];
52+
const dstChain = enabledChains[parseInt(dstChainId)];
7153

7254
if (!srcChain || !dstChain) {
7355
res.status(500).send("Internal error: Invalid chain configuration");
@@ -77,7 +59,7 @@ export const quoteHandler = async (req: Request, res: Response) => {
7759
const expiryTime = new Date();
7860
expiryTime.setHours(expiryTime.getHours() + 1);
7961

80-
const dstGasPrice = await getGasPrice(dstChain);
62+
const dstGasPrice = await EvmHandler.getGasPrice(dstChain);
8163

8264
const quote: Quote = {
8365
quote: {

0 commit comments

Comments
 (0)