From 73b0d59f46fbbfdc9f2f60b51cc8b38d913746e4 Mon Sep 17 00:00:00 2001 From: Marc-Aurele Besner <82244926+marc-aurele-besner@users.noreply.github.com> Date: Mon, 15 Jul 2024 15:13:55 -0400 Subject: [PATCH] cleanup logic with suggestion --- explorer/src/components/Operator/NominationManagement.tsx | 6 ++---- explorer/src/components/Operator/NominatorsList.tsx | 6 ++---- explorer/src/components/Operator/OperatorManagement.tsx | 4 ++-- explorer/src/components/Operator/OperatorsList.tsx | 4 ++-- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/explorer/src/components/Operator/NominationManagement.tsx b/explorer/src/components/Operator/NominationManagement.tsx index 6decedad0..ec02e55aa 100644 --- a/explorer/src/components/Operator/NominationManagement.tsx +++ b/explorer/src/components/Operator/NominationManagement.tsx @@ -243,14 +243,12 @@ export const NominationManagement: FC = () => { const excludeActions = [OperatorActionType.Deregister, OperatorActionType.UnlockFunds] if ( row.original.operator.status && - (JSON.parse(row.original.operator.status) as unknown as { deregistered: object }) - .deregistered + JSON.parse(row.original.operator.status ?? '{}')?.deregistered ) excludeActions.push(OperatorActionType.Nominating) if ( row.original.operator.status && - (JSON.parse(row.original.operator.status) as unknown as { slashed: object }).slashed === - null + JSON.parse(row.original.operator.status ?? '{}')?.slashed === null ) return <> return ( diff --git a/explorer/src/components/Operator/NominatorsList.tsx b/explorer/src/components/Operator/NominatorsList.tsx index e31895ecb..8c5429fdc 100644 --- a/explorer/src/components/Operator/NominatorsList.tsx +++ b/explorer/src/components/Operator/NominatorsList.tsx @@ -237,14 +237,12 @@ export const NominatorsList: FC = () => { const excludeActions = [OperatorActionType.Deregister, OperatorActionType.UnlockFunds] if ( row.original.operator.status && - (JSON.parse(row.original.operator.status) as unknown as { deregistered: object }) - .deregistered + JSON.parse(row.original.operator.status ?? '{}')?.deregistered ) excludeActions.push(OperatorActionType.Nominating) if ( row.original.operator.status && - (JSON.parse(row.original.operator.status) as unknown as { slashed: object }).slashed === - null + JSON.parse(row.original.operator.status ?? '{}')?.slashed === null ) return <> return ( diff --git a/explorer/src/components/Operator/OperatorManagement.tsx b/explorer/src/components/Operator/OperatorManagement.tsx index 29270f864..dd605ea26 100644 --- a/explorer/src/components/Operator/OperatorManagement.tsx +++ b/explorer/src/components/Operator/OperatorManagement.tsx @@ -361,13 +361,13 @@ export const OperatorManagement: FC = () => { if ( !useRpcData && row.original.status && - (JSON.parse(row.original.status) as unknown as { deregistered: object }).deregistered + JSON.parse(row.original.status ?? '{}')?.deregistered ) excludeActions.push(OperatorActionType.Nominating) if ( !useRpcData && row.original.status && - (JSON.parse(row.original.status) as unknown as { slashed: object }).slashed === null + JSON.parse(row.original.status ?? '{}')?.slashed === null ) return <> return ( diff --git a/explorer/src/components/Operator/OperatorsList.tsx b/explorer/src/components/Operator/OperatorsList.tsx index 62c93b041..598d60006 100644 --- a/explorer/src/components/Operator/OperatorsList.tsx +++ b/explorer/src/components/Operator/OperatorsList.tsx @@ -257,13 +257,13 @@ export const OperatorsList: FC = () => { !useRpcData && !nominator && row.original.status && - (JSON.parse(row.original.status) as unknown as { deregistered: object }).deregistered + JSON.parse(row.original.status ?? '{}')?.deregistered ) excludeActions.push(OperatorActionType.Nominating) if ( !useRpcData && row.original.status && - (JSON.parse(row.original.status) as unknown as { slashed: object }).slashed === null + JSON.parse(row.original.status ?? '{}')?.slashed === null ) return <> return (