Skip to content

Commit

Permalink
fix(kmd): handle empty password correctly in getPassword (#318)
Browse files Browse the repository at this point in the history
When using KMD wallet for localnet, it's common that the password is set to an empty string. In this case, the memoised logic failed to detect the existing password.

To fix this:
- the password field is initialised to null
- the memoised logic returns the password if it is not null
  • Loading branch information
PatrickDinh authored Nov 28, 2024
1 parent 9107b30 commit 4c2f5a8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/use-wallet/src/wallets/kmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class KmdWallet extends BaseWallet {
private options: KmdConstructor
private walletName: string
private walletId: string = ''
private password: string = ''
private password: string | null = null

protected store: Store<State>

Expand Down Expand Up @@ -302,7 +302,7 @@ export class KmdWallet extends BaseWallet {
}

private getPassword(): string {
if (this.password) {
if (this.password !== null) {
return this.password
}
const password = prompt('KMD password') || ''
Expand Down

0 comments on commit 4c2f5a8

Please sign in to comment.