@pythnetwork/pyth-sui-js 1.2.1 → 1.2.3
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/client.d.ts +5 -2
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +10 -8
- package/package.json +2 -2
package/lib/client.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare class SuiPythClient {
|
|
|
8
8
|
wormholeStateId: ObjectId;
|
|
9
9
|
private pythPackageId;
|
|
10
10
|
private wormholePackageId;
|
|
11
|
-
private
|
|
11
|
+
private priceTableInfo;
|
|
12
12
|
private priceFeedObjectIdCache;
|
|
13
13
|
private baseUpdateFee;
|
|
14
14
|
constructor(provider: JsonRpcProvider, pythStateId: ObjectId, wormholeStateId: ObjectId);
|
|
@@ -65,7 +65,10 @@ export declare class SuiPythClient {
|
|
|
65
65
|
* Fetches the price table object id for the current state id if not cached
|
|
66
66
|
* @returns price table object id
|
|
67
67
|
*/
|
|
68
|
-
|
|
68
|
+
getPriceTableInfo(): Promise<{
|
|
69
|
+
id: ObjectId;
|
|
70
|
+
fieldType: ObjectId;
|
|
71
|
+
}>;
|
|
69
72
|
/**
|
|
70
73
|
* Checks if a message is an accumulator message or not
|
|
71
74
|
* @param msg - update message from price service
|
package/lib/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";AAAA,OAAO,EAEL,eAAe,EACf,QAAQ,EAER,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,qBAAa,aAAa;IAOf,QAAQ,EAAE,eAAe;IACzB,WAAW,EAAE,QAAQ;IACrB,eAAe,EAAE,QAAQ;IARlC,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO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,SAAS,CAAC;IA2B5E;;;OAGG;IACG,iBAAiB,IAAI,OAAO,CAAC;QAAE,EAAE,EAAE,QAAQ,CAAC;QAAC,SAAS,EAAE,QAAQ,CAAA;KAAE,CAAC;IAwBzE;;;OAGG;IACH,gBAAgB,CAAC,GAAG,EAAE,MAAM;IAK5B;;;;OAIG;IACH,qCAAqC,CAAC,kBAAkB,EAAE,MAAM,GAAG,MAAM;CAe1E"}
|
package/lib/client.js
CHANGED
|
@@ -10,7 +10,7 @@ class SuiPythClient {
|
|
|
10
10
|
wormholeStateId;
|
|
11
11
|
pythPackageId;
|
|
12
12
|
wormholePackageId;
|
|
13
|
-
|
|
13
|
+
priceTableInfo;
|
|
14
14
|
priceFeedObjectIdCache = new Map();
|
|
15
15
|
baseUpdateFee;
|
|
16
16
|
constructor(provider, pythStateId, wormholeStateId) {
|
|
@@ -226,11 +226,11 @@ class SuiPythClient {
|
|
|
226
226
|
async getPriceFeedObjectId(feedId) {
|
|
227
227
|
const normalizedFeedId = feedId.replace("0x", "");
|
|
228
228
|
if (!this.priceFeedObjectIdCache.has(normalizedFeedId)) {
|
|
229
|
-
const tableId = await this.
|
|
229
|
+
const { id: tableId, fieldType } = await this.getPriceTableInfo();
|
|
230
230
|
const result = await this.provider.getDynamicFieldObject({
|
|
231
231
|
parentId: tableId,
|
|
232
232
|
name: {
|
|
233
|
-
type: `${
|
|
233
|
+
type: `${fieldType}::price_identifier::PriceIdentifier`,
|
|
234
234
|
value: {
|
|
235
235
|
bytes: Array.from(buffer_1.Buffer.from(normalizedFeedId, "hex")),
|
|
236
236
|
},
|
|
@@ -250,8 +250,8 @@ class SuiPythClient {
|
|
|
250
250
|
* Fetches the price table object id for the current state id if not cached
|
|
251
251
|
* @returns price table object id
|
|
252
252
|
*/
|
|
253
|
-
async
|
|
254
|
-
if (this.
|
|
253
|
+
async getPriceTableInfo() {
|
|
254
|
+
if (this.priceTableInfo === undefined) {
|
|
255
255
|
const result = await this.provider.getDynamicFieldObject({
|
|
256
256
|
parentId: this.pythStateId,
|
|
257
257
|
name: {
|
|
@@ -259,12 +259,14 @@ class SuiPythClient {
|
|
|
259
259
|
value: "price_info",
|
|
260
260
|
},
|
|
261
261
|
});
|
|
262
|
-
if (!result.data) {
|
|
262
|
+
if (!result.data || !result.data.type) {
|
|
263
263
|
throw new Error("Price Table not found, contract may not be initialized");
|
|
264
264
|
}
|
|
265
|
-
|
|
265
|
+
let type = result.data.type.replace("0x2::table::Table<", "");
|
|
266
|
+
type = type.replace("::price_identifier::PriceIdentifier, 0x2::object::ID>", "");
|
|
267
|
+
this.priceTableInfo = { id: result.data.objectId, fieldType: type };
|
|
266
268
|
}
|
|
267
|
-
return this.
|
|
269
|
+
return this.priceTableInfo;
|
|
268
270
|
}
|
|
269
271
|
/**
|
|
270
272
|
* Checks if a message is an accumulator message or not
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pythnetwork/pyth-sui-js",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Pyth Network Sui Utilities",
|
|
5
5
|
"homepage": "https://pyth.network",
|
|
6
6
|
"author": {
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"@pythnetwork/price-service-client": "*",
|
|
58
58
|
"buffer": "^6.0.3"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "2b51cffdc7e782995e7c267d2fc3b0a8a24e1c60"
|
|
61
61
|
}
|