diff --git a/src/api/api.ts b/src/api/api.ts index 799d183..296242c 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -23,10 +23,12 @@ const event: { network: vscode.EventEmitter account: vscode.EventEmitter contracts: vscode.EventEmitter + updateAccountList: vscode.EventEmitter } = { network: new vscode.EventEmitter(), account: new vscode.EventEmitter(), - contracts: new vscode.EventEmitter() + contracts: new vscode.EventEmitter(), + updateAccountList: new vscode.EventEmitter() } // PROVIDER diff --git a/src/api/events.ts b/src/api/events.ts index 4a3fb98..4d02de2 100644 --- a/src/api/events.ts +++ b/src/api/events.ts @@ -28,6 +28,14 @@ export interface EventsInterface { * @type {vscode.EventEmitter} */ contracts: vscode.EventEmitter + + /** + * An event emitter for Account List change. + * + * @event + * @type {vscode.EventEmitter} + */ + updateAccountList: vscode.EventEmitter } /** @@ -40,10 +48,12 @@ export function events (): EventsInterface { const network = event.network const account = event.account const contracts = event.contracts + const updateAccountList = event.updateAccountList return { network, account, - contracts + contracts, + updateAccountList } } diff --git a/src/utils/wallet.ts b/src/utils/wallet.ts index 1f6b929..7ba0584 100644 --- a/src/utils/wallet.ts +++ b/src/utils/wallet.ts @@ -76,10 +76,9 @@ const createKeyPair: any = (context: vscode.ExtensionContext, path: string, pswd fs.mkdirSync(`${path}/keystore`) } keythereum.exportToFile(keyObject, `${path}/keystore`) - listAddresses(context, path) - .catch((error: any) => { - logger.error(error) - }) + listAddresses(context, path).then((addresses: string[]) => { + event.updateAccountList.fire(addresses) + }).catch((error: any) => logger.error(error)) return keyObject.address }