@pythnetwork/pyth-sui-js 1.2.5 → 2.0.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/client.d.ts +14 -16
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +65 -81
- package/lib/examples/SuiRelay.d.ts +2 -2
- package/lib/examples/SuiRelay.d.ts.map +1 -1
- package/lib/examples/SuiRelay.js +33 -11
- package/package.json +4 -4
package/lib/client.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
2
|
+
import { SuiClient } from "@mysten/sui.js/client";
|
|
3
|
+
import { TransactionBlock } from "@mysten/sui.js/transactions";
|
|
3
4
|
import { HexString } from "@pythnetwork/price-service-client";
|
|
4
5
|
import { Buffer } from "buffer";
|
|
6
|
+
export type ObjectId = string;
|
|
5
7
|
export declare class SuiPythClient {
|
|
6
|
-
provider:
|
|
8
|
+
provider: SuiClient;
|
|
7
9
|
pythStateId: ObjectId;
|
|
8
10
|
wormholeStateId: ObjectId;
|
|
9
11
|
private pythPackageId;
|
|
@@ -11,7 +13,7 @@ export declare class SuiPythClient {
|
|
|
11
13
|
private priceTableInfo;
|
|
12
14
|
private priceFeedObjectIdCache;
|
|
13
15
|
private baseUpdateFee;
|
|
14
|
-
constructor(provider:
|
|
16
|
+
constructor(provider: SuiClient, pythStateId: ObjectId, wormholeStateId: ObjectId);
|
|
15
17
|
getBaseUpdateFee(): Promise<number>;
|
|
16
18
|
/**
|
|
17
19
|
* getPackageId returns the latest package id that the object belongs to. Use this to
|
|
@@ -25,21 +27,11 @@ export declare class SuiPythClient {
|
|
|
25
27
|
* @param vaas array of vaas to verify
|
|
26
28
|
* @param tx transaction block to add commands to
|
|
27
29
|
*/
|
|
28
|
-
verifyVaas(vaas: Buffer[], tx: TransactionBlock): Promise<
|
|
29
|
-
kind: "Input";
|
|
30
|
-
index: number;
|
|
31
|
-
type?: "object" | "pure" | undefined;
|
|
32
|
-
value?: any;
|
|
33
|
-
} | {
|
|
34
|
-
kind: "GasCoin";
|
|
35
|
-
} | {
|
|
36
|
-
kind: "Result";
|
|
37
|
-
index: number;
|
|
38
|
-
} | {
|
|
39
|
-
kind: "NestedResult";
|
|
30
|
+
verifyVaas(vaas: Buffer[], tx: TransactionBlock): Promise<{
|
|
40
31
|
index: number;
|
|
41
32
|
resultIndex: number;
|
|
42
|
-
|
|
33
|
+
kind: "NestedResult";
|
|
34
|
+
}[]>;
|
|
43
35
|
/**
|
|
44
36
|
* Adds the necessary commands for updating the pyth price feeds to the transaction block.
|
|
45
37
|
* @param tx transaction block to add commands to
|
|
@@ -69,5 +61,11 @@ export declare class SuiPythClient {
|
|
|
69
61
|
id: ObjectId;
|
|
70
62
|
fieldType: ObjectId;
|
|
71
63
|
}>;
|
|
64
|
+
/**
|
|
65
|
+
* Obtains the vaa bytes embedded in an accumulator message.
|
|
66
|
+
* @param accumulatorMessage - the accumulator price update message
|
|
67
|
+
* @returns vaa bytes as a uint8 array
|
|
68
|
+
*/
|
|
69
|
+
extractVaaBytesFromAccumulatorMessage(accumulatorMessage: Buffer): Buffer;
|
|
72
70
|
}
|
|
73
71
|
//# sourceMappingURL=client.d.ts.map
|
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,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B,qBAAa,aAAa;IAOf,QAAQ,EAAE,SAAS;IACnB,WAAW,EAAE,QAAQ;IACrB,eAAe,EAAE,QAAQ;IARlC,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,iBAAiB,CAAuB;IAChD,OAAO,CAAC,cAAc,CAAoD;IAC1E,OAAO,CAAC,sBAAsB,CAAuC;IACrE,OAAO,CAAC,aAAa,CAAqB;gBAEjC,QAAQ,EAAE,SAAS,EACnB,WAAW,EAAE,QAAQ,EACrB,eAAe,EAAE,QAAQ;IAM5B,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;IAoBzC;;;;;OAKG;IACG,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IA0BzD;;;;OAIG;IACG,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,gBAAgB;;;;;IAuBrD;;;;;OAKG;IACG,gBAAgB,CACpB,EAAE,EAAE,gBAAgB,EACpB,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE,SAAS,EAAE,GACnB,OAAO,CAAC,QAAQ,EAAE,CAAC;IA6DhB,eAAe,CAAC,EAAE,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,EAAE;IA0B7D;;OAEG;IACG,oBAAoB;IAO1B;;OAEG;IACG,gBAAgB;IAOtB;;;OAGG;IACG,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC;IA6B5E;;;OAGG;IACG,iBAAiB,IAAI,OAAO,CAAC;QAAE,EAAE,EAAE,QAAQ,CAAC;QAAC,SAAS,EAAE,QAAQ,CAAA;KAAE,CAAC;IAwBzE;;;;OAIG;IACH,qCAAqC,CAAC,kBAAkB,EAAE,MAAM,GAAG,MAAM;CAY1E"}
|
package/lib/client.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SuiPythClient = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const utils_1 = require("@mysten/sui.js/utils");
|
|
5
|
+
const bcs_1 = require("@mysten/sui.js/bcs");
|
|
6
6
|
const buffer_1 = require("buffer");
|
|
7
7
|
const MAX_ARGUMENT_SIZE = 16 * 1024;
|
|
8
8
|
class SuiPythClient {
|
|
@@ -31,6 +31,8 @@ class SuiPythClient {
|
|
|
31
31
|
!result.data.content ||
|
|
32
32
|
result.data.content.dataType !== "moveObject")
|
|
33
33
|
throw new Error("Unable to fetch pyth state object");
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
35
|
+
// @ts-ignore
|
|
34
36
|
this.baseUpdateFee = result.data.content.fields.base_update_fee;
|
|
35
37
|
}
|
|
36
38
|
return this.baseUpdateFee;
|
|
@@ -53,9 +55,12 @@ class SuiPythClient {
|
|
|
53
55
|
if (result.data?.content?.dataType == "moveObject") {
|
|
54
56
|
return result.data.content.fields;
|
|
55
57
|
}
|
|
56
|
-
|
|
58
|
+
console.log(result.data?.content);
|
|
59
|
+
throw new Error(`Cannot fetch package id for object ${objectId}`);
|
|
57
60
|
});
|
|
58
61
|
if ("upgrade_cap" in state) {
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
63
|
+
// @ts-ignore
|
|
59
64
|
return state.upgrade_cap.fields.package;
|
|
60
65
|
}
|
|
61
66
|
throw new Error("upgrade_cap not found");
|
|
@@ -73,12 +78,12 @@ class SuiPythClient {
|
|
|
73
78
|
target: `${wormholePackageId}::vaa::parse_and_verify`,
|
|
74
79
|
arguments: [
|
|
75
80
|
tx.object(this.wormholeStateId),
|
|
76
|
-
tx.pure(
|
|
81
|
+
tx.pure(bcs_1.bcs
|
|
77
82
|
.ser("vector<u8>", Array.from(vaa), {
|
|
78
83
|
maxSize: MAX_ARGUMENT_SIZE,
|
|
79
84
|
})
|
|
80
85
|
.toBytes()),
|
|
81
|
-
tx.object(
|
|
86
|
+
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
82
87
|
],
|
|
83
88
|
});
|
|
84
89
|
verifiedVaas.push(verifiedVaa);
|
|
@@ -92,46 +97,26 @@ class SuiPythClient {
|
|
|
92
97
|
* @param feedIds array of feed ids to update (in hex format)
|
|
93
98
|
*/
|
|
94
99
|
async updatePriceFeeds(tx, updates, feedIds) {
|
|
95
|
-
const wormholePackageId = await this.getWormholePackageId();
|
|
96
100
|
const packageId = await this.getPythPackageId();
|
|
97
101
|
let priceUpdatesHotPotato;
|
|
98
|
-
if (updates.
|
|
99
|
-
|
|
100
|
-
throw new Error("SDK does not support sending multiple accumulator messages in a single transaction");
|
|
101
|
-
}
|
|
102
|
-
const vaa = (0, price_service_client_1.parseAccumulatorUpdateData)(updates[0]).vaa;
|
|
103
|
-
const verifiedVaas = await this.verifyVaas([vaa], tx);
|
|
104
|
-
[priceUpdatesHotPotato] = tx.moveCall({
|
|
105
|
-
target: `${packageId}::pyth::create_authenticated_price_infos_using_accumulator`,
|
|
106
|
-
arguments: [
|
|
107
|
-
tx.object(this.pythStateId),
|
|
108
|
-
tx.pure(sui_js_1.builder
|
|
109
|
-
.ser("vector<u8>", Array.from(updates[0]), {
|
|
110
|
-
maxSize: MAX_ARGUMENT_SIZE,
|
|
111
|
-
})
|
|
112
|
-
.toBytes()),
|
|
113
|
-
verifiedVaas[0],
|
|
114
|
-
tx.object(sui_js_1.SUI_CLOCK_OBJECT_ID),
|
|
115
|
-
],
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
else if (updates.every((vaa) => !(0, price_service_client_1.isAccumulatorUpdateData)(vaa))) {
|
|
119
|
-
const verifiedVaas = await this.verifyVaas(updates, tx);
|
|
120
|
-
[priceUpdatesHotPotato] = tx.moveCall({
|
|
121
|
-
target: `${packageId}::pyth::create_price_infos_hot_potato`,
|
|
122
|
-
arguments: [
|
|
123
|
-
tx.object(this.pythStateId),
|
|
124
|
-
tx.makeMoveVec({
|
|
125
|
-
type: `${wormholePackageId}::vaa::VAA`,
|
|
126
|
-
objects: verifiedVaas,
|
|
127
|
-
}),
|
|
128
|
-
tx.object(sui_js_1.SUI_CLOCK_OBJECT_ID),
|
|
129
|
-
],
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
throw new Error("Can't mix accumulator and non-accumulator messages");
|
|
102
|
+
if (updates.length > 1) {
|
|
103
|
+
throw new Error("SDK does not support sending multiple accumulator messages in a single transaction");
|
|
134
104
|
}
|
|
105
|
+
const vaa = this.extractVaaBytesFromAccumulatorMessage(updates[0]);
|
|
106
|
+
const verifiedVaas = await this.verifyVaas([vaa], tx);
|
|
107
|
+
[priceUpdatesHotPotato] = tx.moveCall({
|
|
108
|
+
target: `${packageId}::pyth::create_authenticated_price_infos_using_accumulator`,
|
|
109
|
+
arguments: [
|
|
110
|
+
tx.object(this.pythStateId),
|
|
111
|
+
tx.pure(bcs_1.bcs
|
|
112
|
+
.ser("vector<u8>", Array.from(updates[0]), {
|
|
113
|
+
maxSize: MAX_ARGUMENT_SIZE,
|
|
114
|
+
})
|
|
115
|
+
.toBytes()),
|
|
116
|
+
verifiedVaas[0],
|
|
117
|
+
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
118
|
+
],
|
|
119
|
+
});
|
|
135
120
|
const priceInfoObjects = [];
|
|
136
121
|
const baseUpdateFee = await this.getBaseUpdateFee();
|
|
137
122
|
const coins = tx.splitCoins(tx.gas, feedIds.map(() => tx.pure(baseUpdateFee)));
|
|
@@ -149,7 +134,7 @@ class SuiPythClient {
|
|
|
149
134
|
priceUpdatesHotPotato,
|
|
150
135
|
tx.object(priceInfoObjectId),
|
|
151
136
|
coins[coinId],
|
|
152
|
-
tx.object(
|
|
137
|
+
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
153
138
|
],
|
|
154
139
|
});
|
|
155
140
|
coinId++;
|
|
@@ -162,45 +147,25 @@ class SuiPythClient {
|
|
|
162
147
|
return priceInfoObjects;
|
|
163
148
|
}
|
|
164
149
|
async createPriceFeed(tx, updates) {
|
|
165
|
-
const wormholePackageId = await this.getWormholePackageId();
|
|
166
150
|
const packageId = await this.getPythPackageId();
|
|
167
|
-
if (updates.
|
|
168
|
-
|
|
169
|
-
throw new Error("SDK does not support sending multiple accumulator messages in a single transaction");
|
|
170
|
-
}
|
|
171
|
-
const vaa = (0, price_service_client_1.parseAccumulatorUpdateData)(updates[0]).vaa;
|
|
172
|
-
const verifiedVaas = await this.verifyVaas([vaa], tx);
|
|
173
|
-
tx.moveCall({
|
|
174
|
-
target: `${packageId}::pyth::create_price_feeds_using_accumulator`,
|
|
175
|
-
arguments: [
|
|
176
|
-
tx.object(this.pythStateId),
|
|
177
|
-
tx.pure(sui_js_1.builder
|
|
178
|
-
.ser("vector<u8>", Array.from(updates[0]), {
|
|
179
|
-
maxSize: MAX_ARGUMENT_SIZE,
|
|
180
|
-
})
|
|
181
|
-
.toBytes()),
|
|
182
|
-
verifiedVaas[0],
|
|
183
|
-
tx.object(sui_js_1.SUI_CLOCK_OBJECT_ID),
|
|
184
|
-
],
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
else if (updates.every((vaa) => !(0, price_service_client_1.isAccumulatorUpdateData)(vaa))) {
|
|
188
|
-
const verifiedVaas = await this.verifyVaas(updates, tx);
|
|
189
|
-
tx.moveCall({
|
|
190
|
-
target: `${packageId}::pyth::create_price_feeds`,
|
|
191
|
-
arguments: [
|
|
192
|
-
tx.object(this.pythStateId),
|
|
193
|
-
tx.makeMoveVec({
|
|
194
|
-
type: `${wormholePackageId}::vaa::VAA`,
|
|
195
|
-
objects: verifiedVaas,
|
|
196
|
-
}),
|
|
197
|
-
tx.object(sui_js_1.SUI_CLOCK_OBJECT_ID),
|
|
198
|
-
],
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
throw new Error("Can't mix accumulator and non-accumulator messages");
|
|
151
|
+
if (updates.length > 1) {
|
|
152
|
+
throw new Error("SDK does not support sending multiple accumulator messages in a single transaction");
|
|
203
153
|
}
|
|
154
|
+
const vaa = this.extractVaaBytesFromAccumulatorMessage(updates[0]);
|
|
155
|
+
const verifiedVaas = await this.verifyVaas([vaa], tx);
|
|
156
|
+
tx.moveCall({
|
|
157
|
+
target: `${packageId}::pyth::create_price_feeds_using_accumulator`,
|
|
158
|
+
arguments: [
|
|
159
|
+
tx.object(this.pythStateId),
|
|
160
|
+
tx.pure(bcs_1.bcs
|
|
161
|
+
.ser("vector<u8>", Array.from(updates[0]), {
|
|
162
|
+
maxSize: MAX_ARGUMENT_SIZE,
|
|
163
|
+
})
|
|
164
|
+
.toBytes()),
|
|
165
|
+
verifiedVaas[0],
|
|
166
|
+
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
167
|
+
],
|
|
168
|
+
});
|
|
204
169
|
}
|
|
205
170
|
/**
|
|
206
171
|
* Get the packageId for the wormhole package if not already cached
|
|
@@ -243,7 +208,10 @@ class SuiPythClient {
|
|
|
243
208
|
if (result.data.content.dataType !== "moveObject") {
|
|
244
209
|
throw new Error("Price feed type mismatch");
|
|
245
210
|
}
|
|
246
|
-
this.priceFeedObjectIdCache.set(normalizedFeedId,
|
|
211
|
+
this.priceFeedObjectIdCache.set(normalizedFeedId,
|
|
212
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
213
|
+
// @ts-ignore
|
|
214
|
+
result.data.content.fields.value);
|
|
247
215
|
}
|
|
248
216
|
return this.priceFeedObjectIdCache.get(normalizedFeedId);
|
|
249
217
|
}
|
|
@@ -269,5 +237,21 @@ class SuiPythClient {
|
|
|
269
237
|
}
|
|
270
238
|
return this.priceTableInfo;
|
|
271
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* Obtains the vaa bytes embedded in an accumulator message.
|
|
242
|
+
* @param accumulatorMessage - the accumulator price update message
|
|
243
|
+
* @returns vaa bytes as a uint8 array
|
|
244
|
+
*/
|
|
245
|
+
extractVaaBytesFromAccumulatorMessage(accumulatorMessage) {
|
|
246
|
+
// the first 6 bytes in the accumulator message encode the header, major, and minor bytes
|
|
247
|
+
// we ignore them, since we are only interested in the VAA bytes
|
|
248
|
+
const trailingPayloadSize = accumulatorMessage.readUint8(6);
|
|
249
|
+
const vaaSizeOffset = 7 + // header bytes (header(4) + major(1) + minor(1) + trailing payload size(1))
|
|
250
|
+
trailingPayloadSize + // trailing payload (variable number of bytes)
|
|
251
|
+
1; // proof_type (1 byte)
|
|
252
|
+
const vaaSize = accumulatorMessage.readUint16BE(vaaSizeOffset);
|
|
253
|
+
const vaaOffset = vaaSizeOffset + 2;
|
|
254
|
+
return accumulatorMessage.subarray(vaaOffset, vaaOffset + vaaSize);
|
|
255
|
+
}
|
|
272
256
|
}
|
|
273
257
|
exports.SuiPythClient = SuiPythClient;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function getProvider(url: string):
|
|
1
|
+
import { SuiClient } from "@mysten/sui.js/client";
|
|
2
|
+
export declare function getProvider(url: string): SuiClient;
|
|
3
3
|
//# sourceMappingURL=SuiRelay.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuiRelay.d.ts","sourceRoot":"","sources":["../../src/examples/SuiRelay.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"SuiRelay.d.ts","sourceRoot":"","sources":["../../src/examples/SuiRelay.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAqClD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,aAEtC"}
|
package/lib/examples/SuiRelay.js
CHANGED
|
@@ -6,9 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getProvider = void 0;
|
|
7
7
|
const yargs_1 = __importDefault(require("yargs"));
|
|
8
8
|
const helpers_1 = require("yargs/helpers");
|
|
9
|
-
const
|
|
9
|
+
const client_1 = require("@mysten/sui.js/client");
|
|
10
|
+
const transactions_1 = require("@mysten/sui.js/transactions");
|
|
11
|
+
const ed25519_1 = require("@mysten/sui.js/keypairs/ed25519");
|
|
10
12
|
const buffer_1 = require("buffer");
|
|
11
|
-
const
|
|
13
|
+
const client_2 = require("../client");
|
|
12
14
|
const index_1 = require("../index");
|
|
13
15
|
const argvPromise = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
14
16
|
.option("feed-id", {
|
|
@@ -37,7 +39,7 @@ const argvPromise = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
|
37
39
|
demandOption: true,
|
|
38
40
|
}).argv;
|
|
39
41
|
function getProvider(url) {
|
|
40
|
-
return new
|
|
42
|
+
return new client_1.SuiClient({ url });
|
|
41
43
|
}
|
|
42
44
|
exports.getProvider = getProvider;
|
|
43
45
|
async function run() {
|
|
@@ -48,22 +50,42 @@ async function run() {
|
|
|
48
50
|
// Fetch the latest price feed update data from the Price Service
|
|
49
51
|
const connection = new index_1.SuiPriceServiceConnection(argv["hermes"]);
|
|
50
52
|
const feeds = argv["feed-id"];
|
|
51
|
-
const priceFeedUpdateData = await connection.getPriceFeedsUpdateData(feeds);
|
|
52
53
|
const provider = getProvider(argv["full-node"]);
|
|
53
54
|
const wormholeStateId = argv["wormhole-state-id"];
|
|
54
55
|
const pythStateId = argv["pyth-state-id"];
|
|
55
|
-
const client = new
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
56
|
+
const client = new client_2.SuiPythClient(provider, pythStateId, wormholeStateId);
|
|
57
|
+
const newFeeds = [];
|
|
58
|
+
const existingFeeds = [];
|
|
59
|
+
for (const feed of feeds) {
|
|
60
|
+
if ((await client.getPriceFeedObjectId(feed)) == undefined) {
|
|
61
|
+
newFeeds.push(feed);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
existingFeeds.push(feed);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
console.log({
|
|
68
|
+
newFeeds,
|
|
69
|
+
existingFeeds,
|
|
70
|
+
});
|
|
71
|
+
const tx = new transactions_1.TransactionBlock();
|
|
72
|
+
if (existingFeeds.length > 0) {
|
|
73
|
+
const updateData = await connection.getPriceFeedsUpdateData(existingFeeds);
|
|
74
|
+
await client.updatePriceFeeds(tx, updateData, existingFeeds);
|
|
75
|
+
}
|
|
76
|
+
if (newFeeds.length > 0) {
|
|
77
|
+
const updateData = await connection.getPriceFeedsUpdateData(newFeeds);
|
|
78
|
+
await client.createPriceFeed(tx, updateData);
|
|
79
|
+
}
|
|
80
|
+
const wallet = ed25519_1.Ed25519Keypair.fromSecretKey(buffer_1.Buffer.from(process.env.SUI_KEY, "hex"));
|
|
81
|
+
const result = await provider.signAndExecuteTransactionBlock({
|
|
82
|
+
signer: wallet,
|
|
60
83
|
transactionBlock: tx,
|
|
61
84
|
options: {
|
|
62
85
|
showEffects: true,
|
|
63
86
|
showEvents: true,
|
|
64
87
|
},
|
|
65
|
-
};
|
|
66
|
-
const result = await wallet.signAndExecuteTransactionBlock(txBlock);
|
|
88
|
+
});
|
|
67
89
|
console.dir(result, { depth: null });
|
|
68
90
|
}
|
|
69
91
|
run();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pythnetwork/pyth-sui-js",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Pyth Network Sui Utilities",
|
|
5
5
|
"homepage": "https://pyth.network",
|
|
6
6
|
"author": {
|
|
@@ -48,14 +48,14 @@
|
|
|
48
48
|
"jest": "^29.4.1",
|
|
49
49
|
"prettier": "^2.6.2",
|
|
50
50
|
"ts-jest": "^29.0.5",
|
|
51
|
-
"typescript": "^
|
|
51
|
+
"typescript": "^5.3.3",
|
|
52
52
|
"web3": "^1.8.2",
|
|
53
53
|
"yargs": "^17.0.20"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@mysten/sui.js": "^0.
|
|
56
|
+
"@mysten/sui.js": "^0.49.1",
|
|
57
57
|
"@pythnetwork/price-service-client": "*",
|
|
58
58
|
"buffer": "^6.0.3"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "f14dd35d1abe0dc5e35752db4a77f4781d0a5c83"
|
|
61
61
|
}
|