Skip to content

Commit

Permalink
fix: user deactivated on wallet side
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaccoSordo committed Jan 20, 2025
1 parent 1786ff8 commit c048897
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions packages/beacon-wallet/src/client/WalletClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,22 +237,32 @@ export class WalletClient extends Client {
*/
public async _connect(): Promise<void> {
const transport: WalletP2PTransport = (await this.transport) as WalletP2PTransport
if (transport.connectionStatus === TransportStatus.NOT_CONNECTED) {
if (transport.connectionStatus !== TransportStatus.NOT_CONNECTED) {
return
}

try {
await transport.connect()
transport
.addListener(async (message: unknown, connectionInfo: ConnectionContext) => {
if (typeof message === 'string') {
const deserializedMessage = (await new Serializer().deserialize(
message
)) as BeaconRequestMessage
this.handleResponse(deserializedMessage, connectionInfo)
}
})
.catch((error) => logger.log('_connect', error))
this._isConnected.resolve(true)
} else {
// NO-OP
} catch (err: any) {
logger.warn('_connect', err.message)
if (err.message === 'The account is deactivated.') {
await transport.disconnect()
await this._connect()
return
}
}

transport
.addListener(async (message: unknown, connectionInfo: ConnectionContext) => {
if (typeof message === 'string') {
const deserializedMessage = (await new Serializer().deserialize(
message
)) as BeaconRequestMessage
this.handleResponse(deserializedMessage, connectionInfo)
}
})
.catch((error) => logger.log('_connect', error))
this._isConnected.resolve(true)
}

/**
Expand Down

0 comments on commit c048897

Please sign in to comment.