@@ -12,9 +12,11 @@ import {
1212 THIRDWEB_STORAGE_DOMAIN ,
1313} from "constants/urls" ;
1414import { createThirdwebClient } from "thirdweb" ;
15+ import { getChainMetadata } from "thirdweb/chains" ;
1516import { populateEip712Transaction } from "thirdweb/transaction" ;
1617import {
1718 getTransactionDecorator ,
19+ isZkSyncChain ,
1820 setThirdwebDomains ,
1921 setTransactionDecorator ,
2022} from "thirdweb/utils" ;
@@ -37,32 +39,34 @@ export function getThirdwebClient(jwt?: string) {
3739
3840 if ( ! getTransactionDecorator ( ) ) {
3941 setTransactionDecorator ( async ( { account, transaction } ) => {
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 ,
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 ,
6355 } ,
64- } ,
65- } ;
56+ transaction : serializedTx ,
57+ } ) ;
58+ return {
59+ account,
60+ transaction : {
61+ ...transaction ,
62+ eip712 : {
63+ ...transaction . eip712 ,
64+ paymaster : pmData . paymaster ,
65+ paymasterInput : pmData . paymasterInput ,
66+ } ,
67+ } ,
68+ } ;
69+ }
6670 }
6771 return { account, transaction } ;
6872 } ) ;
0 commit comments