(args: {
mustBeNew?: boolean;
mustExist?: boolean;
doNotComplete?: boolean;
})
| 92 | } |
| 93 | |
| 94 | async getClient(args: { |
| 95 | mustBeNew?: boolean; |
| 96 | mustExist?: boolean; |
| 97 | doNotComplete?: boolean; |
| 98 | }): Promise<ClientType> { |
| 99 | const { mustBeNew, mustExist, doNotComplete } = args; |
| 100 | |
| 101 | this.client = new Client({ |
| 102 | baseUrl: url.resolve(this.host, '/bws/api'), |
| 103 | supportStaffWalletId: this.walletId |
| 104 | }); |
| 105 | |
| 106 | const exists = this.storage.exists(); |
| 107 | if (exists && mustBeNew) { |
| 108 | Utils.die(`File "${this.filename}" already exists.`); |
| 109 | } |
| 110 | if (!exists) { |
| 111 | if (mustExist) { |
| 112 | Utils.die(`File "${this.filename}" not found.`); |
| 113 | } |
| 114 | return this.client; |
| 115 | } |
| 116 | |
| 117 | _verbose && prompt.intro('Loading wallet'); |
| 118 | const key = await this.load({ doNotComplete, allowCache: true }); |
| 119 | _verbose && prompt.outro(`${!key ? 'Read-only ' : ''}Wallet loaded`); |
| 120 | |
| 121 | return this.client; |
| 122 | } |
| 123 | |
| 124 | async create(args: { |
| 125 | coin?: string; |
no test coverage detected