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

The getViemChain function should use chain in the chainsConfig #1498

Merged
merged 1 commit into from
Aug 4, 2023
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
1 change: 1 addition & 0 deletions libs/dapp-config/src/chains/evm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ const additionalRpcUrls = {
[PresetTypedChainId.MoonbaseAlpha]: [
'https://moonbase-alpha.public.blastapi.io',
'https://moonbeam-alpha.api.onfinality.io/public',
'https://moonbase.unitedbloc.com:1000',
],
[PresetTypedChainId.Sepolia]: [
'https://endpoints.omniatech.io/v1/eth/sepolia/public',
Expand Down
10 changes: 8 additions & 2 deletions libs/web3-api-provider/src/utils/getViemClient.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import { parseTypedChainId } from '@webb-tools/sdk-core';
import { PublicClient, createPublicClient, fallback, http } from 'viem';
import { Chain, PublicClient, createPublicClient, fallback, http } from 'viem';
import {
VIEM_NOT_SUPPORTED_MULTICALL_CHAINS,
defineViemChain,
getViemChain,
} from './getViemChain';
import { chainsConfig } from '@webb-tools/dapp-config/chains/evm';

function getViemClient(typedChainId: number): PublicClient {
const { chainId } = parseTypedChainId(typedChainId);

let chain = getViemChain(chainId);
let chain: Chain | undefined = chainsConfig[typedChainId];

if (!chain) {
chain = getViemChain(typedChainId);
}

if (!chain || VIEM_NOT_SUPPORTED_MULTICALL_CHAINS.includes(chainId)) {
chain = defineViemChain(typedChainId);
}
Expand Down
17 changes: 12 additions & 5 deletions tools/scripts/fetchingOnChainConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path';
import { workspaceRoot } from 'nx/src/utils/workspace-root';
import { config } from 'dotenv';
import { workspaceRoot } from 'nx/src/utils/workspace-root';
import path from 'path';

config({
path: path.join(workspaceRoot, '.env'),
Expand All @@ -11,12 +11,12 @@ config({
});

import { ApiPromise } from '@polkadot/api';
import merge from 'lodash/merge';
import {
anchorDeploymentBlock,
parsedAnchorConfig,
} from '@webb-tools/dapp-config/src/anchors/anchor-config';
import { chainsConfig } from '@webb-tools/dapp-config/src/chains/chain-config';
import { DEFAULT_NATIVE_INDEX } from '@webb-tools/dapp-config/src/constants';
import {
AnchorMetadata,
ConfigType,
Expand All @@ -27,14 +27,14 @@ import {
ChainType,
parseTypedChainId,
} from '@webb-tools/sdk-core/typed-chain-id';
import { ZERO_ADDRESS } from '@webb-tools/utils';
import evmProviderFactory from '@webb-tools/web3-api-provider/src/utils/evmProviderFactory';
import fs from 'fs';
import { Listr, color } from 'listr2';
import merge from 'lodash/merge';
import { ON_CHAIN_CONFIG_PATH } from './constants';
import fetchAnchorMetadata from './utils/on-chain-utils/fetchAnchorMetadata';
import mergeConfig from './utils/on-chain-utils/mergeConfig';
import { ZERO_ADDRESS } from '@webb-tools/utils';
import { DEFAULT_NATIVE_INDEX } from '@webb-tools/dapp-config/src/constants';

const configPath = path.join(workspaceRoot, ON_CHAIN_CONFIG_PATH);

Expand Down Expand Up @@ -69,6 +69,7 @@ async function filterActiveEVMChains(
await provider.getChainId();
return typedChainId;
} catch (error) {
console.log(error);
return null;
}
})
Expand Down Expand Up @@ -153,6 +154,12 @@ async function fetchAnchorMetadataTask(
)
);

metadataSettled.forEach((res) => {
if (res.status === 'rejected') {
console.log(res.reason);
}
});

const metadata = metadataSettled
.filter(
(result): result is PromiseFulfilledResult<AnchorMetadata> =>
Expand Down
Loading