Skip to content

Commit 6681f70

Browse files
committed
prettier & gh actions
1 parent 0bbf68f commit 6681f70

File tree

10 files changed

+50
-32
lines changed

10 files changed

+50
-32
lines changed

.github/workflows/app.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: app
2+
on: pull_request
3+
jobs:
4+
test:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v4
8+
- uses: oven-sh/setup-bun@4bc047ad259df6fc24a6c9b0f9a0cb08cf17fbe5 # pinning the commit to v2
9+
- run: bun install --frozen-lockfile
10+
- run: bun run check

bun.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"devDependencies": {
1616
"@types/bun": "latest",
1717
"@types/cors": "^2.8.17",
18+
"prettier": "^3.5.3",
1819
},
1920
"peerDependencies": {
2021
"typescript": "^5",
@@ -178,6 +179,8 @@
178179

179180
"path-to-regexp": ["[email protected]", "", {}, "sha512-TdrF7fW9Rphjq4RjrW0Kp2AW0Ahwu9sRGTkS6bvDi0SCwZlEZYmcfDbEsTz8RVk0EHIS/Vd1bv3JhG+1xZuAyQ=="],
180181

182+
"prettier": ["[email protected]", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ=="],
183+
181184
"proxy-addr": ["[email protected]", "", { "dependencies": { "forwarded": "0.2.0", "ipaddr.js": "1.9.1" } }, "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg=="],
182185

183186
"qs": ["[email protected]", "", { "dependencies": { "side-channel": "^1.1.0" } }, "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w=="],

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@
55
"private": true,
66
"devDependencies": {
77
"@types/bun": "latest",
8-
"@types/cors": "^2.8.17"
8+
"@types/cors": "^2.8.17",
9+
"prettier": "^3.5.3"
910
},
1011
"peerDependencies": {
1112
"typescript": "^5"
1213
},
1314
"scripts": {
14-
"start": "bun src/index.ts"
15+
"start": "bun src/index.ts",
16+
"check": "bun run type:check && bun run prettier:check",
17+
"type:check": "tsc --noEmit",
18+
"prettier:check": "prettier . --check"
1519
},
1620
"dependencies": {
1721
"@types/express": "^5.0.3",
@@ -21,5 +25,6 @@
2125
"cors": "^2.8.5",
2226
"express": "^5.1.0",
2327
"viem": "^2.31.7"
24-
}
28+
},
29+
"prettier": {}
2530
}

src/api/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export { quoteHandler } from "./quote";
22
export { statusHandler } from "./status";
3-
export { capabilitiesHandler } from "./capabilities";
3+
export { capabilitiesHandler } from "./capabilities";

src/api/quote.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ export const quoteHandler = async (req: Request, res: Response) => {
4949
.status(400)
5050
.send(
5151
`Unsupported source chain: ${srcChainId}, supported chains: ${enabledChainIds.join(
52-
","
53-
)}`
52+
",",
53+
)}`,
5454
);
5555
return;
5656
}
@@ -60,8 +60,8 @@ export const quoteHandler = async (req: Request, res: Response) => {
6060
.status(400)
6161
.send(
6262
`Unsupported destination chain: ${dstChainId}, supported chains: ${enabledChainIds.join(
63-
","
64-
)}`
63+
",",
64+
)}`,
6565
);
6666
return;
6767
}
@@ -87,7 +87,7 @@ export const quoteHandler = async (req: Request, res: Response) => {
8787
padHex(PAYEE_PUBLIC_KEY, {
8888
dir: "left",
8989
size: 32,
90-
})
90+
}),
9191
),
9292
srcChain: parseInt(srcChainId),
9393
dstChain: parseInt(dstChainId),
@@ -116,7 +116,7 @@ export const quoteHandler = async (req: Request, res: Response) => {
116116
res
117117
.status(400)
118118
.send(
119-
`Request exceeds maxGasLimit: ${gasLimit.toString()} requested, ${dstChain.capabilities.maxGasLimit.toString()} maximum.`
119+
`Request exceeds maxGasLimit: ${gasLimit.toString()} requested, ${dstChain.capabilities.maxGasLimit.toString()} maximum.`,
120120
);
121121
return;
122122
}
@@ -125,7 +125,7 @@ export const quoteHandler = async (req: Request, res: Response) => {
125125
res
126126
.status(400)
127127
.send(
128-
`Request exceeds maxMsgValue: ${msgValue.toString()} requested, ${dstChain.capabilities.maxMsgValue.toString()} maximum.`
128+
`Request exceeds maxMsgValue: ${msgValue.toString()} requested, ${dstChain.capabilities.maxMsgValue.toString()} maximum.`,
129129
);
130130
return;
131131
}
@@ -136,7 +136,7 @@ export const quoteHandler = async (req: Request, res: Response) => {
136136
msgValue,
137137
dstChain.gasPriceDecimals,
138138
srcChain.nativeDecimals,
139-
dstChain.nativeDecimals
139+
dstChain.nativeDecimals,
140140
);
141141
}
142142
res.status(200).json(response);

src/consts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { mnemonicToAccount } from "viem/accounts";
33

44
const account = mnemonicToAccount(
55
"test test test test test test test test test test test junk",
6-
{ addressIndex: 9 }
6+
{ addressIndex: 9 },
77
);
88

99
export const PAYEE_PUBLIC_KEY = account.address;

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ BigInt.prototype.toJSON = function () {
1111

1212
await overrideGuardianSet(
1313
"http://anvil-eth-sepolia:8545",
14-
"0x4a8bc80Ed5a4067f1CCf107057b8270E0cC11A78"
14+
"0x4a8bc80Ed5a4067f1CCf107057b8270E0cC11A78",
1515
);
1616
await overrideGuardianSet(
1717
"http://anvil-base-sepolia:8545",
18-
"0x79A1027a6A159502049F10906D333EC57E95F083"
18+
"0x79A1027a6A159502049F10906D333EC57E95F083",
1919
);
2020

2121
const app = express();

src/mockGuardian.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { EVM_PRIVATE_KEY } from "./consts";
2323
async function getWormholeMessage(
2424
rpc: string,
2525
txHash: Hex,
26-
coreContractAddress: Hex
26+
coreContractAddress: Hex,
2727
): Promise<VAA<"Uint8Array"> | undefined> {
2828
console.log(`Mocking guardian signatures for ${rpc} ${txHash}`);
2929
const transport = http(rpc);
@@ -60,12 +60,12 @@ async function getWormholeMessage(
6060
blockHash: transaction.blockHash,
6161
includeTransactions: false,
6262
})
63-
).timestamp
63+
).timestamp,
6464
),
6565
// NOTE: the Wormhole SDK requires this be a known chain, though that is not strictly necessary for our use case.
6666
emitterChain: toChain(chainId),
6767
emitterAddress: new UniversalAddress(
68-
toBytes(padHex(emitter, { dir: "left", size: 32 }))
68+
toBytes(padHex(emitter, { dir: "left", size: 32 })),
6969
),
7070
consistencyLevel: topic.args.consistencyLevel,
7171
sequence: topic.args.sequence,
@@ -83,7 +83,7 @@ async function getWormholeMessage(
8383
export async function mockWormhole(
8484
rpc: string,
8585
txHash: Hex,
86-
coreContractAddress: Hex
86+
coreContractAddress: Hex,
8787
): Promise<string> {
8888
const vaa = await getWormholeMessage(rpc, txHash, coreContractAddress);
8989
if (vaa) {

src/overrideGuardianSet.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { EVM_PUBLIC_KEY } from "./consts";
1616

1717
export async function overrideGuardianSet(
1818
anvilRpcUrl: string,
19-
coreContractAddress: Hex
19+
coreContractAddress: Hex,
2020
) {
2121
const transport = http(anvilRpcUrl);
2222
const publicClient = createPublicClient({
@@ -39,7 +39,7 @@ export async function overrideGuardianSet(
3939
encodeAbiParameters(parseAbiParameters("uint32, bytes32"), [
4040
guardianSetIndex,
4141
GUARDIAN_SETS_SLOT,
42-
])
42+
]),
4343
);
4444
const firstIndexStorageSlot = BigInt(keccak256(addressesStorageSlot));
4545
await anvilClient.setStorageAt({
@@ -61,7 +61,7 @@ export async function overrideGuardianSet(
6161
]);
6262
console.log(
6363
`Overrode guardian set ${guardianSetIndex} of ${anvilRpcUrl} contract ${coreContractAddress} to ${guardianSet.keys.join(
64-
", "
65-
)}`
64+
", ",
65+
)}`,
6666
);
6767
}

src/utils.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ export async function signQuote(quote: Quote, privateKey: `0x${string}`) {
2222
}
2323

2424
export function getTotalGasLimitAndMsgValue(
25-
relayInstructionsHex: `0x${string}`
25+
relayInstructionsHex: `0x${string}`,
2626
) {
2727
const relayInstructions = deserialize(
2828
relayInstructionsLayout,
29-
fromHex(relayInstructionsHex, "bytes")
29+
fromHex(relayInstructionsHex, "bytes"),
3030
);
3131

3232
return totalGasLimitAndMsgValue(relayInstructions);
@@ -60,44 +60,44 @@ export function estimateQuote(
6060
msgValue: bigint,
6161
dstGasPriceDecimals: number,
6262
srcTokenDecimals: number,
63-
dstNativeDecimals: number
63+
dstNativeDecimals: number,
6464
): bigint {
6565
const r = 18;
6666
const srcChainValueForBaseFee = ScaledMath.normalize(
6767
quote.baseFee,
6868
SIGNED_QUOTE_DECIMALS,
69-
srcTokenDecimals
69+
srcTokenDecimals,
7070
);
7171

7272
const nSrcPrice = ScaledMath.normalize(
7373
quote.srcPrice,
7474
SIGNED_QUOTE_DECIMALS,
75-
r
75+
r,
7676
);
7777
const nDstPrice = ScaledMath.normalize(
7878
quote.dstPrice,
7979
SIGNED_QUOTE_DECIMALS,
80-
r
80+
r,
8181
);
8282
const scaledConversion = ScaledMath.div(nDstPrice, nSrcPrice, r);
8383

8484
const nGasLimitCost = ScaledMath.normalize(
8585
gasLimit * quote.dstGasPrice,
8686
dstGasPriceDecimals,
87-
r
87+
r,
8888
);
8989

9090
const srcChainValueForGasLimit = ScaledMath.normalize(
9191
ScaledMath.mul(nGasLimitCost, scaledConversion, r),
9292
r,
93-
srcTokenDecimals
93+
srcTokenDecimals,
9494
);
9595

9696
const nMsgValue = ScaledMath.normalize(msgValue, dstNativeDecimals, r);
9797
const srcChainValueForMsgValue = ScaledMath.normalize(
9898
ScaledMath.mul(nMsgValue, scaledConversion, r),
9999
r,
100-
srcTokenDecimals
100+
srcTokenDecimals,
101101
);
102102
return (
103103
srcChainValueForBaseFee +

0 commit comments

Comments
 (0)