Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@harmony-js/account

Package Overview
Dependencies
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@harmony-js/account - npm Package Compare versions

Comparing version 0.0.20 to 0.0.21

9

dist/wallet.d.ts

@@ -43,2 +43,11 @@ import { EncryptOptions } from '@harmony-js/crypto';

/**
* @function addByKeyStore
* @memberof Wallet
* @description add an account using privateKey
* @param {string} keyStore - keystore jsonString to add
* @param {string} password - password to decrypt the file
* @return {Account} return added Account
*/
addByKeyStore(keyStore: string, password: string): Promise<Account>;
/**
* @function createAccount

@@ -45,0 +54,0 @@ * @description create a new account using Mnemonic

65

dist/wallet.js

@@ -100,2 +100,41 @@ "use strict";

/**
* @function addByKeyStore
* @memberof Wallet
* @description add an account using privateKey
* @param {string} keyStore - keystore jsonString to add
* @param {string} password - password to decrypt the file
* @return {Account} return added Account
*/
Wallet.prototype.addByKeyStore = function (keyStore, password) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var newAcc, result, error_1;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
newAcc = new account_1.Account(undefined);
return [4 /*yield*/, newAcc.fromFile(keyStore, password)];
case 1:
result = _a.sent();
result.setMessenger(this.messenger);
if (result.address) {
this.accountMap.set(result.address, result);
if (!this.defaultSigner) {
this.setSigner(result.address);
}
return [2 /*return*/, result];
}
else {
throw new Error('add account failed');
}
return [3 /*break*/, 3];
case 2:
error_1 = _a.sent();
throw error_1;
case 3: return [2 /*return*/];
}
});
});
};
/**
* @function createAccount

@@ -143,3 +182,3 @@ * @description create a new account using Mnemonic

return tslib_1.__awaiter(this, void 0, void 0, function () {
var foundAcc, error_1;
var foundAcc, error_2;
return tslib_1.__generator(this, function (_a) {

@@ -169,4 +208,4 @@ switch (_a.label) {

case 4:
error_1 = _a.sent();
throw error_1;
error_2 = _a.sent();
throw error_2;
case 5: return [2 /*return*/];

@@ -188,3 +227,3 @@ }

return tslib_1.__awaiter(this, void 0, void 0, function () {
var foundAcc, error_2;
var foundAcc, error_3;
return tslib_1.__generator(this, function (_a) {

@@ -215,4 +254,4 @@ switch (_a.label) {

case 4:
error_2 = _a.sent();
throw error_2;
error_3 = _a.sent();
throw error_3;
case 5: return [2 /*return*/];

@@ -231,3 +270,3 @@ }

Wallet.prototype.getAccount = function (address) {
return this.accountMap.get(address);
return this.accountMap.get(crypto_1.getAddress(address).basicHex);
};

@@ -241,3 +280,3 @@ /**

Wallet.prototype.removeAccount = function (address) {
this.accountMap.delete(address);
this.accountMap.delete(crypto_1.getAddress(address).basicHex);
if (this.defaultSigner === address) {

@@ -265,3 +304,3 @@ this.defaultSigner = undefined;

return tslib_1.__awaiter(this, void 0, void 0, function () {
var toSignWith, decrypted, signed, error_3, signed, error_4;
var toSignWith, decrypted, signed, error_4, signed, error_5;
return tslib_1.__generator(this, function (_a) {

@@ -294,4 +333,4 @@ switch (_a.label) {

case 5:
error_3 = _a.sent();
throw error_3;
error_4 = _a.sent();
throw error_4;
case 6: return [3 /*break*/, 13];

@@ -310,4 +349,4 @@ case 7:

case 10:
error_4 = _a.sent();
throw error_4;
error_5 = _a.sent();
throw error_5;
case 11: return [3 /*break*/, 13];

@@ -314,0 +353,0 @@ case 12: throw new Error('sign transaction failed');

14

package.json
{
"name": "@harmony-js/account",
"version": "0.0.20",
"version": "0.0.21",
"description": "account and wallet for harmony",

@@ -21,9 +21,9 @@ "main": "dist/index.js",

"dependencies": {
"@harmony-js/core": "0.0.20",
"@harmony-js/crypto": "0.0.20",
"@harmony-js/network": "0.0.20",
"@harmony-js/transaction": "0.0.20",
"@harmony-js/utils": "0.0.20"
"@harmony-js/core": "0.0.21",
"@harmony-js/crypto": "0.0.21",
"@harmony-js/network": "0.0.21",
"@harmony-js/transaction": "0.0.21",
"@harmony-js/utils": "0.0.21"
},
"gitHead": "5b1841346387f4f3f5822f894d2297ee3bf36554"
"gitHead": "7a51fd2bcccc294bd32f991181f755fdbc88f6e8"
}

@@ -1,2 +0,2 @@

import { bip39, hdkey, EncryptOptions } from '@harmony-js/crypto';
import { bip39, hdkey, EncryptOptions, getAddress } from '@harmony-js/crypto';
import { Messenger } from '@harmony-js/network';

@@ -91,2 +91,29 @@ import { isPrivateKey, isAddress } from '@harmony-js/utils';

/**
* @function addByKeyStore
* @memberof Wallet
* @description add an account using privateKey
* @param {string} keyStore - keystore jsonString to add
* @param {string} password - password to decrypt the file
* @return {Account} return added Account
*/
async addByKeyStore(keyStore: string, password: string): Promise<Account> {
try {
const newAcc = new Account(undefined);
const result = await newAcc.fromFile(keyStore, password);
result.setMessenger(this.messenger);
if (result.address) {
this.accountMap.set(result.address, result);
if (!this.defaultSigner) {
this.setSigner(result.address);
}
return result;
} else {
throw new Error('add account failed');
}
} catch (error) {
throw error;
}
}
/**
* @function createAccount

@@ -194,3 +221,3 @@ * @description create a new account using Mnemonic

getAccount(address: string): Account | undefined {
return this.accountMap.get(address);
return this.accountMap.get(getAddress(address).basicHex);
}

@@ -205,3 +232,3 @@

removeAccount(address: string): void {
this.accountMap.delete(address);
this.accountMap.delete(getAddress(address).basicHex);
if (this.defaultSigner === address) {

@@ -208,0 +235,0 @@ this.defaultSigner = undefined;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc