Skip to content
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
6 changes: 6 additions & 0 deletions bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@

"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=="],

"bufferutil": ["[email protected]", "", { "dependencies": { "node-gyp-build": "^4.3.0" } }, "sha512-WDtdLmJvAuNNPzByAYpRo2rF1Mmradw6gvWsQKf63476DDXmomT9zUiGypLcG4ibIM67vhAj8jJRdbmEws2Aqw=="],

"bun-types": ["[email protected]", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-04+Eha5NP7Z0A9YgDAzMk5PHR16ZuLVa83b26kH5+cp1qZW4F6FmAURngE7INf4tKOvCE69vYvDEwoNl1tGiWw=="],

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

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

"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=="],

"object-assign": ["[email protected]", "", {}, "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg=="],

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

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

"utf-8-validate": ["[email protected]", "", { "dependencies": { "node-gyp-build": "^4.3.0" } }, "sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ=="],

"vary": ["[email protected]", "", {}, "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg=="],

"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=="],
Expand Down
57 changes: 57 additions & 0 deletions src/abis/requestForExecutionLog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
export const RequestForExecutionLogABI = [
{
type: "event",
name: "RequestForExecution",
inputs: [
{
name: "quoterAddress",
type: "address",
indexed: true,
internalType: "address",
},
{
name: "amtPaid",
type: "uint256",
indexed: false,
internalType: "uint256",
},
{
name: "dstChain",
type: "uint16",
indexed: false,
internalType: "uint16",
},
{
name: "dstAddr",
type: "bytes32",
indexed: false,
internalType: "bytes32",
},
{
name: "refundAddr",
type: "address",
indexed: false,
internalType: "address",
},
{
name: "signedQuote",
type: "bytes",
indexed: false,
internalType: "bytes",
},
{
name: "requestBytes",
type: "bytes",
indexed: false,
internalType: "bytes",
},
{
name: "relayInstructions",
type: "bytes",
indexed: false,
internalType: "bytes",
},
],
anonymous: false,
},
] as const;
37 changes: 37 additions & 0 deletions src/abis/vaaV1ReceiveWithGasDropoffAbi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export const vaaV1ReceiveWithGasDropAbi = [
{
type: "function",
name: "VERSION",
inputs: [],
outputs: [{ name: "", type: "string", internalType: "string" }],
stateMutability: "view",
},
{
type: "function",
name: "receiveMessage",
inputs: [
{ name: "contractAddr", type: "address", internalType: "address" },
{ name: "message", type: "bytes", internalType: "bytes" },
{ name: "payeeAddress", type: "address", internalType: "address" },
{ name: "dropOffValue", type: "uint256", internalType: "uint256" },
],
outputs: [],
stateMutability: "payable",
},
{
type: "error",
name: "DropOffFailed",
inputs: [
{ name: "", type: "address", internalType: "address" },
{ name: "", type: "uint256", internalType: "uint256" },
],
},
{
type: "error",
name: "InvalidMsgValue",
inputs: [
{ name: "msgValue", type: "uint256", internalType: "uint256" },
{ name: "dropOffValue", type: "uint256", internalType: "uint256" },
],
},
] as const;
30 changes: 6 additions & 24 deletions src/api/quote.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type Request, type Response } from "express";
import { enabledChains, type ChainConfig } from "../chains";
import { createPublicClient, http, isHex, padHex, toBytes } from "viem";
import { enabledChains } from "../chains";
import { isHex, padHex, toBytes } from "viem";
import type { Quote } from "@wormhole-foundation/sdk-definitions";
import {
PAYEE_PUBLIC_KEY,
Expand All @@ -12,25 +12,7 @@ import {
getTotalGasLimitAndMsgValue,
signQuote,
} from "../utils";
import { anvil } from "viem/chains";

function getChainConfig(chainId: string): ChainConfig | undefined {
const numericId = parseInt(chainId);
return enabledChains[numericId];
}

async function getGasPrice(chainConfig: ChainConfig): Promise<bigint> {
try {
const transport = http(chainConfig.rpc);
const client = createPublicClient({
chain: anvil,
transport,
});
return await client.getGasPrice();
} catch (e) {
throw new Error(`unable to determine gas price`);
}
}
import { EvmHandler } from "../relay/platform/evm";

export const quoteHandler = async (req: Request, res: Response) => {
const enabledChainIds = Object.keys(enabledChains);
Expand Down Expand Up @@ -66,8 +48,8 @@ export const quoteHandler = async (req: Request, res: Response) => {
return;
}

const srcChain = getChainConfig(srcChainId);
const dstChain = getChainConfig(dstChainId);
const srcChain = enabledChains[parseInt(srcChainId)];
const dstChain = enabledChains[parseInt(dstChainId)];

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

const dstGasPrice = await getGasPrice(dstChain);
const dstGasPrice = await EvmHandler.getGasPrice(dstChain);

const quote: Quote = {
quote: {
Expand Down
Loading
Loading