From 31003c37942fcbc59aeacab5d355255702347a09 Mon Sep 17 00:00:00 2001 From: Magic Cat <37407870+MonikaCat@users.noreply.github.com> Date: Wed, 6 Dec 2023 13:46:21 +0700 Subject: [PATCH] fix: validator moniker display [web] (#1314) ## Description Closes: #XXXX [BDU-1147](https://forbole.atlassian.net/browse/BDU-1147) --- ### Author Checklist _All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues._ I have... - [x] ran linting via `yarn lint` - [ ] wrote tests where necessary - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] targeted the correct branch - [x] provided a link to the relevant issue or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed - [x] added a changeset via [`yarn && yarn changeset`](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md) [BDU-1147]: https://forbole.atlassian.net/browse/BDU-1147?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --- .changeset/grumpy-insects-deliver.md | 5 + .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../src/hooks/useCelestiaProfile/index.ts | 64 ------ .../src/hooks/useCustomProfile/index.ts | 47 ---- .../blocks/components/desktop/index.tsx | 127 ----------- .../screens/home/components/blocks/hooks.ts | 52 ----- .../screens/home/components/blocks/types.ts | 15 -- .../src/screens/validator_details/hooks.ts | 177 --------------- .../src/screens/validator_details/types.ts | 34 --- .../validators/components/list/hooks.ts | 213 ------------------ .../validators/components/list/index.tsx | 57 ----- .../validators/components/list/types.ts | 32 --- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../src/screens/validator_details/index.tsx | 4 +- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../src/hooks/useCustomProfile/index.ts | 47 ---- .../src/hooks/useKyveProfile/index.ts | 64 ------ .../blocks/components/desktop/index.tsx | 127 ----------- .../screens/home/components/blocks/hooks.ts | 52 ----- .../screens/home/components/blocks/types.ts | 15 -- .../src/screens/validator_details/hooks.ts | 177 --------------- .../src/screens/validator_details/types.ts | 34 --- .../validators/components/list/hooks.ts | 213 ------------------ .../validators/components/list/index.tsx | 57 ----- .../validators/components/list/types.ts | 32 --- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../src/hooks/useConsensusProfile/index.ts | 64 ------ .../src/hooks/useCustomProfile/index.ts | 47 ---- .../blocks/components/desktop/index.tsx | 127 ----------- .../screens/home/components/blocks/hooks.ts | 52 ----- .../screens/home/components/blocks/types.ts | 15 -- .../src/screens/validator_details/hooks.ts | 177 --------------- .../src/screens/validator_details/types.ts | 34 --- .../validators/components/list/hooks.ts | 213 ------------------ .../validators/components/list/index.tsx | 57 ----- .../validators/components/list/types.ts | 32 --- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../src/hooks/useCustomProfile/index.ts | 47 ---- .../src/screens/validator_details/hooks.ts | 161 ------------- .../validators/components/list/hooks.ts | 212 ----------------- .../validators/components/list/index.tsx | 57 ----- .../validators/components/list/types.ts | 32 --- .../general/validators_address_list.graphql | 15 -- .../src/graphql/types/general_types.ts | 46 ---- .../general/validators_address_list.graphql | 15 -- apps/web/src/graphql/types/general_types.ts | 46 ---- .../graphql/general/proposal_details.graphql | 1 - .../general/validators_address_list.graphql | 15 -- .../ui/src/graphql/types/general_types.ts | 46 ---- .../ui/src/graphql/types/profile_types.ts | 135 +++++++++++ 105 files changed, 142 insertions(+), 4979 deletions(-) create mode 100644 .changeset/grumpy-insects-deliver.md delete mode 100644 apps/web-celestia/src/hooks/useCelestiaProfile/index.ts delete mode 100644 apps/web-celestia/src/hooks/useCustomProfile/index.ts delete mode 100644 apps/web-celestia/src/screens/home/components/blocks/components/desktop/index.tsx delete mode 100644 apps/web-celestia/src/screens/home/components/blocks/hooks.ts delete mode 100644 apps/web-celestia/src/screens/home/components/blocks/types.ts delete mode 100644 apps/web-celestia/src/screens/validator_details/hooks.ts delete mode 100644 apps/web-celestia/src/screens/validator_details/types.ts delete mode 100644 apps/web-celestia/src/screens/validators/components/list/hooks.ts delete mode 100644 apps/web-celestia/src/screens/validators/components/list/index.tsx delete mode 100644 apps/web-celestia/src/screens/validators/components/list/types.ts rename apps/{web-kyve => web-crescent}/src/screens/validator_details/index.tsx (91%) delete mode 100644 apps/web-kyve/src/hooks/useCustomProfile/index.ts delete mode 100644 apps/web-kyve/src/hooks/useKyveProfile/index.ts delete mode 100644 apps/web-kyve/src/screens/home/components/blocks/components/desktop/index.tsx delete mode 100644 apps/web-kyve/src/screens/home/components/blocks/hooks.ts delete mode 100644 apps/web-kyve/src/screens/home/components/blocks/types.ts delete mode 100644 apps/web-kyve/src/screens/validator_details/hooks.ts delete mode 100644 apps/web-kyve/src/screens/validator_details/types.ts delete mode 100644 apps/web-kyve/src/screens/validators/components/list/hooks.ts delete mode 100644 apps/web-kyve/src/screens/validators/components/list/index.tsx delete mode 100644 apps/web-kyve/src/screens/validators/components/list/types.ts delete mode 100644 apps/web-quicksilver/src/hooks/useConsensusProfile/index.ts delete mode 100644 apps/web-quicksilver/src/hooks/useCustomProfile/index.ts delete mode 100644 apps/web-quicksilver/src/screens/home/components/blocks/components/desktop/index.tsx delete mode 100644 apps/web-quicksilver/src/screens/home/components/blocks/hooks.ts delete mode 100644 apps/web-quicksilver/src/screens/home/components/blocks/types.ts delete mode 100644 apps/web-quicksilver/src/screens/validator_details/hooks.ts delete mode 100644 apps/web-quicksilver/src/screens/validator_details/types.ts delete mode 100644 apps/web-quicksilver/src/screens/validators/components/list/hooks.ts delete mode 100644 apps/web-quicksilver/src/screens/validators/components/list/index.tsx delete mode 100644 apps/web-quicksilver/src/screens/validators/components/list/types.ts delete mode 100644 apps/web-stride/src/hooks/useCustomProfile/index.ts delete mode 100644 apps/web-stride/src/screens/validator_details/hooks.ts delete mode 100644 apps/web-stride/src/screens/validators/components/list/hooks.ts delete mode 100644 apps/web-stride/src/screens/validators/components/list/index.tsx delete mode 100644 apps/web-stride/src/screens/validators/components/list/types.ts diff --git a/.changeset/grumpy-insects-deliver.md b/.changeset/grumpy-insects-deliver.md new file mode 100644 index 0000000000..3a6acf1a35 --- /dev/null +++ b/.changeset/grumpy-insects-deliver.md @@ -0,0 +1,5 @@ +--- +'web': minor +--- + +fix: validator moniker display diff --git a/apps/web-agoric/src/graphql/general/validators_address_list.graphql b/apps/web-agoric/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-agoric/src/graphql/general/validators_address_list.graphql +++ b/apps/web-agoric/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-agoric/src/graphql/types/general_types.ts b/apps/web-agoric/src/graphql/types/general_types.ts index 41393540b0..6bbfbeeb0b 100644 --- a/apps/web-agoric/src/graphql/types/general_types.ts +++ b/apps/web-agoric/src/graphql/types/general_types.ts @@ -13663,52 +13663,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-akash/src/graphql/general/validators_address_list.graphql b/apps/web-akash/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-akash/src/graphql/general/validators_address_list.graphql +++ b/apps/web-akash/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-akash/src/graphql/types/general_types.ts b/apps/web-akash/src/graphql/types/general_types.ts index 5966d69d87..8e1cfb279d 100644 --- a/apps/web-akash/src/graphql/types/general_types.ts +++ b/apps/web-akash/src/graphql/types/general_types.ts @@ -14930,52 +14930,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-archway/src/graphql/general/validators_address_list.graphql b/apps/web-archway/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-archway/src/graphql/general/validators_address_list.graphql +++ b/apps/web-archway/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-archway/src/graphql/types/general_types.ts b/apps/web-archway/src/graphql/types/general_types.ts index 9c05052f3a..15a88d79a6 100644 --- a/apps/web-archway/src/graphql/types/general_types.ts +++ b/apps/web-archway/src/graphql/types/general_types.ts @@ -9421,52 +9421,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-assetmantle/src/graphql/general/validators_address_list.graphql b/apps/web-assetmantle/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-assetmantle/src/graphql/general/validators_address_list.graphql +++ b/apps/web-assetmantle/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-assetmantle/src/graphql/types/general_types.ts b/apps/web-assetmantle/src/graphql/types/general_types.ts index 86bc7b87e8..bc3a82c256 100644 --- a/apps/web-assetmantle/src/graphql/types/general_types.ts +++ b/apps/web-assetmantle/src/graphql/types/general_types.ts @@ -13667,52 +13667,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-band/src/graphql/general/validators_address_list.graphql b/apps/web-band/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-band/src/graphql/general/validators_address_list.graphql +++ b/apps/web-band/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-band/src/graphql/types/general_types.ts b/apps/web-band/src/graphql/types/general_types.ts index 987ec72111..f1b847934f 100644 --- a/apps/web-band/src/graphql/types/general_types.ts +++ b/apps/web-band/src/graphql/types/general_types.ts @@ -13854,52 +13854,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-bitsong/src/graphql/general/validators_address_list.graphql b/apps/web-bitsong/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-bitsong/src/graphql/general/validators_address_list.graphql +++ b/apps/web-bitsong/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-bitsong/src/graphql/types/general_types.ts b/apps/web-bitsong/src/graphql/types/general_types.ts index 8be8ca1e29..ae53960006 100644 --- a/apps/web-bitsong/src/graphql/types/general_types.ts +++ b/apps/web-bitsong/src/graphql/types/general_types.ts @@ -13667,52 +13667,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-celestia/src/graphql/general/validators_address_list.graphql b/apps/web-celestia/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-celestia/src/graphql/general/validators_address_list.graphql +++ b/apps/web-celestia/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-celestia/src/graphql/types/general_types.ts b/apps/web-celestia/src/graphql/types/general_types.ts index 9370592b87..dc5c753a84 100644 --- a/apps/web-celestia/src/graphql/types/general_types.ts +++ b/apps/web-celestia/src/graphql/types/general_types.ts @@ -8574,52 +8574,6 @@ export function useCustomValidatorLazyQuery(baseOptions?: Apollo.LazyQueryHookOp export type CustomValidatorQueryHookResult = ReturnType; export type CustomValidatorLazyQueryHookResult = ReturnType; export type CustomValidatorQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-celestia/src/hooks/useCelestiaProfile/index.ts b/apps/web-celestia/src/hooks/useCelestiaProfile/index.ts deleted file mode 100644 index bc5e47f887..0000000000 --- a/apps/web-celestia/src/hooks/useCelestiaProfile/index.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { useEffect, useState } from 'react'; -import { useRecoilCallback } from 'recoil'; -import * as R from 'ramda'; -import { writeProfile } from '@/recoil/profiles/selectors'; -import { useCustomValidatorQuery } from '@/graphql/types/general_types'; - -type Profile = { - name: string; - address: string; - imageUrl: string; - bio: string; - website: string; - consensusAddress: string; -}; - -interface CelestiaProfileResult { - profile: Profile | undefined; - loading: boolean; -} - -/** - * Accepts consensus address and returns the appropriate profile - * @param consensus - the consensus address of the validator - * @param validator - the operator address of the validator - * @returns The return value is an object with the following properties: - * name, address, imageUrl - */ -const useCelestiaProfile = (consensus: string, validator: string): CelestiaProfileResult => { - const { data, loading } = useCustomValidatorQuery({ variables: { consensusAddress: consensus } }); - const [profile, setProfile] = useState(); - const setAvatarName = useRecoilCallback( - ({ set }) => - (address: string, avatarName: AvatarName | null) => - set(writeProfile(address), (prevState) => - R.equals(prevState, avatarName) ? prevState : avatarName - ), - [] - ); - useEffect(() => { - if (data && data.validatorDescriptions.length > 0) { - const validatorDescription = data.validatorDescriptions[0]; - const consensusAddress = validatorDescription.validator_address ?? ''; - const name = validatorDescription.moniker ?? ''; - const imageUrl = validatorDescription.avatar_url ?? ''; - const bio = validatorDescription.details ?? ''; - const website = validatorDescription.website ?? ''; - const address = validator; - const res: Profile = { - name, - address, - imageUrl, - bio, - website, - consensusAddress, - }; - setProfile(res); - setAvatarName(address, res); - } - }, [data, loading, setAvatarName, validator]); - - return { profile, loading }; -}; - -export default useCelestiaProfile; diff --git a/apps/web-celestia/src/hooks/useCustomProfile/index.ts b/apps/web-celestia/src/hooks/useCustomProfile/index.ts deleted file mode 100644 index fc312164f6..0000000000 --- a/apps/web-celestia/src/hooks/useCustomProfile/index.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { useEffect, useState } from 'react'; -import { ValidatorType } from '@/screens/validators/components/list/types'; - -interface AvatarName { - className?: string; - imageUrl: string | ''; - address: string; - name: string; - href?: (address: string) => string; - image?: React.ReactNode; - target?: JSX.IntrinsicElements['a']['target']; -} - -/** - * Accepts a list of state items and returns the appropriate profiles - * @param item - * @return a loading state and a list of profiles - */ -const useCustomProfile = (item: ValidatorType[]) => { - const [loading, setLoading] = useState(true); - const [profiles, setProfiles] = useState([]); - - useEffect(() => { - if (item.length) { - const data = item.map((x) => { - const address = x.validator ?? x.moniker[0].validator_address ?? ''; - const name = x.moniker[0].moniker ?? ''; - const imageUrl = x.moniker[0].avatar_url ?? ''; - const bio = x.moniker[0].details ?? ''; - const website = x.moniker[0].website ?? ''; - return { - address, - name, - imageUrl, - bio, - website, - }; - }); - setProfiles(data); - setLoading(false); - } - }, [item, loading]); - - return { profiles, loading }; -}; - -export default useCustomProfile; diff --git a/apps/web-celestia/src/screens/home/components/blocks/components/desktop/index.tsx b/apps/web-celestia/src/screens/home/components/blocks/components/desktop/index.tsx deleted file mode 100644 index 23f60319d2..0000000000 --- a/apps/web-celestia/src/screens/home/components/blocks/components/desktop/index.tsx +++ /dev/null @@ -1,127 +0,0 @@ -import AvatarName from '@/components/avatar_name'; -import Timestamp from '@/components/Timestamp'; -import useStyles from '@/screens/home/components/blocks/components/desktop/styles'; -import { columns } from '@/screens/home/components/blocks/components/desktop/utils'; -import type { ItemType } from '@/screens/home/components/blocks/types'; -import { getMiddleEllipsis } from '@/utils/get_middle_ellipsis'; -import { BLOCK_DETAILS } from '@/utils/go_to_page'; -import Table from '@mui/material/Table'; -import TableBody from '@mui/material/TableBody'; -import TableCell from '@mui/material/TableCell'; -import TableHead from '@mui/material/TableHead'; -import TableRow from '@mui/material/TableRow'; -import { AnimatePresence, motion, Variants } from 'framer-motion'; -import useAppTranslation from '@/hooks/useAppTranslation'; -import Link from 'next/link'; -import numeral from 'numeral'; -import { FC } from 'react'; -import useCelestiaProfile from '@/hooks/useCelestiaProfile'; - -type BlockRowProps = { - item: ItemType; -}; - -const variants: Variants = { - initial: { - height: 0, - display: 'flex', - alignItems: 'center', - overflow: 'hidden', - clipPath: 'inset(0 50 0 50)', - }, - animate: { - height: 50, - display: 'flex', - alignItems: 'center', - overflow: 'hidden', - clipPath: 'inset(0 0 0 0)', - }, - exit: { - height: 50, - display: 'flex', - alignItems: 'center', - overflow: 'hidden', - position: 'absolute', - marginTop: [50, 60], - opacity: 0, - transition: { duration: 0.5 }, - }, -}; - -const BlockRow: FC = ({ item }) => { - const { profile } = useCelestiaProfile(item.consensusAddress, item.proposer); - const name = profile?.name ?? ''; - const imageUrl = profile?.imageUrl ?? ''; - const address = profile?.address ?? ''; - - const formattedData = { - height: ( - - {numeral(item.height).format('0,0')} - - ), - txs: numeral(item.txs).format('0,0'), - time: , - proposer: , - hash: getMiddleEllipsis(item.hash, { - beginning: 6, - ending: 5, - }), - }; - return ( - - {columns.map((column) => { - const { key, align } = column; - return ( - - - {formattedData[key as keyof typeof formattedData]} - - - ); - })} - - ); -}; - -type DesktopProps = { - className?: string; - items: ItemType[]; -}; - -const Desktop: FC = ({ className, items }) => { - const { t } = useAppTranslation('blocks'); - const { classes, cx } = useStyles(); - - return ( -
- - - - {columns.map((column) => ( - - {t(column.key)} - - ))} - - - - - {items.map((row) => ( - - ))} - - -
-
- ); -}; - -export default Desktop; diff --git a/apps/web-celestia/src/screens/home/components/blocks/hooks.ts b/apps/web-celestia/src/screens/home/components/blocks/hooks.ts deleted file mode 100644 index bf5a258c0d..0000000000 --- a/apps/web-celestia/src/screens/home/components/blocks/hooks.ts +++ /dev/null @@ -1,52 +0,0 @@ -import * as R from 'ramda'; -import { useCallback, useState } from 'react'; -import { - BlocksListenerSubscription, - useBlocksListenerSubscription, -} from '@/graphql/types/general_types'; -import type { BlocksState } from '@/screens/home/components/blocks/types'; - -const formatBlocks = (data: BlocksListenerSubscription) => - data.blocks.map((x) => { - const proposerAddress = x?.validator?.validatorInfo?.operatorAddress ?? ''; - const consensusAddress = x?.validator?.validatorInfo?.consensusAddress ?? ''; - return { - height: x.height, - txs: x.txs ?? 0, - hash: x.hash, - timestamp: x.timestamp, - proposer: proposerAddress, - consensusAddress, - }; - }) ?? []; - -export const useBlocks = () => { - const [state, setState] = useState({ - loading: true, - items: [], - }); - - const handleSetState = useCallback((stateChange: (prevState: BlocksState) => BlocksState) => { - setState((prevState) => { - const newState = stateChange(prevState); - return R.equals(prevState, newState) ? prevState : newState; - }); - }, []); - - // ================================ - // block subscription - // ================================ - useBlocksListenerSubscription({ - onData: (data) => { - handleSetState((prevState) => ({ - ...prevState, - loading: false, - items: data.data.data ? formatBlocks(data.data.data) : [], - })); - }, - }); - - return { - state, - }; -}; diff --git a/apps/web-celestia/src/screens/home/components/blocks/types.ts b/apps/web-celestia/src/screens/home/components/blocks/types.ts deleted file mode 100644 index 522c61a7cd..0000000000 --- a/apps/web-celestia/src/screens/home/components/blocks/types.ts +++ /dev/null @@ -1,15 +0,0 @@ -export interface BlockType { - height: number; - txs: number; - timestamp: string; - proposer: string; - hash: string; - consensusAddress: string; -} - -export interface BlocksState { - loading: boolean; - items: BlockType[]; -} - -export type ItemType = BlockType; diff --git a/apps/web-celestia/src/screens/validator_details/hooks.ts b/apps/web-celestia/src/screens/validator_details/hooks.ts deleted file mode 100644 index cbc67f6920..0000000000 --- a/apps/web-celestia/src/screens/validator_details/hooks.ts +++ /dev/null @@ -1,177 +0,0 @@ -import { useRouter } from 'next/router'; -import * as R from 'ramda'; -import { useCallback, useEffect, useState } from 'react'; -import chainConfig from '@/chainConfig'; -import { useValidatorDetailsQuery, ValidatorDetailsQuery } from '@/graphql/types/general_types'; -import useCelestiaProfile from '@/hooks/useCelestiaProfile'; -import { SlashingParams } from '@/models'; -import { StatusType, ValidatorDetailsState } from '@/screens/validator_details/types'; -import { formatToken } from '@/utils/format_token'; -import { getValidatorCondition } from '@/utils/get_validator_condition'; - -const { extra, votingPowerTokenUnit } = chainConfig(); - -const initialTokenDenom: TokenUnit = { - value: '0', - displayDenom: '', - baseDenom: '', - exponent: 0, -}; - -const initialState: ValidatorDetailsState = { - exists: true, - desmosProfile: null, - overview: { - validator: '', - operatorAddress: '', - selfDelegateAddress: '', - consensusAddress: '', - description: '', - website: '', - }, - status: { - status: 0, - jailed: false, - tombstoned: false, - condition: 0, - commission: 0, - missedBlockCounter: 0, - signedBlockWindow: 0, - maxRate: '0', - }, - votingPower: { - height: 0, - overall: initialTokenDenom, - self: 0, - }, -}; - -// ============================ -// overview -// ============================ -const formatOverview = (data: ValidatorDetailsQuery) => { - const operatorAddress = data?.validator?.[0]?.validatorInfo?.operatorAddress ?? ''; - const selfDelegateAddress = data?.validator?.[0]?.validatorInfo?.selfDelegateAddress ?? ''; - const consensusAddress = data?.validator?.[0]?.validatorInfo?.consensusAddress ?? ''; - const profile = { - validator: operatorAddress, - operatorAddress, - selfDelegateAddress, - consensusAddress, - description: data.validator[0]?.validatorDescriptions?.[0]?.details ?? '', - website: data.validator[0]?.validatorDescriptions?.[0]?.website ?? '', - }; - - return profile; -}; - -// ============================ -// status -// ============================ -const formatStatus = (data: ValidatorDetailsQuery) => { - const slashingParams = SlashingParams.fromJson(data?.slashingParams?.[0]?.params ?? {}); - const missedBlockCounter = - data.validator[0]?.validatorSigningInfos?.[0]?.missedBlocksCounter ?? 0; - const { signedBlockWindow } = slashingParams; - const condition = getValidatorCondition(signedBlockWindow, missedBlockCounter); - - const profile: StatusType = { - status: data.validator[0]?.validatorStatuses?.[0]?.status ?? 3, - jailed: data.validator[0]?.validatorStatuses?.[0]?.jailed ?? false, - tombstoned: data.validator[0]?.validatorSigningInfos?.[0]?.tombstoned ?? false, - commission: data.validator[0]?.validatorCommissions?.[0]?.commission ?? 0, - condition, - missedBlockCounter, - signedBlockWindow, - maxRate: data?.validator?.[0]?.validatorInfo?.maxRate ?? '0', - }; - - return profile; -}; - -// ============================ -// votingPower -// ============================ -const formatVotingPower = (data: ValidatorDetailsQuery) => { - const selfVotingPower = - (data.validator[0]?.validatorVotingPowers?.[0]?.votingPower ?? 0) / - 10 ** (extra.votingPowerExponent ?? 0); - - const votingPower = { - self: selfVotingPower, - overall: formatToken(data?.stakingPool?.[0]?.bonded ?? 0, votingPowerTokenUnit), - height: data.validator[0]?.validatorVotingPowers?.[0]?.height ?? 0, - }; - - return votingPower; -}; - -export const useValidatorDetails = () => { - const router = useRouter(); - const [state, setState] = useState(initialState); - - const handleSetState = useCallback( - (stateChange: (prevState: ValidatorDetailsState) => ValidatorDetailsState) => { - setState((prevState) => { - const newState = stateChange(prevState); - return R.equals(prevState, newState) ? prevState : newState; - }); - }, - [] - ); - - // ========================== - // Fetch Data - // ========================== - const { loading } = useValidatorDetailsQuery({ - variables: { - address: router.query.address as string, - }, - onCompleted: (data) => { - handleSetState((prevState) => ({ ...prevState, ...formatAccountQuery(data) })); - }, - }); - - // ========================== - // Celestia Profile - // ========================== - const { profile: dataDesmosProfile, loading: loadingDesmosProfile } = useCelestiaProfile( - state.overview.consensusAddress, - state.overview.selfDelegateAddress - ); - useEffect(() => { - if (dataDesmosProfile) { - const { name, imageUrl, bio } = dataDesmosProfile; - setState((prevState) => ({ - ...prevState, - desmosProfile: { - name, - imageUrl, - bio, - dtag: name, - nickname: name, - coverUrl: '', - connections: [], - }, - })); - } - }, [dataDesmosProfile]); - - return { state, loading: loading || loadingDesmosProfile }; -}; - -function formatAccountQuery(data: ValidatorDetailsQuery): Partial { - const stateChange: Partial = {}; - - if (!data.validator.length) { - stateChange.exists = false; - return stateChange; - } - - stateChange.overview = formatOverview(data); - - stateChange.status = formatStatus(data); - stateChange.votingPower = formatVotingPower(data); - - return stateChange; -} diff --git a/apps/web-celestia/src/screens/validator_details/types.ts b/apps/web-celestia/src/screens/validator_details/types.ts deleted file mode 100644 index df700ad40f..0000000000 --- a/apps/web-celestia/src/screens/validator_details/types.ts +++ /dev/null @@ -1,34 +0,0 @@ -export interface OverviewType { - validator: string; - operatorAddress: string; - selfDelegateAddress: string; - consensusAddress: string; - description: string; - website: string; -} - -export interface StatusType { - inActiveSet?: string; - jailed: boolean; - tombstoned: boolean; - commission: number; - signedBlockWindow: number; - missedBlockCounter: number; - maxRate: string; - status: number; - condition: number; -} - -export interface VotingPowerType { - height: number; - overall: TokenUnit; - self: number; -} - -export interface ValidatorDetailsState { - exists: boolean; - desmosProfile: DesmosProfile | null; - overview: OverviewType; - status: StatusType; - votingPower: VotingPowerType; -} diff --git a/apps/web-celestia/src/screens/validators/components/list/hooks.ts b/apps/web-celestia/src/screens/validators/components/list/hooks.ts deleted file mode 100644 index b42cb49595..0000000000 --- a/apps/web-celestia/src/screens/validators/components/list/hooks.ts +++ /dev/null @@ -1,213 +0,0 @@ -import Big from 'big.js'; -import numeral from 'numeral'; -import * as R from 'ramda'; -import { SyntheticEvent, useCallback, useState } from 'react'; -import chainConfig from '@/chainConfig'; -import { useValidatorsQuery, ValidatorsQuery } from '@/graphql/types/general_types'; -import { SlashingParams } from '@/models'; -import type { - ItemType, - ValidatorsState, - ValidatorType, -} from '@/screens/validators/components/list/types'; -import { formatToken } from '@/utils/format_token'; -import { getValidatorCondition } from '@/utils/get_validator_condition'; - -const { extra, votingPowerTokenUnit } = chainConfig(); - -// ========================== -// Parse data -// ========================== -const formatValidators = (data: ValidatorsQuery): Partial => { - const slashingParams = SlashingParams.fromJson(data?.slashingParams?.[0]?.params ?? {}); - const votingPowerOverall = - numeral( - formatToken(data?.stakingPool?.[0]?.bondedTokens ?? 0, votingPowerTokenUnit).value - ).value() ?? 0; - - const { signedBlockWindow } = slashingParams; - - let formattedItems: ValidatorType[] = data.validator - .filter((x) => x.validatorInfo && x.validatorDescriptions) - .map((x) => { - const votingPower = - (x?.validatorVotingPowers?.[0]?.votingPower ?? 0) / 10 ** (extra.votingPowerExponent ?? 0); - const votingPowerPercent = votingPowerOverall - ? numeral((votingPower / votingPowerOverall) * 100).value() - : 0; - - const missedBlockCounter = x?.validatorSigningInfos?.[0]?.missedBlocksCounter ?? 0; - const condition = getValidatorCondition(signedBlockWindow, missedBlockCounter); - - return { - moniker: x.validatorDescriptions ?? '', - consensus: x.validatorInfo?.consensusAddress ?? '', - validator: x.validatorInfo?.operatorAddress ?? '', - votingPower: votingPower ?? 0, - votingPowerPercent: votingPowerPercent ?? 0, - commission: (x?.validatorCommissions?.[0]?.commission ?? 0) * 100, - condition, - status: x?.validatorStatuses?.[0]?.status ?? 0, - jailed: x?.validatorStatuses?.[0]?.jailed ?? false, - tombstoned: x?.validatorSigningInfos?.[0]?.tombstoned ?? false, - }; - }); - - // get the top 34% validators - formattedItems = formattedItems.sort((a, b) => (a.votingPower > b.votingPower ? -1 : 1)); - - // add key to indicate they are part of top 34% - let cumulativeVotingPower = Big(0); - let reached = false; - formattedItems.forEach((x) => { - if (x.status === 3) { - const totalVp = cumulativeVotingPower.add(x.votingPowerPercent); - if (totalVp.lte(34) && !reached) { - x.topVotingPower = true; - } - - if (totalVp.gt(34) && !reached) { - x.topVotingPower = true; - reached = true; - } - - cumulativeVotingPower = totalVp; - } - }); - - return { - votingPowerOverall, - items: formattedItems, - }; -}; - -export const useValidators = () => { - const [search, setSearch] = useState(''); - const [state, setState] = useState({ - loading: true, - exists: true, - items: [], - votingPowerOverall: 0, - tab: 0, - sortKey: 'validator.name', - sortDirection: 'asc', - }); - - const handleSetState = useCallback( - (stateChange: (prevState: ValidatorsState) => ValidatorsState) => { - setState((prevState) => { - const newState = stateChange(prevState); - return R.equals(prevState, newState) ? prevState : newState; - }); - }, - [] - ); - - // ========================== - // Fetch Data - // ========================== - useValidatorsQuery({ - onCompleted: (data) => { - handleSetState((prevState) => ({ - ...prevState, - loading: false, - ...formatValidators(data), - })); - }, - onError: () => { - handleSetState((prevState) => ({ - ...prevState, - loading: false, - exists: false, - })); - }, - }); - - const handleTabChange = useCallback( - (_event: SyntheticEvent, newValue: number) => { - setState((prevState) => ({ - ...prevState, - tab: newValue, - })); - }, - [] - ); - - const handleSort = useCallback( - (key: string) => { - if (key === state.sortKey) { - setState((prevState) => ({ - ...prevState, - sortDirection: prevState.sortDirection === 'asc' ? 'desc' : 'asc', - })); - } else { - setState((prevState) => ({ - ...prevState, - sortKey: key, - sortDirection: 'asc', // new key so we start the sort by asc - })); - } - }, - [state.sortKey] - ); - - const handleSearch = useCallback((value: string) => { - setSearch(value); - }, []); - - const sortItems = useCallback( - (items: ItemType[]) => { - let sorted: ItemType[] = R.clone(items); - - if (state.tab === 0) { - sorted = sorted.filter((x) => x.status === 3); - } - - if (state.tab === 1) { - sorted = sorted.filter((x) => x.status !== 3); - } - - if (search) { - sorted = sorted.filter((x) => { - const formattedSearch = search.toLowerCase().replace(/ /g, ''); - return ( - x.validator.name.toLowerCase().replace(/ /g, '').includes(formattedSearch) || - x.validator.address.toLowerCase().includes(formattedSearch) - ); - }); - } - - if (state.sortKey && state.sortDirection) { - sorted.sort((a, b) => { - let compareA = R.pathOr('', [...state.sortKey.split('.')], a); - let compareB = R.pathOr('', [...state.sortKey.split('.')], b); - - if (typeof compareA === 'string' && typeof compareB === 'string') { - compareA = compareA.toLowerCase(); - compareB = compareB.toLowerCase(); - } - - if (compareA < compareB) { - return state.sortDirection === 'asc' ? -1 : 1; - } - if (compareA > compareB) { - return state.sortDirection === 'asc' ? 1 : -1; - } - return 0; - }); - } - - return sorted; - }, - [search, state.sortDirection, state.sortKey, state.tab] - ); - - return { - state, - handleTabChange, - handleSort, - handleSearch, - sortItems, - search, - }; -}; diff --git a/apps/web-celestia/src/screens/validators/components/list/index.tsx b/apps/web-celestia/src/screens/validators/components/list/index.tsx deleted file mode 100644 index 26965f3d07..0000000000 --- a/apps/web-celestia/src/screens/validators/components/list/index.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import { FC, ReactNode, useMemo } from 'react'; -import Box from '@/components/box'; -import LoadAndExist from '@/components/load_and_exist'; -import NoData from '@/components/no_data'; -import Desktop from '@/screens/validators/components/list/components/desktop'; -import Mobile from '@/screens/validators/components/list/components/mobile'; -import Tabs from '@/screens/validators/components/list/components/tabs'; -import { useValidators } from '@/screens/validators/components/list/hooks'; -import useStyles from '@/screens/validators/components/list/styles'; -import { useDisplayStyles } from '@/styles/useSharedStyles'; -import useCustomProfile from '@/hooks/useCustomProfile'; - -const List: FC = ({ className }) => { - const { classes, cx } = useStyles(); - const display = useDisplayStyles().classes; - const { state, handleTabChange, handleSearch, handleSort, sortItems, search } = useValidators(); - const { profiles: dataProfiles, loading } = useCustomProfile(state.items); - const items = useMemo( - () => sortItems(state.items.map((x, i) => ({ ...x, validator: dataProfiles?.[i] }))), - [state.items, dataProfiles, sortItems] - ); - - let list: ReactNode; - - if (!items.length) { - list = ; - } else { - list = ( - <> - - - - ); - } - - return ( - - - -
{list}
-
-
- ); -}; - -export default List; diff --git a/apps/web-celestia/src/screens/validators/components/list/types.ts b/apps/web-celestia/src/screens/validators/components/list/types.ts deleted file mode 100644 index 52031b052b..0000000000 --- a/apps/web-celestia/src/screens/validators/components/list/types.ts +++ /dev/null @@ -1,32 +0,0 @@ -interface MonikerType { - moniker?: string | null | undefined; - avatar_url?: string | null; - validator_address: string; - website?: string | null; - details?: string | null; -} - -export interface ValidatorType { - moniker: MonikerType[]; - validator: string; - votingPower: number; - votingPowerPercent: number; - commission: number; - condition: number; - status: number; - jailed: boolean; - tombstoned: boolean; - topVotingPower?: boolean; // top 34% VP -} - -export interface ValidatorsState { - loading: boolean; - exists: boolean; - tab: number; - sortKey: string; - sortDirection: 'asc' | 'desc'; - votingPowerOverall: number; - items: ValidatorType[]; -} - -export type ItemType = Override; diff --git a/apps/web-cheqd/src/graphql/general/validators_address_list.graphql b/apps/web-cheqd/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-cheqd/src/graphql/general/validators_address_list.graphql +++ b/apps/web-cheqd/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-cheqd/src/graphql/types/general_types.ts b/apps/web-cheqd/src/graphql/types/general_types.ts index 169a869b4f..5724931d22 100644 --- a/apps/web-cheqd/src/graphql/types/general_types.ts +++ b/apps/web-cheqd/src/graphql/types/general_types.ts @@ -9574,52 +9574,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-comdex/src/graphql/general/validators_address_list.graphql b/apps/web-comdex/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-comdex/src/graphql/general/validators_address_list.graphql +++ b/apps/web-comdex/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-comdex/src/graphql/types/general_types.ts b/apps/web-comdex/src/graphql/types/general_types.ts index a58458a4de..7af7580e50 100644 --- a/apps/web-comdex/src/graphql/types/general_types.ts +++ b/apps/web-comdex/src/graphql/types/general_types.ts @@ -14799,52 +14799,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-coreum/src/graphql/general/validators_address_list.graphql b/apps/web-coreum/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-coreum/src/graphql/general/validators_address_list.graphql +++ b/apps/web-coreum/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-coreum/src/graphql/types/general_types.ts b/apps/web-coreum/src/graphql/types/general_types.ts index e4d48bc417..1a02e8dccb 100644 --- a/apps/web-coreum/src/graphql/types/general_types.ts +++ b/apps/web-coreum/src/graphql/types/general_types.ts @@ -9404,52 +9404,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-cosmos/src/graphql/general/validators_address_list.graphql b/apps/web-cosmos/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-cosmos/src/graphql/general/validators_address_list.graphql +++ b/apps/web-cosmos/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-cosmos/src/graphql/types/general_types.ts b/apps/web-cosmos/src/graphql/types/general_types.ts index 86bc7b87e8..bc3a82c256 100644 --- a/apps/web-cosmos/src/graphql/types/general_types.ts +++ b/apps/web-cosmos/src/graphql/types/general_types.ts @@ -13667,52 +13667,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-crescent/src/graphql/general/validators_address_list.graphql b/apps/web-crescent/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-crescent/src/graphql/general/validators_address_list.graphql +++ b/apps/web-crescent/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-crescent/src/graphql/types/general_types.ts b/apps/web-crescent/src/graphql/types/general_types.ts index a681d79a4f..c143504c50 100644 --- a/apps/web-crescent/src/graphql/types/general_types.ts +++ b/apps/web-crescent/src/graphql/types/general_types.ts @@ -14059,52 +14059,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-kyve/src/screens/validator_details/index.tsx b/apps/web-crescent/src/screens/validator_details/index.tsx similarity index 91% rename from apps/web-kyve/src/screens/validator_details/index.tsx rename to apps/web-crescent/src/screens/validator_details/index.tsx index ff7f4682d1..a096f375db 100644 --- a/apps/web-kyve/src/screens/validator_details/index.tsx +++ b/apps/web-crescent/src/screens/validator_details/index.tsx @@ -40,8 +40,8 @@ const ValidatorDetails = () => { data={votingPower} status={status.status} /> - - + + diff --git a/apps/web-desmos/src/graphql/general/validators_address_list.graphql b/apps/web-desmos/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-desmos/src/graphql/general/validators_address_list.graphql +++ b/apps/web-desmos/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-desmos/src/graphql/types/general_types.ts b/apps/web-desmos/src/graphql/types/general_types.ts index 67310cf23e..5e016833be 100644 --- a/apps/web-desmos/src/graphql/types/general_types.ts +++ b/apps/web-desmos/src/graphql/types/general_types.ts @@ -13852,52 +13852,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-emoney/src/graphql/general/validators_address_list.graphql b/apps/web-emoney/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-emoney/src/graphql/general/validators_address_list.graphql +++ b/apps/web-emoney/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-emoney/src/graphql/types/general_types.ts b/apps/web-emoney/src/graphql/types/general_types.ts index 70b15a36ae..77a521cbd5 100644 --- a/apps/web-emoney/src/graphql/types/general_types.ts +++ b/apps/web-emoney/src/graphql/types/general_types.ts @@ -13564,52 +13564,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-evmos/src/graphql/general/validators_address_list.graphql b/apps/web-evmos/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-evmos/src/graphql/general/validators_address_list.graphql +++ b/apps/web-evmos/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-evmos/src/graphql/types/general_types.ts b/apps/web-evmos/src/graphql/types/general_types.ts index 2ae1478ff8..90dc327195 100644 --- a/apps/web-evmos/src/graphql/types/general_types.ts +++ b/apps/web-evmos/src/graphql/types/general_types.ts @@ -13588,52 +13588,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-gitopia/src/graphql/general/validators_address_list.graphql b/apps/web-gitopia/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-gitopia/src/graphql/general/validators_address_list.graphql +++ b/apps/web-gitopia/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-gitopia/src/graphql/types/general_types.ts b/apps/web-gitopia/src/graphql/types/general_types.ts index 7432cf4740..b80678c141 100644 --- a/apps/web-gitopia/src/graphql/types/general_types.ts +++ b/apps/web-gitopia/src/graphql/types/general_types.ts @@ -8320,52 +8320,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-humansai/src/graphql/general/validators_address_list.graphql b/apps/web-humansai/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-humansai/src/graphql/general/validators_address_list.graphql +++ b/apps/web-humansai/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-humansai/src/graphql/types/general_types.ts b/apps/web-humansai/src/graphql/types/general_types.ts index 7432cf4740..b80678c141 100644 --- a/apps/web-humansai/src/graphql/types/general_types.ts +++ b/apps/web-humansai/src/graphql/types/general_types.ts @@ -8320,52 +8320,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-jackal/src/graphql/general/validators_address_list.graphql b/apps/web-jackal/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-jackal/src/graphql/general/validators_address_list.graphql +++ b/apps/web-jackal/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-jackal/src/graphql/types/general_types.ts b/apps/web-jackal/src/graphql/types/general_types.ts index fa7edf8c52..b47802f0b5 100644 --- a/apps/web-jackal/src/graphql/types/general_types.ts +++ b/apps/web-jackal/src/graphql/types/general_types.ts @@ -8514,52 +8514,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-kyve/src/graphql/general/validators_address_list.graphql b/apps/web-kyve/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-kyve/src/graphql/general/validators_address_list.graphql +++ b/apps/web-kyve/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-kyve/src/graphql/types/general_types.ts b/apps/web-kyve/src/graphql/types/general_types.ts index 2d6c6f8e59..9c047ab4ee 100644 --- a/apps/web-kyve/src/graphql/types/general_types.ts +++ b/apps/web-kyve/src/graphql/types/general_types.ts @@ -9509,52 +9509,6 @@ export function useCustomValidatorLazyQuery(baseOptions?: Apollo.LazyQueryHookOp export type CustomValidatorQueryHookResult = ReturnType; export type CustomValidatorLazyQueryHookResult = ReturnType; export type CustomValidatorQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-kyve/src/hooks/useCustomProfile/index.ts b/apps/web-kyve/src/hooks/useCustomProfile/index.ts deleted file mode 100644 index fc312164f6..0000000000 --- a/apps/web-kyve/src/hooks/useCustomProfile/index.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { useEffect, useState } from 'react'; -import { ValidatorType } from '@/screens/validators/components/list/types'; - -interface AvatarName { - className?: string; - imageUrl: string | ''; - address: string; - name: string; - href?: (address: string) => string; - image?: React.ReactNode; - target?: JSX.IntrinsicElements['a']['target']; -} - -/** - * Accepts a list of state items and returns the appropriate profiles - * @param item - * @return a loading state and a list of profiles - */ -const useCustomProfile = (item: ValidatorType[]) => { - const [loading, setLoading] = useState(true); - const [profiles, setProfiles] = useState([]); - - useEffect(() => { - if (item.length) { - const data = item.map((x) => { - const address = x.validator ?? x.moniker[0].validator_address ?? ''; - const name = x.moniker[0].moniker ?? ''; - const imageUrl = x.moniker[0].avatar_url ?? ''; - const bio = x.moniker[0].details ?? ''; - const website = x.moniker[0].website ?? ''; - return { - address, - name, - imageUrl, - bio, - website, - }; - }); - setProfiles(data); - setLoading(false); - } - }, [item, loading]); - - return { profiles, loading }; -}; - -export default useCustomProfile; diff --git a/apps/web-kyve/src/hooks/useKyveProfile/index.ts b/apps/web-kyve/src/hooks/useKyveProfile/index.ts deleted file mode 100644 index a953fbe679..0000000000 --- a/apps/web-kyve/src/hooks/useKyveProfile/index.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { useEffect, useState } from 'react'; -import { useRecoilCallback } from 'recoil'; -import * as R from 'ramda'; -import { writeProfile } from '@/recoil/profiles/selectors'; -import { useCustomValidatorQuery } from '@/graphql/types/general_types'; - -type Profile = { - name: string; - address: string; - imageUrl: string; - bio: string; - website: string; - consensusAddress: string; -}; - -interface CelestiaProfileResult { - profile: Profile | undefined; - loading: boolean; -} - -/** - * Accepts consensus address and returns the appropriate profile - * @param consensus - the consensus address of the validator - * @param validator - the operator address of the validator - * @returns The return value is an object with the following properties: - * name, address, imageUrl - */ -const useKyveProfile = (consensus: string, validator: string): CelestiaProfileResult => { - const { data, loading } = useCustomValidatorQuery({ variables: { consensusAddress: consensus } }); - const [profile, setProfile] = useState(); - const setAvatarName = useRecoilCallback( - ({ set }) => - (address: string, avatarName: AvatarName | null) => - set(writeProfile(address), (prevState) => - R.equals(prevState, avatarName) ? prevState : avatarName - ), - [] - ); - useEffect(() => { - if (data && data.validatorDescriptions.length > 0) { - const validatorDescription = data.validatorDescriptions[0]; - const consensusAddress = validatorDescription.validator_address ?? ''; - const name = validatorDescription.moniker ?? ''; - const imageUrl = validatorDescription.avatar_url ?? ''; - const bio = validatorDescription.details ?? ''; - const website = validatorDescription.website ?? ''; - const address = validator; - const res: Profile = { - name, - address, - imageUrl, - bio, - website, - consensusAddress, - }; - setProfile(res); - setAvatarName(address, res); - } - }, [data, loading, setAvatarName, validator]); - - return { profile, loading }; -}; - -export default useKyveProfile; diff --git a/apps/web-kyve/src/screens/home/components/blocks/components/desktop/index.tsx b/apps/web-kyve/src/screens/home/components/blocks/components/desktop/index.tsx deleted file mode 100644 index 2fa8efa27f..0000000000 --- a/apps/web-kyve/src/screens/home/components/blocks/components/desktop/index.tsx +++ /dev/null @@ -1,127 +0,0 @@ -import AvatarName from '@/components/avatar_name'; -import Timestamp from '@/components/Timestamp'; -import useStyles from '@/screens/home/components/blocks/components/desktop/styles'; -import { columns } from '@/screens/home/components/blocks/components/desktop/utils'; -import type { ItemType } from '@/screens/home/components/blocks/types'; -import { getMiddleEllipsis } from '@/utils/get_middle_ellipsis'; -import { BLOCK_DETAILS } from '@/utils/go_to_page'; -import Table from '@mui/material/Table'; -import TableBody from '@mui/material/TableBody'; -import TableCell from '@mui/material/TableCell'; -import TableHead from '@mui/material/TableHead'; -import TableRow from '@mui/material/TableRow'; -import { AnimatePresence, motion, Variants } from 'framer-motion'; -import useAppTranslation from '@/hooks/useAppTranslation'; -import Link from 'next/link'; -import numeral from 'numeral'; -import { FC } from 'react'; -import useKyveProfile from '@/hooks/useKyveProfile'; - -type BlockRowProps = { - item: ItemType; -}; - -const variants: Variants = { - initial: { - height: 0, - display: 'flex', - alignItems: 'center', - overflow: 'hidden', - clipPath: 'inset(0 50 0 50)', - }, - animate: { - height: 50, - display: 'flex', - alignItems: 'center', - overflow: 'hidden', - clipPath: 'inset(0 0 0 0)', - }, - exit: { - height: 50, - display: 'flex', - alignItems: 'center', - overflow: 'hidden', - position: 'absolute', - marginTop: [50, 60], - opacity: 0, - transition: { duration: 0.5 }, - }, -}; - -const BlockRow: FC = ({ item }) => { - const { profile } = useKyveProfile(item.consensusAddress, item.proposer); - const name = profile?.name ?? ''; - const imageUrl = profile?.imageUrl ?? ''; - const address = profile?.address ?? ''; - - const formattedData = { - height: ( - - {numeral(item.height).format('0,0')} - - ), - txs: numeral(item.txs).format('0,0'), - time: , - proposer: , - hash: getMiddleEllipsis(item.hash, { - beginning: 6, - ending: 5, - }), - }; - return ( - - {columns.map((column) => { - const { key, align } = column; - return ( - - - {formattedData[key as keyof typeof formattedData]} - - - ); - })} - - ); -}; - -type DesktopProps = { - className?: string; - items: ItemType[]; -}; - -const Desktop: FC = ({ className, items }) => { - const { t } = useAppTranslation('blocks'); - const { classes, cx } = useStyles(); - - return ( -
- - - - {columns.map((column) => ( - - {t(column.key)} - - ))} - - - - - {items.map((row) => ( - - ))} - - -
-
- ); -}; - -export default Desktop; diff --git a/apps/web-kyve/src/screens/home/components/blocks/hooks.ts b/apps/web-kyve/src/screens/home/components/blocks/hooks.ts deleted file mode 100644 index bf5a258c0d..0000000000 --- a/apps/web-kyve/src/screens/home/components/blocks/hooks.ts +++ /dev/null @@ -1,52 +0,0 @@ -import * as R from 'ramda'; -import { useCallback, useState } from 'react'; -import { - BlocksListenerSubscription, - useBlocksListenerSubscription, -} from '@/graphql/types/general_types'; -import type { BlocksState } from '@/screens/home/components/blocks/types'; - -const formatBlocks = (data: BlocksListenerSubscription) => - data.blocks.map((x) => { - const proposerAddress = x?.validator?.validatorInfo?.operatorAddress ?? ''; - const consensusAddress = x?.validator?.validatorInfo?.consensusAddress ?? ''; - return { - height: x.height, - txs: x.txs ?? 0, - hash: x.hash, - timestamp: x.timestamp, - proposer: proposerAddress, - consensusAddress, - }; - }) ?? []; - -export const useBlocks = () => { - const [state, setState] = useState({ - loading: true, - items: [], - }); - - const handleSetState = useCallback((stateChange: (prevState: BlocksState) => BlocksState) => { - setState((prevState) => { - const newState = stateChange(prevState); - return R.equals(prevState, newState) ? prevState : newState; - }); - }, []); - - // ================================ - // block subscription - // ================================ - useBlocksListenerSubscription({ - onData: (data) => { - handleSetState((prevState) => ({ - ...prevState, - loading: false, - items: data.data.data ? formatBlocks(data.data.data) : [], - })); - }, - }); - - return { - state, - }; -}; diff --git a/apps/web-kyve/src/screens/home/components/blocks/types.ts b/apps/web-kyve/src/screens/home/components/blocks/types.ts deleted file mode 100644 index 522c61a7cd..0000000000 --- a/apps/web-kyve/src/screens/home/components/blocks/types.ts +++ /dev/null @@ -1,15 +0,0 @@ -export interface BlockType { - height: number; - txs: number; - timestamp: string; - proposer: string; - hash: string; - consensusAddress: string; -} - -export interface BlocksState { - loading: boolean; - items: BlockType[]; -} - -export type ItemType = BlockType; diff --git a/apps/web-kyve/src/screens/validator_details/hooks.ts b/apps/web-kyve/src/screens/validator_details/hooks.ts deleted file mode 100644 index e32f908722..0000000000 --- a/apps/web-kyve/src/screens/validator_details/hooks.ts +++ /dev/null @@ -1,177 +0,0 @@ -import { useRouter } from 'next/router'; -import * as R from 'ramda'; -import { useCallback, useEffect, useState } from 'react'; -import chainConfig from '@/chainConfig'; -import { useValidatorDetailsQuery, ValidatorDetailsQuery } from '@/graphql/types/general_types'; -import useKyveProfile from '@/hooks/useKyveProfile'; -import { SlashingParams } from '@/models'; -import { StatusType, ValidatorDetailsState } from '@/screens/validator_details/types'; -import { formatToken } from '@/utils/format_token'; -import { getValidatorCondition } from '@/utils/get_validator_condition'; - -const { extra, votingPowerTokenUnit } = chainConfig(); - -const initialTokenDenom: TokenUnit = { - value: '0', - displayDenom: '', - baseDenom: '', - exponent: 0, -}; - -const initialState: ValidatorDetailsState = { - exists: true, - desmosProfile: null, - overview: { - validator: '', - operatorAddress: '', - selfDelegateAddress: '', - consensusAddress: '', - description: '', - website: '', - }, - status: { - status: 0, - jailed: false, - tombstoned: false, - condition: 0, - commission: 0, - missedBlockCounter: 0, - signedBlockWindow: 0, - maxRate: '0', - }, - votingPower: { - height: 0, - overall: initialTokenDenom, - self: 0, - }, -}; - -// ============================ -// overview -// ============================ -const formatOverview = (data: ValidatorDetailsQuery) => { - const operatorAddress = data?.validator?.[0]?.validatorInfo?.operatorAddress ?? ''; - const selfDelegateAddress = data?.validator?.[0]?.validatorInfo?.selfDelegateAddress ?? ''; - const consensusAddress = data?.validator?.[0]?.validatorInfo?.consensusAddress ?? ''; - const profile = { - validator: operatorAddress, - operatorAddress, - selfDelegateAddress, - consensusAddress, - description: data.validator[0]?.validatorDescriptions?.[0]?.details ?? '', - website: data.validator[0]?.validatorDescriptions?.[0]?.website ?? '', - }; - - return profile; -}; - -// ============================ -// status -// ============================ -const formatStatus = (data: ValidatorDetailsQuery) => { - const slashingParams = SlashingParams.fromJson(data?.slashingParams?.[0]?.params ?? {}); - const missedBlockCounter = - data.validator[0]?.validatorSigningInfos?.[0]?.missedBlocksCounter ?? 0; - const { signedBlockWindow } = slashingParams; - const condition = getValidatorCondition(signedBlockWindow, missedBlockCounter); - - const profile: StatusType = { - status: data.validator[0]?.validatorStatuses?.[0]?.status ?? 3, - jailed: data.validator[0]?.validatorStatuses?.[0]?.jailed ?? false, - tombstoned: data.validator[0]?.validatorSigningInfos?.[0]?.tombstoned ?? false, - commission: data.validator[0]?.validatorCommissions?.[0]?.commission ?? 0, - condition, - missedBlockCounter, - signedBlockWindow, - maxRate: data?.validator?.[0]?.validatorInfo?.maxRate ?? '0', - }; - - return profile; -}; - -// ============================ -// votingPower -// ============================ -const formatVotingPower = (data: ValidatorDetailsQuery) => { - const selfVotingPower = - (data.validator[0]?.validatorVotingPowers?.[0]?.votingPower ?? 0) / - 10 ** (extra.votingPowerExponent ?? 0); - - const votingPower = { - self: selfVotingPower, - overall: formatToken(data?.stakingPool?.[0]?.bonded ?? 0, votingPowerTokenUnit), - height: data.validator[0]?.validatorVotingPowers?.[0]?.height ?? 0, - }; - - return votingPower; -}; - -export const useValidatorDetails = () => { - const router = useRouter(); - const [state, setState] = useState(initialState); - - const handleSetState = useCallback( - (stateChange: (prevState: ValidatorDetailsState) => ValidatorDetailsState) => { - setState((prevState) => { - const newState = stateChange(prevState); - return R.equals(prevState, newState) ? prevState : newState; - }); - }, - [] - ); - - // ========================== - // Fetch Data - // ========================== - const { loading } = useValidatorDetailsQuery({ - variables: { - address: router.query.address as string, - }, - onCompleted: (data) => { - handleSetState((prevState) => ({ ...prevState, ...formatAccountQuery(data) })); - }, - }); - - // ========================== - // Celestia Profile - // ========================== - const { profile: dataDesmosProfile, loading: loadingDesmosProfile } = useKyveProfile( - state.overview.consensusAddress, - state.overview.selfDelegateAddress - ); - useEffect(() => { - if (dataDesmosProfile) { - const { name, imageUrl, bio } = dataDesmosProfile; - setState((prevState) => ({ - ...prevState, - desmosProfile: { - name, - imageUrl, - bio, - dtag: name, - nickname: name, - coverUrl: '', - connections: [], - }, - })); - } - }, [dataDesmosProfile]); - - return { state, loading: loading || loadingDesmosProfile }; -}; - -function formatAccountQuery(data: ValidatorDetailsQuery): Partial { - const stateChange: Partial = {}; - - if (!data.validator.length) { - stateChange.exists = false; - return stateChange; - } - - stateChange.overview = formatOverview(data); - - stateChange.status = formatStatus(data); - stateChange.votingPower = formatVotingPower(data); - - return stateChange; -} diff --git a/apps/web-kyve/src/screens/validator_details/types.ts b/apps/web-kyve/src/screens/validator_details/types.ts deleted file mode 100644 index df700ad40f..0000000000 --- a/apps/web-kyve/src/screens/validator_details/types.ts +++ /dev/null @@ -1,34 +0,0 @@ -export interface OverviewType { - validator: string; - operatorAddress: string; - selfDelegateAddress: string; - consensusAddress: string; - description: string; - website: string; -} - -export interface StatusType { - inActiveSet?: string; - jailed: boolean; - tombstoned: boolean; - commission: number; - signedBlockWindow: number; - missedBlockCounter: number; - maxRate: string; - status: number; - condition: number; -} - -export interface VotingPowerType { - height: number; - overall: TokenUnit; - self: number; -} - -export interface ValidatorDetailsState { - exists: boolean; - desmosProfile: DesmosProfile | null; - overview: OverviewType; - status: StatusType; - votingPower: VotingPowerType; -} diff --git a/apps/web-kyve/src/screens/validators/components/list/hooks.ts b/apps/web-kyve/src/screens/validators/components/list/hooks.ts deleted file mode 100644 index b42cb49595..0000000000 --- a/apps/web-kyve/src/screens/validators/components/list/hooks.ts +++ /dev/null @@ -1,213 +0,0 @@ -import Big from 'big.js'; -import numeral from 'numeral'; -import * as R from 'ramda'; -import { SyntheticEvent, useCallback, useState } from 'react'; -import chainConfig from '@/chainConfig'; -import { useValidatorsQuery, ValidatorsQuery } from '@/graphql/types/general_types'; -import { SlashingParams } from '@/models'; -import type { - ItemType, - ValidatorsState, - ValidatorType, -} from '@/screens/validators/components/list/types'; -import { formatToken } from '@/utils/format_token'; -import { getValidatorCondition } from '@/utils/get_validator_condition'; - -const { extra, votingPowerTokenUnit } = chainConfig(); - -// ========================== -// Parse data -// ========================== -const formatValidators = (data: ValidatorsQuery): Partial => { - const slashingParams = SlashingParams.fromJson(data?.slashingParams?.[0]?.params ?? {}); - const votingPowerOverall = - numeral( - formatToken(data?.stakingPool?.[0]?.bondedTokens ?? 0, votingPowerTokenUnit).value - ).value() ?? 0; - - const { signedBlockWindow } = slashingParams; - - let formattedItems: ValidatorType[] = data.validator - .filter((x) => x.validatorInfo && x.validatorDescriptions) - .map((x) => { - const votingPower = - (x?.validatorVotingPowers?.[0]?.votingPower ?? 0) / 10 ** (extra.votingPowerExponent ?? 0); - const votingPowerPercent = votingPowerOverall - ? numeral((votingPower / votingPowerOverall) * 100).value() - : 0; - - const missedBlockCounter = x?.validatorSigningInfos?.[0]?.missedBlocksCounter ?? 0; - const condition = getValidatorCondition(signedBlockWindow, missedBlockCounter); - - return { - moniker: x.validatorDescriptions ?? '', - consensus: x.validatorInfo?.consensusAddress ?? '', - validator: x.validatorInfo?.operatorAddress ?? '', - votingPower: votingPower ?? 0, - votingPowerPercent: votingPowerPercent ?? 0, - commission: (x?.validatorCommissions?.[0]?.commission ?? 0) * 100, - condition, - status: x?.validatorStatuses?.[0]?.status ?? 0, - jailed: x?.validatorStatuses?.[0]?.jailed ?? false, - tombstoned: x?.validatorSigningInfos?.[0]?.tombstoned ?? false, - }; - }); - - // get the top 34% validators - formattedItems = formattedItems.sort((a, b) => (a.votingPower > b.votingPower ? -1 : 1)); - - // add key to indicate they are part of top 34% - let cumulativeVotingPower = Big(0); - let reached = false; - formattedItems.forEach((x) => { - if (x.status === 3) { - const totalVp = cumulativeVotingPower.add(x.votingPowerPercent); - if (totalVp.lte(34) && !reached) { - x.topVotingPower = true; - } - - if (totalVp.gt(34) && !reached) { - x.topVotingPower = true; - reached = true; - } - - cumulativeVotingPower = totalVp; - } - }); - - return { - votingPowerOverall, - items: formattedItems, - }; -}; - -export const useValidators = () => { - const [search, setSearch] = useState(''); - const [state, setState] = useState({ - loading: true, - exists: true, - items: [], - votingPowerOverall: 0, - tab: 0, - sortKey: 'validator.name', - sortDirection: 'asc', - }); - - const handleSetState = useCallback( - (stateChange: (prevState: ValidatorsState) => ValidatorsState) => { - setState((prevState) => { - const newState = stateChange(prevState); - return R.equals(prevState, newState) ? prevState : newState; - }); - }, - [] - ); - - // ========================== - // Fetch Data - // ========================== - useValidatorsQuery({ - onCompleted: (data) => { - handleSetState((prevState) => ({ - ...prevState, - loading: false, - ...formatValidators(data), - })); - }, - onError: () => { - handleSetState((prevState) => ({ - ...prevState, - loading: false, - exists: false, - })); - }, - }); - - const handleTabChange = useCallback( - (_event: SyntheticEvent, newValue: number) => { - setState((prevState) => ({ - ...prevState, - tab: newValue, - })); - }, - [] - ); - - const handleSort = useCallback( - (key: string) => { - if (key === state.sortKey) { - setState((prevState) => ({ - ...prevState, - sortDirection: prevState.sortDirection === 'asc' ? 'desc' : 'asc', - })); - } else { - setState((prevState) => ({ - ...prevState, - sortKey: key, - sortDirection: 'asc', // new key so we start the sort by asc - })); - } - }, - [state.sortKey] - ); - - const handleSearch = useCallback((value: string) => { - setSearch(value); - }, []); - - const sortItems = useCallback( - (items: ItemType[]) => { - let sorted: ItemType[] = R.clone(items); - - if (state.tab === 0) { - sorted = sorted.filter((x) => x.status === 3); - } - - if (state.tab === 1) { - sorted = sorted.filter((x) => x.status !== 3); - } - - if (search) { - sorted = sorted.filter((x) => { - const formattedSearch = search.toLowerCase().replace(/ /g, ''); - return ( - x.validator.name.toLowerCase().replace(/ /g, '').includes(formattedSearch) || - x.validator.address.toLowerCase().includes(formattedSearch) - ); - }); - } - - if (state.sortKey && state.sortDirection) { - sorted.sort((a, b) => { - let compareA = R.pathOr('', [...state.sortKey.split('.')], a); - let compareB = R.pathOr('', [...state.sortKey.split('.')], b); - - if (typeof compareA === 'string' && typeof compareB === 'string') { - compareA = compareA.toLowerCase(); - compareB = compareB.toLowerCase(); - } - - if (compareA < compareB) { - return state.sortDirection === 'asc' ? -1 : 1; - } - if (compareA > compareB) { - return state.sortDirection === 'asc' ? 1 : -1; - } - return 0; - }); - } - - return sorted; - }, - [search, state.sortDirection, state.sortKey, state.tab] - ); - - return { - state, - handleTabChange, - handleSort, - handleSearch, - sortItems, - search, - }; -}; diff --git a/apps/web-kyve/src/screens/validators/components/list/index.tsx b/apps/web-kyve/src/screens/validators/components/list/index.tsx deleted file mode 100644 index 26965f3d07..0000000000 --- a/apps/web-kyve/src/screens/validators/components/list/index.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import { FC, ReactNode, useMemo } from 'react'; -import Box from '@/components/box'; -import LoadAndExist from '@/components/load_and_exist'; -import NoData from '@/components/no_data'; -import Desktop from '@/screens/validators/components/list/components/desktop'; -import Mobile from '@/screens/validators/components/list/components/mobile'; -import Tabs from '@/screens/validators/components/list/components/tabs'; -import { useValidators } from '@/screens/validators/components/list/hooks'; -import useStyles from '@/screens/validators/components/list/styles'; -import { useDisplayStyles } from '@/styles/useSharedStyles'; -import useCustomProfile from '@/hooks/useCustomProfile'; - -const List: FC = ({ className }) => { - const { classes, cx } = useStyles(); - const display = useDisplayStyles().classes; - const { state, handleTabChange, handleSearch, handleSort, sortItems, search } = useValidators(); - const { profiles: dataProfiles, loading } = useCustomProfile(state.items); - const items = useMemo( - () => sortItems(state.items.map((x, i) => ({ ...x, validator: dataProfiles?.[i] }))), - [state.items, dataProfiles, sortItems] - ); - - let list: ReactNode; - - if (!items.length) { - list = ; - } else { - list = ( - <> - - - - ); - } - - return ( - - - -
{list}
-
-
- ); -}; - -export default List; diff --git a/apps/web-kyve/src/screens/validators/components/list/types.ts b/apps/web-kyve/src/screens/validators/components/list/types.ts deleted file mode 100644 index 52031b052b..0000000000 --- a/apps/web-kyve/src/screens/validators/components/list/types.ts +++ /dev/null @@ -1,32 +0,0 @@ -interface MonikerType { - moniker?: string | null | undefined; - avatar_url?: string | null; - validator_address: string; - website?: string | null; - details?: string | null; -} - -export interface ValidatorType { - moniker: MonikerType[]; - validator: string; - votingPower: number; - votingPowerPercent: number; - commission: number; - condition: number; - status: number; - jailed: boolean; - tombstoned: boolean; - topVotingPower?: boolean; // top 34% VP -} - -export interface ValidatorsState { - loading: boolean; - exists: boolean; - tab: number; - sortKey: string; - sortDirection: 'asc' | 'desc'; - votingPowerOverall: number; - items: ValidatorType[]; -} - -export type ItemType = Override; diff --git a/apps/web-likecoin/src/graphql/general/validators_address_list.graphql b/apps/web-likecoin/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-likecoin/src/graphql/general/validators_address_list.graphql +++ b/apps/web-likecoin/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-likecoin/src/graphql/types/general_types.ts b/apps/web-likecoin/src/graphql/types/general_types.ts index 6208037103..c977dd880a 100644 --- a/apps/web-likecoin/src/graphql/types/general_types.ts +++ b/apps/web-likecoin/src/graphql/types/general_types.ts @@ -13355,52 +13355,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-nym/src/graphql/general/validators_address_list.graphql b/apps/web-nym/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-nym/src/graphql/general/validators_address_list.graphql +++ b/apps/web-nym/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-nym/src/graphql/types/general_types.ts b/apps/web-nym/src/graphql/types/general_types.ts index c98df8c3c9..a13260a0a4 100644 --- a/apps/web-nym/src/graphql/types/general_types.ts +++ b/apps/web-nym/src/graphql/types/general_types.ts @@ -13858,52 +13858,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-osmosis/src/graphql/general/validators_address_list.graphql b/apps/web-osmosis/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-osmosis/src/graphql/general/validators_address_list.graphql +++ b/apps/web-osmosis/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-osmosis/src/graphql/types/general_types.ts b/apps/web-osmosis/src/graphql/types/general_types.ts index b15f0753f5..9c44459080 100644 --- a/apps/web-osmosis/src/graphql/types/general_types.ts +++ b/apps/web-osmosis/src/graphql/types/general_types.ts @@ -13658,52 +13658,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-persistence/src/graphql/general/validators_address_list.graphql b/apps/web-persistence/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-persistence/src/graphql/general/validators_address_list.graphql +++ b/apps/web-persistence/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-persistence/src/graphql/types/general_types.ts b/apps/web-persistence/src/graphql/types/general_types.ts index e440908fad..3217092227 100644 --- a/apps/web-persistence/src/graphql/types/general_types.ts +++ b/apps/web-persistence/src/graphql/types/general_types.ts @@ -9663,52 +9663,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-provenance/src/graphql/general/validators_address_list.graphql b/apps/web-provenance/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-provenance/src/graphql/general/validators_address_list.graphql +++ b/apps/web-provenance/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-provenance/src/graphql/types/general_types.ts b/apps/web-provenance/src/graphql/types/general_types.ts index 3bd077ba5f..3adc17a032 100644 --- a/apps/web-provenance/src/graphql/types/general_types.ts +++ b/apps/web-provenance/src/graphql/types/general_types.ts @@ -13924,52 +13924,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-quasar/src/graphql/general/validators_address_list.graphql b/apps/web-quasar/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-quasar/src/graphql/general/validators_address_list.graphql +++ b/apps/web-quasar/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-quasar/src/graphql/types/general_types.ts b/apps/web-quasar/src/graphql/types/general_types.ts index 9c05052f3a..15a88d79a6 100644 --- a/apps/web-quasar/src/graphql/types/general_types.ts +++ b/apps/web-quasar/src/graphql/types/general_types.ts @@ -9421,52 +9421,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-quicksilver/src/graphql/general/validators_address_list.graphql b/apps/web-quicksilver/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-quicksilver/src/graphql/general/validators_address_list.graphql +++ b/apps/web-quicksilver/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-quicksilver/src/graphql/types/general_types.ts b/apps/web-quicksilver/src/graphql/types/general_types.ts index 4b75264b59..9c1a60b9ce 100644 --- a/apps/web-quicksilver/src/graphql/types/general_types.ts +++ b/apps/web-quicksilver/src/graphql/types/general_types.ts @@ -9461,52 +9461,6 @@ export function useCustomValidatorLazyQuery(baseOptions?: Apollo.LazyQueryHookOp export type CustomValidatorQueryHookResult = ReturnType; export type CustomValidatorLazyQueryHookResult = ReturnType; export type CustomValidatorQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-quicksilver/src/hooks/useConsensusProfile/index.ts b/apps/web-quicksilver/src/hooks/useConsensusProfile/index.ts deleted file mode 100644 index 97520c1bae..0000000000 --- a/apps/web-quicksilver/src/hooks/useConsensusProfile/index.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { useEffect, useState } from 'react'; -import { useRecoilCallback } from 'recoil'; -import * as R from 'ramda'; -import { writeProfile } from '@/recoil/profiles/selectors'; -import { useCustomValidatorQuery } from '@/graphql/types/general_types'; - -type Profile = { - name: string; - address: string; - imageUrl: string; - bio: string; - website: string; - consensusAddress: string; -}; - -interface ConsensusProfileResult { - profile: Profile | undefined; - loading: boolean; -} - -/** - * Accepts consensus address and returns the appropriate profile - * @param consensus - the consensus address of the validator - * @param validator - the operator address of the validator - * @returns The return value is an object with the following properties: - * name, address, imageUrl - */ -const useConsensusProfile = (consensus: string, validator: string): ConsensusProfileResult => { - const { data, loading } = useCustomValidatorQuery({ variables: { consensusAddress: consensus } }); - const [profile, setProfile] = useState(); - const setAvatarName = useRecoilCallback( - ({ set }) => - (address: string, avatarName: AvatarName | null) => - set(writeProfile(address), (prevState) => - R.equals(prevState, avatarName) ? prevState : avatarName - ), - [] - ); - useEffect(() => { - if (data && data.validatorDescriptions.length > 0) { - const validatorDescription = data.validatorDescriptions[0]; - const consensusAddress = validatorDescription.validator_address ?? ''; - const name = validatorDescription.moniker ?? ''; - const imageUrl = validatorDescription.avatar_url ?? ''; - const bio = validatorDescription.details ?? ''; - const website = validatorDescription.website ?? ''; - const address = validator; - const res: Profile = { - name, - address, - imageUrl, - bio, - website, - consensusAddress, - }; - setProfile(res); - setAvatarName(address, res); - } - }, [data, loading, setAvatarName, validator]); - - return { profile, loading }; -}; - -export default useConsensusProfile; diff --git a/apps/web-quicksilver/src/hooks/useCustomProfile/index.ts b/apps/web-quicksilver/src/hooks/useCustomProfile/index.ts deleted file mode 100644 index fc312164f6..0000000000 --- a/apps/web-quicksilver/src/hooks/useCustomProfile/index.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { useEffect, useState } from 'react'; -import { ValidatorType } from '@/screens/validators/components/list/types'; - -interface AvatarName { - className?: string; - imageUrl: string | ''; - address: string; - name: string; - href?: (address: string) => string; - image?: React.ReactNode; - target?: JSX.IntrinsicElements['a']['target']; -} - -/** - * Accepts a list of state items and returns the appropriate profiles - * @param item - * @return a loading state and a list of profiles - */ -const useCustomProfile = (item: ValidatorType[]) => { - const [loading, setLoading] = useState(true); - const [profiles, setProfiles] = useState([]); - - useEffect(() => { - if (item.length) { - const data = item.map((x) => { - const address = x.validator ?? x.moniker[0].validator_address ?? ''; - const name = x.moniker[0].moniker ?? ''; - const imageUrl = x.moniker[0].avatar_url ?? ''; - const bio = x.moniker[0].details ?? ''; - const website = x.moniker[0].website ?? ''; - return { - address, - name, - imageUrl, - bio, - website, - }; - }); - setProfiles(data); - setLoading(false); - } - }, [item, loading]); - - return { profiles, loading }; -}; - -export default useCustomProfile; diff --git a/apps/web-quicksilver/src/screens/home/components/blocks/components/desktop/index.tsx b/apps/web-quicksilver/src/screens/home/components/blocks/components/desktop/index.tsx deleted file mode 100644 index fedc64d4bd..0000000000 --- a/apps/web-quicksilver/src/screens/home/components/blocks/components/desktop/index.tsx +++ /dev/null @@ -1,127 +0,0 @@ -import AvatarName from '@/components/avatar_name'; -import Timestamp from '@/components/Timestamp'; -import useAppTranslation from '@/hooks/useAppTranslation'; -import useConsensusProfile from '@/hooks/useConsensusProfile'; -import useStyles from '@/screens/home/components/blocks/components/desktop/styles'; -import { columns } from '@/screens/home/components/blocks/components/desktop/utils'; -import type { ItemType } from '@/screens/home/components/blocks/types'; -import { getMiddleEllipsis } from '@/utils/get_middle_ellipsis'; -import { BLOCK_DETAILS } from '@/utils/go_to_page'; -import Table from '@mui/material/Table'; -import TableBody from '@mui/material/TableBody'; -import TableCell from '@mui/material/TableCell'; -import TableHead from '@mui/material/TableHead'; -import TableRow from '@mui/material/TableRow'; -import { AnimatePresence, motion, Variants } from 'framer-motion'; -import Link from 'next/link'; -import numeral from 'numeral'; -import { FC } from 'react'; - -type BlockRowProps = { - item: ItemType; -}; - -const variants: Variants = { - initial: { - height: 0, - display: 'flex', - alignItems: 'center', - overflow: 'hidden', - clipPath: 'inset(0 50 0 50)', - }, - animate: { - height: 50, - display: 'flex', - alignItems: 'center', - overflow: 'hidden', - clipPath: 'inset(0 0 0 0)', - }, - exit: { - height: 50, - display: 'flex', - alignItems: 'center', - overflow: 'hidden', - position: 'absolute', - marginTop: [50, 60], - opacity: 0, - transition: { duration: 0.5 }, - }, -}; - -const BlockRow: FC = ({ item }) => { - const { profile } = useConsensusProfile(item.consensusAddress, item.proposer); - const name = profile?.name ?? ''; - const imageUrl = profile?.imageUrl ?? ''; - const address = profile?.address ?? ''; - - const formattedData = { - height: ( - - {numeral(item.height).format('0,0')} - - ), - txs: numeral(item.txs).format('0,0'), - time: , - proposer: , - hash: getMiddleEllipsis(item.hash, { - beginning: 6, - ending: 5, - }), - }; - return ( - - {columns.map((column) => { - const { key, align } = column; - return ( - - - {formattedData[key as keyof typeof formattedData]} - - - ); - })} - - ); -}; - -type DesktopProps = { - className?: string; - items: ItemType[]; -}; - -const Desktop: FC = ({ className, items }) => { - const { t } = useAppTranslation('blocks'); - const { classes, cx } = useStyles(); - - return ( -
- - - - {columns.map((column) => ( - - {t(column.key)} - - ))} - - - - - {items.map((row) => ( - - ))} - - -
-
- ); -}; - -export default Desktop; diff --git a/apps/web-quicksilver/src/screens/home/components/blocks/hooks.ts b/apps/web-quicksilver/src/screens/home/components/blocks/hooks.ts deleted file mode 100644 index bf5a258c0d..0000000000 --- a/apps/web-quicksilver/src/screens/home/components/blocks/hooks.ts +++ /dev/null @@ -1,52 +0,0 @@ -import * as R from 'ramda'; -import { useCallback, useState } from 'react'; -import { - BlocksListenerSubscription, - useBlocksListenerSubscription, -} from '@/graphql/types/general_types'; -import type { BlocksState } from '@/screens/home/components/blocks/types'; - -const formatBlocks = (data: BlocksListenerSubscription) => - data.blocks.map((x) => { - const proposerAddress = x?.validator?.validatorInfo?.operatorAddress ?? ''; - const consensusAddress = x?.validator?.validatorInfo?.consensusAddress ?? ''; - return { - height: x.height, - txs: x.txs ?? 0, - hash: x.hash, - timestamp: x.timestamp, - proposer: proposerAddress, - consensusAddress, - }; - }) ?? []; - -export const useBlocks = () => { - const [state, setState] = useState({ - loading: true, - items: [], - }); - - const handleSetState = useCallback((stateChange: (prevState: BlocksState) => BlocksState) => { - setState((prevState) => { - const newState = stateChange(prevState); - return R.equals(prevState, newState) ? prevState : newState; - }); - }, []); - - // ================================ - // block subscription - // ================================ - useBlocksListenerSubscription({ - onData: (data) => { - handleSetState((prevState) => ({ - ...prevState, - loading: false, - items: data.data.data ? formatBlocks(data.data.data) : [], - })); - }, - }); - - return { - state, - }; -}; diff --git a/apps/web-quicksilver/src/screens/home/components/blocks/types.ts b/apps/web-quicksilver/src/screens/home/components/blocks/types.ts deleted file mode 100644 index 522c61a7cd..0000000000 --- a/apps/web-quicksilver/src/screens/home/components/blocks/types.ts +++ /dev/null @@ -1,15 +0,0 @@ -export interface BlockType { - height: number; - txs: number; - timestamp: string; - proposer: string; - hash: string; - consensusAddress: string; -} - -export interface BlocksState { - loading: boolean; - items: BlockType[]; -} - -export type ItemType = BlockType; diff --git a/apps/web-quicksilver/src/screens/validator_details/hooks.ts b/apps/web-quicksilver/src/screens/validator_details/hooks.ts deleted file mode 100644 index 2324d27865..0000000000 --- a/apps/web-quicksilver/src/screens/validator_details/hooks.ts +++ /dev/null @@ -1,177 +0,0 @@ -import { useRouter } from 'next/router'; -import * as R from 'ramda'; -import { useCallback, useEffect, useState } from 'react'; -import chainConfig from '@/chainConfig'; -import { useValidatorDetailsQuery, ValidatorDetailsQuery } from '@/graphql/types/general_types'; -import useConsensusProfile from '@/hooks/useConsensusProfile'; -import { SlashingParams } from '@/models'; -import { StatusType, ValidatorDetailsState } from '@/screens/validator_details/types'; -import { formatToken } from '@/utils/format_token'; -import { getValidatorCondition } from '@/utils/get_validator_condition'; - -const { extra, votingPowerTokenUnit } = chainConfig(); - -const initialTokenDenom: TokenUnit = { - value: '0', - displayDenom: '', - baseDenom: '', - exponent: 0, -}; - -const initialState: ValidatorDetailsState = { - exists: true, - desmosProfile: null, - overview: { - validator: '', - operatorAddress: '', - selfDelegateAddress: '', - consensusAddress: '', - description: '', - website: '', - }, - status: { - status: 0, - jailed: false, - tombstoned: false, - condition: 0, - commission: 0, - missedBlockCounter: 0, - signedBlockWindow: 0, - maxRate: '0', - }, - votingPower: { - height: 0, - overall: initialTokenDenom, - self: 0, - }, -}; - -// ============================ -// overview -// ============================ -const formatOverview = (data: ValidatorDetailsQuery) => { - const operatorAddress = data?.validator?.[0]?.validatorInfo?.operatorAddress ?? ''; - const selfDelegateAddress = data?.validator?.[0]?.validatorInfo?.selfDelegateAddress ?? ''; - const consensusAddress = data?.validator?.[0]?.validatorInfo?.consensusAddress ?? ''; - const profile = { - validator: operatorAddress, - operatorAddress, - selfDelegateAddress, - consensusAddress, - description: data.validator[0]?.validatorDescriptions?.[0]?.details ?? '', - website: data.validator[0]?.validatorDescriptions?.[0]?.website ?? '', - }; - - return profile; -}; - -// ============================ -// status -// ============================ -const formatStatus = (data: ValidatorDetailsQuery) => { - const slashingParams = SlashingParams.fromJson(data?.slashingParams?.[0]?.params ?? {}); - const missedBlockCounter = - data.validator[0]?.validatorSigningInfos?.[0]?.missedBlocksCounter ?? 0; - const { signedBlockWindow } = slashingParams; - const condition = getValidatorCondition(signedBlockWindow, missedBlockCounter); - - const profile: StatusType = { - status: data.validator[0]?.validatorStatuses?.[0]?.status ?? 3, - jailed: data.validator[0]?.validatorStatuses?.[0]?.jailed ?? false, - tombstoned: data.validator[0]?.validatorSigningInfos?.[0]?.tombstoned ?? false, - commission: data.validator[0]?.validatorCommissions?.[0]?.commission ?? 0, - condition, - missedBlockCounter, - signedBlockWindow, - maxRate: data?.validator?.[0]?.validatorInfo?.maxRate ?? '0', - }; - - return profile; -}; - -// ============================ -// votingPower -// ============================ -const formatVotingPower = (data: ValidatorDetailsQuery) => { - const selfVotingPower = - (data.validator[0]?.validatorVotingPowers?.[0]?.votingPower ?? 0) / - 10 ** (extra.votingPowerExponent ?? 0); - - const votingPower = { - self: selfVotingPower, - overall: formatToken(data?.stakingPool?.[0]?.bonded ?? 0, votingPowerTokenUnit), - height: data.validator[0]?.validatorVotingPowers?.[0]?.height ?? 0, - }; - - return votingPower; -}; - -export const useValidatorDetails = () => { - const router = useRouter(); - const [state, setState] = useState(initialState); - - const handleSetState = useCallback( - (stateChange: (prevState: ValidatorDetailsState) => ValidatorDetailsState) => { - setState((prevState) => { - const newState = stateChange(prevState); - return R.equals(prevState, newState) ? prevState : newState; - }); - }, - [] - ); - - // ========================== - // Fetch Data - // ========================== - const { loading } = useValidatorDetailsQuery({ - variables: { - address: router.query.address as string, - }, - onCompleted: (data) => { - handleSetState((prevState) => ({ ...prevState, ...formatAccountQuery(data) })); - }, - }); - - // ========================== - // Celestia Profile - // ========================== - const { profile: dataDesmosProfile, loading: loadingDesmosProfile } = useConsensusProfile( - state.overview.consensusAddress, - state.overview.selfDelegateAddress - ); - useEffect(() => { - if (dataDesmosProfile) { - const { name, imageUrl, bio } = dataDesmosProfile; - setState((prevState) => ({ - ...prevState, - desmosProfile: { - name, - imageUrl, - bio, - dtag: name, - nickname: name, - coverUrl: '', - connections: [], - }, - })); - } - }, [dataDesmosProfile]); - - return { state, loading: loading || loadingDesmosProfile }; -}; - -function formatAccountQuery(data: ValidatorDetailsQuery): Partial { - const stateChange: Partial = {}; - - if (!data.validator.length) { - stateChange.exists = false; - return stateChange; - } - - stateChange.overview = formatOverview(data); - - stateChange.status = formatStatus(data); - stateChange.votingPower = formatVotingPower(data); - - return stateChange; -} diff --git a/apps/web-quicksilver/src/screens/validator_details/types.ts b/apps/web-quicksilver/src/screens/validator_details/types.ts deleted file mode 100644 index df700ad40f..0000000000 --- a/apps/web-quicksilver/src/screens/validator_details/types.ts +++ /dev/null @@ -1,34 +0,0 @@ -export interface OverviewType { - validator: string; - operatorAddress: string; - selfDelegateAddress: string; - consensusAddress: string; - description: string; - website: string; -} - -export interface StatusType { - inActiveSet?: string; - jailed: boolean; - tombstoned: boolean; - commission: number; - signedBlockWindow: number; - missedBlockCounter: number; - maxRate: string; - status: number; - condition: number; -} - -export interface VotingPowerType { - height: number; - overall: TokenUnit; - self: number; -} - -export interface ValidatorDetailsState { - exists: boolean; - desmosProfile: DesmosProfile | null; - overview: OverviewType; - status: StatusType; - votingPower: VotingPowerType; -} diff --git a/apps/web-quicksilver/src/screens/validators/components/list/hooks.ts b/apps/web-quicksilver/src/screens/validators/components/list/hooks.ts deleted file mode 100644 index b42cb49595..0000000000 --- a/apps/web-quicksilver/src/screens/validators/components/list/hooks.ts +++ /dev/null @@ -1,213 +0,0 @@ -import Big from 'big.js'; -import numeral from 'numeral'; -import * as R from 'ramda'; -import { SyntheticEvent, useCallback, useState } from 'react'; -import chainConfig from '@/chainConfig'; -import { useValidatorsQuery, ValidatorsQuery } from '@/graphql/types/general_types'; -import { SlashingParams } from '@/models'; -import type { - ItemType, - ValidatorsState, - ValidatorType, -} from '@/screens/validators/components/list/types'; -import { formatToken } from '@/utils/format_token'; -import { getValidatorCondition } from '@/utils/get_validator_condition'; - -const { extra, votingPowerTokenUnit } = chainConfig(); - -// ========================== -// Parse data -// ========================== -const formatValidators = (data: ValidatorsQuery): Partial => { - const slashingParams = SlashingParams.fromJson(data?.slashingParams?.[0]?.params ?? {}); - const votingPowerOverall = - numeral( - formatToken(data?.stakingPool?.[0]?.bondedTokens ?? 0, votingPowerTokenUnit).value - ).value() ?? 0; - - const { signedBlockWindow } = slashingParams; - - let formattedItems: ValidatorType[] = data.validator - .filter((x) => x.validatorInfo && x.validatorDescriptions) - .map((x) => { - const votingPower = - (x?.validatorVotingPowers?.[0]?.votingPower ?? 0) / 10 ** (extra.votingPowerExponent ?? 0); - const votingPowerPercent = votingPowerOverall - ? numeral((votingPower / votingPowerOverall) * 100).value() - : 0; - - const missedBlockCounter = x?.validatorSigningInfos?.[0]?.missedBlocksCounter ?? 0; - const condition = getValidatorCondition(signedBlockWindow, missedBlockCounter); - - return { - moniker: x.validatorDescriptions ?? '', - consensus: x.validatorInfo?.consensusAddress ?? '', - validator: x.validatorInfo?.operatorAddress ?? '', - votingPower: votingPower ?? 0, - votingPowerPercent: votingPowerPercent ?? 0, - commission: (x?.validatorCommissions?.[0]?.commission ?? 0) * 100, - condition, - status: x?.validatorStatuses?.[0]?.status ?? 0, - jailed: x?.validatorStatuses?.[0]?.jailed ?? false, - tombstoned: x?.validatorSigningInfos?.[0]?.tombstoned ?? false, - }; - }); - - // get the top 34% validators - formattedItems = formattedItems.sort((a, b) => (a.votingPower > b.votingPower ? -1 : 1)); - - // add key to indicate they are part of top 34% - let cumulativeVotingPower = Big(0); - let reached = false; - formattedItems.forEach((x) => { - if (x.status === 3) { - const totalVp = cumulativeVotingPower.add(x.votingPowerPercent); - if (totalVp.lte(34) && !reached) { - x.topVotingPower = true; - } - - if (totalVp.gt(34) && !reached) { - x.topVotingPower = true; - reached = true; - } - - cumulativeVotingPower = totalVp; - } - }); - - return { - votingPowerOverall, - items: formattedItems, - }; -}; - -export const useValidators = () => { - const [search, setSearch] = useState(''); - const [state, setState] = useState({ - loading: true, - exists: true, - items: [], - votingPowerOverall: 0, - tab: 0, - sortKey: 'validator.name', - sortDirection: 'asc', - }); - - const handleSetState = useCallback( - (stateChange: (prevState: ValidatorsState) => ValidatorsState) => { - setState((prevState) => { - const newState = stateChange(prevState); - return R.equals(prevState, newState) ? prevState : newState; - }); - }, - [] - ); - - // ========================== - // Fetch Data - // ========================== - useValidatorsQuery({ - onCompleted: (data) => { - handleSetState((prevState) => ({ - ...prevState, - loading: false, - ...formatValidators(data), - })); - }, - onError: () => { - handleSetState((prevState) => ({ - ...prevState, - loading: false, - exists: false, - })); - }, - }); - - const handleTabChange = useCallback( - (_event: SyntheticEvent, newValue: number) => { - setState((prevState) => ({ - ...prevState, - tab: newValue, - })); - }, - [] - ); - - const handleSort = useCallback( - (key: string) => { - if (key === state.sortKey) { - setState((prevState) => ({ - ...prevState, - sortDirection: prevState.sortDirection === 'asc' ? 'desc' : 'asc', - })); - } else { - setState((prevState) => ({ - ...prevState, - sortKey: key, - sortDirection: 'asc', // new key so we start the sort by asc - })); - } - }, - [state.sortKey] - ); - - const handleSearch = useCallback((value: string) => { - setSearch(value); - }, []); - - const sortItems = useCallback( - (items: ItemType[]) => { - let sorted: ItemType[] = R.clone(items); - - if (state.tab === 0) { - sorted = sorted.filter((x) => x.status === 3); - } - - if (state.tab === 1) { - sorted = sorted.filter((x) => x.status !== 3); - } - - if (search) { - sorted = sorted.filter((x) => { - const formattedSearch = search.toLowerCase().replace(/ /g, ''); - return ( - x.validator.name.toLowerCase().replace(/ /g, '').includes(formattedSearch) || - x.validator.address.toLowerCase().includes(formattedSearch) - ); - }); - } - - if (state.sortKey && state.sortDirection) { - sorted.sort((a, b) => { - let compareA = R.pathOr('', [...state.sortKey.split('.')], a); - let compareB = R.pathOr('', [...state.sortKey.split('.')], b); - - if (typeof compareA === 'string' && typeof compareB === 'string') { - compareA = compareA.toLowerCase(); - compareB = compareB.toLowerCase(); - } - - if (compareA < compareB) { - return state.sortDirection === 'asc' ? -1 : 1; - } - if (compareA > compareB) { - return state.sortDirection === 'asc' ? 1 : -1; - } - return 0; - }); - } - - return sorted; - }, - [search, state.sortDirection, state.sortKey, state.tab] - ); - - return { - state, - handleTabChange, - handleSort, - handleSearch, - sortItems, - search, - }; -}; diff --git a/apps/web-quicksilver/src/screens/validators/components/list/index.tsx b/apps/web-quicksilver/src/screens/validators/components/list/index.tsx deleted file mode 100644 index 26965f3d07..0000000000 --- a/apps/web-quicksilver/src/screens/validators/components/list/index.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import { FC, ReactNode, useMemo } from 'react'; -import Box from '@/components/box'; -import LoadAndExist from '@/components/load_and_exist'; -import NoData from '@/components/no_data'; -import Desktop from '@/screens/validators/components/list/components/desktop'; -import Mobile from '@/screens/validators/components/list/components/mobile'; -import Tabs from '@/screens/validators/components/list/components/tabs'; -import { useValidators } from '@/screens/validators/components/list/hooks'; -import useStyles from '@/screens/validators/components/list/styles'; -import { useDisplayStyles } from '@/styles/useSharedStyles'; -import useCustomProfile from '@/hooks/useCustomProfile'; - -const List: FC = ({ className }) => { - const { classes, cx } = useStyles(); - const display = useDisplayStyles().classes; - const { state, handleTabChange, handleSearch, handleSort, sortItems, search } = useValidators(); - const { profiles: dataProfiles, loading } = useCustomProfile(state.items); - const items = useMemo( - () => sortItems(state.items.map((x, i) => ({ ...x, validator: dataProfiles?.[i] }))), - [state.items, dataProfiles, sortItems] - ); - - let list: ReactNode; - - if (!items.length) { - list = ; - } else { - list = ( - <> - - - - ); - } - - return ( - - - -
{list}
-
-
- ); -}; - -export default List; diff --git a/apps/web-quicksilver/src/screens/validators/components/list/types.ts b/apps/web-quicksilver/src/screens/validators/components/list/types.ts deleted file mode 100644 index 52031b052b..0000000000 --- a/apps/web-quicksilver/src/screens/validators/components/list/types.ts +++ /dev/null @@ -1,32 +0,0 @@ -interface MonikerType { - moniker?: string | null | undefined; - avatar_url?: string | null; - validator_address: string; - website?: string | null; - details?: string | null; -} - -export interface ValidatorType { - moniker: MonikerType[]; - validator: string; - votingPower: number; - votingPowerPercent: number; - commission: number; - condition: number; - status: number; - jailed: boolean; - tombstoned: boolean; - topVotingPower?: boolean; // top 34% VP -} - -export interface ValidatorsState { - loading: boolean; - exists: boolean; - tab: number; - sortKey: string; - sortDirection: 'asc' | 'desc'; - votingPowerOverall: number; - items: ValidatorType[]; -} - -export type ItemType = Override; diff --git a/apps/web-regen/src/graphql/general/validators_address_list.graphql b/apps/web-regen/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-regen/src/graphql/general/validators_address_list.graphql +++ b/apps/web-regen/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-regen/src/graphql/types/general_types.ts b/apps/web-regen/src/graphql/types/general_types.ts index 7d6b897e07..725e55c53c 100644 --- a/apps/web-regen/src/graphql/types/general_types.ts +++ b/apps/web-regen/src/graphql/types/general_types.ts @@ -13649,52 +13649,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-rizon/src/graphql/general/validators_address_list.graphql b/apps/web-rizon/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-rizon/src/graphql/general/validators_address_list.graphql +++ b/apps/web-rizon/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-rizon/src/graphql/types/general_types.ts b/apps/web-rizon/src/graphql/types/general_types.ts index cc3e2cfd13..1cb0027360 100644 --- a/apps/web-rizon/src/graphql/types/general_types.ts +++ b/apps/web-rizon/src/graphql/types/general_types.ts @@ -13164,52 +13164,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-shentu/src/graphql/general/validators_address_list.graphql b/apps/web-shentu/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-shentu/src/graphql/general/validators_address_list.graphql +++ b/apps/web-shentu/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-shentu/src/graphql/types/general_types.ts b/apps/web-shentu/src/graphql/types/general_types.ts index d1bf9ca9e8..4e66946038 100644 --- a/apps/web-shentu/src/graphql/types/general_types.ts +++ b/apps/web-shentu/src/graphql/types/general_types.ts @@ -15058,52 +15058,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-stride/src/graphql/general/validators_address_list.graphql b/apps/web-stride/src/graphql/general/validators_address_list.graphql index 7a105bb9f1..12756f1cb9 100644 --- a/apps/web-stride/src/graphql/general/validators_address_list.graphql +++ b/apps/web-stride/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-stride/src/graphql/types/general_types.ts b/apps/web-stride/src/graphql/types/general_types.ts index 5a87a922f9..9297126614 100644 --- a/apps/web-stride/src/graphql/types/general_types.ts +++ b/apps/web-stride/src/graphql/types/general_types.ts @@ -24013,52 +24013,6 @@ export function useProviderCustomValidatorLazyQuery(baseOptions?: Apollo.LazyQue export type ProviderCustomValidatorQueryHookResult = ReturnType; export type ProviderCustomValidatorLazyQueryHookResult = ReturnType; export type ProviderCustomValidatorQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web-stride/src/hooks/useCustomProfile/index.ts b/apps/web-stride/src/hooks/useCustomProfile/index.ts deleted file mode 100644 index fc312164f6..0000000000 --- a/apps/web-stride/src/hooks/useCustomProfile/index.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { useEffect, useState } from 'react'; -import { ValidatorType } from '@/screens/validators/components/list/types'; - -interface AvatarName { - className?: string; - imageUrl: string | ''; - address: string; - name: string; - href?: (address: string) => string; - image?: React.ReactNode; - target?: JSX.IntrinsicElements['a']['target']; -} - -/** - * Accepts a list of state items and returns the appropriate profiles - * @param item - * @return a loading state and a list of profiles - */ -const useCustomProfile = (item: ValidatorType[]) => { - const [loading, setLoading] = useState(true); - const [profiles, setProfiles] = useState([]); - - useEffect(() => { - if (item.length) { - const data = item.map((x) => { - const address = x.validator ?? x.moniker[0].validator_address ?? ''; - const name = x.moniker[0].moniker ?? ''; - const imageUrl = x.moniker[0].avatar_url ?? ''; - const bio = x.moniker[0].details ?? ''; - const website = x.moniker[0].website ?? ''; - return { - address, - name, - imageUrl, - bio, - website, - }; - }); - setProfiles(data); - setLoading(false); - } - }, [item, loading]); - - return { profiles, loading }; -}; - -export default useCustomProfile; diff --git a/apps/web-stride/src/screens/validator_details/hooks.ts b/apps/web-stride/src/screens/validator_details/hooks.ts deleted file mode 100644 index 1676c2ece8..0000000000 --- a/apps/web-stride/src/screens/validator_details/hooks.ts +++ /dev/null @@ -1,161 +0,0 @@ -import { useRouter } from 'next/router'; -import * as R from 'ramda'; -import { useCallback, useEffect, useState } from 'react'; -import chainConfig from '@/chainConfig'; -import { useValidatorDetailsQuery, ValidatorDetailsQuery } from '@/graphql/types/general_types'; -import { useDesmosProfile } from '@/hooks/use_desmos_profile'; -import { SlashingParams } from '@/models'; -import { StatusType, ValidatorDetailsState } from '@/screens/validator_details/types'; -import { formatToken } from '@/utils/format_token'; -import { getValidatorCondition } from '@/utils/get_validator_condition'; - -const { extra, votingPowerTokenUnit } = chainConfig(); - -const initialTokenDenom: TokenUnit = { - value: '0', - displayDenom: '', - baseDenom: '', - exponent: 0, -}; - -const initialState: ValidatorDetailsState = { - exists: true, - desmosProfile: null, - overview: { - validator: '', - operatorAddress: '', - selfDelegateAddress: '', - description: '', - website: '', - }, - status: { - status: 0, - jailed: false, - tombstoned: false, - condition: 0, - commission: 0, - missedBlockCounter: 0, - signedBlockWindow: 0, - maxRate: '0', - }, - votingPower: { - height: 0, - overall: initialTokenDenom, - self: 0, - }, -}; - -// ============================ -// overview -// ============================ -const formatOverview = (data: ValidatorDetailsQuery) => { - const operatorAddress = data?.validator?.[0]?.validatorInfo?.operatorAddress ?? ''; - const selfDelegateAddress = data?.validator?.[0]?.validatorInfo?.selfDelegateAddress ?? ''; - const profile = { - validator: operatorAddress, - operatorAddress, - selfDelegateAddress, - description: data.validator[0]?.validatorDescriptions?.[0]?.details ?? '', - website: data.validator[0]?.validatorDescriptions?.[0]?.website ?? '', - }; - - return profile; -}; - -// ============================ -// status -// ============================ -const formatStatus = (data: ValidatorDetailsQuery) => { - const slashingParams = SlashingParams.fromJson(data?.slashingParams?.[0]?.params ?? {}); - const missedBlockCounter = - data.validator[0]?.validatorSigningInfos?.[0]?.missedBlocksCounter ?? 0; - const { signedBlockWindow } = slashingParams; - const condition = getValidatorCondition(signedBlockWindow, missedBlockCounter); - - const profile: StatusType = { - status: data.validator[0]?.validatorStatuses?.[0]?.status ?? 3, - jailed: data.validator[0]?.validatorStatuses?.[0]?.jailed ?? false, - tombstoned: data.validator[0]?.validatorSigningInfos?.[0]?.tombstoned ?? false, - commission: data.validator[0]?.validatorCommissions?.[0]?.commission ?? 0, - condition, - missedBlockCounter, - signedBlockWindow, - maxRate: data?.validator?.[0]?.validatorInfo?.maxRate ?? '0', - }; - - return profile; -}; - -// ============================ -// votingPower -// ============================ -const formatVotingPower = (data: ValidatorDetailsQuery) => { - const selfVotingPower = - (data.validator[0]?.validatorVotingPowers?.[0]?.votingPower ?? 0) / - 10 ** (extra.votingPowerExponent ?? 0); - - const votingPower = { - self: selfVotingPower, - overall: formatToken(data?.stakingPool?.[0]?.bonded ?? 0, votingPowerTokenUnit), - height: data.validator[0]?.validatorVotingPowers?.[0]?.height ?? 0, - }; - - return votingPower; -}; - -export const useValidatorDetails = () => { - const router = useRouter(); - const [state, setState] = useState(initialState); - - const handleSetState = useCallback( - (stateChange: (prevState: ValidatorDetailsState) => ValidatorDetailsState) => { - setState((prevState) => { - const newState = stateChange(prevState); - return R.equals(prevState, newState) ? prevState : newState; - }); - }, - [] - ); - - // ========================== - // Fetch Data - // ========================== - const { loading } = useValidatorDetailsQuery({ - variables: { - address: router.query.address as string, - }, - onCompleted: (data) => { - handleSetState((prevState) => ({ ...prevState, ...formatAccountQuery(data) })); - }, - }); - - // ========================== - // Desmos Profile - // ========================== - const { data: dataDesmosProfile, loading: loadingDesmosProfile } = useDesmosProfile({ - addresses: [state.overview.selfDelegateAddress], - skip: !extra.profile || !state.overview.selfDelegateAddress, - }); - useEffect( - () => setState((prevState) => ({ ...prevState, desmosProfile: dataDesmosProfile?.[0] })), - [dataDesmosProfile] - ); - - return { state, loading: loading || loadingDesmosProfile }; -}; - -function formatAccountQuery(data: ValidatorDetailsQuery): Partial { - const stateChange: Partial = {}; - - if (!data.validator.length) { - stateChange.exists = false; - return stateChange; - } - - stateChange.overview = formatOverview(data); - - stateChange.status = formatStatus(data); - stateChange.votingPower = formatVotingPower(data); - - return stateChange; -} diff --git a/apps/web-stride/src/screens/validators/components/list/hooks.ts b/apps/web-stride/src/screens/validators/components/list/hooks.ts deleted file mode 100644 index 5793afad60..0000000000 --- a/apps/web-stride/src/screens/validators/components/list/hooks.ts +++ /dev/null @@ -1,212 +0,0 @@ -import Big from 'big.js'; -import numeral from 'numeral'; -import * as R from 'ramda'; -import { SyntheticEvent, useCallback, useState } from 'react'; -import chainConfig from '@/chainConfig'; -import { useValidatorsQuery, ValidatorsQuery } from '@/graphql/types/general_types'; -import { SlashingParams } from '@/models'; -import type { - ItemType, - ValidatorsState, - ValidatorType, -} from '@/screens/validators/components/list/types'; -import { formatToken } from '@/utils/format_token'; -import { getValidatorCondition } from '@/utils/get_validator_condition'; - -const { extra, votingPowerTokenUnit } = chainConfig(); - -// ========================== -// Parse data -// ========================== -const formatValidators = (data: ValidatorsQuery): Partial => { - const slashingParams = SlashingParams.fromJson(data?.slashingParams?.[0]?.params ?? {}); - const votingPowerOverall = - numeral( - formatToken(data?.stakingPool?.[0]?.bondedTokens ?? 0, votingPowerTokenUnit).value - ).value() ?? 0; - - const { signedBlockWindow } = slashingParams; - - let formattedItems: ValidatorType[] = data.validator - .filter((x) => x.validatorInfo && x.validatorDescriptions) - .map((x) => { - const votingPower = - (x?.validatorVotingPowers?.[0]?.votingPower ?? 0) / 10 ** (extra.votingPowerExponent ?? 0); - const votingPowerPercent = votingPowerOverall - ? numeral((votingPower / votingPowerOverall) * 100).value() - : 0; - - const missedBlockCounter = x?.validatorSigningInfos?.[0]?.missedBlocksCounter ?? 0; - const condition = getValidatorCondition(signedBlockWindow, missedBlockCounter); - - return { - moniker: x.validatorDescriptions ?? '', - validator: x.validatorInfo?.operatorAddress ?? '', - votingPower: votingPower ?? 0, - votingPowerPercent: votingPowerPercent ?? 0, - commission: (x?.validatorCommissions?.[0]?.commission ?? 0) * 100, - condition, - status: x?.validatorStatuses?.[0]?.status ?? 0, - jailed: x?.validatorStatuses?.[0]?.jailed ?? false, - tombstoned: x?.validatorSigningInfos?.[0]?.tombstoned ?? false, - }; - }); - - // get the top 34% validators - formattedItems = formattedItems.sort((a, b) => (a.votingPower > b.votingPower ? -1 : 1)); - - // add key to indicate they are part of top 34% - let cumulativeVotingPower = Big(0); - let reached = false; - formattedItems.forEach((x) => { - if (x.status === 3) { - const totalVp = cumulativeVotingPower.add(x.votingPowerPercent); - if (totalVp.lte(34) && !reached) { - x.topVotingPower = true; - } - - if (totalVp.gt(34) && !reached) { - x.topVotingPower = true; - reached = true; - } - - cumulativeVotingPower = totalVp; - } - }); - - return { - votingPowerOverall, - items: formattedItems, - }; -}; - -export const useValidators = () => { - const [search, setSearch] = useState(''); - const [state, setState] = useState({ - loading: true, - exists: true, - items: [], - votingPowerOverall: 0, - tab: 0, - sortKey: 'validator.name', - sortDirection: 'asc', - }); - - const handleSetState = useCallback( - (stateChange: (prevState: ValidatorsState) => ValidatorsState) => { - setState((prevState) => { - const newState = stateChange(prevState); - return R.equals(prevState, newState) ? prevState : newState; - }); - }, - [] - ); - - // ========================== - // Fetch Data - // ========================== - useValidatorsQuery({ - onCompleted: (data) => { - handleSetState((prevState) => ({ - ...prevState, - loading: false, - ...formatValidators(data), - })); - }, - onError: () => { - handleSetState((prevState) => ({ - ...prevState, - loading: false, - exists: false, - })); - }, - }); - - const handleTabChange = useCallback( - (_event: SyntheticEvent, newValue: number) => { - setState((prevState) => ({ - ...prevState, - tab: newValue, - })); - }, - [] - ); - - const handleSort = useCallback( - (key: string) => { - if (key === state.sortKey) { - setState((prevState) => ({ - ...prevState, - sortDirection: prevState.sortDirection === 'asc' ? 'desc' : 'asc', - })); - } else { - setState((prevState) => ({ - ...prevState, - sortKey: key, - sortDirection: 'asc', // new key so we start the sort by asc - })); - } - }, - [state.sortKey] - ); - - const handleSearch = useCallback((value: string) => { - setSearch(value); - }, []); - - const sortItems = useCallback( - (items: ItemType[]) => { - let sorted: ItemType[] = R.clone(items); - - if (state.tab === 0) { - sorted = sorted.filter((x) => x.status === 3); - } - - if (state.tab === 1) { - sorted = sorted.filter((x) => x.status !== 3); - } - - if (search) { - sorted = sorted.filter((x) => { - const formattedSearch = search.toLowerCase().replace(/ /g, ''); - return ( - x.validator.name.toLowerCase().replace(/ /g, '').includes(formattedSearch) || - x.validator.address.toLowerCase().includes(formattedSearch) - ); - }); - } - - if (state.sortKey && state.sortDirection) { - sorted.sort((a, b) => { - let compareA = R.pathOr('', [...state.sortKey.split('.')], a); - let compareB = R.pathOr('', [...state.sortKey.split('.')], b); - - if (typeof compareA === 'string' && typeof compareB === 'string') { - compareA = compareA.toLowerCase(); - compareB = compareB.toLowerCase(); - } - - if (compareA < compareB) { - return state.sortDirection === 'asc' ? -1 : 1; - } - if (compareA > compareB) { - return state.sortDirection === 'asc' ? 1 : -1; - } - return 0; - }); - } - - return sorted; - }, - [search, state.sortDirection, state.sortKey, state.tab] - ); - - return { - state, - handleTabChange, - handleSort, - handleSearch, - sortItems, - search, - }; -}; diff --git a/apps/web-stride/src/screens/validators/components/list/index.tsx b/apps/web-stride/src/screens/validators/components/list/index.tsx deleted file mode 100644 index 26965f3d07..0000000000 --- a/apps/web-stride/src/screens/validators/components/list/index.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import { FC, ReactNode, useMemo } from 'react'; -import Box from '@/components/box'; -import LoadAndExist from '@/components/load_and_exist'; -import NoData from '@/components/no_data'; -import Desktop from '@/screens/validators/components/list/components/desktop'; -import Mobile from '@/screens/validators/components/list/components/mobile'; -import Tabs from '@/screens/validators/components/list/components/tabs'; -import { useValidators } from '@/screens/validators/components/list/hooks'; -import useStyles from '@/screens/validators/components/list/styles'; -import { useDisplayStyles } from '@/styles/useSharedStyles'; -import useCustomProfile from '@/hooks/useCustomProfile'; - -const List: FC = ({ className }) => { - const { classes, cx } = useStyles(); - const display = useDisplayStyles().classes; - const { state, handleTabChange, handleSearch, handleSort, sortItems, search } = useValidators(); - const { profiles: dataProfiles, loading } = useCustomProfile(state.items); - const items = useMemo( - () => sortItems(state.items.map((x, i) => ({ ...x, validator: dataProfiles?.[i] }))), - [state.items, dataProfiles, sortItems] - ); - - let list: ReactNode; - - if (!items.length) { - list = ; - } else { - list = ( - <> - - - - ); - } - - return ( - - - -
{list}
-
-
- ); -}; - -export default List; diff --git a/apps/web-stride/src/screens/validators/components/list/types.ts b/apps/web-stride/src/screens/validators/components/list/types.ts deleted file mode 100644 index 52031b052b..0000000000 --- a/apps/web-stride/src/screens/validators/components/list/types.ts +++ /dev/null @@ -1,32 +0,0 @@ -interface MonikerType { - moniker?: string | null | undefined; - avatar_url?: string | null; - validator_address: string; - website?: string | null; - details?: string | null; -} - -export interface ValidatorType { - moniker: MonikerType[]; - validator: string; - votingPower: number; - votingPowerPercent: number; - commission: number; - condition: number; - status: number; - jailed: boolean; - tombstoned: boolean; - topVotingPower?: boolean; // top 34% VP -} - -export interface ValidatorsState { - loading: boolean; - exists: boolean; - tab: number; - sortKey: string; - sortDirection: 'asc' | 'desc'; - votingPowerOverall: number; - items: ValidatorType[]; -} - -export type ItemType = Override; diff --git a/apps/web-wormhole/src/graphql/general/validators_address_list.graphql b/apps/web-wormhole/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web-wormhole/src/graphql/general/validators_address_list.graphql +++ b/apps/web-wormhole/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web-wormhole/src/graphql/types/general_types.ts b/apps/web-wormhole/src/graphql/types/general_types.ts index a2011b571c..e5192df66c 100644 --- a/apps/web-wormhole/src/graphql/types/general_types.ts +++ b/apps/web-wormhole/src/graphql/types/general_types.ts @@ -10382,52 +10382,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/apps/web/src/graphql/general/validators_address_list.graphql b/apps/web/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/apps/web/src/graphql/general/validators_address_list.graphql +++ b/apps/web/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/apps/web/src/graphql/types/general_types.ts b/apps/web/src/graphql/types/general_types.ts index 24624c5a4b..f300b55cac 100644 --- a/apps/web/src/graphql/types/general_types.ts +++ b/apps/web/src/graphql/types/general_types.ts @@ -13884,52 +13884,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/packages/ui/src/graphql/general/proposal_details.graphql b/packages/ui/src/graphql/general/proposal_details.graphql index 82ddef911b..e298e93cc8 100644 --- a/packages/ui/src/graphql/general/proposal_details.graphql +++ b/packages/ui/src/graphql/general/proposal_details.graphql @@ -7,7 +7,6 @@ query ProposalDetails($proposalId: Int) { content proposalId: id submitTime: submit_time - proposalType: proposal_type depositEndTime: deposit_end_time votingStartTime: voting_start_time votingEndTime: voting_end_time diff --git a/packages/ui/src/graphql/general/validators_address_list.graphql b/packages/ui/src/graphql/general/validators_address_list.graphql index d018f104bc..62523d5466 100644 --- a/packages/ui/src/graphql/general/validators_address_list.graphql +++ b/packages/ui/src/graphql/general/validators_address_list.graphql @@ -1,18 +1,3 @@ -query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions(limit: 1, order_by: {height: desc}) { - moniker - identity - avatarUrl: avatar_url - } - } -} - query ValidatorAddresses { validator(where: {validator_info: {operator_address: {_is_null: false}, consensus_address: {_is_null: false}, self_delegate_address: {_is_null: false}}}) { validatorInfo: validator_info { diff --git a/packages/ui/src/graphql/types/general_types.ts b/packages/ui/src/graphql/types/general_types.ts index 24624c5a4b..f300b55cac 100644 --- a/packages/ui/src/graphql/types/general_types.ts +++ b/packages/ui/src/graphql/types/general_types.ts @@ -13884,52 +13884,6 @@ export function useValidatorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type ValidatorsQueryHookResult = ReturnType; export type ValidatorsLazyQueryHookResult = ReturnType; export type ValidatorsQueryResult = Apollo.QueryResult; -export const ValidatorsAddressListDocument = gql` - query ValidatorsAddressList { - validator { - validatorInfo: validator_info { - operatorAddress: operator_address - selfDelegateAddress: self_delegate_address - consensusAddress: consensus_address - } - validatorDescriptions: validator_descriptions( - limit: 1 - order_by: {height: desc} - ) { - moniker - identity - avatarUrl: avatar_url - } - } -} - `; - -/** - * __useValidatorsAddressListQuery__ - * - * To run a query within a React component, call `useValidatorsAddressListQuery` and pass it any options that fit your needs. - * When your component renders, `useValidatorsAddressListQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useValidatorsAddressListQuery({ - * variables: { - * }, - * }); - */ -export function useValidatorsAddressListQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ValidatorsAddressListDocument, options); - } -export function useValidatorsAddressListLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ValidatorsAddressListDocument, options); - } -export type ValidatorsAddressListQueryHookResult = ReturnType; -export type ValidatorsAddressListLazyQueryHookResult = ReturnType; -export type ValidatorsAddressListQueryResult = Apollo.QueryResult; export const ValidatorAddressesDocument = gql` query ValidatorAddresses { validator( diff --git a/packages/ui/src/graphql/types/profile_types.ts b/packages/ui/src/graphql/types/profile_types.ts index 3de2066bc5..d56e03631c 100644 --- a/packages/ui/src/graphql/types/profile_types.ts +++ b/packages/ui/src/graphql/types/profile_types.ts @@ -760,6 +760,10 @@ export type Query_Root = { profile_by_pk?: Maybe; /** fetch data from the table: "profiles_params" */ profiles_params: Array; + /** fetch data from the table: "user_block" */ + user_block: Array; + /** fetch data from the table: "user_relationship" */ + user_relationship: Array; }; @@ -848,6 +852,24 @@ export type Query_RootProfiles_ParamsArgs = { where?: InputMaybe; }; + +export type Query_RootUser_BlockArgs = { + distinct_on?: InputMaybe>; + limit?: InputMaybe; + offset?: InputMaybe; + order_by?: InputMaybe>; + where?: InputMaybe; +}; + + +export type Query_RootUser_RelationshipArgs = { + distinct_on?: InputMaybe>; + limit?: InputMaybe; + offset?: InputMaybe; + order_by?: InputMaybe>; + where?: InputMaybe; +}; + export type Subscription_Root = { __typename?: 'subscription_root'; /** fetch data from the table: "application_link" */ @@ -870,6 +892,10 @@ export type Subscription_Root = { profile_by_pk?: Maybe; /** fetch data from the table: "profiles_params" */ profiles_params: Array; + /** fetch data from the table: "user_block" */ + user_block: Array; + /** fetch data from the table: "user_relationship" */ + user_relationship: Array; }; @@ -958,6 +984,24 @@ export type Subscription_RootProfiles_ParamsArgs = { where?: InputMaybe; }; + +export type Subscription_RootUser_BlockArgs = { + distinct_on?: InputMaybe>; + limit?: InputMaybe; + offset?: InputMaybe; + order_by?: InputMaybe>; + where?: InputMaybe; +}; + + +export type Subscription_RootUser_RelationshipArgs = { + distinct_on?: InputMaybe>; + limit?: InputMaybe; + offset?: InputMaybe; + order_by?: InputMaybe>; + where?: InputMaybe; +}; + /** Boolean expression to compare columns of type "timestamp". All fields are combined with logical 'AND'. */ export type Timestamp_Comparison_Exp = { _eq?: InputMaybe; @@ -971,6 +1015,97 @@ export type Timestamp_Comparison_Exp = { _nin?: InputMaybe>; }; +/** columns and relationships of "user_block" */ +export type User_Block = { + __typename?: 'user_block'; + /** An object relationship */ + blocked?: Maybe; + blocked_address?: Maybe; + /** An object relationship */ + blocker?: Maybe; + blocker_address?: Maybe; + reason?: Maybe; + subspace_id: Scalars['bigint']; +}; + +/** Boolean expression to filter rows from the table "user_block". All fields are combined with a logical 'AND'. */ +export type User_Block_Bool_Exp = { + _and?: InputMaybe>; + _not?: InputMaybe; + _or?: InputMaybe>; + blocked?: InputMaybe; + blocked_address?: InputMaybe; + blocker?: InputMaybe; + blocker_address?: InputMaybe; + reason?: InputMaybe; + subspace_id?: InputMaybe; +}; + +/** Ordering options when selecting data from "user_block". */ +export type User_Block_Order_By = { + blocked?: InputMaybe; + blocked_address?: InputMaybe; + blocker?: InputMaybe; + blocker_address?: InputMaybe; + reason?: InputMaybe; + subspace_id?: InputMaybe; +}; + +/** select columns of table "user_block" */ +export enum User_Block_Select_Column { + /** column name */ + BlockedAddress = 'blocked_address', + /** column name */ + BlockerAddress = 'blocker_address', + /** column name */ + Reason = 'reason', + /** column name */ + SubspaceId = 'subspace_id' +} + +/** columns and relationships of "user_relationship" */ +export type User_Relationship = { + __typename?: 'user_relationship'; + /** An object relationship */ + counterparty?: Maybe; + counterparty_address: Scalars['String']; + /** An object relationship */ + creator?: Maybe; + creator_address: Scalars['String']; + subspace_id: Scalars['bigint']; +}; + +/** Boolean expression to filter rows from the table "user_relationship". All fields are combined with a logical 'AND'. */ +export type User_Relationship_Bool_Exp = { + _and?: InputMaybe>; + _not?: InputMaybe; + _or?: InputMaybe>; + counterparty?: InputMaybe; + counterparty_address?: InputMaybe; + creator?: InputMaybe; + creator_address?: InputMaybe; + subspace_id?: InputMaybe; +}; + +/** Ordering options when selecting data from "user_relationship". */ +export type User_Relationship_Order_By = { + counterparty?: InputMaybe; + counterparty_address?: InputMaybe; + creator?: InputMaybe; + creator_address?: InputMaybe; + subspace_id?: InputMaybe; +}; + +/** select columns of table "user_relationship" */ +export enum User_Relationship_Select_Column { + /** column name */ + CounterpartyAddress = 'counterparty_address', + /** column name */ + CreatorAddress = 'creator_address', + /** column name */ + SubspaceId = 'subspace_id' +} + export type DesmosProfileQueryVariables = Exact<{ addresses?: InputMaybe | Scalars['String']>; }>;