@xchainjs/xchain-thornode 0.1.0-alpha3 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -80,25 +80,31 @@ const assertParamExists = function (functionName, paramName, paramValue) {
80
80
  throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
81
81
  }
82
82
  };
83
+ function setFlattenedQueryParams(urlSearchParams, parameter, key = "") {
84
+ if (typeof parameter === "object") {
85
+ if (Array.isArray(parameter)) {
86
+ parameter.forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
87
+ }
88
+ else {
89
+ Object.keys(parameter).forEach(currentKey => setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`));
90
+ }
91
+ }
92
+ else {
93
+ if (urlSearchParams.has(key)) {
94
+ urlSearchParams.append(key, parameter);
95
+ }
96
+ else {
97
+ urlSearchParams.set(key, parameter);
98
+ }
99
+ }
100
+ }
83
101
  /**
84
102
  *
85
103
  * @export
86
104
  */
87
105
  const setSearchParams = function (url, ...objects) {
88
106
  const searchParams = new URLSearchParams(url.search);
89
- for (const object of objects) {
90
- for (const key in object) {
91
- if (Array.isArray(object[key])) {
92
- searchParams.delete(key);
93
- for (const item of object[key]) {
94
- searchParams.append(key, item);
95
- }
96
- }
97
- else {
98
- searchParams.set(key, object[key]);
99
- }
100
- }
101
- }
107
+ setFlattenedQueryParams(searchParams, objects);
102
108
  url.search = searchParams.toString();
103
109
  };
104
110
  /**
@@ -134,6 +140,165 @@ const VaultTypeEnum = {
134
140
  AsgardVault: 'AsgardVault',
135
141
  YggdrasilVault: 'YggdrasilVault'
136
142
  };
143
+ /**
144
+ * BucketsApi - axios parameter creator
145
+ * @export
146
+ */
147
+ const BucketsApiAxiosParamCreator = function (configuration) {
148
+ return {
149
+ /**
150
+ * Returns the bucket information for the provided asset.
151
+ * @param {string} asset
152
+ * @param {number} [height] optional block height, defaults to current tip
153
+ * @param {*} [options] Override http request option.
154
+ * @throws {RequiredError}
155
+ */
156
+ bucket: (asset, height, options = {}) => __awaiter(this, void 0, void 0, function* () {
157
+ // verify required parameter 'asset' is not null or undefined
158
+ assertParamExists('bucket', 'asset', asset);
159
+ const localVarPath = `/thorchain/bucket/{asset}`
160
+ .replace(`{${"asset"}}`, encodeURIComponent(String(asset)));
161
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
162
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
163
+ let baseOptions;
164
+ if (configuration) {
165
+ baseOptions = configuration.baseOptions;
166
+ }
167
+ const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
168
+ const localVarHeaderParameter = {};
169
+ const localVarQueryParameter = {};
170
+ if (height !== undefined) {
171
+ localVarQueryParameter['height'] = height;
172
+ }
173
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
174
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
175
+ localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
176
+ return {
177
+ url: toPathString(localVarUrlObj),
178
+ options: localVarRequestOptions,
179
+ };
180
+ }),
181
+ /**
182
+ * Returns the bucket information for all assets.
183
+ * @param {number} [height] optional block height, defaults to current tip
184
+ * @param {*} [options] Override http request option.
185
+ * @throws {RequiredError}
186
+ */
187
+ buckets: (height, options = {}) => __awaiter(this, void 0, void 0, function* () {
188
+ const localVarPath = `/thorchain/buckets`;
189
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
190
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
191
+ let baseOptions;
192
+ if (configuration) {
193
+ baseOptions = configuration.baseOptions;
194
+ }
195
+ const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
196
+ const localVarHeaderParameter = {};
197
+ const localVarQueryParameter = {};
198
+ if (height !== undefined) {
199
+ localVarQueryParameter['height'] = height;
200
+ }
201
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
202
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
203
+ localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
204
+ return {
205
+ url: toPathString(localVarUrlObj),
206
+ options: localVarRequestOptions,
207
+ };
208
+ }),
209
+ };
210
+ };
211
+ /**
212
+ * BucketsApi - functional programming interface
213
+ * @export
214
+ */
215
+ const BucketsApiFp = function (configuration) {
216
+ const localVarAxiosParamCreator = BucketsApiAxiosParamCreator(configuration);
217
+ return {
218
+ /**
219
+ * Returns the bucket information for the provided asset.
220
+ * @param {string} asset
221
+ * @param {number} [height] optional block height, defaults to current tip
222
+ * @param {*} [options] Override http request option.
223
+ * @throws {RequiredError}
224
+ */
225
+ bucket(asset, height, options) {
226
+ return __awaiter(this, void 0, void 0, function* () {
227
+ const localVarAxiosArgs = yield localVarAxiosParamCreator.bucket(asset, height, options);
228
+ return createRequestFunction(localVarAxiosArgs, globalAxios__default['default'], BASE_PATH, configuration);
229
+ });
230
+ },
231
+ /**
232
+ * Returns the bucket information for all assets.
233
+ * @param {number} [height] optional block height, defaults to current tip
234
+ * @param {*} [options] Override http request option.
235
+ * @throws {RequiredError}
236
+ */
237
+ buckets(height, options) {
238
+ return __awaiter(this, void 0, void 0, function* () {
239
+ const localVarAxiosArgs = yield localVarAxiosParamCreator.buckets(height, options);
240
+ return createRequestFunction(localVarAxiosArgs, globalAxios__default['default'], BASE_PATH, configuration);
241
+ });
242
+ },
243
+ };
244
+ };
245
+ /**
246
+ * BucketsApi - factory interface
247
+ * @export
248
+ */
249
+ const BucketsApiFactory = function (configuration, basePath, axios) {
250
+ const localVarFp = BucketsApiFp(configuration);
251
+ return {
252
+ /**
253
+ * Returns the bucket information for the provided asset.
254
+ * @param {string} asset
255
+ * @param {number} [height] optional block height, defaults to current tip
256
+ * @param {*} [options] Override http request option.
257
+ * @throws {RequiredError}
258
+ */
259
+ bucket(asset, height, options) {
260
+ return localVarFp.bucket(asset, height, options).then((request) => request(axios, basePath));
261
+ },
262
+ /**
263
+ * Returns the bucket information for all assets.
264
+ * @param {number} [height] optional block height, defaults to current tip
265
+ * @param {*} [options] Override http request option.
266
+ * @throws {RequiredError}
267
+ */
268
+ buckets(height, options) {
269
+ return localVarFp.buckets(height, options).then((request) => request(axios, basePath));
270
+ },
271
+ };
272
+ };
273
+ /**
274
+ * BucketsApi - object-oriented interface
275
+ * @export
276
+ * @class BucketsApi
277
+ * @extends {BaseAPI}
278
+ */
279
+ class BucketsApi extends BaseAPI {
280
+ /**
281
+ * Returns the bucket information for the provided asset.
282
+ * @param {string} asset
283
+ * @param {number} [height] optional block height, defaults to current tip
284
+ * @param {*} [options] Override http request option.
285
+ * @throws {RequiredError}
286
+ * @memberof BucketsApi
287
+ */
288
+ bucket(asset, height, options) {
289
+ return BucketsApiFp(this.configuration).bucket(asset, height, options).then((request) => request(this.axios, this.basePath));
290
+ }
291
+ /**
292
+ * Returns the bucket information for all assets.
293
+ * @param {number} [height] optional block height, defaults to current tip
294
+ * @param {*} [options] Override http request option.
295
+ * @throws {RequiredError}
296
+ * @memberof BucketsApi
297
+ */
298
+ buckets(height, options) {
299
+ return BucketsApiFp(this.configuration).buckets(height, options).then((request) => request(this.axios, this.basePath));
300
+ }
301
+ }
137
302
  /**
138
303
  * HealthApi - axios parameter creator
139
304
  * @export
@@ -1415,6 +1580,99 @@ class NodesApi extends BaseAPI {
1415
1580
  return NodesApiFp(this.configuration).nodes(height, options).then((request) => request(this.axios, this.basePath));
1416
1581
  }
1417
1582
  }
1583
+ /**
1584
+ * POLApi - axios parameter creator
1585
+ * @export
1586
+ */
1587
+ const POLApiAxiosParamCreator = function (configuration) {
1588
+ return {
1589
+ /**
1590
+ * Returns protocol owned liquidity overview statistics.
1591
+ * @param {number} [height] optional block height, defaults to current tip
1592
+ * @param {*} [options] Override http request option.
1593
+ * @throws {RequiredError}
1594
+ */
1595
+ pol: (height, options = {}) => __awaiter(this, void 0, void 0, function* () {
1596
+ const localVarPath = `/thorchain/pol`;
1597
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
1598
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1599
+ let baseOptions;
1600
+ if (configuration) {
1601
+ baseOptions = configuration.baseOptions;
1602
+ }
1603
+ const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
1604
+ const localVarHeaderParameter = {};
1605
+ const localVarQueryParameter = {};
1606
+ if (height !== undefined) {
1607
+ localVarQueryParameter['height'] = height;
1608
+ }
1609
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
1610
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1611
+ localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
1612
+ return {
1613
+ url: toPathString(localVarUrlObj),
1614
+ options: localVarRequestOptions,
1615
+ };
1616
+ }),
1617
+ };
1618
+ };
1619
+ /**
1620
+ * POLApi - functional programming interface
1621
+ * @export
1622
+ */
1623
+ const POLApiFp = function (configuration) {
1624
+ const localVarAxiosParamCreator = POLApiAxiosParamCreator(configuration);
1625
+ return {
1626
+ /**
1627
+ * Returns protocol owned liquidity overview statistics.
1628
+ * @param {number} [height] optional block height, defaults to current tip
1629
+ * @param {*} [options] Override http request option.
1630
+ * @throws {RequiredError}
1631
+ */
1632
+ pol(height, options) {
1633
+ return __awaiter(this, void 0, void 0, function* () {
1634
+ const localVarAxiosArgs = yield localVarAxiosParamCreator.pol(height, options);
1635
+ return createRequestFunction(localVarAxiosArgs, globalAxios__default['default'], BASE_PATH, configuration);
1636
+ });
1637
+ },
1638
+ };
1639
+ };
1640
+ /**
1641
+ * POLApi - factory interface
1642
+ * @export
1643
+ */
1644
+ const POLApiFactory = function (configuration, basePath, axios) {
1645
+ const localVarFp = POLApiFp(configuration);
1646
+ return {
1647
+ /**
1648
+ * Returns protocol owned liquidity overview statistics.
1649
+ * @param {number} [height] optional block height, defaults to current tip
1650
+ * @param {*} [options] Override http request option.
1651
+ * @throws {RequiredError}
1652
+ */
1653
+ pol(height, options) {
1654
+ return localVarFp.pol(height, options).then((request) => request(axios, basePath));
1655
+ },
1656
+ };
1657
+ };
1658
+ /**
1659
+ * POLApi - object-oriented interface
1660
+ * @export
1661
+ * @class POLApi
1662
+ * @extends {BaseAPI}
1663
+ */
1664
+ class POLApi extends BaseAPI {
1665
+ /**
1666
+ * Returns protocol owned liquidity overview statistics.
1667
+ * @param {number} [height] optional block height, defaults to current tip
1668
+ * @param {*} [options] Override http request option.
1669
+ * @throws {RequiredError}
1670
+ * @memberof POLApi
1671
+ */
1672
+ pol(height, options) {
1673
+ return POLApiFp(this.configuration).pol(height, options).then((request) => request(this.axios, this.basePath));
1674
+ }
1675
+ }
1418
1676
  /**
1419
1677
  * PoolsApi - axios parameter creator
1420
1678
  * @export
@@ -2619,7 +2877,7 @@ class VaultsApi extends BaseAPI {
2619
2877
  * Thornode API
2620
2878
  * Thornode REST API.
2621
2879
  *
2622
- * The version of the OpenAPI document: 1.89.0
2880
+ * The version of the OpenAPI document: 1.97.2
2623
2881
  * Contact: devs@thorchain.org
2624
2882
  *
2625
2883
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -2654,6 +2912,10 @@ class Configuration {
2654
2912
 
2655
2913
  const THORNODE_API_9R_URL = 'https://thornode.ninerealms.com/';
2656
2914
 
2915
+ exports.BucketsApi = BucketsApi;
2916
+ exports.BucketsApiAxiosParamCreator = BucketsApiAxiosParamCreator;
2917
+ exports.BucketsApiFactory = BucketsApiFactory;
2918
+ exports.BucketsApiFp = BucketsApiFp;
2657
2919
  exports.Configuration = Configuration;
2658
2920
  exports.HealthApi = HealthApi;
2659
2921
  exports.HealthApiAxiosParamCreator = HealthApiAxiosParamCreator;
@@ -2677,6 +2939,10 @@ exports.NodesApiAxiosParamCreator = NodesApiAxiosParamCreator;
2677
2939
  exports.NodesApiFactory = NodesApiFactory;
2678
2940
  exports.NodesApiFp = NodesApiFp;
2679
2941
  exports.ObservedTxStatusEnum = ObservedTxStatusEnum;
2942
+ exports.POLApi = POLApi;
2943
+ exports.POLApiAxiosParamCreator = POLApiAxiosParamCreator;
2944
+ exports.POLApiFactory = POLApiFactory;
2945
+ exports.POLApiFp = POLApiFp;
2680
2946
  exports.PoolsApi = PoolsApi;
2681
2947
  exports.PoolsApiAxiosParamCreator = PoolsApiAxiosParamCreator;
2682
2948
  exports.PoolsApiFactory = PoolsApiFactory;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-thornode",
3
- "version": "0.1.0-alpha3",
3
+ "version": "0.1.0",
4
4
  "license": "MIT",
5
5
  "description": "Thornode module that exposes all thornode functions using openapi-generator-cli",
6
6
  "keywords": [
@@ -29,14 +29,11 @@
29
29
  "lint": "eslint \"{src,__tests__}/**/*.ts\" --fix --max-warnings 0",
30
30
  "prepublishOnly": "yarn run build",
31
31
  "test": "jest --passWithNoTests",
32
- "generate:types": "yarn clean:types:thornode && yarn generate:types:convertToJson && yarn generate:types:thornode && yarn clean:types:tempFiles",
33
- "generate:types:convertToJson": "curl 'https://gitlab.com/thorchain/thornode/-/raw/357456ea9e71cb2e846157b169bb5581b4075d0f/openapi/openapi.yaml' > ./input.yaml && yaml2json ./input.yaml --pretty > ./input.json",
34
- "generate:types:thornode": "TS_POST_PROCESS_FILE=./node_modules/.bin/prettier openapi-generator-cli generate -i ./input.json -g typescript-axios -o ./src/generated/thornodeApi --reserved-words-mappings in=in",
35
- "clean:types:tempFiles": "rimraf ./input.yaml ./input.json",
32
+ "generate:types": "yarn clean:types:thornode && yarn generate:types:thornode",
33
+ "generate:types:thornode": "TS_POST_PROCESS_FILE=./node_modules/.bin/prettier openapi-generator-cli generate -i https://gitlab.com/thorchain/thornode/-/raw/release-1.97.2/openapi/openapi.yaml -g typescript-axios -o ./src/generated/thornodeApi --skip-validate-spec --generate-alias-as-model",
36
34
  "clean:types:thornode": "rimraf ./src/generated/thornodeApi"
37
35
  },
38
36
  "devDependencies": {
39
- "yamljs": "^0.3.0",
40
37
  "@openapitools/openapi-generator-cli": "^2.5.1",
41
38
  "rimraf": "~3.0.2"
42
39
  },