@@ -45,7 +45,7 @@ function getResult(result: { status?: number, message?: string, result?: any }):
45
45
return result . result ;
46
46
}
47
47
48
- if ( result . status != 1 || result . message != "OK" ) {
48
+ if ( result . status != 1 || typeof ( result . message ) !== "string" || ! result . message . match ( / ^ O K / ) ) {
49
49
const error : any = new Error ( "invalid response" ) ;
50
50
error . result = JSON . stringify ( result ) ;
51
51
if ( ( result . result || "" ) . toLowerCase ( ) . indexOf ( "rate limit" ) >= 0 ) {
@@ -93,8 +93,6 @@ function checkLogTag(blockTag: string): number | "latest" {
93
93
}
94
94
95
95
96
- const defaultApiKey = "9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB" ;
97
-
98
96
function checkError ( method : string , error : any , transaction : any ) : any {
99
97
// Undo the "convenience" some nodes are attempting to prevent backwards
100
98
// incompatibility; maybe for v6 consider forwarding reverts as errors
@@ -160,13 +158,13 @@ function checkError(method: string, error: any, transaction: any): any {
160
158
161
159
export class EtherscanProvider extends BaseProvider {
162
160
readonly baseUrl : string ;
163
- readonly apiKey : string ;
161
+ readonly apiKey : string | null ;
164
162
165
163
constructor ( network ?: Networkish , apiKey ?: string ) {
166
164
super ( network ) ;
167
165
168
166
defineReadOnly ( this , "baseUrl" , this . getBaseUrl ( ) ) ;
169
- defineReadOnly ( this , "apiKey" , apiKey || defaultApiKey ) ;
167
+ defineReadOnly ( this , "apiKey" , apiKey || null ) ;
170
168
}
171
169
172
170
getBaseUrl ( ) : string {
@@ -447,6 +445,6 @@ export class EtherscanProvider extends BaseProvider{
447
445
}
448
446
449
447
isCommunityResource ( ) : boolean {
450
- return ( this . apiKey === defaultApiKey ) ;
448
+ return ( this . apiKey == null ) ;
451
449
}
452
450
}
0 commit comments