Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tangle-dapp): Fix disabled bridge transfer button #2605

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading