File tree Expand file tree Collapse file tree
packages/providers/src.ts Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ "use strict"
2+
3+ import {
4+ UrlJsonRpcProvider ,
5+ showThrottleMessage ,
6+ } from "@ethersproject/providers"
7+
8+ import { Logger } from "@ethersproject/logger"
9+ const logger = new Logger ( "providers/5.5.1" )
10+
11+ const defaultApiKey = "3439|6806e8faf10643e2bde903920bbcb1ff"
12+
13+ export class SpiceProvider extends UrlJsonRpcProvider {
14+ static getApiKey ( apiKey ) {
15+ if ( apiKey == null ) {
16+ return defaultApiKey
17+ }
18+ if ( apiKey && typeof apiKey !== "string" ) {
19+ logger . throwArgumentError ( "invalid apiKey" , "apiKey" , apiKey )
20+ }
21+ return apiKey
22+ }
23+
24+ static getUrl ( network , apiKey ) {
25+ const host = "https://data.spiceai.io"
26+ let path = null
27+ switch ( network . name ) {
28+ case "homestead" :
29+ path = "/eth"
30+ break
31+ default :
32+ logger . throwArgumentError (
33+ "unsupported network" ,
34+ "network" ,
35+ arguments [ 0 ]
36+ )
37+ }
38+
39+ return {
40+ allowGzip : true ,
41+ url : host + path ,
42+ throttleCallback : ( attempt , url ) => {
43+ if ( apiKey === defaultApiKey ) {
44+ showThrottleMessage ( )
45+ }
46+ return Promise . resolve ( true )
47+ } ,
48+ }
49+ }
50+
51+ isCommunityResource ( ) {
52+ return this . apiKey === defaultApiKey
53+ }
54+ }
You can’t perform that action at this time.
0 commit comments