Skip to content

Commit

Permalink
Experimental code cleanup and a bug fix on provider
Browse files Browse the repository at this point in the history
  • Loading branch information
KaffinPX committed Sep 15, 2024
1 parent 21cf959 commit 83d1a60
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/pages/Wallet/Send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<KaspaInput[]>(JSON.parse(params.get('inputs')!) || [])
const [ outputs, setOutputs ] = useState<[ string, string ][]>(JSON.parse(params.get('outputs')!) || [["", ""]])
const [ feeRate, setFeerate ] = useState(1)
const [ inputs ] = useState<CustomInput[]>(JSON.parse(params.get('inputs') ?? `[]`))
const [ fee ] = useState(params.get('fee') ?? "0")
const [ transactions, setTransactions ] = useState<string[]>()
const [ error, setError ] = useState("")
const [ tab, setTab ] = useState(Tabs.Creation)
Expand Down Expand Up @@ -152,7 +152,7 @@ export default function SendDrawer () {
</Button>
</div>
</div>
<div className="flex items-center gap-1 h-6 -mt-4">
<div className="flex items-center gap-1 h-6 -mt-3">
<TargetIcon size={18} />
<p className="font-semibold text-sm">
Priority
Expand Down Expand Up @@ -181,7 +181,7 @@ export default function SendDrawer () {
default
</Button>
</div>
<Button className={"gap-2"} disabled={!!transactions} onClick={initiateSend}>
<Button className={"gap-2"} disabled={!!transactions} onClick={initiateSend} autoFocus>
<SendToBack />
{i18n.getMessage('send')}
</Button>
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/messaging/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export interface EventMessage<M extends keyof EventMappings = keyof EventMapping
}

export type Event<M extends keyof EventMappings = keyof EventMappings> = {
[ K in M]: EventMessage<K>
[ K in M ]: EventMessage<K>
}[ M ]

export function isEvent (message: any): message is Event {
Expand Down
3 changes: 2 additions & 1 deletion src/wallet/messaging/wallet/provider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 83d1a60

Please sign in to comment.