Skip to content

refactor(apriori): move the aprMON ABI to the explorer tier - #198

Merged
nishuzumi merged 2 commits into
nishuzumi:mainfrom
zkasuran:apriori-explorer-tier
Sep 16, 2026
Merged

nishuzumi merged 2 commits into
nishuzumi:mainfrom
zkasuran:apriori-explorer-tier

Conversation

@zkasuran

Copy link
Copy Markdown
Contributor

What and why

The aprMON EIP-1967 implementation 0x7D2F8dc5a67CA1911bb1A2429552CDf507d106F2 is now verified on MonadScan (contract aprMON, compiler v0.8.28+commit.7893614a, exact bytecode match). ADR 0007 orders ABI provenance compiled > explorer > vendored and moves a vendored ABI up once the chain allows a live explorer cross-check. The chain now allows one, so this moves @themoss/protocol-apriori from the vendored tier to the explorer tier. Closes #197.

src/abis/apriori.ts is now the full implementation ABI fetched from the explorer and committed as typed as const, generated by renderAbiModule from a scripts/abis.ts source table, replacing the curated hand-vendored signature list. The full artifact also brings in the viewRedeemRequest and getUserRequestData view helpers the curated ABI never carried.

Type of change

  • Protocol / Capability / Query
  • Core / simulator / MCP server
  • Bug fix
  • Documentation / example
  • Tooling / dependency

Framework and package impact

@themoss/protocol-apriori only. The exported AprMonAbi becomes the full explorer ABI (165 entries) instead of the 11-entry curated list. Every function and event the adapter uses keeps its signature and the three decoded events keep their parameter names, so the Capabilities, Receipt parsers and typed Handles are unchanged. No change to the MCP composition. Adds a tsx devDependency and an update:abis script, matching the other explorer-tier packages.

Verification

  • pnpm build
  • pnpm typecheck
  • pnpm lint
  • pnpm test
  • User-facing package changes include a changeset
  • Docs and examples match the implemented API

Protocol changes

  • Parameters separate reusable Zod value types from field-purpose descriptions
  • Every Capability owns one direct TransactionNode and one typed Receipt
  • Receipt tests preserve every original Change object in exact length and order
  • Positive and @ts-expect-error fixtures cover exported type behavior
  • Fixed addresses and ABIs include sources and verification
  • A live Monad happy path returns zero Warnings

Evidence

  • pnpm --filter @themoss/protocol-apriori test:abi:online (keyed, Monad mainnet) passes 7/7: proxy pin, deployed bytecode, the EIP-1967 slot resolving to the recorded implementation, on-chain name/symbol/decimals against the exported constants, a convertToShares/convertToAssets round-trip and compareDeployedAbi(AprMonAbi, fetchAbi(implementation)) returning zero issues.
  • pnpm --filter @themoss/protocol-apriori test passes 23/23 including the live stake and unstake simulations with zero Warnings, plus the chain-derived Redeem-tx fixture, all against the full ABI.
  • Offline test/abis.test.ts asserts the committed module is exact renderAbiModule output, so a hand-edit or a drift fails closed. abis.json pins the proxy/implementation pair with an empty allowedExplorerOnly.

AI assistance (Claude, Anthropic) was used in developing this change. The design, review and verification were done by the author. Verified locally before submitting: pnpm build, pnpm typecheck, pnpm lint, pnpm test (23/23, including the live Monad stake and unstake simulations) and the keyed pnpm --filter @themoss/protocol-apriori test:abi:online (7/7) all pass.

The aprMON implementation is verified on MonadScan, so the ABI moves from the vendored tier to the explorer tier per ADR 0007. The full implementation ABI is fetched from the explorer and committed as typed as const via update:abis. An offline test asserts it is exact renderAbiModule output and a keyed online test cross-checks it against the verified implementation with compareDeployedAbi. The exported AprMonAbi now includes the viewRedeemRequest and getUserRequestData view helpers.
…ish the explorer-tier wording

- test/abis.test.ts asserts SOURCES fetches the implementation abis.json
  pins, so the offline derivation and the keyed cross-check cannot point
  at different contracts; drop the dead fallbacks.
- test-online keeps the implementation bytecode check the deleted
  selector test used to carry.
- vitest.online.config.ts describes the keyed suite; README states what
  the offline test does and does not defend.
- Changeset minor: the exported AprMonAbi widens from 11 to 165 entries.

@nishuzumi nishuzumi left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Audited exact head 709f8cea against main@8a3bc89, plus my follow-up commit.

The tier switch is correct and complete for #197: the committed 165-entry artifact is byte-for-byte the explorer ABI MonadScan serves for 0x7D2F… today (independently fetched and compared), every one of the eleven previously vendored signatures has an identical entry (indexed layouts included; only the two convertTo* outputs gained names), and the keyed compareDeployedAbi cross-check fails closed on added/removed/changed entries and on any indexed flip. #192's real-log Redeem tests still fail on a mutated layout against the full artifact, so the offline suite keeps a content anchor for the three decoded events. Type cost is unchanged (fewer instantiations than the parseAbi string parsing it replaces); dist/index.d.ts grows to 61 KB, in line with kuru.

Deleting the bytecode selector/topic test was the right call — against exact-match verified source it adds nothing compareDeployedAbi lacks and cannot see indexed or outputs — so I did not ask for it back.

Pushed before the squash:

  • test/abis.test.ts now asserts SOURCES[0].address === abis.json.aprMon.implementation (#197 item 4); a typo'd source address that MonadScan still knows would otherwise render a valid module and stay green offline. Dead ?? fallbacks removed.
  • the online suite keeps the implementation-bytecode check that lived inside the deleted selector test.
  • vitest.online.config.ts no longer describes the suite as keyless/vendored/"tracked in #197" (item 5), and the README states precisely what the offline test defends: canonical rendering and the recorded address, not ABI content, which the keyed cross-check and the real-log test cover.
  • Changeset minor: AprMonAbi is a public export and widens.

Verification: frozen install, lint, build, typecheck, offline suite; apriori live 23/23 with zero-Warning stake/unstake simulations; keyed test:abi:online 7/7. Remaining live failures (Aave #201, Kuru #194) are baseline.

@nishuzumi
nishuzumi merged commit 4e3b985 into nishuzumi:main Sep 16, 2026
1 of 2 checks passed
@nishuzumi

Copy link
Copy Markdown
Owner

@zkasuran merged as 4e3b985; #197 closed. The review comment has the details of the follow-up commit I squashed in (SOURCES↔abis.json assertion, implementation bytecode check kept, config/README wording, changeset minor). aPriori is the third explorer-tier package after kuru and pancakeswap — thanks for carrying this from the #159 search through to the switch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

apriori: move the aprMON ABI to the explorer tier now that the implementation is verified

2 participants