lunesjs 1.5.9 → 1.5.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,20 +0,0 @@
1
- import { IAccount } from "./wallet.types";
2
- declare class Account implements IAccount {
3
- privateKey: string;
4
- publicKey: string;
5
- address: string;
6
- chain: number;
7
- nonce: number;
8
- seed: string;
9
- constructor(wallet: IAccount);
10
- }
11
- export declare function accountFactory({ privateKey, publicKey, address, nWords, chain, nonce, seed }?: {
12
- privateKey?: string;
13
- publicKey?: string;
14
- address?: string;
15
- nWords?: number;
16
- chain?: number;
17
- nonce?: number;
18
- seed?: string;
19
- }): Account;
20
- export {};
@@ -1,35 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.accountFactory = void 0;
7
- const crypto_1 = __importDefault(require("../../utils/crypto"));
8
- class Account {
9
- constructor(wallet) {
10
- this.privateKey = wallet.privateKey;
11
- this.publicKey = wallet.publicKey;
12
- this.address = wallet.address;
13
- this.chain = wallet.chain;
14
- this.nonce = wallet.nonce;
15
- this.seed = wallet.seed;
16
- }
17
- }
18
- function accountFactory({ privateKey, publicKey, address, nWords, chain, nonce, seed } = {}) {
19
- if (seed != undefined) {
20
- return new Account(Object.assign({}, crypto_1.default.fromExistingSeed(seed, nonce != undefined ? nonce : 0, chain != undefined ? chain : 1)));
21
- }
22
- else if (privateKey != undefined) {
23
- return new Account(Object.assign({}, crypto_1.default.fromPrivateKey(privateKey, chain != undefined ? chain : 1)));
24
- }
25
- else if (publicKey != undefined) {
26
- return new Account(Object.assign({}, crypto_1.default.fromPublicKey(publicKey, chain != undefined ? chain : 1)));
27
- }
28
- else if (address != undefined) {
29
- return new Account(Object.assign({}, crypto_1.default.fromAddress(address, chain != undefined ? chain : 0)));
30
- }
31
- else {
32
- return new Account(Object.assign({}, crypto_1.default.fromNewSeed(nWords != undefined ? nWords : 12, nonce != undefined ? nonce : 0, chain != undefined ? chain : 1)));
33
- }
34
- }
35
- exports.accountFactory = accountFactory;
@@ -1,21 +0,0 @@
1
- export declare type empty = "";
2
- export declare type zero = 0;
3
- export declare namespace WalletTypes {
4
- type Seed = string | empty;
5
- type Nonce = number | zero;
6
- enum Chain {
7
- Mainnet = 1,
8
- Testnet = 0
9
- }
10
- type PrivateKey = string | empty;
11
- type PublicKey = string | empty;
12
- type Address = string | empty;
13
- }
14
- export interface IAccount {
15
- privateKey: WalletTypes.PrivateKey;
16
- publicKey: WalletTypes.PublicKey;
17
- address: WalletTypes.Address;
18
- nonce: WalletTypes.Nonce;
19
- chain: WalletTypes.Chain;
20
- seed: WalletTypes.Seed;
21
- }
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WalletTypes = void 0;
4
- var WalletTypes;
5
- (function (WalletTypes) {
6
- let Chain;
7
- (function (Chain) {
8
- Chain[Chain["Mainnet"] = 1] = "Mainnet";
9
- Chain[Chain["Testnet"] = 0] = "Testnet";
10
- })(Chain = WalletTypes.Chain || (WalletTypes.Chain = {}));
11
- })(WalletTypes = exports.WalletTypes || (exports.WalletTypes = {}));
package/dist/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export { transferTokenFactory } from "./client/transactions/transfer/service.transfer";
2
- export { accountFactory } from "./client/wallet/service.account";
3
- export { WalletTypes } from "./client/wallet/wallet.types";
4
- import cryptoUtils from "./utils/crypto";
5
- export default cryptoUtils;
package/dist/index.js DELETED
@@ -1,14 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.WalletTypes = exports.accountFactory = exports.transferTokenFactory = void 0;
7
- var service_transfer_1 = require("./client/transactions/transfer/service.transfer");
8
- Object.defineProperty(exports, "transferTokenFactory", { enumerable: true, get: function () { return service_transfer_1.transferTokenFactory; } });
9
- var service_account_1 = require("./client/wallet/service.account");
10
- Object.defineProperty(exports, "accountFactory", { enumerable: true, get: function () { return service_account_1.accountFactory; } });
11
- var wallet_types_1 = require("./client/wallet/wallet.types");
12
- Object.defineProperty(exports, "WalletTypes", { enumerable: true, get: function () { return wallet_types_1.WalletTypes; } });
13
- const crypto_1 = __importDefault(require("./utils/crypto"));
14
- exports.default = crypto_1.default;
@@ -1,13 +0,0 @@
1
- import { IAccount, WalletTypes } from "../client/wallet/wallet.types";
2
- declare const cryptoUtils: {
3
- fromExistingSeed: (seed: string, nonce: number, chain: WalletTypes.Chain) => IAccount;
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;
8
- validateAddress: (address: string, chain: WalletTypes.Chain) => boolean;
9
- validateSignature: (publicKey: string, message: string, signature: string) => boolean;
10
- fastSignature: (privateKey: string, message: string) => string;
11
- fullSignature: (privateKey: string, message: string) => string;
12
- };
13
- export default cryptoUtils;
@@ -1,102 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const constants_1 = __importDefault(require("../client/wallet/constants"));
30
- const wasm = __importStar(require("lunesrs"));
31
- const cryptoUtils = {
32
- fromExistingSeed: (seed, nonce, chain) => {
33
- const hidden_seed = wasm.hiddenSeed(nonce, seed);
34
- const privateKey = wasm.toPrivateKey(hidden_seed);
35
- const publicKey = wasm.toPublicKey(privateKey);
36
- const address = wasm.toAddress(1, chain, publicKey);
37
- return {
38
- nonce: nonce,
39
- chain: chain,
40
- seed: seed,
41
- privateKey: wasm.arrayToBase58(privateKey),
42
- publicKey: wasm.arrayToBase58(publicKey),
43
- address: wasm.arrayToBase58(address)
44
- };
45
- },
46
- fromPrivateKey: (privateKey, chain) => {
47
- const publicKey = wasm.toPublicKey(wasm.base58ToArray(privateKey));
48
- const address = wasm.toAddress(1, chain, publicKey);
49
- return {
50
- seed: "",
51
- nonce: 0,
52
- chain: chain,
53
- privateKey: privateKey,
54
- publicKey: wasm.arrayToBase58(publicKey),
55
- address: wasm.arrayToBase58(address)
56
- };
57
- },
58
- fromPublicKey: (publicKey, chain) => {
59
- const address = wasm.toAddress(1, chain, wasm.base58ToArray(publicKey));
60
- return {
61
- seed: "",
62
- nonce: 0,
63
- privateKey: "",
64
- chain: chain,
65
- publicKey: publicKey,
66
- address: wasm.arrayToBase58(address)
67
- };
68
- },
69
- fromAddress: (address, chain) => {
70
- return {
71
- seed: "",
72
- nonce: 0,
73
- privateKey: "",
74
- publicKey: "",
75
- chain: chain,
76
- address: address
77
- };
78
- },
79
- fromNewSeed: (nWords, nonce, chain) => {
80
- let seed = [];
81
- nWords = nWords != undefined ? Math.round(nWords / 3) : 4;
82
- for (let i = 0; i < nWords; i++) {
83
- for (let n in wasm.randomTripleNumber()) {
84
- seed.push(constants_1.default.wordsList[n]);
85
- }
86
- }
87
- return cryptoUtils.fromExistingSeed(seed.join(" "), nonce, chain);
88
- },
89
- validateAddress: (address, chain) => {
90
- return wasm.validateAddress(chain, wasm.base58ToArray(address));
91
- },
92
- validateSignature: (publicKey, message, signature) => {
93
- return wasm.validateSignature(wasm.base58ToArray(publicKey), wasm.base58ToArray(message), wasm.base58ToArray(signature));
94
- },
95
- fastSignature: (privateKey, message) => {
96
- return wasm.arrayToBase58(wasm.fastSignature(wasm.base58ToArray(privateKey), wasm.base58ToArray(message)));
97
- },
98
- fullSignature: (privateKey, message) => {
99
- return wasm.arrayToBase58(wasm.fullSignature(wasm.base58ToArray(privateKey), wasm.base58ToArray(message)));
100
- }
101
- };
102
- exports.default = cryptoUtils;