From 7bbe60f2be08fd9f3f917cece72e014b6e756ffc Mon Sep 17 00:00:00 2001 From: joaquim-verges Date: Wed, 13 Nov 2024 20:29:31 +0000 Subject: [PATCH] [Dashboard] Fix: Only use paymaster for sophon testnet chain (#5392) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Problem solved Short description of the bug fixed or feature added --- ## 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}` --- .../src/@/constants/thirdweb.server.ts | 63 ++++++++----------- 1 file changed, 25 insertions(+), 38 deletions(-) diff --git a/apps/dashboard/src/@/constants/thirdweb.server.ts b/apps/dashboard/src/@/constants/thirdweb.server.ts index 5686e5d1acc..67e151e4c92 100644 --- a/apps/dashboard/src/@/constants/thirdweb.server.ts +++ b/apps/dashboard/src/@/constants/thirdweb.server.ts @@ -12,11 +12,9 @@ import { THIRDWEB_STORAGE_DOMAIN, } from "constants/urls"; import { createThirdwebClient } from "thirdweb"; -import { getChainMetadata } from "thirdweb/chains"; import { populateEip712Transaction } from "thirdweb/transaction"; import { getTransactionDecorator, - isZkSyncChain, setThirdwebDomains, setTransactionDecorator, } from "thirdweb/utils"; @@ -39,43 +37,32 @@ export function getThirdwebClient(jwt?: string) { if (!getTransactionDecorator()) { setTransactionDecorator(async ({ account, transaction }) => { - // use paymaster for zk chains on testnets - const chainMeta = await getChainMetadata(transaction.chain); - if (chainMeta.testnet) { - const isZkChain = await isZkSyncChain(transaction.chain); - if (isZkChain) { - const serializedTx = await populateEip712Transaction({ - transaction, - account, - }); - const pmData = await getZkPaymasterData({ - options: { - client: transaction.client, - chain: transaction.chain, + // special override for sophon testnet (zk chain) + // sophon only allows transactions through their paymaster + // so always use eip712 tx + paymaster + if (transaction.chain.id === 531050104) { + const serializedTx = await populateEip712Transaction({ + transaction, + account, + }); + const pmData = await getZkPaymasterData({ + options: { + client: transaction.client, + chain: transaction.chain, + }, + transaction: serializedTx, + }); + return { + account, + transaction: { + ...transaction, + eip712: { + ...transaction.eip712, + paymaster: pmData.paymaster, + paymasterInput: pmData.paymasterInput, }, - transaction: serializedTx, - }).catch((e) => { - console.warn( - "No zk paymaster data available on chain ", - transaction.chain.id, - e, - ); - return undefined; - }); - return { - account, - transaction: { - ...transaction, - eip712: pmData - ? { - ...transaction.eip712, - paymaster: pmData.paymaster, - paymasterInput: pmData.paymasterInput, - } - : transaction.eip712, - }, - }; - } + }, + }; } return { account, transaction }; });