lunesjs 1.5.11 → 1.5.14-js
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/CHANGELOG.md
ADDED
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
36
|
};
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
38
38
|
const transactions_types_1 = require("../transactions.types");
|
39
|
-
const crypto_1 =
|
39
|
+
const crypto_1 = require("../../../utils/crypto");
|
40
40
|
const wasm = __importStar(require("lunesrs"));
|
41
41
|
const axios_1 = __importDefault(require("axios"));
|
42
42
|
const validator = {
|
@@ -63,8 +63,8 @@ const validator = {
|
|
63
63
|
if (amount <= 0) {
|
64
64
|
return false;
|
65
65
|
}
|
66
|
-
else if (!(crypto_1.
|
67
|
-
crypto_1.
|
66
|
+
else if (!(crypto_1.cryptoUtils.validateAddress(sender, chain) === true &&
|
67
|
+
crypto_1.cryptoUtils.validateAddress(recipient, chain) === true)) {
|
68
68
|
return false;
|
69
69
|
}
|
70
70
|
else {
|
@@ -73,7 +73,7 @@ const validator = {
|
|
73
73
|
},
|
74
74
|
sign: (privateKey, tx) => {
|
75
75
|
const message = validator.serialize(tx.senderPublicKey, tx.assetId, tx.feeAsset, tx.timestamp, tx.amount, tx.fee, tx.recipient);
|
76
|
-
return crypto_1.
|
76
|
+
return crypto_1.cryptoUtils.fastSignature(privateKey, wasm.arrayToBase58(new Uint8Array(message)));
|
77
77
|
},
|
78
78
|
send: (tx) => __awaiter(void 0, void 0, void 0, function* () {
|
79
79
|
yield axios_1.default
|
@@ -1,10 +1,7 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
3
|
exports.accountFactory = void 0;
|
7
|
-
const crypto_1 =
|
4
|
+
const crypto_1 = require("../../utils/crypto");
|
8
5
|
class Account {
|
9
6
|
constructor(wallet) {
|
10
7
|
this.privateKey = wallet.privateKey;
|
@@ -17,19 +14,19 @@ class Account {
|
|
17
14
|
}
|
18
15
|
function accountFactory({ privateKey, publicKey, address, nWords, chain, nonce, seed } = {}) {
|
19
16
|
if (seed != undefined) {
|
20
|
-
return new Account(Object.assign({}, crypto_1.
|
17
|
+
return new Account(Object.assign({}, crypto_1.cryptoUtils.fromExistingSeed(seed, nonce != undefined ? nonce : 0, chain != undefined ? chain : 1)));
|
21
18
|
}
|
22
19
|
else if (privateKey != undefined) {
|
23
|
-
return new Account(Object.assign({}, crypto_1.
|
20
|
+
return new Account(Object.assign({}, crypto_1.cryptoUtils.fromPrivateKey(privateKey, chain != undefined ? chain : 1)));
|
24
21
|
}
|
25
22
|
else if (publicKey != undefined) {
|
26
|
-
return new Account(Object.assign({}, crypto_1.
|
23
|
+
return new Account(Object.assign({}, crypto_1.cryptoUtils.fromPublicKey(publicKey, chain != undefined ? chain : 1)));
|
27
24
|
}
|
28
25
|
else if (address != undefined) {
|
29
|
-
return new Account(Object.assign({}, crypto_1.
|
26
|
+
return new Account(Object.assign({}, crypto_1.cryptoUtils.fromAddress(address, chain != undefined ? chain : 0)));
|
30
27
|
}
|
31
28
|
else {
|
32
|
-
return new Account(Object.assign({}, crypto_1.
|
29
|
+
return new Account(Object.assign({}, crypto_1.cryptoUtils.fromNewSeed(nWords != undefined ? nWords : 12, nonce != undefined ? nonce : 0, chain != undefined ? chain : 1)));
|
33
30
|
}
|
34
31
|
}
|
35
32
|
exports.accountFactory = accountFactory;
|
package/lib/index.d.ts
CHANGED
@@ -1,5 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
import { transferTokenFactory } from "./client/transactions/transfer/service.transfer";
|
2
|
+
import { accountFactory } from "./client/wallet/service.account";
|
3
|
+
declare const _default: {
|
4
|
+
transferTokenFactory: typeof transferTokenFactory;
|
5
|
+
accountFactory: typeof accountFactory;
|
6
|
+
cryptoUtils: {
|
7
|
+
fromExistingSeed: (seed: string, nonce: number, chain: import("./client/wallet/wallet.types").WalletTypes.Chain) => import("./client/wallet/wallet.types").IAccount;
|
8
|
+
fromPrivateKey: (privateKey: string, chain: import("./client/wallet/wallet.types").WalletTypes.Chain) => import("./client/wallet/wallet.types").IAccount;
|
9
|
+
fromPublicKey: (publicKey: string, chain: import("./client/wallet/wallet.types").WalletTypes.Chain) => import("./client/wallet/wallet.types").IAccount;
|
10
|
+
fromAddress: (address: string, chain: import("./client/wallet/wallet.types").WalletTypes.Chain) => import("./client/wallet/wallet.types").IAccount;
|
11
|
+
fromNewSeed: (nWords: number, nonce: number, chain: import("./client/wallet/wallet.types").WalletTypes.Chain) => import("./client/wallet/wallet.types").IAccount;
|
12
|
+
validateAddress: (address: string, chain: import("./client/wallet/wallet.types").WalletTypes.Chain) => boolean;
|
13
|
+
validateSignature: (publicKey: string, message: string, signature: string) => boolean;
|
14
|
+
fastSignature: (privateKey: string, message: string) => string;
|
15
|
+
fullSignature: (privateKey: string, message: string) => string;
|
16
|
+
};
|
17
|
+
};
|
18
|
+
export default _default;
|
package/lib/index.js
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
3
|
+
const service_transfer_1 = require("./client/transactions/transfer/service.transfer");
|
4
|
+
const service_account_1 = require("./client/wallet/service.account");
|
5
|
+
const crypto_1 = require("./utils/crypto");
|
6
|
+
exports.default = {
|
7
|
+
transferTokenFactory: service_transfer_1.transferTokenFactory,
|
8
|
+
accountFactory: service_account_1.accountFactory,
|
9
|
+
cryptoUtils: crypto_1.cryptoUtils
|
10
|
+
};
|
package/lib/utils/crypto.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { IAccount, WalletTypes } from "../client/wallet/wallet.types";
|
2
|
-
declare const cryptoUtils: {
|
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
5
|
fromPublicKey: (publicKey: string, chain: WalletTypes.Chain) => IAccount;
|
@@ -10,4 +10,3 @@ declare const cryptoUtils: {
|
|
10
10
|
fastSignature: (privateKey: string, message: string) => string;
|
11
11
|
fullSignature: (privateKey: string, message: string) => string;
|
12
12
|
};
|
13
|
-
export default cryptoUtils;
|
package/lib/utils/crypto.js
CHANGED
@@ -26,9 +26,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
27
|
};
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
+
exports.cryptoUtils = void 0;
|
29
30
|
const constants_1 = __importDefault(require("../client/wallet/constants"));
|
30
31
|
const wasm = __importStar(require("lunesrs"));
|
31
|
-
|
32
|
+
exports.cryptoUtils = {
|
32
33
|
fromExistingSeed: (seed, nonce, chain) => {
|
33
34
|
const hidden_seed = wasm.hiddenSeed(nonce, seed);
|
34
35
|
const privateKey = wasm.toPrivateKey(hidden_seed);
|
@@ -84,7 +85,7 @@ const cryptoUtils = {
|
|
84
85
|
seed.push(constants_1.default.wordsList[n]);
|
85
86
|
}
|
86
87
|
}
|
87
|
-
return cryptoUtils.fromExistingSeed(seed.join(" "), nonce, chain);
|
88
|
+
return exports.cryptoUtils.fromExistingSeed(seed.join(" "), nonce, chain);
|
88
89
|
},
|
89
90
|
validateAddress: (address, chain) => {
|
90
91
|
return wasm.validateAddress(chain, wasm.base58ToArray(address));
|
@@ -99,4 +100,3 @@ const cryptoUtils = {
|
|
99
100
|
return wasm.arrayToBase58(wasm.fullSignature(wasm.base58ToArray(privateKey), wasm.base58ToArray(message)));
|
100
101
|
}
|
101
102
|
};
|
102
|
-
exports.default = cryptoUtils;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "lunesjs",
|
3
|
-
"version": "1.5.
|
3
|
+
"version": "1.5.14-js",
|
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",
|
@@ -10,7 +10,7 @@
|
|
10
10
|
"README.md",
|
11
11
|
"package.json"
|
12
12
|
],
|
13
|
-
"repository": "
|
13
|
+
"repository": "https://github.com/lunes-platform/lunesjs.git",
|
14
14
|
"keywords": [
|
15
15
|
"blockchain",
|
16
16
|
"lunes",
|
@@ -19,6 +19,7 @@
|
|
19
19
|
"author": "lunes-platform",
|
20
20
|
"license": "Apache-2.0",
|
21
21
|
"scripts": {
|
22
|
+
"deploy": "yarn build && yarn publish",
|
22
23
|
"fmt": "prettier -w .",
|
23
24
|
"fmtc": "prettier -c",
|
24
25
|
"test": "yarn jest",
|
@@ -34,6 +35,6 @@
|
|
34
35
|
},
|
35
36
|
"dependencies": {
|
36
37
|
"axios": "^0.26.1",
|
37
|
-
"lunesrs": "^1.8.2-
|
38
|
+
"lunesrs": "^1.8.2-nodejs"
|
38
39
|
}
|
39
|
-
}
|
40
|
+
}
|