From 9f41bf21e66e7253a31f12afcdbed8e3ad8e0055 Mon Sep 17 00:00:00 2001 From: sohrab <4444588+sohrab-@users.noreply.github.com> Date: Fri, 23 Dec 2022 14:52:17 +1100 Subject: [PATCH] refactor: switch to non-relative import paths --- .vscode/settings.json | 1 + src/App.tsx | 22 ++++++++-------- src/coders/borsh.ts | 4 +-- src/coders/buffer-layout.ts | 4 +-- src/coders/index.ts | 2 +- src/components/ImportModal.tsx | 2 +- src/components/ShareModal.tsx | 12 ++++----- src/components/client/Instruction.tsx | 18 ++++++------- src/components/client/InstructionHeader.tsx | 12 ++++----- src/components/client/Instructions.tsx | 12 ++++----- src/components/client/Transaction.tsx | 6 ++--- src/components/client/TransactionHeader.tsx | 25 ++++++++---------- src/components/client/accounts/Account.tsx | 24 ++++++++--------- .../client/accounts/AccountInput.tsx | 16 ++++++------ .../client/accounts/AccountTypeButton.tsx | 6 ++--- src/components/client/accounts/Accounts.tsx | 12 ++++----- .../client/accounts/AirdropButton.tsx | 12 ++++----- .../accounts/type-configs/PdaTypeConfig.tsx | 4 +-- src/components/client/data/Data.tsx | 6 ++--- src/components/client/data/RawData.tsx | 4 +-- .../client/data/editor/DataEditor.tsx | 14 +++++----- .../client/data/editor/DataField.tsx | 23 +++++++--------- .../client/results/BalanceTable.tsx | 8 +++--- src/components/client/results/ProgramLogs.tsx | 4 +-- src/components/client/results/Results.tsx | 20 +++++++------- src/components/client/results/Signature.tsx | 8 +++--- src/components/common/AccountAutoComplete.tsx | 16 +++++------- src/components/common/Description.tsx | 2 +- src/components/common/DragHandle.tsx | 2 +- src/components/common/ExplorerButton.tsx | 6 ++--- src/components/common/Numbering.tsx | 2 +- src/components/common/RpcEndpointMenu.tsx | 6 ++--- src/components/common/Sortable.tsx | 2 +- src/components/common/Web3Provider.tsx | 4 +-- src/components/header/Examples.tsx | 14 +++++----- src/components/header/Header.tsx | 9 +++---- src/components/info/InfoModal.tsx | 10 +++---- src/components/info/Privacy.tsx | 2 +- src/components/options/GeneralOptions.tsx | 10 +++---- src/components/options/Options.tsx | 17 +++++------- src/components/options/RpcEndpointOptions.tsx | 10 +++---- src/components/options/TransactionOptions.tsx | 10 +++---- .../options/fields/RpcEndpointOption.tsx | 10 +++---- src/components/palette/ImportTransaction.tsx | 16 ++++++------ src/components/palette/Palette.tsx | 2 +- .../palette/import/AnchorJsonImport.tsx | 4 +-- .../palette/import/AnchorProgramIdImport.tsx | 16 ++++++------ .../palette/import/ShareJsonImport.tsx | 4 +-- .../palette/import/ShareUrlImport.tsx | 4 +-- .../palette/import/TransactionIdImport.tsx | 14 +++++----- .../palette/preview/AccountSummary.tsx | 2 +- .../palette/preview/DataPreview.tsx | 5 +--- .../palette/preview/InstructionPreview.tsx | 18 ++++++------- src/components/palette/preview/Preview.tsx | 14 +++++----- src/hooks/useAccount.ts | 8 +++--- src/hooks/useAccountType.ts | 10 +++---- src/hooks/useConfigStore.ts | 4 +-- src/hooks/useGetWeb3Transaction.ts | 6 ++--- src/hooks/useImportFromUrl.ts | 26 +++++++++---------- src/hooks/useInstruction.ts | 14 +++++----- src/hooks/useInstructionDataField.ts | 12 +++------ src/hooks/useSendWeb3Transaction.ts | 12 ++++----- src/hooks/useSessionStore.ts | 10 +++---- src/hooks/useWeb3Account.ts | 12 ++++----- src/hooks/useWeb3Connection.ts | 2 +- src/index.tsx | 4 +-- src/library/examples.ts | 2 +- src/library/programs.ts | 4 +-- src/mappers/external-to-internal.ts | 10 +++---- src/mappers/external-to-preview.ts | 6 ++--- src/mappers/external-to-protobuf.ts | 18 ++++++------- src/mappers/idl-to-preview.ts | 8 +++--- src/mappers/internal-to-external.ts | 6 ++--- src/mappers/internal-to-web3js.ts | 10 +++---- src/mappers/preview-to-internal.ts | 8 +++--- src/mappers/protobuf-to-external.ts | 18 ++++++------- src/mappers/protobuf.ts | 4 +-- src/mappers/web3js-to-internal.ts | 2 +- src/mappers/web3js-to-preview.ts | 12 +++------ src/types/README.md | 1 + src/utils/internal.ts | 6 ++--- src/utils/sortable.ts | 2 +- src/utils/state.ts | 10 +++---- src/utils/ui-constants.ts | 4 +-- tsconfig.json | 3 ++- vite.config.ts | 9 +++++-- 86 files changed, 379 insertions(+), 396 deletions(-) create mode 100644 src/types/README.md diff --git a/.vscode/settings.json b/.vscode/settings.json index 5d126b6..6d5b89e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -15,4 +15,5 @@ "source.organizeImports": true }, }, + "typescript.preferences.importModuleSpecifier": "non-relative" } \ No newline at end of file diff --git a/src/App.tsx b/src/App.tsx index e0e3853..7c3e926 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -8,19 +8,19 @@ import { Hide, Show, } from "@chakra-ui/react"; +import { Transaction } from "components/client/Transaction"; +import { Web3Provider } from "components/common/Web3Provider"; +import { Footer } from "components/Footer"; +import { Header } from "components/header/Header"; +import { ImportModal } from "components/ImportModal"; +import { InfoModal } from "components/info/InfoModal"; +import { Options } from "components/options/Options"; +import { Palette } from "components/palette/Palette"; +import { ShareModal } from "components/ShareModal"; +import { useSessionStoreWithoutUndo } from "hooks/useSessionStore"; import React from "react"; -import { Transaction } from "./components/client/Transaction"; -import { Web3Provider } from "./components/common/Web3Provider"; -import { Footer } from "./components/Footer"; -import { Header } from "./components/header/Header"; -import { ImportModal } from "./components/ImportModal"; -import { InfoModal } from "./components/info/InfoModal"; -import { Options } from "./components/options/Options"; -import { Palette } from "./components/palette/Palette"; -import { ShareModal } from "./components/ShareModal"; -import { useSessionStoreWithoutUndo } from "./hooks/useSessionStore"; -import theme from "./theme"; +import theme from "theme"; import "@solana/wallet-adapter-react-ui/styles.css"; diff --git a/src/coders/borsh.ts b/src/coders/borsh.ts index cf54795..c5a3149 100644 --- a/src/coders/borsh.ts +++ b/src/coders/borsh.ts @@ -1,7 +1,7 @@ import * as Borsh from "@project-serum/borsh"; import { PublicKey } from "@solana/web3.js"; -import { Coder } from "."; -import { IInstrctionDataField } from "../types/internal"; +import { Coder } from "coders"; +import { IInstrctionDataField } from "types/internal"; export class BorshCoder implements Coder { encode(fields: IInstrctionDataField[]): Buffer { diff --git a/src/coders/buffer-layout.ts b/src/coders/buffer-layout.ts index ce2bafd..0c797bd 100644 --- a/src/coders/buffer-layout.ts +++ b/src/coders/buffer-layout.ts @@ -1,7 +1,7 @@ import * as BufferLayout from "@solana/buffer-layout"; import { PublicKey } from "@solana/web3.js"; -import { Coder, rustString } from "."; -import { IInstrctionDataField } from "../types/internal"; +import { Coder, rustString } from "coders"; +import { IInstrctionDataField } from "types/internal"; export class BufferLayoutCoder implements Coder { encode(fields: IInstrctionDataField[]): Buffer { diff --git a/src/coders/index.ts b/src/coders/index.ts index 57c305a..9541526 100644 --- a/src/coders/index.ts +++ b/src/coders/index.ts @@ -1,5 +1,5 @@ import * as BufferLayout from "@solana/buffer-layout"; -import { IInstrctionDataField } from "../types/internal"; +import { IInstrctionDataField } from "types/internal"; export interface Coder { encode(fields: IInstrctionDataField[]): Buffer; diff --git a/src/components/ImportModal.tsx b/src/components/ImportModal.tsx index a721ff9..5eee6d4 100644 --- a/src/components/ImportModal.tsx +++ b/src/components/ImportModal.tsx @@ -9,7 +9,7 @@ import { Text, VStack, } from "@chakra-ui/react"; -import { useImportFromUrl } from "../hooks/useImportFromUrl"; +import { useImportFromUrl } from "hooks/useImportFromUrl"; export const ImportModal: React.FC = () => { const { isLoading, status, cancel } = useImportFromUrl(); diff --git a/src/components/ShareModal.tsx b/src/components/ShareModal.tsx index ef57917..a89434b 100644 --- a/src/components/ShareModal.tsx +++ b/src/components/ShareModal.tsx @@ -27,15 +27,15 @@ import { Tooltip, useClipboard, } from "@chakra-ui/react"; -import { useEffect, useState } from "react"; -import { FaGithub } from "react-icons/fa"; +import { CopyButton } from "components/common/CopyButton"; import { useShallowSessionStoreWithoutUndo, useShallowSessionStoreWithUndo, -} from "../hooks/useSessionStore"; -import { mapITransactionExtToProtobuf } from "../mappers/external-to-protobuf"; -import { mapITransactionToTransactionExt } from "../mappers/internal-to-external"; -import { CopyButton } from "./common/CopyButton"; +} from "hooks/useSessionStore"; +import { mapITransactionExtToProtobuf } from "mappers/external-to-protobuf"; +import { mapITransactionToTransactionExt } from "mappers/internal-to-external"; +import { useEffect, useState } from "react"; +import { FaGithub } from "react-icons/fa"; export const ShareModal: React.FC = () => { const [isOpen, set] = useShallowSessionStoreWithoutUndo((state) => [ diff --git a/src/components/client/Instruction.tsx b/src/components/client/Instruction.tsx index a06f9d4..dbbecf4 100644 --- a/src/components/client/Instruction.tsx +++ b/src/components/client/Instruction.tsx @@ -15,17 +15,17 @@ import { Tooltip, useColorModeValue, } from "@chakra-ui/react"; +import { Accounts } from "components/client/accounts/Accounts"; +import { Data } from "components/client/data/Data"; +import { InstructionHeader } from "components/client/InstructionHeader"; +import { AccountAutoComplete } from "components/common/AccountAutoComplete"; +import { Description } from "components/common/Description"; +import { ExplorerButton } from "components/common/ExplorerButton"; +import { useInstruction } from "hooks/useInstruction"; +import { useSessionStoreWithUndo } from "hooks/useSessionStore"; +import { useWeb3Account } from "hooks/useWeb3Account"; import React from "react"; import { FaAnchor, FaRocket } from "react-icons/fa"; -import { useInstruction } from "../../hooks/useInstruction"; -import { useSessionStoreWithUndo } from "../../hooks/useSessionStore"; -import { useWeb3Account } from "../../hooks/useWeb3Account"; -import { AccountAutoComplete } from "../common/AccountAutoComplete"; -import { Description } from "../common/Description"; -import { ExplorerButton } from "../common/ExplorerButton"; -import { Accounts } from "./accounts/Accounts"; -import { Data } from "./data/Data"; -import { InstructionHeader } from "./InstructionHeader"; export const Instruction: React.FC<{ index: number }> = ({ index }) => { const rpcEndpoint = useSessionStoreWithUndo((state) => state.rpcEndpoint); diff --git a/src/components/client/InstructionHeader.tsx b/src/components/client/InstructionHeader.tsx index 3f289c8..500b26f 100644 --- a/src/components/client/InstructionHeader.tsx +++ b/src/components/client/InstructionHeader.tsx @@ -15,6 +15,11 @@ import { Tooltip, } from "@chakra-ui/react"; import { arrayMove } from "@dnd-kit/sortable"; +import { DragHandle } from "components/common/DragHandle"; +import { EditableName } from "components/common/EditableName"; +import { Numbering } from "components/common/Numbering"; +import { useInstruction } from "hooks/useInstruction"; +import { useShallowSessionStoreWithUndo } from "hooks/useSessionStore"; import React from "react"; import { FaAngleDoubleDown, @@ -24,12 +29,7 @@ import { FaEye, FaEyeSlash, } from "react-icons/fa"; -import { useInstruction } from "../../hooks/useInstruction"; -import { useShallowSessionStoreWithUndo } from "../../hooks/useSessionStore"; -import { removeFrom } from "../../utils/sortable"; -import { DragHandle } from "../common/DragHandle"; -import { EditableName } from "../common/EditableName"; -import { Numbering } from "../common/Numbering"; +import { removeFrom } from "utils/sortable"; export const InstructionHeader: React.FC<{ index: number }> = ({ index }) => { const { id, useShallowGet, update, reset } = useInstruction(); diff --git a/src/components/client/Instructions.tsx b/src/components/client/Instructions.tsx index 785e8df..3a9fa54 100644 --- a/src/components/client/Instructions.tsx +++ b/src/components/client/Instructions.tsx @@ -7,13 +7,13 @@ import { Tooltip, useColorModeValue, } from "@chakra-ui/react"; +import { Instruction } from "components/client/Instruction"; +import { Sortable } from "components/common/Sortable"; +import { useShallowSessionStoreWithUndo } from "hooks/useSessionStore"; import React from "react"; -import { useShallowSessionStoreWithUndo } from "../../hooks/useSessionStore"; -import { IID } from "../../types/sortable"; -import { newInstruction } from "../../utils/internal"; -import { addTo } from "../../utils/sortable"; -import { Sortable } from "../common/Sortable"; -import { Instruction } from "./Instruction"; +import { IID } from "types/sortable"; +import { newInstruction } from "utils/internal"; +import { addTo } from "utils/sortable"; export const InstructionContext = React.createContext(""); diff --git a/src/components/client/Transaction.tsx b/src/components/client/Transaction.tsx index 2294b26..f772eac 100644 --- a/src/components/client/Transaction.tsx +++ b/src/components/client/Transaction.tsx @@ -1,8 +1,8 @@ import { Box, Divider, Grid } from "@chakra-ui/react"; +import { Instructions } from "components/client/Instructions"; +import { Results } from "components/client/results/Results"; +import { TransactionHeader } from "components/client/TransactionHeader"; import React, { useRef } from "react"; -import { Instructions } from "./Instructions"; -import { Results } from "./results/Results"; -import { TransactionHeader } from "./TransactionHeader"; export const Transaction: React.FC = () => { // used for scrolling to results diff --git a/src/components/client/TransactionHeader.tsx b/src/components/client/TransactionHeader.tsx index af7357a..8a82364 100644 --- a/src/components/client/TransactionHeader.tsx +++ b/src/components/client/TransactionHeader.tsx @@ -16,6 +16,16 @@ import { Tooltip, } from "@chakra-ui/react"; import { useWallet } from "@solana/wallet-adapter-react"; +import { Description } from "components/common/Description"; +import { EditableName } from "components/common/EditableName"; +import { RpcEndpointMenu } from "components/common/RpcEndpointMenu"; +import { ToggleIconButton } from "components/common/ToggleIconButton"; +import { useConfigStore, useShallowConfigStore } from "hooks/useConfigStore"; +import { useSendWeb3Transaction } from "hooks/useSendWeb3Transaction"; +import { + useShallowSessionStoreWithoutUndo, + useShallowSessionStoreWithUndo, +} from "hooks/useSessionStore"; import React, { useEffect } from "react"; import { FaCompress, @@ -27,20 +37,7 @@ import { FaPlay, FaShareAlt, } from "react-icons/fa"; -import { - useConfigStore, - useShallowConfigStore, -} from "../../hooks/useConfigStore"; -import { useSendWeb3Transaction } from "../../hooks/useSendWeb3Transaction"; -import { - useShallowSessionStoreWithoutUndo, - useShallowSessionStoreWithUndo, -} from "../../hooks/useSessionStore"; -import { DEFAULT_TRANSACTION_RUN, EMPTY_TRANSACTION } from "../../utils/state"; -import { Description } from "../common/Description"; -import { EditableName } from "../common/EditableName"; -import { RpcEndpointMenu } from "../common/RpcEndpointMenu"; -import { ToggleIconButton } from "../common/ToggleIconButton"; +import { DEFAULT_TRANSACTION_RUN, EMPTY_TRANSACTION } from "utils/state"; export const TransactionHeader: React.FC<{ resultsRef: React.RefObject; diff --git a/src/components/client/accounts/Account.tsx b/src/components/client/accounts/Account.tsx index d14b14e..480a7b7 100644 --- a/src/components/client/accounts/Account.tsx +++ b/src/components/client/accounts/Account.tsx @@ -9,20 +9,20 @@ import { useBreakpointValue, Wrap, } from "@chakra-ui/react"; +import { AccountInput } from "components/client/accounts/AccountInput"; +import { PdaTypeConfig } from "components/client/accounts/type-configs/PdaTypeConfig"; +import { Description } from "components/common/Description"; +import { DragHandle } from "components/common/DragHandle"; +import { EditableName } from "components/common/EditableName"; +import { Numbering } from "components/common/Numbering"; +import { ToggleIconButton } from "components/common/ToggleIconButton"; +import { useAccount } from "hooks/useAccount"; +import { useAccountType } from "hooks/useAccountType"; +import { useInstruction } from "hooks/useInstruction"; +import { useShallowSessionStoreWithUndo } from "hooks/useSessionStore"; import React from "react"; import { FaFeather, FaICursor } from "react-icons/fa"; -import { useAccount } from "../../../hooks/useAccount"; -import { useAccountType } from "../../../hooks/useAccountType"; -import { useInstruction } from "../../../hooks/useInstruction"; -import { useShallowSessionStoreWithUndo } from "../../../hooks/useSessionStore"; -import { removeFrom } from "../../../utils/sortable"; -import { Description } from "../../common/Description"; -import { DragHandle } from "../../common/DragHandle"; -import { EditableName } from "../../common/EditableName"; -import { Numbering } from "../../common/Numbering"; -import { ToggleIconButton } from "../../common/ToggleIconButton"; -import { AccountInput } from "./AccountInput"; -import { PdaTypeConfig } from "./type-configs/PdaTypeConfig"; +import { removeFrom } from "utils/sortable"; export const Account: React.FC<{ index: number; diff --git a/src/components/client/accounts/AccountInput.tsx b/src/components/client/accounts/AccountInput.tsx index 91271d1..8653ac5 100644 --- a/src/components/client/accounts/AccountInput.tsx +++ b/src/components/client/accounts/AccountInput.tsx @@ -6,16 +6,16 @@ import { InputRightElement, Tooltip, } from "@chakra-ui/react"; +import { AccountTypeButton } from "components/client/accounts/AccountTypeButton"; +import { AirdropButton } from "components/client/accounts/AirdropButton"; +import { AccountAutoComplete } from "components/common/AccountAutoComplete"; +import { ExplorerButton } from "components/common/ExplorerButton"; +import { useAccount } from "hooks/useAccount"; +import { useAccountType } from "hooks/useAccountType"; +import { useSessionStoreWithUndo } from "hooks/useSessionStore"; import React from "react"; import { FaMagic } from "react-icons/fa"; -import { useAccount } from "../../../hooks/useAccount"; -import { useAccountType } from "../../../hooks/useAccountType"; -import { useSessionStoreWithUndo } from "../../../hooks/useSessionStore"; -import { isValidPublicKey } from "../../../utils/web3js"; -import { AccountAutoComplete } from "../../common/AccountAutoComplete"; -import { ExplorerButton } from "../../common/ExplorerButton"; -import { AccountTypeButton } from "./AccountTypeButton"; -import { AirdropButton } from "./AirdropButton"; +import { isValidPublicKey } from "utils/web3js"; export const AccountInput: React.FC = () => { const { useGet, update } = useAccount(); diff --git a/src/components/client/accounts/AccountTypeButton.tsx b/src/components/client/accounts/AccountTypeButton.tsx index a5aefb3..5a2b554 100644 --- a/src/components/client/accounts/AccountTypeButton.tsx +++ b/src/components/client/accounts/AccountTypeButton.tsx @@ -9,6 +9,8 @@ import { Portal, Tooltip, } from "@chakra-ui/react"; +import { useAccount } from "hooks/useAccount"; +import { useAccountType } from "hooks/useAccountType"; import { FaCog, FaCoins, @@ -18,9 +20,7 @@ import { FaRobot, FaWallet, } from "react-icons/fa"; -import { useAccount } from "../../../hooks/useAccount"; -import { useAccountType } from "../../../hooks/useAccountType"; -import { AccountType } from "../../../types/internal"; +import { AccountType } from "types/internal"; const TYPES: AccountType[] = [ "wallet", diff --git a/src/components/client/accounts/Accounts.tsx b/src/components/client/accounts/Accounts.tsx index adf8a84..d85e153 100644 --- a/src/components/client/accounts/Accounts.tsx +++ b/src/components/client/accounts/Accounts.tsx @@ -11,13 +11,13 @@ import { Tooltip, useColorModeValue, } from "@chakra-ui/react"; +import { Account } from "components/client/accounts/Account"; +import { Sortable } from "components/common/Sortable"; +import { useInstruction } from "hooks/useInstruction"; import React from "react"; -import { useInstruction } from "../../../hooks/useInstruction"; -import { IID } from "../../../types/sortable"; -import { newAccount } from "../../../utils/internal"; -import { addTo } from "../../../utils/sortable"; -import { Sortable } from "../../common/Sortable"; -import { Account } from "./Account"; +import { IID } from "types/sortable"; +import { newAccount } from "utils/internal"; +import { addTo } from "utils/sortable"; export const AccountContext = React.createContext<{ id: IID | number; diff --git a/src/components/client/accounts/AirdropButton.tsx b/src/components/client/accounts/AirdropButton.tsx index d7abcba..7be71d6 100644 --- a/src/components/client/accounts/AirdropButton.tsx +++ b/src/components/client/accounts/AirdropButton.tsx @@ -30,14 +30,14 @@ import { VStack, } from "@chakra-ui/react"; import { LAMPORTS_PER_SOL, PublicKey } from "@solana/web3.js"; +import { ExplorerButton } from "components/common/ExplorerButton"; +import { useGetWeb3Transaction } from "hooks/useGetWeb3Transaction"; +import { useSessionStoreWithUndo } from "hooks/useSessionStore"; +import { useWeb3Connection } from "hooks/useWeb3Connection"; import React, { useRef, useState } from "react"; import { FaParachuteBox } from "react-icons/fa"; -import { useGetWeb3Transaction } from "../../../hooks/useGetWeb3Transaction"; -import { useSessionStoreWithUndo } from "../../../hooks/useSessionStore"; -import { useWeb3Connection } from "../../../hooks/useWeb3Connection"; -import { IPubKey } from "../../../types/internal"; -import { short, toLamports } from "../../../utils/web3js"; -import { ExplorerButton } from "../../common/ExplorerButton"; +import { IPubKey } from "types/internal"; +import { short, toLamports } from "utils/web3js"; export const AirdropButton: React.FC<{ accountPubkey: IPubKey }> = ({ accountPubkey, diff --git a/src/components/client/accounts/type-configs/PdaTypeConfig.tsx b/src/components/client/accounts/type-configs/PdaTypeConfig.tsx index 67f7797..25da6d9 100644 --- a/src/components/client/accounts/type-configs/PdaTypeConfig.tsx +++ b/src/components/client/accounts/type-configs/PdaTypeConfig.tsx @@ -20,9 +20,9 @@ import { Text, Wrap, } from "@chakra-ui/react"; +import { useAccount } from "hooks/useAccount"; +import { useAccountType } from "hooks/useAccountType"; import React, { useRef, useState } from "react"; -import { useAccount } from "../../../../hooks/useAccount"; -import { useAccountType } from "../../../../hooks/useAccountType"; // TODO not sophisticated enough, we need to handle many types of numbers, basically Buffer.write*() diff --git a/src/components/client/data/Data.tsx b/src/components/client/data/Data.tsx index 191c739..3414842 100644 --- a/src/components/client/data/Data.tsx +++ b/src/components/client/data/Data.tsx @@ -11,10 +11,10 @@ import { Tabs, useColorModeValue, } from "@chakra-ui/react"; +import { DataEditor } from "components/client/data/editor/DataEditor"; +import { RawData } from "components/client/data/RawData"; +import { useInstruction } from "hooks/useInstruction"; import React from "react"; -import { useInstruction } from "../../../hooks/useInstruction"; -import { DataEditor } from "./editor/DataEditor"; -import { RawData } from "./RawData"; export const Data: React.FC = () => { const { isAnchor, useGet, update } = useInstruction(); diff --git a/src/components/client/data/RawData.tsx b/src/components/client/data/RawData.tsx index 09e0409..e9e8cfa 100644 --- a/src/components/client/data/RawData.tsx +++ b/src/components/client/data/RawData.tsx @@ -9,9 +9,9 @@ import { useToast, } from "@chakra-ui/react"; import bs58 from "bs58"; +import { Description } from "components/common/Description"; +import { useInstruction } from "hooks/useInstruction"; import React from "react"; -import { useInstruction } from "../../../hooks/useInstruction"; -import { Description } from "../../common/Description"; export const RawData: React.FC = () => { const { useShallowGet, update } = useInstruction(); diff --git a/src/components/client/data/editor/DataEditor.tsx b/src/components/client/data/editor/DataEditor.tsx index ecbb937..e79ffc9 100644 --- a/src/components/client/data/editor/DataEditor.tsx +++ b/src/components/client/data/editor/DataEditor.tsx @@ -7,15 +7,15 @@ import { Tooltip, useColorModeValue, } from "@chakra-ui/react"; +import { DataField } from "components/client/data/editor/DataField"; +import { Sortable } from "components/common/Sortable"; +import { useInstruction } from "hooks/useInstruction"; import { WritableDraft } from "immer/dist/internal"; import React from "react"; -import { useInstruction } from "../../../../hooks/useInstruction"; -import { DataFormat, IInstrctionDataField } from "../../../../types/internal"; -import { IID, SortableCollection } from "../../../../types/sortable"; -import { newDataField } from "../../../../utils/internal"; -import { addTo } from "../../../../utils/sortable"; -import { Sortable } from "../../../common/Sortable"; -import { DataField } from "./DataField"; +import { DataFormat, IInstrctionDataField } from "types/internal"; +import { IID, SortableCollection } from "types/sortable"; +import { newDataField } from "utils/internal"; +import { addTo } from "utils/sortable"; export const InstructionDataFieldContext = React.createContext(""); diff --git a/src/components/client/data/editor/DataField.tsx b/src/components/client/data/editor/DataField.tsx index 40ef8bf..128e1ac 100644 --- a/src/components/client/data/editor/DataField.tsx +++ b/src/components/client/data/editor/DataField.tsx @@ -14,24 +14,21 @@ import { Tooltip, useBreakpointValue, } from "@chakra-ui/react"; +import { Description } from "components/common/Description"; +import { DragHandle } from "components/common/DragHandle"; +import { EditableName } from "components/common/EditableName"; +import { Numbering } from "components/common/Numbering"; +import { useInstruction } from "hooks/useInstruction"; +import { useInstrcutionDataField } from "hooks/useInstructionDataField"; import React from "react"; -import { useInstruction } from "../../../../hooks/useInstruction"; -import { useInstrcutionDataField } from "../../../../hooks/useInstructionDataField"; import { DataFormat, IInstrctionDataField, InstructionDataFieldType, -} from "../../../../types/internal"; -import { SortableCollection } from "../../../../types/sortable"; -import { removeFrom } from "../../../../utils/sortable"; -import { - FORMAT_DATA_TYPES, - NUMERICAL_DATA_TYPES, -} from "../../../../utils/ui-constants"; -import { Description } from "../../../common/Description"; -import { DragHandle } from "../../../common/DragHandle"; -import { EditableName } from "../../../common/EditableName"; -import { Numbering } from "../../../common/Numbering"; +} from "types/internal"; +import { SortableCollection } from "types/sortable"; +import { removeFrom } from "utils/sortable"; +import { FORMAT_DATA_TYPES, NUMERICAL_DATA_TYPES } from "utils/ui-constants"; export const DataField: React.FC<{ format: DataFormat; diff --git a/src/components/client/results/BalanceTable.tsx b/src/components/client/results/BalanceTable.tsx index 40f5a00..ad762d0 100644 --- a/src/components/client/results/BalanceTable.tsx +++ b/src/components/client/results/BalanceTable.tsx @@ -11,11 +11,11 @@ import { Thead, Tr, } from "@chakra-ui/react"; +import { ExplorerButton } from "components/common/ExplorerButton"; +import { useSessionStoreWithUndo } from "hooks/useSessionStore"; import React, { useState } from "react"; -import { useSessionStoreWithUndo } from "../../../hooks/useSessionStore"; -import { IBalance } from "../../../types/internal"; -import { toSol } from "../../../utils/web3js"; -import { ExplorerButton } from "../../common/ExplorerButton"; +import { IBalance } from "types/internal"; +import { toSol } from "utils/web3js"; export const BalanceTable: React.FC<{ balances: IBalance[]; diff --git a/src/components/client/results/ProgramLogs.tsx b/src/components/client/results/ProgramLogs.tsx index d0496a2..9eb4621 100644 --- a/src/components/client/results/ProgramLogs.tsx +++ b/src/components/client/results/ProgramLogs.tsx @@ -8,9 +8,9 @@ import { Stack, Tooltip, } from "@chakra-ui/react"; +import { CopyButton } from "components/common/CopyButton"; +import { useSessionStoreWithoutUndo } from "hooks/useSessionStore"; import React, { useMemo } from "react"; -import { useSessionStoreWithoutUndo } from "../../../hooks/useSessionStore"; -import { CopyButton } from "../../common/CopyButton"; export const ProgramLogs: React.FC<{ inProgress: boolean; diff --git a/src/components/client/results/Results.tsx b/src/components/client/results/Results.tsx index 7292f39..26c155f 100644 --- a/src/components/client/results/Results.tsx +++ b/src/components/client/results/Results.tsx @@ -22,19 +22,19 @@ import { Tooltip, } from "@chakra-ui/react"; import { TransactionConfirmationStatus } from "@solana/web3.js"; -import { useEffect, useState } from "react"; -import { useConfigStore } from "../../../hooks/useConfigStore"; -import { useGetWeb3Transaction } from "../../../hooks/useGetWeb3Transaction"; -import { useSessionStoreWithoutUndo } from "../../../hooks/useSessionStore"; +import { BalanceTable } from "components/client/results/BalanceTable"; +import { ProgramLogs } from "components/client/results/ProgramLogs"; +import { Signature } from "components/client/results/Signature"; +import { ErrorAlert } from "components/common/ErrorAlert"; +import { useConfigStore } from "hooks/useConfigStore"; +import { useGetWeb3Transaction } from "hooks/useGetWeb3Transaction"; +import { useSessionStoreWithoutUndo } from "hooks/useSessionStore"; import { extractBalances, mapWeb3TransactionError, -} from "../../../mappers/web3js-to-internal"; -import { IBalance } from "../../../types/internal"; -import { ErrorAlert } from "../../common/ErrorAlert"; -import { BalanceTable } from "./BalanceTable"; -import { ProgramLogs } from "./ProgramLogs"; -import { Signature } from "./Signature"; +} from "mappers/web3js-to-internal"; +import { useEffect, useState } from "react"; +import { IBalance } from "types/internal"; type State = { slot?: number; diff --git a/src/components/client/results/Signature.tsx b/src/components/client/results/Signature.tsx index d8f1fed..b448059 100644 --- a/src/components/client/results/Signature.tsx +++ b/src/components/client/results/Signature.tsx @@ -1,10 +1,10 @@ import { Box, Flex, FormLabel, Tag, Text } from "@chakra-ui/react"; import { TransactionConfirmationStatus } from "@solana/web3.js"; +import { CopyButton } from "components/common/CopyButton"; +import { ExplorerButton } from "components/common/ExplorerButton"; +import { useSessionStoreWithUndo } from "hooks/useSessionStore"; import React from "react"; -import { useSessionStoreWithUndo } from "../../../hooks/useSessionStore"; -import { toSol } from "../../../utils/web3js"; -import { CopyButton } from "../../common/CopyButton"; -import { ExplorerButton } from "../../common/ExplorerButton"; +import { toSol } from "utils/web3js"; export const Signature: React.FC<{ signature: string; diff --git a/src/components/common/AccountAutoComplete.tsx b/src/components/common/AccountAutoComplete.tsx index 39679ec..fbdc1e1 100644 --- a/src/components/common/AccountAutoComplete.tsx +++ b/src/components/common/AccountAutoComplete.tsx @@ -1,17 +1,13 @@ import { Badge, Flex, InputProps, Spacer, Text } from "@chakra-ui/react"; +import { Autocomplete, AutoCompleteItem } from "components/common/AutoComplete"; +import { useSessionStoreWithUndo } from "hooks/useSessionStore"; import { WritableDraft } from "immer/dist/internal"; +import { LOADER_IDS, programLabel, PROGRAM_INFO_BY_ID } from "library/programs"; +import { SYSVARS_BY_ID } from "library/sysvars"; import React, { useState } from "react"; import { useFilter } from "react-aria"; -import { useSessionStoreWithUndo } from "../../hooks/useSessionStore"; -import { - LOADER_IDS, - programLabel, - PROGRAM_INFO_BY_ID, -} from "../../library/programs"; -import { SYSVARS_BY_ID } from "../../library/sysvars"; -import { AccountType, IAccount, INetwork, IPubKey } from "../../types/internal"; -import { ALL_NETWORKS } from "../../utils/internal"; -import { Autocomplete, AutoCompleteItem } from "./AutoComplete"; +import { AccountType, IAccount, INetwork, IPubKey } from "types/internal"; +import { ALL_NETWORKS } from "utils/internal"; type OptionType = "input" | "type" | "program" | "sysvar"; diff --git a/src/components/common/Description.tsx b/src/components/common/Description.tsx index 151d8fb..8dae216 100644 --- a/src/components/common/Description.tsx +++ b/src/components/common/Description.tsx @@ -20,10 +20,10 @@ import { useDisclosure, } from "@chakra-ui/react"; import ChakraUIRenderer from "chakra-ui-markdown-renderer"; +import { useSessionStoreWithoutUndo } from "hooks/useSessionStore"; import React, { ReactFragment, useState } from "react"; import { FaMarkdown } from "react-icons/fa"; import ReactMarkdown from "react-markdown"; -import { useSessionStoreWithoutUndo } from "../../hooks/useSessionStore"; export const Description: React.FC< { diff --git a/src/components/common/DragHandle.tsx b/src/components/common/DragHandle.tsx index bc2b21e..9c3d971 100644 --- a/src/components/common/DragHandle.tsx +++ b/src/components/common/DragHandle.tsx @@ -1,7 +1,7 @@ import { DragHandleIcon, LockIcon } from "@chakra-ui/icons"; import { IconProps, useColorModeValue } from "@chakra-ui/react"; +import { SortableItemContext } from "components/common/Sortable"; import { useContext } from "react"; -import { SortableItemContext } from "./Sortable"; export const DragHandle: React.FC<{ locked?: boolean; diff --git a/src/components/common/ExplorerButton.tsx b/src/components/common/ExplorerButton.tsx index 7a3d381..cce575f 100644 --- a/src/components/common/ExplorerButton.tsx +++ b/src/components/common/ExplorerButton.tsx @@ -8,10 +8,10 @@ import { Tooltip, useColorModeValue, } from "@chakra-ui/react"; +import { useConfigStore } from "hooks/useConfigStore"; import React from "react"; -import { useConfigStore } from "../../hooks/useConfigStore"; -import { INetwork, IRpcEndpoint } from "../../types/internal"; -import { Explorer } from "../../types/state"; +import { INetwork, IRpcEndpoint } from "types/internal"; +import { Explorer } from "types/state"; export type AddressType = "tx" | "account"; diff --git a/src/components/common/Numbering.tsx b/src/components/common/Numbering.tsx index cb17eac..d3cf555 100644 --- a/src/components/common/Numbering.tsx +++ b/src/components/common/Numbering.tsx @@ -1,6 +1,6 @@ import { Badge, BadgeProps, useColorModeValue } from "@chakra-ui/react"; +import { useConfigStore } from "hooks/useConfigStore"; import React from "react"; -import { useConfigStore } from "../../hooks/useConfigStore"; export const Numbering: React.FC<{ index: number } & BadgeProps> = ({ index, diff --git a/src/components/common/RpcEndpointMenu.tsx b/src/components/common/RpcEndpointMenu.tsx index 3071526..de80def 100644 --- a/src/components/common/RpcEndpointMenu.tsx +++ b/src/components/common/RpcEndpointMenu.tsx @@ -13,10 +13,10 @@ import { Portal, Tooltip, } from "@chakra-ui/react"; +import { useConfigStore } from "hooks/useConfigStore"; import React from "react"; -import { useConfigStore } from "../../hooks/useConfigStore"; -import { IRpcEndpoint } from "../../types/internal"; -import { toSortedArray } from "../../utils/sortable"; +import { IRpcEndpoint } from "types/internal"; +import { toSortedArray } from "utils/sortable"; export const RpcEndpointMenu: React.FC<{ endpoint: IRpcEndpoint; diff --git a/src/components/common/Sortable.tsx b/src/components/common/Sortable.tsx index 7cb56d9..195f923 100644 --- a/src/components/common/Sortable.tsx +++ b/src/components/common/Sortable.tsx @@ -25,7 +25,7 @@ import { } from "@dnd-kit/sortable"; import { CSS } from "@dnd-kit/utilities"; import React from "react"; -import { IID } from "../../types/sortable"; +import { IID } from "types/sortable"; export const SortableItemContext = React.createContext<{ attributes?: DraggableAttributes; diff --git a/src/components/common/Web3Provider.tsx b/src/components/common/Web3Provider.tsx index d3f50fe..7c91cee 100644 --- a/src/components/common/Web3Provider.tsx +++ b/src/components/common/Web3Provider.tsx @@ -9,9 +9,9 @@ import { } from "@solana/wallet-adapter-react"; import { WalletModalProvider } from "@solana/wallet-adapter-react-ui"; import { SolflareWalletAdapter } from "@solana/wallet-adapter-solflare"; +import { useShallowConfigStore } from "hooks/useConfigStore"; +import { useSessionStoreWithUndo } from "hooks/useSessionStore"; import React, { useMemo } from "react"; -import { useShallowConfigStore } from "../../hooks/useConfigStore"; -import { useSessionStoreWithUndo } from "../../hooks/useSessionStore"; export const Web3Provider: React.FC<{ children: React.ReactNode }> = ({ children, diff --git a/src/components/header/Examples.tsx b/src/components/header/Examples.tsx index 99ff3f9..312c6bd 100644 --- a/src/components/header/Examples.tsx +++ b/src/components/header/Examples.tsx @@ -9,16 +9,16 @@ import { Tooltip, useToast, } from "@chakra-ui/react"; -import React, { useEffect } from "react"; -import { useShallowConfigStore } from "../../hooks/useConfigStore"; +import { useShallowConfigStore } from "hooks/useConfigStore"; import { useSessionStoreWithoutUndo, useSessionStoreWithUndo, -} from "../../hooks/useSessionStore"; -import { EXAMPLES } from "../../library/examples"; -import { mapITransactionExtToITransaction } from "../../mappers/external-to-internal"; -import { toSortedArray } from "../../utils/sortable"; -import { DEFAULT_TRANSACTION_RUN } from "../../utils/state"; +} from "hooks/useSessionStore"; +import { EXAMPLES } from "library/examples"; +import { mapITransactionExtToITransaction } from "mappers/external-to-internal"; +import React, { useEffect } from "react"; +import { toSortedArray } from "utils/sortable"; +import { DEFAULT_TRANSACTION_RUN } from "utils/state"; export const Example: React.FC = () => { const setTransaction = useSessionStoreWithUndo((state) => state.set); diff --git a/src/components/header/Header.tsx b/src/components/header/Header.tsx index da0bcc1..b5da632 100644 --- a/src/components/header/Header.tsx +++ b/src/components/header/Header.tsx @@ -11,12 +11,12 @@ import { Tooltip, useToast, } from "@chakra-ui/react"; +import { ColorModeSwitcher } from "components/header/ColorModeSwitcher"; +import { Example } from "components/header/Examples"; +import { WalletButton } from "components/header/WalletButton"; +import { useSessionStoreWithoutUndo } from "hooks/useSessionStore"; import { useState } from "react"; import { FaWrench } from "react-icons/fa"; -import { useSessionStoreWithoutUndo } from "../../hooks/useSessionStore"; -import { ColorModeSwitcher } from "./ColorModeSwitcher"; -import { Example } from "./Examples"; -import { WalletButton } from "./WalletButton"; export const Header: React.FC = () => { const [funTitle, setFunTitle] = useState(true); @@ -84,7 +84,6 @@ export const Header: React.FC = () => { */} - diff --git a/src/components/info/InfoModal.tsx b/src/components/info/InfoModal.tsx index ad49bea..168f108 100644 --- a/src/components/info/InfoModal.tsx +++ b/src/components/info/InfoModal.tsx @@ -11,11 +11,11 @@ import { TabPanels, Tabs, } from "@chakra-ui/react"; -import { useShallowSessionStoreWithoutUndo } from "../../hooks/useSessionStore"; -import { About } from "./About"; -import { Acknowledgements } from "./Acknowledgements"; -import { Help } from "./Help"; -import { Privacy } from "./Privacy"; +import { About } from "components/info/About"; +import { Acknowledgements } from "components/info/Acknowledgements"; +import { Help } from "components/info/Help"; +import { Privacy } from "components/info/Privacy"; +import { useShallowSessionStoreWithoutUndo } from "hooks/useSessionStore"; export const InfoModal: React.FC = () => { const [isOpen, set] = useShallowSessionStoreWithoutUndo((state) => [ diff --git a/src/components/info/Privacy.tsx b/src/components/info/Privacy.tsx index f0ef5a6..d6d9648 100644 --- a/src/components/info/Privacy.tsx +++ b/src/components/info/Privacy.tsx @@ -7,7 +7,7 @@ import { Text, UnorderedList, } from "@chakra-ui/react"; -import { GITHUB_URL } from "./About"; +import { GITHUB_URL } from "components/info/About"; export const Privacy: React.FC = () => ( diff --git a/src/components/options/GeneralOptions.tsx b/src/components/options/GeneralOptions.tsx index 04cbcfa..6073aa4 100644 --- a/src/components/options/GeneralOptions.tsx +++ b/src/components/options/GeneralOptions.tsx @@ -1,10 +1,10 @@ import { Grid } from "@chakra-ui/react"; +import { ChoiceOption } from "components/options/fields/ChoiceOption"; +import { ToggleOption } from "components/options/fields/ToggleOption"; +import { useShallowConfigStore } from "hooks/useConfigStore"; import React from "react"; -import { useShallowConfigStore } from "../../hooks/useConfigStore"; -import { Explorer } from "../../types/state"; -import { EXPLORERS } from "../../utils/ui-constants"; -import { ChoiceOption } from "./fields/ChoiceOption"; -import { ToggleOption } from "./fields/ToggleOption"; +import { Explorer } from "types/state"; +import { EXPLORERS } from "utils/ui-constants"; export const GeneralOptions: React.FC = () => { const [appOptions, set] = useShallowConfigStore((state) => [ diff --git a/src/components/options/Options.tsx b/src/components/options/Options.tsx index 5eb11df..34e9ea2 100644 --- a/src/components/options/Options.tsx +++ b/src/components/options/Options.tsx @@ -13,17 +13,14 @@ import { TabPanels, Tabs, } from "@chakra-ui/react"; +import { GeneralOptions } from "components/options/GeneralOptions"; +import { RpcEndpointOptions } from "components/options/RpcEndpointOptions"; +import { TransactionOptions } from "components/options/TransactionOptions"; +import { useConfigStore } from "hooks/useConfigStore"; +import { useShallowSessionStoreWithoutUndo } from "hooks/useSessionStore"; import React from "react"; -import { useConfigStore } from "../../hooks/useConfigStore"; -import { useShallowSessionStoreWithoutUndo } from "../../hooks/useSessionStore"; -import {} from "../../types/state"; -import { - DEFAULT_APP_OPTIONS, - DEFAUT_TRANSACTION_OPTIONS, -} from "../../utils/state"; -import { GeneralOptions } from "./GeneralOptions"; -import { RpcEndpointOptions } from "./RpcEndpointOptions"; -import { TransactionOptions } from "./TransactionOptions"; +import {} from "types/state"; +import { DEFAULT_APP_OPTIONS, DEFAUT_TRANSACTION_OPTIONS } from "utils/state"; export const Options: React.FC = () => { const [isOpen, setSession] = useShallowSessionStoreWithoutUndo((state) => [ diff --git a/src/components/options/RpcEndpointOptions.tsx b/src/components/options/RpcEndpointOptions.tsx index b836b8b..e9c40d3 100644 --- a/src/components/options/RpcEndpointOptions.tsx +++ b/src/components/options/RpcEndpointOptions.tsx @@ -1,10 +1,10 @@ import { AddIcon } from "@chakra-ui/icons"; import { Grid, IconButton, Text, Tooltip } from "@chakra-ui/react"; -import { useShallowConfigStore } from "../../hooks/useConfigStore"; -import { newRpcEndpoint } from "../../utils/internal"; -import { addTo, toSortedArray } from "../../utils/sortable"; -import { Sortable } from "../common/Sortable"; -import { RpcEndpointOption } from "./fields/RpcEndpointOption"; +import { Sortable } from "components/common/Sortable"; +import { RpcEndpointOption } from "components/options/fields/RpcEndpointOption"; +import { useShallowConfigStore } from "hooks/useConfigStore"; +import { newRpcEndpoint } from "utils/internal"; +import { addTo, toSortedArray } from "utils/sortable"; export const RpcEndpointOptions: React.FC = () => { const [rpcEndpoints, set] = useShallowConfigStore((state) => [ diff --git a/src/components/options/TransactionOptions.tsx b/src/components/options/TransactionOptions.tsx index 07b159f..e44073f 100644 --- a/src/components/options/TransactionOptions.tsx +++ b/src/components/options/TransactionOptions.tsx @@ -1,11 +1,11 @@ import { Grid } from "@chakra-ui/react"; import { Commitment, Finality } from "@solana/web3.js"; +import { ChoiceOption } from "components/options/fields/ChoiceOption"; +import { NumberOption } from "components/options/fields/NumberOption"; +import { ToggleOption } from "components/options/fields/ToggleOption"; +import { useShallowConfigStore } from "hooks/useConfigStore"; import React from "react"; -import { useShallowConfigStore } from "../../hooks/useConfigStore"; -import { COMMITMENT_LEVELS, FINALITY_LEVELS } from "../../utils/ui-constants"; -import { ChoiceOption } from "./fields/ChoiceOption"; -import { NumberOption } from "./fields/NumberOption"; -import { ToggleOption } from "./fields/ToggleOption"; +import { COMMITMENT_LEVELS, FINALITY_LEVELS } from "utils/ui-constants"; export const TransactionOptions: React.FC = () => { const [transactionOptions, set] = useShallowConfigStore((state) => [ diff --git a/src/components/options/fields/RpcEndpointOption.tsx b/src/components/options/fields/RpcEndpointOption.tsx index edbc67b..edd0e3a 100644 --- a/src/components/options/fields/RpcEndpointOption.tsx +++ b/src/components/options/fields/RpcEndpointOption.tsx @@ -13,14 +13,14 @@ import { Portal, Tooltip, } from "@chakra-ui/react"; +import { DragHandle } from "components/common/DragHandle"; +import { useConfigStore } from "hooks/useConfigStore"; import { WritableDraft } from "immer/dist/internal"; import React, { useEffect, useState } from "react"; import { FaEye, FaEyeSlash } from "react-icons/fa"; -import { useConfigStore } from "../../../hooks/useConfigStore"; -import { IRpcEndpoint } from "../../../types/internal"; -import { removeFrom } from "../../../utils/sortable"; -import { RPC_NETWORK_OPTIONS } from "../../../utils/state"; -import { DragHandle } from "../../common/DragHandle"; +import { IRpcEndpoint } from "types/internal"; +import { removeFrom } from "utils/sortable"; +import { RPC_NETWORK_OPTIONS } from "utils/state"; const isValidUrl = (url: string) => { try { diff --git a/src/components/palette/ImportTransaction.tsx b/src/components/palette/ImportTransaction.tsx index ce428a5..38ca421 100644 --- a/src/components/palette/ImportTransaction.tsx +++ b/src/components/palette/ImportTransaction.tsx @@ -10,15 +10,15 @@ import { MenuItem, MenuList, } from "@chakra-ui/react"; +import { ErrorAlert } from "components/common/ErrorAlert"; +import { AnchorJsonImport } from "components/palette/import/AnchorJsonImport"; +import { AnchorProgramIdImport } from "components/palette/import/AnchorProgramIdImport"; +import { ShareJsonImport } from "components/palette/import/ShareJsonImport"; +import { ShareUrlImport } from "components/palette/import/ShareUrlImport"; +import { TransactionIdImport } from "components/palette/import/TransactionIdImport"; +import { Preview } from "components/palette/preview/Preview"; import { useState } from "react"; -import { IPreview, PreviewSource } from "../../types/preview"; -import { ErrorAlert } from "../common/ErrorAlert"; -import { AnchorJsonImport } from "./import/AnchorJsonImport"; -import { AnchorProgramIdImport } from "./import/AnchorProgramIdImport"; -import { ShareJsonImport } from "./import/ShareJsonImport"; -import { ShareUrlImport } from "./import/ShareUrlImport"; -import { TransactionIdImport } from "./import/TransactionIdImport"; -import { Preview } from "./preview/Preview"; +import { IPreview, PreviewSource } from "types/preview"; const SOURCES: { source: PreviewSource; label: string; type: string }[] = [ { source: "tx", label: "Transaction ID", type: "tx" }, diff --git a/src/components/palette/Palette.tsx b/src/components/palette/Palette.tsx index 72c5b69..076c81c 100644 --- a/src/components/palette/Palette.tsx +++ b/src/components/palette/Palette.tsx @@ -6,8 +6,8 @@ import { Tabs, useColorModeValue, } from "@chakra-ui/react"; +import { ImportTransaction } from "components/palette/ImportTransaction"; import React from "react"; -import { ImportTransaction } from "./ImportTransaction"; export const Palette: React.FC = () => { return ( diff --git a/src/components/palette/import/AnchorJsonImport.tsx b/src/components/palette/import/AnchorJsonImport.tsx index 64d2851..bb653d3 100644 --- a/src/components/palette/import/AnchorJsonImport.tsx +++ b/src/components/palette/import/AnchorJsonImport.tsx @@ -1,6 +1,6 @@ import { Flex, Textarea } from "@chakra-ui/react"; -import { mapIdlToIPreview } from "../../../mappers/idl-to-preview"; -import { IPreview } from "../../../types/preview"; +import { mapIdlToIPreview } from "mappers/idl-to-preview"; +import { IPreview } from "types/preview"; export const AnchorJsonImport: React.FC<{ setPreview: (tranaction: IPreview | undefined) => void; diff --git a/src/components/palette/import/AnchorProgramIdImport.tsx b/src/components/palette/import/AnchorProgramIdImport.tsx index 143bc2f..1b13276 100644 --- a/src/components/palette/import/AnchorProgramIdImport.tsx +++ b/src/components/palette/import/AnchorProgramIdImport.tsx @@ -1,14 +1,14 @@ import { SearchIcon, TriangleDownIcon } from "@chakra-ui/icons"; import { Button, ButtonGroup, Flex, Input, Tooltip } from "@chakra-ui/react"; +import { RpcEndpointMenu } from "components/common/RpcEndpointMenu"; +import { useConfigStore } from "hooks/useConfigStore"; +import { useWeb3Connection } from "hooks/useWeb3Connection"; +import { mapIdlToIPreview } from "mappers/idl-to-preview"; import { useState } from "react"; -import { useConfigStore } from "../../../hooks/useConfigStore"; -import { useWeb3Connection } from "../../../hooks/useWeb3Connection"; -import { mapIdlToIPreview } from "../../../mappers/idl-to-preview"; -import { IRpcEndpoint } from "../../../types/internal"; -import { IPreview } from "../../../types/preview"; -import { fetchIdl } from "../../../utils/idl"; -import { isValidPublicKey } from "../../../utils/web3js"; -import { RpcEndpointMenu } from "../../common/RpcEndpointMenu"; +import { IRpcEndpoint } from "types/internal"; +import { IPreview } from "types/preview"; +import { fetchIdl } from "utils/idl"; +import { isValidPublicKey } from "utils/web3js"; export const AnchorProgramIdImport: React.FC<{ setPreview: (tranaction: IPreview | undefined) => void; diff --git a/src/components/palette/import/ShareJsonImport.tsx b/src/components/palette/import/ShareJsonImport.tsx index bb4e472..25d5ca9 100644 --- a/src/components/palette/import/ShareJsonImport.tsx +++ b/src/components/palette/import/ShareJsonImport.tsx @@ -1,6 +1,6 @@ import { Flex, Textarea } from "@chakra-ui/react"; -import { mapITransactionExtToIPreview } from "../../../mappers/external-to-preview"; -import { IPreview } from "../../../types/preview"; +import { mapITransactionExtToIPreview } from "mappers/external-to-preview"; +import { IPreview } from "types/preview"; export const ShareJsonImport: React.FC<{ setPreview: (tranaction: IPreview | undefined) => void; diff --git a/src/components/palette/import/ShareUrlImport.tsx b/src/components/palette/import/ShareUrlImport.tsx index ded02f1..6a224d6 100644 --- a/src/components/palette/import/ShareUrlImport.tsx +++ b/src/components/palette/import/ShareUrlImport.tsx @@ -1,9 +1,9 @@ import { DownloadIcon } from "@chakra-ui/icons"; import { Flex, IconButton, Input, Tooltip } from "@chakra-ui/react"; import axios from "axios"; +import { mapITransactionExtToIPreview } from "mappers/external-to-preview"; import { useState } from "react"; -import { mapITransactionExtToIPreview } from "../../../mappers/external-to-preview"; -import { IPreview } from "../../../types/preview"; +import { IPreview } from "types/preview"; export const ShareUrlImport: React.FC<{ setPreview: (tranaction: IPreview | undefined) => void; diff --git a/src/components/palette/import/TransactionIdImport.tsx b/src/components/palette/import/TransactionIdImport.tsx index 328ff62..f6aeb6d 100644 --- a/src/components/palette/import/TransactionIdImport.tsx +++ b/src/components/palette/import/TransactionIdImport.tsx @@ -1,13 +1,13 @@ import { SearchIcon, TriangleDownIcon } from "@chakra-ui/icons"; import { Button, ButtonGroup, Flex, Input, Tooltip } from "@chakra-ui/react"; +import { RpcEndpointMenu } from "components/common/RpcEndpointMenu"; +import { useConfigStore } from "hooks/useConfigStore"; +import { useGetWeb3Transaction } from "hooks/useGetWeb3Transaction"; +import { useWeb3Connection } from "hooks/useWeb3Connection"; +import { mapTransactionResponseToIPreview } from "mappers/web3js-to-preview"; import { useState } from "react"; -import { useConfigStore } from "../../../hooks/useConfigStore"; -import { useGetWeb3Transaction } from "../../../hooks/useGetWeb3Transaction"; -import { useWeb3Connection } from "../../../hooks/useWeb3Connection"; -import { mapTransactionResponseToIPreview } from "../../../mappers/web3js-to-preview"; -import { IRpcEndpoint } from "../../../types/internal"; -import { IPreview } from "../../../types/preview"; -import { RpcEndpointMenu } from "../../common/RpcEndpointMenu"; +import { IRpcEndpoint } from "types/internal"; +import { IPreview } from "types/preview"; export const TransactionIdImport: React.FC<{ setPreview: (tranaction: IPreview | undefined) => void; diff --git a/src/components/palette/preview/AccountSummary.tsx b/src/components/palette/preview/AccountSummary.tsx index 6d5889f..d264514 100644 --- a/src/components/palette/preview/AccountSummary.tsx +++ b/src/components/palette/preview/AccountSummary.tsx @@ -9,7 +9,7 @@ import { Wrap, } from "@chakra-ui/react"; import React from "react"; -import { IAccountSummary } from "../../../types/preview"; +import { IAccountSummary } from "types/preview"; export const AccountSummary: React.FC< { diff --git a/src/components/palette/preview/DataPreview.tsx b/src/components/palette/preview/DataPreview.tsx index afc1fa2..2635d0b 100644 --- a/src/components/palette/preview/DataPreview.tsx +++ b/src/components/palette/preview/DataPreview.tsx @@ -8,10 +8,7 @@ import { useColorModeValue, } from "@chakra-ui/react"; import React from "react"; -import { - IInstrctionDataFieldExt, - IInstructionDataExt, -} from "../../../types/external"; +import { IInstrctionDataFieldExt, IInstructionDataExt } from "types/external"; export const DataPreview: React.FC< { data: IInstructionDataExt } & FlexProps diff --git a/src/components/palette/preview/InstructionPreview.tsx b/src/components/palette/preview/InstructionPreview.tsx index 1434a7c..b16a489 100644 --- a/src/components/palette/preview/InstructionPreview.tsx +++ b/src/components/palette/preview/InstructionPreview.tsx @@ -9,15 +9,15 @@ import { Tooltip, useColorModeValue, } from "@chakra-ui/react"; -import { useSessionStoreWithUndo } from "../../../hooks/useSessionStore"; -import { mapIInstructionPreviewToIInstruction } from "../../../mappers/preview-to-internal"; -import { IInstructionPreview, PreviewSource } from "../../../types/preview"; -import { addTo } from "../../../utils/sortable"; -import { short } from "../../../utils/web3js"; -import { CopyButton } from "../../common/CopyButton"; -import { Numbering } from "../../common/Numbering"; -import { AccountSummary } from "./AccountSummary"; -import { DataPreview } from "./DataPreview"; +import { CopyButton } from "components/common/CopyButton"; +import { Numbering } from "components/common/Numbering"; +import { AccountSummary } from "components/palette/preview/AccountSummary"; +import { DataPreview } from "components/palette/preview/DataPreview"; +import { useSessionStoreWithUndo } from "hooks/useSessionStore"; +import { mapIInstructionPreviewToIInstruction } from "mappers/preview-to-internal"; +import { IInstructionPreview, PreviewSource } from "types/preview"; +import { addTo } from "utils/sortable"; +import { short } from "utils/web3js"; export const InstructionPreview: React.FC<{ index: number; diff --git a/src/components/palette/preview/Preview.tsx b/src/components/palette/preview/Preview.tsx index cb9330a..30bfd9b 100644 --- a/src/components/palette/preview/Preview.tsx +++ b/src/components/palette/preview/Preview.tsx @@ -16,14 +16,14 @@ import { Tooltip, useColorModeValue, } from "@chakra-ui/react"; +import { CopyButton } from "components/common/CopyButton"; +import { AccountSummary } from "components/palette/preview/AccountSummary"; +import { InstructionPreview } from "components/palette/preview/InstructionPreview"; +import { useSessionStoreWithUndo } from "hooks/useSessionStore"; +import { mapIPreviewToITransaction } from "mappers/preview-to-internal"; import { FaAnchor } from "react-icons/fa"; -import { useSessionStoreWithUndo } from "../../../hooks/useSessionStore"; -import { mapIPreviewToITransaction } from "../../../mappers/preview-to-internal"; -import { IPreview, PreviewSource } from "../../../types/preview"; -import { short } from "../../../utils/web3js"; -import { CopyButton } from "../../common/CopyButton"; -import { AccountSummary } from "./AccountSummary"; -import { InstructionPreview } from "./InstructionPreview"; +import { IPreview, PreviewSource } from "types/preview"; +import { short } from "utils/web3js"; export const Preview: React.FC<{ preview: IPreview; diff --git a/src/hooks/useAccount.ts b/src/hooks/useAccount.ts index c4c9154..ac0456a 100644 --- a/src/hooks/useAccount.ts +++ b/src/hooks/useAccount.ts @@ -1,9 +1,9 @@ +import { AccountContext } from "components/client/accounts/Accounts"; +import { useInstruction } from "hooks/useInstruction"; import { WritableDraft } from "immer/dist/internal"; import { useContext } from "react"; -import { AccountContext } from "../components/client/accounts/Accounts"; -import { IAccount, IInstruction } from "../types/internal"; -import { IID } from "../types/sortable"; -import { useInstruction } from "./useInstruction"; +import { IAccount, IInstruction } from "types/internal"; +import { IID } from "types/sortable"; /** * Provides the current account's details and methods to interact with it diff --git a/src/hooks/useAccountType.ts b/src/hooks/useAccountType.ts index 92c5b85..8ee883c 100644 --- a/src/hooks/useAccountType.ts +++ b/src/hooks/useAccountType.ts @@ -1,11 +1,11 @@ import { useToast } from "@chakra-ui/react"; import { useWallet } from "@solana/wallet-adapter-react"; import { Keypair, PublicKey } from "@solana/web3.js"; -import { AccountType, IAccountMetadata } from "../types/internal"; -import { isValidPublicKey } from "../utils/web3js"; -import { useAccount } from "./useAccount"; -import { useInstruction } from "./useInstruction"; -import { useSessionStoreWithUndo } from "./useSessionStore"; +import { useAccount } from "hooks/useAccount"; +import { useInstruction } from "hooks/useInstruction"; +import { useSessionStoreWithUndo } from "hooks/useSessionStore"; +import { AccountType, IAccountMetadata } from "types/internal"; +import { isValidPublicKey } from "utils/web3js"; /** * Encapsulates logic to populate accounts based on their type diff --git a/src/hooks/useConfigStore.ts b/src/hooks/useConfigStore.ts index 4b89254..3a3443c 100644 --- a/src/hooks/useConfigStore.ts +++ b/src/hooks/useConfigStore.ts @@ -1,9 +1,9 @@ import produce from "immer"; +import { PersistentState } from "types/state"; +import { DEFAULT_PERSISTENT_STATE } from "utils/state"; import create from "zustand"; import { persist } from "zustand/middleware"; import shallow from "zustand/shallow"; -import { PersistentState } from "../types/state"; -import { DEFAULT_PERSISTENT_STATE } from "../utils/state"; /** * Provides access to the LocalStorage Zustand store diff --git a/src/hooks/useGetWeb3Transaction.ts b/src/hooks/useGetWeb3Transaction.ts index ffb9a37..458b2ed 100644 --- a/src/hooks/useGetWeb3Transaction.ts +++ b/src/hooks/useGetWeb3Transaction.ts @@ -4,10 +4,10 @@ import { SignatureStatus, TransactionResponse, } from "@solana/web3.js"; +import { useConfigStore } from "hooks/useConfigStore"; +import { useWeb3Connection } from "hooks/useWeb3Connection"; import { useState } from "react"; -import { IPubKey } from "../types/internal"; -import { useConfigStore } from "./useConfigStore"; -import { useWeb3Connection } from "./useWeb3Connection"; +import { IPubKey } from "types/internal"; /** * Use it to poll for the results of a transaction diff --git a/src/hooks/useImportFromUrl.ts b/src/hooks/useImportFromUrl.ts index 7e63261..dbf9337 100644 --- a/src/hooks/useImportFromUrl.ts +++ b/src/hooks/useImportFromUrl.ts @@ -1,21 +1,21 @@ import { useToast } from "@chakra-ui/react"; import axios from "axios"; -import { useEffect, useMemo, useState } from "react"; -import { useSearchParams } from "react-router-dom"; -import { validate } from "../generated/validate/index.mjs"; -import { mapITransactionExtToITransaction } from "../mappers/external-to-internal"; -import { mapITransactionExtToIPreview } from "../mappers/external-to-preview"; -import { mapIPreviewToITransaction } from "../mappers/preview-to-internal"; -import { mapProtobufToITransactionExt } from "../mappers/protobuf-to-external"; -import { mapTransactionResponseToIPreview } from "../mappers/web3js-to-preview"; -import { short } from "../utils/web3js"; -import { useConfigStore } from "./useConfigStore"; -import { useGetWeb3Transaction } from "./useGetWeb3Transaction"; +import { validate } from "generated/validate/index.mjs"; +import { useConfigStore } from "hooks/useConfigStore"; +import { useGetWeb3Transaction } from "hooks/useGetWeb3Transaction"; import { useSessionStoreWithoutUndo, useSessionStoreWithUndo, -} from "./useSessionStore"; -import { useWeb3Connection } from "./useWeb3Connection"; +} from "hooks/useSessionStore"; +import { useWeb3Connection } from "hooks/useWeb3Connection"; +import { mapITransactionExtToITransaction } from "mappers/external-to-internal"; +import { mapITransactionExtToIPreview } from "mappers/external-to-preview"; +import { mapIPreviewToITransaction } from "mappers/preview-to-internal"; +import { mapProtobufToITransactionExt } from "mappers/protobuf-to-external"; +import { mapTransactionResponseToIPreview } from "mappers/web3js-to-preview"; +import { useEffect, useMemo, useState } from "react"; +import { useSearchParams } from "react-router-dom"; +import { short } from "utils/web3js"; const DEFAULT_STATUS = { isLoading: false, status: "" }; diff --git a/src/hooks/useInstruction.ts b/src/hooks/useInstruction.ts index 8ca2a4a..4134efa 100644 --- a/src/hooks/useInstruction.ts +++ b/src/hooks/useInstruction.ts @@ -1,13 +1,13 @@ -import { WritableDraft } from "immer/dist/internal"; -import { useContext } from "react"; -import { InstructionContext } from "../components/client/Instructions"; -import { IInstruction } from "../types/internal"; -import { IID } from "../types/sortable"; -import { newInstruction } from "../utils/internal"; +import { InstructionContext } from "components/client/Instructions"; import { useSessionStoreWithUndo, useShallowSessionStoreWithUndo, -} from "./useSessionStore"; +} from "hooks/useSessionStore"; +import { WritableDraft } from "immer/dist/internal"; +import { useContext } from "react"; +import { IInstruction } from "types/internal"; +import { IID } from "types/sortable"; +import { newInstruction } from "utils/internal"; /** * Provides the current instruction details and methods to interact with it diff --git a/src/hooks/useInstructionDataField.ts b/src/hooks/useInstructionDataField.ts index f5100bc..e69fff0 100644 --- a/src/hooks/useInstructionDataField.ts +++ b/src/hooks/useInstructionDataField.ts @@ -1,13 +1,9 @@ +import { InstructionDataFieldContext } from "components/client/data/editor/DataEditor"; +import { useInstruction } from "hooks/useInstruction"; import { WritableDraft } from "immer/dist/internal"; import { useContext } from "react"; -import { InstructionDataFieldContext } from "../components/client/data/editor/DataEditor"; -import { - DataFormat, - IInstrctionDataField, - IInstruction, -} from "../types/internal"; -import { IID } from "../types/sortable"; -import { useInstruction } from "./useInstruction"; +import { DataFormat, IInstrctionDataField, IInstruction } from "types/internal"; +import { IID } from "types/sortable"; /** * Provides the current instruction data's details and methods to interact with it diff --git a/src/hooks/useSendWeb3Transaction.ts b/src/hooks/useSendWeb3Transaction.ts index a7bd518..515ab7b 100644 --- a/src/hooks/useSendWeb3Transaction.ts +++ b/src/hooks/useSendWeb3Transaction.ts @@ -1,11 +1,11 @@ import { useWallet } from "@solana/wallet-adapter-react"; import { Connection, PublicKey, Signer } from "@solana/web3.js"; -import { mapITransactionToWeb3Transaction } from "../mappers/internal-to-web3js"; -import { ITransaction } from "../types/internal"; -import { sentryCaptureException } from "../utils/sentry"; -import { useConfigStore } from "./useConfigStore"; -import { useSessionStoreWithUndo } from "./useSessionStore"; -import { useWeb3Connection } from "./useWeb3Connection"; +import { useConfigStore } from "hooks/useConfigStore"; +import { useSessionStoreWithUndo } from "hooks/useSessionStore"; +import { useWeb3Connection } from "hooks/useWeb3Connection"; +import { mapITransactionToWeb3Transaction } from "mappers/internal-to-web3js"; +import { ITransaction } from "types/internal"; +import { sentryCaptureException } from "utils/sentry"; /** * Use it to send transactions to Solana diff --git a/src/hooks/useSessionStore.ts b/src/hooks/useSessionStore.ts index ee0f097..16f23df 100644 --- a/src/hooks/useSessionStore.ts +++ b/src/hooks/useSessionStore.ts @@ -1,12 +1,12 @@ import produce from "immer"; -import create from "zustand"; -import { persist, subscribeWithSelector } from "zustand/middleware"; -import shallow from "zustand/shallow"; -import { SessionStateWithoutUndo, SessionStateWithUndo } from "../types/state"; +import { SessionStateWithoutUndo, SessionStateWithUndo } from "types/state"; import { DEFAULT_SESSION_STATE_WITHOUT_UNDO, DEFAULT_SESSION_STATE_WITH_UNDO, -} from "../utils/state"; +} from "utils/state"; +import create from "zustand"; +import { persist, subscribeWithSelector } from "zustand/middleware"; +import shallow from "zustand/shallow"; // TODO implement undo/redo once this is resolved: https://github.com/charkour/zundo/issues/38 diff --git a/src/hooks/useWeb3Account.ts b/src/hooks/useWeb3Account.ts index 6c5e6a7..94cf125 100644 --- a/src/hooks/useWeb3Account.ts +++ b/src/hooks/useWeb3Account.ts @@ -1,13 +1,13 @@ import { idlAddress } from "@project-serum/anchor/dist/cjs/idl"; import { Connection, PublicKey } from "@solana/web3.js"; import axios from "axios"; +import { useSessionStoreWithUndo } from "hooks/useSessionStore"; +import { useWeb3Connection } from "hooks/useWeb3Connection"; +import { programLabel } from "library/programs"; import { useEffect, useState } from "react"; -import { programLabel } from "../library/programs"; -import { IPubKey, IRpcEndpoint } from "../types/internal"; -import { sentryCaptureException } from "../utils/sentry"; -import { isValidPublicKey } from "../utils/web3js"; -import { useSessionStoreWithUndo } from "./useSessionStore"; -import { useWeb3Connection } from "./useWeb3Connection"; +import { IPubKey, IRpcEndpoint } from "types/internal"; +import { sentryCaptureException } from "utils/sentry"; +import { isValidPublicKey } from "utils/web3js"; interface Web3AccountInfo { status: "new" | "inProgress" | "fetched" | "invalid"; diff --git a/src/hooks/useWeb3Connection.ts b/src/hooks/useWeb3Connection.ts index df00356..29a7224 100644 --- a/src/hooks/useWeb3Connection.ts +++ b/src/hooks/useWeb3Connection.ts @@ -1,7 +1,7 @@ import { useConnection } from "@solana/wallet-adapter-react"; import { Connection } from "@solana/web3.js"; +import { useConfigStore } from "hooks/useConfigStore"; import { useMemo } from "react"; -import { useConfigStore } from "./useConfigStore"; /** * Returns a Solana connection for the given RPC URL, diff --git a/src/index.tsx b/src/index.tsx index 092ab92..4cfc7ca 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,10 +1,10 @@ import { ColorModeScript } from "@chakra-ui/react"; import * as Sentry from "@sentry/react"; +import { App } from "App"; import * as React from "react"; import * as ReactDOM from "react-dom/client"; import { BrowserRouter } from "react-router-dom"; -import { App } from "./App"; -import reportWebVitals from "./reportWebVitals"; +import reportWebVitals from "reportWebVitals"; Sentry.init({ dsn: import.meta.env.VITE_SENTRY_DSN, diff --git a/src/library/examples.ts b/src/library/examples.ts index fe38f0a..26bb609 100644 --- a/src/library/examples.ts +++ b/src/library/examples.ts @@ -1,4 +1,4 @@ -import { ITransactionExt } from "../types/external"; +import { ITransactionExt } from "types/external"; // TODO add an Anchor example diff --git a/src/library/programs.ts b/src/library/programs.ts index 39fb3f3..a9cb896 100644 --- a/src/library/programs.ts +++ b/src/library/programs.ts @@ -7,8 +7,8 @@ import { SystemProgram, VOTE_PROGRAM_ID, } from "@solana/web3.js"; -import { INetwork } from "../types/internal"; -import { ALL_NETWORKS, LIVE_NETWORKS } from "../utils/internal"; +import { INetwork } from "types/internal"; +import { ALL_NETWORKS, LIVE_NETWORKS } from "utils/internal"; // Copied and modified from https://github.com/solana-labs/solana/blob/adcc36da8e1961e2730c926b77faede12c9c5407/explorer/src/utils/tx.ts diff --git a/src/mappers/external-to-internal.ts b/src/mappers/external-to-internal.ts index b5b752c..2df391c 100644 --- a/src/mappers/external-to-internal.ts +++ b/src/mappers/external-to-internal.ts @@ -1,18 +1,18 @@ -import { v4 as uuid } from "uuid"; import { IAccountExt, IInstrctionDataFieldExt, IInstructionExt, ITransactionExt, -} from "../types/external"; +} from "types/external"; import { IAccount, IInstruction, IInstructionDataRaw, ITransaction, -} from "../types/internal"; -import { Identifiable, SortableCollection } from "../types/sortable"; -import { toSortableCollection } from "../utils/sortable"; +} from "types/internal"; +import { Identifiable, SortableCollection } from "types/sortable"; +import { toSortableCollection } from "utils/sortable"; +import { v4 as uuid } from "uuid"; const mapToSortable = (item: T): T & Identifiable => ({ ...item, diff --git a/src/mappers/external-to-preview.ts b/src/mappers/external-to-preview.ts index 7ee5f85..6b336ac 100644 --- a/src/mappers/external-to-preview.ts +++ b/src/mappers/external-to-preview.ts @@ -1,6 +1,6 @@ -import { ITransactionExt } from "../types/external"; -import { IPreview, PreviewSource } from "../types/preview"; -import { accountSummary } from "./web3js-to-preview"; +import { accountSummary } from "mappers/web3js-to-preview"; +import { ITransactionExt } from "types/external"; +import { IPreview, PreviewSource } from "types/preview"; export const mapITransactionExtToIPreview = ( { name, instructions }: ITransactionExt, diff --git a/src/mappers/external-to-protobuf.ts b/src/mappers/external-to-protobuf.ts index 71cd223..22e4a14 100644 --- a/src/mappers/external-to-protobuf.ts +++ b/src/mappers/external-to-protobuf.ts @@ -1,18 +1,18 @@ -import pako from "pako"; -import { bettercallsol as protobuf, google } from "../generated/protobuf"; -import { - IAccountExt, - IInstrctionDataFieldExt, - ITransactionExt, -} from "../types/external"; -import { IAccountMetadata, IInstructionDataRaw } from "../types/internal"; +import { bettercallsol as protobuf, google } from "generated/protobuf"; import { mapAccountTypeToProtobuf, mapDataFormatToProtobuf, mapINetworkToProtobuf, mapInstructionDataFieldTypeToProtobuf, mapRawEncodingToProtobuf, -} from "./protobuf"; +} from "mappers/protobuf"; +import pako from "pako"; +import { + IAccountExt, + IInstrctionDataFieldExt, + ITransactionExt, +} from "types/external"; +import { IAccountMetadata, IInstructionDataRaw } from "types/internal"; const mapAnyToProtobuf = (x: any): google.protobuf.IValue => typeof x === "boolean" diff --git a/src/mappers/idl-to-preview.ts b/src/mappers/idl-to-preview.ts index 78afb8c..57b54b5 100644 --- a/src/mappers/idl-to-preview.ts +++ b/src/mappers/idl-to-preview.ts @@ -4,10 +4,10 @@ import { IdlAccountItem, IdlInstruction, } from "@project-serum/anchor/dist/cjs/idl"; -import { IAccountExt, IInstrctionDataFieldExt } from "../types/external"; -import { IPubKey, IRpcEndpoint } from "../types/internal"; -import { IInstructionPreview, IPreview, PreviewSource } from "../types/preview"; -import { accountSummary } from "./web3js-to-preview"; +import { accountSummary } from "mappers/web3js-to-preview"; +import { IAccountExt, IInstrctionDataFieldExt } from "types/external"; +import { IPubKey, IRpcEndpoint } from "types/internal"; +import { IInstructionPreview, IPreview, PreviewSource } from "types/preview"; const mapIdlAccountItemToIAccountExt = ( account: IdlAccountItem diff --git a/src/mappers/internal-to-external.ts b/src/mappers/internal-to-external.ts index 32df4d9..45873fb 100644 --- a/src/mappers/internal-to-external.ts +++ b/src/mappers/internal-to-external.ts @@ -2,14 +2,14 @@ import { IAccountExt, IInstrctionDataFieldExt, ITransactionExt, -} from "../types/external"; +} from "types/external"; import { IAccount, IInstrctionDataField, IRpcEndpoint, ITransaction, -} from "../types/internal"; -import { toSortedArray } from "../utils/sortable"; +} from "types/internal"; +import { toSortedArray } from "utils/sortable"; const mapIAccountToIAccountExt = ({ type, diff --git a/src/mappers/internal-to-web3js.ts b/src/mappers/internal-to-web3js.ts index 5c94319..f88b6fb 100644 --- a/src/mappers/internal-to-web3js.ts +++ b/src/mappers/internal-to-web3js.ts @@ -3,12 +3,12 @@ import { Transaction, TransactionInstruction, } from "@solana/web3.js"; -import { BorshCoder } from "../coders/borsh"; -import { BufferLayoutCoder } from "../coders/buffer-layout"; -import { ITransaction } from "../types/internal"; -import { toSortedArray } from "../utils/sortable"; -import { anchorMethodSighash, isValidPublicKey } from "../utils/web3js"; import bs58 from "bs58"; +import { BorshCoder } from "coders/borsh"; +import { BufferLayoutCoder } from "coders/buffer-layout"; +import { ITransaction } from "types/internal"; +import { toSortedArray } from "utils/sortable"; +import { anchorMethodSighash, isValidPublicKey } from "utils/web3js"; export const mapITransactionToWeb3Transaction = ({ instructions, diff --git a/src/mappers/preview-to-internal.ts b/src/mappers/preview-to-internal.ts index 9eed20f..184f34c 100644 --- a/src/mappers/preview-to-internal.ts +++ b/src/mappers/preview-to-internal.ts @@ -1,7 +1,7 @@ -import { IInstruction, ITransaction } from "../types/internal"; -import { IInstructionPreview, IPreview, PreviewSource } from "../types/preview"; -import { toSortableCollection, toSortedArray } from "../utils/sortable"; -import { mapIInstructionExtToIInstruction } from "./external-to-internal"; +import { mapIInstructionExtToIInstruction } from "mappers/external-to-internal"; +import { IInstruction, ITransaction } from "types/internal"; +import { IInstructionPreview, IPreview, PreviewSource } from "types/preview"; +import { toSortableCollection, toSortedArray } from "utils/sortable"; export const mapIInstructionPreviewToIInstruction = ( instruction: IInstructionPreview, diff --git a/src/mappers/protobuf-to-external.ts b/src/mappers/protobuf-to-external.ts index f3d67be..ce1c77f 100644 --- a/src/mappers/protobuf-to-external.ts +++ b/src/mappers/protobuf-to-external.ts @@ -1,18 +1,18 @@ -import pako from "pako"; -import { bettercallsol as protobuf, google } from "../generated/protobuf"; -import { - IAccountExt, - IInstrctionDataFieldExt, - ITransactionExt, -} from "../types/external"; -import { IAccountMetadata, IInstructionDataRaw } from "../types/internal"; +import { bettercallsol as protobuf, google } from "generated/protobuf"; import { mapProtobuffToDataFormat, mapProtobufToAccountType, mapProtobufToINetwork, mapProtobufToInstructionDataFieldType, mapProtobufToRawEncoding, -} from "./protobuf"; +} from "mappers/protobuf"; +import pako from "pako"; +import { + IAccountExt, + IInstrctionDataFieldExt, + ITransactionExt, +} from "types/external"; +import { IAccountMetadata, IInstructionDataRaw } from "types/internal"; const mapValueToAny = ({ boolValue, diff --git a/src/mappers/protobuf.ts b/src/mappers/protobuf.ts index 8ddeca9..fc5cea0 100644 --- a/src/mappers/protobuf.ts +++ b/src/mappers/protobuf.ts @@ -1,11 +1,11 @@ -import { bettercallsol as protobuf } from "../generated/protobuf"; +import { bettercallsol as protobuf } from "generated/protobuf"; import { AccountType, DataFormat, INetwork, InstructionDataFieldType, RawEncoding, -} from "../types/internal"; +} from "types/internal"; // enums const ProtoNetwork = protobuf.Transaction.Network; diff --git a/src/mappers/web3js-to-internal.ts b/src/mappers/web3js-to-internal.ts index 8869c9a..d7760c7 100644 --- a/src/mappers/web3js-to-internal.ts +++ b/src/mappers/web3js-to-internal.ts @@ -1,5 +1,5 @@ import { TransactionResponse } from "@solana/web3.js"; -import { IBalance } from "../types/internal"; +import { IBalance } from "types/internal"; export const extractBalances = ( transaction: TransactionResponse diff --git a/src/mappers/web3js-to-preview.ts b/src/mappers/web3js-to-preview.ts index dd5aabd..2c914c8 100644 --- a/src/mappers/web3js-to-preview.ts +++ b/src/mappers/web3js-to-preview.ts @@ -1,12 +1,8 @@ import { CompiledInstruction, TransactionResponse } from "@solana/web3.js"; -import { IAccountExt } from "../types/external"; -import { IRpcEndpoint } from "../types/internal"; -import { - IAccountSummary, - IInstructionPreview, - IPreview, -} from "../types/preview"; -import { mapWeb3TransactionError } from "./web3js-to-internal"; +import { mapWeb3TransactionError } from "mappers/web3js-to-internal"; +import { IAccountExt } from "types/external"; +import { IRpcEndpoint } from "types/internal"; +import { IAccountSummary, IInstructionPreview, IPreview } from "types/preview"; // TODO getParsedTransaction has some more info for specific instructions // { diff --git a/src/types/README.md b/src/types/README.md new file mode 100644 index 0000000..7cf4b50 --- /dev/null +++ b/src/types/README.md @@ -0,0 +1 @@ +Note: Types seem to have import each other using relative paths only. \ No newline at end of file diff --git a/src/utils/internal.ts b/src/utils/internal.ts index c98adb5..0345ea3 100644 --- a/src/utils/internal.ts +++ b/src/utils/internal.ts @@ -1,4 +1,3 @@ -import { v4 as uuid } from "uuid"; import { IAccount, IInstrctionDataField, @@ -6,8 +5,9 @@ import { IInstructionData, INetwork, IRpcEndpoint, -} from "../types/internal"; -import { toSortableCollection } from "./sortable"; +} from "types/internal"; +import { toSortableCollection } from "utils/sortable"; +import { v4 as uuid } from "uuid"; export const ALL_NETWORKS: INetwork[] = ["devnet", "testnet", "mainnet-beta"]; export const LIVE_NETWORKS: INetwork[] = ["devnet", "testnet", "mainnet-beta"]; diff --git a/src/utils/sortable.ts b/src/utils/sortable.ts index 4497d8d..da53a8d 100644 --- a/src/utils/sortable.ts +++ b/src/utils/sortable.ts @@ -1,5 +1,5 @@ import { WritableDraft } from "immer/dist/internal"; -import { Identifiable, IID, SortableCollection } from "../types/sortable"; +import { Identifiable, IID, SortableCollection } from "types/sortable"; export const addTo = ( collection: SortableCollection | WritableDraft>, diff --git a/src/utils/state.ts b/src/utils/state.ts index f04f54a..e6127e8 100644 --- a/src/utils/state.ts +++ b/src/utils/state.ts @@ -1,20 +1,20 @@ import { clusterApiUrl } from "@solana/web3.js"; -import { v4 as uuid } from "uuid"; import { INetwork, IRpcEndpoint, ITransaction, ITransactionOptions, ITransactionRun, -} from "../types/internal"; +} from "types/internal"; import { AppOptions, PersistentState, SessionStateWithoutUndo, SessionStateWithUndo, -} from "../types/state"; -import { newAccount, newInstruction } from "./internal"; -import { toSortableCollection } from "./sortable"; +} from "types/state"; +import { newAccount, newInstruction } from "utils/internal"; +import { toSortableCollection } from "utils/sortable"; +import { v4 as uuid } from "uuid"; export const RPC_NETWORK_OPTIONS: INetwork[] = [ "devnet", diff --git a/src/utils/ui-constants.ts b/src/utils/ui-constants.ts index e166bd1..5cf7bd3 100644 --- a/src/utils/ui-constants.ts +++ b/src/utils/ui-constants.ts @@ -1,6 +1,6 @@ import { Commitment, Finality } from "@solana/web3.js"; -import { DataFormat, InstructionDataFieldType } from "../types/internal"; -import { Explorer } from "../types/state"; +import { DataFormat, InstructionDataFieldType } from "types/internal"; +import { Explorer } from "types/state"; // for explorer option drop-down export const EXPLORERS: { id: Explorer; name: string }[] = [ diff --git a/tsconfig.json b/tsconfig.json index 536155a..ca59145 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,7 +15,8 @@ "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, - "jsx": "react-jsx" + "jsx": "react-jsx", + "baseUrl": "./src" }, "include": ["src"] } \ No newline at end of file diff --git a/vite.config.ts b/vite.config.ts index 90ed69c..1aa9977 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,11 +1,16 @@ import react from "@vitejs/plugin-react"; -import { defineConfig } from "vite"; +import { defineConfig, splitVendorChunkPlugin } from "vite"; import svgrPlugin from "vite-plugin-svgr"; import viteTsconfigPaths from "vite-tsconfig-paths"; // https://vitejs.dev/config/ export default defineConfig({ - plugins: [react(), viteTsconfigPaths(), svgrPlugin()], + plugins: [ + react(), + viteTsconfigPaths(), + svgrPlugin(), + splitVendorChunkPlugin(), + ], server: { open: true, },