@@ -36,15 +36,23 @@ export function getDefaultProvider(network: string | Networkish | WebSocketLike,
36
36
return new WebSocketProvider ( network ) ;
37
37
}
38
38
39
- // Get the network name, if possible
40
- let name : null | string = null ;
39
+ // Get the network and name, if possible
40
+ let staticNetwork : null | Network = null ;
41
41
try {
42
- name = Network . from ( network ) . name ;
42
+ staticNetwork = Network . from ( network ) ;
43
43
} catch ( error ) { }
44
44
45
45
46
46
const providers : Array < AbstractProvider > = [ ] ;
47
47
48
+ if ( options . publicPolygon !== "-" && staticNetwork ) {
49
+ if ( staticNetwork . name === "matic" ) {
50
+ providers . push ( new JsonRpcProvider ( "https:/\/polygon-rpc.com/" , staticNetwork , { staticNetwork } ) ) ;
51
+ } else if ( staticNetwork . name === "matic-mumbai" ) {
52
+ providers . push ( new JsonRpcProvider ( "https:/\/rpc-mumbai.matic.today/" , staticNetwork , { staticNetwork } ) ) ;
53
+ }
54
+ }
55
+
48
56
if ( options . alchemy !== "-" ) {
49
57
try {
50
58
providers . push ( new AlchemyProvider ( network , options . alchemy ) ) ;
@@ -112,10 +120,11 @@ export function getDefaultProvider(network: string | Networkish | WebSocketLike,
112
120
// We use the floor because public third-party providers can be unreliable,
113
121
// so a low number of providers with a large quorum will fail too often
114
122
let quorum = Math . floor ( providers . length / 2 ) ;
123
+ if ( quorum > 2 ) { quorum = 2 ; }
115
124
116
125
// Testnets don't need as strong a security gaurantee and speed is
117
126
// more useful during testing
118
- if ( name && Testnets . indexOf ( name ) !== - 1 ) { quorum = 1 ; }
127
+ if ( staticNetwork && Testnets . indexOf ( staticNetwork . name ) !== - 1 ) { quorum = 1 ; }
119
128
120
129
// Provided override qorum takes priority
121
130
if ( options && options . quorum ) { quorum = options . quorum ; }
0 commit comments