Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hazae41 committed Mar 2, 2023
1 parent 67dbeb7 commit dd58773
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/libs/events/events.ts
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
9 changes: 9 additions & 0 deletions src/libs/xswr/pipes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { State } from "@hazae41/xswr";

export namespace Pipes {

export function data<D>(mutator: (d?: D) => D | undefined) {
return (state?: State<D>) => ({ ...state, data: mutator(state?.data) })
}

}
9 changes: 9 additions & 0 deletions src/libs/xswr/pipes.tsx → src/libs/xswr/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ export namespace Results {
return { ...result, data } as Result<R>
}

export async function wrap<T>(callback: () => Promise<T>): Promise<Result<T>> {
try {
const data = await callback()
return { data }
} catch (error: unknown) {
return { error }
}
}

}


File renamed without changes.
10 changes: 0 additions & 10 deletions src/libs/xswr/wrap.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/mods/entities/wallets/all/create.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion src/mods/entities/wallets/data.ts
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
2 changes: 1 addition & 1 deletion src/mods/tor/sockets/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit dd58773

Please sign in to comment.