Skip to content

Commit

Permalink
Modifications (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
Krish-bhardwaj authored Jun 27, 2023
1 parent 739e4f5 commit ef936e1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ const event: {
network: vscode.EventEmitter<string>
account: vscode.EventEmitter<string>
contracts: vscode.EventEmitter<any>
updateAccountList: vscode.EventEmitter<string[]>
} = {
network: new vscode.EventEmitter<string>(),
account: new vscode.EventEmitter<string>(),
contracts: new vscode.EventEmitter<any>()
contracts: new vscode.EventEmitter<any>(),
updateAccountList: new vscode.EventEmitter<string[]>()
}

// PROVIDER
Expand Down
12 changes: 11 additions & 1 deletion src/api/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ export interface EventsInterface {
* @type {vscode.EventEmitter<any>}
*/
contracts: vscode.EventEmitter<any>

/**
* An event emitter for Account List change.
*
* @event
* @type {vscode.EventEmitter<any>}
*/
updateAccountList: vscode.EventEmitter<any>
}

/**
Expand All @@ -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
}
}
7 changes: 3 additions & 4 deletions src/utils/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit ef936e1

Please sign in to comment.