ethereum / clrfund

Eth2 CLR project built on clr.fund

Home Page:https://eth2clrfund.netlify.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to connect wallet

samajammin opened this issue · comments

Seeing issues with connecting a wallet in the current round: https://eth2clrfund.netlify.app/#/projects

TypeError: Cannot read properties of null (reading 'nativeTokenSymbol')

The app needs a current round in order to find the nativeTokenSymbol. Seems like we should provide a default/fallback - I suggest we set this to DAI if no current round exists.

Not sure where we need to add this, perhaps just in the WalletWidget. Most components will have a currentRound when they're rendered.

Just tried this locally to see if it would allow me to connect (and it did):

Added this to plugins/Web3/constants/tokens.ts:

export const DEFAULT_TOKEN = {
  nativeTokenAddress: '0xda10009cbd5d07dd0cecc66161fc93d7c9000da1',
  nativeTokenSymbol: 'DAI',
  nativeTokenDecimals: 18,
}

Then in store/mutations.ts:

import { DEFAULT_TOKEN } from '@/plugins/Web3/constants/tokens'

// Then in SET_CURRENT_ROUND, fall back to DEFAULT_TOKEN if round is null:
state.currentRound = round ? round : DEFAULT_TOKEN

Honestly not sure if we even need the token address in there, but if I recall this would allow us to look up the users balance, but it's specific to Arbitrum One in this case.

Just one approach, open to suggestions from others.

Hmm I think we should not fall back to DAI directly, we should fall back to the factory native token in this case.

The factory has a native token and each round can have its own native token as well.

// from deploy script
const setTokenTx = await fundingRoundFactory.setToken(
  process.env.NATIVE_TOKEN_ADDRESS
)

And I wouldn't overwrite the state.currentRound for this because that is not true since currentRound does not exist. I think the issue is coming from WalletWidget and we should do the fix in there. The rest of the components that are trying to access nativeTokenSymbol from the currentRound are related to the contribution phase, so we shouldn't have any problem there due that when those components are used, is because a round is going on.