diff --git a/src/components/Activity.tsx b/src/components/Activity.tsx index d090d59..5afd18d 100644 --- a/src/components/Activity.tsx +++ b/src/components/Activity.tsx @@ -19,7 +19,7 @@ import { } from "~/components"; import { useI18n } from "~/i18n/context"; import { useMegaStore } from "~/state/megaStore"; -import { createDeepSignal } from "~/utils/deepSignal"; +import { createDeepSignal } from "~/utils"; export const THREE_COLUMNS = "grid grid-cols-[auto,1fr,auto] gap-4 py-2 px-2 border-b border-neutral-800 last:border-b-0"; diff --git a/src/components/ActivityItem.tsx b/src/components/ActivityItem.tsx index c24b259..e6283b2 100644 --- a/src/components/ActivityItem.tsx +++ b/src/components/ActivityItem.tsx @@ -9,8 +9,7 @@ import on from "~/assets/icons/upload-channel.svg"; import { AmountFiat, AmountSats } from "~/components"; import { useI18n } from "~/i18n/context"; import { useMegaStore } from "~/state/megaStore"; -import { generateGradient } from "~/utils/gradientHash"; -import { timeAgo } from "~/utils/prettyPrintTime"; +import { generateGradient, timeAgo } from "~/utils"; export const ActivityAmount: ParentComponent<{ amount: string; diff --git a/src/components/Amount.tsx b/src/components/Amount.tsx index 171c26b..b5649ae 100644 --- a/src/components/Amount.tsx +++ b/src/components/Amount.tsx @@ -4,7 +4,7 @@ import bolt from "~/assets/icons/bolt.svg"; import chain from "~/assets/icons/chain.svg"; import { useI18n } from "~/i18n/context"; import { useMegaStore } from "~/state/megaStore"; -import { satsToUsd } from "~/utils/conversions"; +import { satsToUsd } from "~/utils"; function prettyPrintAmount(n?: number | bigint): string { if (!n || n.valueOf() === 0) { diff --git a/src/components/AmountCard.tsx b/src/components/AmountCard.tsx index 20a0be0..59aba4d 100644 --- a/src/components/AmountCard.tsx +++ b/src/components/AmountCard.tsx @@ -3,7 +3,7 @@ import { createMemo, Match, ParentComponent, Show, Switch } from "solid-js"; import { AmountEditable, Card, VStack } from "~/components"; import { useI18n } from "~/i18n/context"; import { useMegaStore } from "~/state/megaStore"; -import { satsToUsd } from "~/utils/conversions"; +import { satsToUsd } from "~/utils"; const noop = () => { // do nothing diff --git a/src/components/AmountEditable.tsx b/src/components/AmountEditable.tsx index 5daf80a..280692a 100644 --- a/src/components/AmountEditable.tsx +++ b/src/components/AmountEditable.tsx @@ -20,7 +20,7 @@ import { useI18n } from "~/i18n/context"; import { Network } from "~/logic/mutinyWalletSetup"; import { useMegaStore } from "~/state/megaStore"; import { DIALOG_CONTENT, DIALOG_POSITIONER } from "~/styles/dialogs"; -import { satsToUsd, usdToSats } from "~/utils/conversions"; +import { satsToUsd, usdToSats } from "~/utils"; function fiatInputSanitizer(input: string): string { // Make sure only numbers and a single decimal point are allowed diff --git a/src/components/CopyableQR.tsx b/src/components/CopyableQR.tsx index 6aad8b5..c239dda 100644 --- a/src/components/CopyableQR.tsx +++ b/src/components/CopyableQR.tsx @@ -2,7 +2,7 @@ import { Show } from "solid-js"; import { QRCodeSVG } from "solid-qr-code"; import { useI18n } from "~/i18n/context"; -import { useCopy } from "~/utils/useCopy"; +import { useCopy } from "~/utils"; export function CopyableQR(props: { value: string }) { const i18n = useI18n(); diff --git a/src/components/DecryptDialog.tsx b/src/components/DecryptDialog.tsx index a7be673..2eb2fd8 100644 --- a/src/components/DecryptDialog.tsx +++ b/src/components/DecryptDialog.tsx @@ -4,7 +4,7 @@ import { A } from "solid-start"; import { Button, InfoBox, SimpleDialog, TextField } from "~/components"; import { useI18n } from "~/i18n/context"; import { useMegaStore } from "~/state/megaStore"; -import eify from "~/utils/eify"; +import { eify } from "~/utils"; export function DecryptDialog() { const i18n = useI18n(); diff --git a/src/components/DeleteEverything.tsx b/src/components/DeleteEverything.tsx index 00343cf..29cbf08 100644 --- a/src/components/DeleteEverything.tsx +++ b/src/components/DeleteEverything.tsx @@ -4,7 +4,7 @@ import { createSignal } from "solid-js"; import { Button, ConfirmDialog, showToast } from "~/components"; import { useI18n } from "~/i18n/context"; import { useMegaStore } from "~/state/megaStore"; -import eify from "~/utils/eify"; +import { eify } from "~/utils"; export function DeleteEverything(props: { emergency?: boolean }) { const i18n = useI18n(); diff --git a/src/components/DetailsModal.tsx b/src/components/DetailsModal.tsx index aad2bdc..fdbb81d 100644 --- a/src/components/DetailsModal.tsx +++ b/src/components/DetailsModal.tsx @@ -32,10 +32,13 @@ import { import { useI18n } from "~/i18n/context"; import { Network } from "~/logic/mutinyWalletSetup"; import { useMegaStore } from "~/state/megaStore"; -import mempoolTxUrl from "~/utils/mempoolTxUrl"; -import { prettyPrintTime } from "~/utils/prettyPrintTime"; -import { MutinyTagItem, tagToMutinyTag } from "~/utils/tags"; -import { useCopy } from "~/utils/useCopy"; +import { + mempoolTxUrl, + MutinyTagItem, + prettyPrintTime, + tagToMutinyTag, + useCopy +} from "~/utils"; interface ChannelClosure { channel_id: string; diff --git a/src/components/ImportExport.tsx b/src/components/ImportExport.tsx index 3e75fce..b84f363 100644 --- a/src/components/ImportExport.tsx +++ b/src/components/ImportExport.tsx @@ -15,8 +15,7 @@ import { } from "~/components"; import { useI18n } from "~/i18n/context"; import { useMegaStore } from "~/state/megaStore"; -import { downloadTextFile } from "~/utils/download"; -import eify from "~/utils/eify"; +import { downloadTextFile, eify } from "~/utils"; export function ImportExport(props: { emergency?: boolean }) { const i18n = useI18n(); diff --git a/src/components/IntegratedQR.tsx b/src/components/IntegratedQR.tsx index 5fbcb33..2e6db53 100644 --- a/src/components/IntegratedQR.tsx +++ b/src/components/IntegratedQR.tsx @@ -8,7 +8,7 @@ import shareBlack from "~/assets/icons/share-black.svg"; import { AmountFiat, AmountSats, TruncateMiddle } from "~/components"; import { useI18n } from "~/i18n/context"; import { ReceiveFlavor } from "~/routes/Receive"; -import { useCopy } from "~/utils/useCopy"; +import { useCopy } from "~/utils"; function KindIndicator(props: { kind: ReceiveFlavor }) { const i18n = useI18n(); diff --git a/src/components/KitchenSink.tsx b/src/components/KitchenSink.tsx index e08e52b..feb26d0 100644 --- a/src/components/KitchenSink.tsx +++ b/src/components/KitchenSink.tsx @@ -26,8 +26,7 @@ import { import { useI18n } from "~/i18n/context"; import { Network } from "~/logic/mutinyWalletSetup"; import { useMegaStore } from "~/state/megaStore"; -import eify from "~/utils/eify"; -import mempoolTxUrl from "~/utils/mempoolTxUrl"; +import { eify, mempoolTxUrl } from "~/utils"; // TODO: hopefully I don't have to maintain this type forever but I don't know how to pass it around otherwise type RefetchPeersType = ( diff --git a/src/components/Logs.tsx b/src/components/Logs.tsx index d069d1a..966a024 100644 --- a/src/components/Logs.tsx +++ b/src/components/Logs.tsx @@ -2,7 +2,7 @@ import { MutinyWallet } from "@mutinywallet/mutiny-wasm"; import { Button, InnerCard, NiceP, VStack } from "~/components"; import { useI18n } from "~/i18n/context"; -import { downloadTextFile } from "~/utils/download"; +import { downloadTextFile } from "~/utils"; export function Logs() { const i18n = useI18n(); diff --git a/src/components/PendingNwc.tsx b/src/components/PendingNwc.tsx index ea0ab11..f14953b 100644 --- a/src/components/PendingNwc.tsx +++ b/src/components/PendingNwc.tsx @@ -17,9 +17,7 @@ import redClose from "~/assets/icons/red-close.svg"; import { ActivityAmount, Card, InfoBox, VStack } from "~/components"; import { useI18n } from "~/i18n/context"; import { useMegaStore } from "~/state/megaStore"; -import { createDeepSignal } from "~/utils/deepSignal"; -import eify from "~/utils/eify"; -import { formatExpiration } from "~/utils/prettyPrintTime"; +import { createDeepSignal, eify, formatExpiration } from "~/utils"; type PendingItem = { id: string; diff --git a/src/components/SeedWords.tsx b/src/components/SeedWords.tsx index bbc6e0e..9e5bd2f 100644 --- a/src/components/SeedWords.tsx +++ b/src/components/SeedWords.tsx @@ -2,7 +2,7 @@ import { createMemo, createSignal, For, Match, Switch } from "solid-js"; import copyIcon from "~/assets/icons/copy.svg"; import { useI18n } from "~/i18n/context"; -import { useCopy } from "~/utils/useCopy"; +import { useCopy } from "~/utils"; export function SeedWords(props: { words: string; diff --git a/src/components/ShareCard.tsx b/src/components/ShareCard.tsx index 2e6fbac..92890bd 100644 --- a/src/components/ShareCard.tsx +++ b/src/components/ShareCard.tsx @@ -7,7 +7,7 @@ import shareBlack from "~/assets/icons/share-black.svg"; import shareIcon from "~/assets/icons/share.svg"; import { Card, JsonModal, VStack } from "~/components"; import { useI18n } from "~/i18n/context"; -import { useCopy } from "~/utils/useCopy"; +import { useCopy } from "~/utils"; const STYLE = "px-4 py-2 rounded-xl border-2 border-white flex gap-2 items-center font-semibold hover:text-m-blue transition-colors"; diff --git a/src/components/TagEditor.tsx b/src/components/TagEditor.tsx index 5bed626..e348be1 100644 --- a/src/components/TagEditor.tsx +++ b/src/components/TagEditor.tsx @@ -6,7 +6,7 @@ import { createMemo, createSignal, For, onMount, Show } from "solid-js"; import { TinyButton } from "~/components"; import { useMegaStore } from "~/state/megaStore"; -import { MutinyTagItem, sortByLastUsed } from "~/utils/tags"; +import { MutinyTagItem, sortByLastUsed } from "~/utils"; const createLabelValue = (label: string): Partial => { return { name: label, kind: "Contact" }; diff --git a/src/components/layout/Misc.tsx b/src/components/layout/Misc.tsx index 54ab807..e498d28 100644 --- a/src/components/layout/Misc.tsx +++ b/src/components/layout/Misc.tsx @@ -23,8 +23,7 @@ import down from "~/assets/icons/down.svg"; import { DecryptDialog, LoadingIndicator } from "~/components"; import { useI18n } from "~/i18n/context"; import { useMegaStore } from "~/state/megaStore"; -import { generateGradient } from "~/utils/gradientHash"; -import { MutinyTagItem } from "~/utils/tags"; +import { generateGradient, MutinyTagItem } from "~/utils"; export const SmallHeader: ParentComponent<{ class?: string }> = (props) => { return ( diff --git a/src/logic/waila.ts b/src/logic/waila.ts index 2a43185..ff69bcc 100644 --- a/src/logic/waila.ts +++ b/src/logic/waila.ts @@ -1,6 +1,6 @@ import initWaila, { PaymentParams } from "@mutinywallet/waila-wasm"; -import { Result } from "~/utils/typescript"; +import { Result } from "~/utils"; // Make sure we've initialzied waila before we try to use it await initWaila(); diff --git a/src/routes/Activity.tsx b/src/routes/Activity.tsx index 44d0e7d..6254729 100644 --- a/src/routes/Activity.tsx +++ b/src/routes/Activity.tsx @@ -22,7 +22,7 @@ import { } from "~/components"; import { useI18n } from "~/i18n/context"; import { useMegaStore } from "~/state/megaStore"; -import { gradientsPerContact } from "~/utils/gradientHash"; +import { gradientsPerContact } from "~/utils"; function ContactRow() { const i18n = useI18n(); diff --git a/src/routes/Feedback.tsx b/src/routes/Feedback.tsx index 08ce3a9..55475af 100644 --- a/src/routes/Feedback.tsx +++ b/src/routes/Feedback.tsx @@ -26,7 +26,7 @@ import { VStack } from "~/components/layout"; import { useI18n } from "~/i18n/context"; -import eify from "~/utils/eify"; +import { eify } from "~/utils"; const FEEDBACK_API = import.meta.env.VITE_FEEDBACK; diff --git a/src/routes/Receive.tsx b/src/routes/Receive.tsx index 5981a26..ed0e3f0 100644 --- a/src/routes/Receive.tsx +++ b/src/routes/Receive.tsx @@ -46,10 +46,12 @@ import { useI18n } from "~/i18n/context"; import { matchError } from "~/logic/errorDispatch"; import { Network } from "~/logic/mutinyWalletSetup"; import { useMegaStore } from "~/state/megaStore"; -import eify from "~/utils/eify"; -import mempoolTxUrl from "~/utils/mempoolTxUrl"; -import { objectToSearchParams } from "~/utils/objectToSearchParams"; -import { MutinyTagItem } from "~/utils/tags"; +import { + eify, + mempoolTxUrl, + MutinyTagItem, + objectToSearchParams +} from "~/utils"; type OnChainTx = { transaction: { diff --git a/src/routes/Redshift.tsx b/src/routes/Redshift.tsx index 7d6925e..0a41f0f 100644 --- a/src/routes/Redshift.tsx +++ b/src/routes/Redshift.tsx @@ -41,8 +41,7 @@ import { import { useI18n } from "~/i18n/context"; import { Network } from "~/logic/mutinyWalletSetup"; import { useMegaStore } from "~/state/megaStore"; -import { getRedshifted, setRedshifted } from "~/utils/fakeLabels"; -import mempoolTxUrl from "~/utils/mempoolTxUrl"; +import { getRedshifted, mempoolTxUrl, setRedshifted } from "~/utils"; type ShiftOption = "utxo" | "lightning"; diff --git a/src/routes/Send.tsx b/src/routes/Send.tsx index 7765d81..5afdca7 100644 --- a/src/routes/Send.tsx +++ b/src/routes/Send.tsx @@ -46,9 +46,7 @@ import { useI18n } from "~/i18n/context"; import { Network } from "~/logic/mutinyWalletSetup"; import { ParsedParams, toParsedParams } from "~/logic/waila"; import { useMegaStore } from "~/state/megaStore"; -import eify from "~/utils/eify"; -import mempoolTxUrl from "~/utils/mempoolTxUrl"; -import { MutinyTagItem } from "~/utils/tags"; +import { eify, mempoolTxUrl, MutinyTagItem } from "~/utils"; import { FeedbackLink } from "./Feedback"; diff --git a/src/routes/Swap.tsx b/src/routes/Swap.tsx index dd625fd..9f0174e 100644 --- a/src/routes/Swap.tsx +++ b/src/routes/Swap.tsx @@ -35,8 +35,7 @@ import { useI18n } from "~/i18n/context"; import { Network } from "~/logic/mutinyWalletSetup"; import { MethodChooser, SendSource } from "~/routes/Send"; import { useMegaStore } from "~/state/megaStore"; -import eify from "~/utils/eify"; -import mempoolTxUrl from "~/utils/mempoolTxUrl"; +import { eify, mempoolTxUrl } from "~/utils"; const CHANNEL_FEE_ESTIMATE_ADDRESS = "bc1qf7546vg73ddsjznzq57z3e8jdn6gtw6au576j07kt6d9j7nz8mzsyn6lgf"; diff --git a/src/routes/settings/Connections.tsx b/src/routes/settings/Connections.tsx index 250d37e..48658b6 100644 --- a/src/routes/settings/Connections.tsx +++ b/src/routes/settings/Connections.tsx @@ -23,7 +23,7 @@ import { } from "~/components"; import { useI18n } from "~/i18n/context"; import { useMegaStore } from "~/state/megaStore"; -import eify from "~/utils/eify"; +import { eify } from "~/utils"; function Nwc() { const i18n = useI18n(); diff --git a/src/routes/settings/Encrypt.tsx b/src/routes/settings/Encrypt.tsx index 80f864b..60350ac 100644 --- a/src/routes/settings/Encrypt.tsx +++ b/src/routes/settings/Encrypt.tsx @@ -17,8 +17,7 @@ import { } from "~/components"; import { useI18n } from "~/i18n/context"; import { useMegaStore } from "~/state/megaStore"; -import eify from "~/utils/eify"; -import { timeout } from "~/utils/timeout"; +import { eify, timeout } from "~/utils"; type EncryptPasswordForm = { existingPassword: string; diff --git a/src/routes/settings/Plus.tsx b/src/routes/settings/Plus.tsx index f184d5b..f72a194 100644 --- a/src/routes/settings/Plus.tsx +++ b/src/routes/settings/Plus.tsx @@ -27,8 +27,7 @@ import { } from "~/components"; import { useI18n } from "~/i18n/context"; import { useMegaStore } from "~/state/megaStore"; -import eify from "~/utils/eify"; -import { subscriptionValid } from "~/utils/subscriptions"; +import { eify, subscriptionValid } from "~/utils"; function Perks(props: { alreadySubbed?: boolean }) { const i18n = useI18n(); diff --git a/src/routes/settings/Restore.tsx b/src/routes/settings/Restore.tsx index 0d3b5b8..e5b0683 100644 --- a/src/routes/settings/Restore.tsx +++ b/src/routes/settings/Restore.tsx @@ -29,8 +29,7 @@ import { } from "~/components"; import { useI18n } from "~/i18n/context"; import { useMegaStore } from "~/state/megaStore"; -import eify from "~/utils/eify"; -import { WORDS_EN } from "~/utils/words"; +import { eify, WORDS_EN } from "~/utils"; type SeedWordsForm = { words: string[]; diff --git a/src/routes/settings/Servers.tsx b/src/routes/settings/Servers.tsx index 5c543c9..36c9f01 100644 --- a/src/routes/settings/Servers.tsx +++ b/src/routes/settings/Servers.tsx @@ -20,7 +20,7 @@ import { setSettings } from "~/logic/mutinyWalletSetup"; import { useMegaStore } from "~/state/megaStore"; -import eify from "~/utils/eify"; +import { eify } from "~/utils"; export function SettingsStringsEditor() { const i18n = useI18n(); diff --git a/src/state/megaStore.tsx b/src/state/megaStore.tsx index 8787b02..efa4b53 100644 --- a/src/state/megaStore.tsx +++ b/src/state/megaStore.tsx @@ -21,9 +21,7 @@ import { setupMutinyWallet } from "~/logic/mutinyWalletSetup"; import { ParsedParams } from "~/logic/waila"; -import eify from "~/utils/eify"; -import { subscriptionValid } from "~/utils/subscriptions"; -import { MutinyTagItem } from "~/utils/tags"; +import { eify, MutinyTagItem, subscriptionValid } from "~/utils"; const MegaStoreContext = createContext(); diff --git a/src/utils/eify.ts b/src/utils/eify.ts index 6ff6fcb..bda3fee 100644 --- a/src/utils/eify.ts +++ b/src/utils/eify.ts @@ -1,5 +1,5 @@ /// Sometimes we catch an error as `unknown` so this turns it into an Error. -export default function eify(e: unknown): Error { +export function eify(e: unknown): Error { if (e instanceof Error) { return e; } else if (typeof e === "string") { diff --git a/src/utils/getHostname.ts b/src/utils/getHostname.ts index eddc959..be1fc15 100644 --- a/src/utils/getHostname.ts +++ b/src/utils/getHostname.ts @@ -1,4 +1,4 @@ -export default function getHostname(url: string): string { +export function getHostname(url: string): string { // Check if the URL begins with "ws://" or "wss://" if (url.startsWith("ws://")) { // If it does, remove "ws://" from the URL diff --git a/src/utils/index.ts b/src/utils/index.ts new file mode 100644 index 0000000..d9e5e55 --- /dev/null +++ b/src/utils/index.ts @@ -0,0 +1,16 @@ +export * from "./conversions"; +export * from "./deepSignal"; +export * from "./download"; +export * from "./eify"; +export * from "./fakeLabels"; +export * from "./getHostname"; +export * from "./gradientHash"; +export * from "./mempoolTxUrl"; +export * from "./objectToSearchParams"; +export * from "./prettyPrintTime"; +export * from "./subscriptions"; +export * from "./tags"; +export * from "./timeout"; +export * from "./typescript"; +export * from "./useCopy"; +export * from "./words"; diff --git a/src/utils/mempoolTxUrl.ts b/src/utils/mempoolTxUrl.ts index 917a595..b6a24bc 100644 --- a/src/utils/mempoolTxUrl.ts +++ b/src/utils/mempoolTxUrl.ts @@ -1,6 +1,6 @@ import { Network } from "~/logic/mutinyWalletSetup"; -export default function mempoolTxUrl(txid?: string, network?: Network) { +export function mempoolTxUrl(txid?: string, network?: Network) { if (!txid || !network) { console.error("Problem creating the mempool url"); return "#";