Skip to content

Commit a960ddb

Browse files
committed
api: fix waitForReceipt self-reference, remove wss RPCs, retryBackoff on tx params
1 parent 39cffe3 commit a960ddb

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

packages/daimo-api/.env.example

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ NEXT_PUBLIC_DAIMO_CHAIN="baseSepolia"
55
# INDEX_DATABASE_URL= defaults to local postgres, db=index
66
EXCHANGE_RATES_URL="https://openexchangerates.org/api/latest.json?app_id=TODO"
77
DAIMO_BUNDLER_RPC="https://api.pimlico.io/TODO"
8-
DAIMO_API_L1_RPC_WS="TODO"
9-
DAIMO_API_L2_RPC_WS="TODO"
8+
DAIMO_API_L1_RPC="TODO"
9+
DAIMO_API_L2_RPC="TODO"
1010

1111
# You can generate your own faucet EOA using Metamask/viem/ethers.
1212
# Then, get Base Sepolia ETH here: https://www.alchemy.com/faucets/base-sepolia

packages/daimo-api/src/env.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ const zEnv = {
2626
// we submit [compressed] bundles ourselves.
2727
DAIMO_BUNDLER_RPC: z.string().startsWith("https://"),
2828
// Ethereum L1 RPC, with comma-delimited fallbacks.
29-
DAIMO_API_L1_RPC_WS: z.string(),
29+
DAIMO_API_L1_RPC: z.string(),
3030
// Ethereum L2 RPC, with comma-delimited fallbacks.
31-
DAIMO_API_L2_RPC_WS: z.string(),
31+
DAIMO_API_L2_RPC: z.string(),
3232
// Deployer, compressed userop bundler, + faucet EOA private key.
3333
DAIMO_API_PRIVATE_KEY: z.string().optional().default(""),
3434
// Push notifications enabled? Should only be true in prod.

packages/daimo-api/src/network/viemClient.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,10 @@ export class ViemClient {
106106
private extApiCache: IExternalApiCache
107107
) {
108108
this.account = this.walletClient.account;
109+
const { waitForTransactionReceipt } = publicClient;
109110
publicClient.waitForTransactionReceipt = (args) => {
110111
// Viem's default is 6 = ~24s
111-
return publicClient.waitForTransactionReceipt({
112+
return waitForTransactionReceipt({
112113
...args,
113114
retryCount: 10,
114115
timeout: 60_000, // Wait at most 1 minute for a tx to confirm
@@ -449,7 +450,9 @@ export class ViemClient {
449450
)} Tx submission attempt ${attempt} with txId ${txAttemptId}`
450451
);
451452

452-
await this.setOverrideParams(localTxId, args, prevGasFees);
453+
await retryBackoff("setOverrideParams", () =>
454+
this.setOverrideParams(localTxId, args, prevGasFees)
455+
);
453456

454457
try {
455458
const txHash = await this.walletClient.writeContract(args);

packages/daimo-api/src/network/viemClientUtils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import { privateKeyToAccount } from "viem/accounts";
1313
import { getEnvApi } from "../env";
1414

1515
export function getTransportFromEnv() {
16-
const l1RPCs = getEnvApi().DAIMO_API_L1_RPC_WS.split(",");
17-
const l2RPCs = getEnvApi().DAIMO_API_L2_RPC_WS.split(",");
16+
const l1RPCs = getEnvApi().DAIMO_API_L1_RPC.split(",");
17+
const l2RPCs = getEnvApi().DAIMO_API_L2_RPC.split(",");
1818

1919
console.log(`[VIEM] using transport RPCs L1: ${l1RPCs}, L2: ${l2RPCs}`);
2020

0 commit comments

Comments
 (0)