diff --git a/src/store/connected-account/effects.ts b/src/store/connected-account/effects.ts index 25ad46433..a53608546 100644 --- a/src/store/connected-account/effects.ts +++ b/src/store/connected-account/effects.ts @@ -1,5 +1,7 @@ import { AnyAction } from "@reduxjs/toolkit" +import { isAddressZero } from "../../web3/utils" import { AppListenerEffectAPI } from "../listener" +import { mapOperatorToStakingProviderModalClosed } from "../modalQueue" import { setRolesOf } from "./connectedAccountSlice" export const getRolesOf = async ( @@ -10,18 +12,24 @@ export const getRolesOf = async ( const { connectedAccount } = listenerApi.getState() const { address } = connectedAccount - if (address) { - listenerApi.unsubscribe() - const { owner, authorizer, beneficiary } = - await listenerApi.extra.threshold.staking.rolesOf(address) - listenerApi.dispatch( - setRolesOf({ - owner, - authorizer, - beneficiary, - }) - ) + if (!address) return + listenerApi.unsubscribe() + const { owner, authorizer, beneficiary } = + await listenerApi.extra.threshold.staking.rolesOf(address) + if ( + isAddressZero(owner) && + isAddressZero(authorizer) && + isAddressZero(beneficiary) + ) { + listenerApi.dispatch(mapOperatorToStakingProviderModalClosed()) } + listenerApi.dispatch( + setRolesOf({ + owner, + authorizer, + beneficiary, + }) + ) } catch (error) { console.log("Could not fetch roles for connected staking provider: ", error) listenerApi.subscribe()