Skip to content

Commit

Permalink
Add hasWallet method to the TypeScript interface
Browse files Browse the repository at this point in the history
  • Loading branch information
mtyszczak authored and Mariusz-Trela committed Sep 4, 2024
1 parent 77400fc commit 7c6186f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions programs/beekeeper/beekeeper_wasm/src/detailed/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ interface IBeekeeperWalletPassword {
password: string;
}

interface IBeekeeperHasWallet {
exists: boolean;
}

interface IBeekeeperWallets {
wallets: Array<{
name: string;
Expand Down Expand Up @@ -45,6 +49,12 @@ export class BeekeeperSession implements IBeekeeperSession {
return wallets;
}

public hasWallet(name: string): boolean {
const result = this.api.extract(this.api.api.has_wallet(this.token, name) as string) as IBeekeeperHasWallet;

return result.exists;
}

public async createWallet(name: string, password: string | undefined, isTemporary: boolean = false): Promise<IWalletCreated> {
if(typeof password === 'string')
this.api.extract(this.api.api.create(this.token, name, password, isTemporary) as string);
Expand Down
11 changes: 11 additions & 0 deletions programs/beekeeper/beekeeper_wasm/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,17 @@ export interface IBeekeeperSession {
*/
getInfo(): IBeekeeperInfo;

/**
* Checks if wallet with given name exists
*
* @param {string} name name of the wallet
*
* @returns {boolean} `true` if a wallet exists otherwise `false`
*
* @throws {BeekeeperError} on any beekeeper API-related error (error parsing response, invalid input, timeout error, fs sync error etc.)
*/
hasWallet(name: string): boolean;

/**
* Lists all of the opened wallets
*
Expand Down

0 comments on commit 7c6186f

Please sign in to comment.