Skip to content

Commit 24a3ee4

Browse files
fix: legacy transactions with in-app wallet (#2914)
1 parent 5525a0e commit 24a3ee4

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

.changeset/chilly-boxes-complain.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 legacy transactions with in-app wallets

packages/thirdweb/src/storage/upload/web-node.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ export async function uploadBatch<const TFiles extends UploadableFile[]>(
3131
);
3232
}
3333
throw new Error(
34-
`Failed to upload files to IPFS - ${res.status} - ${
35-
res.statusText
36-
} - ${await res.text()}`,
34+
`Failed to upload files to IPFS - ${res.status} - ${res.statusText}`,
3735
);
3836
}
3937

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

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -178,23 +178,31 @@ export class InAppWallet {
178178
params: undefined,
179179
});
180180
const _signTransaction = async (tx: SendTransactionOption) => {
181+
// biome-ignore lint/suspicious/noExplicitAny: ethers tx transformation
182+
const transaction: Record<string, any> = {
183+
to: tx.to ?? undefined,
184+
data: tx.data,
185+
value: tx.value,
186+
gasLimit: tx.gas,
187+
nonce: tx.nonce,
188+
chainId: tx.chainId,
189+
};
190+
if (tx.maxFeePerGas) {
191+
// ethers (in the iframe) rejects any type 0 trasaction with unknown keys
192+
// TODO remove this once iframe is upgraded to v5
193+
transaction.accessList = tx.accessList;
194+
transaction.maxFeePerGas = tx.maxFeePerGas;
195+
transaction.maxPriorityFeePerGas = tx.maxPriorityFeePerGas;
196+
transaction.type = 2;
197+
} else {
198+
transaction.gasPrice = tx.gasPrice;
199+
transaction.type = 0;
200+
}
181201
const { signedTransaction } =
182202
await querier.call<SignTransactionReturnType>({
183203
procedureName: "signTransaction",
184204
params: {
185-
transaction: {
186-
to: tx.to ?? undefined,
187-
data: tx.data,
188-
value: tx.value,
189-
gasLimit: tx.gas,
190-
gasPrice: tx.gasPrice,
191-
nonce: tx.nonce,
192-
chainId: tx.chainId,
193-
accessList: tx.accessList,
194-
maxFeePerGas: tx.maxFeePerGas,
195-
maxPriorityFeePerGas: tx.maxPriorityFeePerGas,
196-
type: tx.maxFeePerGas ? 2 : 0,
197-
},
205+
transaction,
198206
chainId: tx.chainId,
199207
rpcEndpoint: `https://${tx.chainId}.rpc.thirdweb.com`, // TODO (ew) shouldnt be needed
200208
},

0 commit comments

Comments
 (0)