View on GitHub
File Changes
  isFetchingPoolInfoSelector,
  totalDelegatedSelector,
  lastAccountStateFetchErrorSelector,
+
  isFlawedWalletSelector,
} from '../../selectors'
import DelegationNavigationButtons from './DelegationNavigationButtons'
import UtxoAutoRefresher from '../Send/UtxoAutoRefresher'
import {fetchAccountState} from '../../actions/account'
import {fetchUTXOs} from '../../actions/utxo'
import {fetchPoolInfo} from '../../actions/pools'
-
import {SHELLEY_WALLET_ROUTES} from '../../RoutesList'
+
import {checkForFlawedWallets} from '../../actions'
+
import {SHELLEY_WALLET_ROUTES, WALLET_INIT_ROUTES} from '../../RoutesList'
import walletManager from '../../crypto/wallet'
import globalMessages from '../../i18n/global-messages'
import {formatAdaWithText, formatAdaInteger} from '../../utils/format'
+
import FlawedWalletModal from '../TxHistory/FlawedWalletModal'

                      
import styles from './styles/DelegationSummary.style'

                      
  poolInfo: ?RemotePoolMetaSuccess,
  totalDelegated: BigNumber,
  lastAccountStateSyncError: any,
+
  checkForFlawedWallets: () => any,
+
  isFlawedWallet: boolean,
}

                      
type State = {
      1000,
    )
    this.props.fetchPoolInfo()
+
    this.props.checkForFlawedWallets()
  }

                      
  componentDidUpdate(prevProps) {
      lastAccountStateSyncError,
      isFetchingUtxos,
      intl,
+
      isFlawedWallet,
+
      navigation,
    } = this.props

                      
    const totalBalance =
      return num.toString()
    }

                      
+
    if (isFlawedWallet === true) {
+
      return (
+
        <FlawedWalletModal
+
          visible
+
          disableButtons={false}
+
          onPress={() =>
+
            navigation.navigate(WALLET_INIT_ROUTES.WALLET_SELECTION)
+
          }
+
          onRequestClose={() =>
+
            navigation.navigate(WALLET_INIT_ROUTES.WALLET_SELECTION)
+
          }
+
        />
+
      )
+
    }
+

                      
    return (
      <SafeAreaView style={styles.scrollView}>
        <StatusBar type="dark" />
        totalDelegated: totalDelegatedSelector(state),
        isOnline: isOnlineSelector(state),
        walletName: walletNameSelector(state),
+
        isFlawedWallet: isFlawedWalletSelector(state),
      }),
      {
        fetchPoolInfo,
        fetchAccountState,
        fetchUTXOs,
+
        checkForFlawedWallets,
      },
    ),
    withNavigation,
    return await api.getPoolInfo(pool, config)
  }

                      
-
  async checkForFlawedWallets() {
+
  async checkForFlawedWallets(): Promise<boolean> {
    const mnemonics = [CONFIG.DEBUG.MNEMONIC1, CONFIG.DEBUG.MNEMONIC2]
    let affected = false
-

                      
    for (const mnemonic of mnemonics) {
      Logger.debug('WalletManager::checkForFlawedWallets mnemonic:', mnemonic)
-
      const flawedAddresses = await util.getAddressesFromMnemonics(
-
        mnemonic,
-
        'External',
-
        [0, 1, 2, 3, 4],
-
        CARDANO_CONFIG.MAINNET,
-
      )
-
      for (let i = 0; i < flawedAddresses.length; i++) {
-
        if (this._wallet == null) throw new WalletClosed()
-
        if (this._wallet._externalChain.isMyAddress(flawedAddresses[i])) {
-
          Logger.debug('WalletManager::checkForFlawedWallets: address match')
-
          affected = true
-
          if (i !== 0) {
-
            throw new Error(
-
              'WalletManager::checkForFlawedWallets: address match found for index > 0',
-
            )
-
          }
-
          return affected
-
        }
+
      let flawedAddresses
+
      if (this.isShelley) {
+
        const flawedAddressesBech32 = await shelleyUtil.getGroupAddressesFromMnemonics(
+
          mnemonic,
+
          'External',
+
          [0],
+
        )
+
        flawedAddresses = await Promise.all(
+
          flawedAddressesBech32.map(async (addr) => {
+
            return Buffer.from(
+
              await (await Address.from_string(addr)).as_bytes(),
+
            ).toString('hex')
+
          }),
+
        )
+
      } else {
+
        flawedAddresses = await util.getAddressesFromMnemonics(
+
          mnemonic,
+
          'External',
+
          [0],
+
          CARDANO_CONFIG.MAINNET,
+
        )
+
      }
+
      if (this._wallet == null) throw new WalletClosed()
+
      if (this._wallet._externalChain.isMyAddress(flawedAddresses[0])) {
+
        Logger.debug('WalletManager::checkForFlawedWallets: address match')
+
        affected = true
+
        return affected
      }
    }
    Logger.debug('WalletManager::checkForFlawedWallets:: no match')