File tree 1 file changed +17
-1
lines changed
1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,11 @@ type Configuration = {
23
23
* Request timeout in milliseconds. Default: 5m
24
24
*/
25
25
timeout ?: number ;
26
+
27
+ /**
28
+ * Switches between existing backend and newer backend
29
+ */
30
+ backend ?: "v0" | "v1" ;
26
31
} ;
27
32
28
33
/**
@@ -33,11 +38,18 @@ export class Substrate {
33
38
baseUrl : string ;
34
39
apiVersion : string ;
35
40
timeout : number ;
41
+ backend : string ;
36
42
37
43
/**
38
44
* Initialize the Substrate SDK.
39
45
*/
40
- constructor ( { apiKey, baseUrl, apiVersion, timeout } : Configuration ) {
46
+ constructor ( {
47
+ apiKey,
48
+ baseUrl,
49
+ apiVersion,
50
+ timeout,
51
+ backend,
52
+ } : Configuration ) {
41
53
if ( ! apiKey ) {
42
54
throw new SubstrateError (
43
55
"An API Key is required. Specify it when constructing the Substrate client: `new Substrate({ apiKey: 'API_KEY' })`" ,
@@ -47,6 +59,7 @@ export class Substrate {
47
59
this . baseUrl = baseUrl ?? "https://api.substrate.run" ;
48
60
this . apiVersion = apiVersion ?? OpenAPIjson [ "info" ] [ "version" ] ;
49
61
this . timeout = timeout ?? 300000 ;
62
+ this . backend = backend ?? "v0" ;
50
63
}
51
64
52
65
/**
@@ -136,6 +149,9 @@ export class Substrate {
136
149
headers . append ( "X-Substrate-Runtime" , props . runtime ) ;
137
150
headers . append ( "X-Substrate-Runtime-Version" , props . runtimeVersion ) ;
138
151
152
+ // Switch between old and new backends
153
+ headers . append ( "X-Substrate-Backend" , this . backend ) ;
154
+
139
155
return headers ;
140
156
}
141
157
}
You can’t perform that action at this time.
0 commit comments