9
9
PayloadInBatchException ,
10
10
} from "./exceptions" ;
11
11
import { RPCConfig } from "./types/common" ;
12
- import fetch from "cross-fetch" ;
12
+ import fetch_ from "cross-fetch" ;
13
13
import { AbortController as CrossAbortController } from "abort-controller" ;
14
14
15
15
export const ParamsFormatter = paramsFormatter ;
@@ -37,10 +37,11 @@ export class CKBRPC extends Base {
37
37
return this . #resultFormatter;
38
38
}
39
39
40
- constructor ( url : string , config : RPCConfig = { timeout : 30000 } ) {
40
+ constructor ( url : string , config : Partial < RPCConfig > = { } ) {
41
41
super ( ) ;
42
42
this . setNode ( { url } ) ;
43
- this . #config = config ;
43
+ const { timeout = 30000 , fetch = fetch_ } = config ;
44
+ this . #config = { timeout, fetch } ;
44
45
45
46
Object . defineProperties ( this , {
46
47
addMethod : {
@@ -59,7 +60,7 @@ export class CKBRPC extends Base {
59
60
} ) ;
60
61
61
62
Object . keys ( this . rpcProperties ) . forEach ( ( name ) => {
62
- this . addMethod ( { name, ...this . rpcProperties [ name ] } , config ) ;
63
+ this . addMethod ( { name, ...this . rpcProperties [ name ] } , this . # config) ;
63
64
} ) ;
64
65
}
65
66
@@ -141,12 +142,14 @@ export class CKBRPC extends Base {
141
142
ctx . #config. timeout
142
143
) ;
143
144
144
- const batchRes = await fetch ( ctx . #node. url , {
145
- method : "POST" ,
146
- headers : { "content-type" : "application/json" } ,
147
- body : JSON . stringify ( payload ) ,
148
- signal : signal ,
149
- } ) . then ( ( res ) => res . json ( ) ) ;
145
+ const batchRes = await ctx . #config
146
+ . fetch ( ctx . #node. url , {
147
+ method : "POST" ,
148
+ headers : { "content-type" : "application/json" } ,
149
+ body : JSON . stringify ( payload ) ,
150
+ signal : signal ,
151
+ } )
152
+ . then ( ( res ) => res . json ( ) ) ;
150
153
151
154
clearTimeout ( timeout ) ;
152
155
2 commit comments
github-actions[bot] commentedon Nov 27, 2023
🚀 New canary release:
0.0.0-canary-ce8eead-20231127085615
vercel[bot] commentedon Nov 27, 2023
Successfully deployed to the following URLs:
lumos-website – ./
lumos-website.vercel.app
lumos-website-git-develop-magickbase.vercel.app
lumos-website-magickbase.vercel.app