From ff644fbbf4b7317ef748b2ed5c2a3c7af10855a2 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Tue, 28 Feb 2023 01:34:48 +0700 Subject: [PATCH 1/9] refactor: structure and components --- CHANGELOG.md | 1 + src/lib/app-fns/tx/resend.tsx | 4 +- src/lib/app-provider/tx/clearAdmin.ts | 2 +- src/lib/app-provider/tx/resend.ts | 9 +- src/lib/components/Chakra.tsx | 6 +- src/lib/components/ContractCmdButton.tsx | 28 +- src/lib/components/ErrorMessageRender.tsx | 18 +- src/lib/components/InputWithIcon.tsx | 28 +- src/lib/components/LabelText.tsx | 44 +- src/lib/components/Loading.tsx | 30 +- src/lib/components/LoadingOverlay.tsx | 38 +- src/lib/components/OffChainForm.tsx | 94 +-- src/lib/components/PageContainer.tsx | 12 +- .../TxFilterSelection.tsx} | 8 +- src/lib/components/WasmPageContainer.tsx | 26 +- .../components/action-msg/ActionMessages.tsx | 4 +- src/lib/components/button/ResendButton.tsx | 76 +- src/lib/components/button/index.ts | 3 + .../modal/code/CodeDetailsTemplate.tsx | 2 +- src/lib/components/modal/code/SaveNewCode.tsx | 2 +- src/lib/components/modal/code/index.ts | 4 + src/lib/components/modal/contract/index.ts | 1 + src/lib/components/modal/index.ts | 1 + .../modal/select-code}/CodeSelect.tsx | 0 .../select-code}/CodeSelectModalButton.tsx | 0 .../select-code}/CodeSelectSection.tsx | 6 +- .../modal/select-code/CodesTableReadOnly.tsx | 70 ++ .../modal/select-code/MySavedCodeContent.tsx | 22 + .../select-code}/MyStoredCodeContent.tsx | 17 +- src/lib/components/modal/select-code/index.ts | 1 + .../select-contract/AllContractLists.tsx | 2 +- .../select-contract/ContractListDetail.tsx | 9 +- .../ContractListReadOnlyTable.tsx | 75 ++ .../select-contract}/ContractListTable.tsx | 9 +- src/lib/components/pagination/index.tsx | 2 +- .../components/state/DisconnectedState.tsx | 46 +- src/lib/components/state/EmptyState.tsx | 19 +- src/lib/components/state/index.ts | 4 + src/lib/components/stepper/StepperItem.tsx | 34 +- src/lib/components/stepper/index.tsx | 14 +- src/lib/components/table/AccordionTx.tsx | 7 +- src/lib/components/table/EditableCell.tsx | 2 +- src/lib/components/table/TableTitle.tsx | 6 +- src/lib/components/table/ViewMore.tsx | 2 +- .../{ => table/codes}/CodeNameCell.tsx | 2 +- src/lib/components/table/codes/CodesTable.tsx | 38 + .../table/codes/CodesTableHeader.tsx | 2 +- .../components/table/codes/CodesTableRow.tsx | 7 +- src/lib/components/table/codes/index.ts | 2 + src/lib/components/table/codes/index.tsx | 2 - .../table/contracts}/ContractNameCell.tsx | 2 +- .../table/contracts/ContractsTable.tsx | 44 + .../table/contracts/ContractsTableHeader.tsx | 2 +- .../table/contracts/ContractsTableRow.tsx | 7 +- .../table/contracts}/TagsCell.tsx | 0 src/lib/components/table/contracts/index.ts | 3 + src/lib/components/table/contracts/index.tsx | 2 - src/lib/components/table/index.ts | 7 + .../table/proposals/ProposalsTable.tsx | 38 + .../table/proposals/ProposalsTableHeader.tsx | 26 +- .../table/proposals/ProposalsTableRow.tsx | 2 +- .../table/proposals/index.ts} | 0 src/lib/components/table/proposals/index.tsx | 2 - src/lib/components/table/tableComponents.ts | 2 + .../TransactionsNoSenderTable.tsx | 41 + .../table/transactions/TransactionsTable.tsx | 39 + .../transactions/TransactionsTableHeader.tsx | 21 + .../transactions/TransactionsTableRow.tsx} | 58 +- .../components/table/transactions/index.ts | 2 + src/lib/components/wallet/WalletConnect.tsx | 26 +- src/lib/gql/gql.ts | 20 +- src/lib/gql/graphql.ts | 784 +++++++++--------- src/lib/model/account.ts | 2 +- .../components/asset/index.tsx | 2 +- .../components/tables/AdminContractsTable.tsx | 93 +++ .../tables/InstantiatedContractsTable.tsx | 93 +++ .../tables/OpenedProposalsTable.tsx | 88 ++ .../components/tables/StoredCodesTable.tsx | 93 +++ .../{transactions/index.tsx => TxsTable.tsx} | 108 +-- .../components/tables/codes/CodesTable.tsx | 124 --- .../components/tables/codes/index.tsx | 1 - .../tables/contracts/AdminContractsTable.tsx | 133 --- .../contracts/InstantiatedContractsTable.tsx | 133 --- .../components/tables/contracts/index.tsx | 2 - .../components/tables/index.ts | 5 + .../components/tables/index.tsx | 3 - .../tables/proposals/ProposalsTable.tsx | 124 --- src/lib/pages/account-details/index.tsx | 40 +- .../code-details/components/CTASection.tsx | 3 +- .../components/table/CodeContractsTable.tsx | 91 ++ .../components/table/NoContracts.tsx | 2 +- .../table/contracts/ContractTable.tsx | 126 --- src/lib/pages/code-details/index.tsx | 8 +- src/lib/pages/codes/components/CodesTable.tsx | 99 +-- .../pages/codes/components/SaveCodeButton.tsx | 22 +- .../components/contract-description/index.tsx | 18 +- .../index.tsx => ExecuteTxsTable.tsx} | 61 +- .../components/tables/NoTransactions.tsx | 18 - .../index.tsx => RelatedProposalsTable.tsx} | 38 +- .../{transactions/index.tsx => TxsTable.tsx} | 54 +- .../tables/execute/ExecuteTableRow.tsx | 77 -- .../tables/migration/MigrationHeader.tsx | 22 +- .../tables/migration/MigrationRow.tsx | 3 +- .../components/tables/migration/index.tsx | 9 +- .../tables/transactions/TxsTableRow.tsx | 127 --- src/lib/pages/contract-details/index.tsx | 12 +- .../components/ContractListReadOnlyTable.tsx | 74 -- .../home/components/RecentlyViewContracts.tsx | 2 +- .../instantiate/component/FailedModal.tsx | 58 +- .../code-select/CodeTableReadOnly.tsx | 83 -- .../code-select/MySavedCodeContent.tsx | 30 - src/lib/pages/instantiate/component/index.ts | 1 - src/lib/pages/instantiate/instantiate.tsx | 2 +- .../migrate/components/MigrateContract.tsx | 2 +- .../components/FurtherActionButton.tsx | 7 +- .../pages/past-txs/components/MultipleMsg.tsx | 30 - .../pages/past-txs/components/PastTxRow.tsx | 7 +- .../past-txs/components/PastTxsContent.tsx | 7 +- .../components/PastTxsTableHeader.tsx | 22 +- src/lib/pages/past-txs/hooks/useResend.ts | 73 -- src/lib/pages/past-txs/index.tsx | 10 +- .../public-project/components/AllProject.tsx | 2 +- .../public-project/components/SocialMedia.tsx | 2 +- .../table/code/PublicProjectCodeRow.tsx | 2 +- .../table/code/PublicProjectCodeTable.tsx | 34 +- .../contract/PublicProjectContractTable.tsx | 34 +- src/lib/providers/tx-broadcast.tsx | 6 +- src/lib/query/contract.ts | 40 - src/lib/query/tx.ts | 48 ++ src/lib/services/contractService.ts | 90 +- .../txQuery}/generateWhere.ts | 14 +- .../txQuery}/graphqlQuery.ts | 4 + .../query => services/txQuery}/useTxQuery.ts | 25 +- src/lib/services/txService.ts | 102 ++- src/lib/types/tx/msg.ts | 11 - src/lib/types/tx/transaction.ts | 20 +- src/lib/utils/msgFurtherAction.ts | 4 +- 137 files changed, 2162 insertions(+), 2487 deletions(-) rename src/lib/{pages/past-txs/components/FilterSelection.tsx => components/TxFilterSelection.tsx} (97%) create mode 100644 src/lib/components/modal/code/index.ts rename src/lib/{pages/instantiate/component/code-select => components/modal/select-code}/CodeSelect.tsx (100%) rename src/lib/{pages/instantiate/component/code-select => components/modal/select-code}/CodeSelectModalButton.tsx (100%) rename src/lib/components/{ => modal/select-code}/CodeSelectSection.tsx (92%) create mode 100644 src/lib/components/modal/select-code/CodesTableReadOnly.tsx create mode 100644 src/lib/components/modal/select-code/MySavedCodeContent.tsx rename src/lib/{pages/instantiate/component/code-select => components/modal/select-code}/MyStoredCodeContent.tsx (66%) create mode 100644 src/lib/components/modal/select-code/index.ts create mode 100644 src/lib/components/modal/select-contract/ContractListReadOnlyTable.tsx rename src/lib/{pages/contract-list/components => components/modal/select-contract}/ContractListTable.tsx (97%) create mode 100644 src/lib/components/state/index.ts rename src/lib/components/{ => table/codes}/CodeNameCell.tsx (95%) create mode 100644 src/lib/components/table/codes/CodesTable.tsx create mode 100644 src/lib/components/table/codes/index.ts delete mode 100644 src/lib/components/table/codes/index.tsx rename src/lib/{pages/contract-list/components/table => components/table/contracts}/ContractNameCell.tsx (95%) create mode 100644 src/lib/components/table/contracts/ContractsTable.tsx rename src/lib/{pages/contract-list/components/table => components/table/contracts}/TagsCell.tsx (100%) create mode 100644 src/lib/components/table/contracts/index.ts delete mode 100644 src/lib/components/table/contracts/index.tsx create mode 100644 src/lib/components/table/proposals/ProposalsTable.tsx rename src/lib/{pages/account-details/components/tables/proposals/index.tsx => components/table/proposals/index.ts} (100%) delete mode 100644 src/lib/components/table/proposals/index.tsx create mode 100644 src/lib/components/table/transactions/TransactionsNoSenderTable.tsx create mode 100644 src/lib/components/table/transactions/TransactionsTable.tsx create mode 100644 src/lib/components/table/transactions/TransactionsTableHeader.tsx rename src/lib/{pages/account-details/components/tables/transactions/TxsTableRow.tsx => components/table/transactions/TransactionsTableRow.tsx} (74%) create mode 100644 src/lib/components/table/transactions/index.ts create mode 100644 src/lib/pages/account-details/components/tables/AdminContractsTable.tsx create mode 100644 src/lib/pages/account-details/components/tables/InstantiatedContractsTable.tsx create mode 100644 src/lib/pages/account-details/components/tables/OpenedProposalsTable.tsx create mode 100644 src/lib/pages/account-details/components/tables/StoredCodesTable.tsx rename src/lib/pages/account-details/components/tables/{transactions/index.tsx => TxsTable.tsx} (53%) delete mode 100644 src/lib/pages/account-details/components/tables/codes/CodesTable.tsx delete mode 100644 src/lib/pages/account-details/components/tables/codes/index.tsx delete mode 100644 src/lib/pages/account-details/components/tables/contracts/AdminContractsTable.tsx delete mode 100644 src/lib/pages/account-details/components/tables/contracts/InstantiatedContractsTable.tsx delete mode 100644 src/lib/pages/account-details/components/tables/contracts/index.tsx create mode 100644 src/lib/pages/account-details/components/tables/index.ts delete mode 100644 src/lib/pages/account-details/components/tables/index.tsx delete mode 100644 src/lib/pages/account-details/components/tables/proposals/ProposalsTable.tsx create mode 100644 src/lib/pages/code-details/components/table/CodeContractsTable.tsx delete mode 100644 src/lib/pages/code-details/components/table/contracts/ContractTable.tsx rename src/lib/pages/contract-details/components/tables/{execute/index.tsx => ExecuteTxsTable.tsx} (50%) delete mode 100644 src/lib/pages/contract-details/components/tables/NoTransactions.tsx rename src/lib/pages/contract-details/components/tables/{related-proposals/index.tsx => RelatedProposalsTable.tsx} (66%) rename src/lib/pages/contract-details/components/tables/{transactions/index.tsx => TxsTable.tsx} (53%) delete mode 100644 src/lib/pages/contract-details/components/tables/execute/ExecuteTableRow.tsx delete mode 100644 src/lib/pages/contract-details/components/tables/transactions/TxsTableRow.tsx delete mode 100644 src/lib/pages/contract-list/components/ContractListReadOnlyTable.tsx delete mode 100644 src/lib/pages/instantiate/component/code-select/CodeTableReadOnly.tsx delete mode 100644 src/lib/pages/instantiate/component/code-select/MySavedCodeContent.tsx delete mode 100644 src/lib/pages/past-txs/components/MultipleMsg.tsx delete mode 100644 src/lib/pages/past-txs/hooks/useResend.ts rename src/lib/{pages/past-txs/query => services/txQuery}/generateWhere.ts (86%) rename src/lib/{pages/past-txs/query => services/txQuery}/graphqlQuery.ts (96%) rename src/lib/{pages/past-txs/query => services/txQuery}/useTxQuery.ts (93%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 400e07526..5a48b2df9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Improvements +- [#227](https://github.com/alleslabs/celatone-frontend/pull/227) Refactor directory structure and components e.g. various tables - [#207](https://github.com/alleslabs/celatone-frontend/pull/207) Add cta to submit public project in list page - [#206](https://github.com/alleslabs/celatone-frontend/pull/206) Refactor copy functionality into one component diff --git a/src/lib/app-fns/tx/resend.tsx b/src/lib/app-fns/tx/resend.tsx index 07389acae..05215f017 100644 --- a/src/lib/app-fns/tx/resend.tsx +++ b/src/lib/app-fns/tx/resend.tsx @@ -18,6 +18,7 @@ interface ResendTxParams { address: HumanAddr; client: SigningCosmWasmClient; onTxSucceed?: (txHash: string) => void; + onTxFailed?: () => void; fee: StdFee; messages: EncodeObject[]; } @@ -26,6 +27,7 @@ export const resendTx = ({ address, client, onTxSucceed, + onTxFailed, fee, messages, }: ResendTxParams): Observable => { @@ -69,5 +71,5 @@ export const resendTx = ({ actionVariant: "resend", } as TxResultRendering; } - )().pipe(catchTxError()); + )().pipe(catchTxError(onTxFailed)); }; diff --git a/src/lib/app-provider/tx/clearAdmin.ts b/src/lib/app-provider/tx/clearAdmin.ts index 22972e9f1..24314fd9b 100644 --- a/src/lib/app-provider/tx/clearAdmin.ts +++ b/src/lib/app-provider/tx/clearAdmin.ts @@ -2,7 +2,7 @@ import { useWallet } from "@cosmos-kit/react"; import { useQueryClient } from "@tanstack/react-query"; import { useCallback } from "react"; -import { useFabricateFee } from "../hooks"; +import { useFabricateFee } from "../hooks/useFabricateFee"; import { clearAdminTx } from "lib/app-fns/tx/clearAdmin"; import { CLEAR_ADMIN_GAS } from "lib/data"; import type { ContractAddr, HumanAddr } from "lib/types"; diff --git a/src/lib/app-provider/tx/resend.ts b/src/lib/app-provider/tx/resend.ts index f1b0a04b7..87854ed36 100644 --- a/src/lib/app-provider/tx/resend.ts +++ b/src/lib/app-provider/tx/resend.ts @@ -8,6 +8,7 @@ import type { HumanAddr } from "lib/types"; export interface ResendStreamParams { onTxSucceed?: (txHash: string) => void; + onTxFailed?: () => void; estimatedFee?: StdFee; messages: EncodeObject[]; } @@ -16,7 +17,12 @@ export const useResendTx = () => { const { address, getCosmWasmClient } = useWallet(); return useCallback( - async ({ onTxSucceed, estimatedFee, messages }: ResendStreamParams) => { + async ({ + onTxSucceed, + onTxFailed, + estimatedFee, + messages, + }: ResendStreamParams) => { const client = await getCosmWasmClient(); if (!address || !client) throw new Error("Please check your wallet connection."); @@ -25,6 +31,7 @@ export const useResendTx = () => { address: address as HumanAddr, client, onTxSucceed, + onTxFailed, fee: estimatedFee, messages, }); diff --git a/src/lib/components/Chakra.tsx b/src/lib/components/Chakra.tsx index 787b84dea..59515b05d 100644 --- a/src/lib/components/Chakra.tsx +++ b/src/lib/components/Chakra.tsx @@ -7,6 +7,6 @@ interface ChakraProps { children: ReactNode; } -export const Chakra = ({ children }: ChakraProps) => { - return {children}; -}; +export const Chakra = ({ children }: ChakraProps) => ( + {children} +); diff --git a/src/lib/components/ContractCmdButton.tsx b/src/lib/components/ContractCmdButton.tsx index fd6c91500..5d741f151 100644 --- a/src/lib/components/ContractCmdButton.tsx +++ b/src/lib/components/ContractCmdButton.tsx @@ -7,18 +7,16 @@ interface ContractCmdButtonProps { export const ContractCmdButton = ({ cmd, onClickCmd, -}: ContractCmdButtonProps) => { - return ( - - ); -}; +}: ContractCmdButtonProps) => ( + +); diff --git a/src/lib/components/ErrorMessageRender.tsx b/src/lib/components/ErrorMessageRender.tsx index 595a28f22..2e860832c 100644 --- a/src/lib/components/ErrorMessageRender.tsx +++ b/src/lib/components/ErrorMessageRender.tsx @@ -9,13 +9,11 @@ interface ErrorMessageRenderProps extends FlexProps { export const ErrorMessageRender = ({ error, ...restProps -}: ErrorMessageRenderProps) => { - return ( - - - - {error} - - - ); -}; +}: ErrorMessageRenderProps) => ( + + + + {error} + + +); diff --git a/src/lib/components/InputWithIcon.tsx b/src/lib/components/InputWithIcon.tsx index 5fce94bb9..940598a20 100644 --- a/src/lib/components/InputWithIcon.tsx +++ b/src/lib/components/InputWithIcon.tsx @@ -15,20 +15,18 @@ const InputWithIcon = ({ value, size, onChange, -}: InputWithIconProps) => { - return ( - - - - - - - ); -}; +}: InputWithIconProps) => ( + + + + + + +); export default InputWithIcon; diff --git a/src/lib/components/LabelText.tsx b/src/lib/components/LabelText.tsx index 406744921..69769e23c 100644 --- a/src/lib/components/LabelText.tsx +++ b/src/lib/components/LabelText.tsx @@ -12,27 +12,25 @@ export const LabelText = ({ children, helperText1, helperText2, -}: LabelTextProps) => { - return ( - - - {label} +}: LabelTextProps) => ( + + + {label} + + {typeof children === "string" ? ( + {children} + ) : ( + children + )} + {helperText1 && ( + + {helperText1} - {typeof children === "string" ? ( - {children} - ) : ( - children - )} - {helperText1 && ( - - {helperText1} - - )} - {helperText2 && ( - - {helperText2} - - )} - - ); -}; + )} + {helperText2 && ( + + {helperText2} + + )} + +); diff --git a/src/lib/components/Loading.tsx b/src/lib/components/Loading.tsx index 9c72308d8..361bb9aec 100644 --- a/src/lib/components/Loading.tsx +++ b/src/lib/components/Loading.tsx @@ -1,18 +1,16 @@ import { Flex, Spinner, Text } from "@chakra-ui/react"; -export const Loading = () => { - return ( - - - Loading ... - - ); -}; +export const Loading = () => ( + + + Loading ... + +); diff --git a/src/lib/components/LoadingOverlay.tsx b/src/lib/components/LoadingOverlay.tsx index 2ccaffc8a..4e9c27bcd 100644 --- a/src/lib/components/LoadingOverlay.tsx +++ b/src/lib/components/LoadingOverlay.tsx @@ -1,22 +1,20 @@ import { Flex, Spinner, Text } from "@chakra-ui/react"; -export const LoadingOverlay = () => { - return ( - - - Loading ... - - ); -}; +export const LoadingOverlay = () => ( + + + Loading ... + +); diff --git a/src/lib/components/OffChainForm.tsx b/src/lib/components/OffChainForm.tsx index 77d0f86e9..7a58a69d4 100644 --- a/src/lib/components/OffChainForm.tsx +++ b/src/lib/components/OffChainForm.tsx @@ -40,52 +40,50 @@ export const OffChainForm = ({ setContractListsValue, errors, labelBgColor = "background.main", -}: OffChainFormProps) => { - return ( - - } - control={control} - label="Name" - placeholder={contractLabel} - helperText="Set name for your contract" - variant="floating" - rules={{ - maxLength: MAX_CONTRACT_NAME_LENGTH, - }} - error={errors.name && getMaxContractNameLengthError(state.name.length)} - labelBgColor={labelBgColor} - /> - } - control={control} - label="Description" - placeholder="Help understanding what this contract do and how it works ..." - variant="floating" - rules={{ - maxLength: MAX_CONTRACT_DESCRIPTION_LENGTH, - }} - error={ - errors.description && - getMaxContractDescriptionLengthError(state.description.length) - } - labelBgColor={labelBgColor} - /> - - + } + control={control} + label="Name" + placeholder={contractLabel} + helperText="Set name for your contract" + variant="floating" + rules={{ + maxLength: MAX_CONTRACT_NAME_LENGTH, + }} + error={errors.name && getMaxContractNameLengthError(state.name.length)} + labelBgColor={labelBgColor} + /> + } + control={control} + label="Description" + placeholder="Help understanding what this contract do and how it works ..." + variant="floating" + rules={{ + maxLength: MAX_CONTRACT_DESCRIPTION_LENGTH, + }} + error={ + errors.description && + getMaxContractDescriptionLengthError(state.description.length) + } + labelBgColor={labelBgColor} + /> + + - - ); -}; + setResult={setContractListsValue} + labelBgColor={labelBgColor} + /> + +); diff --git a/src/lib/components/PageContainer.tsx b/src/lib/components/PageContainer.tsx index d8c69b3af..106aca933 100644 --- a/src/lib/components/PageContainer.tsx +++ b/src/lib/components/PageContainer.tsx @@ -5,12 +5,10 @@ type PageContainerProps = { children: ReactNode; }; -const PageContainer = ({ children }: PageContainerProps) => { - return ( - - {children} - - ); -}; +const PageContainer = ({ children }: PageContainerProps) => ( + + {children} + +); export default PageContainer; diff --git a/src/lib/pages/past-txs/components/FilterSelection.tsx b/src/lib/components/TxFilterSelection.tsx similarity index 97% rename from src/lib/pages/past-txs/components/FilterSelection.tsx rename to src/lib/components/TxFilterSelection.tsx index a10c72a25..f709589dc 100644 --- a/src/lib/pages/past-txs/components/FilterSelection.tsx +++ b/src/lib/components/TxFilterSelection.tsx @@ -21,7 +21,7 @@ import { MdCheck, MdClose } from "react-icons/md"; import { displayActionValue, mergeRefs } from "lib/utils"; -export interface FilterSelectionProps extends InputProps { +export interface TxFilterSelectionProps extends InputProps { placeholder?: string; result: string[]; setResult: (option: string, bool: boolean) => void; @@ -51,8 +51,8 @@ const tagItemProps: CSSProperties = { }; // TODO - Refactor this along with TagSelection -export const FilterSelection = observer( - forwardRef( +export const TxFilterSelection = observer( + forwardRef( ( { result, @@ -64,7 +64,7 @@ export const FilterSelection = observer( boxWidth = "full", boxHeight = "56px", ...rest - }: FilterSelectionProps, + }: TxFilterSelectionProps, ref ) => { const options = [ diff --git a/src/lib/components/WasmPageContainer.tsx b/src/lib/components/WasmPageContainer.tsx index 32da1f2df..0ccdf949f 100644 --- a/src/lib/components/WasmPageContainer.tsx +++ b/src/lib/components/WasmPageContainer.tsx @@ -5,19 +5,17 @@ type WasmPageContainerProps = { children: ReactNode; }; -const WasmPageContainer = ({ children }: WasmPageContainerProps) => { - return ( - - {children} - - ); -}; +const WasmPageContainer = ({ children }: WasmPageContainerProps) => ( + + {children} + +); export default WasmPageContainer; diff --git a/src/lib/components/action-msg/ActionMessages.tsx b/src/lib/components/action-msg/ActionMessages.tsx index aa62cca09..72e5060e1 100644 --- a/src/lib/components/action-msg/ActionMessages.tsx +++ b/src/lib/components/action-msg/ActionMessages.tsx @@ -1,4 +1,4 @@ -import type { AllTransaction, PastTransaction } from "lib/types"; +import type { Transaction } from "lib/types"; import { ActionMsgType } from "lib/types"; import { extractMsgType } from "lib/utils"; @@ -7,7 +7,7 @@ import { SingleActionMsg } from "./SingleActionMsg"; import { SingleMsg } from "./SingleMsg"; interface RenderActionMessagesProps { - transaction: AllTransaction | PastTransaction; + transaction: Transaction; showCopyButton: boolean; } diff --git a/src/lib/components/button/ResendButton.tsx b/src/lib/components/button/ResendButton.tsx index 749c10252..8bab495c3 100644 --- a/src/lib/components/button/ResendButton.tsx +++ b/src/lib/components/button/ResendButton.tsx @@ -1,32 +1,68 @@ import { Button } from "@chakra-ui/react"; -import { useState } from "react"; +import type { EncodeObject } from "@cosmjs/proto-signing"; +import { useCallback, useState } from "react"; -import { FailedModal } from "lib/pages/instantiate/component"; -import { useResend } from "lib/pages/past-txs/hooks/useResend"; +import { useFabricateFee, useResendTx, useSimulateFee } from "lib/app-provider"; +import { useTxBroadcast } from "lib/providers/tx-broadcast"; +import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import type { Message } from "lib/types"; +import { camelToSnake, encode } from "lib/utils"; interface ResendButtonProps { messages: Message[]; } + +const formatMsgs = (messages: Message[]) => + messages.reduce((acc: EncodeObject[], msg: Message) => { + acc.push({ + typeUrl: msg.type, + value: !msg.msg.msg + ? msg.msg + : { + ...msg.msg, + msg: encode(JSON.stringify(camelToSnake(msg.msg.msg))), + }, + }); + return acc; + }, []); + export const ResendButton = ({ messages }: ResendButtonProps) => { - const onClickResend = useResend(); - const [error, setError] = useState(""); - const [isButtonLoading, setIsButtonLoading] = useState(false); + const fabricateFee = useFabricateFee(); + const { simulate } = useSimulateFee(); + const resendTx = useResendTx(); + const { broadcast } = useTxBroadcast(); + + const [isProcessing, setIsProcessing] = useState(false); + + const proceed = useCallback(async () => { + AmpTrack(AmpEvent.ACTION_RESEND); + const formatedMsgs = formatMsgs(messages); + + const estimatedGasUsed = await simulate(formatedMsgs); + const fee = estimatedGasUsed ? fabricateFee(estimatedGasUsed) : undefined; + + const stream = await resendTx({ + onTxSucceed: () => setIsProcessing(false), + onTxFailed: () => setIsProcessing(false), + estimatedFee: fee, + messages: formatedMsgs, + }); + if (stream) broadcast(stream); + }, [broadcast, fabricateFee, messages, resendTx, simulate]); return ( - <> - - {error && setError("")} />} - + ); }; diff --git a/src/lib/components/button/index.ts b/src/lib/components/button/index.ts index 2833e104d..816dc5140 100644 --- a/src/lib/components/button/index.ts +++ b/src/lib/components/button/index.ts @@ -3,3 +3,6 @@ export * from "./ConnectWallet"; export * from "./InstantiateButton"; export * from "./ShowMoreButton"; export * from "./AdminButton"; +export * from "./RedoButton"; +export * from "./ResendButton"; +export * from "./IconButton"; diff --git a/src/lib/components/modal/code/CodeDetailsTemplate.tsx b/src/lib/components/modal/code/CodeDetailsTemplate.tsx index 66636b458..975b3c64a 100644 --- a/src/lib/components/modal/code/CodeDetailsTemplate.tsx +++ b/src/lib/components/modal/code/CodeDetailsTemplate.tsx @@ -2,7 +2,7 @@ import { Flex, Icon, Text, useToast } from "@chakra-ui/react"; import { useCallback, useEffect, useState } from "react"; import { MdAddCircleOutline, MdCheckCircle } from "react-icons/md"; -import { ActionModal } from ".."; +import { ActionModal } from "../ActionModal"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { TextInput } from "lib/components/forms"; import { PermissionChip } from "lib/components/PermissionChip"; diff --git a/src/lib/components/modal/code/SaveNewCode.tsx b/src/lib/components/modal/code/SaveNewCode.tsx index bb8ba1e2f..9dd979118 100644 --- a/src/lib/components/modal/code/SaveNewCode.tsx +++ b/src/lib/components/modal/code/SaveNewCode.tsx @@ -5,9 +5,9 @@ import { useQuery } from "@tanstack/react-query"; import { useEffect, useMemo, useState } from "react"; import { MdBookmark, MdCheckCircle } from "react-icons/md"; +import { ActionModal } from "../ActionModal"; import type { FormStatus } from "lib/components/forms"; import { TextInput, NumberInput } from "lib/components/forms"; -import { ActionModal } from "lib/components/modal/ActionModal"; import { getMaxCodeNameLengthError, MAX_CODE_NAME_LENGTH } from "lib/data"; import { useCodeStore, useLCDEndpoint } from "lib/hooks"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; diff --git a/src/lib/components/modal/code/index.ts b/src/lib/components/modal/code/index.ts new file mode 100644 index 000000000..ebac140c9 --- /dev/null +++ b/src/lib/components/modal/code/index.ts @@ -0,0 +1,4 @@ +export * from "./RemoveCode"; +export * from "./SaveNewCode"; +export * from "./SaveOrEditCode"; +export * from "./SaveOrRemoveCode"; diff --git a/src/lib/components/modal/contract/index.ts b/src/lib/components/modal/contract/index.ts index 8b89ff325..39e59403d 100644 --- a/src/lib/components/modal/contract/index.ts +++ b/src/lib/components/modal/contract/index.ts @@ -1,4 +1,5 @@ export * from "./AddToOtherList"; +export * from "./ClearAdmin"; export * from "./EditContractDetails"; export * from "./RemoveContract"; export * from "./SaveContractDetails"; diff --git a/src/lib/components/modal/index.ts b/src/lib/components/modal/index.ts index 128914871..ebfc64e39 100644 --- a/src/lib/components/modal/index.ts +++ b/src/lib/components/modal/index.ts @@ -1,3 +1,4 @@ +export * from "./code"; export * from "./contract"; export * from "./list"; export * from "./tx"; diff --git a/src/lib/pages/instantiate/component/code-select/CodeSelect.tsx b/src/lib/components/modal/select-code/CodeSelect.tsx similarity index 100% rename from src/lib/pages/instantiate/component/code-select/CodeSelect.tsx rename to src/lib/components/modal/select-code/CodeSelect.tsx diff --git a/src/lib/pages/instantiate/component/code-select/CodeSelectModalButton.tsx b/src/lib/components/modal/select-code/CodeSelectModalButton.tsx similarity index 100% rename from src/lib/pages/instantiate/component/code-select/CodeSelectModalButton.tsx rename to src/lib/components/modal/select-code/CodeSelectModalButton.tsx diff --git a/src/lib/components/CodeSelectSection.tsx b/src/lib/components/modal/select-code/CodeSelectSection.tsx similarity index 92% rename from src/lib/components/CodeSelectSection.tsx rename to src/lib/components/modal/select-code/CodeSelectSection.tsx index e18d93fc1..52ab383bb 100644 --- a/src/lib/components/CodeSelectSection.tsx +++ b/src/lib/components/modal/select-code/CodeSelectSection.tsx @@ -2,12 +2,12 @@ import { Flex, Radio, RadioGroup } from "@chakra-ui/react"; import { useState } from "react"; import type { Control, FieldPath, FieldValues } from "react-hook-form"; -import { CodeSelect } from "lib/pages/instantiate/component"; +import { ControllerInput } from "lib/components/forms"; +import type { FormStatus } from "lib/components/forms"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import type { Option } from "lib/types"; -import type { FormStatus } from "./forms"; -import { ControllerInput } from "./forms"; +import { CodeSelect } from "./CodeSelect"; interface CodeSelectSectionProps { codeId: string; diff --git a/src/lib/components/modal/select-code/CodesTableReadOnly.tsx b/src/lib/components/modal/select-code/CodesTableReadOnly.tsx new file mode 100644 index 000000000..d1de6b723 --- /dev/null +++ b/src/lib/components/modal/select-code/CodesTableReadOnly.tsx @@ -0,0 +1,70 @@ +import { Grid, Text } from "@chakra-ui/react"; + +import { ExplorerLink } from "lib/components/ExplorerLink"; +import { TableContainer, TableHeader, TableRow } from "lib/components/table"; +import type { CodeInfo } from "lib/types"; + +const TEMPLATE_COLUMNS = "48px 1fr 4fr 1fr 2fr 48px"; + +interface CodesTableRowProps { + codeInfo: CodeInfo; + onCodeSelect: (newVal: string) => void; +} + +const CodesTableRow = ({ codeInfo, onCodeSelect }: CodesTableRowProps) => ( + onCodeSelect(codeInfo.id.toString())} + templateColumns={TEMPLATE_COLUMNS} + > + + {codeInfo.id} + + + {codeInfo.name ?? "Untitled Name"} + + + + + {codeInfo.contractCount ?? "N/A"} + + + + + + + +); + +interface CodesTableReadOnlyProps { + onCodeSelect: (code: string) => void; + codes: CodeInfo[]; +} + +export const CodesTableReadOnly = ({ + onCodeSelect, + codes, +}: CodesTableReadOnlyProps) => ( + + + + Code ID + Code Name + Contracts + Uploader + + + {codes.map((code, index) => ( + + ))} + +); diff --git a/src/lib/components/modal/select-code/MySavedCodeContent.tsx b/src/lib/components/modal/select-code/MySavedCodeContent.tsx new file mode 100644 index 000000000..f91444096 --- /dev/null +++ b/src/lib/components/modal/select-code/MySavedCodeContent.tsx @@ -0,0 +1,22 @@ +import { EmptyState } from "lib/components/state"; +import type { CodeInfo } from "lib/types"; + +import { CodesTableReadOnly } from "./CodesTableReadOnly"; + +interface MySavedCodeContentProps { + handleSelect: (code: string) => void; + savedCodes: CodeInfo[]; +} + +export const MySavedCodeContent = ({ + handleSelect, + savedCodes, +}: MySavedCodeContentProps) => + !savedCodes.length ? ( + + ) : ( + + ); diff --git a/src/lib/pages/instantiate/component/code-select/MyStoredCodeContent.tsx b/src/lib/components/modal/select-code/MyStoredCodeContent.tsx similarity index 66% rename from src/lib/pages/instantiate/component/code-select/MyStoredCodeContent.tsx rename to src/lib/components/modal/select-code/MyStoredCodeContent.tsx index 75352df1f..b433f60ce 100644 --- a/src/lib/pages/instantiate/component/code-select/MyStoredCodeContent.tsx +++ b/src/lib/components/modal/select-code/MyStoredCodeContent.tsx @@ -2,10 +2,10 @@ import { Flex, Text } from "@chakra-ui/react"; import { useWallet } from "@cosmos-kit/react"; import { ConnectWalletBtn } from "lib/components/button"; -import { EmptyState } from "lib/components/state/EmptyState"; +import { EmptyState } from "lib/components/state"; import type { CodeInfo } from "lib/types"; -import { CodeTableReadOnly } from "./CodeTableReadOnly"; +import { CodesTableReadOnly } from "./CodesTableReadOnly"; interface MyStoredCodeContentProps { handleSelect: (code: string) => void; @@ -36,16 +36,7 @@ export const MyStoredCodeContent = ({ } if (!storedCodes.length) { - return ( - - - - ); + return ; } - return ; + return ; }; diff --git a/src/lib/components/modal/select-code/index.ts b/src/lib/components/modal/select-code/index.ts new file mode 100644 index 000000000..96e376d39 --- /dev/null +++ b/src/lib/components/modal/select-code/index.ts @@ -0,0 +1 @@ +export * from "./CodeSelectSection"; diff --git a/src/lib/components/modal/select-contract/AllContractLists.tsx b/src/lib/components/modal/select-contract/AllContractLists.tsx index 85d1ad8ca..b203edc8f 100644 --- a/src/lib/components/modal/select-contract/AllContractLists.tsx +++ b/src/lib/components/modal/select-contract/AllContractLists.tsx @@ -2,7 +2,7 @@ import { Box, SimpleGrid } from "@chakra-ui/react"; import { useMemo, useState } from "react"; import { TextInput } from "lib/components/forms"; -import { EmptyState } from "lib/components/state/EmptyState"; +import { EmptyState } from "lib/components/state"; import type { ContractListInfo } from "lib/stores/contract"; import { ContractListCard } from "./ContractListCard"; diff --git a/src/lib/components/modal/select-contract/ContractListDetail.tsx b/src/lib/components/modal/select-contract/ContractListDetail.tsx index f09d19a4a..d3a197ace 100644 --- a/src/lib/components/modal/select-contract/ContractListDetail.tsx +++ b/src/lib/components/modal/select-contract/ContractListDetail.tsx @@ -5,16 +5,15 @@ import { useMemo, useState } from "react"; import { TagSelection, TextInput } from "lib/components/forms"; import { Loading } from "lib/components/Loading"; -import { DisconnectedState } from "lib/components/state/DisconnectedState"; -import { EmptyState } from "lib/components/state/EmptyState"; -import { ZeroState } from "lib/components/state/ZeroState"; +import { DisconnectedState, EmptyState, ZeroState } from "lib/components/state"; import { INSTANTIATED_LIST_NAME } from "lib/data"; -import { ContractListReadOnlyTable } from "lib/pages/contract-list/components/ContractListReadOnlyTable"; -import { ContractListTable } from "lib/pages/contract-list/components/ContractListTable"; import type { ContractLocalInfo, ContractListInfo } from "lib/stores/contract"; import type { ContractAddr, HumanAddr, LVPair, Option } from "lib/types"; import { formatSlugName } from "lib/utils"; +import { ContractListReadOnlyTable } from "./ContractListReadOnlyTable"; +import { ContractListTable } from "./ContractListTable"; + interface FilteredListDetailProps { contracts: ContractLocalInfo[]; isReadOnly?: boolean; diff --git a/src/lib/components/modal/select-contract/ContractListReadOnlyTable.tsx b/src/lib/components/modal/select-contract/ContractListReadOnlyTable.tsx new file mode 100644 index 000000000..20ca634d7 --- /dev/null +++ b/src/lib/components/modal/select-contract/ContractListReadOnlyTable.tsx @@ -0,0 +1,75 @@ +import { Grid, Text } from "@chakra-ui/react"; + +import { ExplorerLink } from "lib/components/ExplorerLink"; +import { + ContractNameCell, + TableContainer, + TableHeader, + TableRow, + TagsCell, +} from "lib/components/table"; +import type { ContractLocalInfo } from "lib/stores/contract"; +import type { ContractAddr } from "lib/types"; + +interface ContractListReadOnlyTableProps { + contracts: ContractLocalInfo[]; + onContractSelect: (addr: ContractAddr) => void; +} + +const TEMPLATE_COLUMNS = "160px 280px 260px 1fr"; + +export const ContractListReadOnlyTable = ({ + contracts = [], + onContractSelect, +}: ContractListReadOnlyTableProps) => ( + + + Contract Address + Contract Name + Tags + Instantiated by + + {contracts.map((item) => ( + { + onContractSelect(item.contractAddress); + }} + cursor="pointer" + > + + + + + + + + + + + {item.instantiator ? ( + + ) : ( + + N/A + + )} + + + ))} + +); diff --git a/src/lib/pages/contract-list/components/ContractListTable.tsx b/src/lib/components/modal/select-contract/ContractListTable.tsx similarity index 97% rename from src/lib/pages/contract-list/components/ContractListTable.tsx rename to src/lib/components/modal/select-contract/ContractListTable.tsx index d5ff84735..5968c8500 100644 --- a/src/lib/pages/contract-list/components/ContractListTable.tsx +++ b/src/lib/components/modal/select-contract/ContractListTable.tsx @@ -25,24 +25,23 @@ import { useInternalNavigate } from "lib/app-provider"; import { AppLink } from "lib/components/AppLink"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { + ClearAdminModal, AddToOtherListModal, EditContractDetailsModal, RemoveContractModal, -} from "lib/components/modal/contract"; -import { ClearAdminModal } from "lib/components/modal/contract/ClearAdmin"; +} from "lib/components/modal"; import { + ContractNameCell, TableContainer, TableHeaderNoBorder, TableRowNoBorder, + TagsCell, } from "lib/components/table"; import { useGetAddressType } from "lib/hooks"; import { useAdminByContractAddresses } from "lib/services/contractService"; import type { ContractLocalInfo } from "lib/stores/contract"; import type { LVPair } from "lib/types"; -import { ContractNameCell } from "./table/ContractNameCell"; -import { TagsCell } from "./table/TagsCell"; - const StyledMenuItem = chakra(MenuItem, { baseStyle: { fontSize: "14px", diff --git a/src/lib/components/pagination/index.tsx b/src/lib/components/pagination/index.tsx index 54ccc2873..bea25fb64 100644 --- a/src/lib/components/pagination/index.tsx +++ b/src/lib/components/pagination/index.tsx @@ -55,7 +55,7 @@ export const Pagination = ({ pagesQuantity={pagesQuantity} onPageChange={onPageChange} > - + Items per page: diff --git a/src/lib/components/state/DisconnectedState.tsx b/src/lib/components/state/DisconnectedState.tsx index 016e25772..157405abd 100644 --- a/src/lib/components/state/DisconnectedState.tsx +++ b/src/lib/components/state/DisconnectedState.tsx @@ -10,27 +10,25 @@ interface DisconnectedStateProps { export const DisconnectedState = ({ text, helperText, -}: DisconnectedStateProps) => { - return ( - <> - - - - {text} - - - {helperText && ( - - {helperText} - - )} - - ); -}; +}: DisconnectedStateProps) => ( + <> + + + + {text} + + + {helperText && ( + + {helperText} + + )} + +); diff --git a/src/lib/components/state/EmptyState.tsx b/src/lib/components/state/EmptyState.tsx index 4cf59f770..0f2a0e5e8 100644 --- a/src/lib/components/state/EmptyState.tsx +++ b/src/lib/components/state/EmptyState.tsx @@ -5,10 +5,21 @@ interface EmptyStateProps { icon?: IconType; image?: string; message: string; + withBorder?: boolean; } -export const EmptyState = ({ icon, message, image }: EmptyStateProps) => { - return ( +export const EmptyState = ({ + icon, + message, + image, + withBorder = false, +}: EmptyStateProps) => ( + {icon && } {image && ( @@ -22,5 +33,5 @@ export const EmptyState = ({ icon, message, image }: EmptyStateProps) => { {message} - ); -}; + +); diff --git a/src/lib/components/state/index.ts b/src/lib/components/state/index.ts new file mode 100644 index 000000000..9598441e6 --- /dev/null +++ b/src/lib/components/state/index.ts @@ -0,0 +1,4 @@ +export * from "./DisconnectedState"; +export * from "./EmptyState"; +export * from "./InvalidState"; +export * from "./ZeroState"; diff --git a/src/lib/components/stepper/StepperItem.tsx b/src/lib/components/stepper/StepperItem.tsx index 308981ac5..ff4d9d13f 100644 --- a/src/lib/components/stepper/StepperItem.tsx +++ b/src/lib/components/stepper/StepperItem.tsx @@ -16,24 +16,22 @@ const StepLabel = ({ step: Step; disabled?: boolean; currentStep: Step; -}) => { - return ( - - {currentStep > step ? ( - - ) : ( - {step} - )} - - ); -}; +}) => ( + + {currentStep > step ? ( + + ) : ( + {step} + )} + +); export const StepperItem = ({ mode, diff --git a/src/lib/components/stepper/index.tsx b/src/lib/components/stepper/index.tsx index 23940169d..e3b79a4ae 100644 --- a/src/lib/components/stepper/index.tsx +++ b/src/lib/components/stepper/index.tsx @@ -8,11 +8,9 @@ interface StepperProps { currentStep: Step; } -export const Stepper = ({ mode, currentStep }: StepperProps) => { - return ( - - - - - ); -}; +export const Stepper = ({ mode, currentStep }: StepperProps) => ( + + + + +); diff --git a/src/lib/components/table/AccordionTx.tsx b/src/lib/components/table/AccordionTx.tsx index 2cf01ad0a..e01e6d023 100644 --- a/src/lib/components/table/AccordionTx.tsx +++ b/src/lib/components/table/AccordionTx.tsx @@ -1,10 +1,9 @@ import { SlideFade } from "@chakra-ui/react"; import { useState } from "react"; -import { SingleActionMsg } from "../action-msg/SingleActionMsg"; -import { AccordionStepperItem } from "lib/components/AccordionStepperItem"; -import { RedoButton } from "lib/components/button/RedoButton"; -import { ResendButton } from "lib/components/button/ResendButton"; +import { AccordionStepperItem } from "../AccordionStepperItem"; +import { SingleActionMsg } from "lib/components/action-msg/SingleActionMsg"; +import { RedoButton, ResendButton } from "lib/components/button"; import type { Message } from "lib/types"; import { extractMsgType } from "lib/utils"; diff --git a/src/lib/components/table/EditableCell.tsx b/src/lib/components/table/EditableCell.tsx index 5777629fa..163028f2d 100644 --- a/src/lib/components/table/EditableCell.tsx +++ b/src/lib/components/table/EditableCell.tsx @@ -106,7 +106,7 @@ export const EditableCell = ({ e.stopPropagation(); setIsEditCellOpen(false); }} - zIndex={1} + zIndex={10000} /> )} {title} - + {count} diff --git a/src/lib/components/table/ViewMore.tsx b/src/lib/components/table/ViewMore.tsx index 7f4745ff3..bc23382d3 100644 --- a/src/lib/components/table/ViewMore.tsx +++ b/src/lib/components/table/ViewMore.tsx @@ -6,7 +6,7 @@ interface ViewMoreProps { } export const ViewMore = ({ onClick }: ViewMoreProps) => ( - + - ); -}; +}: ConnectWalletType) => ( + +); export const Connected = ({ buttonText, diff --git a/src/lib/gql/gql.ts b/src/lib/gql/gql.ts index c2e743166..215a99f47 100644 --- a/src/lib/gql/gql.ts +++ b/src/lib/gql/gql.ts @@ -25,10 +25,6 @@ const documents = { types.GetInstantiateDetailByContractQueryDocumentDocument, "\n query getAdminByContractAddressesQueryDocument(\n $contractAddresses: [String!]!\n ) {\n contracts(where: { address: { _in: $contractAddresses } }) {\n address\n admin: account {\n address\n }\n }\n }\n": types.GetAdminByContractAddressesQueryDocumentDocument, - "\n query getExecuteTxsByContractAddressPagination(\n $contractAddress: String!\n $offset: Int!\n $pageSize: Int!\n ) {\n contract_transactions_view(\n where: {\n contract_address: { _eq: $contractAddress }\n is_execute: { _eq: true }\n }\n order_by: { timestamp: desc }\n limit: $pageSize\n offset: $offset\n ) {\n hash\n messages\n success\n sender\n height\n timestamp\n }\n }\n": - types.GetExecuteTxsByContractAddressPaginationDocument, - "\n query getExecuteTxsCountByContractAddress($contractAddress: String!) {\n contract_transactions_aggregate(\n where: {\n contract: { address: { _eq: $contractAddress } }\n transaction: { is_execute: { _eq: true } }\n }\n ) {\n aggregate {\n count\n }\n }\n }\n": - types.GetExecuteTxsCountByContractAddressDocument, "\n query getContractListByAdmin($address: String!) {\n contracts(\n where: { account: { address: { _eq: $address } } }\n order_by: { transaction: { block: { timestamp: desc } } }\n ) {\n address\n label\n accountByInitBy {\n address\n }\n }\n }\n": types.GetContractListByAdminDocument, "\n query getContractListByCodeIdPagination(\n $codeId: Int!\n $offset: Int!\n $pageSize: Int!\n ) {\n contracts(\n where: { code_id: { _eq: $codeId } }\n order_by: { transaction: { block: { timestamp: desc } } }\n offset: $offset\n limit: $pageSize\n ) {\n address\n label\n admin: account {\n address\n }\n init_by: contract_histories(\n order_by: { block: { timestamp: asc } }\n limit: 1\n ) {\n account {\n address\n }\n }\n contract_histories(order_by: { block: { timestamp: desc } }, limit: 1) {\n block {\n timestamp\n }\n account {\n address\n }\n remark\n }\n }\n }\n": @@ -53,6 +49,10 @@ const documents = { types.GetProposalsByWalletAddressPaginationDocument, "\n query getProposalsCountByWalletAddress($walletAddress: String!) {\n proposals_aggregate(\n where: { account: { address: { _eq: $walletAddress } } }\n ) {\n aggregate {\n count\n }\n }\n }\n": types.GetProposalsCountByWalletAddressDocument, + "\n query getExecuteTxsByContractAddressPagination(\n $contractAddress: String!\n $offset: Int!\n $pageSize: Int!\n ) {\n contract_transactions_view(\n where: {\n contract_address: { _eq: $contractAddress }\n is_execute: { _eq: true }\n }\n order_by: { timestamp: desc }\n limit: $pageSize\n offset: $offset\n ) {\n hash\n messages\n success\n sender\n height\n timestamp\n is_execute\n is_ibc\n is_instantiate\n is_send\n is_store_code\n is_migrate\n is_update_admin\n is_clear_admin\n }\n }\n": + types.GetExecuteTxsByContractAddressPaginationDocument, + "\n query getExecuteTxsCountByContractAddress($contractAddress: String!) {\n contract_transactions_aggregate(\n where: {\n contract: { address: { _eq: $contractAddress } }\n transaction: { is_execute: { _eq: true } }\n }\n ) {\n aggregate {\n count\n }\n }\n }\n": + types.GetExecuteTxsCountByContractAddressDocument, "\n query getTxsByContractAddress(\n $contractAddress: String!\n $offset: Int!\n $pageSize: Int!\n ) {\n contract_transactions_view(\n where: { contract_address: { _eq: $contractAddress } }\n order_by: { timestamp: desc }\n offset: $offset\n limit: $pageSize\n ) {\n hash\n success\n messages\n sender\n height\n timestamp\n is_execute\n is_ibc\n is_instantiate\n is_send\n is_store_code\n is_migrate\n is_update_admin\n is_clear_admin\n }\n }\n": types.GetTxsByContractAddressDocument, "\n query getTxsCountByContractAddress($contractAddress: String!) {\n contract_transactions_aggregate(\n where: { contract: { address: { _eq: $contractAddress } } }\n ) {\n aggregate {\n count\n }\n }\n }\n": @@ -92,12 +92,6 @@ export function graphql( export function graphql( source: "\n query getAdminByContractAddressesQueryDocument(\n $contractAddresses: [String!]!\n ) {\n contracts(where: { address: { _in: $contractAddresses } }) {\n address\n admin: account {\n address\n }\n }\n }\n" ): typeof documents["\n query getAdminByContractAddressesQueryDocument(\n $contractAddresses: [String!]!\n ) {\n contracts(where: { address: { _in: $contractAddresses } }) {\n address\n admin: account {\n address\n }\n }\n }\n"]; -export function graphql( - source: "\n query getExecuteTxsByContractAddressPagination(\n $contractAddress: String!\n $offset: Int!\n $pageSize: Int!\n ) {\n contract_transactions_view(\n where: {\n contract_address: { _eq: $contractAddress }\n is_execute: { _eq: true }\n }\n order_by: { timestamp: desc }\n limit: $pageSize\n offset: $offset\n ) {\n hash\n messages\n success\n sender\n height\n timestamp\n }\n }\n" -): typeof documents["\n query getExecuteTxsByContractAddressPagination(\n $contractAddress: String!\n $offset: Int!\n $pageSize: Int!\n ) {\n contract_transactions_view(\n where: {\n contract_address: { _eq: $contractAddress }\n is_execute: { _eq: true }\n }\n order_by: { timestamp: desc }\n limit: $pageSize\n offset: $offset\n ) {\n hash\n messages\n success\n sender\n height\n timestamp\n }\n }\n"]; -export function graphql( - source: "\n query getExecuteTxsCountByContractAddress($contractAddress: String!) {\n contract_transactions_aggregate(\n where: {\n contract: { address: { _eq: $contractAddress } }\n transaction: { is_execute: { _eq: true } }\n }\n ) {\n aggregate {\n count\n }\n }\n }\n" -): typeof documents["\n query getExecuteTxsCountByContractAddress($contractAddress: String!) {\n contract_transactions_aggregate(\n where: {\n contract: { address: { _eq: $contractAddress } }\n transaction: { is_execute: { _eq: true } }\n }\n ) {\n aggregate {\n count\n }\n }\n }\n"]; export function graphql( source: "\n query getContractListByAdmin($address: String!) {\n contracts(\n where: { account: { address: { _eq: $address } } }\n order_by: { transaction: { block: { timestamp: desc } } }\n ) {\n address\n label\n accountByInitBy {\n address\n }\n }\n }\n" ): typeof documents["\n query getContractListByAdmin($address: String!) {\n contracts(\n where: { account: { address: { _eq: $address } } }\n order_by: { transaction: { block: { timestamp: desc } } }\n ) {\n address\n label\n accountByInitBy {\n address\n }\n }\n }\n"]; @@ -134,6 +128,12 @@ export function graphql( export function graphql( source: "\n query getProposalsCountByWalletAddress($walletAddress: String!) {\n proposals_aggregate(\n where: { account: { address: { _eq: $walletAddress } } }\n ) {\n aggregate {\n count\n }\n }\n }\n" ): typeof documents["\n query getProposalsCountByWalletAddress($walletAddress: String!) {\n proposals_aggregate(\n where: { account: { address: { _eq: $walletAddress } } }\n ) {\n aggregate {\n count\n }\n }\n }\n"]; +export function graphql( + source: "\n query getExecuteTxsByContractAddressPagination(\n $contractAddress: String!\n $offset: Int!\n $pageSize: Int!\n ) {\n contract_transactions_view(\n where: {\n contract_address: { _eq: $contractAddress }\n is_execute: { _eq: true }\n }\n order_by: { timestamp: desc }\n limit: $pageSize\n offset: $offset\n ) {\n hash\n messages\n success\n sender\n height\n timestamp\n is_execute\n is_ibc\n is_instantiate\n is_send\n is_store_code\n is_migrate\n is_update_admin\n is_clear_admin\n }\n }\n" +): typeof documents["\n query getExecuteTxsByContractAddressPagination(\n $contractAddress: String!\n $offset: Int!\n $pageSize: Int!\n ) {\n contract_transactions_view(\n where: {\n contract_address: { _eq: $contractAddress }\n is_execute: { _eq: true }\n }\n order_by: { timestamp: desc }\n limit: $pageSize\n offset: $offset\n ) {\n hash\n messages\n success\n sender\n height\n timestamp\n is_execute\n is_ibc\n is_instantiate\n is_send\n is_store_code\n is_migrate\n is_update_admin\n is_clear_admin\n }\n }\n"]; +export function graphql( + source: "\n query getExecuteTxsCountByContractAddress($contractAddress: String!) {\n contract_transactions_aggregate(\n where: {\n contract: { address: { _eq: $contractAddress } }\n transaction: { is_execute: { _eq: true } }\n }\n ) {\n aggregate {\n count\n }\n }\n }\n" +): typeof documents["\n query getExecuteTxsCountByContractAddress($contractAddress: String!) {\n contract_transactions_aggregate(\n where: {\n contract: { address: { _eq: $contractAddress } }\n transaction: { is_execute: { _eq: true } }\n }\n ) {\n aggregate {\n count\n }\n }\n }\n"]; export function graphql( source: "\n query getTxsByContractAddress(\n $contractAddress: String!\n $offset: Int!\n $pageSize: Int!\n ) {\n contract_transactions_view(\n where: { contract_address: { _eq: $contractAddress } }\n order_by: { timestamp: desc }\n offset: $offset\n limit: $pageSize\n ) {\n hash\n success\n messages\n sender\n height\n timestamp\n is_execute\n is_ibc\n is_instantiate\n is_send\n is_store_code\n is_migrate\n is_update_admin\n is_clear_admin\n }\n }\n" ): typeof documents["\n query getTxsByContractAddress(\n $contractAddress: String!\n $offset: Int!\n $pageSize: Int!\n ) {\n contract_transactions_view(\n where: { contract_address: { _eq: $contractAddress } }\n order_by: { timestamp: desc }\n offset: $offset\n limit: $pageSize\n ) {\n hash\n success\n messages\n sender\n height\n timestamp\n is_execute\n is_ibc\n is_instantiate\n is_send\n is_store_code\n is_migrate\n is_update_admin\n is_clear_admin\n }\n }\n"]; diff --git a/src/lib/gql/graphql.ts b/src/lib/gql/graphql.ts index 3150f4b48..a464572a9 100644 --- a/src/lib/gql/graphql.ts +++ b/src/lib/gql/graphql.ts @@ -7079,40 +7079,6 @@ export type GetAdminByContractAddressesQueryDocumentQuery = { }>; }; -export type GetExecuteTxsByContractAddressPaginationQueryVariables = Exact<{ - contractAddress: Scalars["String"]; - offset: Scalars["Int"]; - pageSize: Scalars["Int"]; -}>; - -export type GetExecuteTxsByContractAddressPaginationQuery = { - __typename?: "query_root"; - contract_transactions_view: Array<{ - __typename?: "contract_transactions_view"; - hash?: any | null; - messages?: any | null; - success?: boolean | null; - sender?: string | null; - height?: number | null; - timestamp?: any | null; - }>; -}; - -export type GetExecuteTxsCountByContractAddressQueryVariables = Exact<{ - contractAddress: Scalars["String"]; -}>; - -export type GetExecuteTxsCountByContractAddressQuery = { - __typename?: "query_root"; - contract_transactions_aggregate: { - __typename?: "contract_transactions_aggregate"; - aggregate?: { - __typename?: "contract_transactions_aggregate_fields"; - count: number; - } | null; - }; -}; - export type GetContractListByAdminQueryVariables = Exact<{ address: Scalars["String"]; }>; @@ -7353,6 +7319,48 @@ export type GetProposalsCountByWalletAddressQuery = { }; }; +export type GetExecuteTxsByContractAddressPaginationQueryVariables = Exact<{ + contractAddress: Scalars["String"]; + offset: Scalars["Int"]; + pageSize: Scalars["Int"]; +}>; + +export type GetExecuteTxsByContractAddressPaginationQuery = { + __typename?: "query_root"; + contract_transactions_view: Array<{ + __typename?: "contract_transactions_view"; + hash?: any | null; + messages?: any | null; + success?: boolean | null; + sender?: string | null; + height?: number | null; + timestamp?: any | null; + is_execute?: boolean | null; + is_ibc?: boolean | null; + is_instantiate?: boolean | null; + is_send?: boolean | null; + is_store_code?: boolean | null; + is_migrate?: boolean | null; + is_update_admin?: boolean | null; + is_clear_admin?: boolean | null; + }>; +}; + +export type GetExecuteTxsCountByContractAddressQueryVariables = Exact<{ + contractAddress: Scalars["String"]; +}>; + +export type GetExecuteTxsCountByContractAddressQuery = { + __typename?: "query_root"; + contract_transactions_aggregate: { + __typename?: "contract_transactions_aggregate"; + aggregate?: { + __typename?: "contract_transactions_aggregate_fields"; + count: number; + } | null; + }; +}; + export type GetTxsByContractAddressQueryVariables = Exact<{ contractAddress: Scalars["String"]; offset: Scalars["Int"]; @@ -8717,19 +8725,19 @@ export const GetAdminByContractAddressesQueryDocumentDocument = { GetAdminByContractAddressesQueryDocumentQuery, GetAdminByContractAddressesQueryDocumentQueryVariables >; -export const GetExecuteTxsByContractAddressPaginationDocument = { +export const GetContractListByAdminDocument = { kind: "Document", definitions: [ { kind: "OperationDefinition", operation: "query", - name: { kind: "Name", value: "getExecuteTxsByContractAddressPagination" }, + name: { kind: "Name", value: "getContractListByAdmin" }, variableDefinitions: [ { kind: "VariableDefinition", variable: { kind: "Variable", - name: { kind: "Name", value: "contractAddress" }, + name: { kind: "Name", value: "address" }, }, type: { kind: "NonNullType", @@ -8739,35 +8747,13 @@ export const GetExecuteTxsByContractAddressPaginationDocument = { }, }, }, - { - kind: "VariableDefinition", - variable: { - kind: "Variable", - name: { kind: "Name", value: "offset" }, - }, - type: { - kind: "NonNullType", - type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, - }, - }, - { - kind: "VariableDefinition", - variable: { - kind: "Variable", - name: { kind: "Name", value: "pageSize" }, - }, - type: { - kind: "NonNullType", - type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, - }, - }, ], selectionSet: { kind: "SelectionSet", selections: [ { kind: "Field", - name: { kind: "Name", value: "contract_transactions_view" }, + name: { kind: "Name", value: "contracts" }, arguments: [ { kind: "Argument", @@ -8777,35 +8763,30 @@ export const GetExecuteTxsByContractAddressPaginationDocument = { fields: [ { kind: "ObjectField", - name: { kind: "Name", value: "contract_address" }, + name: { kind: "Name", value: "account" }, value: { kind: "ObjectValue", fields: [ { kind: "ObjectField", - name: { kind: "Name", value: "_eq" }, + name: { kind: "Name", value: "address" }, value: { - kind: "Variable", - name: { kind: "Name", value: "contractAddress" }, + kind: "ObjectValue", + fields: [ + { + kind: "ObjectField", + name: { kind: "Name", value: "_eq" }, + value: { + kind: "Variable", + name: { kind: "Name", value: "address" }, + }, + }, + ], }, }, ], }, }, - { - kind: "ObjectField", - name: { kind: "Name", value: "is_execute" }, - value: { - kind: "ObjectValue", - fields: [ - { - kind: "ObjectField", - name: { kind: "Name", value: "_eq" }, - value: { kind: "BooleanValue", value: true }, - }, - ], - }, - }, ], }, }, @@ -8817,38 +8798,49 @@ export const GetExecuteTxsByContractAddressPaginationDocument = { fields: [ { kind: "ObjectField", - name: { kind: "Name", value: "timestamp" }, - value: { kind: "EnumValue", value: "desc" }, + name: { kind: "Name", value: "transaction" }, + value: { + kind: "ObjectValue", + fields: [ + { + kind: "ObjectField", + name: { kind: "Name", value: "block" }, + value: { + kind: "ObjectValue", + fields: [ + { + kind: "ObjectField", + name: { kind: "Name", value: "timestamp" }, + value: { kind: "EnumValue", value: "desc" }, + }, + ], + }, + }, + ], + }, }, ], }, }, - { - kind: "Argument", - name: { kind: "Name", value: "limit" }, - value: { - kind: "Variable", - name: { kind: "Name", value: "pageSize" }, - }, - }, - { - kind: "Argument", - name: { kind: "Name", value: "offset" }, - value: { - kind: "Variable", - name: { kind: "Name", value: "offset" }, - }, - }, ], selectionSet: { kind: "SelectionSet", selections: [ - { kind: "Field", name: { kind: "Name", value: "hash" } }, - { kind: "Field", name: { kind: "Name", value: "messages" } }, - { kind: "Field", name: { kind: "Name", value: "success" } }, - { kind: "Field", name: { kind: "Name", value: "sender" } }, - { kind: "Field", name: { kind: "Name", value: "height" } }, - { kind: "Field", name: { kind: "Name", value: "timestamp" } }, + { kind: "Field", name: { kind: "Name", value: "address" } }, + { kind: "Field", name: { kind: "Name", value: "label" } }, + { + kind: "Field", + name: { kind: "Name", value: "accountByInitBy" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "address" }, + }, + ], + }, + }, ], }, }, @@ -8857,29 +8849,48 @@ export const GetExecuteTxsByContractAddressPaginationDocument = { }, ], } as unknown as DocumentNode< - GetExecuteTxsByContractAddressPaginationQuery, - GetExecuteTxsByContractAddressPaginationQueryVariables + GetContractListByAdminQuery, + GetContractListByAdminQueryVariables >; -export const GetExecuteTxsCountByContractAddressDocument = { +export const GetContractListByCodeIdPaginationDocument = { kind: "Document", definitions: [ { kind: "OperationDefinition", operation: "query", - name: { kind: "Name", value: "getExecuteTxsCountByContractAddress" }, + name: { kind: "Name", value: "getContractListByCodeIdPagination" }, variableDefinitions: [ { kind: "VariableDefinition", variable: { kind: "Variable", - name: { kind: "Name", value: "contractAddress" }, + name: { kind: "Name", value: "codeId" }, }, type: { kind: "NonNullType", - type: { - kind: "NamedType", - name: { kind: "Name", value: "String" }, - }, + type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, + }, + }, + { + kind: "VariableDefinition", + variable: { + kind: "Variable", + name: { kind: "Name", value: "offset" }, + }, + type: { + kind: "NonNullType", + type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, + }, + }, + { + kind: "VariableDefinition", + variable: { + kind: "Variable", + name: { kind: "Name", value: "pageSize" }, + }, + type: { + kind: "NonNullType", + type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, }, }, ], @@ -8888,7 +8899,7 @@ export const GetExecuteTxsCountByContractAddressDocument = { selections: [ { kind: "Field", - name: { kind: "Name", value: "contract_transactions_aggregate" }, + name: { kind: "Name", value: "contracts" }, arguments: [ { kind: "Argument", @@ -8898,278 +8909,16 @@ export const GetExecuteTxsCountByContractAddressDocument = { fields: [ { kind: "ObjectField", - name: { kind: "Name", value: "contract" }, + name: { kind: "Name", value: "code_id" }, value: { kind: "ObjectValue", fields: [ { kind: "ObjectField", - name: { kind: "Name", value: "address" }, + name: { kind: "Name", value: "_eq" }, value: { - kind: "ObjectValue", - fields: [ - { - kind: "ObjectField", - name: { kind: "Name", value: "_eq" }, - value: { - kind: "Variable", - name: { - kind: "Name", - value: "contractAddress", - }, - }, - }, - ], - }, - }, - ], - }, - }, - { - kind: "ObjectField", - name: { kind: "Name", value: "transaction" }, - value: { - kind: "ObjectValue", - fields: [ - { - kind: "ObjectField", - name: { kind: "Name", value: "is_execute" }, - value: { - kind: "ObjectValue", - fields: [ - { - kind: "ObjectField", - name: { kind: "Name", value: "_eq" }, - value: { kind: "BooleanValue", value: true }, - }, - ], - }, - }, - ], - }, - }, - ], - }, - }, - ], - selectionSet: { - kind: "SelectionSet", - selections: [ - { - kind: "Field", - name: { kind: "Name", value: "aggregate" }, - selectionSet: { - kind: "SelectionSet", - selections: [ - { kind: "Field", name: { kind: "Name", value: "count" } }, - ], - }, - }, - ], - }, - }, - ], - }, - }, - ], -} as unknown as DocumentNode< - GetExecuteTxsCountByContractAddressQuery, - GetExecuteTxsCountByContractAddressQueryVariables ->; -export const GetContractListByAdminDocument = { - kind: "Document", - definitions: [ - { - kind: "OperationDefinition", - operation: "query", - name: { kind: "Name", value: "getContractListByAdmin" }, - variableDefinitions: [ - { - kind: "VariableDefinition", - variable: { - kind: "Variable", - name: { kind: "Name", value: "address" }, - }, - type: { - kind: "NonNullType", - type: { - kind: "NamedType", - name: { kind: "Name", value: "String" }, - }, - }, - }, - ], - selectionSet: { - kind: "SelectionSet", - selections: [ - { - kind: "Field", - name: { kind: "Name", value: "contracts" }, - arguments: [ - { - kind: "Argument", - name: { kind: "Name", value: "where" }, - value: { - kind: "ObjectValue", - fields: [ - { - kind: "ObjectField", - name: { kind: "Name", value: "account" }, - value: { - kind: "ObjectValue", - fields: [ - { - kind: "ObjectField", - name: { kind: "Name", value: "address" }, - value: { - kind: "ObjectValue", - fields: [ - { - kind: "ObjectField", - name: { kind: "Name", value: "_eq" }, - value: { - kind: "Variable", - name: { kind: "Name", value: "address" }, - }, - }, - ], - }, - }, - ], - }, - }, - ], - }, - }, - { - kind: "Argument", - name: { kind: "Name", value: "order_by" }, - value: { - kind: "ObjectValue", - fields: [ - { - kind: "ObjectField", - name: { kind: "Name", value: "transaction" }, - value: { - kind: "ObjectValue", - fields: [ - { - kind: "ObjectField", - name: { kind: "Name", value: "block" }, - value: { - kind: "ObjectValue", - fields: [ - { - kind: "ObjectField", - name: { kind: "Name", value: "timestamp" }, - value: { kind: "EnumValue", value: "desc" }, - }, - ], - }, - }, - ], - }, - }, - ], - }, - }, - ], - selectionSet: { - kind: "SelectionSet", - selections: [ - { kind: "Field", name: { kind: "Name", value: "address" } }, - { kind: "Field", name: { kind: "Name", value: "label" } }, - { - kind: "Field", - name: { kind: "Name", value: "accountByInitBy" }, - selectionSet: { - kind: "SelectionSet", - selections: [ - { - kind: "Field", - name: { kind: "Name", value: "address" }, - }, - ], - }, - }, - ], - }, - }, - ], - }, - }, - ], -} as unknown as DocumentNode< - GetContractListByAdminQuery, - GetContractListByAdminQueryVariables ->; -export const GetContractListByCodeIdPaginationDocument = { - kind: "Document", - definitions: [ - { - kind: "OperationDefinition", - operation: "query", - name: { kind: "Name", value: "getContractListByCodeIdPagination" }, - variableDefinitions: [ - { - kind: "VariableDefinition", - variable: { - kind: "Variable", - name: { kind: "Name", value: "codeId" }, - }, - type: { - kind: "NonNullType", - type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, - }, - }, - { - kind: "VariableDefinition", - variable: { - kind: "Variable", - name: { kind: "Name", value: "offset" }, - }, - type: { - kind: "NonNullType", - type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, - }, - }, - { - kind: "VariableDefinition", - variable: { - kind: "Variable", - name: { kind: "Name", value: "pageSize" }, - }, - type: { - kind: "NonNullType", - type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, - }, - }, - ], - selectionSet: { - kind: "SelectionSet", - selections: [ - { - kind: "Field", - name: { kind: "Name", value: "contracts" }, - arguments: [ - { - kind: "Argument", - name: { kind: "Name", value: "where" }, - value: { - kind: "ObjectValue", - fields: [ - { - kind: "ObjectField", - name: { kind: "Name", value: "code_id" }, - value: { - kind: "ObjectValue", - fields: [ - { - kind: "ObjectField", - name: { kind: "Name", value: "_eq" }, - value: { - kind: "Variable", - name: { kind: "Name", value: "codeId" }, + kind: "Variable", + name: { kind: "Name", value: "codeId" }, }, }, ], @@ -10967,6 +10716,285 @@ export const GetProposalsCountByWalletAddressDocument = { GetProposalsCountByWalletAddressQuery, GetProposalsCountByWalletAddressQueryVariables >; +export const GetExecuteTxsByContractAddressPaginationDocument = { + kind: "Document", + definitions: [ + { + kind: "OperationDefinition", + operation: "query", + name: { kind: "Name", value: "getExecuteTxsByContractAddressPagination" }, + variableDefinitions: [ + { + kind: "VariableDefinition", + variable: { + kind: "Variable", + name: { kind: "Name", value: "contractAddress" }, + }, + type: { + kind: "NonNullType", + type: { + kind: "NamedType", + name: { kind: "Name", value: "String" }, + }, + }, + }, + { + kind: "VariableDefinition", + variable: { + kind: "Variable", + name: { kind: "Name", value: "offset" }, + }, + type: { + kind: "NonNullType", + type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, + }, + }, + { + kind: "VariableDefinition", + variable: { + kind: "Variable", + name: { kind: "Name", value: "pageSize" }, + }, + type: { + kind: "NonNullType", + type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, + }, + }, + ], + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "contract_transactions_view" }, + arguments: [ + { + kind: "Argument", + name: { kind: "Name", value: "where" }, + value: { + kind: "ObjectValue", + fields: [ + { + kind: "ObjectField", + name: { kind: "Name", value: "contract_address" }, + value: { + kind: "ObjectValue", + fields: [ + { + kind: "ObjectField", + name: { kind: "Name", value: "_eq" }, + value: { + kind: "Variable", + name: { kind: "Name", value: "contractAddress" }, + }, + }, + ], + }, + }, + { + kind: "ObjectField", + name: { kind: "Name", value: "is_execute" }, + value: { + kind: "ObjectValue", + fields: [ + { + kind: "ObjectField", + name: { kind: "Name", value: "_eq" }, + value: { kind: "BooleanValue", value: true }, + }, + ], + }, + }, + ], + }, + }, + { + kind: "Argument", + name: { kind: "Name", value: "order_by" }, + value: { + kind: "ObjectValue", + fields: [ + { + kind: "ObjectField", + name: { kind: "Name", value: "timestamp" }, + value: { kind: "EnumValue", value: "desc" }, + }, + ], + }, + }, + { + kind: "Argument", + name: { kind: "Name", value: "limit" }, + value: { + kind: "Variable", + name: { kind: "Name", value: "pageSize" }, + }, + }, + { + kind: "Argument", + name: { kind: "Name", value: "offset" }, + value: { + kind: "Variable", + name: { kind: "Name", value: "offset" }, + }, + }, + ], + selectionSet: { + kind: "SelectionSet", + selections: [ + { kind: "Field", name: { kind: "Name", value: "hash" } }, + { kind: "Field", name: { kind: "Name", value: "messages" } }, + { kind: "Field", name: { kind: "Name", value: "success" } }, + { kind: "Field", name: { kind: "Name", value: "sender" } }, + { kind: "Field", name: { kind: "Name", value: "height" } }, + { kind: "Field", name: { kind: "Name", value: "timestamp" } }, + { kind: "Field", name: { kind: "Name", value: "is_execute" } }, + { kind: "Field", name: { kind: "Name", value: "is_ibc" } }, + { + kind: "Field", + name: { kind: "Name", value: "is_instantiate" }, + }, + { kind: "Field", name: { kind: "Name", value: "is_send" } }, + { + kind: "Field", + name: { kind: "Name", value: "is_store_code" }, + }, + { kind: "Field", name: { kind: "Name", value: "is_migrate" } }, + { + kind: "Field", + name: { kind: "Name", value: "is_update_admin" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "is_clear_admin" }, + }, + ], + }, + }, + ], + }, + }, + ], +} as unknown as DocumentNode< + GetExecuteTxsByContractAddressPaginationQuery, + GetExecuteTxsByContractAddressPaginationQueryVariables +>; +export const GetExecuteTxsCountByContractAddressDocument = { + kind: "Document", + definitions: [ + { + kind: "OperationDefinition", + operation: "query", + name: { kind: "Name", value: "getExecuteTxsCountByContractAddress" }, + variableDefinitions: [ + { + kind: "VariableDefinition", + variable: { + kind: "Variable", + name: { kind: "Name", value: "contractAddress" }, + }, + type: { + kind: "NonNullType", + type: { + kind: "NamedType", + name: { kind: "Name", value: "String" }, + }, + }, + }, + ], + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "contract_transactions_aggregate" }, + arguments: [ + { + kind: "Argument", + name: { kind: "Name", value: "where" }, + value: { + kind: "ObjectValue", + fields: [ + { + kind: "ObjectField", + name: { kind: "Name", value: "contract" }, + value: { + kind: "ObjectValue", + fields: [ + { + kind: "ObjectField", + name: { kind: "Name", value: "address" }, + value: { + kind: "ObjectValue", + fields: [ + { + kind: "ObjectField", + name: { kind: "Name", value: "_eq" }, + value: { + kind: "Variable", + name: { + kind: "Name", + value: "contractAddress", + }, + }, + }, + ], + }, + }, + ], + }, + }, + { + kind: "ObjectField", + name: { kind: "Name", value: "transaction" }, + value: { + kind: "ObjectValue", + fields: [ + { + kind: "ObjectField", + name: { kind: "Name", value: "is_execute" }, + value: { + kind: "ObjectValue", + fields: [ + { + kind: "ObjectField", + name: { kind: "Name", value: "_eq" }, + value: { kind: "BooleanValue", value: true }, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, + ], + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "aggregate" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { kind: "Field", name: { kind: "Name", value: "count" } }, + ], + }, + }, + ], + }, + }, + ], + }, + }, + ], +} as unknown as DocumentNode< + GetExecuteTxsCountByContractAddressQuery, + GetExecuteTxsCountByContractAddressQueryVariables +>; export const GetTxsByContractAddressDocument = { kind: "Document", definitions: [ diff --git a/src/lib/model/account.ts b/src/lib/model/account.ts index 96f8719ca..4d71fb166 100644 --- a/src/lib/model/account.ts +++ b/src/lib/model/account.ts @@ -1,13 +1,13 @@ // TODO - Refactor Past txs query import { DEFAULT_TX_FILTERS } from "lib/data"; import { useUserAssetInfos } from "lib/pages/account-details/data"; -import { useTxQueryCount } from "lib/pages/past-txs/query/useTxQuery"; import { useCodeListCountByWalletAddress } from "lib/services/codeService"; import { useContractListCountByAdmin, useInstantiatedCountByUserQuery, } from "lib/services/contractService"; import { useProposalsCountByWalletAddress } from "lib/services/proposalService"; +import { useTxQueryCount } from "lib/services/txQuery/useTxQuery"; import type { HumanAddr } from "lib/types"; /** diff --git a/src/lib/pages/account-details/components/asset/index.tsx b/src/lib/pages/account-details/components/asset/index.tsx index ab0324479..176ea1576 100644 --- a/src/lib/pages/account-details/components/asset/index.tsx +++ b/src/lib/pages/account-details/components/asset/index.tsx @@ -4,7 +4,7 @@ import big from "big.js"; import { Loading } from "lib/components/Loading"; import { UnsupportedTokensModal } from "lib/components/modal/UnsupportedTokensModal"; -import { ViewMore } from "lib/components/table/ViewMore"; +import { ViewMore } from "lib/components/table"; import { TokenCard } from "lib/components/TokenCard"; import { useUserAssetInfos } from "lib/pages/account-details/data"; import type { BalanceWithAssetInfo, HumanAddr, Option, USD } from "lib/types"; diff --git a/src/lib/pages/account-details/components/tables/AdminContractsTable.tsx b/src/lib/pages/account-details/components/tables/AdminContractsTable.tsx new file mode 100644 index 000000000..65e87d7a3 --- /dev/null +++ b/src/lib/pages/account-details/components/tables/AdminContractsTable.tsx @@ -0,0 +1,93 @@ +import { Box } from "@chakra-ui/react"; +import type { ChangeEvent } from "react"; + +import { Pagination } from "lib/components/pagination"; +import { usePaginator } from "lib/components/pagination/usePaginator"; +import { EmptyState } from "lib/components/state"; +import { ContractsTable, TableTitle, ViewMore } from "lib/components/table"; +import { useContractsAdmin } from "lib/pages/account-details/data"; +import type { HumanAddr, Option } from "lib/types"; + +interface AdminContractsTableProps { + walletAddress: HumanAddr; + scrollComponentId: string; + totalData: Option; + refetchCount: () => void; + onViewMore?: () => void; +} + +export const AdminContractsTable = ({ + walletAddress, + scrollComponentId, + totalData, + refetchCount, + onViewMore, +}: AdminContractsTableProps) => { + const { + pagesQuantity, + currentPage, + setCurrentPage, + pageSize, + setPageSize, + offset, + } = usePaginator({ + total: totalData, + initialState: { + pageSize: 10, + currentPage: 1, + isDisabled: false, + }, + }); + const { contracts, isLoading } = useContractsAdmin( + walletAddress, + offset, + onViewMore ? 5 : pageSize + ); + + const onPageChange = (nextPage: number) => { + refetchCount(); + setCurrentPage(nextPage); + }; + + const onPageSizeChange = (e: ChangeEvent) => { + const size = Number(e.target.value); + refetchCount(); + setPageSize(size); + setCurrentPage(1); + }; + + return ( + + + + } + /> + {!!totalData && + (onViewMore + ? totalData > 5 && + : totalData > 10 && ( + + ))} + + ); +}; diff --git a/src/lib/pages/account-details/components/tables/InstantiatedContractsTable.tsx b/src/lib/pages/account-details/components/tables/InstantiatedContractsTable.tsx new file mode 100644 index 000000000..ffcc5421e --- /dev/null +++ b/src/lib/pages/account-details/components/tables/InstantiatedContractsTable.tsx @@ -0,0 +1,93 @@ +import { Box } from "@chakra-ui/react"; +import type { ChangeEvent } from "react"; + +import { Pagination } from "lib/components/pagination"; +import { usePaginator } from "lib/components/pagination/usePaginator"; +import { EmptyState } from "lib/components/state"; +import { ContractsTable, TableTitle, ViewMore } from "lib/components/table"; +import { useContractInstances } from "lib/pages/account-details/data"; +import type { HumanAddr, Option } from "lib/types"; + +interface InstantiatedContractsTableProps { + walletAddress: HumanAddr; + scrollComponentId: string; + totalData: Option; + refetchCount: () => void; + onViewMore?: () => void; +} + +export const InstantiatedContractsTable = ({ + walletAddress, + scrollComponentId, + totalData, + refetchCount, + onViewMore, +}: InstantiatedContractsTableProps) => { + const { + pagesQuantity, + currentPage, + setCurrentPage, + pageSize, + setPageSize, + offset, + } = usePaginator({ + total: totalData, + initialState: { + pageSize: 10, + currentPage: 1, + isDisabled: false, + }, + }); + const { contracts, isLoading } = useContractInstances( + walletAddress, + offset, + onViewMore ? 5 : pageSize + ); + + const onPageChange = (nextPage: number) => { + refetchCount(); + setCurrentPage(nextPage); + }; + + const onPageSizeChange = (e: ChangeEvent) => { + const size = Number(e.target.value); + refetchCount(); + setPageSize(size); + setCurrentPage(1); + }; + + return ( + + + + } + /> + {!!totalData && + (onViewMore + ? totalData > 5 && + : totalData > 10 && ( + + ))} + + ); +}; diff --git a/src/lib/pages/account-details/components/tables/OpenedProposalsTable.tsx b/src/lib/pages/account-details/components/tables/OpenedProposalsTable.tsx new file mode 100644 index 000000000..21a33eee2 --- /dev/null +++ b/src/lib/pages/account-details/components/tables/OpenedProposalsTable.tsx @@ -0,0 +1,88 @@ +import { Box } from "@chakra-ui/react"; +import type { ChangeEvent } from "react"; + +import { Pagination } from "lib/components/pagination"; +import { usePaginator } from "lib/components/pagination/usePaginator"; +import { EmptyState } from "lib/components/state"; +import { ProposalsTable, TableTitle, ViewMore } from "lib/components/table"; +import { useProposalsByWalletAddressPagination } from "lib/services/proposalService"; +import type { HumanAddr, Option } from "lib/types"; + +interface OpenedProposalsTableProps { + walletAddress: HumanAddr; + scrollComponentId: string; + totalData: Option; + refetchCount: () => void; + onViewMore?: () => void; +} + +export const OpenedProposalsTable = ({ + walletAddress, + scrollComponentId, + totalData, + refetchCount, + onViewMore, +}: OpenedProposalsTableProps) => { + const { + pagesQuantity, + currentPage, + setCurrentPage, + pageSize, + setPageSize, + offset, + } = usePaginator({ + total: totalData, + initialState: { + pageSize: 10, + currentPage: 1, + isDisabled: false, + }, + }); + const { data: proposals, isLoading } = useProposalsByWalletAddressPagination( + walletAddress, + offset, + onViewMore ? 5 : pageSize + ); + + const onPageChange = (nextPage: number) => { + refetchCount(); + setCurrentPage(nextPage); + }; + + const onPageSizeChange = (e: ChangeEvent) => { + const size = Number(e.target.value); + refetchCount(); + setPageSize(size); + setCurrentPage(1); + }; + return ( + + + + } + /> + {!!totalData && + (onViewMore + ? totalData > 5 && + : totalData > 10 && ( + + ))} + + ); +}; diff --git a/src/lib/pages/account-details/components/tables/StoredCodesTable.tsx b/src/lib/pages/account-details/components/tables/StoredCodesTable.tsx new file mode 100644 index 000000000..4899a8ace --- /dev/null +++ b/src/lib/pages/account-details/components/tables/StoredCodesTable.tsx @@ -0,0 +1,93 @@ +import { Box } from "@chakra-ui/react"; +import type { ChangeEvent } from "react"; + +import { Pagination } from "lib/components/pagination"; +import { usePaginator } from "lib/components/pagination/usePaginator"; +import { EmptyState } from "lib/components/state"; +import { CodesTable, TableTitle, ViewMore } from "lib/components/table"; +import { useCodeStored } from "lib/pages/account-details/data"; +import type { HumanAddr, Option } from "lib/types"; + +interface StoredCodesTableProps { + walletAddress: HumanAddr; + scrollComponentId: string; + totalData: Option; + refetchCount: () => void; + onViewMore?: () => void; +} + +export const StoredCodesTable = ({ + walletAddress, + scrollComponentId, + totalData, + refetchCount, + onViewMore, +}: StoredCodesTableProps) => { + const { + pagesQuantity, + currentPage, + setCurrentPage, + pageSize, + setPageSize, + offset, + } = usePaginator({ + total: totalData, + initialState: { + pageSize: 10, + currentPage: 1, + isDisabled: false, + }, + }); + const { codes, isLoading } = useCodeStored( + walletAddress, + offset, + onViewMore ? 5 : pageSize + ); + + const onPageChange = (nextPage: number) => { + refetchCount(); + setCurrentPage(nextPage); + }; + + const onPageSizeChange = (e: ChangeEvent) => { + const size = Number(e.target.value); + refetchCount(); + setPageSize(size); + setCurrentPage(1); + }; + + return ( + + + + } + /> + {!!totalData && + (onViewMore + ? totalData > 5 && + : totalData > 10 && ( + + ))} + + ); +}; diff --git a/src/lib/pages/account-details/components/tables/transactions/index.tsx b/src/lib/pages/account-details/components/tables/TxsTable.tsx similarity index 53% rename from src/lib/pages/account-details/components/tables/transactions/index.tsx rename to src/lib/pages/account-details/components/tables/TxsTable.tsx index 856901bb9..da91f3f90 100644 --- a/src/lib/pages/account-details/components/tables/transactions/index.tsx +++ b/src/lib/pages/account-details/components/tables/TxsTable.tsx @@ -1,23 +1,22 @@ // TODO - Refactor: move common component out of pasttx -import { Box, Flex, Grid } from "@chakra-ui/react"; +import { Box, Flex } from "@chakra-ui/react"; import type { ChangeEvent } from "react"; import { useState } from "react"; -import { Loading } from "lib/components/Loading"; import { Pagination } from "lib/components/pagination"; import { usePaginator } from "lib/components/pagination/usePaginator"; -import { EmptyState } from "lib/components/state/EmptyState"; -import { TableContainer, TableHeader } from "lib/components/table"; -import { TableTitle } from "lib/components/table/TableTitle"; -import { ViewMore } from "lib/components/table/ViewMore"; +import { EmptyState } from "lib/components/state"; +import { + TableTitle, + TransactionsNoSenderTable, + ViewMore, +} from "lib/components/table"; +import { TxFilterSelection } from "lib/components/TxFilterSelection"; import { DEFAULT_TX_FILTERS } from "lib/data"; -import { FilterSelection } from "lib/pages/past-txs/components/FilterSelection"; -import { useTxQuery } from "lib/pages/past-txs/query/useTxQuery"; +import { useTxQuery } from "lib/services/txQuery/useTxQuery"; import type { HumanAddr, Option, TxFilters } from "lib/types"; -import { TxsTableRow } from "./TxsTableRow"; - -interface TransactionsTableProps { +interface TxsTableProps { walletAddress: HumanAddr; scrollComponentId: string; totalData: Option; @@ -25,12 +24,12 @@ interface TransactionsTableProps { onViewMore?: () => void; } -interface TransactionsTableBodyProps extends TransactionsTableProps { +interface TxsTableBodyProps extends TxsTableProps { filters: TxFilters; filterSelected: string[]; } -const TransactionsTableBody = ({ +const TxsTableBody = ({ walletAddress, scrollComponentId, totalData, @@ -38,7 +37,7 @@ const TransactionsTableBody = ({ onViewMore, filters, filterSelected, -}: TransactionsTableBodyProps) => { +}: TxsTableBodyProps) => { const { pagesQuantity, currentPage, @@ -75,58 +74,27 @@ const TransactionsTableBody = ({ setCurrentPage(1); }; - const templateColumns = "180px 70px minmax(360px, 1fr) max(250px) max(70px)"; - - if (isLoading) return ; - - if (!transactions?.length && filterSelected.length > 0) - return ( - - - - ); - - if (!transactions?.length) - return ( - - - - ); - return ( <> - - - Transaction Hash - - Messages - Timestamp - - - {transactions.map((transaction) => ( - - ))} - - {totalData && + + ) : ( + + ) + } + /> + {!!totalData && (onViewMore ? totalData > 5 && : totalData > 10 && ( @@ -145,9 +113,7 @@ const TransactionsTableBody = ({ ); }; -export const TransactionsTable = ( - transactionsTableProps: TransactionsTableProps -) => { +export const TxsTable = (txsTableProps: TxsTableProps) => { const [filters, setFilters] = useState(DEFAULT_TX_FILTERS); const handleSetFilters = (filter: string, bool: boolean) => { @@ -158,13 +124,13 @@ export const TransactionsTable = ( (key) => filters[key as keyof typeof filters] ); - const { totalData, onViewMore } = transactionsTableProps; + const { totalData, onViewMore } = txsTableProps; return ( {!onViewMore && ( - )} - diff --git a/src/lib/pages/account-details/components/tables/codes/CodesTable.tsx b/src/lib/pages/account-details/components/tables/codes/CodesTable.tsx deleted file mode 100644 index 327861e89..000000000 --- a/src/lib/pages/account-details/components/tables/codes/CodesTable.tsx +++ /dev/null @@ -1,124 +0,0 @@ -import { Box, Flex } from "@chakra-ui/react"; -import { observer } from "mobx-react-lite"; -import type { ChangeEvent } from "react"; - -import { Loading } from "lib/components/Loading"; -import { Pagination } from "lib/components/pagination"; -import { usePaginator } from "lib/components/pagination/usePaginator"; -import { EmptyState } from "lib/components/state/EmptyState"; -import { TableContainer } from "lib/components/table"; -import { CodesTableHeader, CodesTableRow } from "lib/components/table/codes"; -import { TableTitle } from "lib/components/table/TableTitle"; -import { ViewMore } from "lib/components/table/ViewMore"; -import { useCodeStored } from "lib/pages/account-details/data"; -import type { HumanAddr, Option } from "lib/types"; - -interface CodesTableProps { - walletAddress: HumanAddr; - scrollComponentId: string; - totalData: Option; - refetchCount: () => void; - onViewMore?: () => void; -} - -const CodesTableBody = observer( - ({ - walletAddress, - scrollComponentId, - totalData, - refetchCount, - onViewMore, - }: CodesTableProps) => { - const { - pagesQuantity, - currentPage, - setCurrentPage, - pageSize, - setPageSize, - offset, - } = usePaginator({ - total: totalData, - initialState: { - pageSize: 10, - currentPage: 1, - isDisabled: false, - }, - }); - const { codes, isLoading } = useCodeStored( - walletAddress, - offset, - onViewMore ? 5 : pageSize - ); - - const onPageChange = (nextPage: number) => { - refetchCount(); - setCurrentPage(nextPage); - }; - - const onPageSizeChange = (e: ChangeEvent) => { - const size = Number(e.target.value); - refetchCount(); - setPageSize(size); - setCurrentPage(1); - }; - - const templateColumns = - "max(80px) minmax(320px, 1fr) max(120px) max(160px) minmax(320px, 0.75fr)"; - - if (isLoading) return ; - if (!codes?.length) - return ( - - - - ); - return ( - <> - - - {codes.map((code) => ( - - ))} - - {totalData && - (onViewMore - ? totalData > 5 && - : totalData > 10 && ( - - ))} - - ); - } -); - -export const CodesTable = ({ - totalData, - ...componentProps -}: CodesTableProps) => ( - - - - -); diff --git a/src/lib/pages/account-details/components/tables/codes/index.tsx b/src/lib/pages/account-details/components/tables/codes/index.tsx deleted file mode 100644 index 77c12b1be..000000000 --- a/src/lib/pages/account-details/components/tables/codes/index.tsx +++ /dev/null @@ -1 +0,0 @@ -export * from "./CodesTable"; diff --git a/src/lib/pages/account-details/components/tables/contracts/AdminContractsTable.tsx b/src/lib/pages/account-details/components/tables/contracts/AdminContractsTable.tsx deleted file mode 100644 index 649894f85..000000000 --- a/src/lib/pages/account-details/components/tables/contracts/AdminContractsTable.tsx +++ /dev/null @@ -1,133 +0,0 @@ -import { Box, Flex } from "@chakra-ui/react"; -import { observer } from "mobx-react-lite"; -import type { ChangeEvent } from "react"; - -import { Loading } from "lib/components/Loading"; -import { Pagination } from "lib/components/pagination"; -import { usePaginator } from "lib/components/pagination/usePaginator"; -import { EmptyState } from "lib/components/state/EmptyState"; -import { TableContainer } from "lib/components/table"; -import { - ContractsTableHeader, - ContractsTableRow, -} from "lib/components/table/contracts"; -import { TableTitle } from "lib/components/table/TableTitle"; -import { ViewMore } from "lib/components/table/ViewMore"; -import { useContractsAdmin } from "lib/pages/account-details/data"; -import type { HumanAddr, Option } from "lib/types"; - -interface ContractsTableProps { - walletAddress: HumanAddr; - scrollComponentId: string; - totalData: Option; - refetchCount: () => void; - onViewMore?: () => void; -} - -const ContractsTableBody = observer( - ({ - walletAddress, - scrollComponentId, - totalData, - refetchCount, - onViewMore, - }: ContractsTableProps) => { - const { - pagesQuantity, - currentPage, - setCurrentPage, - pageSize, - setPageSize, - offset, - } = usePaginator({ - total: totalData, - initialState: { - pageSize: 10, - currentPage: 1, - isDisabled: false, - }, - }); - const { contracts, isLoading } = useContractsAdmin( - walletAddress, - offset, - onViewMore ? 5 : pageSize - ); - - const onPageChange = (nextPage: number) => { - refetchCount(); - setCurrentPage(nextPage); - }; - - const onPageSizeChange = (e: ChangeEvent) => { - const size = Number(e.target.value); - refetchCount(); - setPageSize(size); - setCurrentPage(1); - }; - - const templateColumns = - "150px minmax(250px, 1fr) 200px 150px minmax(250px, 300px) 70px"; - - if (isLoading) return ; - if (!contracts?.length) - return ( - - - - ); - return ( - <> - - - {contracts.map((contractInfo) => ( - - ))} - - {totalData && - (onViewMore - ? totalData > 5 && - : totalData > 10 && ( - - ))} - - ); - } -); - -export const AdminContractsTable = ({ - totalData, - ...componentProps -}: ContractsTableProps) => ( - - - - -); diff --git a/src/lib/pages/account-details/components/tables/contracts/InstantiatedContractsTable.tsx b/src/lib/pages/account-details/components/tables/contracts/InstantiatedContractsTable.tsx deleted file mode 100644 index d29e1f06c..000000000 --- a/src/lib/pages/account-details/components/tables/contracts/InstantiatedContractsTable.tsx +++ /dev/null @@ -1,133 +0,0 @@ -import { Box, Flex } from "@chakra-ui/react"; -import { observer } from "mobx-react-lite"; -import type { ChangeEvent } from "react"; - -import { Loading } from "lib/components/Loading"; -import { Pagination } from "lib/components/pagination"; -import { usePaginator } from "lib/components/pagination/usePaginator"; -import { EmptyState } from "lib/components/state/EmptyState"; -import { TableContainer } from "lib/components/table"; -import { - ContractsTableHeader, - ContractsTableRow, -} from "lib/components/table/contracts"; -import { TableTitle } from "lib/components/table/TableTitle"; -import { ViewMore } from "lib/components/table/ViewMore"; -import { useContractInstances } from "lib/pages/account-details/data"; -import type { HumanAddr, Option } from "lib/types"; - -interface ContractsTableProps { - walletAddress: HumanAddr; - scrollComponentId: string; - totalData: Option; - refetchCount: () => void; - onViewMore?: () => void; -} - -const ContractsTableBody = observer( - ({ - walletAddress, - scrollComponentId, - totalData, - refetchCount, - onViewMore, - }: ContractsTableProps) => { - const { - pagesQuantity, - currentPage, - setCurrentPage, - pageSize, - setPageSize, - offset, - } = usePaginator({ - total: totalData, - initialState: { - pageSize: 10, - currentPage: 1, - isDisabled: false, - }, - }); - const { contracts, isLoading } = useContractInstances( - walletAddress, - offset, - onViewMore ? 5 : pageSize - ); - - const onPageChange = (nextPage: number) => { - refetchCount(); - setCurrentPage(nextPage); - }; - - const onPageSizeChange = (e: ChangeEvent) => { - const size = Number(e.target.value); - refetchCount(); - setPageSize(size); - setCurrentPage(1); - }; - - const templateColumns = - "150px minmax(250px, 1fr) 200px 150px minmax(250px, 300px) 70px"; - - if (isLoading) return ; - if (!contracts?.length) - return ( - - - - ); - return ( - <> - - - {contracts.map((contractInfo) => ( - - ))} - - {totalData && - (onViewMore - ? totalData > 5 && - : totalData > 10 && ( - - ))} - - ); - } -); - -export const InstantiatedContractsTable = ({ - totalData, - ...componentProps -}: ContractsTableProps) => ( - - - - -); diff --git a/src/lib/pages/account-details/components/tables/contracts/index.tsx b/src/lib/pages/account-details/components/tables/contracts/index.tsx deleted file mode 100644 index 1d72cb003..000000000 --- a/src/lib/pages/account-details/components/tables/contracts/index.tsx +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./AdminContractsTable"; -export * from "./InstantiatedContractsTable"; diff --git a/src/lib/pages/account-details/components/tables/index.ts b/src/lib/pages/account-details/components/tables/index.ts new file mode 100644 index 000000000..25de2895a --- /dev/null +++ b/src/lib/pages/account-details/components/tables/index.ts @@ -0,0 +1,5 @@ +export * from "./AdminContractsTable"; +export * from "./InstantiatedContractsTable"; +export * from "./OpenedProposalsTable"; +export * from "./StoredCodesTable"; +export * from "./TxsTable"; diff --git a/src/lib/pages/account-details/components/tables/index.tsx b/src/lib/pages/account-details/components/tables/index.tsx deleted file mode 100644 index d093be8e5..000000000 --- a/src/lib/pages/account-details/components/tables/index.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export * from "./codes"; -export * from "./contracts"; -export * from "./proposals"; diff --git a/src/lib/pages/account-details/components/tables/proposals/ProposalsTable.tsx b/src/lib/pages/account-details/components/tables/proposals/ProposalsTable.tsx deleted file mode 100644 index ef9db4335..000000000 --- a/src/lib/pages/account-details/components/tables/proposals/ProposalsTable.tsx +++ /dev/null @@ -1,124 +0,0 @@ -import { Box, Flex } from "@chakra-ui/react"; -import { observer } from "mobx-react-lite"; -import type { ChangeEvent } from "react"; - -import { Loading } from "lib/components/Loading"; -import { Pagination } from "lib/components/pagination"; -import { usePaginator } from "lib/components/pagination/usePaginator"; -import { EmptyState } from "lib/components/state/EmptyState"; -import { TableContainer } from "lib/components/table"; -import { - ProposalsTableHeader, - ProposalsTableRow, -} from "lib/components/table/proposals"; -import { TableTitle } from "lib/components/table/TableTitle"; -import { ViewMore } from "lib/components/table/ViewMore"; -import { useProposalsByWalletAddressPagination } from "lib/services/proposalService"; -import type { HumanAddr, Option } from "lib/types"; - -interface ProposalsTableProps { - walletAddress: HumanAddr; - scrollComponentId: string; - totalData: Option; - refetchCount: () => void; - onViewMore?: () => void; -} - -const ProposalsTableBody = observer( - ({ - walletAddress, - scrollComponentId, - totalData, - refetchCount, - onViewMore, - }: ProposalsTableProps) => { - const { - pagesQuantity, - currentPage, - setCurrentPage, - pageSize, - setPageSize, - offset, - } = usePaginator({ - total: totalData, - initialState: { - pageSize: 10, - currentPage: 1, - isDisabled: false, - }, - }); - const { data: proposals, isLoading } = - useProposalsByWalletAddressPagination( - walletAddress, - offset, - onViewMore ? 5 : pageSize - ); - - const onPageChange = (nextPage: number) => { - refetchCount(); - setCurrentPage(nextPage); - }; - - const onPageSizeChange = (e: ChangeEvent) => { - const size = Number(e.target.value); - refetchCount(); - setPageSize(size); - setCurrentPage(1); - }; - - const templateColumns = - "100px minmax(300px, 1fr) 150px 280px 180px 190px 160px"; - - if (isLoading) return ; - if (!proposals?.length) - return ( - - - - ); - return ( - <> - - - {proposals.map((proposal) => ( - - ))} - - {totalData && - (onViewMore - ? totalData > 5 && - : totalData > 10 && ( - - ))} - - ); - } -); - -export const ProposalsTable = ({ - totalData, - ...componentProps -}: ProposalsTableProps) => ( - - - - -); diff --git a/src/lib/pages/account-details/index.tsx b/src/lib/pages/account-details/index.tsx index c2a0067f0..3e5b0fcaa 100644 --- a/src/lib/pages/account-details/index.tsx +++ b/src/lib/pages/account-details/index.tsx @@ -14,21 +14,21 @@ import { BackButton } from "lib/components/button"; import { CustomTab } from "lib/components/CustomTab"; import { ExplorerLink } from "lib/components/ExplorerLink"; import PageContainer from "lib/components/PageContainer"; -import { InvalidState } from "lib/components/state/InvalidState"; +import { InvalidState } from "lib/components/state"; import { useValidateAddress } from "lib/hooks"; import { useAccountDetailsTableCounts } from "lib/model/account"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import type { HumanAddr } from "lib/types"; -import { getFirstQueryParam } from "lib/utils"; +import { getFirstQueryParam, scrollToTop } from "lib/utils"; import { AssetsSection } from "./components/asset"; import { AdminContractsTable, - CodesTable, InstantiatedContractsTable, - ProposalsTable, + OpenedProposalsTable, + StoredCodesTable, + TxsTable, } from "./components/tables"; -import { TransactionsTable } from "./components/tables/transactions"; enum TabIndex { Overview, @@ -59,6 +59,11 @@ const AccountDetailsBody = ({ accountAddress }: AccountDetailsBodyProps) => { refetchProposalsCount, } = useAccountDetailsTableCounts(accountAddress); + const handleOnViewMore = (tab: TabIndex) => { + setTabIndex(tab); + scrollToTop(); + }; + return ( <> @@ -83,6 +88,7 @@ const AccountDetailsBody = ({ accountAddress }: AccountDetailsBodyProps) => { setTabIndex(TabIndex.Overview)}> @@ -141,42 +147,42 @@ const AccountDetailsBody = ({ accountAddress }: AccountDetailsBodyProps) => { Delegations setTabIndex(TabIndex.Assets)} + onViewMore={() => handleOnViewMore(TabIndex.Assets)} /> - setTabIndex(TabIndex.Txs)} + onViewMore={() => handleOnViewMore(TabIndex.Txs)} /> - setTabIndex(TabIndex.Codes)} + onViewMore={() => handleOnViewMore(TabIndex.Codes)} /> setTabIndex(TabIndex.Contracts)} + onViewMore={() => handleOnViewMore(TabIndex.Contracts)} /> setTabIndex(TabIndex.Admins)} + onViewMore={() => handleOnViewMore(TabIndex.Admins)} /> - setTabIndex(TabIndex.Proposals)} + onViewMore={() => handleOnViewMore(TabIndex.Proposals)} /> @@ -187,7 +193,7 @@ const AccountDetailsBody = ({ accountAddress }: AccountDetailsBodyProps) => { - { /> - { /> - { + const { getContractLocalInfo } = useContractStore(); + + const { data: totalData, refetch } = useContractListCountByCodeId(codeId); + const { + pagesQuantity, + currentPage, + setCurrentPage, + pageSize, + setPageSize, + offset, + } = usePaginator({ + total: totalData, + initialState: { + pageSize: 10, + currentPage: 1, + isDisabled: false, + }, + }); + + const { data: rawCodeContracts, isLoading } = + useContractListByCodeIdPagination(codeId, offset, pageSize); + const codeContracts: Option = + rawCodeContracts?.map((contract) => ({ + ...contract, + ...getContractLocalInfo(contract.contractAddress), + })); + + useEffect(() => { + setCurrentPage(1); + }, [pageSize, setCurrentPage]); + + const onPageChange = (nextPage: number) => { + refetch(); + setCurrentPage(nextPage); + }; + + const onPageSizeChange = (e: ChangeEvent) => { + const size = Number(e.target.value); + refetch(); + setPageSize(size); + }; + + // FIXME - might be a better way to scroll to table header + const tableHeaderId = "contractTableHeader"; + + return ( + <> + + } + /> + {totalData && totalData > 10 && ( + + )} + + ); + } +); diff --git a/src/lib/pages/code-details/components/table/NoContracts.tsx b/src/lib/pages/code-details/components/table/NoContracts.tsx index 4d6d88580..b40d038ff 100644 --- a/src/lib/pages/code-details/components/table/NoContracts.tsx +++ b/src/lib/pages/code-details/components/table/NoContracts.tsx @@ -1,7 +1,7 @@ import { Box, Flex, Text } from "@chakra-ui/react"; import { useWallet } from "@cosmos-kit/react"; -import { ConnectWalletBtn } from "lib/components/button/ConnectWallet"; +import { ConnectWalletBtn } from "lib/components/button"; const DisconnectedState = () => ( diff --git a/src/lib/pages/code-details/components/table/contracts/ContractTable.tsx b/src/lib/pages/code-details/components/table/contracts/ContractTable.tsx deleted file mode 100644 index 693ede8fd..000000000 --- a/src/lib/pages/code-details/components/table/contracts/ContractTable.tsx +++ /dev/null @@ -1,126 +0,0 @@ -import { Badge, Flex, Heading } from "@chakra-ui/react"; -import { observer } from "mobx-react-lite"; -import type { ChangeEvent } from "react"; -import { useEffect } from "react"; - -import { NoContracts } from "../NoContracts"; -import { Pagination } from "lib/components/pagination"; -import { usePaginator } from "lib/components/pagination/usePaginator"; -import { TableContainer } from "lib/components/table"; -import { - ContractsTableHeader, - ContractsTableRow, -} from "lib/components/table/contracts"; -import { useContractStore } from "lib/hooks"; -import { - useContractListByCodeIdPagination, - useContractListCountByCodeId, -} from "lib/services/contractService"; -import type { ContractInfo, Option } from "lib/types"; - -interface ContractTableProps { - codeId: number; -} - -export const ContractTable = observer(({ codeId }: ContractTableProps) => { - const { getContractLocalInfo } = useContractStore(); - - const { data: totalData, refetch } = useContractListCountByCodeId(codeId); - const { - pagesQuantity, - currentPage, - setCurrentPage, - pageSize, - setPageSize, - offset, - } = usePaginator({ - total: totalData, - initialState: { - pageSize: 10, - currentPage: 1, - isDisabled: false, - }, - }); - - const { data: rawCodeContracts } = useContractListByCodeIdPagination( - codeId, - offset, - pageSize - ); - const codeContracts: Option = - rawCodeContracts?.map((contract) => ({ - ...contract, - ...getContractLocalInfo(contract.contractAddress), - })); - - useEffect(() => { - setCurrentPage(1); - }, [pageSize, setCurrentPage]); - - const onPageChange = (nextPage: number) => { - refetch(); - setCurrentPage(nextPage); - }; - - const onPageSizeChange = (e: ChangeEvent) => { - const size = Number(e.target.value); - refetch(); - setPageSize(size); - }; - - // FIXME - might be a better way to scroll to table header - const tableHeaderId = "contractTableHeader"; - const templateColumns = - "150px minmax(250px, 1fr) 200px 150px minmax(250px, 300px) 70px"; - - return ( - <> - - - Contract Instances - - - {totalData ?? 0} - - - {!codeContracts?.length ? ( - - ) : ( - <> - - - {codeContracts.map((contractInfo) => ( - - ))} - - {totalData && totalData > 10 && ( - - )} - - )} - - ); -}); diff --git a/src/lib/pages/code-details/index.tsx b/src/lib/pages/code-details/index.tsx index 6210a7878..c5f806558 100644 --- a/src/lib/pages/code-details/index.tsx +++ b/src/lib/pages/code-details/index.tsx @@ -3,11 +3,11 @@ import { observer } from "mobx-react-lite"; import { useRouter } from "next/router"; import { useEffect } from "react"; -import { BackButton } from "lib/components/button/BackButton"; +import { BackButton } from "lib/components/button"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { Loading } from "lib/components/Loading"; import PageContainer from "lib/components/PageContainer"; -import { InvalidState } from "lib/components/state/InvalidState"; +import { InvalidState } from "lib/components/state"; import { useCodeStore } from "lib/hooks"; import type { CodeDataState } from "lib/model/code"; import { useCodeData } from "lib/model/code"; @@ -17,7 +17,7 @@ import { getFirstQueryParam, isCodeId } from "lib/utils"; import { CodeInfoSection } from "./components/CodeInfoSection"; import { CTASection } from "./components/CTASection"; -import { ContractTable } from "./components/table/contracts/ContractTable"; +import { CodeContractsTable } from "./components/table/CodeContractsTable"; interface CodeDetailsBodyProps { codeDataState: CodeDataState; @@ -74,7 +74,7 @@ const CodeDetailsBody = observer( - + ); } diff --git a/src/lib/pages/codes/components/CodesTable.tsx b/src/lib/pages/codes/components/CodesTable.tsx index 7b858dbe3..ce0d6997c 100644 --- a/src/lib/pages/codes/components/CodesTable.tsx +++ b/src/lib/pages/codes/components/CodesTable.tsx @@ -13,16 +13,16 @@ import type { ReactNode } from "react"; import { useInternalNavigate } from "lib/app-provider"; import { InstantiateButton } from "lib/components/button"; -import { CodeNameCell } from "lib/components/CodeNameCell"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { Loading } from "lib/components/Loading"; -import { SaveOrRemoveCodeModal } from "lib/components/modal/code/SaveOrRemoveCode"; +import { SaveOrRemoveCodeModal } from "lib/components/modal"; import { PermissionChip } from "lib/components/PermissionChip"; -import { DisconnectedState } from "lib/components/state/DisconnectedState"; +import { DisconnectedState } from "lib/components/state"; import { TableContainer, TableHeaderNoBorder, TableRowNoBorder, + CodeNameCell, } from "lib/components/table"; import type { CodeInfo } from "lib/types"; @@ -55,32 +55,29 @@ const StateContainer = ({ children }: { children: ReactNode }) => ( borderBottomWidth={1} minH="128px" justifyContent="center" + px={12} py={8} > {children} ); -const NotMatched = () => { - return ( - - result not found - No matched codes found. - - ); -}; +const NotMatched = () => ( + + result not found + No matched codes found. + +); -const Unconnected = () => { - return ( - - - - ); -}; +const Unconnected = () => ( + + + +); const Empty = ({ type }: OtherTBodyProps) => { const renderEmptyText = () => { @@ -102,24 +99,22 @@ const Empty = ({ type }: OtherTBodyProps) => { ); }; -const CodeTableHead = () => { - return ( - - Code ID - Code Name - Contracts - Uploader - Permission - - ); -}; +const CodeTableHead = () => ( + + Code ID + Code Name + Contracts + Uploader + Permission + +); const CodeTableRow = ({ code }: CodesRowProps) => { const navigate = useInternalNavigate(); @@ -191,19 +186,17 @@ const CodeTableRow = ({ code }: CodesRowProps) => { const NormalRender = ({ codes, tableName, -}: Pick) => { - return ( - - - {codes.map((code) => ( - - ))} - - ); -}; +}: Pick) => ( + + + {codes.map((code) => ( + + ))} + +); function CodesTable({ type, diff --git a/src/lib/pages/codes/components/SaveCodeButton.tsx b/src/lib/pages/codes/components/SaveCodeButton.tsx index 201e40633..bd54e1f57 100644 --- a/src/lib/pages/codes/components/SaveCodeButton.tsx +++ b/src/lib/pages/codes/components/SaveCodeButton.tsx @@ -1,15 +1,13 @@ import { MdBookmarkBorder } from "react-icons/md"; -import { SaveNewCodeModal } from "lib/components/modal/code/SaveNewCode"; +import { SaveNewCodeModal } from "lib/components/modal"; -export default () => { - return ( - , - children: "Save New Code", - }} - /> - ); -}; +export default () => ( + , + children: "Save New Code", + }} + /> +); diff --git a/src/lib/pages/contract-details/components/contract-description/index.tsx b/src/lib/pages/contract-details/components/contract-description/index.tsx index e0f7d2e10..798022b07 100644 --- a/src/lib/pages/contract-details/components/contract-description/index.tsx +++ b/src/lib/pages/contract-details/components/contract-description/index.tsx @@ -8,13 +8,11 @@ import { UserContractDesc } from "./UserContractDesc"; interface ContractDescProps { contractData: ContractData; } -export const ContractDesc = ({ contractData }: ContractDescProps) => { - return ( - - {contractData.publicProject.publicInfo?.description && ( - - )} - - - ); -}; +export const ContractDesc = ({ contractData }: ContractDescProps) => ( + + {contractData.publicProject.publicInfo?.description && ( + + )} + + +); diff --git a/src/lib/pages/contract-details/components/tables/execute/index.tsx b/src/lib/pages/contract-details/components/tables/ExecuteTxsTable.tsx similarity index 50% rename from src/lib/pages/contract-details/components/tables/execute/index.tsx rename to src/lib/pages/contract-details/components/tables/ExecuteTxsTable.tsx index 5128320b6..2bcdca920 100644 --- a/src/lib/pages/contract-details/components/tables/execute/index.tsx +++ b/src/lib/pages/contract-details/components/tables/ExecuteTxsTable.tsx @@ -1,28 +1,25 @@ -import { Grid } from "@chakra-ui/react"; import type { ChangeEvent } from "react"; -import { NoTransactions } from "../NoTransactions"; import { Pagination } from "lib/components/pagination"; import { usePaginator } from "lib/components/pagination/usePaginator"; -import { TableContainer, TableHeader } from "lib/components/table"; -import { useExecuteTxsByContractAddressPagination } from "lib/services/contractService"; +import { EmptyState } from "lib/components/state"; +import { TransactionsTable } from "lib/components/table"; +import { useExecuteTxsByContractAddressPagination } from "lib/services/txService"; import type { ContractAddr, Option } from "lib/types"; -import { ExecuteTableRow } from "./ExecuteTableRow"; - -interface ExecuteTableProps { +interface ExecuteTxsTableProps { contractAddress: ContractAddr; scrollComponentId: string; totalData: Option; refetchCount: () => void; } -export const ExecuteTable = ({ +export const ExecuteTxsTable = ({ contractAddress, scrollComponentId, totalData, refetchCount, -}: ExecuteTableProps) => { +}: ExecuteTxsTableProps) => { const { pagesQuantity, currentPage, @@ -39,11 +36,8 @@ export const ExecuteTable = ({ }, }); - const { data: executeTransaction } = useExecuteTxsByContractAddressPagination( - contractAddress, - offset, - pageSize - ); + const { data: executeTransactions, isLoading } = + useExecuteTxsByContractAddressPagination(contractAddress, offset, pageSize); const onPageChange = (nextPage: number) => { refetchCount(); @@ -57,32 +51,19 @@ export const ExecuteTable = ({ setCurrentPage(1); }; - if (!executeTransaction?.length) - return ( - - ); - - const templateColumnsStyle = - "170px 70px minmax(300px, 1fr) repeat(2, max(170px)) max(300px)"; - return ( - - - Transaction Hash - - Execute Messages - Sender - Block Height - Timestamp - - {executeTransaction?.map((transaction) => ( - - ))} - {totalData && totalData > 10 && ( + <> + + } + /> + {!!totalData && totalData > 10 && ( )} - + ); }; diff --git a/src/lib/pages/contract-details/components/tables/NoTransactions.tsx b/src/lib/pages/contract-details/components/tables/NoTransactions.tsx deleted file mode 100644 index b5bb21212..000000000 --- a/src/lib/pages/contract-details/components/tables/NoTransactions.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { Flex, Text } from "@chakra-ui/react"; - -interface NoTransactionsProps { - displayText: string; -} - -export const NoTransactions = ({ displayText }: NoTransactionsProps) => ( - - - {displayText} - - -); diff --git a/src/lib/pages/contract-details/components/tables/related-proposals/index.tsx b/src/lib/pages/contract-details/components/tables/RelatedProposalsTable.tsx similarity index 66% rename from src/lib/pages/contract-details/components/tables/related-proposals/index.tsx rename to src/lib/pages/contract-details/components/tables/RelatedProposalsTable.tsx index 110ccd187..a839feb6f 100644 --- a/src/lib/pages/contract-details/components/tables/related-proposals/index.tsx +++ b/src/lib/pages/contract-details/components/tables/RelatedProposalsTable.tsx @@ -1,13 +1,9 @@ import type { ChangeEvent } from "react"; -import { NoTransactions } from "../NoTransactions"; import { Pagination } from "lib/components/pagination"; import { usePaginator } from "lib/components/pagination/usePaginator"; -import { TableContainer } from "lib/components/table"; -import { - ProposalsTableHeader, - ProposalsTableRow, -} from "lib/components/table/proposals"; +import { EmptyState } from "lib/components/state"; +import { ProposalsTable } from "lib/components/table"; import { useRelatedProposalsByContractAddressPagination } from "lib/services/proposalService"; import type { ContractAddr, Option } from "lib/types"; @@ -40,7 +36,7 @@ export const RelatedProposalsTable = ({ }, }); - const { data: relatedProposals } = + const { data: relatedProposals, isLoading } = useRelatedProposalsByContractAddressPagination( contractAddress, offset, @@ -59,27 +55,19 @@ export const RelatedProposalsTable = ({ setCurrentPage(1); }; - const templateColumns = - "100px minmax(300px, 1fr) 150px 280px 180px 190px 160px"; - - if (!relatedProposals?.length) - return ( - - ); - return ( <> - - - {relatedProposals.map((proposal) => ( - - ))} - - {totalData && totalData > 10 && ( + } + /> + {!!totalData && totalData > 10 && ( ; refetchCount: () => void; } -export const TransactionsTable = ({ +export const TxsTable = ({ contractAddress, scrollComponentId, totalData, refetchCount, -}: TransactionsTableProps) => { +}: TxsTableProps) => { const { pagesQuantity, currentPage, @@ -39,7 +36,7 @@ export const TransactionsTable = ({ }, }); - const { data: transactions } = useTxsByContractAddressPagination( + const { data: transactions, isLoading } = useTxsByContractAddressPagination( contractAddress, offset, pageSize @@ -57,32 +54,19 @@ export const TransactionsTable = ({ setCurrentPage(1); }; - if (!transactions?.length) - return ( - - ); - - const templateColumnsStyle = - "180px 70px minmax(360px, 1fr) repeat(2, max(170px)) max(300px)"; - return ( - - - Transaction Hash - - Messages - Sender - Block Height - Timestamp - - {transactions?.map((transaction) => ( - - ))} - {totalData && totalData > 10 && ( + <> + + } + /> + {!!totalData && totalData > 10 && ( )} - + ); }; diff --git a/src/lib/pages/contract-details/components/tables/execute/ExecuteTableRow.tsx b/src/lib/pages/contract-details/components/tables/execute/ExecuteTableRow.tsx deleted file mode 100644 index 79c854680..000000000 --- a/src/lib/pages/contract-details/components/tables/execute/ExecuteTableRow.tsx +++ /dev/null @@ -1,77 +0,0 @@ -import { Flex, Icon, Tag, Text, Grid } from "@chakra-ui/react"; -import { MdCheck, MdClose } from "react-icons/md"; - -import { ExplorerLink } from "lib/components/ExplorerLink"; -import { TableRow } from "lib/components/table"; -import type { ExecuteTransaction } from "lib/types"; -import { dateFromNow, formatUTC } from "lib/utils"; -import { getExecuteMsgTags } from "lib/utils/executeTags"; - -interface ExecuteTableRowProps { - transaction: ExecuteTransaction; - templateColumnsStyle: string; -} - -export const ExecuteTableRow = ({ - transaction, - templateColumnsStyle, -}: ExecuteTableRowProps) => { - return ( - - - - - - - - - - {getExecuteMsgTags(transaction.messages, 2).map( - (tag: string, index: number) => ( - - {tag} - - ) - )} - - - - - - - - - - - - {transaction.created ? ( - <> - {formatUTC(transaction.created)} - - {`(${dateFromNow(transaction.created)})`} - - - ) : ( - N/A - )} - - - - ); -}; diff --git a/src/lib/pages/contract-details/components/tables/migration/MigrationHeader.tsx b/src/lib/pages/contract-details/components/tables/migration/MigrationHeader.tsx index 0b4237f49..52d63adb7 100644 --- a/src/lib/pages/contract-details/components/tables/migration/MigrationHeader.tsx +++ b/src/lib/pages/contract-details/components/tables/migration/MigrationHeader.tsx @@ -7,15 +7,13 @@ export const MigrationHeader = ({ templateColumns, }: { templateColumns: GridProps["templateColumns"]; -}) => { - return ( - - Code ID - Code Name - Sender - Block Height - Timestamp - Remark - - ); -}; +}) => ( + + Code ID + Code Name + Sender + Block Height + Timestamp + Remark + +); diff --git a/src/lib/pages/contract-details/components/tables/migration/MigrationRow.tsx b/src/lib/pages/contract-details/components/tables/migration/MigrationRow.tsx index 4ad151e31..414862129 100644 --- a/src/lib/pages/contract-details/components/tables/migration/MigrationRow.tsx +++ b/src/lib/pages/contract-details/components/tables/migration/MigrationRow.tsx @@ -1,9 +1,8 @@ import type { GridProps } from "@chakra-ui/react"; import { Flex, Grid, Text } from "@chakra-ui/react"; -import { CodeNameCell } from "lib/components/CodeNameCell"; import { ExplorerLink } from "lib/components/ExplorerLink"; -import { TableRow } from "lib/components/table"; +import { TableRow, CodeNameCell } from "lib/components/table"; import { useGetAddressType } from "lib/hooks"; import type { ContractMigrationHistory } from "lib/types"; import { RemarkOperation } from "lib/types"; diff --git a/src/lib/pages/contract-details/components/tables/migration/index.tsx b/src/lib/pages/contract-details/components/tables/migration/index.tsx index e0c95d950..ec445976c 100644 --- a/src/lib/pages/contract-details/components/tables/migration/index.tsx +++ b/src/lib/pages/contract-details/components/tables/migration/index.tsx @@ -1,8 +1,8 @@ import type { ChangeEvent } from "react"; -import { NoTransactions } from "../NoTransactions"; import { Pagination } from "lib/components/pagination"; import { usePaginator } from "lib/components/pagination/usePaginator"; +import { EmptyState } from "lib/components/state"; import { TableContainer } from "lib/components/table"; import { useMigrationHistories } from "lib/pages/contract-details/model/data"; import type { ContractAddr, Option } from "lib/types"; @@ -59,7 +59,10 @@ export const MigrationTable = ({ if (!migrationHistories?.length) return ( - + ); const templateColumns = @@ -81,7 +84,7 @@ export const MigrationTable = ({ templateColumns={templateColumns} /> ))} - {totalData && totalData > 10 && ( + {!!totalData && totalData > 10 && ( { - const { isOpen, onToggle } = useDisclosure(); - const [isAccordion, setIsAccordion] = useState(false); - const [showCopyButton, setShowCopyButton] = useState(false); - - useEffect(() => { - if (transaction.messages.length > 1) setIsAccordion(true); - }, [transaction.messages]); - - return ( - - setShowCopyButton(true)} - onMouseLeave={() => setShowCopyButton(false)} - > - - - - - - - - - - {transaction.isIbc && ( - - IBC - - )} - - - - - - - - - - - - - {transaction.created ? ( - <> - {formatUTC(transaction.created)} - - {`(${dateFromNow(transaction.created)})`} - - - ) : ( - N/A - )} - - {isAccordion && ( - - )} - - - - {isAccordion && ( - - )} - - ); -}; diff --git a/src/lib/pages/contract-details/index.tsx b/src/lib/pages/contract-details/index.tsx index c3eb430d0..416219cee 100644 --- a/src/lib/pages/contract-details/index.tsx +++ b/src/lib/pages/contract-details/index.tsx @@ -10,11 +10,11 @@ import { observer } from "mobx-react-lite"; import { useRouter } from "next/router"; import { useEffect } from "react"; -import { BackButton } from "lib/components/button/BackButton"; +import { BackButton } from "lib/components/button"; import { CustomTab } from "lib/components/CustomTab"; import { Loading } from "lib/components/Loading"; import PageContainer from "lib/components/PageContainer"; -import { InvalidState } from "lib/components/state/InvalidState"; +import { InvalidState } from "lib/components/state"; import { useValidateAddress } from "lib/hooks"; import { useContractData, @@ -30,8 +30,8 @@ import { ContractTop } from "./components/ContractTop"; import { InstantiateInfo } from "./components/InstantiateInfo"; import { JsonInfo } from "./components/JsonInfo"; import { MigrationTable } from "./components/tables/migration"; -import { RelatedProposalsTable } from "./components/tables/related-proposals"; -import { TransactionsTable } from "./components/tables/transactions"; +import { RelatedProposalsTable } from "./components/tables/RelatedProposalsTable"; +import { TxsTable } from "./components/tables/TxsTable"; import { TokenSection } from "./components/token/TokenSection"; interface ContractDetailsBodyProps { @@ -104,7 +104,7 @@ const ContractDetailsBody = observer( - {/* Remove execute table for now */} {/* - void; -} - -const TEMPLATE_COLUMNS = "160px 280px 260px 1fr"; - -export const ContractListReadOnlyTable = ({ - contracts = [], - onContractSelect, -}: ContractListReadOnlyTableProps) => { - return ( - - - Contract Address - Contract Name - Tags - Instantiated by - - {contracts.map((item) => ( - { - onContractSelect(item.contractAddress); - }} - cursor="pointer" - > - - - - - - - - - - - {item.instantiator ? ( - - ) : ( - - N/A - - )} - - - ))} - - ); -}; diff --git a/src/lib/pages/home/components/RecentlyViewContracts.tsx b/src/lib/pages/home/components/RecentlyViewContracts.tsx index 1f3cf8c38..63839d562 100644 --- a/src/lib/pages/home/components/RecentlyViewContracts.tsx +++ b/src/lib/pages/home/components/RecentlyViewContracts.tsx @@ -1,6 +1,6 @@ import { Heading, Box, Flex, Text } from "@chakra-ui/react"; -import { ContractListTable } from "lib/pages/contract-list/components/ContractListTable"; +import { ContractListTable } from "lib/components/modal/select-contract/ContractListTable"; import type { Addr, ContractAddr } from "lib/types"; import { getCurrentDate } from "lib/utils"; diff --git a/src/lib/pages/instantiate/component/FailedModal.tsx b/src/lib/pages/instantiate/component/FailedModal.tsx index da0b8a24f..fb5ab4f15 100644 --- a/src/lib/pages/instantiate/component/FailedModal.tsx +++ b/src/lib/pages/instantiate/component/FailedModal.tsx @@ -22,34 +22,32 @@ interface FailedModalProps { onClose: () => void; } -export const FailedModal = ({ errorLog, onClose }: FailedModalProps) => { - return ( - - - - - - - - Failed to instantiate - - - - - - Something went wrong. Here are the error logs. - - {errorLog} - - +export const FailedModal = ({ errorLog, onClose }: FailedModalProps) => ( + + + + + + + + Failed to instantiate + + + + + + Something went wrong. Here are the error logs. + + {errorLog} + + - - - - - - - ); -}; + + + + + + +); diff --git a/src/lib/pages/instantiate/component/code-select/CodeTableReadOnly.tsx b/src/lib/pages/instantiate/component/code-select/CodeTableReadOnly.tsx deleted file mode 100644 index aad9fcd52..000000000 --- a/src/lib/pages/instantiate/component/code-select/CodeTableReadOnly.tsx +++ /dev/null @@ -1,83 +0,0 @@ -import { Grid, Text } from "@chakra-ui/react"; - -import { ExplorerLink } from "lib/components/ExplorerLink"; -import { TableContainer, TableHeader, TableRow } from "lib/components/table"; -import type { CodeInfo } from "lib/types"; - -const TEMPLATE_COLUMNS = "48px 1fr 4fr 1fr 2fr 48px"; - -interface TableRowProps { - onCodeSelect: (newVal: string) => void; - codeDetail: CodeInfo; -} - -const CodeTableRow = ({ onCodeSelect, codeDetail }: TableRowProps) => { - return ( - onCodeSelect(codeDetail.id.toString())} - templateColumns={TEMPLATE_COLUMNS} - > - - {codeDetail.id} - - - {codeDetail?.name ?? "Untitled Name"} - - - - - {codeDetail.contractCount ?? "N/A"} - - - - - - - - ); -}; - -interface CodeTableReadOnlyProps { - onCodeSelect: (code: string) => void; - codes: CodeInfo[]; -} - -export const CodeTableReadOnly = ({ - onCodeSelect, - codes, -}: CodeTableReadOnlyProps) => { - return ( - - - - Code ID - Code Name - Contracts - Uploader - - - {codes.map((code, index) => ( - - ))} - - ); -}; diff --git a/src/lib/pages/instantiate/component/code-select/MySavedCodeContent.tsx b/src/lib/pages/instantiate/component/code-select/MySavedCodeContent.tsx deleted file mode 100644 index de8e37bce..000000000 --- a/src/lib/pages/instantiate/component/code-select/MySavedCodeContent.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import { Flex } from "@chakra-ui/react"; - -import { EmptyState } from "lib/components/state/EmptyState"; -import type { CodeInfo } from "lib/types"; - -import { CodeTableReadOnly } from "./CodeTableReadOnly"; - -interface MySavedCodeContentProps { - handleSelect: (code: string) => void; - savedCodes: CodeInfo[]; -} - -export const MySavedCodeContent = ({ - handleSelect, - savedCodes, -}: MySavedCodeContentProps) => { - if (!savedCodes.length) { - return ( - - - - ); - } - return ; -}; diff --git a/src/lib/pages/instantiate/component/index.ts b/src/lib/pages/instantiate/component/index.ts index b32172090..1f544d6f6 100644 --- a/src/lib/pages/instantiate/component/index.ts +++ b/src/lib/pages/instantiate/component/index.ts @@ -1,3 +1,2 @@ -export * from "./code-select/CodeSelect"; export * from "./FailedModal"; export * from "./Footer"; diff --git a/src/lib/pages/instantiate/instantiate.tsx b/src/lib/pages/instantiate/instantiate.tsx index d60f39fd2..1e26daa32 100644 --- a/src/lib/pages/instantiate/instantiate.tsx +++ b/src/lib/pages/instantiate/instantiate.tsx @@ -13,7 +13,6 @@ import { useInstantiateTx, useCelatoneApp, } from "lib/app-provider"; -import { CodeSelectSection } from "lib/components/CodeSelectSection"; import { ConnectWalletAlert } from "lib/components/ConnectWalletAlert"; import type { FormStatus } from "lib/components/forms"; import { ControllerInput } from "lib/components/forms"; @@ -22,6 +21,7 @@ import { defaultAsset, defaultAssetJsonStr } from "lib/components/fund/data"; import type { AttachFundsState } from "lib/components/fund/types"; import { AttachFundsType } from "lib/components/fund/types"; import JsonInput from "lib/components/json/JsonInput"; +import { CodeSelectSection } from "lib/components/modal/select-code"; import { Stepper } from "lib/components/stepper"; import WasmPageContainer from "lib/components/WasmPageContainer"; import { useLCDEndpoint, useValidateAddress } from "lib/hooks"; diff --git a/src/lib/pages/migrate/components/MigrateContract.tsx b/src/lib/pages/migrate/components/MigrateContract.tsx index 926f41cdb..e14d1324d 100644 --- a/src/lib/pages/migrate/components/MigrateContract.tsx +++ b/src/lib/pages/migrate/components/MigrateContract.tsx @@ -10,10 +10,10 @@ import { IoIosWarning } from "react-icons/io"; import { useFabricateFee, useSimulateFeeQuery } from "lib/app-provider"; import { useMigrateTx } from "lib/app-provider/tx/migrate"; -import { CodeSelectSection } from "lib/components/CodeSelectSection"; import { EstimatedFeeRender } from "lib/components/EstimatedFeeRender"; import type { FormStatus } from "lib/components/forms"; import JsonInput from "lib/components/json/JsonInput"; +import { CodeSelectSection } from "lib/components/modal/select-code"; import { useLCDEndpoint } from "lib/hooks"; import { useTxBroadcast } from "lib/providers/tx-broadcast"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; diff --git a/src/lib/pages/past-txs/components/FurtherActionButton.tsx b/src/lib/pages/past-txs/components/FurtherActionButton.tsx index 12bae4510..73354cd73 100644 --- a/src/lib/pages/past-txs/components/FurtherActionButton.tsx +++ b/src/lib/pages/past-txs/components/FurtherActionButton.tsx @@ -1,12 +1,11 @@ -import { RedoButton } from "lib/components/button/RedoButton"; -import { ResendButton } from "lib/components/button/ResendButton"; +import { RedoButton, ResendButton } from "lib/components/button"; import { RedoModal } from "lib/components/modal/RedoModal"; -import type { PastTransaction } from "lib/types"; +import type { Transaction } from "lib/types"; import { MsgFurtherAction } from "lib/types"; import { extractMsgType } from "lib/utils"; interface FurtherActionButtonProps { - transaction: PastTransaction; + transaction: Transaction; } /** diff --git a/src/lib/pages/past-txs/components/MultipleMsg.tsx b/src/lib/pages/past-txs/components/MultipleMsg.tsx deleted file mode 100644 index e0684d508..000000000 --- a/src/lib/pages/past-txs/components/MultipleMsg.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import { Flex, Tag } from "@chakra-ui/react"; -import { snakeCase } from "snake-case"; - -export interface MultipleMsgProps { - type: string; - tags?: Array; - length: number; - text: string; -} - -export const MultipleMsg = ({ type, tags, length, text }: MultipleMsgProps) => { - return ( - - {type} - {tags && - tags.map((tag: string, index: number) => ( - - {snakeCase(tag)} - - ))} - {tags && length - tags.length > 0 ? ( - +{length - tags.length} - ) : ( - {length} - )} - {/* For Execute */} - {!!tags?.length && "on"} {text} - - ); -}; diff --git a/src/lib/pages/past-txs/components/PastTxRow.tsx b/src/lib/pages/past-txs/components/PastTxRow.tsx index f9b5a607f..00771ccca 100644 --- a/src/lib/pages/past-txs/components/PastTxRow.tsx +++ b/src/lib/pages/past-txs/components/PastTxRow.tsx @@ -12,15 +12,14 @@ import { MdCheck, MdClose, MdKeyboardArrowDown } from "react-icons/md"; import { RenderActionMessages } from "lib/components/action-msg/ActionMessages"; import { ExplorerLink } from "lib/components/ExplorerLink"; -import { TableRow } from "lib/components/table"; -import { AccordionTx } from "lib/components/table/AccordionTx"; -import type { PastTransaction } from "lib/types"; +import { TableRow, AccordionTx } from "lib/components/table"; +import type { Transaction } from "lib/types"; import { dateFromNow, formatUTC } from "lib/utils"; import { FurtherActionButton } from "./FurtherActionButton"; interface PastTxRowProps { - transaction: PastTransaction; + transaction: Transaction; templateColumnsStyle: string; } diff --git a/src/lib/pages/past-txs/components/PastTxsContent.tsx b/src/lib/pages/past-txs/components/PastTxsContent.tsx index 6e4ba5386..f9607aa10 100644 --- a/src/lib/pages/past-txs/components/PastTxsContent.tsx +++ b/src/lib/pages/past-txs/components/PastTxsContent.tsx @@ -2,9 +2,8 @@ import { Flex } from "@chakra-ui/react"; import { useWallet } from "@cosmos-kit/react"; import { Loading } from "lib/components/Loading"; -import { DisconnectedState } from "lib/components/state/DisconnectedState"; -import { EmptyState } from "lib/components/state/EmptyState"; -import type { PastTransaction, Option } from "lib/types"; +import { DisconnectedState, EmptyState } from "lib/components/state"; +import type { Option, Transaction } from "lib/types"; import { PastTxRow } from "./PastTxRow"; import { PastTxsTableHeader } from "./PastTxsTableHeader"; @@ -14,7 +13,7 @@ interface PastTxsContentProps { txDataError: unknown; input: string; filterSelected: string[]; - txData: Option; + txData: Option; } export const PastTxsContent = ({ isLoading, diff --git a/src/lib/pages/past-txs/components/PastTxsTableHeader.tsx b/src/lib/pages/past-txs/components/PastTxsTableHeader.tsx index 809350947..ec5ad0b3a 100644 --- a/src/lib/pages/past-txs/components/PastTxsTableHeader.tsx +++ b/src/lib/pages/past-txs/components/PastTxsTableHeader.tsx @@ -7,15 +7,13 @@ export const PastTxsTableHeader = ({ templateColumns, }: { templateColumns: GridProps["templateColumns"]; -}) => { - return ( - - Transaction Hash - - Messages - Timestamp - - - - ); -}; +}) => ( + + Transaction Hash + + Messages + Timestamp + + + +); diff --git a/src/lib/pages/past-txs/hooks/useResend.ts b/src/lib/pages/past-txs/hooks/useResend.ts deleted file mode 100644 index c6adebfb3..000000000 --- a/src/lib/pages/past-txs/hooks/useResend.ts +++ /dev/null @@ -1,73 +0,0 @@ -import type { EncodeObject } from "@cosmjs/proto-signing"; -import { useCallback } from "react"; - -import { useFabricateFee, useResendTx, useSimulateFee } from "lib/app-provider"; -import { useTxBroadcast } from "lib/providers/tx-broadcast"; -import { AmpEvent, AmpTrack } from "lib/services/amplitude"; -import type { Message } from "lib/types"; -import { camelToSnake, encode } from "lib/utils"; - -export const useResend = () => { - const fabricateFee = useFabricateFee(); - const { simulate } = useSimulateFee(); - const resendTx = useResendTx(); - const { broadcast } = useTxBroadcast(); - - return useCallback( - ( - e: React.MouseEvent, - messages: Message[], - setIsButtonLoading: (isButtonLoading: boolean) => void, - setError: (err: string) => void - ) => { - (async () => { - AmpTrack(AmpEvent.ACTION_RESEND); - e.stopPropagation(); - setIsButtonLoading(true); - const formatedMsgs = messages.reduce( - (acc: EncodeObject[], msg: Message) => { - if (msg.msg.msg) { - acc.push({ - typeUrl: msg.type, - value: { - ...msg.msg, - msg: encode(JSON.stringify(camelToSnake(msg.msg.msg))), - }, - }); - } else { - acc.push({ - typeUrl: msg.type, - value: { - ...msg.msg, - }, - }); - } - return acc; - }, - [] - ); - - try { - const estimatedGasUsed = await simulate(formatedMsgs); - let fee; - if (estimatedGasUsed) { - fee = fabricateFee(estimatedGasUsed); - } - const stream = await resendTx({ - onTxSucceed: () => {}, - estimatedFee: fee, - messages: formatedMsgs, - }); - if (stream) broadcast(stream); - setIsButtonLoading(false); - } catch (err) { - setError((err as Error).message); - setIsButtonLoading(false); - } - - return null; - })(); - }, - [broadcast, fabricateFee, resendTx, simulate] - ); -}; diff --git a/src/lib/pages/past-txs/index.tsx b/src/lib/pages/past-txs/index.tsx index 3a579a234..f1c08b8af 100644 --- a/src/lib/pages/past-txs/index.tsx +++ b/src/lib/pages/past-txs/index.tsx @@ -14,15 +14,15 @@ import { useEffect, useMemo } from "react"; import { useForm } from "react-hook-form"; import { MdSearch } from "react-icons/md"; +import { TxFilterSelection } from "../../components/TxFilterSelection"; +import { useTxQuery, useTxQueryCount } from "../../services/txQuery/useTxQuery"; import { Pagination } from "lib/components/pagination"; import { usePaginator } from "lib/components/pagination/usePaginator"; import { DEFAULT_TX_FILTERS } from "lib/data"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import type { HumanAddr } from "lib/types"; -import { FilterSelection } from "./components/FilterSelection"; import { PastTxsContent } from "./components/PastTxsContent"; -import { useTxQuery, useTxQueryCount } from "./query/useTxQuery"; const PastTxs = () => { const router = useRouter(); @@ -107,7 +107,7 @@ const PastTxs = () => { }, [router.isReady]); return ( - + <> Past Transactions @@ -126,7 +126,7 @@ const PastTxs = () => { - { onPageSizeChange={onPageSizeChange} /> )} - + ); }; diff --git a/src/lib/pages/public-project/components/AllProject.tsx b/src/lib/pages/public-project/components/AllProject.tsx index db3d31405..94cfe9fc0 100644 --- a/src/lib/pages/public-project/components/AllProject.tsx +++ b/src/lib/pages/public-project/components/AllProject.tsx @@ -14,7 +14,7 @@ import { BsGithub } from "react-icons/bs"; import { TextInput } from "lib/components/forms"; import { Loading } from "lib/components/Loading"; -import { EmptyState } from "lib/components/state/EmptyState"; +import { EmptyState } from "lib/components/state"; import { usePublicProjectStore } from "lib/hooks"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import { usePublicProjects } from "lib/services/publicProjectService"; diff --git a/src/lib/pages/public-project/components/SocialMedia.tsx b/src/lib/pages/public-project/components/SocialMedia.tsx index 68bd9e354..def221f8b 100644 --- a/src/lib/pages/public-project/components/SocialMedia.tsx +++ b/src/lib/pages/public-project/components/SocialMedia.tsx @@ -8,7 +8,7 @@ import { } from "react-icons/fa"; import { MdLanguage } from "react-icons/md"; -import { IconButton } from "lib/components/button/IconButton"; +import { IconButton } from "lib/components/button"; import { AmpTrackSocial, AmpTrackWebsite } from "lib/services/amplitude"; import type { Option, PublicDetail } from "lib/types"; diff --git a/src/lib/pages/public-project/components/table/code/PublicProjectCodeRow.tsx b/src/lib/pages/public-project/components/table/code/PublicProjectCodeRow.tsx index c2158f02b..20dc0daaa 100644 --- a/src/lib/pages/public-project/components/table/code/PublicProjectCodeRow.tsx +++ b/src/lib/pages/public-project/components/table/code/PublicProjectCodeRow.tsx @@ -4,7 +4,7 @@ import { useWallet } from "@cosmos-kit/react"; import { useInternalNavigate } from "lib/app-provider"; import { InstantiateButton } from "lib/components/button"; import { ExplorerLink } from "lib/components/ExplorerLink"; -import { SaveOrRemoveCodeModal } from "lib/components/modal/code/SaveOrRemoveCode"; +import { SaveOrRemoveCodeModal } from "lib/components/modal"; import { PermissionChip } from "lib/components/PermissionChip"; import { TableRowNoBorder } from "lib/components/table"; import { getAddressTypeByLength } from "lib/hooks"; diff --git a/src/lib/pages/public-project/components/table/code/PublicProjectCodeTable.tsx b/src/lib/pages/public-project/components/table/code/PublicProjectCodeTable.tsx index 926225d74..b12077c65 100644 --- a/src/lib/pages/public-project/components/table/code/PublicProjectCodeTable.tsx +++ b/src/lib/pages/public-project/components/table/code/PublicProjectCodeTable.tsx @@ -1,13 +1,11 @@ -import { TableContainer, Flex, Grid, Box } from "@chakra-ui/react"; +import { TableContainer, Grid, Box } from "@chakra-ui/react"; import { matchSorter } from "match-sorter"; import { observer } from "mobx-react-lite"; import { useMemo, useState } from "react"; import { TextInput } from "lib/components/forms"; -import { EmptyState } from "lib/components/state/EmptyState"; -import { TableHeader } from "lib/components/table"; -import { TableTitle } from "lib/components/table/TableTitle"; -import { ViewMore } from "lib/components/table/ViewMore"; +import { EmptyState } from "lib/components/state"; +import { TableHeader, TableTitle, ViewMore } from "lib/components/table"; import { useCodeStore } from "lib/hooks"; import type { Option, PublicCode, CodeInfo } from "lib/types"; @@ -82,23 +80,15 @@ export const PublicProjectCodeTable = observer( /> )} {!publicCodes.length ? ( - - - + ) : ( diff --git a/src/lib/pages/public-project/components/table/contract/PublicProjectContractTable.tsx b/src/lib/pages/public-project/components/table/contract/PublicProjectContractTable.tsx index a0044620b..2b47846a0 100644 --- a/src/lib/pages/public-project/components/table/contract/PublicProjectContractTable.tsx +++ b/src/lib/pages/public-project/components/table/contract/PublicProjectContractTable.tsx @@ -1,13 +1,11 @@ -import { TableContainer, Flex, Grid, Box } from "@chakra-ui/react"; +import { TableContainer, Grid, Box } from "@chakra-ui/react"; import { matchSorter } from "match-sorter"; import { observer } from "mobx-react-lite"; import { useMemo, useState } from "react"; import { TextInput } from "lib/components/forms"; -import { EmptyState } from "lib/components/state/EmptyState"; -import { TableHeader } from "lib/components/table"; -import { TableTitle } from "lib/components/table/TableTitle"; -import { ViewMore } from "lib/components/table/ViewMore"; +import { EmptyState } from "lib/components/state"; +import { TableHeader, TableTitle, ViewMore } from "lib/components/table"; import { useContractStore } from "lib/hooks"; import type { ContractLocalInfo } from "lib/stores/contract"; import type { PublicContract, Option, ContractAddr } from "lib/types"; @@ -75,23 +73,15 @@ export const PublicProjectContractTable = observer( /> )} {!publicContracts.length ? ( - - - + ) : ( diff --git a/src/lib/providers/tx-broadcast.tsx b/src/lib/providers/tx-broadcast.tsx index 32d4919cb..440fe1565 100644 --- a/src/lib/providers/tx-broadcast.tsx +++ b/src/lib/providers/tx-broadcast.tsx @@ -9,7 +9,7 @@ import { } from "react"; import type { Observable } from "rxjs"; -import { TxModal } from "lib/components/modal"; +import { TxModal } from "lib/components/modal/tx"; import type { TxResultRendering } from "lib/types"; interface TxBroadcast { @@ -60,6 +60,4 @@ export const TxBroadcastProvider = ({ children }: { children: ReactNode }) => { ); }; -export const useTxBroadcast = () => { - return useContext(TxBroadcastContext); -}; +export const useTxBroadcast = () => useContext(TxBroadcastContext); diff --git a/src/lib/query/contract.ts b/src/lib/query/contract.ts index f29585271..4cfcc4605 100644 --- a/src/lib/query/contract.ts +++ b/src/lib/query/contract.ts @@ -73,46 +73,6 @@ export const getAdminByContractAddressesQueryDocument = graphql(` } `); -export const getExecuteTxsByContractAddressPagination = graphql(` - query getExecuteTxsByContractAddressPagination( - $contractAddress: String! - $offset: Int! - $pageSize: Int! - ) { - contract_transactions_view( - where: { - contract_address: { _eq: $contractAddress } - is_execute: { _eq: true } - } - order_by: { timestamp: desc } - limit: $pageSize - offset: $offset - ) { - hash - messages - success - sender - height - timestamp - } - } -`); - -export const getExecuteTxsCountByContractAddress = graphql(` - query getExecuteTxsCountByContractAddress($contractAddress: String!) { - contract_transactions_aggregate( - where: { - contract: { address: { _eq: $contractAddress } } - transaction: { is_execute: { _eq: true } } - } - ) { - aggregate { - count - } - } - } -`); - export const getContractListByAdmin = graphql(` query getContractListByAdmin($address: String!) { contracts( diff --git a/src/lib/query/tx.ts b/src/lib/query/tx.ts index 39f8741ef..e1b805604 100644 --- a/src/lib/query/tx.ts +++ b/src/lib/query/tx.ts @@ -1,5 +1,53 @@ import { graphql } from "lib/gql"; +export const getExecuteTxsByContractAddressPagination = graphql(` + query getExecuteTxsByContractAddressPagination( + $contractAddress: String! + $offset: Int! + $pageSize: Int! + ) { + contract_transactions_view( + where: { + contract_address: { _eq: $contractAddress } + is_execute: { _eq: true } + } + order_by: { timestamp: desc } + limit: $pageSize + offset: $offset + ) { + hash + messages + success + sender + height + timestamp + is_execute + is_ibc + is_instantiate + is_send + is_store_code + is_migrate + is_update_admin + is_clear_admin + } + } +`); + +export const getExecuteTxsCountByContractAddress = graphql(` + query getExecuteTxsCountByContractAddress($contractAddress: String!) { + contract_transactions_aggregate( + where: { + contract: { address: { _eq: $contractAddress } } + transaction: { is_execute: { _eq: true } } + } + ) { + aggregate { + count + } + } + } +`); + export const getTxsByContractAddressPagination = graphql(` query getTxsByContractAddress( $contractAddress: String! diff --git a/src/lib/services/contractService.ts b/src/lib/services/contractService.ts index c3c646ead..0c5715132 100644 --- a/src/lib/services/contractService.ts +++ b/src/lib/services/contractService.ts @@ -11,8 +11,6 @@ import { getContractListByWalletAddressPagination, getContractListCountByAdmin, getContractListCountByCodeId, - getExecuteTxsByContractAddressPagination, - getExecuteTxsCountByContractAddress, getInstantiatedCountByUserQueryDocument, getInstantiateDetailByContractQueryDocument, getInstantiatedListByUserQueryDocument, @@ -23,19 +21,13 @@ import type { ContractLocalInfo } from "lib/stores/contract"; import type { ContractAddr, ContractMigrationHistory, - ExecuteTransaction, HumanAddr, Option, Dict, Addr, ContractInfo, } from "lib/types"; -import { - parseDate, - parseTxHash, - parseTxHashOpt, - parseDateOpt, -} from "lib/utils"; +import { parseDate, parseTxHashOpt, parseDateOpt } from "lib/utils"; interface InstantiateDetail { initMsg: Option; @@ -195,86 +187,6 @@ export const useAdminByContractAddresses = ( ); }; -export const useExecuteTxsByContractAddressPagination = ( - contractAddress: ContractAddr, - offset: number, - pageSize: number -): UseQueryResult => { - const { indexerGraphClient } = useCelatoneApp(); - - const queryFn = useCallback(async () => { - return indexerGraphClient - .request(getExecuteTxsByContractAddressPagination, { - contractAddress, - offset, - pageSize, - }) - .then(({ contract_transactions_view }) => - /** - * @remarks because contract_transactions_view is view table, all fields can be undefined by type - */ - contract_transactions_view.map((transaction) => ({ - hash: parseTxHash(transaction.hash), - messages: transaction.messages, - sender: transaction.sender as Addr, - height: transaction.height, - created: parseDateOpt(transaction.timestamp), - success: transaction.success, - })) - ); - }, [contractAddress, offset, pageSize, indexerGraphClient]); - - return useQuery( - [ - "execute_transactions_by_contract_addr_pagination", - contractAddress, - offset, - pageSize, - indexerGraphClient, - ], - queryFn, - { - keepPreviousData: true, - enabled: !!contractAddress, - } - ); -}; - -export const useExecuteTxsCountByContractAddress = ( - contractAddress: ContractAddr -): UseQueryResult> => { - const { indexerGraphClient } = useCelatoneApp(); - - const queryFn = useCallback(async () => { - if (!contractAddress) - throw new Error( - "Contract address not found (useExecuteTxsCountByContractAddress)" - ); - - return indexerGraphClient - .request(getExecuteTxsCountByContractAddress, { - contractAddress, - }) - .then( - ({ contract_transactions_aggregate }) => - contract_transactions_aggregate?.aggregate?.count - ); - }, [contractAddress, indexerGraphClient]); - - return useQuery( - [ - "execute_transactions_count_by_contract_addr", - contractAddress, - indexerGraphClient, - ], - queryFn, - { - keepPreviousData: true, - enabled: !!contractAddress, - } - ); -}; - export const useMigrationHistoriesByContractAddressPagination = ( contractAddress: ContractAddr, offset: number, diff --git a/src/lib/pages/past-txs/query/generateWhere.ts b/src/lib/services/txQuery/generateWhere.ts similarity index 86% rename from src/lib/pages/past-txs/query/generateWhere.ts rename to src/lib/services/txQuery/generateWhere.ts index 6ea0305e6..c8016a6f7 100644 --- a/src/lib/pages/past-txs/query/generateWhere.ts +++ b/src/lib/services/txQuery/generateWhere.ts @@ -1,4 +1,4 @@ -import type { Filters, HumanAddr, ContractAddr } from "lib/types"; +import type { TxFilters, HumanAddr, ContractAddr } from "lib/types"; const actions = { isExecute: "is_execute", @@ -19,10 +19,10 @@ const actions = { * is_send: {_eq: true}, is_execute: {_eq: true} * */ -export const generateActionsFilter = (filters: Filters) => { +export const generateActionsFilter = (filters: TxFilters) => { return Object.keys(filters).reduce((acc: string, key: string) => { if (filters[key as keyof typeof filters]) { - return `${acc} ${actions[key as keyof Filters]}: {_eq: true },`; + return `${acc} ${actions[key as keyof TxFilters]}: {_eq: true },`; } return acc; }, ""); @@ -36,13 +36,13 @@ export const generateActionsFilter = (filters: Filters) => { const generateActionsFilterDefault = () => { return `${Object.keys(actions).reduce((acc: string, key: string) => { if (key !== "isIbc") { - return `${acc} {${actions[key as keyof Filters]}: {_eq: true }},`; + return `${acc} {${actions[key as keyof TxFilters]}: {_eq: true }},`; } return acc; }, "_or: [")}]`; }; -const chooseActionFilter = (filters: Filters) => { +const chooseActionFilter = (filters: TxFilters) => { if (Object.values(filters).every((value) => !value)) { return generateActionsFilterDefault(); } @@ -51,7 +51,7 @@ const chooseActionFilter = (filters: Filters) => { interface GenerateWhereForContractTx { userAddress: HumanAddr; contractAddress: ContractAddr; - filters: Filters; + filters: TxFilters; } /** @@ -94,7 +94,7 @@ export const generateWhereForContractTxView = ({ interface GenerateWhereForTx { userAddress: HumanAddr; txHash?: string; - filters: Filters; + filters: TxFilters; } /** diff --git a/src/lib/pages/past-txs/query/graphqlQuery.ts b/src/lib/services/txQuery/graphqlQuery.ts similarity index 96% rename from src/lib/pages/past-txs/query/graphqlQuery.ts rename to src/lib/services/txQuery/graphqlQuery.ts index 9cb930e0f..44cce648d 100644 --- a/src/lib/pages/past-txs/query/graphqlQuery.ts +++ b/src/lib/services/txQuery/graphqlQuery.ts @@ -10,6 +10,8 @@ export const queryTransactionsFromTxs = (where: string) => { order_by: {block: {timestamp: desc}} ) { hash + sender + block_height is_send is_execute is_ibc @@ -52,7 +54,9 @@ export const queryTransactionFromContractTxs = (where: string) => { order_by: { timestamp: desc } ) { hash + sender is_send + height is_execute is_ibc is_instantiate diff --git a/src/lib/pages/past-txs/query/useTxQuery.ts b/src/lib/services/txQuery/useTxQuery.ts similarity index 93% rename from src/lib/pages/past-txs/query/useTxQuery.ts rename to src/lib/services/txQuery/useTxQuery.ts index 30bbf4a69..c161bd3bb 100644 --- a/src/lib/pages/past-txs/query/useTxQuery.ts +++ b/src/lib/services/txQuery/useTxQuery.ts @@ -5,16 +5,16 @@ import { useCallback } from "react"; import { useCelatoneApp } from "lib/app-provider"; import { useGetAddressType } from "lib/hooks"; import type { - Filters, + TxFilters, Message, Option, - PastTransaction, HumanAddr, ContractAddr, + Transaction, + Addr, } from "lib/types"; import { getActionMsgType, - parseDateDefault, parseTxHash, snakeToCamel, getMsgFurtherAction, @@ -35,6 +35,7 @@ import { interface GraphqlTransactionsResponse { hash: string; + sender: Addr; isSend: boolean; isExecute: boolean; isIbc: boolean; @@ -45,6 +46,7 @@ interface GraphqlTransactionsResponse { isUpdateAdmin: boolean; messages: Message[]; success: boolean; + blockHeight: number; block: { timestamp: string; }; @@ -52,6 +54,7 @@ interface GraphqlTransactionsResponse { interface GraphqlTransactionsViewResponse { hash: string; + sender: Addr; isSend: boolean; isExecute: boolean; isIbc: boolean; @@ -62,13 +65,14 @@ interface GraphqlTransactionsViewResponse { isUpdateAdmin: boolean; messages: Message[]; success: boolean; + height: number; timestamp: string; } export const useTxQuery = ( userAddress: Option, search: string, - filters: Filters, + filters: TxFilters, pageSize: number, offset: number ) => { @@ -96,9 +100,11 @@ export const useTxQuery = ( contract_transactions_view ) as GraphqlTransactionsViewResponse[]; return contractTransactionsToCamel.map( - (contractTx): PastTransaction => ({ + (contractTx): Transaction => ({ hash: parseTxHash(contractTx.hash), messages: snakeToCamel(contractTx.messages) as Message[], + sender: contractTx.sender, + height: contractTx.height, created: parseDateOpt(contractTx.timestamp), success: contractTx.success, actionMsgType: getActionMsgType([ @@ -145,12 +151,13 @@ export const useTxQuery = ( const transactionsToCamel = snakeToCamel( transactions ) as GraphqlTransactionsResponse[]; - return transactionsToCamel.map((transaction): PastTransaction => { + return transactionsToCamel.map((transaction): Transaction => { return { hash: parseTxHash(transaction.hash), messages: snakeToCamel(transaction.messages) as Message[], - // TODO - Remove default case - created: parseDateDefault(transaction.block?.timestamp), + sender: transaction.sender, + height: transaction.blockHeight, + created: parseDateOpt(transaction.block?.timestamp), success: transaction.success, actionMsgType: getActionMsgType([ transaction.isExecute, @@ -207,7 +214,7 @@ export const useTxQuery = ( export const useTxQueryCount = ( userAddress: Option, search: string, - filters: Filters + filters: TxFilters ): UseQueryResult => { const getAddressType = useGetAddressType(); const { indexerGraphClient } = useCelatoneApp(); diff --git a/src/lib/services/txService.ts b/src/lib/services/txService.ts index c04c906ea..10c99f633 100644 --- a/src/lib/services/txService.ts +++ b/src/lib/services/txService.ts @@ -4,10 +4,13 @@ import { useCallback } from "react"; import { useCelatoneApp } from "lib/app-provider"; import { + getExecuteTxsByContractAddressPagination, + getExecuteTxsCountByContractAddress, getTxsByContractAddressPagination, getTxsCountByContractAddress, } from "lib/query"; -import type { Addr, AllTransaction, ContractAddr, Option } from "lib/types"; +import { MsgFurtherAction } from "lib/types"; +import type { Addr, ContractAddr, Option, Transaction } from "lib/types"; import { getActionMsgType, parseDateOpt, @@ -16,11 +19,104 @@ import { unwrapAll, } from "lib/utils"; +export const useExecuteTxsByContractAddressPagination = ( + contractAddress: ContractAddr, + offset: number, + pageSize: number +): UseQueryResult => { + const { indexerGraphClient } = useCelatoneApp(); + + const queryFn = useCallback(async () => { + return indexerGraphClient + .request(getExecuteTxsByContractAddressPagination, { + contractAddress, + offset, + pageSize, + }) + .then(({ contract_transactions_view }) => + /** + * @remarks because contract_transactions_view is view table, all fields can be undefined by type + */ + contract_transactions_view.map((transaction) => ({ + hash: parseTxHash(transaction.hash), + messages: snakeToCamel(transaction.messages), + sender: transaction.sender as Addr, + height: transaction.height, + created: parseDateOpt(transaction.timestamp), + success: transaction.success, + actionMsgType: getActionMsgType([ + /* these value must not be null */ + unwrapAll(transaction.is_execute), + unwrapAll(transaction.is_instantiate), + unwrapAll(transaction.is_send), + unwrapAll(transaction.is_store_code), + unwrapAll(transaction.is_migrate), + unwrapAll(transaction.is_update_admin), + unwrapAll(transaction.is_clear_admin), + ]), + furtherAction: MsgFurtherAction.NONE, + isIbc: transaction.is_ibc, + isInstantiate: transaction.is_instantiate, + })) + ); + }, [contractAddress, offset, pageSize, indexerGraphClient]); + + return useQuery( + [ + "execute_transactions_by_contract_addr_pagination", + contractAddress, + offset, + pageSize, + indexerGraphClient, + ], + queryFn, + { + keepPreviousData: true, + enabled: !!contractAddress, + } + ); +}; + +export const useExecuteTxsCountByContractAddress = ( + contractAddress: ContractAddr +): UseQueryResult> => { + const { indexerGraphClient } = useCelatoneApp(); + + const queryFn = useCallback(async () => { + if (!contractAddress) + throw new Error( + "Contract address not found (useExecuteTxsCountByContractAddress)" + ); + + return indexerGraphClient + .request(getExecuteTxsCountByContractAddress, { + contractAddress, + }) + .then( + ({ contract_transactions_aggregate }) => + contract_transactions_aggregate?.aggregate?.count + ); + }, [contractAddress, indexerGraphClient]); + + return useQuery( + [ + "execute_transactions_count_by_contract_addr", + contractAddress, + indexerGraphClient, + ], + queryFn, + { + keepPreviousData: true, + enabled: !!contractAddress, + } + ); +}; + export const useTxsByContractAddressPagination = ( contractAddress: ContractAddr, offset: number, pageSize: number -): UseQueryResult => { +): UseQueryResult => { const { indexerGraphClient } = useCelatoneApp(); const queryFn = useCallback(async () => { @@ -51,7 +147,9 @@ export const useTxsByContractAddressPagination = ( unwrapAll(contractTx.is_update_admin), unwrapAll(contractTx.is_clear_admin), ]), + furtherAction: MsgFurtherAction.NONE, isIbc: contractTx.is_ibc, + isInstantiate: contractTx.is_instantiate, })) ); }, [contractAddress, offset, pageSize, indexerGraphClient]); diff --git a/src/lib/types/tx/msg.ts b/src/lib/types/tx/msg.ts index ec4c3f46a..252dfbc64 100644 --- a/src/lib/types/tx/msg.ts +++ b/src/lib/types/tx/msg.ts @@ -104,14 +104,3 @@ export interface DetailMigrate { msg: object; sender: Addr; } - -export interface TxFilters { - isExecute: boolean; - isInstantiate: boolean; - isUpload: boolean; - isIbc: boolean; - isSend: boolean; - isMigrate: boolean; - isUpdateAdmin: boolean; - isClearAdmin: boolean; -} diff --git a/src/lib/types/tx/transaction.ts b/src/lib/types/tx/transaction.ts index 8e4642b15..0b0bd5b9a 100644 --- a/src/lib/types/tx/transaction.ts +++ b/src/lib/types/tx/transaction.ts @@ -22,17 +22,6 @@ export enum MsgFurtherAction { NONE = "NONE", } -export interface PastTransaction { - hash: string; - messages: Message[]; - created: Option; - success: boolean; - actionMsgType: ActionMsgType; - furtherAction: MsgFurtherAction; - isIbc: boolean; - isInstantiate: boolean; -} - export interface Message { detail: | DetailExecute @@ -57,21 +46,20 @@ export interface Msg { contract: string; } -export interface ExecuteTransaction { +export interface Transaction { hash: string; messages: Message[]; sender: Addr; height: number; created: Option; success: boolean; -} - -export interface AllTransaction extends ExecuteTransaction { actionMsgType: ActionMsgType; + furtherAction: MsgFurtherAction; isIbc: boolean; + isInstantiate: boolean; } -export interface Filters { +export interface TxFilters { isExecute: boolean; isInstantiate: boolean; isUpload: boolean; diff --git a/src/lib/utils/msgFurtherAction.ts b/src/lib/utils/msgFurtherAction.ts index 14c201fe5..1a67b9e5f 100644 --- a/src/lib/utils/msgFurtherAction.ts +++ b/src/lib/utils/msgFurtherAction.ts @@ -1,9 +1,9 @@ -import type { Filters } from "lib/types"; +import type { TxFilters } from "lib/types"; import { MsgFurtherAction } from "lib/types"; export const getMsgFurtherAction = ( length: number, - filters: Filters, + filters: TxFilters, isSuccess: boolean ) => { // Redo: instantiate, execute, check length === 1 From 8618a39672789b72a8bc15b77cfc4407dd8639e2 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Tue, 28 Feb 2023 01:44:49 +0700 Subject: [PATCH 2/9] fix: rename and remove debug --- ...esTableReadOnly.tsx => CodesReadOnlyTable.tsx} | 15 +++++++++------ .../modal/select-code/MySavedCodeContent.tsx | 4 ++-- .../modal/select-code/MyStoredCodeContent.tsx | 4 ++-- src/lib/components/table/EditableCell.tsx | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) rename src/lib/components/modal/select-code/{CodesTableReadOnly.tsx => CodesReadOnlyTable.tsx} (86%) diff --git a/src/lib/components/modal/select-code/CodesTableReadOnly.tsx b/src/lib/components/modal/select-code/CodesReadOnlyTable.tsx similarity index 86% rename from src/lib/components/modal/select-code/CodesTableReadOnly.tsx rename to src/lib/components/modal/select-code/CodesReadOnlyTable.tsx index d1de6b723..7f2517fd1 100644 --- a/src/lib/components/modal/select-code/CodesTableReadOnly.tsx +++ b/src/lib/components/modal/select-code/CodesReadOnlyTable.tsx @@ -6,12 +6,15 @@ import type { CodeInfo } from "lib/types"; const TEMPLATE_COLUMNS = "48px 1fr 4fr 1fr 2fr 48px"; -interface CodesTableRowProps { +interface CodesReadOnlyTableRowProps { codeInfo: CodeInfo; onCodeSelect: (newVal: string) => void; } -const CodesTableRow = ({ codeInfo, onCodeSelect }: CodesTableRowProps) => ( +const CodesReadOnlyTableRow = ({ + codeInfo, + onCodeSelect, +}: CodesReadOnlyTableRowProps) => ( ( ); -interface CodesTableReadOnlyProps { +interface CodesReadOnlyTableProps { onCodeSelect: (code: string) => void; codes: CodeInfo[]; } -export const CodesTableReadOnly = ({ +export const CodesReadOnlyTable = ({ onCodeSelect, codes, -}: CodesTableReadOnlyProps) => ( +}: CodesReadOnlyTableProps) => ( @@ -60,7 +63,7 @@ export const CodesTableReadOnly = ({ {codes.map((code, index) => ( - void; @@ -18,5 +18,5 @@ export const MySavedCodeContent = ({ withBorder /> ) : ( - + ); diff --git a/src/lib/components/modal/select-code/MyStoredCodeContent.tsx b/src/lib/components/modal/select-code/MyStoredCodeContent.tsx index b433f60ce..7077b4e6e 100644 --- a/src/lib/components/modal/select-code/MyStoredCodeContent.tsx +++ b/src/lib/components/modal/select-code/MyStoredCodeContent.tsx @@ -5,7 +5,7 @@ import { ConnectWalletBtn } from "lib/components/button"; import { EmptyState } from "lib/components/state"; import type { CodeInfo } from "lib/types"; -import { CodesTableReadOnly } from "./CodesTableReadOnly"; +import { CodesReadOnlyTable } from "./CodesReadOnlyTable"; interface MyStoredCodeContentProps { handleSelect: (code: string) => void; @@ -38,5 +38,5 @@ export const MyStoredCodeContent = ({ if (!storedCodes.length) { return ; } - return ; + return ; }; diff --git a/src/lib/components/table/EditableCell.tsx b/src/lib/components/table/EditableCell.tsx index 163028f2d..5777629fa 100644 --- a/src/lib/components/table/EditableCell.tsx +++ b/src/lib/components/table/EditableCell.tsx @@ -106,7 +106,7 @@ export const EditableCell = ({ e.stopPropagation(); setIsEditCellOpen(false); }} - zIndex={10000} + zIndex={1} /> )} Date: Tue, 28 Feb 2023 13:09:49 +0700 Subject: [PATCH 3/9] fix: decyclic and restructure --- src/lib/app-provider/contexts/app.tsx | 2 +- src/lib/app-provider/hooks/index.ts | 17 ++++++---- .../{ => app-provider}/hooks/useAddress.ts | 0 .../{ => app-provider}/hooks/useChainId.ts | 0 .../hooks/useDummyWallet.ts | 0 .../hooks/useLCDEndpoint.ts | 0 .../{ => app-provider}/hooks/useMediaQuery.ts | 0 src/lib/app-provider/queries/simulateFee.ts | 2 +- src/lib/components/ContractSelectSection.tsx | 6 ++-- .../components/{forms => }/ListSelection.tsx | 6 ++-- src/lib/components/MobileGuard.tsx | 2 +- src/lib/components/OffChainForm.tsx | 10 +++--- .../components/{forms => }/TagSelection.tsx | 3 +- src/lib/components/button/RedoButton.tsx | 2 +- src/lib/components/forms/TextAreaInput.tsx | 1 + src/lib/components/forms/index.ts | 11 +++--- src/lib/components/modal/CodeSnippet.tsx | 2 +- src/lib/components/modal/RedoModal.tsx | 2 +- .../modal/UnsupportedTokensModal.tsx | 4 +-- .../modal/code/CodeDetailsTemplate.tsx | 3 +- src/lib/components/modal/code/RemoveCode.tsx | 4 +-- src/lib/components/modal/code/SaveNewCode.tsx | 3 +- .../modal/contract/AddToOtherList.tsx | 2 +- .../modal/contract/SaveNewContract.tsx | 14 ++++---- src/lib/components/modal/index.ts | 4 +-- .../components/modal/list/CreateNewList.tsx | 7 ++-- .../components/modal/list/EditListName.tsx | 3 +- src/lib/components/modal/list/RemoveList.tsx | 5 +-- .../{modal => }/select-code/CodeSelect.tsx | 4 +-- .../select-code/CodeSelectModalButton.tsx | 0 .../select-code/CodeSelectSection.tsx | 0 .../select-code/CodesReadOnlyTable.tsx | 0 .../select-code/MySavedCodeContent.tsx | 0 .../select-code/MyStoredCodeContent.tsx | 0 .../{modal => }/select-code/index.ts | 0 .../select-contract/AllContractLists.tsx | 0 .../select-contract/ContractListCard.tsx | 2 +- .../select-contract/ContractListDetail.tsx | 3 +- .../ContractListReadOnlyTable.tsx | 0 .../select-contract/ContractListTable.tsx | 0 .../select-contract/SelectContractAdmin.tsx | 2 +- .../SelectContractInstantiator.tsx | 8 ++--- .../{modal => }/select-contract/index.ts | 0 .../components/table/codes/CodeNameCell.tsx | 2 +- .../{modal => table/contracts}/EditTags.tsx | 6 ++-- .../components/table/contracts/TagsCell.tsx | 3 +- .../index.tsx => TxReceiptRender.tsx} | 34 ++++++++----------- src/lib/components/tx/index.ts | 2 ++ .../{modal/tx => tx/modal}/ButtonSection.tsx | 0 .../{modal/tx => tx/modal}/index.tsx | 2 +- src/lib/components/upload/UploadSection.tsx | 2 +- src/lib/hooks/index.ts | 13 ++++--- src/lib/hooks/store.ts | 16 --------- .../hooks/useExecuteCmds.ts | 3 +- src/lib/hooks/useHandleSave.tsx | 2 +- .../{app-provider => }/hooks/useQueryCmds.ts | 2 +- src/lib/{pages/past-txs => }/hooks/useRedo.ts | 0 src/lib/hooks/useSingleMessageProps.ts | 3 +- src/lib/layout/Searchbar.tsx | 3 +- src/lib/layout/index.tsx | 2 +- src/lib/layout/navbar/Collapse.tsx | 2 +- src/lib/layout/navbar/index.tsx | 2 +- src/lib/model/code.ts | 3 +- src/lib/model/contract.ts | 9 ++--- .../components/asset/index.tsx | 2 +- .../components/tables/StoredCodesTable.tsx | 4 +-- src/lib/pages/account-details/data.ts | 4 +-- src/lib/pages/account-details/index.tsx | 2 +- src/lib/pages/admin/index.tsx | 8 ++--- .../code-details/components/CTASection.tsx | 2 +- .../components/table/CodeContractsTable.tsx | 2 +- src/lib/pages/code-details/index.tsx | 2 +- src/lib/pages/codes/data.ts | 8 ++--- src/lib/pages/codes/index.tsx | 2 +- .../components/token/TokenSection.tsx | 2 +- src/lib/pages/contract-details/index.tsx | 2 +- src/lib/pages/contract-details/model/data.ts | 2 +- src/lib/pages/contract-list/index.tsx | 5 ++- .../pages/execute/components/ExecuteArea.tsx | 2 +- .../home/components/RecentActivities.tsx | 3 +- src/lib/pages/instantiate/completed.tsx | 2 +- .../component/InstantiateOffchainForm.tsx | 4 +-- src/lib/pages/instantiate/instantiate.tsx | 5 +-- .../migrate/components/MigrateContract.tsx | 9 +++-- src/lib/pages/migrate/index.tsx | 7 ++-- .../components/FurtherActionButton.tsx | 2 +- .../public-project/components/AllProject.tsx | 2 +- .../components/BookmarkButton.tsx | 2 +- .../table/code/PublicProjectCodeTable.tsx | 2 +- .../contract/PublicProjectContractTable.tsx | 2 +- src/lib/pages/query/components/QueryArea.tsx | 4 ++- src/lib/pages/query/index.tsx | 3 +- src/lib/pages/recent-codes/data.ts | 3 +- src/lib/pages/recent-codes/index.tsx | 2 +- src/lib/providers/store.tsx | 17 +++++++++- src/lib/providers/tx-broadcast.tsx | 2 +- 96 files changed, 185 insertions(+), 180 deletions(-) rename src/lib/{ => app-provider}/hooks/useAddress.ts (100%) rename src/lib/{ => app-provider}/hooks/useChainId.ts (100%) rename src/lib/{ => app-provider}/hooks/useDummyWallet.ts (100%) rename src/lib/{ => app-provider}/hooks/useLCDEndpoint.ts (100%) rename src/lib/{ => app-provider}/hooks/useMediaQuery.ts (100%) rename src/lib/components/{forms => }/ListSelection.tsx (97%) rename src/lib/components/{forms => }/TagSelection.tsx (98%) rename src/lib/components/{modal => }/select-code/CodeSelect.tsx (95%) rename src/lib/components/{modal => }/select-code/CodeSelectModalButton.tsx (100%) rename src/lib/components/{modal => }/select-code/CodeSelectSection.tsx (100%) rename src/lib/components/{modal => }/select-code/CodesReadOnlyTable.tsx (100%) rename src/lib/components/{modal => }/select-code/MySavedCodeContent.tsx (100%) rename src/lib/components/{modal => }/select-code/MyStoredCodeContent.tsx (100%) rename src/lib/components/{modal => }/select-code/index.ts (100%) rename src/lib/components/{modal => }/select-contract/AllContractLists.tsx (100%) rename src/lib/components/{modal => }/select-contract/ContractListCard.tsx (97%) rename src/lib/components/{modal => }/select-contract/ContractListDetail.tsx (97%) rename src/lib/components/{modal => }/select-contract/ContractListReadOnlyTable.tsx (100%) rename src/lib/components/{modal => }/select-contract/ContractListTable.tsx (100%) rename src/lib/components/{modal => }/select-contract/SelectContractAdmin.tsx (98%) rename src/lib/components/{modal => }/select-contract/SelectContractInstantiator.tsx (98%) rename src/lib/components/{modal => }/select-contract/index.ts (100%) rename src/lib/components/{modal => table/contracts}/EditTags.tsx (92%) rename src/lib/components/tx/{receipt/index.tsx => TxReceiptRender.tsx} (56%) create mode 100644 src/lib/components/tx/index.ts rename src/lib/components/{modal/tx => tx/modal}/ButtonSection.tsx (100%) rename src/lib/components/{modal/tx => tx/modal}/index.tsx (96%) delete mode 100644 src/lib/hooks/store.ts rename src/lib/{app-provider => }/hooks/useExecuteCmds.ts (92%) rename src/lib/{app-provider => }/hooks/useQueryCmds.ts (95%) rename src/lib/{pages/past-txs => }/hooks/useRedo.ts (100%) diff --git a/src/lib/app-provider/contexts/app.tsx b/src/lib/app-provider/contexts/app.tsx index 4e3a59f3f..c10e52a01 100644 --- a/src/lib/app-provider/contexts/app.tsx +++ b/src/lib/app-provider/contexts/app.tsx @@ -15,7 +15,7 @@ import { useCodeStore, useContractStore, usePublicProjectStore, -} from "lib/hooks"; +} from "lib/providers/store"; import type { ChainGasPrice, Token, U } from "lib/types"; import { formatUserKey } from "lib/utils"; diff --git a/src/lib/app-provider/hooks/index.ts b/src/lib/app-provider/hooks/index.ts index 9197bc17e..4219f011d 100644 --- a/src/lib/app-provider/hooks/index.ts +++ b/src/lib/app-provider/hooks/index.ts @@ -1,11 +1,14 @@ -export * from "./useFabricateFee"; -export * from "./useSimulateFee"; -export * from "./useRestrictedInput"; +export * from "./useAddress"; +export * from "./useAmplitude"; export * from "./useCelatoneApp"; -export * from "./useQueryCmds"; -export * from "./useExecuteCmds"; -export * from "./useTokensInfo"; +export * from "./useChainId"; +export * from "./useDummyWallet"; +export * from "./useFabricateFee"; export * from "./useInternalNavigate"; +export * from "./useLCDEndpoint"; +export * from "./useMediaQuery"; export * from "./useNetworkChange"; -export * from "./useAmplitude"; +export * from "./useRestrictedInput"; export * from "./useSelectChain"; +export * from "./useSimulateFee"; +export * from "./useTokensInfo"; diff --git a/src/lib/hooks/useAddress.ts b/src/lib/app-provider/hooks/useAddress.ts similarity index 100% rename from src/lib/hooks/useAddress.ts rename to src/lib/app-provider/hooks/useAddress.ts diff --git a/src/lib/hooks/useChainId.ts b/src/lib/app-provider/hooks/useChainId.ts similarity index 100% rename from src/lib/hooks/useChainId.ts rename to src/lib/app-provider/hooks/useChainId.ts diff --git a/src/lib/hooks/useDummyWallet.ts b/src/lib/app-provider/hooks/useDummyWallet.ts similarity index 100% rename from src/lib/hooks/useDummyWallet.ts rename to src/lib/app-provider/hooks/useDummyWallet.ts diff --git a/src/lib/hooks/useLCDEndpoint.ts b/src/lib/app-provider/hooks/useLCDEndpoint.ts similarity index 100% rename from src/lib/hooks/useLCDEndpoint.ts rename to src/lib/app-provider/hooks/useLCDEndpoint.ts diff --git a/src/lib/hooks/useMediaQuery.ts b/src/lib/app-provider/hooks/useMediaQuery.ts similarity index 100% rename from src/lib/hooks/useMediaQuery.ts rename to src/lib/app-provider/hooks/useMediaQuery.ts diff --git a/src/lib/app-provider/queries/simulateFee.ts b/src/lib/app-provider/queries/simulateFee.ts index 920cfa5fc..a7980b551 100644 --- a/src/lib/app-provider/queries/simulateFee.ts +++ b/src/lib/app-provider/queries/simulateFee.ts @@ -2,7 +2,7 @@ import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate"; import { useWallet } from "@cosmos-kit/react"; import { useQuery } from "@tanstack/react-query"; -import { useDummyWallet } from "lib/hooks"; +import { useDummyWallet } from "../hooks"; import type { ComposedMsg, Gas } from "lib/types"; interface SimulateQueryParams { diff --git a/src/lib/components/ContractSelectSection.tsx b/src/lib/components/ContractSelectSection.tsx index f3661620b..a2028fc79 100644 --- a/src/lib/components/ContractSelectSection.tsx +++ b/src/lib/components/ContractSelectSection.tsx @@ -5,8 +5,8 @@ import { useEffect, useMemo } from "react"; import { useForm } from "react-hook-form"; import { MdMode, MdOutlineBookmarkBorder } from "react-icons/md"; -import { useCelatoneApp } from "lib/app-provider"; -import { useContractStore, useLCDEndpoint, useMobile } from "lib/hooks"; +import { useCelatoneApp, useLCDEndpoint, useMobile } from "lib/app-provider"; +import { useContractStore } from "lib/providers/store"; import { queryInstantiateInfo } from "lib/services/contract"; import type { ContractLocalInfo } from "lib/stores/contract"; import type { Addr, ContractAddr, Option } from "lib/types"; @@ -16,7 +16,7 @@ import { EditContractDetailsModal, SaveContractDetailsModal } from "./modal"; import { SelectContractAdmin, SelectContractInstantiator, -} from "./modal/select-contract"; +} from "./select-contract"; interface DisplayNameProps { notSelected: boolean; diff --git a/src/lib/components/forms/ListSelection.tsx b/src/lib/components/ListSelection.tsx similarity index 97% rename from src/lib/components/forms/ListSelection.tsx rename to src/lib/components/ListSelection.tsx index 0de9ce4bc..55cacf6a1 100644 --- a/src/lib/components/forms/ListSelection.tsx +++ b/src/lib/components/ListSelection.tsx @@ -18,11 +18,13 @@ import type { CSSProperties } from "react"; import { useState, useRef, forwardRef } from "react"; import { MdCheck, MdClose, MdAdd } from "react-icons/md"; -import { CreateNewListModal } from "lib/components/modal/list"; -import { useContractStore, useUserKey } from "lib/hooks"; +import { useUserKey } from "lib/hooks"; +import { useContractStore } from "lib/providers/store"; import type { LVPair } from "lib/types"; import { formatSlugName, mergeRefs } from "lib/utils"; +import { CreateNewListModal } from "./modal/list/CreateNewList"; + export interface ListSelectionProps extends InputProps { placeholder?: string; result: LVPair[]; diff --git a/src/lib/components/MobileGuard.tsx b/src/lib/components/MobileGuard.tsx index cf189454f..344085f78 100644 --- a/src/lib/components/MobileGuard.tsx +++ b/src/lib/components/MobileGuard.tsx @@ -1,6 +1,6 @@ import type { ReactNode } from "react"; -import { useMobile } from "lib/hooks"; +import { useMobile } from "lib/app-provider"; import { NoMobile } from "./modal"; diff --git a/src/lib/components/OffChainForm.tsx b/src/lib/components/OffChainForm.tsx index 7a58a69d4..dc301e854 100644 --- a/src/lib/components/OffChainForm.tsx +++ b/src/lib/components/OffChainForm.tsx @@ -1,12 +1,6 @@ import { VStack } from "@chakra-ui/react"; import type { Control, FieldErrorsImpl, FieldPath } from "react-hook-form"; -import { - ControllerInput, - ListSelection, - TagSelection, - ControllerTextarea, -} from "lib/components/forms"; import { getMaxContractDescriptionLengthError, getMaxContractNameLengthError, @@ -15,6 +9,10 @@ import { } from "lib/data"; import type { LVPair } from "lib/types"; +import { ControllerInput, ControllerTextarea } from "./forms"; +import { ListSelection } from "./ListSelection"; +import { TagSelection } from "./TagSelection"; + export interface OffchainDetail { name: string; description: string; diff --git a/src/lib/components/forms/TagSelection.tsx b/src/lib/components/TagSelection.tsx similarity index 98% rename from src/lib/components/forms/TagSelection.tsx rename to src/lib/components/TagSelection.tsx index f3c6b9147..926ff6a80 100644 --- a/src/lib/components/forms/TagSelection.tsx +++ b/src/lib/components/TagSelection.tsx @@ -19,7 +19,8 @@ import type { CSSProperties, KeyboardEvent } from "react"; import { useEffect, useState, useRef, forwardRef } from "react"; import { MdCheckCircle, MdClose } from "react-icons/md"; -import { useContractStore, useUserKey } from "lib/hooks"; +import { useUserKey } from "lib/hooks"; +import { useContractStore } from "lib/providers/store"; import { mergeRefs } from "lib/utils"; export interface TagSelectionProps extends InputProps { diff --git a/src/lib/components/button/RedoButton.tsx b/src/lib/components/button/RedoButton.tsx index 2d1adf455..04e964ed2 100644 --- a/src/lib/components/button/RedoButton.tsx +++ b/src/lib/components/button/RedoButton.tsx @@ -2,7 +2,7 @@ import { Button } from "@chakra-ui/react"; import { useWallet } from "@cosmos-kit/react"; import { BsArrowCounterclockwise } from "react-icons/bs"; -import { useRedo } from "lib/pages/past-txs/hooks/useRedo"; +import { useRedo } from "lib/hooks/useRedo"; import type { Message } from "lib/types"; import { extractMsgType } from "lib/utils"; diff --git a/src/lib/components/forms/TextAreaInput.tsx b/src/lib/components/forms/TextAreaInput.tsx index 07b7a7d76..534246cb4 100644 --- a/src/lib/components/forms/TextAreaInput.tsx +++ b/src/lib/components/forms/TextAreaInput.tsx @@ -12,6 +12,7 @@ import type { Dispatch, SetStateAction } from "react"; import type { FormStatus } from "./FormStatus"; import { getResponseMsg } from "./FormStatus"; +// TODO: remove export interface TextAreaProps extends FormControlProps { value: string; setInputState: Dispatch> | ((newVal: string) => void); diff --git a/src/lib/components/forms/index.ts b/src/lib/components/forms/index.ts index be6d99c4b..d062c5b7e 100644 --- a/src/lib/components/forms/index.ts +++ b/src/lib/components/forms/index.ts @@ -1,10 +1,9 @@ +export * from "./AssetInput"; +export * from "./ControllerInput"; +export * from "./ControllerTextarea"; +export * from "./FilterByPermission"; export * from "./FormStatus"; -export * from "./ListSelection"; export * from "./NumberInput"; -export * from "./TagSelection"; -export * from "./TextInput"; export * from "./SelectInput"; export * from "./TextAreaInput"; -export * from "./ControllerInput"; -export * from "./ControllerTextarea"; -export * from "./AssetInput"; +export * from "./TextInput"; diff --git a/src/lib/components/modal/CodeSnippet.tsx b/src/lib/components/modal/CodeSnippet.tsx index cc8f726f9..8bcbc4a18 100644 --- a/src/lib/components/modal/CodeSnippet.tsx +++ b/src/lib/components/modal/CodeSnippet.tsx @@ -19,9 +19,9 @@ import { useWallet } from "@cosmos-kit/react"; import AceEditor from "react-ace"; import { MdCode } from "react-icons/md"; +import { useLCDEndpoint } from "lib/app-provider"; import { CopyButton } from "lib/components/copy"; import { CustomTab } from "lib/components/CustomTab"; -import { useLCDEndpoint } from "lib/hooks"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import type { ContractAddr, Option } from "lib/types"; diff --git a/src/lib/components/modal/RedoModal.tsx b/src/lib/components/modal/RedoModal.tsx index 77d0f1f4a..e58d72faa 100644 --- a/src/lib/components/modal/RedoModal.tsx +++ b/src/lib/components/modal/RedoModal.tsx @@ -17,7 +17,7 @@ import { useWallet } from "@cosmos-kit/react"; import { BsArrowCounterclockwise } from "react-icons/bs"; import { MdReplay } from "react-icons/md"; -import { useRedo } from "lib/pages/past-txs/hooks/useRedo"; +import { useRedo } from "lib/hooks/useRedo"; import type { Message } from "lib/types"; import { extractMsgType } from "lib/utils"; diff --git a/src/lib/components/modal/UnsupportedTokensModal.tsx b/src/lib/components/modal/UnsupportedTokensModal.tsx index 709dfc765..43d7670c6 100644 --- a/src/lib/components/modal/UnsupportedTokensModal.tsx +++ b/src/lib/components/modal/UnsupportedTokensModal.tsx @@ -20,9 +20,9 @@ import { FaCoins } from "react-icons/fa"; import { MdAttachMoney } from "react-icons/md"; import { ExplorerLink } from "../ExplorerLink"; +import { getAddressTypeByLength } from "lib/app-provider"; +import type { AddressReturnType } from "lib/app-provider"; import { Copier } from "lib/components/copy"; -import type { AddressReturnType } from "lib/hooks"; -import { getAddressTypeByLength } from "lib/hooks"; import type { BalanceWithAssetInfo, Balance, Token, U, Addr } from "lib/types"; import { getTokenType, diff --git a/src/lib/components/modal/code/CodeDetailsTemplate.tsx b/src/lib/components/modal/code/CodeDetailsTemplate.tsx index 975b3c64a..d2e3061d3 100644 --- a/src/lib/components/modal/code/CodeDetailsTemplate.tsx +++ b/src/lib/components/modal/code/CodeDetailsTemplate.tsx @@ -3,11 +3,12 @@ import { useCallback, useEffect, useState } from "react"; import { MdAddCircleOutline, MdCheckCircle } from "react-icons/md"; import { ActionModal } from "../ActionModal"; +import { useGetAddressType } from "lib/app-provider"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { TextInput } from "lib/components/forms"; import { PermissionChip } from "lib/components/PermissionChip"; import { MAX_CODE_NAME_LENGTH } from "lib/data"; -import { useCodeStore, useGetAddressType } from "lib/hooks"; +import { useCodeStore } from "lib/providers/store"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import type { Addr, CodeInfo } from "lib/types"; diff --git a/src/lib/components/modal/code/RemoveCode.tsx b/src/lib/components/modal/code/RemoveCode.tsx index a98eb2fbe..4de7d2e1c 100644 --- a/src/lib/components/modal/code/RemoveCode.tsx +++ b/src/lib/components/modal/code/RemoveCode.tsx @@ -2,8 +2,8 @@ import { useToast, Icon, Text, chakra, IconButton } from "@chakra-ui/react"; import { useCallback } from "react"; import { MdCheckCircle, MdDelete } from "react-icons/md"; -import { ActionModal } from "lib/components/modal/ActionModal"; -import { useCodeStore } from "lib/hooks"; +import { ActionModal } from "../ActionModal"; +import { useCodeStore } from "lib/providers/store"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import { getNameAndDescriptionDefault, shortenName } from "lib/utils"; diff --git a/src/lib/components/modal/code/SaveNewCode.tsx b/src/lib/components/modal/code/SaveNewCode.tsx index 9dd979118..1330f3323 100644 --- a/src/lib/components/modal/code/SaveNewCode.tsx +++ b/src/lib/components/modal/code/SaveNewCode.tsx @@ -6,10 +6,11 @@ import { useEffect, useMemo, useState } from "react"; import { MdBookmark, MdCheckCircle } from "react-icons/md"; import { ActionModal } from "../ActionModal"; +import { useLCDEndpoint } from "lib/app-provider"; import type { FormStatus } from "lib/components/forms"; import { TextInput, NumberInput } from "lib/components/forms"; import { getMaxCodeNameLengthError, MAX_CODE_NAME_LENGTH } from "lib/data"; -import { useCodeStore, useLCDEndpoint } from "lib/hooks"; +import { useCodeStore } from "lib/providers/store"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import { getCodeIdInfo } from "lib/services/code"; import type { Addr, HumanAddr } from "lib/types"; diff --git a/src/lib/components/modal/contract/AddToOtherList.tsx b/src/lib/components/modal/contract/AddToOtherList.tsx index 6b8ff22be..d7a3ed699 100644 --- a/src/lib/components/modal/contract/AddToOtherList.tsx +++ b/src/lib/components/modal/contract/AddToOtherList.tsx @@ -4,7 +4,7 @@ import { useEffect, useState } from "react"; import { MdBookmark } from "react-icons/md"; import { ExplorerLink } from "lib/components/ExplorerLink"; -import { ListSelection } from "lib/components/forms/ListSelection"; +import { ListSelection } from "lib/components/ListSelection"; import { ActionModal } from "lib/components/modal/ActionModal"; import { useHandleContractSave } from "lib/hooks/useHandleSave"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; diff --git a/src/lib/components/modal/contract/SaveNewContract.tsx b/src/lib/components/modal/contract/SaveNewContract.tsx index ca35b9768..2c3908465 100644 --- a/src/lib/components/modal/contract/SaveNewContract.tsx +++ b/src/lib/components/modal/contract/SaveNewContract.tsx @@ -6,19 +6,19 @@ import { useState, useEffect } from "react"; import { useForm } from "react-hook-form"; import { MdBookmark } from "react-icons/md"; -import { useCelatoneApp } from "lib/app-provider"; +import { + useCelatoneApp, + useLCDEndpoint, + useValidateAddress, +} from "lib/app-provider"; import type { FormStatus } from "lib/components/forms"; import { ControllerInput } from "lib/components/forms"; import { ActionModal } from "lib/components/modal/ActionModal"; import type { OffchainDetail } from "lib/components/OffChainForm"; import { OffChainForm } from "lib/components/OffChainForm"; import { DEFAULT_RPC_ERROR, INSTANTIATED_LIST_NAME } from "lib/data"; -import { - useContractStore, - useLCDEndpoint, - useValidateAddress, -} from "lib/hooks"; -import { useHandleContractSave } from "lib/hooks/useHandleSave"; +import { useHandleContractSave } from "lib/hooks"; +import { useContractStore } from "lib/providers/store"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import { queryInstantiateInfo } from "lib/services/contract"; import type { Addr, ContractAddr, LVPair, RpcQueryError } from "lib/types"; diff --git a/src/lib/components/modal/index.ts b/src/lib/components/modal/index.ts index ebfc64e39..a0c7be837 100644 --- a/src/lib/components/modal/index.ts +++ b/src/lib/components/modal/index.ts @@ -1,7 +1,7 @@ export * from "./code"; export * from "./contract"; export * from "./list"; -export * from "./tx"; export * from "./ActionModal"; -export * from "./EditTags"; export * from "./NoMobile"; +export * from "./RedoModal"; +export * from "./UnsupportedTokensModal"; diff --git a/src/lib/components/modal/list/CreateNewList.tsx b/src/lib/components/modal/list/CreateNewList.tsx index 99684bb50..cc8d772d1 100644 --- a/src/lib/components/modal/list/CreateNewList.tsx +++ b/src/lib/components/modal/list/CreateNewList.tsx @@ -4,11 +4,12 @@ import { useCallback, useEffect, useState } from "react"; import type { ReactNode } from "react"; import { MdAddCircleOutline, MdCheckCircle } from "react-icons/md"; +import { ActionModal } from "../ActionModal"; import type { FormStatus } from "lib/components/forms"; -import { TextInput } from "lib/components/forms/TextInput"; -import { ActionModal } from "lib/components/modal/ActionModal"; +import { TextInput } from "lib/components/forms"; import { getMaxListNameLengthError, MAX_LIST_NAME_LENGTH } from "lib/data"; -import { useContractStore, useUserKey } from "lib/hooks"; +import { useUserKey } from "lib/hooks"; +import { useContractStore } from "lib/providers/store"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import { shortenName } from "lib/utils"; diff --git a/src/lib/components/modal/list/EditListName.tsx b/src/lib/components/modal/list/EditListName.tsx index 5a69c32b9..07808a6bc 100644 --- a/src/lib/components/modal/list/EditListName.tsx +++ b/src/lib/components/modal/list/EditListName.tsx @@ -8,7 +8,8 @@ import type { FormStatus } from "lib/components/forms"; import { TextInput } from "lib/components/forms/TextInput"; import { ActionModal } from "lib/components/modal/ActionModal"; import { getMaxListNameLengthError, MAX_LIST_NAME_LENGTH } from "lib/data"; -import { useContractStore, useUserKey } from "lib/hooks"; +import { useUserKey } from "lib/hooks"; +import { useContractStore } from "lib/providers/store"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import type { LVPair } from "lib/types"; import { formatSlugName, shortenName } from "lib/utils"; diff --git a/src/lib/components/modal/list/RemoveList.tsx b/src/lib/components/modal/list/RemoveList.tsx index 090a5d5be..ac8825256 100644 --- a/src/lib/components/modal/list/RemoveList.tsx +++ b/src/lib/components/modal/list/RemoveList.tsx @@ -2,9 +2,10 @@ import type { MenuItemProps } from "@chakra-ui/react"; import { MenuItem, useToast, Icon, Text } from "@chakra-ui/react"; import { MdDeleteForever, MdCheckCircle } from "react-icons/md"; +import { ActionModal } from "../ActionModal"; import { useInternalNavigate } from "lib/app-provider"; -import { ActionModal } from "lib/components/modal/ActionModal"; -import { useContractStore, useUserKey } from "lib/hooks"; +import { useUserKey } from "lib/hooks"; +import { useContractStore } from "lib/providers/store"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import type { LVPair } from "lib/types"; import { shortenName } from "lib/utils"; diff --git a/src/lib/components/modal/select-code/CodeSelect.tsx b/src/lib/components/select-code/CodeSelect.tsx similarity index 95% rename from src/lib/components/modal/select-code/CodeSelect.tsx rename to src/lib/components/select-code/CodeSelect.tsx index 2a07895b3..6cfe70ad9 100644 --- a/src/lib/components/modal/select-code/CodeSelect.tsx +++ b/src/lib/components/select-code/CodeSelect.tsx @@ -3,8 +3,8 @@ import { Flex, Text } from "@chakra-ui/react"; import type { FormStatus } from "lib/components/forms"; import { UploadIcon } from "lib/components/icon/UploadIcon"; -import { useCodeStore } from "lib/hooks/store"; -import { useUserKey } from "lib/hooks/useUserKey"; +import { useUserKey } from "lib/hooks"; +import { useCodeStore } from "lib/providers/store"; import { CodeSelectModalButton } from "./CodeSelectModalButton"; diff --git a/src/lib/components/modal/select-code/CodeSelectModalButton.tsx b/src/lib/components/select-code/CodeSelectModalButton.tsx similarity index 100% rename from src/lib/components/modal/select-code/CodeSelectModalButton.tsx rename to src/lib/components/select-code/CodeSelectModalButton.tsx diff --git a/src/lib/components/modal/select-code/CodeSelectSection.tsx b/src/lib/components/select-code/CodeSelectSection.tsx similarity index 100% rename from src/lib/components/modal/select-code/CodeSelectSection.tsx rename to src/lib/components/select-code/CodeSelectSection.tsx diff --git a/src/lib/components/modal/select-code/CodesReadOnlyTable.tsx b/src/lib/components/select-code/CodesReadOnlyTable.tsx similarity index 100% rename from src/lib/components/modal/select-code/CodesReadOnlyTable.tsx rename to src/lib/components/select-code/CodesReadOnlyTable.tsx diff --git a/src/lib/components/modal/select-code/MySavedCodeContent.tsx b/src/lib/components/select-code/MySavedCodeContent.tsx similarity index 100% rename from src/lib/components/modal/select-code/MySavedCodeContent.tsx rename to src/lib/components/select-code/MySavedCodeContent.tsx diff --git a/src/lib/components/modal/select-code/MyStoredCodeContent.tsx b/src/lib/components/select-code/MyStoredCodeContent.tsx similarity index 100% rename from src/lib/components/modal/select-code/MyStoredCodeContent.tsx rename to src/lib/components/select-code/MyStoredCodeContent.tsx diff --git a/src/lib/components/modal/select-code/index.ts b/src/lib/components/select-code/index.ts similarity index 100% rename from src/lib/components/modal/select-code/index.ts rename to src/lib/components/select-code/index.ts diff --git a/src/lib/components/modal/select-contract/AllContractLists.tsx b/src/lib/components/select-contract/AllContractLists.tsx similarity index 100% rename from src/lib/components/modal/select-contract/AllContractLists.tsx rename to src/lib/components/select-contract/AllContractLists.tsx diff --git a/src/lib/components/modal/select-contract/ContractListCard.tsx b/src/lib/components/select-contract/ContractListCard.tsx similarity index 97% rename from src/lib/components/modal/select-contract/ContractListCard.tsx rename to src/lib/components/select-contract/ContractListCard.tsx index c4c28bd0d..9e0905547 100644 --- a/src/lib/components/modal/select-contract/ContractListCard.tsx +++ b/src/lib/components/select-contract/ContractListCard.tsx @@ -14,7 +14,7 @@ import { } from "@chakra-ui/react"; import { MdMoreHoriz, MdMode, MdDelete } from "react-icons/md"; -import { EditListNameModal, RemoveListModal } from "../list"; +import { EditListNameModal, RemoveListModal } from "lib/components/modal"; import { getListIcon, INSTANTIATED_LIST_NAME } from "lib/data"; import type { ContractListInfo } from "lib/stores/contract"; import { dateFromNow, formatSlugName } from "lib/utils"; diff --git a/src/lib/components/modal/select-contract/ContractListDetail.tsx b/src/lib/components/select-contract/ContractListDetail.tsx similarity index 97% rename from src/lib/components/modal/select-contract/ContractListDetail.tsx rename to src/lib/components/select-contract/ContractListDetail.tsx index d3a197ace..8a15a7dc5 100644 --- a/src/lib/components/modal/select-contract/ContractListDetail.tsx +++ b/src/lib/components/select-contract/ContractListDetail.tsx @@ -3,9 +3,10 @@ import { useWallet } from "@cosmos-kit/react"; import { matchSorter } from "match-sorter"; import { useMemo, useState } from "react"; -import { TagSelection, TextInput } from "lib/components/forms"; +import { TextInput } from "lib/components/forms"; import { Loading } from "lib/components/Loading"; import { DisconnectedState, EmptyState, ZeroState } from "lib/components/state"; +import { TagSelection } from "lib/components/TagSelection"; import { INSTANTIATED_LIST_NAME } from "lib/data"; import type { ContractLocalInfo, ContractListInfo } from "lib/stores/contract"; import type { ContractAddr, HumanAddr, LVPair, Option } from "lib/types"; diff --git a/src/lib/components/modal/select-contract/ContractListReadOnlyTable.tsx b/src/lib/components/select-contract/ContractListReadOnlyTable.tsx similarity index 100% rename from src/lib/components/modal/select-contract/ContractListReadOnlyTable.tsx rename to src/lib/components/select-contract/ContractListReadOnlyTable.tsx diff --git a/src/lib/components/modal/select-contract/ContractListTable.tsx b/src/lib/components/select-contract/ContractListTable.tsx similarity index 100% rename from src/lib/components/modal/select-contract/ContractListTable.tsx rename to src/lib/components/select-contract/ContractListTable.tsx diff --git a/src/lib/components/modal/select-contract/SelectContractAdmin.tsx b/src/lib/components/select-contract/SelectContractAdmin.tsx similarity index 98% rename from src/lib/components/modal/select-contract/SelectContractAdmin.tsx rename to src/lib/components/select-contract/SelectContractAdmin.tsx index b703abf5a..066632a11 100644 --- a/src/lib/components/modal/select-contract/SelectContractAdmin.tsx +++ b/src/lib/components/select-contract/SelectContractAdmin.tsx @@ -14,7 +14,7 @@ import { useWallet } from "@cosmos-kit/react"; import { MdList, MdSwapHoriz } from "react-icons/md"; import { ADMIN_SPECIAL_SLUG } from "lib/data"; -import { useContractStore } from "lib/hooks"; +import { useContractStore } from "lib/providers/store"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import { useContractListByAdmin } from "lib/services/contractService"; import type { ContractListInfo, ContractLocalInfo } from "lib/stores/contract"; diff --git a/src/lib/components/modal/select-contract/SelectContractInstantiator.tsx b/src/lib/components/select-contract/SelectContractInstantiator.tsx similarity index 98% rename from src/lib/components/modal/select-contract/SelectContractInstantiator.tsx rename to src/lib/components/select-contract/SelectContractInstantiator.tsx index 07d8ab9ea..18c78984e 100644 --- a/src/lib/components/modal/select-contract/SelectContractInstantiator.tsx +++ b/src/lib/components/select-contract/SelectContractInstantiator.tsx @@ -19,14 +19,14 @@ import type { AxiosError } from "axios"; import { useState } from "react"; import { MdChevronLeft, MdList, MdSwapHoriz } from "react-icons/md"; -import { useCelatoneApp } from "lib/app-provider"; -import { DEFAULT_RPC_ERROR } from "lib/data"; import { - useContractStore, + useCelatoneApp, useLCDEndpoint, useValidateAddress, -} from "lib/hooks"; +} from "lib/app-provider"; +import { DEFAULT_RPC_ERROR } from "lib/data"; import { useInstantiatedByMe } from "lib/model/contract"; +import { useContractStore } from "lib/providers/store"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import { queryContract } from "lib/services/contract"; import type { ContractAddr, RpcQueryError } from "lib/types"; diff --git a/src/lib/components/modal/select-contract/index.ts b/src/lib/components/select-contract/index.ts similarity index 100% rename from src/lib/components/modal/select-contract/index.ts rename to src/lib/components/select-contract/index.ts diff --git a/src/lib/components/table/codes/CodeNameCell.tsx b/src/lib/components/table/codes/CodeNameCell.tsx index 67ba4b494..8a11c257c 100644 --- a/src/lib/components/table/codes/CodeNameCell.tsx +++ b/src/lib/components/table/codes/CodeNameCell.tsx @@ -3,7 +3,7 @@ import { MdCheckCircle } from "react-icons/md"; import { EditableCell } from "../EditableCell"; import { MAX_CODE_NAME_LENGTH } from "lib/data"; -import { useCodeStore } from "lib/hooks"; +import { useCodeStore } from "lib/providers/store"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import type { CodeLocalInfo } from "lib/stores/code"; diff --git a/src/lib/components/modal/EditTags.tsx b/src/lib/components/table/contracts/EditTags.tsx similarity index 92% rename from src/lib/components/modal/EditTags.tsx rename to src/lib/components/table/contracts/EditTags.tsx index 4a34696cb..c9f565882 100644 --- a/src/lib/components/modal/EditTags.tsx +++ b/src/lib/components/table/contracts/EditTags.tsx @@ -2,9 +2,9 @@ import { Icon, Flex, FormControl, Box, Text } from "@chakra-ui/react"; import { useState } from "react"; import { MdMode } from "react-icons/md"; -import { ExplorerLink } from "../ExplorerLink"; -import { TagSelection } from "lib/components/forms/TagSelection"; -import { ActionModal } from "lib/components/modal/ActionModal"; +import { ExplorerLink } from "lib/components/ExplorerLink"; +import { ActionModal } from "lib/components/modal"; +import { TagSelection } from "lib/components/TagSelection"; import { useHandleContractSave } from "lib/hooks/useHandleSave"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import type { ContractLocalInfo } from "lib/stores/contract"; diff --git a/src/lib/components/table/contracts/TagsCell.tsx b/src/lib/components/table/contracts/TagsCell.tsx index 001cc674e..02bcf6402 100644 --- a/src/lib/components/table/contracts/TagsCell.tsx +++ b/src/lib/components/table/contracts/TagsCell.tsx @@ -1,10 +1,11 @@ import { Flex, Tag, TagLabel, Text } from "@chakra-ui/react"; import { useState } from "react"; -import { EditTags } from "lib/components/modal/EditTags"; import type { ContractLocalInfo } from "lib/stores/contract"; import { getTagsDefault } from "lib/utils"; +import { EditTags } from "./EditTags"; + interface TagsCellProps { contractLocalInfo: ContractLocalInfo; isReadOnly?: boolean; diff --git a/src/lib/components/tx/receipt/index.tsx b/src/lib/components/tx/TxReceiptRender.tsx similarity index 56% rename from src/lib/components/tx/receipt/index.tsx rename to src/lib/components/tx/TxReceiptRender.tsx index 007fcabd6..4e0f73ef5 100644 --- a/src/lib/components/tx/receipt/index.tsx +++ b/src/lib/components/tx/TxReceiptRender.tsx @@ -26,26 +26,22 @@ const variantStyle: Record< }, }; -const ReceiptRow = ({ title, value, html }: TxReceipt) => { - return ( - - - {title} - - {html || {value}} - - ); -}; +const ReceiptRow = ({ title, value, html }: TxReceipt) => ( + + + {title} + + {html || {value}} + +); export const TxReceiptRender = ({ receipts, variant = "packed", -}: TxReceiptRenderProps) => { - return ( - - {receipts.map((receipt) => ( - - ))} - - ); -}; +}: TxReceiptRenderProps) => ( + + {receipts.map((receipt) => ( + + ))} + +); diff --git a/src/lib/components/tx/index.ts b/src/lib/components/tx/index.ts new file mode 100644 index 000000000..28c70d6c6 --- /dev/null +++ b/src/lib/components/tx/index.ts @@ -0,0 +1,2 @@ +export * from "./modal"; +export * from "./TxReceiptRender"; diff --git a/src/lib/components/modal/tx/ButtonSection.tsx b/src/lib/components/tx/modal/ButtonSection.tsx similarity index 100% rename from src/lib/components/modal/tx/ButtonSection.tsx rename to src/lib/components/tx/modal/ButtonSection.tsx diff --git a/src/lib/components/modal/tx/index.tsx b/src/lib/components/tx/modal/index.tsx similarity index 96% rename from src/lib/components/modal/tx/index.tsx rename to src/lib/components/tx/modal/index.tsx index d01d6ffff..f1e019de7 100644 --- a/src/lib/components/modal/tx/index.tsx +++ b/src/lib/components/tx/modal/index.tsx @@ -10,8 +10,8 @@ import { } from "@chakra-ui/react"; import { useCallback } from "react"; +import { TxReceiptRender } from "../TxReceiptRender"; import { useInternalNavigate } from "lib/app-provider"; -import { TxReceiptRender } from "lib/components/tx/receipt"; import type { TxResultRendering } from "lib/types"; import { TxStreamPhase } from "lib/types"; diff --git a/src/lib/components/upload/UploadSection.tsx b/src/lib/components/upload/UploadSection.tsx index ba347f88b..91b8fbb93 100644 --- a/src/lib/components/upload/UploadSection.tsx +++ b/src/lib/components/upload/UploadSection.tsx @@ -13,7 +13,7 @@ import { DropZone } from "lib/components/dropzone"; import { EstimatedFeeRender } from "lib/components/EstimatedFeeRender"; import { ControllerInput } from "lib/components/forms"; import { getMaxCodeNameLengthError, MAX_CODE_NAME_LENGTH } from "lib/data"; -import { useCodeStore } from "lib/hooks"; +import { useCodeStore } from "lib/providers/store"; import { useTxBroadcast } from "lib/providers/tx-broadcast"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import type { HumanAddr } from "lib/types"; diff --git a/src/lib/hooks/index.ts b/src/lib/hooks/index.ts index b207469e7..c5e72069d 100644 --- a/src/lib/hooks/index.ts +++ b/src/lib/hooks/index.ts @@ -1,9 +1,8 @@ -export * from "./store"; -export * from "./useMediaQuery"; +export * from "./useCodeFilter"; +export * from "./useExecuteCmds"; +export * from "./useHandleSave"; +export * from "./useQueryCmds"; +export * from "./useRedo"; +export * from "./useSingleMessageProps"; export * from "./useToast"; -export * from "./useLCDEndpoint"; export * from "./useUserKey"; -export * from "./useDummyWallet"; -export * from "./useAddress"; -export * from "./useCodeFilter"; -export * from "./useChainId"; diff --git a/src/lib/hooks/store.ts b/src/lib/hooks/store.ts deleted file mode 100644 index d62df02e9..000000000 --- a/src/lib/hooks/store.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { useStore } from "lib/providers/store"; - -export function useCodeStore() { - const { codeStore } = useStore(); - return codeStore; -} - -export function useContractStore() { - const { contractStore } = useStore(); - return contractStore; -} - -export function usePublicProjectStore() { - const { publicProjectStore } = useStore(); - return publicProjectStore; -} diff --git a/src/lib/app-provider/hooks/useExecuteCmds.ts b/src/lib/hooks/useExecuteCmds.ts similarity index 92% rename from src/lib/app-provider/hooks/useExecuteCmds.ts rename to src/lib/hooks/useExecuteCmds.ts index eb9a1168b..0d04c76a0 100644 --- a/src/lib/app-provider/hooks/useExecuteCmds.ts +++ b/src/lib/hooks/useExecuteCmds.ts @@ -1,7 +1,6 @@ import { useEffect, useState } from "react"; -import { useSimulateFeeQuery } from "../queries"; -import { useDummyWallet } from "lib/hooks"; +import { useSimulateFeeQuery, useDummyWallet } from "lib/app-provider"; import type { HumanAddr, ContractAddr } from "lib/types"; import { MsgType } from "lib/types"; import { composeMsg } from "lib/utils"; diff --git a/src/lib/hooks/useHandleSave.tsx b/src/lib/hooks/useHandleSave.tsx index 9cbdaafa1..6108a69a5 100644 --- a/src/lib/hooks/useHandleSave.tsx +++ b/src/lib/hooks/useHandleSave.tsx @@ -1,9 +1,9 @@ import { Icon, useToast } from "@chakra-ui/react"; import { MdCheckCircle } from "react-icons/md"; +import { useContractStore } from "lib/providers/store"; import type { Addr, ContractAddr, LVPair, Option } from "lib/types"; -import { useContractStore } from "./store"; import { useUserKey } from "./useUserKey"; interface UseHandleContractSaveProps { diff --git a/src/lib/app-provider/hooks/useQueryCmds.ts b/src/lib/hooks/useQueryCmds.ts similarity index 95% rename from src/lib/app-provider/hooks/useQueryCmds.ts rename to src/lib/hooks/useQueryCmds.ts index 41f456e15..7286a7229 100644 --- a/src/lib/app-provider/hooks/useQueryCmds.ts +++ b/src/lib/hooks/useQueryCmds.ts @@ -2,7 +2,7 @@ import { useQuery } from "@tanstack/react-query"; import type { AxiosError } from "axios"; import { useState } from "react"; -import { useLCDEndpoint } from "lib/hooks"; +import { useLCDEndpoint } from "lib/app-provider"; import { queryData } from "lib/services/contract"; import type { ContractAddr, RpcQueryError } from "lib/types"; diff --git a/src/lib/pages/past-txs/hooks/useRedo.ts b/src/lib/hooks/useRedo.ts similarity index 100% rename from src/lib/pages/past-txs/hooks/useRedo.ts rename to src/lib/hooks/useRedo.ts diff --git a/src/lib/hooks/useSingleMessageProps.ts b/src/lib/hooks/useSingleMessageProps.ts index 3f2cb00ea..1171b753b 100644 --- a/src/lib/hooks/useSingleMessageProps.ts +++ b/src/lib/hooks/useSingleMessageProps.ts @@ -1,9 +1,10 @@ import { useWallet } from "@cosmos-kit/react"; import router from "next/router"; +import { getAddressTypeByLength } from "lib/app-provider"; import type { SingleMsgProps } from "lib/components/action-msg/SingleMsg"; import type { LinkType } from "lib/components/ExplorerLink"; -import { getAddressTypeByLength, useContractStore } from "lib/hooks"; +import { useContractStore } from "lib/providers/store"; import { useAssetInfos } from "lib/services/assetService"; import type { ContractLocalInfo } from "lib/stores/contract"; import type { diff --git a/src/lib/layout/Searchbar.tsx b/src/lib/layout/Searchbar.tsx index 70dab1ef7..566fccf4e 100644 --- a/src/lib/layout/Searchbar.tsx +++ b/src/lib/layout/Searchbar.tsx @@ -13,8 +13,7 @@ import type { ChangeEvent, KeyboardEvent } from "react"; import { useRef, useEffect, useState } from "react"; import { MdSearch } from "react-icons/md"; -import { useInternalNavigate } from "lib/app-provider"; -import { useValidateAddress } from "lib/hooks"; +import { useInternalNavigate, useValidateAddress } from "lib/app-provider"; import { AmpTrackUseMainSearch } from "lib/services/amplitude"; import { isCodeId, isTxHash } from "lib/utils"; diff --git a/src/lib/layout/index.tsx b/src/lib/layout/index.tsx index 72f159472..430990e3d 100644 --- a/src/lib/layout/index.tsx +++ b/src/lib/layout/index.tsx @@ -3,7 +3,7 @@ import { useRouter } from "next/router"; import type { ReactNode } from "react"; import { useState, useEffect } from "react"; -import { useMobile } from "lib/hooks"; +import { useMobile } from "lib/app-provider"; import { scrollToTop } from "lib/utils"; import Footer from "./Footer"; diff --git a/src/lib/layout/navbar/Collapse.tsx b/src/lib/layout/navbar/Collapse.tsx index 93e250d92..7b87cba83 100644 --- a/src/lib/layout/navbar/Collapse.tsx +++ b/src/lib/layout/navbar/Collapse.tsx @@ -1,8 +1,8 @@ import { Box, Flex, Icon, IconButton, Image, Tooltip } from "@chakra-ui/react"; import { MdDoubleArrow } from "react-icons/md"; +import { useMobile } from "lib/app-provider"; import { AppLink } from "lib/components/AppLink"; -import { useMobile } from "lib/hooks"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import type { NavMenuProps } from "./type"; diff --git a/src/lib/layout/navbar/index.tsx b/src/lib/layout/navbar/index.tsx index 131c78bcb..dd791dfcb 100644 --- a/src/lib/layout/navbar/index.tsx +++ b/src/lib/layout/navbar/index.tsx @@ -16,7 +16,7 @@ import { } from "react-icons/md"; import { INSTANTIATED_LIST_NAME, getListIcon, SAVED_LIST_NAME } from "lib/data"; -import { useContractStore, usePublicProjectStore } from "lib/hooks"; +import { useContractStore, usePublicProjectStore } from "lib/providers/store"; import { cmpContractListInfo } from "lib/stores/contract"; import { formatSlugName } from "lib/utils"; diff --git a/src/lib/model/code.ts b/src/lib/model/code.ts index 64114fb8d..40ea14c9a 100644 --- a/src/lib/model/code.ts +++ b/src/lib/model/code.ts @@ -1,4 +1,5 @@ -import { useChainId, useContractStore } from "lib/hooks"; +import { useChainId } from "lib/app-provider"; +import { useContractStore } from "lib/providers/store"; import { useCodeInfoByCodeId } from "lib/services/codeService"; import { useContractListByCodeIdPagination, diff --git a/src/lib/model/contract.ts b/src/lib/model/contract.ts index 97a79e27a..fad932c53 100644 --- a/src/lib/model/contract.ts +++ b/src/lib/model/contract.ts @@ -1,14 +1,9 @@ import { useWallet } from "@cosmos-kit/react"; import { useQuery } from "@tanstack/react-query"; -import { useCelatoneApp } from "lib/app-provider"; +import { useCelatoneApp, useChainId, useLCDEndpoint } from "lib/app-provider"; import { INSTANTIATED_LIST_NAME } from "lib/data"; -import { - useChainId, - useCodeStore, - useContractStore, - useLCDEndpoint, -} from "lib/hooks"; +import { useCodeStore, useContractStore } from "lib/providers/store"; import { useAssetInfos } from "lib/services/assetService"; import { queryContractCw2Info, diff --git a/src/lib/pages/account-details/components/asset/index.tsx b/src/lib/pages/account-details/components/asset/index.tsx index 176ea1576..abe001058 100644 --- a/src/lib/pages/account-details/components/asset/index.tsx +++ b/src/lib/pages/account-details/components/asset/index.tsx @@ -3,7 +3,7 @@ import type { Big } from "big.js"; import big from "big.js"; import { Loading } from "lib/components/Loading"; -import { UnsupportedTokensModal } from "lib/components/modal/UnsupportedTokensModal"; +import { UnsupportedTokensModal } from "lib/components/modal"; import { ViewMore } from "lib/components/table"; import { TokenCard } from "lib/components/TokenCard"; import { useUserAssetInfos } from "lib/pages/account-details/data"; diff --git a/src/lib/pages/account-details/components/tables/StoredCodesTable.tsx b/src/lib/pages/account-details/components/tables/StoredCodesTable.tsx index 4899a8ace..79686dabe 100644 --- a/src/lib/pages/account-details/components/tables/StoredCodesTable.tsx +++ b/src/lib/pages/account-details/components/tables/StoredCodesTable.tsx @@ -5,7 +5,7 @@ import { Pagination } from "lib/components/pagination"; import { usePaginator } from "lib/components/pagination/usePaginator"; import { EmptyState } from "lib/components/state"; import { CodesTable, TableTitle, ViewMore } from "lib/components/table"; -import { useCodeStored } from "lib/pages/account-details/data"; +import { useStoredCodes } from "lib/pages/account-details/data"; import type { HumanAddr, Option } from "lib/types"; interface StoredCodesTableProps { @@ -38,7 +38,7 @@ export const StoredCodesTable = ({ isDisabled: false, }, }); - const { codes, isLoading } = useCodeStored( + const { codes, isLoading } = useStoredCodes( walletAddress, offset, onViewMore ? 5 : pageSize diff --git a/src/lib/pages/account-details/data.ts b/src/lib/pages/account-details/data.ts index 2f2e2ed2d..361d73f2b 100644 --- a/src/lib/pages/account-details/data.ts +++ b/src/lib/pages/account-details/data.ts @@ -1,4 +1,4 @@ -import { useCodeStore, useContractStore } from "lib/hooks"; +import { useCodeStore, useContractStore } from "lib/providers/store"; import { useAccountBalances } from "lib/services/accountService"; import { useAssetInfos } from "lib/services/assetService"; import { useCodeListByWalletAddressPagination } from "lib/services/codeService"; @@ -88,7 +88,7 @@ export const useContractsAdmin = ( }; }; -export const useCodeStored = ( +export const useStoredCodes = ( walletAddress: HumanAddr, offset: number, pageSize: number diff --git a/src/lib/pages/account-details/index.tsx b/src/lib/pages/account-details/index.tsx index 3e5b0fcaa..4e83bd4b2 100644 --- a/src/lib/pages/account-details/index.tsx +++ b/src/lib/pages/account-details/index.tsx @@ -10,12 +10,12 @@ import { import { useRouter } from "next/router"; import { useEffect, useState } from "react"; +import { useValidateAddress } from "lib/app-provider"; import { BackButton } from "lib/components/button"; import { CustomTab } from "lib/components/CustomTab"; import { ExplorerLink } from "lib/components/ExplorerLink"; import PageContainer from "lib/components/PageContainer"; import { InvalidState } from "lib/components/state"; -import { useValidateAddress } from "lib/hooks"; import { useAccountDetailsTableCounts } from "lib/model/account"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import type { HumanAddr } from "lib/types"; diff --git a/src/lib/pages/admin/index.tsx b/src/lib/pages/admin/index.tsx index 807a1079a..463a4ac35 100644 --- a/src/lib/pages/admin/index.tsx +++ b/src/lib/pages/admin/index.tsx @@ -11,6 +11,9 @@ import { useInternalNavigate, useSimulateFeeQuery, useUpdateAdminTx, + useLCDEndpoint, + useGetAddressType, + useValidateAddress, } from "lib/app-provider"; import { ConnectWalletAlert } from "lib/components/ConnectWalletAlert"; import { ContractSelectSection } from "lib/components/ContractSelectSection"; @@ -19,11 +22,6 @@ import { EstimatedFeeRender } from "lib/components/EstimatedFeeRender"; import type { FormStatus } from "lib/components/forms"; import { TextInput } from "lib/components/forms"; import WasmPageContainer from "lib/components/WasmPageContainer"; -import { - useLCDEndpoint, - useGetAddressType, - useValidateAddress, -} from "lib/hooks"; import { useTxBroadcast } from "lib/providers/tx-broadcast"; import { AmpEvent, diff --git a/src/lib/pages/code-details/components/CTASection.tsx b/src/lib/pages/code-details/components/CTASection.tsx index cfab7238d..0a01991b2 100644 --- a/src/lib/pages/code-details/components/CTASection.tsx +++ b/src/lib/pages/code-details/components/CTASection.tsx @@ -4,7 +4,7 @@ import { MdCheck } from "react-icons/md"; import { InstantiateButton } from "lib/components/button"; import { RemoveCodeModal, SaveOrEditCodeModal } from "lib/components/modal"; -import { useCodeStore } from "lib/hooks"; +import { useCodeStore } from "lib/providers/store"; import type { CodeInfo } from "lib/types"; const StyledIcon = chakra(Icon, { diff --git a/src/lib/pages/code-details/components/table/CodeContractsTable.tsx b/src/lib/pages/code-details/components/table/CodeContractsTable.tsx index 95d754f69..ec2836a0b 100644 --- a/src/lib/pages/code-details/components/table/CodeContractsTable.tsx +++ b/src/lib/pages/code-details/components/table/CodeContractsTable.tsx @@ -5,7 +5,7 @@ import { useEffect } from "react"; import { Pagination } from "lib/components/pagination"; import { usePaginator } from "lib/components/pagination/usePaginator"; import { ContractsTable, TableTitle } from "lib/components/table"; -import { useContractStore } from "lib/hooks"; +import { useContractStore } from "lib/providers/store"; import { useContractListByCodeIdPagination, useContractListCountByCodeId, diff --git a/src/lib/pages/code-details/index.tsx b/src/lib/pages/code-details/index.tsx index c5f806558..85dd67f67 100644 --- a/src/lib/pages/code-details/index.tsx +++ b/src/lib/pages/code-details/index.tsx @@ -8,9 +8,9 @@ import { ExplorerLink } from "lib/components/ExplorerLink"; import { Loading } from "lib/components/Loading"; import PageContainer from "lib/components/PageContainer"; import { InvalidState } from "lib/components/state"; -import { useCodeStore } from "lib/hooks"; import type { CodeDataState } from "lib/model/code"; import { useCodeData } from "lib/model/code"; +import { useCodeStore } from "lib/providers/store"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import { InstantiatePermission } from "lib/types"; import { getFirstQueryParam, isCodeId } from "lib/utils"; diff --git a/src/lib/pages/codes/data.ts b/src/lib/pages/codes/data.ts index d1b075866..5ae873ead 100644 --- a/src/lib/pages/codes/data.ts +++ b/src/lib/pages/codes/data.ts @@ -2,12 +2,8 @@ import { useWallet } from "@cosmos-kit/react"; import { useMemo } from "react"; import type { PermissionFilterValue } from "lib/hooks"; -import { - useUserKey, - useCodeStore, - usePermissionFilter, - useSearchFilter, -} from "lib/hooks"; +import { useUserKey, usePermissionFilter, useSearchFilter } from "lib/hooks"; +import { useCodeStore } from "lib/providers/store"; import { useCodeListPageQuery } from "lib/services/codeService"; import type { CodeInfo, HumanAddr } from "lib/types"; import { InstantiatePermission } from "lib/types"; diff --git a/src/lib/pages/codes/index.tsx b/src/lib/pages/codes/index.tsx index dfbb9f65e..e846c791c 100644 --- a/src/lib/pages/codes/index.tsx +++ b/src/lib/pages/codes/index.tsx @@ -14,7 +14,7 @@ import { useEffect } from "react"; import { useForm } from "react-hook-form"; import { CustomTab } from "lib/components/CustomTab"; -import { FilterByPermission } from "lib/components/forms/FilterByPermission"; +import { FilterByPermission } from "lib/components/forms"; import InputWithIcon from "lib/components/InputWithIcon"; import type { PermissionFilterValue } from "lib/hooks"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; diff --git a/src/lib/pages/contract-details/components/token/TokenSection.tsx b/src/lib/pages/contract-details/components/token/TokenSection.tsx index df2bb2b3d..681eac9c3 100644 --- a/src/lib/pages/contract-details/components/token/TokenSection.tsx +++ b/src/lib/pages/contract-details/components/token/TokenSection.tsx @@ -3,7 +3,7 @@ import router from "next/router"; import { useMemo, useState } from "react"; import { ShowMoreButton } from "lib/components/button"; -import { UnsupportedTokensModal } from "lib/components/modal/UnsupportedTokensModal"; +import { UnsupportedTokensModal } from "lib/components/modal"; import { TokenCard } from "lib/components/TokenCard"; import type { BalanceWithAssetInfo, ContractAddr, Option } from "lib/types"; import { getFirstQueryParam } from "lib/utils"; diff --git a/src/lib/pages/contract-details/index.tsx b/src/lib/pages/contract-details/index.tsx index 416219cee..c46c9b7c2 100644 --- a/src/lib/pages/contract-details/index.tsx +++ b/src/lib/pages/contract-details/index.tsx @@ -10,12 +10,12 @@ import { observer } from "mobx-react-lite"; import { useRouter } from "next/router"; import { useEffect } from "react"; +import { useValidateAddress } from "lib/app-provider"; import { BackButton } from "lib/components/button"; import { CustomTab } from "lib/components/CustomTab"; import { Loading } from "lib/components/Loading"; import PageContainer from "lib/components/PageContainer"; import { InvalidState } from "lib/components/state"; -import { useValidateAddress } from "lib/hooks"; import { useContractData, useContractDetailsTableCounts, diff --git a/src/lib/pages/contract-details/model/data.ts b/src/lib/pages/contract-details/model/data.ts index 85f3cf59d..6cf352e6f 100644 --- a/src/lib/pages/contract-details/model/data.ts +++ b/src/lib/pages/contract-details/model/data.ts @@ -1,4 +1,4 @@ -import { useCodeStore } from "lib/hooks"; +import { useCodeStore } from "lib/providers/store"; import { useMigrationHistoriesByContractAddressPagination } from "lib/services/contractService"; import type { ContractAddr, ContractMigrationHistory, Option } from "lib/types"; diff --git a/src/lib/pages/contract-list/index.tsx b/src/lib/pages/contract-list/index.tsx index 8d466ecd3..ae425ca9b 100644 --- a/src/lib/pages/contract-list/index.tsx +++ b/src/lib/pages/contract-list/index.tsx @@ -5,11 +5,10 @@ import { useEffect } from "react"; import { MdOutlineAdd } from "react-icons/md"; import { useInternalNavigate } from "lib/app-provider"; -import { CreateNewListModal } from "lib/components/modal/list"; -import { AllContractLists } from "lib/components/modal/select-contract"; +import { CreateNewListModal, AllContractLists } from "lib/components/modal"; import PageContainer from "lib/components/PageContainer"; -import { useContractStore } from "lib/hooks"; import { useInstantiatedMockInfoByMe } from "lib/model/contract"; +import { useContractStore } from "lib/providers/store"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; const AllContractListsPage = observer(() => { diff --git a/src/lib/pages/execute/components/ExecuteArea.tsx b/src/lib/pages/execute/components/ExecuteArea.tsx index f310fa1a3..b412761c0 100644 --- a/src/lib/pages/execute/components/ExecuteArea.tsx +++ b/src/lib/pages/execute/components/ExecuteArea.tsx @@ -22,7 +22,7 @@ import { import type { AttachFundsState } from "lib/components/fund/types"; import { AttachFundsType } from "lib/components/fund/types"; import JsonInput from "lib/components/json/JsonInput"; -import { useContractStore } from "lib/hooks"; +import { useContractStore } from "lib/providers/store"; import { useTxBroadcast } from "lib/providers/tx-broadcast"; import { AmpEvent, AmpTrack, AmpTrackAction } from "lib/services/amplitude"; import type { Activity } from "lib/stores/contract"; diff --git a/src/lib/pages/home/components/RecentActivities.tsx b/src/lib/pages/home/components/RecentActivities.tsx index 559e05871..d8655bdb0 100644 --- a/src/lib/pages/home/components/RecentActivities.tsx +++ b/src/lib/pages/home/components/RecentActivities.tsx @@ -5,7 +5,8 @@ import { MdSearch, MdInput } from "react-icons/md"; import { useInternalNavigate } from "lib/app-provider"; import { ExplorerLink } from "lib/components/ExplorerLink"; -import { useContractStore, useUserKey } from "lib/hooks"; +import { useUserKey } from "lib/hooks"; +import { useContractStore } from "lib/providers/store"; import { dateFromNow } from "lib/utils"; export const RecentActivities = observer(() => { diff --git a/src/lib/pages/instantiate/completed.tsx b/src/lib/pages/instantiate/completed.tsx index 0ed406ee3..5fd2b80f9 100644 --- a/src/lib/pages/instantiate/completed.tsx +++ b/src/lib/pages/instantiate/completed.tsx @@ -3,7 +3,7 @@ import { MdCheckCircle } from "react-icons/md"; import { useInternalNavigate } from "lib/app-provider"; import { ExplorerLink } from "lib/components/ExplorerLink"; -import { TxReceiptRender } from "lib/components/tx/receipt"; +import { TxReceiptRender } from "lib/components/tx"; import WasmPageContainer from "lib/components/WasmPageContainer"; import { InstantiateOffChainForm } from "lib/pages/instantiate/component/InstantiateOffchainForm"; import type { ContractAddr } from "lib/types"; diff --git a/src/lib/pages/instantiate/component/InstantiateOffchainForm.tsx b/src/lib/pages/instantiate/component/InstantiateOffchainForm.tsx index dd0a59341..9fe628b12 100644 --- a/src/lib/pages/instantiate/component/InstantiateOffchainForm.tsx +++ b/src/lib/pages/instantiate/component/InstantiateOffchainForm.tsx @@ -7,8 +7,8 @@ import { useInternalNavigate } from "lib/app-provider"; import { OffChainForm } from "lib/components/OffChainForm"; import type { OffchainDetail } from "lib/components/OffChainForm"; import { INSTANTIATED_LIST_NAME } from "lib/data"; -import { useContractStore } from "lib/hooks"; -import { useUserKey } from "lib/hooks/useUserKey"; +import { useUserKey } from "lib/hooks"; +import { useContractStore } from "lib/providers/store"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import type { ContractAddr, HumanAddr, LVPair } from "lib/types"; import { formatSlugName } from "lib/utils"; diff --git a/src/lib/pages/instantiate/instantiate.tsx b/src/lib/pages/instantiate/instantiate.tsx index 1e26daa32..583502492 100644 --- a/src/lib/pages/instantiate/instantiate.tsx +++ b/src/lib/pages/instantiate/instantiate.tsx @@ -12,6 +12,8 @@ import { useSimulateFee, useInstantiateTx, useCelatoneApp, + useLCDEndpoint, + useValidateAddress, } from "lib/app-provider"; import { ConnectWalletAlert } from "lib/components/ConnectWalletAlert"; import type { FormStatus } from "lib/components/forms"; @@ -21,10 +23,9 @@ import { defaultAsset, defaultAssetJsonStr } from "lib/components/fund/data"; import type { AttachFundsState } from "lib/components/fund/types"; import { AttachFundsType } from "lib/components/fund/types"; import JsonInput from "lib/components/json/JsonInput"; -import { CodeSelectSection } from "lib/components/modal/select-code"; +import { CodeSelectSection } from "lib/components/select-code"; import { Stepper } from "lib/components/stepper"; import WasmPageContainer from "lib/components/WasmPageContainer"; -import { useLCDEndpoint, useValidateAddress } from "lib/hooks"; import { useTxBroadcast } from "lib/providers/tx-broadcast"; import { AmpEvent, diff --git a/src/lib/pages/migrate/components/MigrateContract.tsx b/src/lib/pages/migrate/components/MigrateContract.tsx index e14d1324d..1a30ee419 100644 --- a/src/lib/pages/migrate/components/MigrateContract.tsx +++ b/src/lib/pages/migrate/components/MigrateContract.tsx @@ -8,13 +8,16 @@ import { useForm } from "react-hook-form"; import { FiChevronLeft } from "react-icons/fi"; import { IoIosWarning } from "react-icons/io"; -import { useFabricateFee, useSimulateFeeQuery } from "lib/app-provider"; +import { + useFabricateFee, + useSimulateFeeQuery, + useLCDEndpoint, +} from "lib/app-provider"; import { useMigrateTx } from "lib/app-provider/tx/migrate"; import { EstimatedFeeRender } from "lib/components/EstimatedFeeRender"; import type { FormStatus } from "lib/components/forms"; import JsonInput from "lib/components/json/JsonInput"; -import { CodeSelectSection } from "lib/components/modal/select-code"; -import { useLCDEndpoint } from "lib/hooks"; +import { CodeSelectSection } from "lib/components/select-code"; import { useTxBroadcast } from "lib/providers/tx-broadcast"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import { getCodeIdInfo } from "lib/services/code"; diff --git a/src/lib/pages/migrate/index.tsx b/src/lib/pages/migrate/index.tsx index 5142747f0..04b2b9c2b 100644 --- a/src/lib/pages/migrate/index.tsx +++ b/src/lib/pages/migrate/index.tsx @@ -5,12 +5,15 @@ import { useRouter } from "next/router"; import { useCallback, useEffect } from "react"; import { useForm } from "react-hook-form"; -import { useCelatoneApp, useInternalNavigate } from "lib/app-provider"; +import { + useCelatoneApp, + useInternalNavigate, + useLCDEndpoint, +} from "lib/app-provider"; import { ConnectWalletAlert } from "lib/components/ConnectWalletAlert"; import { ContractSelectSection } from "lib/components/ContractSelectSection"; import { Stepper } from "lib/components/stepper"; import WasmPageContainer from "lib/components/WasmPageContainer"; -import { useLCDEndpoint } from "lib/hooks"; import { AmpTrackToMigrate } from "lib/services/amplitude"; import { queryInstantiateInfo } from "lib/services/contract"; import type { ContractAddr } from "lib/types"; diff --git a/src/lib/pages/past-txs/components/FurtherActionButton.tsx b/src/lib/pages/past-txs/components/FurtherActionButton.tsx index 73354cd73..6ca9d6b43 100644 --- a/src/lib/pages/past-txs/components/FurtherActionButton.tsx +++ b/src/lib/pages/past-txs/components/FurtherActionButton.tsx @@ -1,5 +1,5 @@ import { RedoButton, ResendButton } from "lib/components/button"; -import { RedoModal } from "lib/components/modal/RedoModal"; +import { RedoModal } from "lib/components/modal"; import type { Transaction } from "lib/types"; import { MsgFurtherAction } from "lib/types"; import { extractMsgType } from "lib/utils"; diff --git a/src/lib/pages/public-project/components/AllProject.tsx b/src/lib/pages/public-project/components/AllProject.tsx index 94cfe9fc0..762391b4d 100644 --- a/src/lib/pages/public-project/components/AllProject.tsx +++ b/src/lib/pages/public-project/components/AllProject.tsx @@ -15,7 +15,7 @@ import { BsGithub } from "react-icons/bs"; import { TextInput } from "lib/components/forms"; import { Loading } from "lib/components/Loading"; import { EmptyState } from "lib/components/state"; -import { usePublicProjectStore } from "lib/hooks"; +import { usePublicProjectStore } from "lib/providers/store"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import { usePublicProjects } from "lib/services/publicProjectService"; import type { PublicProjectInfo } from "lib/types"; diff --git a/src/lib/pages/public-project/components/BookmarkButton.tsx b/src/lib/pages/public-project/components/BookmarkButton.tsx index 44a7a14f7..07724b590 100644 --- a/src/lib/pages/public-project/components/BookmarkButton.tsx +++ b/src/lib/pages/public-project/components/BookmarkButton.tsx @@ -5,7 +5,7 @@ import { useCallback } from "react"; import type { IconType } from "react-icons"; import { MdBookmark, MdBookmarkBorder, MdCheckCircle } from "react-icons/md"; -import { usePublicProjectStore } from "lib/hooks"; +import { usePublicProjectStore } from "lib/providers/store"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import type { Option, PublicDetail } from "lib/types"; diff --git a/src/lib/pages/public-project/components/table/code/PublicProjectCodeTable.tsx b/src/lib/pages/public-project/components/table/code/PublicProjectCodeTable.tsx index b12077c65..805f157bf 100644 --- a/src/lib/pages/public-project/components/table/code/PublicProjectCodeTable.tsx +++ b/src/lib/pages/public-project/components/table/code/PublicProjectCodeTable.tsx @@ -6,7 +6,7 @@ import { useMemo, useState } from "react"; import { TextInput } from "lib/components/forms"; import { EmptyState } from "lib/components/state"; import { TableHeader, TableTitle, ViewMore } from "lib/components/table"; -import { useCodeStore } from "lib/hooks"; +import { useCodeStore } from "lib/providers/store"; import type { Option, PublicCode, CodeInfo } from "lib/types"; import { PublicProjectCodeRow } from "./PublicProjectCodeRow"; diff --git a/src/lib/pages/public-project/components/table/contract/PublicProjectContractTable.tsx b/src/lib/pages/public-project/components/table/contract/PublicProjectContractTable.tsx index 2b47846a0..7802a3f7c 100644 --- a/src/lib/pages/public-project/components/table/contract/PublicProjectContractTable.tsx +++ b/src/lib/pages/public-project/components/table/contract/PublicProjectContractTable.tsx @@ -6,7 +6,7 @@ import { useMemo, useState } from "react"; import { TextInput } from "lib/components/forms"; import { EmptyState } from "lib/components/state"; import { TableHeader, TableTitle, ViewMore } from "lib/components/table"; -import { useContractStore } from "lib/hooks"; +import { useContractStore } from "lib/providers/store"; import type { ContractLocalInfo } from "lib/stores/contract"; import type { PublicContract, Option, ContractAddr } from "lib/types"; diff --git a/src/lib/pages/query/components/QueryArea.tsx b/src/lib/pages/query/components/QueryArea.tsx index 61aae9768..10665794b 100644 --- a/src/lib/pages/query/components/QueryArea.tsx +++ b/src/lib/pages/query/components/QueryArea.tsx @@ -6,12 +6,14 @@ import type { AxiosError } from "axios"; import dynamic from "next/dynamic"; import { useEffect, useState } from "react"; +import { useLCDEndpoint } from "lib/app-provider"; import { ContractCmdButton } from "lib/components/ContractCmdButton"; import { CopyButton } from "lib/components/copy"; import JsonInput from "lib/components/json/JsonInput"; import JsonReadOnly from "lib/components/json/JsonReadOnly"; import { DEFAULT_RPC_ERROR } from "lib/data"; -import { useContractStore, useLCDEndpoint, useUserKey } from "lib/hooks"; +import { useUserKey } from "lib/hooks"; +import { useContractStore } from "lib/providers/store"; import { AmpTrack, AmpEvent } from "lib/services/amplitude"; import { queryData } from "lib/services/contract"; import type { ContractAddr, HumanAddr, RpcQueryError } from "lib/types"; diff --git a/src/lib/pages/query/index.tsx b/src/lib/pages/query/index.tsx index c4a6e1543..74bac106b 100644 --- a/src/lib/pages/query/index.tsx +++ b/src/lib/pages/query/index.tsx @@ -5,12 +5,11 @@ import type { AxiosError } from "axios"; import { useRouter } from "next/router"; import { useCallback, useEffect, useState } from "react"; -import { useInternalNavigate } from "lib/app-provider"; +import { useInternalNavigate, useLCDEndpoint } from "lib/app-provider"; import { BackButton } from "lib/components/button"; import { ContractSelectSection } from "lib/components/ContractSelectSection"; import { LoadingOverlay } from "lib/components/LoadingOverlay"; import PageContainer from "lib/components/PageContainer"; -import { useLCDEndpoint } from "lib/hooks"; import { AmpTrackToQuery } from "lib/services/amplitude"; import { queryData } from "lib/services/contract"; import type { ContractAddr, RpcQueryError } from "lib/types"; diff --git a/src/lib/pages/recent-codes/data.ts b/src/lib/pages/recent-codes/data.ts index 0b238a7d8..c9fc3ec6a 100644 --- a/src/lib/pages/recent-codes/data.ts +++ b/src/lib/pages/recent-codes/data.ts @@ -1,7 +1,8 @@ import { useMemo } from "react"; import type { PermissionFilterValue } from "lib/hooks"; -import { useCodeStore, usePermissionFilter, useSearchFilter } from "lib/hooks"; +import { usePermissionFilter, useSearchFilter } from "lib/hooks"; +import { useCodeStore } from "lib/providers/store"; import { useCodeListQuery } from "lib/services/codeService"; import type { CodeInfo } from "lib/types"; diff --git a/src/lib/pages/recent-codes/index.tsx b/src/lib/pages/recent-codes/index.tsx index 70e04b2f9..99c18859e 100644 --- a/src/lib/pages/recent-codes/index.tsx +++ b/src/lib/pages/recent-codes/index.tsx @@ -5,7 +5,7 @@ import type { ChangeEvent } from "react"; import { useEffect } from "react"; import { useForm } from "react-hook-form"; -import { FilterByPermission } from "lib/components/forms/FilterByPermission"; +import { FilterByPermission } from "lib/components/forms"; import InputWithIcon from "lib/components/InputWithIcon"; import type { PermissionFilterValue } from "lib/hooks"; import CodesTable from "lib/pages/codes/components/CodesTable"; diff --git a/src/lib/providers/store.tsx b/src/lib/providers/store.tsx index 090bcedfc..baea529b4 100644 --- a/src/lib/providers/store.tsx +++ b/src/lib/providers/store.tsx @@ -6,7 +6,7 @@ import { RootStore } from "lib/stores/root"; let store: RootStore; export const StoreContext = createContext(undefined); -export function useStore() { +function useStore() { const context = useContext(StoreContext); if (context === undefined) { throw new Error("useStore must be used within StoreProvider"); @@ -34,3 +34,18 @@ export function StoreProvider({ children }: { children: ReactNode }) { {children} ); } + +export function useCodeStore() { + const { codeStore } = useStore(); + return codeStore; +} + +export function useContractStore() { + const { contractStore } = useStore(); + return contractStore; +} + +export function usePublicProjectStore() { + const { publicProjectStore } = useStore(); + return publicProjectStore; +} diff --git a/src/lib/providers/tx-broadcast.tsx b/src/lib/providers/tx-broadcast.tsx index 440fe1565..9eca8e845 100644 --- a/src/lib/providers/tx-broadcast.tsx +++ b/src/lib/providers/tx-broadcast.tsx @@ -9,7 +9,7 @@ import { } from "react"; import type { Observable } from "rxjs"; -import { TxModal } from "lib/components/modal/tx"; +import { TxModal } from "lib/components/tx"; import type { TxResultRendering } from "lib/types"; interface TxBroadcast { From 2aec4c4040641dab7748449f0ddde1cf3bedd9a4 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Tue, 28 Feb 2023 13:10:49 +0700 Subject: [PATCH 4/9] fix: errors --- src/lib/components/ExplorerLink.tsx | 2 +- .../select-contract/ContractListTable.tsx | 3 +- src/lib/components/select-contract/index.ts | 2 + .../table/contracts/ContractsTableRow.tsx | 3 +- .../table/proposals/ProposalsTableRow.tsx | 2 +- .../components/CodeInfoSection.tsx | 2 +- .../components/CommandSection.tsx | 7 +-- .../components/InstantiateInfo.tsx | 2 +- .../tables/migration/MigrationRow.tsx | 2 +- src/lib/pages/contract-list/index.tsx | 3 +- src/lib/pages/contract-list/slug.tsx | 6 +-- src/lib/pages/execute/index.tsx | 3 +- .../home/components/RecentlyViewContracts.tsx | 52 +++++++++---------- .../table/code/PublicProjectCodeRow.tsx | 3 +- .../contract/PublicProjectContractRow.tsx | 3 +- src/lib/services/txQuery/useTxQuery.ts | 3 +- src/lib/utils/address.ts | 2 +- 17 files changed, 47 insertions(+), 53 deletions(-) diff --git a/src/lib/components/ExplorerLink.tsx b/src/lib/components/ExplorerLink.tsx index b82d9c812..904a3037d 100644 --- a/src/lib/components/ExplorerLink.tsx +++ b/src/lib/components/ExplorerLink.tsx @@ -7,7 +7,7 @@ import { getExplorerTxUrl, getProposalUrl, } from "lib/app-fns/explorer"; -import type { AddressReturnType } from "lib/hooks"; +import type { AddressReturnType } from "lib/app-provider"; import { AmpTrackMintscan } from "lib/services/amplitude"; import { truncate } from "lib/utils"; diff --git a/src/lib/components/select-contract/ContractListTable.tsx b/src/lib/components/select-contract/ContractListTable.tsx index 5968c8500..29720ae72 100644 --- a/src/lib/components/select-contract/ContractListTable.tsx +++ b/src/lib/components/select-contract/ContractListTable.tsx @@ -21,7 +21,7 @@ import { MdPerson, } from "react-icons/md"; -import { useInternalNavigate } from "lib/app-provider"; +import { useInternalNavigate, useGetAddressType } from "lib/app-provider"; import { AppLink } from "lib/components/AppLink"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { @@ -37,7 +37,6 @@ import { TableRowNoBorder, TagsCell, } from "lib/components/table"; -import { useGetAddressType } from "lib/hooks"; import { useAdminByContractAddresses } from "lib/services/contractService"; import type { ContractLocalInfo } from "lib/stores/contract"; import type { LVPair } from "lib/types"; diff --git a/src/lib/components/select-contract/index.ts b/src/lib/components/select-contract/index.ts index 896d9c9ad..a8df86c5c 100644 --- a/src/lib/components/select-contract/index.ts +++ b/src/lib/components/select-contract/index.ts @@ -1,5 +1,7 @@ export * from "./AllContractLists"; export * from "./ContractListCard"; export * from "./ContractListDetail"; +export * from "./ContractListReadOnlyTable"; +export * from "./ContractListTable"; export * from "./SelectContractAdmin"; export * from "./SelectContractInstantiator"; diff --git a/src/lib/components/table/contracts/ContractsTableRow.tsx b/src/lib/components/table/contracts/ContractsTableRow.tsx index 30904fe86..3447d7919 100644 --- a/src/lib/components/table/contracts/ContractsTableRow.tsx +++ b/src/lib/components/table/contracts/ContractsTableRow.tsx @@ -2,13 +2,12 @@ import { Flex, Text, Grid, IconButton, Box, chakra } from "@chakra-ui/react"; import { MdBookmark, MdBookmarkBorder } from "react-icons/md"; import { TableRow } from "../tableComponents"; -import { useInternalNavigate } from "lib/app-provider"; +import { useInternalNavigate, useGetAddressType } from "lib/app-provider"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { AddToOtherListModal, SaveContractDetailsModal, } from "lib/components/modal"; -import { useGetAddressType } from "lib/hooks"; import type { ContractInfo } from "lib/types"; import { RemarkOperation } from "lib/types"; import { dateFromNow, formatUTC } from "lib/utils"; diff --git a/src/lib/components/table/proposals/ProposalsTableRow.tsx b/src/lib/components/table/proposals/ProposalsTableRow.tsx index cb3f6b681..21a5a22fa 100644 --- a/src/lib/components/table/proposals/ProposalsTableRow.tsx +++ b/src/lib/components/table/proposals/ProposalsTableRow.tsx @@ -2,8 +2,8 @@ import type { GridProps } from "@chakra-ui/react"; import { Flex, Grid, Text } from "@chakra-ui/react"; import { TableRow } from "../tableComponents"; +import { useGetAddressType } from "lib/app-provider"; import { ExplorerLink } from "lib/components/ExplorerLink"; -import { useGetAddressType } from "lib/hooks"; import type { Proposal } from "lib/types"; import { ProposalStatus } from "lib/types"; import { dateFromNow, formatUTC } from "lib/utils"; diff --git a/src/lib/pages/code-details/components/CodeInfoSection.tsx b/src/lib/pages/code-details/components/CodeInfoSection.tsx index f780ef098..a88564b3e 100644 --- a/src/lib/pages/code-details/components/CodeInfoSection.tsx +++ b/src/lib/pages/code-details/components/CodeInfoSection.tsx @@ -2,10 +2,10 @@ import { Heading, Flex, Text, Box, Grid, Button, Icon } from "@chakra-ui/react"; import { useState } from "react"; import { FiChevronDown } from "react-icons/fi"; +import { useGetAddressType } from "lib/app-provider"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { LabelText } from "lib/components/LabelText"; import { PermissionChip } from "lib/components/PermissionChip"; -import { useGetAddressType } from "lib/hooks"; import type { CodeData, PermissionAddresses } from "lib/types"; import { dateFromNow, formatUTC, getAddressTypeText } from "lib/utils"; diff --git a/src/lib/pages/contract-details/components/CommandSection.tsx b/src/lib/pages/contract-details/components/CommandSection.tsx index 855d417d2..e24dcef23 100644 --- a/src/lib/pages/contract-details/components/CommandSection.tsx +++ b/src/lib/pages/contract-details/components/CommandSection.tsx @@ -1,12 +1,9 @@ import { ButtonGroup, Flex, Spinner, Text } from "@chakra-ui/react"; import { useRouter } from "next/router"; -import { - useExecuteCmds, - useInternalNavigate, - useQueryCmds, -} from "lib/app-provider"; +import { useInternalNavigate } from "lib/app-provider"; import { ContractCmdButton } from "lib/components/ContractCmdButton"; +import { useExecuteCmds, useQueryCmds } from "lib/hooks"; import type { ContractAddr } from "lib/types"; import { encode, getFirstQueryParam, jsonPrettify } from "lib/utils"; diff --git a/src/lib/pages/contract-details/components/InstantiateInfo.tsx b/src/lib/pages/contract-details/components/InstantiateInfo.tsx index 753579f39..bced543bb 100644 --- a/src/lib/pages/contract-details/components/InstantiateInfo.tsx +++ b/src/lib/pages/contract-details/components/InstantiateInfo.tsx @@ -1,9 +1,9 @@ import { Box, chakra, Divider, Flex, Text } from "@chakra-ui/react"; +import { useGetAddressType } from "lib/app-provider"; import { Copier } from "lib/components/copy"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { LabelText } from "lib/components/LabelText"; -import { useGetAddressType } from "lib/hooks"; import type { ContractData, Option } from "lib/types"; import { formatUTC, dateFromNow } from "lib/utils"; import { getAddressTypeText } from "lib/utils/address"; diff --git a/src/lib/pages/contract-details/components/tables/migration/MigrationRow.tsx b/src/lib/pages/contract-details/components/tables/migration/MigrationRow.tsx index 414862129..4fddd6362 100644 --- a/src/lib/pages/contract-details/components/tables/migration/MigrationRow.tsx +++ b/src/lib/pages/contract-details/components/tables/migration/MigrationRow.tsx @@ -1,9 +1,9 @@ import type { GridProps } from "@chakra-ui/react"; import { Flex, Grid, Text } from "@chakra-ui/react"; +import { useGetAddressType } from "lib/app-provider"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { TableRow, CodeNameCell } from "lib/components/table"; -import { useGetAddressType } from "lib/hooks"; import type { ContractMigrationHistory } from "lib/types"; import { RemarkOperation } from "lib/types"; import { dateFromNow, formatUTC } from "lib/utils"; diff --git a/src/lib/pages/contract-list/index.tsx b/src/lib/pages/contract-list/index.tsx index ae425ca9b..964bd5d1d 100644 --- a/src/lib/pages/contract-list/index.tsx +++ b/src/lib/pages/contract-list/index.tsx @@ -5,8 +5,9 @@ import { useEffect } from "react"; import { MdOutlineAdd } from "react-icons/md"; import { useInternalNavigate } from "lib/app-provider"; -import { CreateNewListModal, AllContractLists } from "lib/components/modal"; +import { CreateNewListModal } from "lib/components/modal"; import PageContainer from "lib/components/PageContainer"; +import { AllContractLists } from "lib/components/select-contract"; import { useInstantiatedMockInfoByMe } from "lib/model/contract"; import { useContractStore } from "lib/providers/store"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; diff --git a/src/lib/pages/contract-list/slug.tsx b/src/lib/pages/contract-list/slug.tsx index 6366e04aa..a1aa6ba7a 100644 --- a/src/lib/pages/contract-list/slug.tsx +++ b/src/lib/pages/contract-list/slug.tsx @@ -26,12 +26,12 @@ import { import { useInternalNavigate } from "lib/app-provider"; import { AppLink } from "lib/components/AppLink"; +import { EditListNameModal, RemoveListModal } from "lib/components/modal"; import { SaveNewContractModal } from "lib/components/modal/contract"; -import { EditListNameModal, RemoveListModal } from "lib/components/modal/list"; -import { ContractListDetail } from "lib/components/modal/select-contract"; +import { ContractListDetail } from "lib/components/select-contract"; import { INSTANTIATED_LIST_NAME, SAVED_LIST_NAME } from "lib/data"; -import { useContractStore } from "lib/hooks"; import { useInstantiatedByMe } from "lib/model/contract"; +import { useContractStore } from "lib/providers/store"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import { formatSlugName, getFirstQueryParam } from "lib/utils"; diff --git a/src/lib/pages/execute/index.tsx b/src/lib/pages/execute/index.tsx index 9660ceb42..c386eba7b 100644 --- a/src/lib/pages/execute/index.tsx +++ b/src/lib/pages/execute/index.tsx @@ -4,12 +4,13 @@ import type { Coin } from "@cosmjs/stargate"; import { useRouter } from "next/router"; import { useCallback, useEffect, useState } from "react"; -import { useExecuteCmds, useInternalNavigate } from "lib/app-provider"; +import { useInternalNavigate } from "lib/app-provider"; import { BackButton } from "lib/components/button"; import { ConnectWalletAlert } from "lib/components/ConnectWalletAlert"; import { ContractSelectSection } from "lib/components/ContractSelectSection"; import { LoadingOverlay } from "lib/components/LoadingOverlay"; import PageContainer from "lib/components/PageContainer"; +import { useExecuteCmds } from "lib/hooks"; import { AmpTrackToExecute } from "lib/services/amplitude"; import type { ContractAddr } from "lib/types"; import { diff --git a/src/lib/pages/home/components/RecentlyViewContracts.tsx b/src/lib/pages/home/components/RecentlyViewContracts.tsx index 63839d562..cb10875fc 100644 --- a/src/lib/pages/home/components/RecentlyViewContracts.tsx +++ b/src/lib/pages/home/components/RecentlyViewContracts.tsx @@ -1,6 +1,6 @@ import { Heading, Box, Flex, Text } from "@chakra-ui/react"; -import { ContractListTable } from "lib/components/modal/select-contract/ContractListTable"; +import { ContractListTable } from "lib/components/select-contract"; import type { Addr, ContractAddr } from "lib/types"; import { getCurrentDate } from "lib/utils"; @@ -49,29 +49,27 @@ const contracts = [ created: getCurrentDate(), }, ]; -export const RecentlyViewContracts = () => { - return ( - - - Recently Viewed Contracts - - {contracts && contracts.length ? ( - - ) : ( - - - Your recently viewed smart contracts will display here - - - )} - - ); -}; +export const RecentlyViewContracts = () => ( + + + Recently Viewed Contracts + + {contracts && contracts.length ? ( + + ) : ( + + + Your recently viewed smart contracts will display here + + + )} + +); diff --git a/src/lib/pages/public-project/components/table/code/PublicProjectCodeRow.tsx b/src/lib/pages/public-project/components/table/code/PublicProjectCodeRow.tsx index 20dc0daaa..9fbd94279 100644 --- a/src/lib/pages/public-project/components/table/code/PublicProjectCodeRow.tsx +++ b/src/lib/pages/public-project/components/table/code/PublicProjectCodeRow.tsx @@ -1,13 +1,12 @@ import { HStack, Grid, Text } from "@chakra-ui/react"; import { useWallet } from "@cosmos-kit/react"; -import { useInternalNavigate } from "lib/app-provider"; +import { useInternalNavigate, getAddressTypeByLength } from "lib/app-provider"; import { InstantiateButton } from "lib/components/button"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { SaveOrRemoveCodeModal } from "lib/components/modal"; import { PermissionChip } from "lib/components/PermissionChip"; import { TableRowNoBorder } from "lib/components/table"; -import { getAddressTypeByLength } from "lib/hooks"; import type { PublicCodeInfo } from "./PublicProjectCodeTable"; diff --git a/src/lib/pages/public-project/components/table/contract/PublicProjectContractRow.tsx b/src/lib/pages/public-project/components/table/contract/PublicProjectContractRow.tsx index e62efb068..0eef51874 100644 --- a/src/lib/pages/public-project/components/table/contract/PublicProjectContractRow.tsx +++ b/src/lib/pages/public-project/components/table/contract/PublicProjectContractRow.tsx @@ -12,7 +12,7 @@ import { import { useWallet } from "@cosmos-kit/react"; import { MdBookmark, MdBookmarkBorder } from "react-icons/md"; -import { useInternalNavigate } from "lib/app-provider"; +import { useInternalNavigate, getAddressTypeByLength } from "lib/app-provider"; import { AppLink } from "lib/components/AppLink"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { @@ -20,7 +20,6 @@ import { SaveContractDetailsModal, } from "lib/components/modal"; import { TableRowNoBorder } from "lib/components/table"; -import { getAddressTypeByLength } from "lib/hooks"; import type { PublicContractInfo } from "./PublicProjectContractTable"; diff --git a/src/lib/services/txQuery/useTxQuery.ts b/src/lib/services/txQuery/useTxQuery.ts index c161bd3bb..6e5e1b324 100644 --- a/src/lib/services/txQuery/useTxQuery.ts +++ b/src/lib/services/txQuery/useTxQuery.ts @@ -2,8 +2,7 @@ import type { UseQueryResult } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query"; import { useCallback } from "react"; -import { useCelatoneApp } from "lib/app-provider"; -import { useGetAddressType } from "lib/hooks"; +import { useCelatoneApp, useGetAddressType } from "lib/app-provider"; import type { TxFilters, Message, diff --git a/src/lib/utils/address.ts b/src/lib/utils/address.ts index 610962b5d..22b4d441c 100644 --- a/src/lib/utils/address.ts +++ b/src/lib/utils/address.ts @@ -1,4 +1,4 @@ -import type { AddressReturnType } from "lib/hooks"; +import type { AddressReturnType } from "lib/app-provider"; export const getAddressTypeText = (addressType: AddressReturnType) => { switch (addressType) { From 4c8ff5eb0ee4ae01f6269deedf220e4cb7b7ffc8 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Tue, 28 Feb 2023 13:36:13 +0700 Subject: [PATCH 5/9] fix: misc --- src/lib/components/button/IconButton.tsx | 54 ++++----- src/lib/components/button/index.ts | 6 +- src/lib/components/forms/AssetInput.tsx | 52 ++++---- .../components/forms/FilterByPermission.tsx | 24 ++-- src/lib/components/forms/SelectInput.tsx | 34 +++--- src/lib/components/forms/TextAreaInput.tsx | 62 +++++----- src/lib/components/forms/TextInput.tsx | 82 ++++++------- src/lib/components/json/ViewFullMsgButton.tsx | 64 +++++----- .../components/modal/code/SaveOrEditCode.tsx | 7 +- .../modal/code/SaveOrRemoveCode.tsx | 7 +- .../components/table/proposals/StatusChip.tsx | 12 +- src/lib/components/wallet/WalletConnect.tsx | 38 +++--- src/lib/hooks/useCodeFilter.ts | 5 +- .../pages/home/components/PastTransaction.tsx | 58 +++++---- src/lib/pages/home/components/QuickMenu.tsx | 114 +++++++++--------- .../migrate/components/MigrateOptions.tsx | 42 +++---- .../components/DetailHeader.tsx | 114 +++++++++--------- src/lib/utils/funds.ts | 5 +- src/lib/utils/isDecimalNumber.ts | 5 +- src/lib/utils/number.ts | 5 +- 20 files changed, 377 insertions(+), 413 deletions(-) diff --git a/src/lib/components/button/IconButton.tsx b/src/lib/components/button/IconButton.tsx index 6b99f31f8..d5f6c862d 100644 --- a/src/lib/components/button/IconButton.tsx +++ b/src/lib/components/button/IconButton.tsx @@ -10,32 +10,30 @@ interface IconButtonProps { const iconHover = "pebble.500"; -export const IconButton = ({ href, icon, onClick }: IconButtonProps) => { - return ( - - ); -}; + + + +); diff --git a/src/lib/components/button/index.ts b/src/lib/components/button/index.ts index 816dc5140..87a80d128 100644 --- a/src/lib/components/button/index.ts +++ b/src/lib/components/button/index.ts @@ -1,8 +1,8 @@ +export * from "./AdminButton"; export * from "./BackButton"; export * from "./ConnectWallet"; +export * from "./IconButton"; export * from "./InstantiateButton"; -export * from "./ShowMoreButton"; -export * from "./AdminButton"; export * from "./RedoButton"; export * from "./ResendButton"; -export * from "./IconButton"; +export * from "./ShowMoreButton"; diff --git a/src/lib/components/forms/AssetInput.tsx b/src/lib/components/forms/AssetInput.tsx index afd5d0564..902f8c59d 100644 --- a/src/lib/components/forms/AssetInput.tsx +++ b/src/lib/components/forms/AssetInput.tsx @@ -25,31 +25,29 @@ export const AssetInput = ({ amountInput: AmountInput, assetOptions, initialSelected, -}: AssetInputProps) => { - return ( - - ( + + + {AmountInput} + - - ); -}; + + +); diff --git a/src/lib/components/forms/FilterByPermission.tsx b/src/lib/components/forms/FilterByPermission.tsx index 77dc0c0b2..07053f498 100644 --- a/src/lib/components/forms/FilterByPermission.tsx +++ b/src/lib/components/forms/FilterByPermission.tsx @@ -46,16 +46,14 @@ const options: PermissionOption[] = [ export const FilterByPermission = ({ setPermissionValue, initialSelected, -}: FilterByPermissionProps) => { - return ( - - - formLabel="Filter by Instantiate Permission" - options={options} - onChange={setPermissionValue} - placeholder="Select" - initialSelected={initialSelected} - /> - - ); -}; +}: FilterByPermissionProps) => ( + + + formLabel="Filter by Instantiate Permission" + options={options} + onChange={setPermissionValue} + placeholder="Select" + initialSelected={initialSelected} + /> + +); diff --git a/src/lib/components/forms/SelectInput.tsx b/src/lib/components/forms/SelectInput.tsx index 8b8a5d679..dede39240 100644 --- a/src/lib/components/forms/SelectInput.tsx +++ b/src/lib/components/forms/SelectInput.tsx @@ -42,24 +42,22 @@ interface SelectItemProps { disabled: boolean; } -const SelectItem = ({ children, onSelect, disabled }: SelectItemProps) => { - return ( - - {children} - - ); -}; +const SelectItem = ({ children, onSelect, disabled }: SelectItemProps) => ( + + {children} + +); export const SelectInput = ({ formLabel, diff --git a/src/lib/components/forms/TextAreaInput.tsx b/src/lib/components/forms/TextAreaInput.tsx index 534246cb4..519e106b5 100644 --- a/src/lib/components/forms/TextAreaInput.tsx +++ b/src/lib/components/forms/TextAreaInput.tsx @@ -33,35 +33,33 @@ export const TextAreaInput = ({ error, status, ...componentProps -}: TextAreaProps) => { - return ( - - {label && ( - - {label} - - )} -