lunesjs 1.5.16-nodejs → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +12 -38
- package/lib/index.d.ts +7 -9
- package/lib/index.js +3 -3
- package/lib/{client/transactions → tx}/BaseTransaction.d.ts +0 -0
- package/lib/{client/transactions → tx}/BaseTransaction.js +0 -0
- package/lib/{client/transactions → tx}/transactions.types.d.ts +0 -0
- package/lib/{client/transactions → tx}/transactions.types.js +0 -0
- package/lib/{client/transactions → tx}/transfer/service.transfer.d.ts +0 -0
- package/lib/{client/transactions → tx}/transfer/service.transfer.js +0 -0
- package/lib/{client/transactions → tx}/transfer/transfer.types.d.ts +0 -0
- package/lib/{client/transactions → tx}/transfer/transfer.types.js +0 -0
- package/lib/{client/transactions → tx}/transfer/validator.d.ts +0 -0
- package/lib/{client/transactions → tx}/transfer/validator.js +1 -1
- package/lib/utils/crypto.d.ts +2 -4
- package/lib/utils/crypto.js +5 -26
- package/lib/{client/wallet → wallet}/constants.d.ts +0 -0
- package/lib/{client/wallet → wallet}/constants.js +0 -0
- package/lib/{client/wallet/service.account.d.ts → wallet/wallet.service.d.ts} +2 -4
- package/lib/{client/wallet/service.account.js → wallet/wallet.service.js} +5 -11
- package/lib/{client/wallet → wallet}/wallet.types.d.ts +0 -0
- package/lib/{client/wallet → wallet}/wallet.types.js +0 -0
- package/package.json +3 -3
package/README.md
CHANGED
@@ -1,48 +1,22 @@
|
|
1
|
-
<div align="center">
|
2
|
-
|
3
|
-
<a href="https://lunes.io">
|
4
|
-
<img alt="Lunes" src="static/img/jslogo.png" width="100" />
|
5
|
-
</a>
|
6
|
-
|
7
1
|
# LunesJS
|
8
2
|
|
9
|
-
|
3
|
+
📦 Build based in the WebAssembly by Rust using [LunesRs](https://github.com/lunes-platform/lunesrs) for communication with nodes on the mainnet or testnet of the lunes-blockchain network Allows automation of asset submission, final issuance of token reissue, leasing, registration and creation of a new wallet.
|
10
4
|
|
11
5
|
[![Deploy](https://github.com/lunes-platform/lunesjs/actions/workflows/deploy.yml/badge.svg?branch=main)](https://github.com/lunes-platform/lunesjs/actions/workflows/deploy.yml)
|
12
|
-
[![Test](https://github.com/lunes-platform/lunesjs/actions/workflows/test.yml/badge.svg)](https://github.com/lunes-platform/lunesjs/actions/workflows/test.yml)
|
13
|
-
[![
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
[![Watchers](https://img.shields.io/github/watchers/lunes-platform/lunesjs.svg?color=blueviolet)](https://github.com/lunes-platform/lunesjs/watchers)
|
23
|
-
[![Followers](https://img.shields.io/github/followers/lunes-platform.svg?style=social&label=Follow&maxAge=2592000?color=blueviolet)](https://github.com/lunes-platform?tab=followers)
|
24
|
-
[![Website](https://img.shields.io/website?url=https%3A%2F%2Flunes.io%2F)](https://lunes.io)
|
25
|
-
![PullRequest](https://img.shields.io/github/issues-pr/lunes-platform/lunesjs?color=blueviolet)
|
26
|
-
![PullRequestClosed](https://img.shields.io/github/issues-pr-closed/lunes-platform/lunesjs?color=blueviolet)
|
27
|
-
[![GitHub](https://badgen.net/badge/icon/github?icon=github&label&color=purple)](https://github.com/lunes-platform)
|
28
|
-
![ClosedIssue](https://flat.badgen.net/github/closed-issues/lunes-platform/lunesjs?color=red)
|
29
|
-
|
30
|
-
<a href="https://twitter.com/LunesPlatform" target="_blank">
|
31
|
-
<img alt="Twitter: Lunes Platform" src="https://badgen.net/twitter/follow/lunesplatform?icon=twitter&label=follow @LunesPlatform&color=blue" />
|
32
|
-
</a>
|
33
|
-
<a href="https://t.me/LunesPlatformPT" target="_blank">
|
34
|
-
<img alt="Telegram" src="https://badgen.net/badge/icon/Lunes%20Platform?icon=telegram&label=Telegram&color=blue"/>
|
35
|
-
</a>
|
36
|
-
|
37
|
-
</div>
|
38
|
-
|
39
|
-
## Changelog
|
40
|
-
|
41
|
-
The changelog process for this project is described [here](CHANGELOG.md).
|
6
|
+
[![Test](https://github.com/lunes-platform/lunesjs/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/lunes-platform/lunesjs/actions/workflows/test.yml)
|
7
|
+
[![Lint](https://github.com/lunes-platform/lunesjs/actions/workflows/lint.yml/badge.svg?branch=main)](https://github.com/lunes-platform/lunesjs/actions/workflows/lint.yml)
|
8
|
+
![npm](https://img.shields.io/npm/v/lunesjs)
|
9
|
+
|
10
|
+
![npm](https://img.shields.io/npm/dm/lunesjs)
|
11
|
+
![GitHub last commit](https://img.shields.io/github/last-commit/lunes-platform/lunesjs)
|
12
|
+
![GitHub commit activity](https://img.shields.io/github/commit-activity/m/lunes-platform/lunesjs)
|
13
|
+
|
14
|
+
![NPM](https://img.shields.io/npm/l/lunesjs)
|
15
|
+
![Discord](https://img.shields.io/discord/958424925453058158)
|
42
16
|
|
43
17
|
## Documentation
|
44
18
|
|
45
|
-
The LunesJS documentations is hosted at [ Telescope ](https://
|
19
|
+
The `LunesJS` documentations is hosted at [ Telescope ](https://github.io/telescope/)
|
46
20
|
|
47
21
|
## Contributing
|
48
22
|
|
package/lib/index.d.ts
CHANGED
@@ -1,15 +1,13 @@
|
|
1
|
-
import { transferTokenFactory } from "./
|
2
|
-
import {
|
1
|
+
import { transferTokenFactory } from "./tx/transfer/service.transfer";
|
2
|
+
import { walletFactory } from "./wallet/wallet.service";
|
3
3
|
declare const _default: {
|
4
4
|
transferTokenFactory: typeof transferTokenFactory;
|
5
|
-
|
5
|
+
walletFactory: typeof walletFactory;
|
6
6
|
cryptoUtils: {
|
7
|
-
fromExistingSeed: (seed: string, nonce: number, chain: import("./
|
8
|
-
fromPrivateKey: (privateKey: string, chain: import("./
|
9
|
-
|
10
|
-
|
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;
|
7
|
+
fromExistingSeed: (seed: string, nonce: number, chain: import("./wallet/wallet.types").WalletTypes.Chain) => import("./wallet/wallet.types").IAccount;
|
8
|
+
fromPrivateKey: (privateKey: string, 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;
|
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;
|
15
13
|
fullSignature: (privateKey: string, message: string) => string;
|
package/lib/index.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const service_transfer_1 = require("./
|
4
|
-
const
|
3
|
+
const service_transfer_1 = require("./tx/transfer/service.transfer");
|
4
|
+
const wallet_service_1 = require("./wallet/wallet.service");
|
5
5
|
const crypto_1 = require("./utils/crypto");
|
6
6
|
exports.default = {
|
7
7
|
transferTokenFactory: service_transfer_1.transferTokenFactory,
|
8
|
-
|
8
|
+
walletFactory: wallet_service_1.walletFactory,
|
9
9
|
cryptoUtils: crypto_1.cryptoUtils
|
10
10
|
};
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -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 = require("
|
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 = {
|
package/lib/utils/crypto.d.ts
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
import { IAccount, WalletTypes } from "../
|
1
|
+
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
|
-
|
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;
|
package/lib/utils/crypto.js
CHANGED
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
27
|
};
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
29
|
exports.cryptoUtils = void 0;
|
30
|
-
const constants_1 = __importDefault(require("../
|
30
|
+
const constants_1 = __importDefault(require("../wallet/constants"));
|
31
31
|
const wasm = __importStar(require("lunesrs"));
|
32
32
|
exports.cryptoUtils = {
|
33
33
|
fromExistingSeed: (seed, nonce, chain) => {
|
@@ -56,32 +56,11 @@ exports.cryptoUtils = {
|
|
56
56
|
address: wasm.arrayToBase58(address)
|
57
57
|
};
|
58
58
|
},
|
59
|
-
|
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
|
-
|
83
|
-
for (let i = 0; i <
|
84
|
-
for (let n
|
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
|
}
|
File without changes
|
File without changes
|
@@ -8,11 +8,9 @@ declare class Account implements IAccount {
|
|
8
8
|
seed: string;
|
9
9
|
constructor(wallet: IAccount);
|
10
10
|
}
|
11
|
-
export declare function
|
11
|
+
export declare function walletFactory({ privateKey, seedLen, chain, nonce, seed }?: {
|
12
12
|
privateKey?: string;
|
13
|
-
|
14
|
-
address?: string;
|
15
|
-
nWords?: number;
|
13
|
+
seedLen?: number;
|
16
14
|
chain?: number;
|
17
15
|
nonce?: number;
|
18
16
|
seed?: string;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
4
|
-
const crypto_1 = require("
|
3
|
+
exports.walletFactory = void 0;
|
4
|
+
const crypto_1 = require("../utils/crypto");
|
5
5
|
class Account {
|
6
6
|
constructor(wallet) {
|
7
7
|
this.privateKey = wallet.privateKey;
|
@@ -12,21 +12,15 @@ class Account {
|
|
12
12
|
this.seed = wallet.seed;
|
13
13
|
}
|
14
14
|
}
|
15
|
-
function
|
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(
|
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
|
-
exports.
|
26
|
+
exports.walletFactory = walletFactory;
|
File without changes
|
File without changes
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "lunesjs",
|
3
|
-
"version": "1.
|
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",
|
@@ -23,7 +23,7 @@
|
|
23
23
|
"fmt": "prettier -w .",
|
24
24
|
"fmtc": "prettier -c",
|
25
25
|
"t": "yarn jest",
|
26
|
-
"build": "
|
26
|
+
"build": "tsc"
|
27
27
|
},
|
28
28
|
"devDependencies": {
|
29
29
|
"@types/jest": "^27.0.3",
|
@@ -35,6 +35,6 @@
|
|
35
35
|
},
|
36
36
|
"dependencies": {
|
37
37
|
"axios": "^0.26.1",
|
38
|
-
"lunesrs": "^1.
|
38
|
+
"lunesrs": "^1.9.1"
|
39
39
|
}
|
40
40
|
}
|