@pythnetwork/pyth-sui-js 2.0.0 → 2.2.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 2025 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
@@ -4,16 +4,11 @@
4
4
 
5
5
  ## Installation
6
6
 
7
- ### npm
7
+ ### pnpm
8
8
 
9
9
  ```
10
- $ npm install --save @pythnetwork/pyth-sui-js
11
- ```
12
-
13
- ### Yarn
14
-
15
- ```
16
- $ yarn add @pythnetwork/pyth-sui-js
10
+ cd to crosschain root
11
+ $ pnpm install
17
12
  ```
18
13
 
19
14
  ## Quickstart
@@ -27,7 +22,7 @@ Pyth prices and submit them to the network:
27
22
 
28
23
  ```typescript
29
24
  const connection = new SuiPriceServiceConnection(
30
- "https://hermes-beta.pyth.network"
25
+ "https://hermes-beta.pyth.network",
31
26
  ); // See Hermes endpoints section below for other endpoints
32
27
 
33
28
  const priceIds = [
@@ -57,7 +52,8 @@ You can use `SuiPythClient` to build such transactions.
57
52
 
58
53
  ```ts
59
54
  import { SuiPythClient } from "@pythnetwork/pyth-sui-js";
60
- import { TransactionBlock } from "@mysten/sui.js";
55
+ import { Transaction } from "@mysten/sui/transactions";
56
+ import { SuiClient } from "@mysten/sui/client";
61
57
 
62
58
  const priceUpdateData = await connection.getPriceFeedsUpdateData(priceIds); // see quickstart section
63
59
 
@@ -69,8 +65,9 @@ const wallet: SignerWithProvider = getWallet();
69
65
  const wormholeStateId = " 0xFILL_ME";
70
66
  const pythStateId = "0xFILL_ME";
71
67
 
68
+ const provider = new SuiClient({ url: "https://fill-sui-endpoint" });
72
69
  const client = new SuiPythClient(wallet.provider, pythStateId, wormholeStateId);
73
- const tx = new TransactionBlock();
70
+ const tx = new Transaction();
74
71
  const priceInfoObjectIds = await client.updatePriceFeeds(tx, priceFeedUpdateData, priceIds);
75
72
 
76
73
  tx.moveCall({
@@ -82,15 +79,14 @@ tx.moveCall({
82
79
  ],
83
80
  });
84
81
 
85
- const txBlock = {
86
- transactionBlock: tx,
87
- options: {
88
- showEffects: true,
89
- showEvents: true,
90
- },
91
- };
92
-
93
- const result = await wallet.signAndExecuteTransactionBlock(txBlock);
82
+ const result = await provider.signAndExecuteTransaction({
83
+ signer: wallet,
84
+ transaction: tx,
85
+ options: {
86
+ showEffects: true,
87
+ showEvents: true,
88
+ },
89
+ });
94
90
  ```
95
91
 
96
92
  Now in your contract you can consume the price by calling `pyth::get_price` or other utility functions on the `PriceInfoObject`.
@@ -102,12 +98,15 @@ Now in your contract you can consume the price by calling `pyth::get_price` or o
102
98
  1. Fetches update data from Hermes for the given price feeds.
103
99
  2. Calls the Pyth Sui contract with the update data.
104
100
 
105
- You can run this example with `npm run example-relay`. A full command that updates prices on Sui testnet looks like:
101
+ In order to run the commands, a SUI private key is needed. The commands expects the key to be in the form of hex. You can use `sui keytool convert` to get the hex version of the key, to be used below, if your private key is in the form "suiprivkey...".
102
+
103
+ You can run this example with `pnpm turbo --filter @pythnetwork/pyth-sui-js run example-relay` from the root of crosschain. Turbo will automatically build any detected dependencies including local ones, and filter is needed to tell it which sub-package to use (Such as this one). A full command that updates prices on Sui testnet looks like:
106
104
 
107
105
  ```bash
108
106
  export SUI_KEY=YOUR_PRIV_KEY;
109
- npm run example-relay -- --feed-id "5a035d5440f5c163069af66062bac6c79377bf88396fa27e6067bfca8096d280" \
110
- --price-service "https://hermes-beta.pyth.network" \
107
+ pnpm turbo run example-relay --filter @pythnetwork/pyth-sui-js -- \
108
+ --feed-id "5a035d5440f5c163069af66062bac6c79377bf88396fa27e6067bfca8096d280" \
109
+ --hermes "https://hermes-beta.pyth.network" \
111
110
  --full-node "https://fullnode.testnet.sui.io:443" \
112
111
  --pyth-state-id "0xd3e79c2c083b934e78b3bd58a490ec6b092561954da6e7322e1e2b3c8abfddc0" \
113
112
  --wormhole-state-id "0x31358d198147da50db32eda2562951d53973a0c0ad5ed738e9b17d88b213d790"
@@ -138,7 +137,7 @@ This method is useful if you want to show continuously updating real-time prices
138
137
  // gets a price update.
139
138
  connection.subscribePriceFeedUpdates(priceIds, (priceFeed) => {
140
139
  console.log(
141
- `Received update for ${priceFeed.id}: ${priceFeed.getPriceNoOlderThan(60)}`
140
+ `Received update for ${priceFeed.id}: ${priceFeed.getPriceNoOlderThan(60)}`,
142
141
  );
143
142
  });
144
143
 
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { PriceServiceConnection, HexString } from "@pythnetwork/price-service-client";
3
2
  import { Buffer } from "buffer";
4
3
  export declare class SuiPriceServiceConnection extends PriceServiceConnection {
@@ -1 +1 @@
1
- {"version":3,"file":"SuiPriceServiceConnection.d.ts","sourceRoot":"","sources":["../src/SuiPriceServiceConnection.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,sBAAsB,EACtB,SAAS,EACV,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,qBAAa,yBAA0B,SAAQ,sBAAsB;IACnE;;;;;;;OAOG;IACG,uBAAuB,CAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAKxE"}
1
+ {"version":3,"file":"SuiPriceServiceConnection.d.ts","sourceRoot":"","sources":["../src/SuiPriceServiceConnection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,SAAS,EACV,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,qBAAa,yBAA0B,SAAQ,sBAAsB;IACnE;;;;;;;OAOG;IACG,uBAAuB,CAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAKxE"}
package/lib/client.d.ts CHANGED
@@ -1,8 +1,11 @@
1
- /// <reference types="node" />
2
- import { SuiClient } from "@mysten/sui.js/client";
3
- import { TransactionBlock } from "@mysten/sui.js/transactions";
1
+ import { SuiClient } from "@mysten/sui/client";
2
+ import { Transaction } from "@mysten/sui/transactions";
4
3
  import { HexString } from "@pythnetwork/price-service-client";
5
4
  import { Buffer } from "buffer";
5
+ type NestedTransactionResult = {
6
+ $kind: "NestedResult";
7
+ NestedResult: [number, number];
8
+ };
6
9
  export type ObjectId = string;
7
10
  export declare class SuiPythClient {
8
11
  provider: SuiClient;
@@ -27,19 +30,28 @@ export declare class SuiPythClient {
27
30
  * @param vaas array of vaas to verify
28
31
  * @param tx transaction block to add commands to
29
32
  */
30
- verifyVaas(vaas: Buffer[], tx: TransactionBlock): Promise<{
31
- index: number;
32
- resultIndex: number;
33
- kind: "NestedResult";
33
+ verifyVaas(vaas: Buffer[], tx: Transaction): Promise<{
34
+ $kind: "NestedResult";
35
+ NestedResult: [number, number];
34
36
  }[]>;
37
+ verifyVaasAndGetHotPotato(tx: Transaction, updates: Buffer[], packageId: string): Promise<NestedTransactionResult>;
38
+ executePriceFeedUpdates(tx: Transaction, packageId: string, feedIds: HexString[], priceUpdatesHotPotato: any, coins: NestedTransactionResult[]): Promise<string[]>;
35
39
  /**
36
40
  * Adds the necessary commands for updating the pyth price feeds to the transaction block.
37
41
  * @param tx transaction block to add commands to
38
42
  * @param updates array of price feed updates received from the price service
39
43
  * @param feedIds array of feed ids to update (in hex format)
40
44
  */
41
- updatePriceFeeds(tx: TransactionBlock, updates: Buffer[], feedIds: HexString[]): Promise<ObjectId[]>;
42
- createPriceFeed(tx: TransactionBlock, updates: Buffer[]): Promise<void>;
45
+ updatePriceFeeds(tx: Transaction, updates: Buffer[], feedIds: HexString[]): Promise<ObjectId[]>;
46
+ /**
47
+ * Updates price feeds using the coin input for payment. Coins can be generated by calling splitCoin on tx.gas.
48
+ * @param tx transaction block to add commands to
49
+ * @param updates array of price feed updates received from the price service
50
+ * @param feedIds array of feed ids to update (in hex format)
51
+ * @param coins array of Coins for payment of update operations
52
+ */
53
+ updatePriceFeedsWithCoins(tx: Transaction, updates: Buffer[], feedIds: HexString[], coins: NestedTransactionResult[]): Promise<ObjectId[]>;
54
+ createPriceFeed(tx: Transaction, updates: Buffer[]): Promise<void>;
43
55
  /**
44
56
  * Get the packageId for the wormhole package if not already cached
45
57
  */
@@ -68,4 +80,5 @@ export declare class SuiPythClient {
68
80
  */
69
81
  extractVaaBytesFromAccumulatorMessage(accumulatorMessage: Buffer): Buffer;
70
82
  }
83
+ export {};
71
84
  //# sourceMappingURL=client.d.ts.map
@@ -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,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,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;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 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()),
@@ -90,26 +91,19 @@ class SuiPythClient {
90
91
  }
91
92
  return verifiedVaas;
92
93
  }
93
- /**
94
- * Adds the necessary commands for updating the pyth price feeds to the transaction block.
95
- * @param tx transaction block to add commands to
96
- * @param updates array of price feed updates received from the price service
97
- * @param feedIds array of feed ids to update (in hex format)
98
- */
99
- async updatePriceFeeds(tx, updates, feedIds) {
100
- const packageId = await this.getPythPackageId();
101
- let priceUpdatesHotPotato;
94
+ async verifyVaasAndGetHotPotato(tx, updates, packageId) {
102
95
  if (updates.length > 1) {
103
96
  throw new Error("SDK does not support sending multiple accumulator messages in a single transaction");
104
97
  }
105
98
  const vaa = this.extractVaaBytesFromAccumulatorMessage(updates[0]);
106
99
  const verifiedVaas = await this.verifyVaas([vaa], tx);
107
- [priceUpdatesHotPotato] = tx.moveCall({
100
+ const [priceUpdatesHotPotato] = tx.moveCall({
108
101
  target: `${packageId}::pyth::create_authenticated_price_infos_using_accumulator`,
109
102
  arguments: [
110
103
  tx.object(this.pythStateId),
111
104
  tx.pure(bcs_1.bcs
112
- .ser("vector<u8>", Array.from(updates[0]), {
105
+ .vector(bcs_1.bcs.U8)
106
+ .serialize(Array.from(updates[0]), {
113
107
  maxSize: MAX_ARGUMENT_SIZE,
114
108
  })
115
109
  .toBytes()),
@@ -117,9 +111,10 @@ class SuiPythClient {
117
111
  tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
118
112
  ],
119
113
  });
114
+ return priceUpdatesHotPotato;
115
+ }
116
+ async executePriceFeedUpdates(tx, packageId, feedIds, priceUpdatesHotPotato, coins) {
120
117
  const priceInfoObjects = [];
121
- const baseUpdateFee = await this.getBaseUpdateFee();
122
- const coins = tx.splitCoins(tx.gas, feedIds.map(() => tx.pure(baseUpdateFee)));
123
118
  let coinId = 0;
124
119
  for (const feedId of feedIds) {
125
120
  const priceInfoObjectId = await this.getPriceFeedObjectId(feedId);
@@ -146,6 +141,31 @@ class SuiPythClient {
146
141
  });
147
142
  return priceInfoObjects;
148
143
  }
144
+ /**
145
+ * Adds the necessary commands for updating the pyth price feeds to the transaction block.
146
+ * @param tx transaction block to add commands to
147
+ * @param updates array of price feed updates received from the price service
148
+ * @param feedIds array of feed ids to update (in hex format)
149
+ */
150
+ async updatePriceFeeds(tx, updates, feedIds) {
151
+ const packageId = await this.getPythPackageId();
152
+ const priceUpdatesHotPotato = await this.verifyVaasAndGetHotPotato(tx, updates, packageId);
153
+ const baseUpdateFee = await this.getBaseUpdateFee();
154
+ const coins = tx.splitCoins(tx.gas, feedIds.map(() => tx.pure.u64(baseUpdateFee)));
155
+ return await this.executePriceFeedUpdates(tx, packageId, feedIds, priceUpdatesHotPotato, coins);
156
+ }
157
+ /**
158
+ * Updates price feeds using the coin input for payment. Coins can be generated by calling splitCoin on tx.gas.
159
+ * @param tx transaction block to add commands to
160
+ * @param updates array of price feed updates received from the price service
161
+ * @param feedIds array of feed ids to update (in hex format)
162
+ * @param coins array of Coins for payment of update operations
163
+ */
164
+ async updatePriceFeedsWithCoins(tx, updates, feedIds, coins) {
165
+ const packageId = await this.getPythPackageId();
166
+ const priceUpdatesHotPotato = await this.verifyVaasAndGetHotPotato(tx, updates, packageId);
167
+ return await this.executePriceFeedUpdates(tx, packageId, feedIds, priceUpdatesHotPotato, coins);
168
+ }
149
169
  async createPriceFeed(tx, updates) {
150
170
  const packageId = await this.getPythPackageId();
151
171
  if (updates.length > 1) {
@@ -158,7 +178,8 @@ class SuiPythClient {
158
178
  arguments: [
159
179
  tx.object(this.pythStateId),
160
180
  tx.pure(bcs_1.bcs
161
- .ser("vector<u8>", Array.from(updates[0]), {
181
+ .vector(bcs_1.bcs.U8)
182
+ .serialize(Array.from(updates[0]), {
162
183
  maxSize: MAX_ARGUMENT_SIZE,
163
184
  })
164
185
  .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;AAsC/C,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,aAEtC"}
@@ -3,18 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getProvider = void 0;
6
+ exports.getProvider = getProvider;
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");
15
15
  const argvPromise = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
16
16
  .option("feed-id", {
17
17
  description: "Price feed ids to update without the leading 0x (e.g f9c0172ba10dfa4d19088d94f5bf61d3b54d5bd7483a322a982e1373ee8ea31b). Can be provided multiple times for multiple feed updates",
18
+ string: true,
18
19
  type: "array",
19
20
  demandOption: true,
20
21
  })
@@ -41,7 +42,6 @@ const argvPromise = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
41
42
  function getProvider(url) {
42
43
  return new client_1.SuiClient({ url });
43
44
  }
44
- exports.getProvider = getProvider;
45
45
  async function run() {
46
46
  if (process.env.SUI_KEY === undefined) {
47
47
  throw new Error(`SUI_KEY environment variable should be set.`);
@@ -50,6 +50,9 @@ async function run() {
50
50
  // Fetch the latest price feed update data from the Price Service
51
51
  const connection = new index_1.SuiPriceServiceConnection(argv["hermes"]);
52
52
  const feeds = argv["feed-id"];
53
+ if (!Array.isArray(feeds)) {
54
+ throw new Error("Not a valid input!");
55
+ }
53
56
  const provider = getProvider(argv["full-node"]);
54
57
  const wormholeStateId = argv["wormhole-state-id"];
55
58
  const pythStateId = argv["pyth-state-id"];
@@ -57,6 +60,9 @@ async function run() {
57
60
  const newFeeds = [];
58
61
  const existingFeeds = [];
59
62
  for (const feed of feeds) {
63
+ if (typeof feed !== "string") {
64
+ throw new Error(`Not a valid string input ${feed}`);
65
+ }
60
66
  if ((await client.getPriceFeedObjectId(feed)) == undefined) {
61
67
  newFeeds.push(feed);
62
68
  }
@@ -68,7 +74,7 @@ async function run() {
68
74
  newFeeds,
69
75
  existingFeeds,
70
76
  });
71
- const tx = new transactions_1.TransactionBlock();
77
+ const tx = new transactions_1.Transaction();
72
78
  if (existingFeeds.length > 0) {
73
79
  const updateData = await connection.getPriceFeedsUpdateData(existingFeeds);
74
80
  await client.updatePriceFeeds(tx, updateData, existingFeeds);
@@ -78,9 +84,9 @@ async function run() {
78
84
  await client.createPriceFeed(tx, updateData);
79
85
  }
80
86
  const wallet = ed25519_1.Ed25519Keypair.fromSecretKey(buffer_1.Buffer.from(process.env.SUI_KEY, "hex"));
81
- const result = await provider.signAndExecuteTransactionBlock({
87
+ const result = await provider.signAndExecuteTransaction({
82
88
  signer: wallet,
83
- transactionBlock: tx,
89
+ transaction: tx,
84
90
  options: {
85
91
  showEffects: true,
86
92
  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.2.0",
4
4
  "description": "Pyth Network Sui Utilities",
5
5
  "homepage": "https://pyth.network",
6
6
  "author": {
@@ -19,16 +19,6 @@
19
19
  "publishConfig": {
20
20
  "access": "public"
21
21
  },
22
- "scripts": {
23
- "test": "jest --passWithNoTests",
24
- "build": "tsc",
25
- "example-relay": "npm run build && node lib/examples/SuiRelay.js",
26
- "format": "prettier --write \"src/**/*.ts\"",
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"
31
- },
32
22
  "keywords": [
33
23
  "pyth",
34
24
  "oracle",
@@ -42,20 +32,29 @@
42
32
  "@types/node": "^18.11.18",
43
33
  "@types/web3-provider-engine": "^14.0.1",
44
34
  "@types/yargs": "^17.0.20",
45
- "@typescript-eslint/eslint-plugin": "^5.21.0",
46
- "@typescript-eslint/parser": "^5.21.0",
35
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
36
+ "@typescript-eslint/parser": "^6.0.0",
47
37
  "eslint": "^8.14.0",
48
38
  "jest": "^29.4.1",
49
- "prettier": "^2.6.2",
39
+ "prettier": "^3.5.3",
50
40
  "ts-jest": "^29.0.5",
51
41
  "typescript": "^5.3.3",
52
42
  "web3": "^1.8.2",
53
43
  "yargs": "^17.0.20"
54
44
  },
55
45
  "dependencies": {
56
- "@mysten/sui.js": "^0.49.1",
57
- "@pythnetwork/price-service-client": "*",
58
- "buffer": "^6.0.3"
46
+ "@mysten/sui": "^1.3.0",
47
+ "buffer": "^6.0.3",
48
+ "@pythnetwork/price-service-client": "1.9.0"
59
49
  },
60
- "gitHead": "f14dd35d1abe0dc5e35752db4a77f4781d0a5c83"
61
- }
50
+ "scripts": {
51
+ "build": "tsc",
52
+ "example-relay": "node lib/examples/SuiRelay.js",
53
+ "test:lint": "eslint src/ --max-warnings 0",
54
+ "test:format": "prettier --check \"src/**/*.ts\"",
55
+ "fix:lint": "eslint src/ --fix --max-warnings 0",
56
+ "fix:format": "prettier --write \"src/**/*.ts\"",
57
+ "preversion": "pnpm run test:lint",
58
+ "version": "pnpm run format && git add -A src"
59
+ }
60
+ }