Skip to content

Commit fbbc56d

Browse files
committed
feat(pyth-sui-js): migrate to @mysten/sui v2 API
Migrate @pythnetwork/pyth-sui-js, the Sui CLI tooling, and contract_manager from @mysten/sui v1 to v2. Key changes: - Replace SuiClient with ClientWithCoreApi (transport-agnostic) in pyth-sui-js - Use provider.core.* namespace for all data access methods - BCS-encode dynamic field names as required by v2 - Update response handling for new object/json format - Move @mysten/sui to peerDependencies (^2.0.0) in pyth-sui-js - Update CLI to use SuiJsonRpcClient and fromBase64 - Migrate contract_manager to SuiJsonRpcClient for compatibility - Update contract_manager tsconfig moduleResolution to bundler - Narrow catch in getPriceFeedObjectId to only swallow not-found errors - Bump pyth-sui-js version from 3.0.0 to 4.0.0 Closes #3454
1 parent 059f890 commit fbbc56d

10 files changed

Lines changed: 307 additions & 97 deletions

File tree

contract_manager/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"@injectivelabs/networks": "^1.14.6",
99
"@iota/iota-sdk": "^0.5.0",
1010
"@mysten/move-bytecode-template": "^0.3.0",
11-
"@mysten/sui": "^1.3.0",
11+
"@mysten/sui": "^2.5.0",
1212
"@pythnetwork/client": "catalog:",
1313
"@pythnetwork/cosmwasm-deploy-tools": "workspace:*",
1414
"@pythnetwork/entropy-sdk-solidity": "workspace:*",

contract_manager/src/core/chains.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import type {
1313
MoveStruct as SuiMoveStruct,
1414
MoveValue as SuiMoveValue,
1515
SuiTransactionBlockResponseOptions,
16-
} from "@mysten/sui/client";
17-
import { SuiClient } from "@mysten/sui/client";
16+
} from "@mysten/sui/jsonRpc";
17+
import { SuiJsonRpcClient } from "@mysten/sui/jsonRpc";
1818
import { Ed25519Keypair as SuiEd25519Keypair } from "@mysten/sui/keypairs/ed25519";
1919
import { Transaction as SuiTransaction } from "@mysten/sui/transactions";
2020
import {
@@ -394,8 +394,11 @@ export class SuiChain extends Chain {
394394
).encode();
395395
}
396396

397-
getProvider(): SuiClient {
398-
return new SuiClient({ url: this.rpcUrl });
397+
getProvider(): SuiJsonRpcClient {
398+
return new SuiJsonRpcClient({
399+
url: this.rpcUrl,
400+
network: this.mainnet ? "mainnet" : "testnet",
401+
});
399402
}
400403

401404
getAccountAddress(privateKey: PrivateKey): Promise<string> {
@@ -611,7 +614,7 @@ export class SuiChain extends Chain {
611614
* `{ .., upgrade_cap: UpgradeCap }` convention.
612615
*/
613616
async getStatePackageInfo(
614-
client: SuiClient,
617+
client: SuiJsonRpcClient,
615618
stateId: string,
616619
): Promise<{
617620
package: string;
@@ -658,7 +661,7 @@ export class SuiChain extends Chain {
658661
}
659662

660663
private async getStateObject(
661-
client: SuiClient,
664+
client: SuiJsonRpcClient,
662665
stateId: string,
663666
): Promise<SuiMoveStruct> {
664667
const { data: stateObject, error } = await client.getObject({

contract_manager/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"compilerOptions": {
33
"module": "preserve",
4-
"moduleResolution": "node",
4+
"moduleResolution": "bundler",
55
"target": "ES2020",
66
},
77
"exclude": ["node_modules", "**/__tests__/*"],

0 commit comments

Comments
 (0)