-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from hyperlane-xyz/main-to-nexus
Main to nexus
- Loading branch information
Showing
34 changed files
with
383 additions
and
322 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
### About | ||
|
||
This folder contains pre-validated and processed configs for the the chains, tokens, and routes. | ||
The contents are auto-generated by the `yarn build:configs` command. Changes will be overridden on new builds. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ChainMap, ChainMetadata, MultiProtocolProvider } from '@hyperlane-xyz/sdk'; | ||
|
||
import type { RoutesMap } from '../features/routes/types'; | ||
import type { TokenMetadata } from '../features/tokens/types'; | ||
|
||
import Chains from './_chains.json'; | ||
import Routes from './_routes.json'; | ||
import Tokens from './_tokens.json'; | ||
|
||
export interface WarpContext { | ||
chains: ChainMap<ChainMetadata & { mailbox?: Address }>; | ||
tokens: TokenMetadata[]; | ||
routes: RoutesMap; | ||
multiProvider: MultiProtocolProvider<{ mailbox?: Address }>; | ||
} | ||
|
||
let warpContext: WarpContext; | ||
|
||
export function getWarpContext() { | ||
if (!warpContext) { | ||
warpContext = { | ||
chains: Chains as any, | ||
tokens: Tokens as any, | ||
routes: Routes as any, | ||
multiProvider: new MultiProtocolProvider<{ mailbox?: Address }>(Chains as any), | ||
}; | ||
} | ||
return warpContext; | ||
} | ||
|
||
export function setWarpContext(context: WarpContext) { | ||
warpContext = context; | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { useMemo } from 'react'; | ||
|
||
import { getChainIdFromToken } from '../caip/tokens'; | ||
import { getTokens } from '../tokens/metadata'; | ||
|
||
import { RoutesMap } from './types'; | ||
|
||
export function useRouteChains(tokenRoutes: RoutesMap): ChainCaip2Id[] { | ||
return useMemo(() => { | ||
const allCaip2Ids = Object.keys(tokenRoutes) as ChainCaip2Id[]; | ||
const collateralCaip2Ids = getTokens().map((t) => getChainIdFromToken(t.tokenCaip19Id)); | ||
return allCaip2Ids.sort((c1, c2) => { | ||
// Surface collateral chains first | ||
if (collateralCaip2Ids.includes(c1) && !collateralCaip2Ids.includes(c2)) return -1; | ||
else if (!collateralCaip2Ids.includes(c1) && collateralCaip2Ids.includes(c2)) return 1; | ||
else return c1 > c2 ? 1 : -1; | ||
}); | ||
}, [tokenRoutes]); | ||
} |
File renamed without changes.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.