@pythnetwork/pyth-sui-js 1.2.4 → 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 +8 -21
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +49 -91
- 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,11 +61,6 @@ export declare class SuiPythClient {
|
|
|
69
61
|
id: ObjectId;
|
|
70
62
|
fieldType: ObjectId;
|
|
71
63
|
}>;
|
|
72
|
-
/**
|
|
73
|
-
* Checks if a message is an accumulator message or not
|
|
74
|
-
* @param msg - update message from price service
|
|
75
|
-
*/
|
|
76
|
-
isAccumulatorMsg(msg: Buffer): boolean;
|
|
77
64
|
/**
|
|
78
65
|
* Obtains the vaa bytes embedded in an accumulator message.
|
|
79
66
|
* @param accumulatorMessage - the accumulator price update message
|
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,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SuiPythClient = void 0;
|
|
4
|
-
const
|
|
4
|
+
const utils_1 = require("@mysten/sui.js/utils");
|
|
5
|
+
const bcs_1 = require("@mysten/sui.js/bcs");
|
|
5
6
|
const buffer_1 = require("buffer");
|
|
6
7
|
const MAX_ARGUMENT_SIZE = 16 * 1024;
|
|
7
8
|
class SuiPythClient {
|
|
@@ -30,6 +31,8 @@ class SuiPythClient {
|
|
|
30
31
|
!result.data.content ||
|
|
31
32
|
result.data.content.dataType !== "moveObject")
|
|
32
33
|
throw new Error("Unable to fetch pyth state object");
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
35
|
+
// @ts-ignore
|
|
33
36
|
this.baseUpdateFee = result.data.content.fields.base_update_fee;
|
|
34
37
|
}
|
|
35
38
|
return this.baseUpdateFee;
|
|
@@ -52,9 +55,12 @@ class SuiPythClient {
|
|
|
52
55
|
if (result.data?.content?.dataType == "moveObject") {
|
|
53
56
|
return result.data.content.fields;
|
|
54
57
|
}
|
|
55
|
-
|
|
58
|
+
console.log(result.data?.content);
|
|
59
|
+
throw new Error(`Cannot fetch package id for object ${objectId}`);
|
|
56
60
|
});
|
|
57
61
|
if ("upgrade_cap" in state) {
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
63
|
+
// @ts-ignore
|
|
58
64
|
return state.upgrade_cap.fields.package;
|
|
59
65
|
}
|
|
60
66
|
throw new Error("upgrade_cap not found");
|
|
@@ -72,12 +78,12 @@ class SuiPythClient {
|
|
|
72
78
|
target: `${wormholePackageId}::vaa::parse_and_verify`,
|
|
73
79
|
arguments: [
|
|
74
80
|
tx.object(this.wormholeStateId),
|
|
75
|
-
tx.pure(
|
|
81
|
+
tx.pure(bcs_1.bcs
|
|
76
82
|
.ser("vector<u8>", Array.from(vaa), {
|
|
77
83
|
maxSize: MAX_ARGUMENT_SIZE,
|
|
78
84
|
})
|
|
79
85
|
.toBytes()),
|
|
80
|
-
tx.object(
|
|
86
|
+
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
81
87
|
],
|
|
82
88
|
});
|
|
83
89
|
verifiedVaas.push(verifiedVaa);
|
|
@@ -91,46 +97,26 @@ class SuiPythClient {
|
|
|
91
97
|
* @param feedIds array of feed ids to update (in hex format)
|
|
92
98
|
*/
|
|
93
99
|
async updatePriceFeeds(tx, updates, feedIds) {
|
|
94
|
-
const wormholePackageId = await this.getWormholePackageId();
|
|
95
100
|
const packageId = await this.getPythPackageId();
|
|
96
101
|
let priceUpdatesHotPotato;
|
|
97
|
-
if (updates.
|
|
98
|
-
|
|
99
|
-
throw new Error("SDK does not support sending multiple accumulator messages in a single transaction");
|
|
100
|
-
}
|
|
101
|
-
const vaa = this.extractVaaBytesFromAccumulatorMessage(updates[0]);
|
|
102
|
-
const verifiedVaas = await this.verifyVaas([vaa], tx);
|
|
103
|
-
[priceUpdatesHotPotato] = tx.moveCall({
|
|
104
|
-
target: `${packageId}::pyth::create_authenticated_price_infos_using_accumulator`,
|
|
105
|
-
arguments: [
|
|
106
|
-
tx.object(this.pythStateId),
|
|
107
|
-
tx.pure(sui_js_1.builder
|
|
108
|
-
.ser("vector<u8>", Array.from(updates[0]), {
|
|
109
|
-
maxSize: MAX_ARGUMENT_SIZE,
|
|
110
|
-
})
|
|
111
|
-
.toBytes()),
|
|
112
|
-
verifiedVaas[0],
|
|
113
|
-
tx.object(sui_js_1.SUI_CLOCK_OBJECT_ID),
|
|
114
|
-
],
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
else if (updates.every((vaa) => !this.isAccumulatorMsg(vaa))) {
|
|
118
|
-
const verifiedVaas = await this.verifyVaas(updates, tx);
|
|
119
|
-
[priceUpdatesHotPotato] = tx.moveCall({
|
|
120
|
-
target: `${packageId}::pyth::create_price_infos_hot_potato`,
|
|
121
|
-
arguments: [
|
|
122
|
-
tx.object(this.pythStateId),
|
|
123
|
-
tx.makeMoveVec({
|
|
124
|
-
type: `${wormholePackageId}::vaa::VAA`,
|
|
125
|
-
objects: verifiedVaas,
|
|
126
|
-
}),
|
|
127
|
-
tx.object(sui_js_1.SUI_CLOCK_OBJECT_ID),
|
|
128
|
-
],
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
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");
|
|
133
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
|
+
});
|
|
134
120
|
const priceInfoObjects = [];
|
|
135
121
|
const baseUpdateFee = await this.getBaseUpdateFee();
|
|
136
122
|
const coins = tx.splitCoins(tx.gas, feedIds.map(() => tx.pure(baseUpdateFee)));
|
|
@@ -148,7 +134,7 @@ class SuiPythClient {
|
|
|
148
134
|
priceUpdatesHotPotato,
|
|
149
135
|
tx.object(priceInfoObjectId),
|
|
150
136
|
coins[coinId],
|
|
151
|
-
tx.object(
|
|
137
|
+
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
152
138
|
],
|
|
153
139
|
});
|
|
154
140
|
coinId++;
|
|
@@ -161,45 +147,25 @@ class SuiPythClient {
|
|
|
161
147
|
return priceInfoObjects;
|
|
162
148
|
}
|
|
163
149
|
async createPriceFeed(tx, updates) {
|
|
164
|
-
const wormholePackageId = await this.getWormholePackageId();
|
|
165
150
|
const packageId = await this.getPythPackageId();
|
|
166
|
-
if (updates.
|
|
167
|
-
|
|
168
|
-
throw new Error("SDK does not support sending multiple accumulator messages in a single transaction");
|
|
169
|
-
}
|
|
170
|
-
const vaa = this.extractVaaBytesFromAccumulatorMessage(updates[0]);
|
|
171
|
-
const verifiedVaas = await this.verifyVaas([vaa], tx);
|
|
172
|
-
tx.moveCall({
|
|
173
|
-
target: `${packageId}::pyth::create_price_feeds_using_accumulator`,
|
|
174
|
-
arguments: [
|
|
175
|
-
tx.object(this.pythStateId),
|
|
176
|
-
tx.pure(sui_js_1.builder
|
|
177
|
-
.ser("vector<u8>", Array.from(updates[0]), {
|
|
178
|
-
maxSize: MAX_ARGUMENT_SIZE,
|
|
179
|
-
})
|
|
180
|
-
.toBytes()),
|
|
181
|
-
verifiedVaas[0],
|
|
182
|
-
tx.object(sui_js_1.SUI_CLOCK_OBJECT_ID),
|
|
183
|
-
],
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
else if (updates.every((vaa) => !this.isAccumulatorMsg(vaa))) {
|
|
187
|
-
const verifiedVaas = await this.verifyVaas(updates, tx);
|
|
188
|
-
tx.moveCall({
|
|
189
|
-
target: `${packageId}::pyth::create_price_feeds`,
|
|
190
|
-
arguments: [
|
|
191
|
-
tx.object(this.pythStateId),
|
|
192
|
-
tx.makeMoveVec({
|
|
193
|
-
type: `${wormholePackageId}::vaa::VAA`,
|
|
194
|
-
objects: verifiedVaas,
|
|
195
|
-
}),
|
|
196
|
-
tx.object(sui_js_1.SUI_CLOCK_OBJECT_ID),
|
|
197
|
-
],
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
201
|
-
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");
|
|
202
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
|
+
});
|
|
203
169
|
}
|
|
204
170
|
/**
|
|
205
171
|
* Get the packageId for the wormhole package if not already cached
|
|
@@ -242,7 +208,10 @@ class SuiPythClient {
|
|
|
242
208
|
if (result.data.content.dataType !== "moveObject") {
|
|
243
209
|
throw new Error("Price feed type mismatch");
|
|
244
210
|
}
|
|
245
|
-
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);
|
|
246
215
|
}
|
|
247
216
|
return this.priceFeedObjectIdCache.get(normalizedFeedId);
|
|
248
217
|
}
|
|
@@ -268,23 +237,12 @@ class SuiPythClient {
|
|
|
268
237
|
}
|
|
269
238
|
return this.priceTableInfo;
|
|
270
239
|
}
|
|
271
|
-
/**
|
|
272
|
-
* Checks if a message is an accumulator message or not
|
|
273
|
-
* @param msg - update message from price service
|
|
274
|
-
*/
|
|
275
|
-
isAccumulatorMsg(msg) {
|
|
276
|
-
const ACCUMULATOR_MAGIC = "504e4155";
|
|
277
|
-
return msg.toString("hex").slice(0, 8) === ACCUMULATOR_MAGIC;
|
|
278
|
-
}
|
|
279
240
|
/**
|
|
280
241
|
* Obtains the vaa bytes embedded in an accumulator message.
|
|
281
242
|
* @param accumulatorMessage - the accumulator price update message
|
|
282
243
|
* @returns vaa bytes as a uint8 array
|
|
283
244
|
*/
|
|
284
245
|
extractVaaBytesFromAccumulatorMessage(accumulatorMessage) {
|
|
285
|
-
if (!this.isAccumulatorMsg(accumulatorMessage)) {
|
|
286
|
-
throw new Error("Not an accumulator message");
|
|
287
|
-
}
|
|
288
246
|
// the first 6 bytes in the accumulator message encode the header, major, and minor bytes
|
|
289
247
|
// we ignore them, since we are only interested in the VAA bytes
|
|
290
248
|
const trailingPayloadSize = accumulatorMessage.readUint8(6);
|
|
@@ -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
|
}
|