From 83d1a6018b2752b798160e43904fe894a86bfd21 Mon Sep 17 00:00:00 2001 From: KaffinPX Date: Sun, 15 Sep 2024 03:16:21 +0300 Subject: [PATCH] Experimental code cleanup and a bug fix on provider --- src/pages/Wallet/Send.tsx | 12 ++++++------ src/wallet/messaging/protocol.ts | 2 +- src/wallet/messaging/wallet/provider/index.ts | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/pages/Wallet/Send.tsx b/src/pages/Wallet/Send.tsx index 796c0cb..a5eae03 100644 --- a/src/pages/Wallet/Send.tsx +++ b/src/pages/Wallet/Send.tsx @@ -17,7 +17,7 @@ import { Input } from "@/components/ui/input" import { Dialog } from "@/components/ui/dialog" import useURLParams from "@/hooks/useURLParams" import useKaspa from "@/hooks/useKaspa" -import { CustomInput } from "@/provider/protocol" +import { Input as KaspaInput } from "@/provider/protocol" export enum Tabs { Creation, @@ -29,10 +29,10 @@ export default function SendDrawer () { const { kaspa, request } = useKaspa() const [ hash, params ] = useURLParams() - const [ outputs, setOutputs ] = useState<[ string, string ][]>(JSON.parse(params.get('outputs') ?? `[[ "", "" ]]`)) - const [ fee ] = useState(params.get('fee') ?? "0") + const [ inputs ] = useState(JSON.parse(params.get('inputs')!) || []) + const [ outputs, setOutputs ] = useState<[ string, string ][]>(JSON.parse(params.get('outputs')!) || [["", ""]]) const [ feeRate, setFeerate ] = useState(1) - const [ inputs ] = useState(JSON.parse(params.get('inputs') ?? `[]`)) + const [ fee ] = useState(params.get('fee') ?? "0") const [ transactions, setTransactions ] = useState() const [ error, setError ] = useState("") const [ tab, setTab ] = useState(Tabs.Creation) @@ -152,7 +152,7 @@ export default function SendDrawer () { -
+

Priority @@ -181,7 +181,7 @@ export default function SendDrawer () { default

- diff --git a/src/wallet/messaging/protocol.ts b/src/wallet/messaging/protocol.ts index bd49986..19e695e 100644 --- a/src/wallet/messaging/protocol.ts +++ b/src/wallet/messaging/protocol.ts @@ -78,7 +78,7 @@ export interface EventMessage = { - [ K in M]: EventMessage + [ K in M ]: EventMessage }[ M ] export function isEvent (message: any): message is Event { diff --git a/src/wallet/messaging/wallet/provider/index.ts b/src/wallet/messaging/wallet/provider/index.ts index 34879a9..3531aa8 100644 --- a/src/wallet/messaging/wallet/provider/index.ts +++ b/src/wallet/messaging/wallet/provider/index.ts @@ -103,8 +103,9 @@ export default class Provider extends EventEmitter { this.submitEvent(request.id, 'transact', transaction) } else { this.submitEvent(request.id, 'transact', false, 'User rejected the request.') - this.account.transactions.off('transaction', appendTransaction) } + + this.account.transactions.off('transaction', appendTransaction) }) this.account.transactions.once('transaction', appendTransaction)