-
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.
Move config management to build-time (#120)
- Refactor chain, token, and route config management into build-time script - Combine chain, token, and route state into single `WarpContext` var - Fix outdated `publicRpcUrls` field in example chain config
- 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { IbcRoute, IbcToWarpRoute } from '../features/tokens/routes/types'; | ||
import { IbcRoute, IbcToWarpRoute } from '../features/routes/types'; | ||
|
||
// Configs for manually-defined IBC-only routes | ||
export const ibcRoutes: Array<IbcRoute | IbcToWarpRoute> = []; |
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.
22fb637
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
hyperlane-warp-template – ./
hyperlane-warp-template-abacus-works.vercel.app
hyperlane-warp-template.vercel.app
hyperlane-warp-template-git-main-abacus-works.vercel.app