@pythnetwork/pyth-sui-js 2.0.0 → 2.1.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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2023 Pyth Contributors.
1
+ Copyright 2024 Pyth Data Association.
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
package/README.md CHANGED
@@ -57,7 +57,8 @@ You can use `SuiPythClient` to build such transactions.
57
57
 
58
58
  ```ts
59
59
  import { SuiPythClient } from "@pythnetwork/pyth-sui-js";
60
- import { TransactionBlock } from "@mysten/sui.js";
60
+ import { Transaction } from "@mysten/sui/transactions";
61
+ import { SuiClient } from "@mysten/sui/client";
61
62
 
62
63
  const priceUpdateData = await connection.getPriceFeedsUpdateData(priceIds); // see quickstart section
63
64
 
@@ -69,8 +70,9 @@ const wallet: SignerWithProvider = getWallet();
69
70
  const wormholeStateId = " 0xFILL_ME";
70
71
  const pythStateId = "0xFILL_ME";
71
72
 
73
+ const provider = new SuiClient({ url: "https://fill-sui-endpoint" });
72
74
  const client = new SuiPythClient(wallet.provider, pythStateId, wormholeStateId);
73
- const tx = new TransactionBlock();
75
+ const tx = new Transaction();
74
76
  const priceInfoObjectIds = await client.updatePriceFeeds(tx, priceFeedUpdateData, priceIds);
75
77
 
76
78
  tx.moveCall({
@@ -82,15 +84,14 @@ tx.moveCall({
82
84
  ],
83
85
  });
84
86
 
85
- const txBlock = {
86
- transactionBlock: tx,
87
- options: {
88
- showEffects: true,
89
- showEvents: true,
90
- },
91
- };
92
-
93
- const result = await wallet.signAndExecuteTransactionBlock(txBlock);
87
+ const result = await provider.signAndExecuteTransaction({
88
+ signer: wallet,
89
+ transaction: tx,
90
+ options: {
91
+ showEffects: true,
92
+ showEvents: true,
93
+ },
94
+ });
94
95
  ```
95
96
 
96
97
  Now in your contract you can consume the price by calling `pyth::get_price` or other utility functions on the `PriceInfoObject`.
package/lib/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
- import { SuiClient } from "@mysten/sui.js/client";
3
- import { TransactionBlock } from "@mysten/sui.js/transactions";
2
+ import { SuiClient } from "@mysten/sui/client";
3
+ import { Transaction } from "@mysten/sui/transactions";
4
4
  import { HexString } from "@pythnetwork/price-service-client";
5
5
  import { Buffer } from "buffer";
6
6
  export type ObjectId = string;
@@ -27,10 +27,9 @@ export declare class SuiPythClient {
27
27
  * @param vaas array of vaas to verify
28
28
  * @param tx transaction block to add commands to
29
29
  */
30
- verifyVaas(vaas: Buffer[], tx: TransactionBlock): Promise<{
31
- index: number;
32
- resultIndex: number;
33
- kind: "NestedResult";
30
+ verifyVaas(vaas: Buffer[], tx: Transaction): Promise<{
31
+ $kind: "NestedResult";
32
+ NestedResult: [number, number];
34
33
  }[]>;
35
34
  /**
36
35
  * Adds the necessary commands for updating the pyth price feeds to the transaction block.
@@ -38,8 +37,8 @@ export declare class SuiPythClient {
38
37
  * @param updates array of price feed updates received from the price service
39
38
  * @param feedIds array of feed ids to update (in hex format)
40
39
  */
41
- updatePriceFeeds(tx: TransactionBlock, updates: Buffer[], feedIds: HexString[]): Promise<ObjectId[]>;
42
- createPriceFeed(tx: TransactionBlock, updates: Buffer[]): Promise<void>;
40
+ updatePriceFeeds(tx: Transaction, updates: Buffer[], feedIds: HexString[]): Promise<ObjectId[]>;
41
+ createPriceFeed(tx: Transaction, updates: Buffer[]): Promise<void>;
43
42
  /**
44
43
  * Get the packageId for the wormhole package if not already cached
45
44
  */
@@ -1 +1 @@
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,EA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E;;;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 utils_1 = require("@mysten/sui.js/utils");
5
- const bcs_1 = require("@mysten/sui.js/bcs");
4
+ const utils_1 = require("@mysten/sui/utils");
5
+ const bcs_1 = require("@mysten/sui/bcs");
6
6
  const buffer_1 = require("buffer");
7
7
  const MAX_ARGUMENT_SIZE = 16 * 1024;
8
8
  class SuiPythClient {
@@ -79,7 +79,8 @@ class SuiPythClient {
79
79
  arguments: [
80
80
  tx.object(this.wormholeStateId),
81
81
  tx.pure(bcs_1.bcs
82
- .ser("vector<u8>", Array.from(vaa), {
82
+ .vector(bcs_1.bcs.U8)
83
+ .serialize(Array.from(vaa), {
83
84
  maxSize: MAX_ARGUMENT_SIZE,
84
85
  })
85
86
  .toBytes()),
@@ -109,7 +110,8 @@ class SuiPythClient {
109
110
  arguments: [
110
111
  tx.object(this.pythStateId),
111
112
  tx.pure(bcs_1.bcs
112
- .ser("vector<u8>", Array.from(updates[0]), {
113
+ .vector(bcs_1.bcs.U8)
114
+ .serialize(Array.from(updates[0]), {
113
115
  maxSize: MAX_ARGUMENT_SIZE,
114
116
  })
115
117
  .toBytes()),
@@ -119,7 +121,7 @@ class SuiPythClient {
119
121
  });
120
122
  const priceInfoObjects = [];
121
123
  const baseUpdateFee = await this.getBaseUpdateFee();
122
- const coins = tx.splitCoins(tx.gas, feedIds.map(() => tx.pure(baseUpdateFee)));
124
+ const coins = tx.splitCoins(tx.gas, feedIds.map(() => tx.pure.u64(baseUpdateFee)));
123
125
  let coinId = 0;
124
126
  for (const feedId of feedIds) {
125
127
  const priceInfoObjectId = await this.getPriceFeedObjectId(feedId);
@@ -158,7 +160,8 @@ class SuiPythClient {
158
160
  arguments: [
159
161
  tx.object(this.pythStateId),
160
162
  tx.pure(bcs_1.bcs
161
- .ser("vector<u8>", Array.from(updates[0]), {
163
+ .vector(bcs_1.bcs.U8)
164
+ .serialize(Array.from(updates[0]), {
162
165
  maxSize: MAX_ARGUMENT_SIZE,
163
166
  })
164
167
  .toBytes()),
@@ -1,3 +1,3 @@
1
- import { SuiClient } from "@mysten/sui.js/client";
1
+ import { SuiClient } from "@mysten/sui/client";
2
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,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAqClD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,aAEtC"}
1
+ {"version":3,"file":"SuiRelay.d.ts","sourceRoot":"","sources":["../../src/examples/SuiRelay.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAqC/C,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,aAEtC"}
@@ -6,9 +6,9 @@ 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 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");
9
+ const client_1 = require("@mysten/sui/client");
10
+ const transactions_1 = require("@mysten/sui/transactions");
11
+ const ed25519_1 = require("@mysten/sui/keypairs/ed25519");
12
12
  const buffer_1 = require("buffer");
13
13
  const client_2 = require("../client");
14
14
  const index_1 = require("../index");
@@ -68,7 +68,7 @@ async function run() {
68
68
  newFeeds,
69
69
  existingFeeds,
70
70
  });
71
- const tx = new transactions_1.TransactionBlock();
71
+ const tx = new transactions_1.Transaction();
72
72
  if (existingFeeds.length > 0) {
73
73
  const updateData = await connection.getPriceFeedsUpdateData(existingFeeds);
74
74
  await client.updatePriceFeeds(tx, updateData, existingFeeds);
@@ -78,9 +78,9 @@ async function run() {
78
78
  await client.createPriceFeed(tx, updateData);
79
79
  }
80
80
  const wallet = ed25519_1.Ed25519Keypair.fromSecretKey(buffer_1.Buffer.from(process.env.SUI_KEY, "hex"));
81
- const result = await provider.signAndExecuteTransactionBlock({
81
+ const result = await provider.signAndExecuteTransaction({
82
82
  signer: wallet,
83
- transactionBlock: tx,
83
+ transaction: tx,
84
84
  options: {
85
85
  showEffects: true,
86
86
  showEvents: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pythnetwork/pyth-sui-js",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Pyth Network Sui Utilities",
5
5
  "homepage": "https://pyth.network",
6
6
  "author": {
@@ -22,12 +22,12 @@
22
22
  "scripts": {
23
23
  "test": "jest --passWithNoTests",
24
24
  "build": "tsc",
25
- "example-relay": "npm run build && node lib/examples/SuiRelay.js",
25
+ "example-relay": "pnpm run build && node lib/examples/SuiRelay.js",
26
26
  "format": "prettier --write \"src/**/*.ts\"",
27
27
  "lint": "eslint src/",
28
- "prepublishOnly": "npm run build && npm test && npm run lint",
29
- "preversion": "npm run lint",
30
- "version": "npm run format && git add -A src"
28
+ "prepublishOnly": "pnpm run build && pnpm test && pnpm run lint",
29
+ "preversion": "pnpm run lint",
30
+ "version": "pnpm run format && git add -A src"
31
31
  },
32
32
  "keywords": [
33
33
  "pyth",
@@ -42,8 +42,8 @@
42
42
  "@types/node": "^18.11.18",
43
43
  "@types/web3-provider-engine": "^14.0.1",
44
44
  "@types/yargs": "^17.0.20",
45
- "@typescript-eslint/eslint-plugin": "^5.21.0",
46
- "@typescript-eslint/parser": "^5.21.0",
45
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
46
+ "@typescript-eslint/parser": "^6.0.0",
47
47
  "eslint": "^8.14.0",
48
48
  "jest": "^29.4.1",
49
49
  "prettier": "^2.6.2",
@@ -53,9 +53,9 @@
53
53
  "yargs": "^17.0.20"
54
54
  },
55
55
  "dependencies": {
56
- "@mysten/sui.js": "^0.49.1",
57
- "@pythnetwork/price-service-client": "*",
56
+ "@mysten/sui": "^1.3.0",
57
+ "@pythnetwork/price-service-client": "1.9.0",
58
58
  "buffer": "^6.0.3"
59
59
  },
60
- "gitHead": "f14dd35d1abe0dc5e35752db4a77f4781d0a5c83"
60
+ "gitHead": "9a31948be215682091abe580a68666909b976462"
61
61
  }