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.21 to 0.0.22

2

dist/account.d.ts

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

readonly checksumAddress: string;
readonly bech32Address: string;
readonly bech32TestNetAddress: string;
/**

@@ -32,0 +34,0 @@ * @function getShardsCount getShards number with this Account

@@ -46,3 +46,3 @@ "use strict";

get: function () {
return this.address ? crypto_1.toChecksumAddress(this.address) : '';
return this.address ? crypto_1.getAddress(this.address).checksum : '';
},

@@ -52,2 +52,16 @@ enumerable: true,

});
Object.defineProperty(Account.prototype, "bech32Address", {
get: function () {
return this.address ? crypto_1.getAddress(this.address).bech32 : '';
},
enumerable: true,
configurable: true
});
Object.defineProperty(Account.prototype, "bech32TestNetAddress", {
get: function () {
return this.address ? crypto_1.getAddress(this.address).bech32TestNet : '';
},
enumerable: true,
configurable: true
});
Object.defineProperty(Account.prototype, "getShardsCount", {

@@ -54,0 +68,0 @@ /**

65

dist/index.cjs.js

@@ -424,2 +424,41 @@ /**

/**
* @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 __awaiter(this, void 0, void 0, function () {
var newAcc, result, error_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
newAcc = new 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

@@ -467,3 +506,3 @@ * @description create a new account using Mnemonic

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

@@ -493,4 +532,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*/];

@@ -512,3 +551,3 @@ }

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

@@ -539,4 +578,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*/];

@@ -555,3 +594,3 @@ }

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

@@ -565,3 +604,3 @@ /**

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

@@ -589,3 +628,3 @@ this.defaultSigner = undefined;

return __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 __generator(this, function (_a) {

@@ -618,4 +657,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];

@@ -634,4 +673,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];

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

@@ -6,3 +6,3 @@ /**

import { HttpProvider, Messenger } from '@harmony-js/network';
import { generatePrivateKey, getAddressFromPrivateKey, getPubkeyFromPrivateKey, toChecksumAddress, encrypt, decrypt, bip39, hdkey } from '@harmony-js/crypto';
import { generatePrivateKey, getAddressFromPrivateKey, getPubkeyFromPrivateKey, toChecksumAddress, encrypt, decrypt, bip39, hdkey, getAddress } from '@harmony-js/crypto';
import { isPrivateKey, add0xToString, hexToNumber, isAddress } from '@harmony-js/utils';

@@ -421,2 +421,41 @@ import { RLPSign } from '@harmony-js/transaction';

/**
* @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 __awaiter(this, void 0, void 0, function () {
var newAcc, result, error_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
newAcc = new 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

@@ -464,3 +503,3 @@ * @description create a new account using Mnemonic

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

@@ -490,4 +529,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*/];

@@ -509,3 +548,3 @@ }

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

@@ -536,4 +575,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*/];

@@ -552,3 +591,3 @@ }

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

@@ -562,3 +601,3 @@ /**

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

@@ -586,3 +625,3 @@ this.defaultSigner = undefined;

return __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 __generator(this, function (_a) {

@@ -615,4 +654,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];

@@ -631,4 +670,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];

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

@@ -421,2 +421,41 @@ /**

/**
* @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 __awaiter(this, void 0, void 0, function () {
var newAcc, result, error_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
newAcc = new 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

@@ -464,3 +503,3 @@ * @description create a new account using Mnemonic

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

@@ -490,4 +529,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*/];

@@ -509,3 +548,3 @@ }

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

@@ -536,4 +575,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*/];

@@ -552,3 +591,3 @@ }

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

@@ -562,3 +601,3 @@ /**

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

@@ -586,3 +625,3 @@ this.defaultSigner = undefined;

return __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 __generator(this, function (_a) {

@@ -615,4 +654,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];

@@ -631,4 +670,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];

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

{
"name": "@harmony-js/account",
"version": "0.0.21",
"version": "0.0.22",
"description": "account and wallet for harmony",

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

"dependencies": {
"@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"
"@harmony-js/core": "0.0.22",
"@harmony-js/crypto": "0.0.22",
"@harmony-js/network": "0.0.22",
"@harmony-js/transaction": "0.0.22",
"@harmony-js/utils": "0.0.22"
},
"gitHead": "7a51fd2bcccc294bd32f991181f755fdbc88f6e8"
"gitHead": "5c53415c333ab12d727fc1808be2e603d40489e0"
}

@@ -5,3 +5,3 @@ import {

getPubkeyFromPrivateKey,
toChecksumAddress,
// toChecksumAddress,
encrypt,

@@ -12,2 +12,3 @@ decrypt,

Signature,
getAddress,
} from '@harmony-js/crypto';

@@ -54,4 +55,10 @@

get checksumAddress(): string {
return this.address ? toChecksumAddress(this.address) : '';
return this.address ? getAddress(this.address).checksum : '';
}
get bech32Address(): string {
return this.address ? getAddress(this.address).bech32 : '';
}
get bech32TestNetAddress(): string {
return this.address ? getAddress(this.address).bech32TestNet : '';
}

@@ -58,0 +65,0 @@ /**

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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