Skip to content
Snippets Groups Projects
Commit 77400fc1 authored by Mateusz Tyszczak's avatar Mateusz Tyszczak :scroll: Committed by Mariusz Trela
Browse files

Add isTemporary argument to the TypeScript interface

parent 308ec72f
No related branches found
No related tags found
3 merge requests!1506Changes made since last release,!1463Merge develop to master for release,!1355[beekeeper] Fixes and some extensions of API endpoints
...@@ -45,9 +45,9 @@ export class BeekeeperSession implements IBeekeeperSession { ...@@ -45,9 +45,9 @@ export class BeekeeperSession implements IBeekeeperSession {
return wallets; return wallets;
} }
public async createWallet(name: string, password?: string): Promise<IWalletCreated> { public async createWallet(name: string, password: string | undefined, isTemporary: boolean = false): Promise<IWalletCreated> {
if(typeof password === 'string') if(typeof password === 'string')
this.api.extract(this.api.api.create(this.token, name, password) as string); this.api.extract(this.api.api.create(this.token, name, password, isTemporary) as string);
else { else {
const result = this.api.extract(this.api.api.create(this.token, name) as string) as IBeekeeperWalletPassword; const result = this.api.extract(this.api.api.create(this.token, name) as string) as IBeekeeperWalletPassword;
({ password } = result); ({ password } = result);
...@@ -55,7 +55,7 @@ export class BeekeeperSession implements IBeekeeperSession { ...@@ -55,7 +55,7 @@ export class BeekeeperSession implements IBeekeeperSession {
await this.api.fs.sync(); await this.api.fs.sync();
const wallet = new BeekeeperLockedWallet(this.api, this, name); const wallet = new BeekeeperLockedWallet(this.api, this, name, isTemporary);
wallet.unlocked = new BeekeeperUnlockedWallet(this.api, this, wallet); wallet.unlocked = new BeekeeperUnlockedWallet(this.api, this, wallet);
this.wallets.set(name, wallet); this.wallets.set(name, wallet);
...@@ -71,7 +71,7 @@ export class BeekeeperSession implements IBeekeeperSession { ...@@ -71,7 +71,7 @@ export class BeekeeperSession implements IBeekeeperSession {
return this.wallets.get(name) as IBeekeeperWallet; return this.wallets.get(name) as IBeekeeperWallet;
this.api.extract(this.api.api.open(this.token, name) as string); this.api.extract(this.api.api.open(this.token, name) as string);
const wallet = new BeekeeperLockedWallet(this.api, this, name); const wallet = new BeekeeperLockedWallet(this.api, this, name, false);
this.wallets.set(name, wallet); this.wallets.set(name, wallet);
......
...@@ -36,6 +36,10 @@ export class BeekeeperUnlockedWallet implements IBeekeeperUnlockedWallet { ...@@ -36,6 +36,10 @@ export class BeekeeperUnlockedWallet implements IBeekeeperUnlockedWallet {
return this.locked.name; return this.locked.name;
} }
get isTemporary(): boolean {
return this.locked.isTemporary;
}
public lock(): BeekeeperLockedWallet { public lock(): BeekeeperLockedWallet {
this.api.extract(this.api.api.lock(this.session.token, this.locked.name) as string); this.api.extract(this.api.api.lock(this.session.token, this.locked.name) as string);
this.locked.unlocked = undefined; this.locked.unlocked = undefined;
...@@ -107,7 +111,8 @@ export class BeekeeperLockedWallet implements IBeekeeperWallet { ...@@ -107,7 +111,8 @@ export class BeekeeperLockedWallet implements IBeekeeperWallet {
public constructor( public constructor(
private readonly api: BeekeeperApi, private readonly api: BeekeeperApi,
private readonly session: BeekeeperSession, private readonly session: BeekeeperSession,
public readonly name: string public readonly name: string,
public readonly isTemporary: boolean
) {} ) {}
public unlock(password: string): IBeekeeperUnlockedWallet { public unlock(password: string): IBeekeeperUnlockedWallet {
......
...@@ -21,6 +21,14 @@ export interface IWallet { ...@@ -21,6 +21,14 @@ export interface IWallet {
* @readonly * @readonly
*/ */
readonly name: string; readonly name: string;
/**
* Indicates if wallet exists only in memory or is saved into a file.
*
* @type {boolean}
* @readonly
*/
readonly isTemporary: boolean;
}; };
export interface IBeekeeperInfo { export interface IBeekeeperInfo {
...@@ -217,6 +225,19 @@ export interface IBeekeeperSession { ...@@ -217,6 +225,19 @@ export interface IBeekeeperSession {
*/ */
createWallet(name: string, password?: string): Promise<IWalletCreated>; createWallet(name: string, password?: string): Promise<IWalletCreated>;
/**
* Creates a new Beekeeper wallet object owned by this session
*
* @param {string} name name of wallet
* @param {?string} password password used for creation of a wallet. Not required and in this case a password is automatically generated and returned
* @param {?boolean} isTemporary If `true` the wallet exists only in memory otherwise is saved into a file. (defaults to `false`)
*
* @returns {Promise<IWalletCreated>} the created unlocked Beekeeper wallet object
*
* @throws {BeekeeperError} on any beekeeper API-related error (error parsing response, invalid input, timeout error, fs sync error etc.)
*/
createWallet(name: string, password: string, isTemporary: boolean): Promise<IWalletCreated>;
/** /**
* Opens Beekeeper wallet object owned by this session * Opens Beekeeper wallet object owned by this session
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment