feat(statics): ERC-7984 statics registry for wrapper↔underlying pairs - #9459
Draft
bitgo-ai-agent-dev[bot] wants to merge 3 commits into
Draft
feat(statics): ERC-7984 statics registry for wrapper↔underlying pairs#9459bitgo-ai-agent-dev[bot] wants to merge 3 commits into
bitgo-ai-agent-dev[bot] wants to merge 3 commits into
Conversation
…airs Introduce erc7984Registry.ts in @bitgo/statics with per-network static configuration for ERC-7984 confidential wrapper↔underlying ERC-20 pairs. Each entry records: - wrapperAddress / underlyingErc20Address (checksummed-lowercase hex) - rate (underlying base units per wrapper base unit, bigint ≥ 1) - requiresApprovalReset (USDT-pattern ERC-20s that need a 0-allowance reset) - isVetted / isActive (gating flags for live shield/unshield eligibility) Wire Hoodi testnet pairs (hteth:ctest1, hteth:cusdt) and all six Ethereum mainnet pairs (eth:czama, eth:cxaut, eth:ctgbp, eth:cweth, eth:cusdt, eth:cusdc). Export getWrapperPair() and getActiveWrapperPairs() helpers for calldata builders that need the underlying address or approval-reset semantics at tx-build time. Unit tests cover: shape invariants, uniqueness within network, case- insensitive address lookup, happy-path lookups for Hoodi and mainnet, and unknown-network/unknown-address fallbacks. Ticket: CHALO-1156 Session-Id: 4d410361-d10d-4cbb-b8fa-1a76aad1adcc Task-Id: 0df7e500-dcfa-4bdc-83de-b3a56aa5dd09
Address review findings from post-commit review agents: - Freeze the registry object, per-network arrays, and pair objects with Object.freeze() so callers cannot corrupt the module-level singleton. - Add readonly modifiers to all Erc7984WrapperPair interface fields and tighten Erc7984Registry / getActiveWrapperPairs return types to use ReadonlyArray so TypeScript propagates immutability to callers. - Add a module-load-time validateRegistry() IIFE that throws on invalid wrapperAddress/underlyingErc20Address format, rate < 1n, or duplicate wrapper addresses within a network — catches bad entries before any caller sees them. - Guard getWrapperPair against null/undefined/empty wrapperAddress so JS callers cannot trigger a TypeError from .toLowerCase() on a falsy value. - Normalize both sides of the address comparison (p.wrapperAddress is already lowercase in the registry, lower is the lowercased input) so future mixed-case entries still resolve correctly. - Expand unit tests: immutability assertion, null wrapperAddress guard, empty wrapperAddress guard, and two explicit filter-exclusion tests (isVetted=false excluded, isActive=false excluded) to cover the filter predicate that was previously exercised only on all-true data. Ticket: CHALO-1156 Session-Id: 4d410361-d10d-4cbb-b8fa-1a76aad1adcc Task-Id: 0df7e500-dcfa-4bdc-83de-b3a56aa5dd09
Contributor
ralph-bitgo
Bot
force-pushed
the
chalo-1156-erc7984-statics-registry
branch
from
August 10, 2026 09:13
846cf0e to
a22afb7
Compare
bitgo-ai-agent-dev
Bot
force-pushed
the
chalo-1156-erc7984-statics-registry
branch
from
August 10, 2026 09:13
a22afb7 to
b4f29f6
Compare
Prettier check was failing in CI because two files had lines exceeding the project's print-width limit. Auto-fixed by running `yarn fmt` in modules/statics — no logic changes. Ticket: CHALO-1156 Session-Id: d928878d-20db-4ab7-bbef-bfda0854f79c Task-Id: f43b12b1-fbfc-411d-9c9a-83b869fb7df3
ralph-bitgo
Bot
force-pushed
the
chalo-1156-erc7984-statics-registry
branch
from
August 10, 2026 11:43
3b1ea6b to
ec9d0f0
Compare
bitgo-ai-agent-dev
Bot
force-pushed
the
chalo-1156-erc7984-statics-registry
branch
from
August 10, 2026 11:43
ec9d0f0 to
8667104
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
modules/statics/src/erc7984Registry.ts— a new per-network static registry for ERC-7984 (Zama fhEVM) confidential token wrapper↔underlying ERC-20 pairswrapperAddress,underlyingErc20Address,rate(bigint, ≥ 1),requiresApprovalReset(USDT-pattern flag),isVetted, andisActivehteth:ctest1,hteth:cusdt) and six Ethereum mainnet pairs (eth:czama,eth:cxaut,eth:ctgbp,eth:cweth,eth:cusdt,eth:cusdc)getWrapperPair(networkName, wrapperAddress)andgetActiveWrapperPairs(networkName)helpers for calldata builders that need the underlying address or approval-reset semantics at tx-build timeObject.freeze()-d;Erc7984WrapperPairfields are allreadonly; return types useReadonlyArrayvalidateRegistry()throws on bad address format,rate < 1n, or duplicate wrapper addresses within a networkgetWrapperPairguards againstnull/undefined/emptywrapperAddresswithout crashing; address lookup is case-insensitivemodules/statics/src/index.tsmodules/statics/test/unit/erc7984Registry.tscovering: shape invariants, uniqueness, immutability, case-insensitive lookup, happy-path lookups for Hoodi + mainnet,null/empty address guards, unknown-network fallbacks, and filter-exclusion forisVetted=false/isActive=falsepairsWhy
buildApproveCalldata,buildWrapCalldata, andbuildUnwrapCalldatacan look up the correct underlying ERC-20 address and know whether to reset the USDT allowance to 0 before approving a new amountTest plan
modules/staticsunit tests pass:yarn unit-test --scope @bitgo/statics(the pre-existingcoins.tsfailure due to missing@bitgo/sdk-corecompiled artifacts in CI is unrelated to this diff and exists onmaster)cd modules/statics && npx tsc --noEmitgetWrapperPairreturns correct pair forhteth:cusdtwith mixed-case address inputgetActiveWrapperPairsreturns 2 Hoodi pairs and 6 mainnet pairsTicket: CHALO-1156