chore(admin): move admin reads to gRPC and drop the JSON-RPC client - #96
Conversation
jangid
left a comment
There was a problem hiding this comment.
operate.md: clean — lint/test/build green, no unresolved security findings, no open change-requests. Read the four migrated helpers against the diff: the two getObject sites correctly drop the JSON-RPC {type, fields} nesting for the flat gRPC json shape, and the addExternalRewardsWalLockedTxb cap lookup is strictly tighter than before (exact ::alphalend_slush_pool::AdminCap type filter server-side, replacing a MoveModule filter plus client-side includes match). Type ids are built from the first package ids, which is right — on-chain type tags keep the original package address across upgrades. The mainnet side-by-side parity output in the description is the evidence this needed.
Coordination note, not a blocker: grpcUrl on AlphaFiSDKConfig is what AlphaFiTech/alphafi-admin#33 is currently red on (TS2353: 'grpcUrl' does not exist in type 'AlphaFiSDKConfig'), so that PR needs this merged and published before its typecheck can pass.
Approvals: 2/2 — threshold met.
Removes the JSON-RPC client from this SDK. Four admin helpers were the only remaining users; they now read over gRPC, so
pythSuiClientand the@mysten/sui/jsonRpcdependency are gone.Motivation: JSON-RPC is deprecated on Sui public fullnodes, and keeping it meant every consumer had to configure a second endpoint for these four functions alone.
Migrated
getRebalanceCapgetOwnedObjects({filter: {StructType}})core.listOwnedObjects({owner, type})addExternalRewardsWalLockedTxbgetOwnedObjects({filter: {MoveModule}})+ client-side type filtercore.listOwnedObjectson the exactAdminCaptypegetWithdrawRequestsAndUnsuppliedAmountgetObject({showContent})core.getObject({include: {json}})getWalLockedRewardInfogetObject({showContent})core.getObject({include: {json}})The two
getObjectsites needed re-parsing, not just a transport swap: JSON-RPC wraps nested Move structs as{type, fields: {...}}while gRPC renders them flat. Scalars are identical.Verified against mainnet — both parsers run side by side on the live objects, output compared:
The AlphaVault pool had 4 real withdraw requests at the time, so the nested
VecMappath (contents[].key/contents[].value.leftover_amount) is exercised rather than short-circuiting on an empty list — worth stating because the failure mode here is silent: the old?.fields?.contents ?? []against a flat payload yields[]and renders an empty screen with no error.getWalLockedRewardInfoalready had??fallbacks that tolerated both shapes, so it was correct either way; it is now written for the one shape it uses.Also:
grpcUrlis plumbed throughAlphaFiSDKConfig→StrategyContext→Blockchain, so consumers can point object reads at their own endpoint instead of the built-in public-fullnode default. It was previously reachable only by mutatingblockchain.suiGrpcClientafter construction, and not at all throughAlphaFiSDK, whosestrategyContextis private.graphqlUrlis untouched — rpcpool does not serve the Sui GraphQL schema, sogqlClientcannot move with the rest.Breaking:
Blockchain.pythSuiClientandBlockchainOptions.pythSuiClientare removed. alphafi-admin is the only consumer I found; its matching change is in alphafi-admin#33.tsc --noEmit,npm run buildand the pre-commit hooks are clean.npm testreports no tests configured.