@pythnetwork/pyth-sui-js 1.1.0 → 1.2.1
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 +1 -0
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +7 -5
- package/lib/examples/SuiRelay.d.ts.map +1 -1
- package/lib/examples/SuiRelay.js +5 -4
- package/package.json +2 -2
package/lib/client.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { JsonRpcProvider, ObjectId, TransactionBlock } from "@mysten/sui.js";
|
|
3
3
|
import { HexString } from "@pythnetwork/price-service-client";
|
|
4
|
+
import { Buffer } from "buffer";
|
|
4
5
|
export declare class SuiPythClient {
|
|
5
6
|
provider: JsonRpcProvider;
|
|
6
7
|
pythStateId: ObjectId;
|
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;
|
|
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,CAAC,iBAAiB,CAAuB;IAChD,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,sBAAsB,CAAuC;IACrE,OAAO,CAAC,aAAa,CAAqB;gBAEjC,QAAQ,EAAE,eAAe,EACzB,WAAW,EAAE,QAAQ,EACrB,eAAe,EAAE,QAAQ;IAM5B,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;IAkBzC;;;;;OAKG;IACG,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAuBzD;;;;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;IA+EhB,eAAe,CAAC,EAAE,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,EAAE;IA4C7D;;OAEG;IACG,oBAAoB;IAO1B;;OAEG;IACG,gBAAgB;IAOtB;;;OAGG;IACG,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC;IA2B5E;;;OAGG;IACG,eAAe,IAAI,OAAO,CAAC,QAAQ,CAAC;IAmB1C;;;OAGG;IACH,gBAAgB,CAAC,GAAG,EAAE,MAAM;IAK5B;;;;OAIG;IACH,qCAAqC,CAAC,kBAAkB,EAAE,MAAM,GAAG,MAAM;CAe1E"}
|
package/lib/client.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SuiPythClient = void 0;
|
|
4
4
|
const sui_js_1 = require("@mysten/sui.js");
|
|
5
|
+
const buffer_1 = require("buffer");
|
|
5
6
|
const MAX_ARGUMENT_SIZE = 16 * 1024;
|
|
6
7
|
class SuiPythClient {
|
|
7
8
|
provider;
|
|
@@ -131,25 +132,26 @@ class SuiPythClient {
|
|
|
131
132
|
throw new Error("Can't mix accumulator and non-accumulator messages");
|
|
132
133
|
}
|
|
133
134
|
const priceInfoObjects = [];
|
|
135
|
+
const baseUpdateFee = await this.getBaseUpdateFee();
|
|
136
|
+
const coins = tx.splitCoins(tx.gas, feedIds.map(() => tx.pure(baseUpdateFee)));
|
|
137
|
+
let coinId = 0;
|
|
134
138
|
for (const feedId of feedIds) {
|
|
135
139
|
const priceInfoObjectId = await this.getPriceFeedObjectId(feedId);
|
|
136
140
|
if (!priceInfoObjectId) {
|
|
137
141
|
throw new Error(`Price feed ${feedId} not found, please create it first`);
|
|
138
142
|
}
|
|
139
143
|
priceInfoObjects.push(priceInfoObjectId);
|
|
140
|
-
const coin = tx.splitCoins(tx.gas, [
|
|
141
|
-
tx.pure(await this.getBaseUpdateFee()),
|
|
142
|
-
]);
|
|
143
144
|
[priceUpdatesHotPotato] = tx.moveCall({
|
|
144
145
|
target: `${packageId}::pyth::update_single_price_feed`,
|
|
145
146
|
arguments: [
|
|
146
147
|
tx.object(this.pythStateId),
|
|
147
148
|
priceUpdatesHotPotato,
|
|
148
149
|
tx.object(priceInfoObjectId),
|
|
149
|
-
|
|
150
|
+
coins[coinId],
|
|
150
151
|
tx.object(sui_js_1.SUI_CLOCK_OBJECT_ID),
|
|
151
152
|
],
|
|
152
153
|
});
|
|
154
|
+
coinId++;
|
|
153
155
|
}
|
|
154
156
|
tx.moveCall({
|
|
155
157
|
target: `${packageId}::hot_potato_vector::destroy`,
|
|
@@ -230,7 +232,7 @@ class SuiPythClient {
|
|
|
230
232
|
name: {
|
|
231
233
|
type: `${await this.getPythPackageId()}::price_identifier::PriceIdentifier`,
|
|
232
234
|
value: {
|
|
233
|
-
bytes: Array.from(Buffer.from(normalizedFeedId, "hex")),
|
|
235
|
+
bytes: Array.from(buffer_1.Buffer.from(normalizedFeedId, "hex")),
|
|
234
236
|
},
|
|
235
237
|
},
|
|
236
238
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuiRelay.d.ts","sourceRoot":"","sources":["../../src/examples/SuiRelay.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,eAAe,EAGhB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"SuiRelay.d.ts","sourceRoot":"","sources":["../../src/examples/SuiRelay.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,eAAe,EAGhB,MAAM,gBAAgB,CAAC;AAkCxB,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,mBAEtC"}
|
package/lib/examples/SuiRelay.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.getProvider = void 0;
|
|
|
7
7
|
const yargs_1 = __importDefault(require("yargs"));
|
|
8
8
|
const helpers_1 = require("yargs/helpers");
|
|
9
9
|
const sui_js_1 = require("@mysten/sui.js");
|
|
10
|
+
const buffer_1 = require("buffer");
|
|
10
11
|
const client_1 = require("../client");
|
|
11
12
|
const index_1 = require("../index");
|
|
12
13
|
const argvPromise = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
@@ -15,8 +16,8 @@ const argvPromise = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
|
15
16
|
type: "array",
|
|
16
17
|
demandOption: true,
|
|
17
18
|
})
|
|
18
|
-
.option("
|
|
19
|
-
description: "Endpoint URL for
|
|
19
|
+
.option("hermes", {
|
|
20
|
+
description: "Endpoint URL for Hermes. e.g: https://hermes.pyth.network",
|
|
20
21
|
type: "string",
|
|
21
22
|
demandOption: true,
|
|
22
23
|
})
|
|
@@ -45,7 +46,7 @@ async function run() {
|
|
|
45
46
|
}
|
|
46
47
|
const argv = await argvPromise;
|
|
47
48
|
// Fetch the latest price feed update data from the Price Service
|
|
48
|
-
const connection = new index_1.SuiPriceServiceConnection(argv["
|
|
49
|
+
const connection = new index_1.SuiPriceServiceConnection(argv["hermes"]);
|
|
49
50
|
const feeds = argv["feed-id"];
|
|
50
51
|
const priceFeedUpdateData = await connection.getPriceFeedsUpdateData(feeds);
|
|
51
52
|
const provider = getProvider(argv["full-node"]);
|
|
@@ -54,7 +55,7 @@ async function run() {
|
|
|
54
55
|
const client = new client_1.SuiPythClient(provider, pythStateId, wormholeStateId);
|
|
55
56
|
const tx = new sui_js_1.TransactionBlock();
|
|
56
57
|
await client.updatePriceFeeds(tx, priceFeedUpdateData, feeds);
|
|
57
|
-
const wallet = new sui_js_1.RawSigner(sui_js_1.Ed25519Keypair.fromSecretKey(Buffer.from(process.env.SUI_KEY, "hex")), provider);
|
|
58
|
+
const wallet = new sui_js_1.RawSigner(sui_js_1.Ed25519Keypair.fromSecretKey(buffer_1.Buffer.from(process.env.SUI_KEY, "hex")), provider);
|
|
58
59
|
const txBlock = {
|
|
59
60
|
transactionBlock: tx,
|
|
60
61
|
options: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pythnetwork/pyth-sui-js",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
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": "940c2035f37058495b183daa5b5dd9916b5d470a"
|
|
61
61
|
}
|