@@ -12,11 +12,9 @@ import {
1212 THIRDWEB_STORAGE_DOMAIN ,
1313} from "constants/urls" ;
1414import { createThirdwebClient } from "thirdweb" ;
15- import { getChainMetadata } from "thirdweb/chains" ;
1615import { populateEip712Transaction } from "thirdweb/transaction" ;
1716import {
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