From 89fef3c41cdf56c2b14a360e9c0e78de8e286851 Mon Sep 17 00:00:00 2001 From: Pavan Soratur Date: Fri, 25 Oct 2024 10:15:18 -0700 Subject: [PATCH] fix(tangle-dapp): Fix disabled bridge transfer button (#2605) Co-authored-by: Pavan Soratur --- .../lib/hyperlane/assembleChainMetadata.ts | 46 +------------ apps/tangle-dapp/lib/hyperlane/consts.ts | 67 ++++++++++++++++++- 2 files changed, 68 insertions(+), 45 deletions(-) diff --git a/apps/tangle-dapp/lib/hyperlane/assembleChainMetadata.ts b/apps/tangle-dapp/lib/hyperlane/assembleChainMetadata.ts index 4d0c2cf46..1699a67e2 100644 --- a/apps/tangle-dapp/lib/hyperlane/assembleChainMetadata.ts +++ b/apps/tangle-dapp/lib/hyperlane/assembleChainMetadata.ts @@ -1,11 +1,9 @@ -import { chainMetadata, GithubRegistry } from '@hyperlane-xyz/registry'; +import { GithubRegistry } from '@hyperlane-xyz/registry'; import { ChainMap, ChainMetadata, ChainMetadataSchema, - ChainTechnicalStack, } from '@hyperlane-xyz/sdk'; -import { ProtocolType } from '@hyperlane-xyz/utils'; import { z } from 'zod'; import { registryUrl } from './config'; @@ -13,8 +11,6 @@ import { customChains } from './consts'; export default async function assembleChainMetadata() { const result = z.record(ChainMetadataSchema).safeParse({ - // Note: Chains must include a cosmos chain or CosmosKit throws errors - cosmoshub: cosmosDefaultChain, ...customChains, }); @@ -25,46 +21,8 @@ export default async function assembleChainMetadata() { const customChainMetadata = result.data as ChainMap; const registry = new GithubRegistry({ uri: registryUrl }); - let defaultChainMetadata = chainMetadata; - if (registryUrl) { - defaultChainMetadata = await registry.getMetadata(); - } else { - // Note: this is an optional optimization to pre-fetch the content list - // and avoid repeated request from the chain logos that will use this info - await registry.listRegistryContent(); - } - - const chains = { ...defaultChainMetadata, ...customChainMetadata }; - // Handle invalid ChainTechnicalStack values - ex: opstack - Object.entries(chains).forEach(([_chainName, chain]) => { - if ( - typeof chain.technicalStack === 'string' && - !Object.values(ChainTechnicalStack).includes(chain.technicalStack) - ) { - chain.technicalStack = ChainTechnicalStack.Other; - } - }); + const chains = customChainMetadata; return { chains, registry }; } - -const cosmosDefaultChain: ChainMetadata = { - protocol: ProtocolType.Cosmos, - name: 'cosmoshub', - chainId: 'cosmoshub-4', - displayName: 'Cosmos Hub', - domainId: 1234, - bech32Prefix: 'cosmos', - slip44: 118, - grpcUrls: [{ http: 'grpc-cosmoshub-ia.cosmosia.notional.ventures:443' }], - rpcUrls: [{ http: 'https://rpc-cosmoshub.blockapsis.com' }], - restUrls: [{ http: 'https://lcd-cosmoshub.blockapsis.com' }], - nativeToken: { - name: 'Atom', - symbol: 'ATOM', - decimals: 6, - denom: 'uatom', - }, - logoURI: '/logos/cosmos.svg', -}; diff --git a/apps/tangle-dapp/lib/hyperlane/consts.ts b/apps/tangle-dapp/lib/hyperlane/consts.ts index 6bee574dc..7a3bdce5f 100644 --- a/apps/tangle-dapp/lib/hyperlane/consts.ts +++ b/apps/tangle-dapp/lib/hyperlane/consts.ts @@ -1,11 +1,76 @@ import { ChainMap, ChainMetadata, + ExplorerFamily, TokenStandard, WarpCoreConfig, } from '@hyperlane-xyz/sdk'; +import { ProtocolType } from '@hyperlane-xyz/utils'; -export const customChains: ChainMap = {}; +export const customChains: ChainMap = { + holesky: { + blockExplorers: [ + { + apiUrl: 'https://api-holesky.etherscan.io/api', + family: ExplorerFamily.Etherscan, + name: 'Etherscan', + url: 'https://holesky.etherscan.io', + }, + ], + blocks: { + confirmations: 1, + estimateBlockTime: 13, + reorgPeriod: 2, + }, + chainId: 17000, + displayName: 'Holesky', + domainId: 17000, + isTestnet: true, + name: 'holesky', + nativeToken: { + decimals: 18, + name: 'Ether', + symbol: 'ETH', + }, + protocol: ProtocolType.Ethereum, + rpcUrls: [ + { + http: 'https://ethereum-holesky-rpc.publicnode.com', + }, + ], + }, + tangletestnet: { + blockExplorers: [ + { + apiUrl: 'https://testnet-explorer.tangle.tools/api', + family: ExplorerFamily.Blockscout, + name: 'Tangle Testnet Explorer', + url: 'https://testnet-explorer.tangle.tools', + }, + ], + blocks: { + confirmations: 4, + estimateBlockTime: 6, + reorgPeriod: 4, + }, + chainId: 3799, + displayName: 'Tangle Testnet', + domainId: 3799, + isTestnet: true, + name: 'tangletestnet', + nativeToken: { + decimals: 18, + name: 'Tangle Testnet Token', + symbol: 'tTNT', + }, + protocol: ProtocolType.Ethereum, + rpcUrls: [ + { + http: 'https://testnet-rpc.tangle.tools', + }, + ], + }, +}; // A list of Warp Route token configs // These configs will be merged with the warp routes in the configured registry