Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('Should be able init wallet', async() => {
await accountControl.auth.setPassword(password)
currentAccount = await accountControl.initWallet(SEED)
expect(currentAccount.index).toBe(0)
expect(currentAccount.publicKey).toBeTruthy()
expect(verifyPrivateKey(currentAccount.privateKey)).toBeTruthy()
expect(currentAccount.balance).not.toBeNull()
expect(toChecksumAddress(currentAccount.address)).toBeTruthy()
})
async getAccountByPrivateKey(importPrivateKey, index = 0) {
if (!verifyPrivateKey(importPrivateKey)) {
throw new Error(errorsCode.WrongPrivateKey)
}
const account = {
privateKey: importPrivateKey,
publicKey: getPubKeyFromPrivateKey(importPrivateKey),
address: getAddressFromPrivateKey(importPrivateKey)
}
const { result } = await this.getBalance(account.address)
account.address = toChecksumAddress(account.address)
return {
...account,
index,
balance: result