Skip to content

Commit 7bbe60f

Browse files
[Dashboard] Fix: Only use paymaster for sophon testnet chain (#5392)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on updating the handling of transactions for the `sophon` testnet, specifically for zk chains. It introduces a special case for transactions that ensures the use of an EIP-712 transaction format along with a paymaster. ### Detailed summary - Removed the general check for zk chains on testnets. - Added a specific condition for the `sophon` testnet (chain ID `531050104`). - Ensured that transactions on the `sophon` testnet always use EIP-712 format and include paymaster data. - Simplified the transaction handling by removing unnecessary error handling logic. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 9f9b67d commit 7bbe60f

File tree

1 file changed

+25
-38
lines changed

1 file changed

+25
-38
lines changed

apps/dashboard/src/@/constants/thirdweb.server.ts

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ import {
1212
THIRDWEB_STORAGE_DOMAIN,
1313
} from "constants/urls";
1414
import { createThirdwebClient } from "thirdweb";
15-
import { getChainMetadata } from "thirdweb/chains";
1615
import { populateEip712Transaction } from "thirdweb/transaction";
1716
import {
1817
getTransactionDecorator,
19-
isZkSyncChain,
2018
setThirdwebDomains,
2119
setTransactionDecorator,
2220
} from "thirdweb/utils";
@@ -39,43 +37,32 @@ export function getThirdwebClient(jwt?: string) {
3937

4038
if (!getTransactionDecorator()) {
4139
setTransactionDecorator(async ({ account, transaction }) => {
42-
// use paymaster for zk chains on testnets
43-
const chainMeta = await getChainMetadata(transaction.chain);
44-
if (chainMeta.testnet) {
45-
const isZkChain = await isZkSyncChain(transaction.chain);
46-
if (isZkChain) {
47-
const serializedTx = await populateEip712Transaction({
48-
transaction,
49-
account,
50-
});
51-
const pmData = await getZkPaymasterData({
52-
options: {
53-
client: transaction.client,
54-
chain: transaction.chain,
40+
// special override for sophon testnet (zk chain)
41+
// sophon only allows transactions through their paymaster
42+
// so always use eip712 tx + paymaster
43+
if (transaction.chain.id === 531050104) {
44+
const serializedTx = await populateEip712Transaction({
45+
transaction,
46+
account,
47+
});
48+
const pmData = await getZkPaymasterData({
49+
options: {
50+
client: transaction.client,
51+
chain: transaction.chain,
52+
},
53+
transaction: serializedTx,
54+
});
55+
return {
56+
account,
57+
transaction: {
58+
...transaction,
59+
eip712: {
60+
...transaction.eip712,
61+
paymaster: pmData.paymaster,
62+
paymasterInput: pmData.paymasterInput,
5563
},
56-
transaction: serializedTx,
57-
}).catch((e) => {
58-
console.warn(
59-
"No zk paymaster data available on chain ",
60-
transaction.chain.id,
61-
e,
62-
);
63-
return undefined;
64-
});
65-
return {
66-
account,
67-
transaction: {
68-
...transaction,
69-
eip712: pmData
70-
? {
71-
...transaction.eip712,
72-
paymaster: pmData.paymaster,
73-
paymasterInput: pmData.paymasterInput,
74-
}
75-
: transaction.eip712,
76-
},
77-
};
78-
}
64+
},
65+
};
7966
}
8067
return { account, transaction };
8168
});

0 commit comments

Comments
 (0)