Skip to content

Commit

Permalink
fix(tangle-dapp): Fix disabled bridge transfer button (#2605)
Browse files Browse the repository at this point in the history
Co-authored-by: Pavan Soratur <[email protected]>
  • Loading branch information
devpavan04 and Pavan Soratur authored Oct 25, 2024
1 parent 98053a6 commit 89fef3c
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 45 deletions.
46 changes: 2 additions & 44 deletions apps/tangle-dapp/lib/hyperlane/assembleChainMetadata.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
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';
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,
});

Expand All @@ -25,46 +21,8 @@ export default async function assembleChainMetadata() {
const customChainMetadata = result.data as ChainMap<ChainMetadata>;

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',
};
67 changes: 66 additions & 1 deletion apps/tangle-dapp/lib/hyperlane/consts.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,76 @@
import {
ChainMap,
ChainMetadata,
ExplorerFamily,
TokenStandard,
WarpCoreConfig,
} from '@hyperlane-xyz/sdk';
import { ProtocolType } from '@hyperlane-xyz/utils';

export const customChains: ChainMap<ChainMetadata> = {};
export const customChains: ChainMap<ChainMetadata> = {
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
Expand Down

0 comments on commit 89fef3c

Please sign in to comment.