Files
explore/configs/app/features/blockchainInteraction.ts

39 lines
878 B
TypeScript

import type { Feature } from './types';
import chain from '../chain';
import { getEnvValue } from '../utils';
const walletConnectProjectId = getEnvValue('NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID');
const title = 'Blockchain interaction (writing to contract, etc.)';
const config: Feature<{ walletConnect: { projectId: string } }> = (() => {
if (
// all chain parameters are required for wagmi provider
// @wagmi/chains/dist/index.d.ts
chain.id &&
chain.name &&
chain.currency.name &&
chain.currency.symbol &&
chain.currency.decimals &&
chain.rpcUrls.length > 0 &&
walletConnectProjectId
) {
return Object.freeze({
title,
isEnabled: true,
walletConnect: {
projectId: walletConnectProjectId,
},
});
}
return Object.freeze({
title,
isEnabled: false,
});
})();
export default config;