Skip to content

Commit d5b7859

Browse files
committed
Merge remote-tracking branch 'origin/main' into ph/increaseGasOnResend
2 parents 5eeee17 + 8f668fe commit d5b7859

File tree

72 files changed

+1433
-1257
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1433
-1257
lines changed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"@cloud-cryptographic-wallet/cloud-kms-signer": "^0.1.2",
3333
"@cloud-cryptographic-wallet/signer": "^0.0.5",
3434
"@ethersproject/json-wallets": "^5.7.0",
35-
"@fastify/basic-auth": "^5.1.1",
3635
"@fastify/swagger": "^8.9.0",
3736
"@fastify/type-provider-typebox": "^3.2.0",
3837
"@fastify/websocket": "^8.2.0",
@@ -67,9 +66,8 @@
6766
"pg": "^8.11.3",
6867
"prisma": "^5.14.0",
6968
"prom-client": "^15.1.3",
70-
"prool": "^0.0.16",
7169
"superjson": "^2.2.1",
72-
"thirdweb": "5.61.3",
70+
"thirdweb": "^5.71.0",
7371
"uuid": "^9.0.1",
7472
"winston": "^3.14.1",
7573
"zod": "^3.23.8"
@@ -91,6 +89,7 @@
9189
"eslint-config-prettier": "^8.7.0",
9290
"openapi-typescript-codegen": "^0.25.0",
9391
"prettier": "^2.8.7",
92+
"prool": "^0.0.16",
9493
"typescript": "^5.1.3",
9594
"vitest": "^2.0.3"
9695
},
@@ -102,7 +101,7 @@
102101
"schema": "./src/prisma/schema.prisma"
103102
},
104103
"resolutions": {
105-
"@thirdweb-dev/auth/**/axios": ">=1.7.4",
104+
"@thirdweb-dev/auth/**/axios": ">=1.7.8",
106105
"@thirdweb-dev/auth/**/web3-utils": ">=4.2.1",
107106
"ethers-gcp-kms-signer/**/protobufjs": ">=7.2.5",
108107
"fastify/**/find-my-way": ">=8.2.2",
@@ -112,6 +111,7 @@
112111
"elliptic": ">=6.6.0",
113112
"micromatch": ">=4.0.8",
114113
"secp256k1": ">=4.0.4",
115-
"ws": ">=8.17.1"
114+
"ws": ">=8.17.1",
115+
"cross-spawn": ">=7.0.6"
116116
}
117117
}

sdk/yarn.lock

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -554,12 +554,12 @@ brace-expansion@^1.1.7:
554554
balanced-match "^1.0.0"
555555
concat-map "0.0.1"
556556

557-
braces@^3.0.2:
558-
version "3.0.2"
559-
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
560-
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
557+
braces@^3.0.3:
558+
version "3.0.3"
559+
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789"
560+
integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==
561561
dependencies:
562-
fill-range "^7.0.1"
562+
fill-range "^7.1.1"
563563

564564
browserslist@^4.21.9:
565565
version "4.22.1"
@@ -764,10 +764,10 @@ fastq@^1.6.0:
764764
dependencies:
765765
reusify "^1.0.4"
766766

767-
fill-range@^7.0.1:
768-
version "7.0.1"
769-
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40"
770-
integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==
767+
fill-range@^7.1.1:
768+
version "7.1.1"
769+
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292"
770+
integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==
771771
dependencies:
772772
to-regex-range "^5.0.1"
773773

@@ -1096,11 +1096,11 @@ merge2@^1.3.0:
10961096
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==
10971097

10981098
micromatch@^4.0.4:
1099-
version "4.0.5"
1100-
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6"
1101-
integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==
1099+
version "4.0.8"
1100+
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202"
1101+
integrity sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==
11021102
dependencies:
1103-
braces "^3.0.2"
1103+
braces "^3.0.3"
11041104
picomatch "^2.3.1"
11051105

11061106
min-indent@^1.0.0:
@@ -1326,9 +1326,9 @@ reusify@^1.0.4:
13261326
integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==
13271327

13281328
rollup@^2.79.1:
1329-
version "2.79.1"
1330-
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.79.1.tgz#bedee8faef7c9f93a2647ac0108748f497f081c7"
1331-
integrity sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==
1329+
version "2.79.2"
1330+
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.79.2.tgz#f150e4a5db4b121a21a747d762f701e5e9f49090"
1331+
integrity sha512-fS6iqSPZDs3dr/y7Od6y5nha8dW1YnbgtsyotCVvoFGKbERG++CVRFv1meyGDE1SNItQA8BrnCw7ScdAhRJ3XQ==
13321332
optionalDependencies:
13331333
fsevents "~2.3.2"
13341334

src/db/chainIndexers/getChainIndexer.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Prisma } from "@prisma/client";
12
import type { PrismaTransaction } from "../../schema/prisma";
23
import { getPrismaWithPostgresTx } from "../client";
34

@@ -14,7 +15,7 @@ export const getLastIndexedBlock = async ({
1415

1516
const indexedChain = await prisma.chainIndexers.findUnique({
1617
where: {
17-
chainId,
18+
chainId: chainId.toString(),
1819
},
1920
});
2021

@@ -42,7 +43,7 @@ export const getBlockForIndexing = async ({
4243
FROM
4344
"chain_indexers"
4445
WHERE
45-
"chainId"=${chainId}
46+
"chainId"=${Prisma.sql`${chainId.toString()}`}
4647
FOR UPDATE NOWAIT
4748
`;
4849
return lastIndexedBlock[0].lastIndexedBlock;

src/db/chainIndexers/upsertChainIndexer.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PrismaTransaction } from "../../schema/prisma";
1+
import type { PrismaTransaction } from "../../schema/prisma";
22
import { getPrismaWithPostgresTx } from "../client";
33

44
interface UpsertChainIndexerParams {
@@ -15,14 +15,14 @@ export const upsertChainIndexer = async ({
1515
const prisma = getPrismaWithPostgresTx(pgtx);
1616
return prisma.chainIndexers.upsert({
1717
where: {
18-
chainId,
18+
chainId: chainId.toString(),
1919
},
2020
update: {
21-
chainId,
21+
chainId: chainId.toString(),
2222
lastIndexedBlock: currentBlockNumber,
2323
},
2424
create: {
25-
chainId,
25+
chainId: chainId.toString(),
2626
lastIndexedBlock: currentBlockNumber,
2727
},
2828
});

src/db/contractEventLogs/deleteContractEventLogs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const deleteContractEventLogs = async ({
1111
}: DeleteContractEventLogsParams) => {
1212
return prisma.contractEventLogs.deleteMany({
1313
where: {
14-
chainId,
14+
chainId: chainId.toString(),
1515
contractAddress,
1616
},
1717
});

src/db/contractEventLogs/getContractEventLogs.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const getContractEventLogsByBlockAndTopics = async ({
1818
topics,
1919
}: GetContractLogsParams) => {
2020
const whereClause = {
21-
chainId,
21+
chainId: chainId.toString(),
2222
contractAddress,
2323
blockNumber: {
2424
gte: fromBlock,
@@ -118,7 +118,9 @@ export const getEventLogsByCursor = async ({
118118
let cursorObj: z.infer<typeof CursorSchema> | null = null;
119119
if (cursor) {
120120
const decodedCursor = base64.decode(cursor);
121-
const parsedCursor = decodedCursor.split("-").map((val) => parseInt(val));
121+
const parsedCursor = decodedCursor
122+
.split("-")
123+
.map((val) => Number.parseInt(val));
122124
const [createdAt, chainId, blockNumber, transactionIndex, logIndex] =
123125
parsedCursor;
124126
const validationResult = CursorSchema.safeParse({
@@ -148,22 +150,22 @@ export const getEventLogsByCursor = async ({
148150
{ createdAt: { gt: cursorObj.createdAt } },
149151
{
150152
createdAt: { equals: cursorObj.createdAt },
151-
chainId: { gt: cursorObj.chainId },
153+
chainId: { gt: cursorObj.chainId.toString() },
152154
},
153155
{
154156
createdAt: { equals: cursorObj.createdAt },
155-
chainId: { equals: cursorObj.chainId },
157+
chainId: { equals: cursorObj.chainId.toString() },
156158
blockNumber: { gt: cursorObj.blockNumber },
157159
},
158160
{
159161
createdAt: { equals: cursorObj.createdAt },
160-
chainId: { equals: cursorObj.chainId },
162+
chainId: { equals: cursorObj.chainId.toString() },
161163
blockNumber: { equals: cursorObj.blockNumber },
162164
transactionIndex: { gt: cursorObj.transactionIndex },
163165
},
164166
{
165167
createdAt: { equals: cursorObj.createdAt },
166-
chainId: { equals: cursorObj.chainId },
168+
chainId: { equals: cursorObj.chainId.toString() },
167169
blockNumber: { equals: cursorObj.blockNumber },
168170
transactionIndex: { equals: cursorObj.transactionIndex },
169171
logIndex: { gt: cursorObj.logIndex },
@@ -234,7 +236,7 @@ export const getContractEventLogsIndexedBlockRange = async ({
234236
}: GetContractEventLogsIndexedBlockRangeParams) => {
235237
const result = await prisma.contractEventLogs.aggregate({
236238
where: {
237-
chainId,
239+
chainId: chainId.toString(),
238240
contractAddress,
239241
},
240242
_min: {

src/db/contractTransactionReceipts/deleteContractTransactionReceipts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const deleteContractTransactionReceipts = async ({
1111
}: DeleteContractTransactionReceiptsParams) => {
1212
return prisma.contractTransactionReceipts.deleteMany({
1313
where: {
14-
chainId,
14+
chainId: chainId.toString(),
1515
contractAddress,
1616
},
1717
});

src/db/contractTransactionReceipts/getContractTransactionReceipts.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const getContractTransactionReceiptsByBlock = async ({
1616
toBlock,
1717
}: GetContractTransactionReceiptsParams) => {
1818
const whereClause = {
19-
chainId,
19+
chainId: chainId.toString(),
2020
contractAddress,
2121
blockNumber: {
2222
gte: fromBlock,
@@ -90,7 +90,9 @@ export const getTransactionReceiptsByCursor = async ({
9090
let cursorObj: z.infer<typeof CursorSchema> | null = null;
9191
if (cursor) {
9292
const decodedCursor = base64.decode(cursor);
93-
const parsedCursor = decodedCursor.split("-").map((val) => parseInt(val));
93+
const parsedCursor = decodedCursor
94+
.split("-")
95+
.map((val) => Number.parseInt(val));
9496
const [createdAt, chainId, blockNumber, transactionIndex] = parsedCursor;
9597
const validationResult = CursorSchema.safeParse({
9698
createdAt,
@@ -118,16 +120,16 @@ export const getTransactionReceiptsByCursor = async ({
118120
{ createdAt: { gt: cursorObj.createdAt } },
119121
{
120122
createdAt: { equals: cursorObj.createdAt },
121-
chainId: { gt: cursorObj.chainId },
123+
chainId: { gt: cursorObj.chainId.toString() },
122124
},
123125
{
124126
createdAt: { equals: cursorObj.createdAt },
125-
chainId: { equals: cursorObj.chainId },
127+
chainId: { equals: cursorObj.chainId.toString() },
126128
blockNumber: { gt: cursorObj.blockNumber },
127129
},
128130
{
129131
createdAt: { equals: cursorObj.createdAt },
130-
chainId: { equals: cursorObj.chainId },
132+
chainId: { equals: cursorObj.chainId.toString() },
131133
blockNumber: { gt: cursorObj.blockNumber },
132134
transactionIndex: { gt: cursorObj.transactionIndex },
133135
},

src/db/wallets/getWalletDetails.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export const getWalletDetails = async ({
175175
? decrypt(walletDetails.awsKmsSecretAccessKey, env.ENCRYPTION_PASSWORD)
176176
: (config.walletConfiguration.aws?.awsSecretAccessKey ?? null);
177177

178-
walletDetails.awsKmsKeyId =
178+
walletDetails.awsKmsAccessKeyId =
179179
walletDetails.awsKmsAccessKeyId ??
180180
config.walletConfiguration.aws?.awsAccessKeyId ??
181181
null;

src/db/wallets/walletNonce.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -250,18 +250,19 @@ export const inspectNonce = async (chainId: number, walletAddress: Address) => {
250250
};
251251

252252
/**
253-
* Delete all wallet nonces. Useful when they get out of sync.
253+
* Delete nonce state for the provided wallets.
254+
* @param backendWallets
254255
*/
255-
export const deleteAllNonces = async () => {
256-
const keys = [
257-
...(await redis.keys("nonce:*")),
258-
...(await redis.keys("nonce-recycled:*")),
259-
...(await redis.keys("sent-nonce:*")),
260-
];
261-
if (keys.length > 0) {
262-
await redis.del(keys);
263-
}
264-
};
256+
export async function deleteNoncesForBackendWallets(
257+
backendWallets: { chainId: number; walletAddress: Address }[],
258+
) {
259+
const keys = backendWallets.flatMap(({ chainId, walletAddress }) => [
260+
lastUsedNonceKey(chainId, walletAddress),
261+
recycledNoncesKey(chainId, walletAddress),
262+
sentNoncesKey(chainId, walletAddress),
263+
]);
264+
await redis.del(keys);
265+
}
265266

266267
/**
267268
* Resync the nonce to the higher of (db nonce, onchain nonce).

0 commit comments

Comments
 (0)