Skip to content

Commit

Permalink
refactor: use worker message types in fedimint wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
okjodom committed Oct 4, 2024
1 parent 058b91b commit 9df4e9f
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions packages/core-web/src/FedimintWallet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WorkerClient } from './worker/WorkerClient'
import { WorkerClient, WorkerMessageType } from './worker'
import {
BalanceService,
MintService,
Expand Down Expand Up @@ -85,9 +85,12 @@ export class FedimintWallet {
await this._client.initialize()
// TODO: Determine if this should be safe or throw
if (this._isOpen) throw new Error('The FedimintWallet is already open.')
const { success } = await this._client.sendSingleMessage('open', {
clientName,
})
const { success } = await this._client.sendSingleMessage(
WorkerMessageType.Open,
{
clientName,
},
)
if (success) {
this._isOpen = !!success
this._resolveOpen()
Expand All @@ -105,10 +108,13 @@ export class FedimintWallet {
throw new Error(
'The FedimintWallet is already open. You can only call `joinFederation` on closed clients.',
)
const response = await this._client.sendSingleMessage('join', {
inviteCode,
clientName,
})
const response = await this._client.sendSingleMessage(
WorkerMessageType.Join,
{
inviteCode,
clientName,
},
)
if (response.success) {
this._isOpen = true
this._resolveOpen()
Expand Down

0 comments on commit 9df4e9f

Please sign in to comment.