Skip to content

Commit 6771cfe

Browse files
committed
Winston/cnct 2311 pro cannot sign transaction with in app wallet (#5390)
## Problem solved https://linear.app/thirdweb/issue/CNCT-2311/pro-cannot-sign-transaction-with-in-app-wallet <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on improving the transaction signing process in the `enclave-wallet` by ensuring proper type checks for various transaction properties, specifically handling cases for `bigint` and `number` types. ### Detailed summary - Updated the handling of `tx.value`, `tx.gas`, `tx.nonce`, `tx.maxPriorityFeePerGas`, and `tx.gasPrice` to check their types before processing. - Ensured that `tx.value`, `tx.gas`, and `tx.maxPriorityFeePerGas` are only processed if they are of type `bigint`. - Adjusted the handling of `tx.nonce` to support both `number` and fallback to `eth_getTransactionCount`. - Maintained a 10% buffer for `tx.gas` calculations. - Updated the assignment of `transaction.maxFeePerGas` and `transaction.type` based on the presence of `tx.maxFeePerGas`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent ff188fd commit 6771cfe

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

.changeset/serious-plants-play.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
fix enclave transaction signing for transactions with 0 maxPriorityFeePerGas

packages/thirdweb/src/wallets/in-app/core/wallet/enclave-wallet.ts

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -141,34 +141,39 @@ export class EnclaveWallet implements IWebWallet {
141141
const transaction: Record<string, Hex | number | undefined> = {
142142
to: tx.to ? getAddress(tx.to) : undefined,
143143
data: tx.data,
144-
value: tx.value ? toHex(tx.value) : undefined,
145-
gas: tx.gas ? toHex(tx.gas + tx.gas / BigInt(10)) : undefined, // Add a 10% buffer to gas
146-
nonce: tx.nonce
147-
? toHex(tx.nonce)
148-
: toHex(
149-
await import(
150-
"../../../../rpc/actions/eth_getTransactionCount.js"
151-
).then(({ eth_getTransactionCount }) =>
152-
eth_getTransactionCount(rpcRequest, {
153-
address: this.address,
154-
blockTag: "pending",
155-
}),
144+
value: typeof tx.value === "bigint" ? toHex(tx.value) : undefined,
145+
gas:
146+
typeof tx.gas === "bigint"
147+
? toHex(tx.gas + tx.gas / BigInt(10))
148+
: undefined, // Add a 10% buffer to gas
149+
nonce:
150+
typeof tx.nonce === "number"
151+
? toHex(tx.nonce)
152+
: toHex(
153+
await import(
154+
"../../../../rpc/actions/eth_getTransactionCount.js"
155+
).then(({ eth_getTransactionCount }) =>
156+
eth_getTransactionCount(rpcRequest, {
157+
address: this.address,
158+
blockTag: "pending",
159+
}),
160+
),
156161
),
157-
),
158162
chainId: toHex(tx.chainId),
159163
};
160164

161165
if (tx.maxFeePerGas) {
162166
transaction.maxFeePerGas = toHex(tx.maxFeePerGas);
163-
transaction.maxPriorityFeePerGas = tx.maxPriorityFeePerGas
164-
? toHex(tx.maxPriorityFeePerGas)
165-
: undefined;
167+
transaction.maxPriorityFeePerGas =
168+
typeof tx.maxPriorityFeePerGas === "bigint"
169+
? toHex(tx.maxPriorityFeePerGas)
170+
: undefined;
166171
transaction.type = 2;
167172
} else {
168-
transaction.gasPrice = tx.gasPrice ? toHex(tx.gasPrice) : undefined;
173+
transaction.gasPrice =
174+
typeof tx.gasPrice === "bigint" ? toHex(tx.gasPrice) : undefined;
169175
transaction.type = 0;
170176
}
171-
172177
return signEnclaveTransaction({
173178
client,
174179
storage,

0 commit comments

Comments
 (0)