threshold-network / token-dashboard

22 stars 23 forks source link

Check if app is TACo on deauth request #744

Closed theref closed 5 months ago

theref commented 5 months ago

User ran into an issue when attempting to deauth their stake. tBTC and RB worked fine, TACo failed.

Using impersonator I got this error in the console:

isOperatorInPool method does not exist (eg on TACo app) TypeError: i._application.isOperatorInPool is not a function

This PR adds a simple check to see if the app is TACo and avoid the isOperatorInPool method.

I'm unsure if this function in src/pages/Staking/AuthorizeStakingApps/AuthorizeApplicationsCardCheckbox/index.tsx also needs to change

  const onInitiateDeauthorization = async (tokenAmount: string) => {
    openModal(ModalType.DeauthorizeApplication, {
      stakingProvider: stakingProvider,
      decreaseAmount: tokenAmount,
      stakingAppName: appAuthData.stakingAppId,
      operator: appAuthData.operator,
      isOperatorInPool: appAuthData.isOperatorInPool,
    })
  }

the type that is being used is:

type StakingAppAuthDataBaseProps = {
  status: Exclude<AuthorizationStatus, "authorization-not-required">
  authorizedStake: string
  percentage: number
  pendingAuthorizationDecrease: string
  isDeauthorizationReqestActive: boolean
  /**
   * Timestamp when the deauthorization request was created. Takes an
   * `undefined` value if it cannot be estimated.
   */
  deauthorizationCreatedAt?: string
  /**
   * Time in seconds until the deauthorization can be completed.
   */
  remainingAuthorizationDecreaseDelay: string
  isOperatorInPool: boolean | undefined
  operator: string
}

and so isOperatorInPool can be undefined

github-actions[bot] commented 5 months ago

Preview uploaded to https://preview.dashboard.test.threshold.network/deauth/index.html.

theref commented 5 months ago

Ok this has been tested now and appears to be working