@@ -10,7 +10,7 @@ import {
1010 type TransactionType ,
1111 type Transport ,
1212} from 'viem'
13- import { createConfig , createStorage , fallback , http } from 'wagmi'
13+ import { createConfig , createStorage , fallback , http , webSocket } from 'wagmi'
1414import { localhost , mainnet , sepolia } from 'wagmi/chains'
1515
1616import { ccipRequest } from '@ensdomains/ensjs/utils'
@@ -53,17 +53,17 @@ export const drpcUrl = (chainName: string) =>
5353 chainName === 'mainnet' ? 'ethereum' : chainName
5454 } &dkey=${ drpcKey } `
5555
56- type SupportedUrlFunc = typeof drpcUrl | typeof tenderlyUrl
57-
58- const initialiseTransports = < const UrlFuncArray extends SupportedUrlFunc [ ] > (
59- chainName : string ,
60- urlFuncArray : UrlFuncArray ,
61- ) => {
62- const transportArray : HttpTransport [ ] = [ ]
63-
64- for ( const urlFunc of urlFuncArray ) transportArray . push ( http ( urlFunc ( chainName ) ) )
56+ export const drpcWsUrl = ( chainName : string ) =>
57+ `wss://lb.drpc.org/ogws?network=${
58+ chainName === 'mainnet' ? 'ethereum' : chainName
59+ } &dkey=${ drpcKey } `
6560
66- return fallback ( transportArray )
61+ const initialiseTransports = ( chainName : string ) => {
62+ return fallback ( [
63+ webSocket ( drpcWsUrl ( chainName ) ) , // Primary: instant block updates via subscription
64+ http ( drpcUrl ( chainName ) ) , // Fallback 1: DRPC HTTP
65+ http ( tenderlyUrl ( chainName ) ) , // Fallback 2: Tenderly HTTP
66+ ] )
6767}
6868
6969export const prefix = 'wagmi'
@@ -109,8 +109,8 @@ export const transports = {
109109 // this is a hack to make the types happy, dont remove pls
110110 [ localhost . id ] : HttpTransport
111111 } ) ) ,
112- [ mainnet . id ] : initialiseTransports ( 'mainnet' , [ drpcUrl , tenderlyUrl ] ) ,
113- [ sepolia . id ] : initialiseTransports ( 'sepolia' , [ drpcUrl , tenderlyUrl ] ) ,
112+ [ mainnet . id ] : initialiseTransports ( 'mainnet' ) ,
113+ [ sepolia . id ] : initialiseTransports ( 'sepolia' ) ,
114114} as const
115115
116116// This is a workaround to fix MetaMask defaulting to the wrong transaction type
0 commit comments