lunesjs 1.6.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -6,9 +6,7 @@ declare const _default: {
6
6
  cryptoUtils: {
7
7
  fromExistingSeed: (seed: string, nonce: number, chain: import("./wallet/wallet.types").WalletTypes.Chain) => import("./wallet/wallet.types").IAccount;
8
8
  fromPrivateKey: (privateKey: string, chain: import("./wallet/wallet.types").WalletTypes.Chain) => import("./wallet/wallet.types").IAccount;
9
- fromPublicKey: (publicKey: string, chain: import("./wallet/wallet.types").WalletTypes.Chain) => import("./wallet/wallet.types").IAccount;
10
- fromAddress: (address: string, chain: import("./wallet/wallet.types").WalletTypes.Chain) => import("./wallet/wallet.types").IAccount;
11
- fromNewSeed: (nWords: number, nonce: number, chain: import("./wallet/wallet.types").WalletTypes.Chain) => import("./wallet/wallet.types").IAccount;
9
+ fromNewSeed: (seedLen: number, nonce: number, chain: import("./wallet/wallet.types").WalletTypes.Chain) => import("./wallet/wallet.types").IAccount;
12
10
  validateAddress: (address: string, chain: import("./wallet/wallet.types").WalletTypes.Chain) => boolean;
13
11
  validateSignature: (publicKey: string, message: string, signature: string) => boolean;
14
12
  fastSignature: (privateKey: string, message: string) => string;
@@ -2,9 +2,7 @@ import { IAccount, WalletTypes } from "../wallet/wallet.types";
2
2
  export declare const cryptoUtils: {
3
3
  fromExistingSeed: (seed: string, nonce: number, chain: WalletTypes.Chain) => IAccount;
4
4
  fromPrivateKey: (privateKey: string, chain: WalletTypes.Chain) => IAccount;
5
- fromPublicKey: (publicKey: string, chain: WalletTypes.Chain) => IAccount;
6
- fromAddress: (address: string, chain: WalletTypes.Chain) => IAccount;
7
- fromNewSeed: (nWords: number, nonce: number, chain: WalletTypes.Chain) => IAccount;
5
+ fromNewSeed: (seedLen: number, nonce: number, chain: WalletTypes.Chain) => IAccount;
8
6
  validateAddress: (address: string, chain: WalletTypes.Chain) => boolean;
9
7
  validateSignature: (publicKey: string, message: string, signature: string) => boolean;
10
8
  fastSignature: (privateKey: string, message: string) => string;
@@ -56,32 +56,11 @@ exports.cryptoUtils = {
56
56
  address: wasm.arrayToBase58(address)
57
57
  };
58
58
  },
59
- fromPublicKey: (publicKey, chain) => {
60
- const address = wasm.toAddress(1, chain, wasm.base58ToArray(publicKey));
61
- return {
62
- seed: "",
63
- nonce: 0,
64
- privateKey: "",
65
- chain: chain,
66
- publicKey: publicKey,
67
- address: wasm.arrayToBase58(address)
68
- };
69
- },
70
- fromAddress: (address, chain) => {
71
- return {
72
- seed: "",
73
- nonce: 0,
74
- privateKey: "",
75
- publicKey: "",
76
- chain: chain,
77
- address: address
78
- };
79
- },
80
- fromNewSeed: (nWords, nonce, chain) => {
59
+ fromNewSeed: (seedLen, nonce, chain) => {
81
60
  let seed = [];
82
- nWords = nWords != undefined ? Math.round(nWords / 3) : 4;
83
- for (let i = 0; i < nWords; i++) {
84
- for (let n in wasm.randomTripleNumber()) {
61
+ seedLen = seedLen != undefined ? Math.round(seedLen / 3) : 4;
62
+ for (let i = 0; i < seedLen; i++) {
63
+ for (let n of wasm.randomTripleNumber()) {
85
64
  seed.push(constants_1.default.wordsList[n]);
86
65
  }
87
66
  }
@@ -8,11 +8,9 @@ declare class Account implements IAccount {
8
8
  seed: string;
9
9
  constructor(wallet: IAccount);
10
10
  }
11
- export declare function walletFactory({ privateKey, publicKey, address, nWords, chain, nonce, seed }?: {
11
+ export declare function walletFactory({ privateKey, seedLen, chain, nonce, seed }?: {
12
12
  privateKey?: string;
13
- publicKey?: string;
14
- address?: string;
15
- nWords?: number;
13
+ seedLen?: number;
16
14
  chain?: number;
17
15
  nonce?: number;
18
16
  seed?: string;
@@ -12,21 +12,15 @@ class Account {
12
12
  this.seed = wallet.seed;
13
13
  }
14
14
  }
15
- function walletFactory({ privateKey, publicKey, address, nWords, chain, nonce, seed } = {}) {
15
+ function walletFactory({ privateKey, seedLen, chain, nonce, seed } = {}) {
16
16
  if (seed != undefined) {
17
17
  return new Account(Object.assign({}, crypto_1.cryptoUtils.fromExistingSeed(seed, nonce != undefined ? nonce : 0, chain != undefined ? chain : 1)));
18
18
  }
19
19
  else if (privateKey != undefined) {
20
20
  return new Account(Object.assign({}, crypto_1.cryptoUtils.fromPrivateKey(privateKey, chain != undefined ? chain : 1)));
21
21
  }
22
- else if (publicKey != undefined) {
23
- return new Account(Object.assign({}, crypto_1.cryptoUtils.fromPublicKey(publicKey, chain != undefined ? chain : 1)));
24
- }
25
- else if (address != undefined) {
26
- return new Account(Object.assign({}, crypto_1.cryptoUtils.fromAddress(address, chain != undefined ? chain : 0)));
27
- }
28
22
  else {
29
- return new Account(Object.assign({}, crypto_1.cryptoUtils.fromNewSeed(nWords != undefined ? nWords : 12, nonce != undefined ? nonce : 0, chain != undefined ? chain : 1)));
23
+ return new Account(Object.assign({}, crypto_1.cryptoUtils.fromNewSeed(seedLen != undefined ? seedLen : 12, nonce != undefined ? nonce : 0, chain != undefined ? chain : 1)));
30
24
  }
31
25
  }
32
26
  exports.walletFactory = walletFactory;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lunesjs",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "Library for communication with nodes in mainnet or testnet of the lunes-blockchain network",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",