@pythnetwork/hermes-client 1.1.0 → 1.3.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/README.md +7 -4
- package/lib/HermesClient.d.ts +33 -5
- package/lib/HermesClient.d.ts.map +1 -1
- package/lib/HermesClient.js +41 -8
- package/lib/examples/HermesClient.js +8 -0
- package/lib/zodSchemas.d.ts +842 -12
- package/lib/zodSchemas.d.ts.map +1 -1
- package/lib/zodSchemas.js +84 -1
- package/package.json +9 -11
package/lib/zodSchemas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zodSchemas.d.ts","sourceRoot":"","sources":["../src/zodSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"zodSchemas.d.ts","sourceRoot":"","sources":["../src/zodSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA8ExB,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEvE"}
|
package/lib/zodSchemas.js
CHANGED
|
@@ -3,7 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createApiClient = exports.api = exports.schemas = void 0;
|
|
4
4
|
const core_1 = require("@zodios/core");
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
|
-
const AssetType = zod_1.z.enum([
|
|
6
|
+
const AssetType = zod_1.z.enum([
|
|
7
|
+
"crypto",
|
|
8
|
+
"fx",
|
|
9
|
+
"equity",
|
|
10
|
+
"metal",
|
|
11
|
+
"rates",
|
|
12
|
+
"crypto_redemption_rate",
|
|
13
|
+
]);
|
|
7
14
|
const asset_type = AssetType.nullish();
|
|
8
15
|
const RpcPriceIdentifier = zod_1.z.string();
|
|
9
16
|
const PriceFeedMetadata = zod_1.z
|
|
@@ -56,6 +63,21 @@ const LatestPublisherStakeCapsUpdateDataResponse = zod_1.z
|
|
|
56
63
|
parsed: zod_1.z.array(ParsedPublisherStakeCapsUpdate).nullish(),
|
|
57
64
|
})
|
|
58
65
|
.passthrough();
|
|
66
|
+
const ParsedPriceFeedTwap = zod_1.z
|
|
67
|
+
.object({
|
|
68
|
+
down_slots_ratio: zod_1.z.string(),
|
|
69
|
+
end_timestamp: zod_1.z.number().int(),
|
|
70
|
+
id: RpcPriceIdentifier,
|
|
71
|
+
start_timestamp: zod_1.z.number().int(),
|
|
72
|
+
twap: RpcPrice,
|
|
73
|
+
})
|
|
74
|
+
.passthrough();
|
|
75
|
+
const TwapsResponse = zod_1.z
|
|
76
|
+
.object({
|
|
77
|
+
binary: BinaryUpdate,
|
|
78
|
+
parsed: zod_1.z.array(ParsedPriceFeedTwap).nullish(),
|
|
79
|
+
})
|
|
80
|
+
.passthrough();
|
|
59
81
|
exports.schemas = {
|
|
60
82
|
AssetType,
|
|
61
83
|
asset_type,
|
|
@@ -71,6 +93,8 @@ exports.schemas = {
|
|
|
71
93
|
ParsedPublisherStakeCap,
|
|
72
94
|
ParsedPublisherStakeCapsUpdate,
|
|
73
95
|
LatestPublisherStakeCapsUpdateDataResponse,
|
|
96
|
+
ParsedPriceFeedTwap,
|
|
97
|
+
TwapsResponse,
|
|
74
98
|
};
|
|
75
99
|
const endpoints = (0, core_1.makeApi)([
|
|
76
100
|
{
|
|
@@ -125,6 +149,11 @@ Given a collection of price feed ids, retrieve the latest Pyth price for each pr
|
|
|
125
149
|
type: "Query",
|
|
126
150
|
schema: zod_1.z.boolean().optional(),
|
|
127
151
|
},
|
|
152
|
+
{
|
|
153
|
+
name: "ignore_invalid_price_ids",
|
|
154
|
+
type: "Query",
|
|
155
|
+
schema: zod_1.z.boolean().optional(),
|
|
156
|
+
},
|
|
128
157
|
],
|
|
129
158
|
response: PriceUpdate,
|
|
130
159
|
errors: [
|
|
@@ -159,6 +188,11 @@ Given a collection of price feed ids, retrieve the latest Pyth price for each pr
|
|
|
159
188
|
type: "Query",
|
|
160
189
|
schema: zod_1.z.boolean().optional(),
|
|
161
190
|
},
|
|
191
|
+
{
|
|
192
|
+
name: "ignore_invalid_price_ids",
|
|
193
|
+
type: "Query",
|
|
194
|
+
schema: zod_1.z.boolean().optional(),
|
|
195
|
+
},
|
|
162
196
|
],
|
|
163
197
|
response: PriceUpdate,
|
|
164
198
|
errors: [
|
|
@@ -201,6 +235,11 @@ Given a collection of price feed ids, retrieve the latest Pyth price for each pr
|
|
|
201
235
|
type: "Query",
|
|
202
236
|
schema: zod_1.z.boolean().optional(),
|
|
203
237
|
},
|
|
238
|
+
{
|
|
239
|
+
name: "ignore_invalid_price_ids",
|
|
240
|
+
type: "Query",
|
|
241
|
+
schema: zod_1.z.boolean().optional(),
|
|
242
|
+
},
|
|
204
243
|
],
|
|
205
244
|
response: PriceUpdate,
|
|
206
245
|
errors: [
|
|
@@ -231,6 +270,50 @@ Given a collection of price feed ids, retrieve the latest Pyth price for each pr
|
|
|
231
270
|
],
|
|
232
271
|
response: LatestPublisherStakeCapsUpdateDataResponse,
|
|
233
272
|
},
|
|
273
|
+
{
|
|
274
|
+
method: "get",
|
|
275
|
+
path: "/v2/updates/twap/:window_seconds/latest",
|
|
276
|
+
alias: "latest_twaps",
|
|
277
|
+
description: `Get the latest TWAP by price feed id with a custom time window.
|
|
278
|
+
|
|
279
|
+
Given a collection of price feed ids, retrieve the latest Pyth TWAP price for each price feed.`,
|
|
280
|
+
requestFormat: "json",
|
|
281
|
+
parameters: [
|
|
282
|
+
{
|
|
283
|
+
name: "window_seconds",
|
|
284
|
+
type: "Path",
|
|
285
|
+
schema: zod_1.z.number().int().gte(0),
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
name: "ids[]",
|
|
289
|
+
type: "Query",
|
|
290
|
+
schema: zod_1.z.array(PriceIdInput),
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
name: "encoding",
|
|
294
|
+
type: "Query",
|
|
295
|
+
schema: zod_1.z.enum(["hex", "base64"]).optional(),
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
name: "parsed",
|
|
299
|
+
type: "Query",
|
|
300
|
+
schema: zod_1.z.boolean().optional(),
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
name: "ignore_invalid_price_ids",
|
|
304
|
+
type: "Query",
|
|
305
|
+
schema: zod_1.z.boolean().optional(),
|
|
306
|
+
},
|
|
307
|
+
],
|
|
308
|
+
response: TwapsResponse,
|
|
309
|
+
errors: [
|
|
310
|
+
{
|
|
311
|
+
status: 404,
|
|
312
|
+
description: `Price ids not found`,
|
|
313
|
+
schema: zod_1.z.void(),
|
|
314
|
+
},
|
|
315
|
+
],
|
|
316
|
+
},
|
|
234
317
|
]);
|
|
235
318
|
exports.api = new core_1.Zodios(endpoints);
|
|
236
319
|
function createApiClient(baseUrl, options) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pythnetwork/hermes-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Pyth Hermes Client",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Pyth Data Association"
|
|
@@ -20,16 +20,14 @@
|
|
|
20
20
|
"access": "public"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"check-hermes-api-types": "git diff --exit-code src/zodSchemas.ts",
|
|
28
|
-
"example": "pnpm run build && node lib/examples/HermesClient.js",
|
|
23
|
+
"build:typescript": "tsc",
|
|
24
|
+
"build:schemas": "openapi-zod-client ./schema.json --output src/zodSchemas.ts",
|
|
25
|
+
"pull:schema": "curl -o schema.json -z schema.json https://hermes.pyth.network/docs/openapi.json",
|
|
26
|
+
"example": "node lib/examples/HermesClient.js",
|
|
29
27
|
"format": "prettier --write \"src/**/*.ts\"",
|
|
30
|
-
"lint": "eslint src/",
|
|
31
|
-
"prepublishOnly": "pnpm run build && pnpm
|
|
32
|
-
"preversion": "pnpm run lint",
|
|
28
|
+
"test:lint": "eslint src/",
|
|
29
|
+
"prepublishOnly": "pnpm run build:typescript && pnpm run test:lint",
|
|
30
|
+
"preversion": "pnpm run test:lint",
|
|
33
31
|
"version": "pnpm run format && git add -A src"
|
|
34
32
|
},
|
|
35
33
|
"keywords": [
|
|
@@ -57,5 +55,5 @@
|
|
|
57
55
|
"eventsource": "^2.0.2",
|
|
58
56
|
"zod": "^3.23.8"
|
|
59
57
|
},
|
|
60
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "512f6375bbedf78ff8e0d651c606701c0f7fb2ac"
|
|
61
59
|
}
|