feat(pyth-sui-js): migrate to @mysten/sui v2 API#3502
feat(pyth-sui-js): migrate to @mysten/sui v2 API#35020xCryptoZen wants to merge 1 commit intopyth-network:mainfrom
Conversation
|
@0xCryptoZen is attempting to deploy a commit to the Pyth Network Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3bba8900b7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| throw new Error(`Cannot fetch package id for object ${objectId}`); | ||
| }); | ||
| const result = await this.provider.core.getObject({ |
There was a problem hiding this comment.
Preserve compatibility with existing Sui providers
This change unconditionally dereferences provider.core, but internal consumers in this repo still instantiate SuiPythClient via SuiChain.getProvider() in contract_manager/src/core/chains.ts while contract_manager/package.json is pinned to @mysten/sui ^1.3.0; that provider shape does not expose core. In that existing path (contract_manager/src/core/contracts/sui.ts), calls like getPackageId() now fail immediately with a runtime undefined property error instead of performing an RPC call.
Useful? React with 👍 / 👎.
| } catch { | ||
| // Dynamic field not found | ||
| return undefined; |
There was a problem hiding this comment.
Propagate non-not-found dynamic field errors
The broad catch here converts every getDynamicObjectField failure into undefined, so network timeouts, auth issues, and malformed responses are all misreported as “feed not found.” That masks real outages and can push callers into incorrect create/update behavior instead of surfacing the underlying RPC failure; only the explicit not-found case should be mapped to undefined.
Useful? React with 👍 / 👎.
3bba890 to
552e7b4
Compare
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 pyth-network#3454
552e7b4 to
fbbc56d
Compare
Re: P1 — Preserve compatibility with existing Sui providersAddressed.
Type-checking passes for both Re: P2 — Propagate non-not-found dynamic field errorsAddressed. The broad } catch (e: unknown) {
const msg = e instanceof Error ? e.message : String(e);
if (
msg.includes("Could not find the referenced object") ||
msg.includes("dynamicFieldNotFound") ||
msg.includes("not found")
) {
return undefined;
}
throw e;
} |
|
@https://github.com/codex review |
|
@devin-ai-integration please review this PR |
Summary
@pythnetwork/pyth-sui-jsfrom@mysten/suiv1 to v2, replacingSuiClientwith the transport-agnosticClientWithCoreApiinterface and updating all API calls to the newprovider.core.*namespace@mysten/suifrom direct dependency topeerDependencies: "^2.0.0"so consumers can choose their preferred transport (JSON-RPC, gRPC, or GraphQL)pyth_deploy.ts,upgrade_pyth.ts) to useSuiJsonRpcClientand the renamedfromBase64utility@pythnetwork/pyth-sui-jsversion from3.0.0to4.0.0(breaking change)Key migration details
SuiClient→ClientWithCoreApi(from@mysten/sui/client)provider.getObject()→provider.core.getObject()with{ include: { json: true } }instead of{ options: { showContent: true } }provider.getDynamicFieldObject()→provider.core.getDynamicObjectField()with BCS-encoded field namesresult.data.content.fields.x→result.object.json.xSuiGrpcClientwith the new transaction result formatCloses #3454
Test plan
client.tsagainst@mysten/sui@2.5.0getBaseUpdateFee(),getPackageId(),getPriceFeedObjectId()SuiRelay.tsexample works withSuiGrpcClientSuiJsonRpcClient