feat(mango): extract mango client#1087
Conversation
|
@rogaldh is attempting to deploy a commit to the Solana Foundation Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR extracts the Mango v3 program decoder into a self-contained
Confidence Score: 5/5Safe to merge — this is a pure internal extraction with no user-facing behaviour change and all prior review concerns addressed. The change is a well-scoped refactor moving existing, battle-tested Mango decoder logic into a dedicated workspace package. The three issues from prior review threads (cluster-keyed cache, null guard on perp market account, and RPC rejection poisoning the cache) are all resolved in the new code. The two remaining observations (stray packages/decoder-mango/src/market.ts — the spot market fetch path has no caching counterpart to the perp market accountInfoCache. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[TransactionInstruction] --> B[isMangoInstruction\ndetection.ts]
B -->|true| C[MangoDetailsCard]
C --> D[parseMangoInstructionTitle\ndetection.ts]
D --> E{Switch on title}
E -->|PlacePerpOrder / PlacePerpOrder2| F[PlacePerpOrder*DetailsCard]
E -->|PlaceSpotOrder| G[PlaceSpotOrderDetailsCard]
E -->|ChangePerpMarketParams| H[ChangePerpMarketParamsDetailsCard]
E -->|AddSpotMarket| I[AddSpotMarketDetailsCard]
E -->|Other Mango variants| J[Generic*DetailsCard]
E -->|Unknown| K[Raw InstructionCard]
F --> L[getPerpMarketFromInstruction\nmarket.ts]
G --> M[getSpotMarketFromInstruction\nmarket.ts]
H --> L
L --> N[useMangoPerpMarket hook\nuse-mango-market.ts]
M --> O[useMangoSpotMarket hook\nuse-mango-market.ts]
N --> P[getPerpMarketFromPerpMarketConfig\nmarket.ts]
O --> Q[getSpotMarketFromSpotMarketConfig\nmarket.ts]
P --> R[(accountInfoCache\nmodule-level)]
R -->|cache miss| S[Connection.getAccountInfo RPC]
Q --> T[Market.load RPC\nno cache]
subgraph decoder-mango package
D
L
M
P
Q
R
end
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[TransactionInstruction] --> B[isMangoInstruction\ndetection.ts]
B -->|true| C[MangoDetailsCard]
C --> D[parseMangoInstructionTitle\ndetection.ts]
D --> E{Switch on title}
E -->|PlacePerpOrder / PlacePerpOrder2| F[PlacePerpOrder*DetailsCard]
E -->|PlaceSpotOrder| G[PlaceSpotOrderDetailsCard]
E -->|ChangePerpMarketParams| H[ChangePerpMarketParamsDetailsCard]
E -->|AddSpotMarket| I[AddSpotMarketDetailsCard]
E -->|Other Mango variants| J[Generic*DetailsCard]
E -->|Unknown| K[Raw InstructionCard]
F --> L[getPerpMarketFromInstruction\nmarket.ts]
G --> M[getSpotMarketFromInstruction\nmarket.ts]
H --> L
L --> N[useMangoPerpMarket hook\nuse-mango-market.ts]
M --> O[useMangoSpotMarket hook\nuse-mango-market.ts]
N --> P[getPerpMarketFromPerpMarketConfig\nmarket.ts]
O --> Q[getSpotMarketFromSpotMarketConfig\nmarket.ts]
P --> R[(accountInfoCache\nmodule-level)]
R -->|cache miss| S[Connection.getAccountInfo RPC]
Q --> T[Market.load RPC\nno cache]
subgraph decoder-mango package
D
L
M
P
Q
R
end
Reviews (9): Last reviewed commit: "feat: improve handling cached exceptions" | Re-trigger Greptile |
|
@greptile-apps issues were addressed |
Description
Extracts the Mango program decoder out of the app into a dedicated
@explorer/decoder-mangopnpm workspace package, and wires that package into the root tooling.packages/decoder-mango(with its own tests,tsconfig, andvitestconfig); the app consumes it via@explorer/decoder-mango.app/features/instruction-program-mango; market lookups moved behinduseMangoPerpMarket/useMangoSpotMarkethooks, with the data sourced from the decoder package.build/test/typecheckdelegate to their*:packagescounterparts, whilelint/formatalready traversepackages/*through the shared config (built output excluded).No user-facing behaviour change — the cards render identically.
Type of change
Internal refactor — extracting a self-contained workspace package and integrating it into the build/test/lint/typecheck tooling. No behavioural change.
Screenshots
No visual changes — the Mango instruction cards keep their existing markup and render identically; this is an internal extraction.
Testing
packages/decoder-mangoships unit tests for the config, decoder, detection, and market logic (46 tests), plus tests for theuse-mango-markethooks.pnpm lint,pnpm typecheck,pnpm build, andpnpm test:packageslocally; the apptsc --noEmitis clean.typecheck:packages, etc.) run the package's own checks.Related Issues
HOO-452
Checklist
pnpm test,pnpm lint,pnpm typecheck)build:infoscript to update build information