diff --git a/nym-wallet/src/context/bonding.tsx b/nym-wallet/src/context/bonding.tsx index 5788594604..687c754ff7 100644 --- a/nym-wallet/src/context/bonding.tsx +++ b/nym-wallet/src/context/bonding.tsx @@ -125,7 +125,6 @@ export type TBondingContext = { updateBondAmount: (data: TUpdateBondArgs, tokenPool: TokenPool) => Promise; redeemRewards: (fee?: FeeDetails) => Promise; updateMixnode: (pm: string, fee?: FeeDetails) => Promise; - checkOwnership: () => Promise; generateMixnodeMsgPayload: (data: TBondMixnodeSignatureArgs) => Promise; generateGatewayMsgPayload: (data: TBondGatewaySignatureArgs) => Promise; isVestingAccount: boolean; @@ -152,9 +151,6 @@ export const BondingContext = createContext({ updateMixnode: async () => { throw new Error('Not implemented'); }, - checkOwnership(): Promise { - throw new Error('Not implemented'); - }, generateMixnodeMsgPayload: async () => { throw new Error('Not implemented'); }, @@ -171,7 +167,7 @@ export const BondingContextProvider: FCWithChildren = ({ children }): JSX.Elemen const [isVestingAccount, setIsVestingAccount] = useState(false); const { userBalance, clientDetails } = useContext(AppContext); - const { ownership, isLoading: isOwnershipLoading, checkOwnership } = useCheckOwnership(); + const { ownership, isLoading: isOwnershipLoading } = useCheckOwnership(); useEffect(() => { userBalance.fetchBalance(); @@ -342,8 +338,6 @@ export const BondingContextProvider: FCWithChildren = ({ children }): JSX.Elemen setIsLoading(true); setError(undefined); - await checkOwnership(); - if (ownership.hasOwnership && ownership.nodeType === EnumNodeType.mixnode && clientDetails) { try { const data = await getMixnodeBondDetails(); @@ -617,7 +611,6 @@ export const BondingContextProvider: FCWithChildren = ({ children }): JSX.Elemen refresh, redeemRewards, updateBondAmount, - checkOwnership, generateMixnodeMsgPayload, generateGatewayMsgPayload, isVestingAccount, diff --git a/nym-wallet/src/hooks/useCheckOwnership.ts b/nym-wallet/src/hooks/useCheckOwnership.ts index d9a63f0e5d..adb62d915f 100644 --- a/nym-wallet/src/hooks/useCheckOwnership.ts +++ b/nym-wallet/src/hooks/useCheckOwnership.ts @@ -4,7 +4,7 @@ import { AppContext } from '../context/main'; import { checkGatewayOwnership, checkMixnodeOwnership, getVestingPledgeInfo } from '../requests'; import { EnumNodeType, TNodeOwnership } from '../types'; -const initial = { +const initial: TNodeOwnership = { hasOwnership: false, nodeType: undefined, vestingPledge: undefined, @@ -18,8 +18,7 @@ export const useCheckOwnership = () => { const [error, setError] = useState(); const checkOwnership = useCallback(async () => { - const status = initial as TNodeOwnership; - + const status = { ...initial }; try { const [ownsMixnode, ownsGateway] = await Promise.all([checkMixnodeOwnership(), checkGatewayOwnership()]); diff --git a/nym-wallet/src/pages/bonding/Bonding.tsx b/nym-wallet/src/pages/bonding/Bonding.tsx index e21c19c3ce..b138f6309b 100644 --- a/nym-wallet/src/pages/bonding/Bonding.tsx +++ b/nym-wallet/src/pages/bonding/Bonding.tsx @@ -34,17 +34,8 @@ const Bonding = () => { const navigate = useNavigate(); - const { - bondedNode, - bondMixnode, - bondGateway, - redeemRewards, - isLoading, - checkOwnership, - updateBondAmount, - error, - refresh, - } = useBondingContext(); + const { bondedNode, bondMixnode, bondGateway, redeemRewards, isLoading, updateBondAmount, error, refresh } = + useBondingContext(); useEffect(() => { if (bondedNode && isMixnode(bondedNode) && bondedNode.uncappedStakeSaturation) { @@ -54,7 +45,7 @@ const Bonding = () => { const handleCloseModal = async () => { setShowModal(undefined); - await checkOwnership(); + refresh(); }; const handleError = (err: string) => {