Repository navigation
feat(aggkit): resolve token origin and wrapped tokens on-chain - #43
Merged
Merged
Conversation
Add AggkitBridgeAggregator.getTokenOrigin and getWrappedTokens, built on the bridge's wrappedTokenToTokenInfo and getTokenWrappedAddress reads. They let a UI map a token known on one network to its address on another without depending on bridge-service sync state. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
Author
|
@claude review |
- getTokenOrigin: answer the native token (zero address) without an on-chain read - getWrappedTokens: report the native token on another network as error instead of absent; reuse one Bridge reader per call; return only originNetwork/originTokenAddress from each input Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
arnaubennassar
approved these changes
Oct 6, 2026
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.
Context
Needed by agglayer/agglayer-dev-ui#31: when the user changes "Bridge from", the UI must show the tokens it already knows in their wrapped version on that network, even when the wrapped token was created after the token was added.
Changes
Two on-chain helpers on
AggkitBridgeAggregator, built on readsnative/bridgealready exposes:getTokenOrigin(tokenAddress, networkId)readswrappedTokenToTokenInfoon that network's bridge and returns{ originNetwork, originTokenAddress, isWrapped }. A zero origin address means the token originates on that network (origin network0is L1 and is valid).getWrappedTokens({ networkId, origins })readsgetTokenWrappedAddressfor each origin and returnsfound/absent/errorper entry, in order. One failing lookup does not reject the batch. IfnetworkIdis the token's origin network no call is made.Why on-chain and not
/token-mappings: it does not depend on a bridge-service syncer being up to date (a lagging syncer would answer "no mapping" for a wrapped token that exists) and needs no aggkit change.absentis not final: the wrapped token appears after the first bridge to that network.getTokenOrigindoes not prove the address is a token (an unknown address also reads as "not wrapped"); callers validate first, e.g. withgetTokenMetadata. Both methods need the network registered with abridgeAddress.Also bumps the version to
1.0.0-beta.33, following the repo's convention.Testing
npx vitest run: 213 tests pass, 8 of them new (origin: wrapped / not wrapped / no bridge address; wrapped tokens: found+absent+origin-network short-circuit, per-entry error, no bridge address).tsc --noEmitclean.Not verified: reads against a live network. The lint-staged hook reformats the whole of
types.ts; I dropped that in a separate commit, as an earlier PR did.🤖 Generated with Claude Code