From dd5877374d73177a75af4f370573c771f602cc69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Haz=20=C3=86=2041?= <4405263+hazae41@users.noreply.github.com> Date: Thu, 2 Mar 2023 11:25:48 +0100 Subject: [PATCH] fix --- src/libs/events/events.ts | 2 +- src/libs/xswr/pipes.ts | 9 +++++++++ src/libs/xswr/{pipes.tsx => results.ts} | 9 +++++++++ src/libs/xswr/{storage.tsx => storage.ts} | 0 src/libs/xswr/wrap.ts | 10 ---------- src/mods/entities/wallets/all/create.tsx | 4 ++-- src/mods/entities/wallets/data.ts | 2 +- src/mods/tor/sockets/context.tsx | 2 +- 8 files changed, 23 insertions(+), 15 deletions(-) create mode 100644 src/libs/xswr/pipes.ts rename src/libs/xswr/{pipes.tsx => results.ts} (56%) rename src/libs/xswr/{storage.tsx => storage.ts} (100%) delete mode 100644 src/libs/xswr/wrap.ts diff --git a/src/libs/events/events.ts b/src/libs/events/events.ts index b876ee8b..d777760d 100644 --- a/src/libs/events/events.ts +++ b/src/libs/events/events.ts @@ -1,4 +1,4 @@ -import { Future } from "libs/futures/future.js" +import { Future } from "@/libs/futures/future.js" import { AbortEvent } from "./abort.js" import { AsyncEventTarget } from "./target.js" diff --git a/src/libs/xswr/pipes.ts b/src/libs/xswr/pipes.ts new file mode 100644 index 00000000..ccb0119b --- /dev/null +++ b/src/libs/xswr/pipes.ts @@ -0,0 +1,9 @@ +import { State } from "@hazae41/xswr"; + +export namespace Pipes { + + export function data(mutator: (d?: D) => D | undefined) { + return (state?: State) => ({ ...state, data: mutator(state?.data) }) + } + +} \ No newline at end of file diff --git a/src/libs/xswr/pipes.tsx b/src/libs/xswr/results.ts similarity index 56% rename from src/libs/xswr/pipes.tsx rename to src/libs/xswr/results.ts index c14edea1..9aba7a1e 100644 --- a/src/libs/xswr/pipes.tsx +++ b/src/libs/xswr/results.ts @@ -9,6 +9,15 @@ export namespace Results { return { ...result, data } as Result } + export async function wrap(callback: () => Promise): Promise> { + try { + const data = await callback() + return { data } + } catch (error: unknown) { + return { error } + } + } + } diff --git a/src/libs/xswr/storage.tsx b/src/libs/xswr/storage.ts similarity index 100% rename from src/libs/xswr/storage.tsx rename to src/libs/xswr/storage.ts diff --git a/src/libs/xswr/wrap.ts b/src/libs/xswr/wrap.ts deleted file mode 100644 index b5993f9c..00000000 --- a/src/libs/xswr/wrap.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Result } from "@hazae41/xswr"; - -export async function wrap(callback: () => Promise): Promise> { - try { - const data = await callback() - return { data } - } catch (error: unknown) { - return { error } - } -} \ No newline at end of file diff --git a/src/mods/entities/wallets/all/create.tsx b/src/mods/entities/wallets/all/create.tsx index e007315c..ada9cf2f 100644 --- a/src/mods/entities/wallets/all/create.tsx +++ b/src/mods/entities/wallets/all/create.tsx @@ -1,7 +1,7 @@ import { Dialog } from "@/libs/modals/dialog"; import { useInputChange, useTextAreaChange } from "@/libs/react/events"; import { CloseProps } from "@/libs/react/props/close"; -import { Results } from "@/libs/xswr/pipes"; +import { Pipes } from "@/libs/xswr/pipes"; import { OppositeTextButton } from "@/mods/components/button"; import { Wallet } from "ethers"; import { useCallback, useEffect, useState } from "react"; @@ -56,7 +56,7 @@ export function WalletCreatorDialog(props: CloseProps) { const { address, privateKey } = wallet const walletd: WalletData = { name, address, privateKey } - mutate(Results.data((prev = []) => [...prev, walletd])) + mutate(Pipes.data((prev = []) => [...prev, walletd])) close() }, [name, wallet, mutate, close]) diff --git a/src/mods/entities/wallets/data.ts b/src/mods/entities/wallets/data.ts index b93409b5..5e7ee387 100644 --- a/src/mods/entities/wallets/data.ts +++ b/src/mods/entities/wallets/data.ts @@ -1,6 +1,6 @@ import { RPC } from "@/libs/rpc/rpc" import { SocketPool } from "@/libs/tor/sockets/pool" -import { Results } from "@/libs/xswr/pipes" +import { Results } from "@/libs/xswr/results" import { storage } from "@/libs/xswr/storage" import { FetcherMore, getSchema, NormalizerMore, useFetch, useSchema } from "@hazae41/xswr" diff --git a/src/mods/tor/sockets/context.tsx b/src/mods/tor/sockets/context.tsx index c7d26e1a..46d9944c 100644 --- a/src/mods/tor/sockets/context.tsx +++ b/src/mods/tor/sockets/context.tsx @@ -18,7 +18,7 @@ export function SocketsProvider(props: ChildrenProps) { const sockets = useMemo(() => { if (!circuits) return - const url = new URL("wss://mainnet.infura.io/ws/v3/b6bf7d3508c941499b10025c0776eaf8") + const url = new URL("wss://goerli.infura.io/ws/v3/b6bf7d3508c941499b10025c0776eaf8") return new SocketPool(url, circuits) }, [circuits])