Skip to content

Commit b70454e

Browse files
authored
Add layered error handling to worker (#333)
* Add layered error handling to worker * Update * Update
1 parent 48a2345 commit b70454e

File tree

2 files changed

+276
-239
lines changed

2 files changed

+276
-239
lines changed

src/db/transactions/queueTx.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { BigNumber } from "ethers";
88
import type { ContractExtension } from "../../schema/extension";
99
import { PrismaTransaction } from "../../schema/prisma";
1010
import { getPrismaWithPostgresTx } from "../client";
11+
import { getWalletDetails } from "../wallets/getWalletDetails";
1112

1213
interface QueueTxParams {
1314
pgtx?: PrismaTransaction;
@@ -40,6 +41,16 @@ export const queueTx = async ({
4041

4142
const prisma = getPrismaWithPostgresTx(pgtx);
4243

44+
const fromAddress = (await tx.getSignerAddress()).toLowerCase();
45+
const walletDetails = await getWalletDetails({
46+
pgtx,
47+
address: fromAddress,
48+
});
49+
50+
if (!walletDetails) {
51+
throw new Error(`No configured wallet found with address ${fromAddress}`);
52+
}
53+
4354
// TODO: We need a much safer way of detecting if the transaction should be a user operation
4455
const isUserOp = !!(tx.getSigner as ERC4337EthersSigner).erc4337provider;
4556
const txTableData = {
@@ -61,7 +72,7 @@ export const queueTx = async ({
6172
signerAddress: await (
6273
tx.getSigner as ERC4337EthersSigner
6374
).originalSigner.getAddress(),
64-
accountAddress: (await tx.getSignerAddress()).toLowerCase(),
75+
accountAddress: fromAddress,
6576
// Fields needed to send user operation
6677
target: tx.getTarget().toLowerCase(),
6778
},
@@ -73,7 +84,7 @@ export const queueTx = async ({
7384
data: {
7485
...txTableData,
7586
// Fields needed to send transaction
76-
fromAddress: (await tx.getSignerAddress()).toLowerCase(),
87+
fromAddress,
7788
toAddress: tx.getTarget().toLowerCase(),
7889
},
7990
});

0 commit comments

Comments
 (0)