Commit b6ecc303 authored by tom's avatar tom

make NEXT_PUBLIC_NETWORK_RPC_URL optional

parent 3978736f
...@@ -251,7 +251,7 @@ ...@@ -251,7 +251,7 @@
"presentation": { "presentation": {
"reveal": "always", "reveal": "always",
"panel": "shared", "panel": "shared",
"close": true, "close": false,
"revealProblems": "onProblem", "revealProblems": "onProblem",
"focus": true, "focus": true,
}, },
......
...@@ -46,7 +46,7 @@ The app instance could be customized by passing following variables to NodeJS en ...@@ -46,7 +46,7 @@ The app instance could be customized by passing following variables to NodeJS en
| NEXT_PUBLIC_NETWORK_SHORT_NAME | `string` *(optional)* | Used for SEO attributes (page title and description) | `OoG` | | NEXT_PUBLIC_NETWORK_SHORT_NAME | `string` *(optional)* | Used for SEO attributes (page title and description) | `OoG` |
| NEXT_PUBLIC_NETWORK_TYPE | `string` *(optional)* | Network type (used for matching pre-defined assets, e.g network logo and icon, which are stored in the project). See all possible values here | `xdai_mainnet` | | NEXT_PUBLIC_NETWORK_TYPE | `string` *(optional)* | Network type (used for matching pre-defined assets, e.g network logo and icon, which are stored in the project). See all possible values here | `xdai_mainnet` |
| NEXT_PUBLIC_NETWORK_ID | `number` | Chain id, see [https://chainlist.org/](https://chainlist.org/) for the reference | `99` | | NEXT_PUBLIC_NETWORK_ID | `number` | Chain id, see [https://chainlist.org/](https://chainlist.org/) for the reference | `99` |
| NEXT_PUBLIC_NETWORK_RPC_URL | `string` | Chain server RPC url, see [https://chainlist.org/](https://chainlist.org/) for the reference | `https://core.poa.network` | | NEXT_PUBLIC_NETWORK_RPC_URL | `string` *(optional)* | Chain server RPC url, see [https://chainlist.org/](https://chainlist.org/) for the reference. If not provided, some functionality of the explorer, related to smart contracts interaction and third-party apps integration, will be unavailable | `https://core.poa.network` |
| NEXT_PUBLIC_NETWORK_CURRENCY_NAME | `string` | Network currency name | `Ether` | | NEXT_PUBLIC_NETWORK_CURRENCY_NAME | `string` | Network currency name | `Ether` |
| NEXT_PUBLIC_NETWORK_CURRENCY_SYMBOL | `string` | Network currency symbol | `ETH` | | NEXT_PUBLIC_NETWORK_CURRENCY_SYMBOL | `string` | Network currency symbol | `ETH` |
| NEXT_PUBLIC_NETWORK_CURRENCY_DECIMALS | `string` | Network currency decimals | `18` | | NEXT_PUBLIC_NETWORK_CURRENCY_DECIMALS | `string` | Network currency decimals | `18` |
......
...@@ -33,7 +33,7 @@ interface ReturnType { ...@@ -33,7 +33,7 @@ interface ReturnType {
} }
export default function useNavItems(): ReturnType { export default function useNavItems(): ReturnType {
const isMarketplaceFilled = appConfig.marketplaceAppList.length > 0; const isMarketplaceFilled = appConfig.marketplaceAppList.length > 0 && appConfig.network.rpcUrl;
const router = useRouter(); const router = useRouter();
const pathname = router.pathname; const pathname = router.pathname;
......
...@@ -20,40 +20,47 @@ interface Props { ...@@ -20,40 +20,47 @@ interface Props {
addressHash?: string; addressHash?: string;
} }
export const currentChain: Chain = { const { wagmiClient, ethereumClient } = (() => {
id: Number(appConfig.network.id), try {
name: appConfig.network.name || '', const currentChain: Chain = {
network: appConfig.network.name || '', id: Number(appConfig.network.id),
nativeCurrency: { name: appConfig.network.name || '',
decimals: appConfig.network.currency.decimals, network: appConfig.network.name || '',
name: appConfig.network.currency.name || '', nativeCurrency: {
symbol: appConfig.network.currency.symbol || '', decimals: appConfig.network.currency.decimals,
}, name: appConfig.network.currency.name || '',
rpcUrls: { symbol: appConfig.network.currency.symbol || '',
'default': { },
http: [ appConfig.network.rpcUrl || '' ], rpcUrls: {
}, 'default': {
}, http: [ appConfig.network.rpcUrl || '' ],
blockExplorers: { },
'default': { },
name: 'Blockscout', blockExplorers: {
url: appConfig.baseUrl, 'default': {
}, name: 'Blockscout',
}, url: appConfig.baseUrl,
}; },
},
};
const chains = [ currentChain ]; const chains = [ currentChain ];
const { provider } = configureChains(chains, [ const { provider } = configureChains(chains, [
walletConnectProvider({ projectId: appConfig.walletConnect.projectId || '' }), walletConnectProvider({ projectId: appConfig.walletConnect.projectId || '' }),
]); ]);
const wagmiClient = createClient({ const wagmiClient = createClient({
autoConnect: true, autoConnect: true,
connectors: modalConnectors({ appName: 'web3Modal', chains }), connectors: modalConnectors({ appName: 'web3Modal', chains }),
provider, provider,
}); });
const ethereumClient = new EthereumClient(wagmiClient, chains);
const ethereumClient = new EthereumClient(wagmiClient, chains); return { wagmiClient, ethereumClient };
} catch (error) {
return { wagmiClient: undefined, ethereumClient: undefined };
}
})();
const TAB_LIST_PROPS = { const TAB_LIST_PROPS = {
columnGap: 3, columnGap: 3,
...@@ -61,6 +68,12 @@ const TAB_LIST_PROPS = { ...@@ -61,6 +68,12 @@ const TAB_LIST_PROPS = {
const AddressContract = ({ addressHash, tabs }: Props) => { const AddressContract = ({ addressHash, tabs }: Props) => {
const modalZIndex = useToken<string>('zIndices', 'modal'); const modalZIndex = useToken<string>('zIndices', 'modal');
const web3ModalTheme = useColorModeValue('light', 'dark');
const noProviderTabs = React.useMemo(() => tabs.filter(({ id }) => id === 'contact_code'), [ tabs ]);
if (!wagmiClient || !ethereumClient) {
return <RoutedTabs tabs={ noProviderTabs } variant="outline" colorScheme="gray" size="sm" tabListProps={ TAB_LIST_PROPS }/>;
}
return ( return (
<WagmiConfig client={ wagmiClient }> <WagmiConfig client={ wagmiClient }>
...@@ -71,7 +84,7 @@ const AddressContract = ({ addressHash, tabs }: Props) => { ...@@ -71,7 +84,7 @@ const AddressContract = ({ addressHash, tabs }: Props) => {
projectId={ appConfig.walletConnect.projectId } projectId={ appConfig.walletConnect.projectId }
ethereumClient={ ethereumClient } ethereumClient={ ethereumClient }
themeZIndex={ Number(modalZIndex) } themeZIndex={ Number(modalZIndex) }
themeMode={ useColorModeValue('light', 'dark') } themeMode={ web3ModalTheme }
themeBackground="themeColor" themeBackground="themeColor"
/> />
</WagmiConfig> </WagmiConfig>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment