@leofcoin/lib 1.2.14 → 1.2.15

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/exports/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ContractMessage, TransactionMessage } from '@leofcoin/messages';
2
2
  import { CodecHash } from '@leofcoin/codec-format-interface';
3
- import { validators as validators$1 } from '@leofcoin/addresses';
3
+ import { validators as validators$1, contractFactory as contractFactory$1 } from '@leofcoin/addresses';
4
4
  export { default as nodeConfig } from './node-config.js';
5
5
 
6
6
  var contractFactory = "237,198,141,3,53,89,84,113,119,88,110,55,76,101,103,89,119,65,109,100,117,75,88,119,116,83,52,118,52,100,97,114,113,66,84,81,82,76,90,106,50,57,117,106,112,114,98,104,52,119,121,76,106,112,56,50,87,106,238,4,99,108,97,115,115,32,70,97,99,116,111,114,121,123,35,110,97,109,101,61,34,65,114,116,79,110,108,105,110,101,67,111,110,116,114,97,99,116,70,97,99,116,111,114,121,34,59,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,61,48,59,35,99,111,110,116,114,97,99,116,115,61,91,93,59,99,111,110,115,116,114,117,99,116,111,114,40,115,116,97,116,101,41,123,115,116,97,116,101,38,38,40,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,61,115,116,97,116,101,46,99,111,110,116,114,97,99,116,115,44,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,61,115,116,97,116,101,46,116,111,116,97,108,67,111,110,116,114,97,99,116,115,41,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,116,111,116,97,108,67,111,110,116,114,97,99,116,115,58,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,44,99,111,110,116,114,97,99,116,115,58,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,125,125,103,101,116,32,110,97,109,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,110,97,109,101,125,103,101,116,32,99,111,110,116,114,97,99,116,115,40,41,123,114,101,116,117,114,110,91,46,46,46,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,93,125,103,101,116,32,116,111,116,97,108,67,111,110,116,114,97,99,116,115,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,125,97,115,121,110,99,32,114,101,103,105,115,116,101,114,67,111,110,116,114,97,99,116,40,97,100,100,114,101,115,115,41,123,105,102,40,97,119,97,105,116,32,109,115,103,46,115,116,97,116,105,99,67,97,108,108,40,97,100,100,114,101,115,115,44,34,104,97,115,82,111,108,101,34,44,91,109,115,103,46,115,101,110,100,101,114,44,34,79,87,78,69,82,34,93,41,44,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,46,105,110,99,108,117,100,101,115,40,97,100,100,114,101,115,115,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,97,108,114,101,97,100,121,32,114,101,103,105,115,116,101,114,101,100,34,41,59,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,43,61,49,44,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,46,112,117,115,104,40,97,100,100,114,101,115,115,41,125,125,114,101,116,117,114,110,32,70,97,99,116,111,114,121,59,2,91,93";
@@ -14,55 +14,79 @@ var bytecodes = {
14
14
  validators: validators
15
15
  };
16
16
 
17
- const contractFactoryMessage = bytecodes.contractFactory;
18
- const nativeTokenMessage = bytecodes.nativeToken;
19
- const nameServiceMessage = bytecodes.nameService;
20
- const validatorsMessage = bytecodes.validators;
21
- const createContractMessage = async (creator, contract, constructorParameters = []) => {
22
- return new ContractMessage({
23
- creator,
24
- contract,
25
- constructorParameters
26
- });
27
- };
28
- const calculateFee = async (transaction) => {
29
- // excluded from fees
30
- if (transaction.to === validators$1)
31
- return 0;
32
- // fee per gb
33
- transaction = await new TransactionMessage(transaction);
34
- let fee = transaction.encoded.length;
35
- fee = fee / 1024;
36
- fee = fee / 1000000;
37
- const parts = String(fee).split('.');
38
- let decimals = 0;
39
- if (parts[1]) {
40
- const potentional = parts[1].split('e');
41
- parts[1] = potentional[0];
42
- decimals = Number(potentional[1].replace(/\-|\+/g, '')) + Number(potentional[0].length);
43
- }
44
- return Number.parseFloat(fee.toString()).toFixed(decimals);
45
- };
46
- const calculateTransactionFee = transaction => {
47
- transaction = new TransactionMessage(transaction);
48
- return calculateFee(transaction);
49
- };
50
- const calculateReward = (validators, fees) => {
51
- validators = Object.keys(validators).reduce((set, key) => {
52
- if (validators[key].active)
53
- set.push({
54
- address: key,
55
- reward: 0
56
- });
57
- return set;
58
- }, []);
59
- return validators;
60
- };
61
- const createTransactionHash = async (transaction) => (await new CodecHash(transaction, { name: 'transaction-message' })).digest;
62
- const signTransaction = async (transaction, wallet) => {
63
- const signature = await wallet.sign(await createTransactionHash(transaction));
64
- const signedTransaction = { ...transaction, signature };
65
- return signedTransaction;
17
+ const contractFactoryMessage = bytecodes.contractFactory;
18
+ const nativeTokenMessage = bytecodes.nativeToken;
19
+ const nameServiceMessage = bytecodes.nameService;
20
+ const validatorsMessage = bytecodes.validators;
21
+ const createContractMessage = async (creator, contract, constructorParameters = []) => {
22
+ return new ContractMessage({
23
+ creator,
24
+ contract,
25
+ constructorParameters
26
+ });
27
+ };
28
+ const calculateFee = async (transaction) => {
29
+ // excluded from fees
30
+ if (transaction.to === validators$1)
31
+ return 0;
32
+ // fee per gb
33
+ transaction = await new TransactionMessage(transaction);
34
+ let fee = transaction.encoded.length;
35
+ fee = fee / 1024;
36
+ fee = fee / 1000000;
37
+ const parts = String(fee).split('.');
38
+ let decimals = 0;
39
+ if (parts[1]) {
40
+ const potentional = parts[1].split('e');
41
+ parts[1] = potentional[0];
42
+ decimals = Number(potentional[1].replace(/\-|\+/g, '')) + Number(potentional[0].length);
43
+ }
44
+ return Number.parseFloat(fee.toString()).toFixed(decimals);
45
+ };
46
+ const calculateTransactionFee = transaction => {
47
+ transaction = new TransactionMessage(transaction);
48
+ return calculateFee(transaction);
49
+ };
50
+ const calculateReward = (validators, fees) => {
51
+ validators = Object.keys(validators).reduce((set, key) => {
52
+ if (validators[key].active)
53
+ set.push({
54
+ address: key,
55
+ reward: 0
56
+ });
57
+ return set;
58
+ }, []);
59
+ return validators;
60
+ };
61
+ const createTransactionHash = async (transaction) => (await new CodecHash(transaction, { name: 'transaction-message' })).digest;
62
+ const signTransaction = async (transaction, wallet) => {
63
+ const signature = await wallet.sign(await createTransactionHash(transaction));
64
+ const signedTransaction = { ...transaction, signature };
65
+ return signedTransaction;
66
+ };
67
+ const prepareContractTransaction = async (owner, contract, constructorParameters = []) => {
68
+ const message = await createContractMessage(owner, contract, constructorParameters);
69
+ const hash = await message.hash();
70
+ const transaction = {
71
+ from: owner,
72
+ to: contractFactory$1,
73
+ timestamp: new Date().getTime(),
74
+ method: 'registerContract',
75
+ params: [hash]
76
+ };
77
+ return transaction;
78
+ };
79
+ /**
80
+ *
81
+ * @param owner address
82
+ * @param contract contract code
83
+ * @param constructorParameters ...
84
+ * @param wallet {sign}
85
+ * @returns
86
+ */
87
+ const prepareContractTransactionAndSign = async (owner, contract, constructorParameters = [], wallet) => {
88
+ const transaction = await prepareContractTransaction(owner, contract, constructorParameters);
89
+ return signTransaction(transaction, wallet);
66
90
  };
67
91
 
68
- export { calculateFee, calculateReward, calculateTransactionFee, contractFactoryMessage, createContractMessage, createTransactionHash, nameServiceMessage, nativeTokenMessage, signTransaction, validatorsMessage };
92
+ export { calculateFee, calculateReward, calculateTransactionFee, contractFactoryMessage, createContractMessage, createTransactionHash, nameServiceMessage, nativeTokenMessage, prepareContractTransaction, prepareContractTransactionAndSign, signTransaction, validatorsMessage };
@@ -1,23 +1,23 @@
1
1
  import { ContractMessage, TransactionMessage, BlockMessage, BWMessage, BWRequestMessage, ValidatorMessage } from '@leofcoin/messages';
2
2
 
3
- var nodeConfig = async (config = {
4
- network: 'leofcoin:peach',
5
- networkName: 'leofcoin:peach',
6
- networkVersion: 'v1.0.0'
7
- }) => {
8
- await globalThis.peernet.addProto('contract-message', ContractMessage);
9
- await globalThis.peernet.addProto('transaction-message', TransactionMessage);
10
- await globalThis.peernet.addProto('block-message', BlockMessage);
11
- await globalThis.peernet.addProto('bw-message', BWMessage);
12
- await globalThis.peernet.addProto('bw-request-message', BWRequestMessage);
13
- await globalThis.peernet.addProto('validator-message', ValidatorMessage);
14
- let name = `.${config.network}`;
15
- const parts = config.network.split(':');
16
- if (parts[1])
17
- name = `.${parts[0]}/${parts[1]}`;
18
- await globalThis.peernet.addStore('contract', 'lfc', name, false);
19
- await globalThis.peernet.addStore('accounts', 'lfc', name, false);
20
- await globalThis.peernet.addStore('transactionPool', 'lfc', name, false);
3
+ var nodeConfig = async (config = {
4
+ network: 'leofcoin:peach',
5
+ networkName: 'leofcoin:peach',
6
+ networkVersion: 'v1.0.0'
7
+ }) => {
8
+ await globalThis.peernet.addProto('contract-message', ContractMessage);
9
+ await globalThis.peernet.addProto('transaction-message', TransactionMessage);
10
+ await globalThis.peernet.addProto('block-message', BlockMessage);
11
+ await globalThis.peernet.addProto('bw-message', BWMessage);
12
+ await globalThis.peernet.addProto('bw-request-message', BWRequestMessage);
13
+ await globalThis.peernet.addProto('validator-message', ValidatorMessage);
14
+ let name = `.${config.network}`;
15
+ const parts = config.network.split(':');
16
+ if (parts[1])
17
+ name = `.${parts[0]}/${parts[1]}`;
18
+ await globalThis.peernet.addStore('contract', 'lfc', name, false);
19
+ await globalThis.peernet.addStore('accounts', 'lfc', name, false);
20
+ await globalThis.peernet.addStore('transactionPool', 'lfc', name, false);
21
21
  };
22
22
 
23
23
  export { nodeConfig as default };
@@ -1,30 +1,40 @@
1
- import { ContractMessage } from '@leofcoin/messages';
2
- export { default as nodeConfig } from './node-config.js';
3
- declare type address = string;
4
- declare type transaction = {
5
- from: address;
6
- to: address;
7
- method: string;
8
- params: [];
9
- timestamp: Number;
10
- };
11
- declare type signedTransaction = {
12
- from: address;
13
- to: address;
14
- method: string;
15
- params: [];
16
- timestamp: Number;
17
- };
18
- declare type signable = {
19
- sign: (transaction: any) => Uint8Array;
20
- };
21
- export declare const contractFactoryMessage: string;
22
- export declare const nativeTokenMessage: string;
23
- export declare const nameServiceMessage: string;
24
- export declare const validatorsMessage: string;
25
- export declare const createContractMessage: (creator: any, contract: any, constructorParameters?: any[]) => Promise<ContractMessage>;
26
- export declare const calculateFee: (transaction: any) => Promise<string | 0>;
27
- export declare const calculateTransactionFee: (transaction: any) => Promise<string | 0>;
28
- export declare const calculateReward: (validators: any, fees: any) => [];
29
- export declare const createTransactionHash: (transaction: transaction) => Promise<Uint8Array>;
30
- export declare const signTransaction: (transaction: transaction, wallet: signable) => Promise<signedTransaction>;
1
+ import { ContractMessage } from '@leofcoin/messages';
2
+ export { default as nodeConfig } from './node-config.js';
3
+ declare type address = string;
4
+ declare type transaction = {
5
+ from: address;
6
+ to: address;
7
+ method: string;
8
+ params: any[];
9
+ timestamp: Number;
10
+ };
11
+ declare type signedTransaction = {
12
+ from: address;
13
+ to: address;
14
+ method: string;
15
+ params: any[];
16
+ timestamp: Number;
17
+ };
18
+ declare type signable = {
19
+ sign: (transaction: any) => Uint8Array;
20
+ };
21
+ export declare const contractFactoryMessage: string;
22
+ export declare const nativeTokenMessage: string;
23
+ export declare const nameServiceMessage: string;
24
+ export declare const validatorsMessage: string;
25
+ export declare const createContractMessage: (creator: any, contract: any, constructorParameters?: any[]) => Promise<ContractMessage>;
26
+ export declare const calculateFee: (transaction: any) => Promise<string | 0>;
27
+ export declare const calculateTransactionFee: (transaction: any) => Promise<string | 0>;
28
+ export declare const calculateReward: (validators: any, fees: any) => [];
29
+ export declare const createTransactionHash: (transaction: transaction) => Promise<Uint8Array>;
30
+ export declare const signTransaction: (transaction: transaction, wallet: signable) => Promise<signedTransaction>;
31
+ export declare const prepareContractTransaction: (owner: any, contract: any, constructorParameters?: any[]) => Promise<transaction>;
32
+ /**
33
+ *
34
+ * @param owner address
35
+ * @param contract contract code
36
+ * @param constructorParameters ...
37
+ * @param wallet {sign}
38
+ * @returns
39
+ */
40
+ export declare const prepareContractTransactionAndSign: (owner: any, contract: any, constructorParameters: any[], wallet: any) => Promise<signedTransaction>;
@@ -1,14 +1,14 @@
1
- import { ContractMessage } from '@leofcoin/messages';
2
- export declare const nodeConfig: (config?: {
3
- network: string;
4
- networkName: string;
5
- networkVersion: string;
6
- }) => Promise<void>;
7
- export declare const contractFactoryMessage: string;
8
- export declare const nativeTokenMessage: string;
9
- export declare const nameServiceMessage: string;
10
- export declare const validatorsMessage: string;
11
- export declare const createContractMessage: (creator: any, contract: any, constructorParameters?: any[]) => Promise<ContractMessage>;
12
- export declare const calculateFee: (transaction: any) => Promise<string | 0>;
13
- export declare const calculateTransactionFee: (transaction: any) => Promise<string | 0>;
14
- export declare const calculateReward: (validators: any, fees: any) => [];
1
+ import { ContractMessage } from '@leofcoin/messages';
2
+ export declare const nodeConfig: (config?: {
3
+ network: string;
4
+ networkName: string;
5
+ networkVersion: string;
6
+ }) => Promise<void>;
7
+ export declare const contractFactoryMessage: string;
8
+ export declare const nativeTokenMessage: string;
9
+ export declare const nameServiceMessage: string;
10
+ export declare const validatorsMessage: string;
11
+ export declare const createContractMessage: (creator: any, contract: any, constructorParameters?: any[]) => Promise<ContractMessage>;
12
+ export declare const calculateFee: (transaction: any) => Promise<string | 0>;
13
+ export declare const calculateTransactionFee: (transaction: any) => Promise<string | 0>;
14
+ export declare const calculateReward: (validators: any, fees: any) => [];
@@ -1,6 +1,6 @@
1
- declare const _default: (config?: {
2
- network: string;
3
- networkName: string;
4
- networkVersion: string;
5
- }) => Promise<void>;
6
- export default _default;
1
+ declare const _default: (config?: {
2
+ network: string;
3
+ networkName: string;
4
+ networkVersion: string;
5
+ }) => Promise<void>;
6
+ export default _default;
package/package.json CHANGED
@@ -1,30 +1,30 @@
1
- {
2
- "name": "@leofcoin/lib",
3
- "version": "1.2.14",
4
- "description": "",
5
- "type": "module",
6
- "typings": "./exports/typings/index.d.ts",
7
- "exports": {
8
- ".": "./exports/index.js",
9
- "./node-config": "./exports/node-config.js",
10
- "./bytecodes": "./src/bytecodes.json"
11
- },
12
- "scripts": {
13
- "build": "rollup -c",
14
- "test": "echo \"Error: no test specified\" && exit 1"
15
- },
16
- "keywords": [],
17
- "author": "",
18
- "license": "ISC",
19
- "dependencies": {
20
- "@leofcoin/addresses": "^1.0.6",
21
- "@leofcoin/codec-format-interface": "^1.4.0",
22
- "@leofcoin/messages": "^1.1.2"
23
- },
24
- "devDependencies": {
25
- "@rollup/plugin-json": "^6.0.0",
26
- "@rollup/plugin-typescript": "^11.0.0",
27
- "rollup": "^3.10.1",
28
- "tslib": "^2.4.1"
29
- }
30
- }
1
+ {
2
+ "name": "@leofcoin/lib",
3
+ "version": "1.2.15",
4
+ "description": "",
5
+ "type": "module",
6
+ "typings": "./exports/typings/index.d.ts",
7
+ "exports": {
8
+ ".": "./exports/index.js",
9
+ "./node-config": "./exports/node-config.js",
10
+ "./bytecodes": "./src/bytecodes.json"
11
+ },
12
+ "scripts": {
13
+ "build": "rollup -c",
14
+ "test": "echo \"Error: no test specified\" && exit 1"
15
+ },
16
+ "keywords": [],
17
+ "author": "",
18
+ "license": "ISC",
19
+ "dependencies": {
20
+ "@leofcoin/addresses": "^1.0.6",
21
+ "@leofcoin/codec-format-interface": "^1.4.0",
22
+ "@leofcoin/messages": "^1.1.2"
23
+ },
24
+ "devDependencies": {
25
+ "@rollup/plugin-json": "^6.0.0",
26
+ "@rollup/plugin-typescript": "^11.0.0",
27
+ "rollup": "^3.10.1",
28
+ "tslib": "^2.4.1"
29
+ }
30
+ }
package/rollup.config.js CHANGED
@@ -1,15 +1,15 @@
1
- import json from '@rollup/plugin-json'
2
- import typescript from '@rollup/plugin-typescript'
3
- import tsConfig from './tsconfig.json' assert { type: 'json'}
4
-
5
- export default [{
6
- input: ['./src/index.ts', './src/node-config.ts'],
7
- output: {
8
- dir: './exports',
9
- format: 'es'
10
- },
11
- plugins: [
12
- json(),
13
- typescript(tsConfig)
14
- ]
15
- }]
1
+ import json from '@rollup/plugin-json'
2
+ import typescript from '@rollup/plugin-typescript'
3
+ import tsConfig from './tsconfig.json' assert { type: 'json'}
4
+
5
+ export default [{
6
+ input: ['./src/index.ts', './src/node-config.ts'],
7
+ output: {
8
+ dir: './exports',
9
+ format: 'es'
10
+ },
11
+ plugins: [
12
+ json(),
13
+ typescript(tsConfig)
14
+ ]
15
+ }]
package/src/index.ts CHANGED
@@ -1,88 +1,117 @@
1
- import bytecodes from './bytecodes.json' assert {type: 'json'}
2
- import { ContractMessage, TransactionMessage } from '@leofcoin/messages'
3
- import { CodecHash } from '@leofcoin/codec-format-interface'
4
- import { validators } from '@leofcoin/addresses'
5
- export { default as nodeConfig} from './node-config.js'
6
-
7
- declare type address = string
8
-
9
- declare type transaction = {
10
- from: address,
11
- to: address,
12
- method: string,
13
- params: [],
14
- timestamp: Number
15
- }
16
-
17
- declare type signedTransaction = {
18
- from: address,
19
- to: address,
20
- method: string,
21
- params: [],
22
- timestamp: Number
23
- }
24
-
25
- declare type signable = {
26
- sign: (transaction) => Uint8Array
27
- }
28
-
29
- export const contractFactoryMessage = bytecodes.contractFactory
30
- export const nativeTokenMessage = bytecodes.nativeToken
31
-
32
- export const nameServiceMessage = bytecodes.nameService
33
- export const validatorsMessage = bytecodes.validators
34
-
35
- export const createContractMessage = async (creator, contract, constructorParameters = []) => {
36
- return new ContractMessage({
37
- creator,
38
- contract,
39
- constructorParameters
40
- })
41
- }
42
-
43
- export const calculateFee = async transaction => {
44
- // excluded from fees
45
- if (transaction.to === validators) return 0
46
- // fee per gb
47
- transaction = await new TransactionMessage(transaction)
48
- let fee = transaction.encoded.length
49
- fee = fee / 1024
50
- fee = fee / 1000000
51
- const parts = String(fee).split('.')
52
- let decimals = 0
53
- if (parts[1]) {
54
- const potentional = parts[1].split('e')
55
- parts[1] = potentional[0]
56
- decimals = Number(potentional[1].replace(/\-|\+/g, '')) + Number(potentional[0].length)
57
- }
58
-
59
- return Number.parseFloat(fee.toString()).toFixed(decimals)
60
- }
61
-
62
- export const calculateTransactionFee = transaction => {
63
- transaction = new TransactionMessage(transaction)
64
- return calculateFee(transaction)
65
- }
66
-
67
- export const calculateReward = (validators, fees): [] => {
68
- validators = Object.keys(validators).reduce((set: object[], key) => {
69
- if (validators[key].active) set.push({
70
- address: key,
71
- reward: 0
72
- })
73
- return set
74
-
75
- }, [])
76
-
77
- return validators
78
- }
79
-
80
- export const createTransactionHash = async (transaction: transaction): Promise<Uint8Array> =>
81
- (await new CodecHash(transaction, {name: 'transaction-message'})).digest
82
-
83
- export const signTransaction = async (transaction: transaction, wallet: signable): Promise<signedTransaction> => {
84
- const signature = await wallet.sign(await createTransactionHash(transaction))
85
- const signedTransaction = {...transaction, signature}
86
- return signedTransaction
87
- }
1
+ import bytecodes from './bytecodes.json' assert {type: 'json'}
2
+ import { ContractMessage, TransactionMessage } from '@leofcoin/messages'
3
+ import { CodecHash } from '@leofcoin/codec-format-interface'
4
+ import { validators, contractFactory} from '@leofcoin/addresses'
5
+ export { default as nodeConfig} from './node-config.js'
6
+
7
+ declare type address = string
8
+
9
+ declare type transaction = {
10
+ from: address,
11
+ to: address,
12
+ method: string,
13
+ params: any[],
14
+ timestamp: Number
15
+ }
16
+
17
+ declare type signedTransaction = {
18
+ from: address,
19
+ to: address,
20
+ method: string,
21
+ params: any[],
22
+ timestamp: Number
23
+ }
24
+
25
+ declare type signable = {
26
+ sign: (transaction) => Uint8Array
27
+ }
28
+
29
+ export const contractFactoryMessage = bytecodes.contractFactory
30
+ export const nativeTokenMessage = bytecodes.nativeToken
31
+
32
+ export const nameServiceMessage = bytecodes.nameService
33
+ export const validatorsMessage = bytecodes.validators
34
+
35
+ export const createContractMessage = async (creator, contract, constructorParameters = []) => {
36
+ return new ContractMessage({
37
+ creator,
38
+ contract,
39
+ constructorParameters
40
+ })
41
+ }
42
+
43
+ export const calculateFee = async transaction => {
44
+ // excluded from fees
45
+ if (transaction.to === validators) return 0
46
+ // fee per gb
47
+ transaction = await new TransactionMessage(transaction)
48
+ let fee = transaction.encoded.length
49
+ fee = fee / 1024
50
+ fee = fee / 1000000
51
+ const parts = String(fee).split('.')
52
+ let decimals = 0
53
+ if (parts[1]) {
54
+ const potentional = parts[1].split('e')
55
+ parts[1] = potentional[0]
56
+ decimals = Number(potentional[1].replace(/\-|\+/g, '')) + Number(potentional[0].length)
57
+ }
58
+
59
+ return Number.parseFloat(fee.toString()).toFixed(decimals)
60
+ }
61
+
62
+ export const calculateTransactionFee = transaction => {
63
+ transaction = new TransactionMessage(transaction)
64
+ return calculateFee(transaction)
65
+ }
66
+
67
+ export const calculateReward = (validators, fees): [] => {
68
+ validators = Object.keys(validators).reduce((set: object[], key) => {
69
+ if (validators[key].active) set.push({
70
+ address: key,
71
+ reward: 0
72
+ })
73
+ return set
74
+
75
+ }, [])
76
+
77
+ return validators
78
+ }
79
+
80
+ export const createTransactionHash = async (transaction: transaction): Promise<Uint8Array> =>
81
+ (await new CodecHash(transaction, {name: 'transaction-message'})).digest
82
+
83
+ export const signTransaction = async (transaction: transaction, wallet: signable): Promise<signedTransaction> => {
84
+ const signature = await wallet.sign(await createTransactionHash(transaction))
85
+ const signedTransaction = {...transaction, signature}
86
+ return signedTransaction
87
+ }
88
+
89
+ export const prepareContractTransaction = async (owner, contract, constructorParameters = []) => {
90
+ const message = await createContractMessage(owner, contract, constructorParameters)
91
+ const hash = await message.hash()
92
+
93
+ const transaction: transaction = {
94
+ from: owner,
95
+ to: contractFactory,
96
+ timestamp: new Date().getTime(),
97
+ method: 'registerContract',
98
+ params: [hash]
99
+ }
100
+
101
+ return transaction
102
+ }
103
+
104
+
105
+ /**
106
+ *
107
+ * @param owner address
108
+ * @param contract contract code
109
+ * @param constructorParameters ...
110
+ * @param wallet {sign}
111
+ * @returns
112
+ */
113
+ export const prepareContractTransactionAndSign = async (owner, contract, constructorParameters = [], wallet) => {
114
+ const transaction = await prepareContractTransaction(owner, contract, constructorParameters)
115
+ return signTransaction(transaction, wallet)
116
+ }
88
117
 
@@ -1,21 +1,21 @@
1
- import { ContractMessage, TransactionMessage, BlockMessage, BWMessage, BWRequestMessage, ValidatorMessage } from '@leofcoin/messages'
2
-
3
- export default async (config = {
4
- network: 'leofcoin:peach',
5
- networkName: 'leofcoin:peach',
6
- networkVersion: 'v1.0.0'
7
- }) => {
8
- await globalThis.peernet.addProto('contract-message', ContractMessage)
9
- await globalThis.peernet.addProto('transaction-message', TransactionMessage)
10
- await globalThis.peernet.addProto('block-message', BlockMessage)
11
- await globalThis.peernet.addProto('bw-message', BWMessage)
12
- await globalThis.peernet.addProto('bw-request-message', BWRequestMessage)
13
- await globalThis.peernet.addProto('validator-message', ValidatorMessage)
14
-
15
- let name = `.${config.network}`
16
- const parts = config.network.split(':')
17
- if (parts[1]) name = `.${parts[0]}/${parts[1]}`
18
- await globalThis.peernet.addStore('contract', 'lfc', name, false)
19
- await globalThis.peernet.addStore('accounts', 'lfc', name, false)
20
- await globalThis.peernet.addStore('transactionPool', 'lfc', name, false)
1
+ import { ContractMessage, TransactionMessage, BlockMessage, BWMessage, BWRequestMessage, ValidatorMessage } from '@leofcoin/messages'
2
+
3
+ export default async (config = {
4
+ network: 'leofcoin:peach',
5
+ networkName: 'leofcoin:peach',
6
+ networkVersion: 'v1.0.0'
7
+ }) => {
8
+ await globalThis.peernet.addProto('contract-message', ContractMessage)
9
+ await globalThis.peernet.addProto('transaction-message', TransactionMessage)
10
+ await globalThis.peernet.addProto('block-message', BlockMessage)
11
+ await globalThis.peernet.addProto('bw-message', BWMessage)
12
+ await globalThis.peernet.addProto('bw-request-message', BWRequestMessage)
13
+ await globalThis.peernet.addProto('validator-message', ValidatorMessage)
14
+
15
+ let name = `.${config.network}`
16
+ const parts = config.network.split(':')
17
+ if (parts[1]) name = `.${parts[0]}/${parts[1]}`
18
+ await globalThis.peernet.addStore('contract', 'lfc', name, false)
19
+ await globalThis.peernet.addStore('accounts', 'lfc', name, false)
20
+ await globalThis.peernet.addStore('transactionPool', 'lfc', name, false)
21
21
  }
package/tsconfig.json CHANGED
@@ -1,18 +1,18 @@
1
- {
2
- "compilerOptions": {
3
- "module": "es2022",
4
- "target": "es2022",
5
- "outDir": "./exports",
6
- "moduleResolution":"NodeNext",
7
- "declaration": true,
8
- "declarationDir": "./exports/typings",
9
- "allowJs": true,
10
- "allowSyntheticDefaultImports": true,
11
- "resolveJsonModule": true
12
-
13
- },
14
- "include": [
15
- "./src/**/*"
16
- ],
17
- "exclude": ["./node_modules"]
1
+ {
2
+ "compilerOptions": {
3
+ "module": "esnext",
4
+ "target": "es2022",
5
+ "outDir": "./exports",
6
+ "moduleResolution":"NodeNext",
7
+ "declaration": true,
8
+ "declarationDir": "./exports/typings",
9
+ "allowJs": true,
10
+ "allowSyntheticDefaultImports": true,
11
+ "resolveJsonModule": true
12
+
13
+ },
14
+ "include": [
15
+ "./src/**/*"
16
+ ],
17
+ "exclude": ["./node_modules"]
18
18
  }
package/dist/lib.js DELETED
@@ -1,273 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var codecFormatInterface = require('@leofcoin/codec-format-interface');
6
-
7
- var contractFactory$1 = "237,198,141,3,123,34,99,114,101,97,116,111,114,34,58,34,56,71,85,107,103,52,120,87,113,109,110,83,56,75,101,122,56,107,54,68,115,82,120,90,66,68,97,54,114,71,74,109,104,107,122,67,75,113,78,75,102,85,110,103,90,122,109,54,97,81,34,44,34,99,111,110,116,114,97,99,116,34,58,34,99,108,97,115,115,32,70,97,99,116,111,114,121,123,35,110,97,109,101,61,92,34,65,114,116,79,110,108,105,110,101,67,111,110,116,114,97,99,116,70,97,99,116,111,114,121,92,34,59,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,61,48,59,35,99,111,110,116,114,97,99,116,115,61,91,93,59,99,111,110,115,116,114,117,99,116,111,114,40,115,116,97,116,101,41,123,115,116,97,116,101,38,38,40,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,61,115,116,97,116,101,46,99,111,110,116,114,97,99,116,115,44,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,61,115,116,97,116,101,46,116,111,116,97,108,67,111,110,116,114,97,99,116,115,41,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,116,111,116,97,108,67,111,110,116,114,97,99,116,115,58,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,44,99,111,110,116,114,97,99,116,115,58,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,125,125,103,101,116,32,110,97,109,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,110,97,109,101,125,103,101,116,32,99,111,110,116,114,97,99,116,115,40,41,123,114,101,116,117,114,110,91,46,46,46,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,93,125,103,101,116,32,116,111,116,97,108,67,111,110,116,114,97,99,116,115,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,125,97,115,121,110,99,32,114,101,103,105,115,116,101,114,67,111,110,116,114,97,99,116,40,97,100,100,114,101,115,115,41,123,105,102,40,97,119,97,105,116,32,109,115,103,46,115,116,97,116,105,99,67,97,108,108,40,97,100,100,114,101,115,115,44,92,34,104,97,115,82,111,108,101,92,34,44,91,109,115,103,46,115,101,110,100,101,114,44,92,34,79,87,78,69,82,92,34,93,41,44,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,46,105,110,99,108,117,100,101,115,40,97,100,100,114,101,115,115,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,97,108,114,101,97,100,121,32,114,101,103,105,115,116,101,114,101,100,92,34,41,59,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,43,61,49,44,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,46,112,117,115,104,40,97,100,100,114,101,115,115,41,125,125,114,101,116,117,114,110,32,70,97,99,116,111,114,121,59,34,44,34,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,34,58,91,93,125";
8
- var nativeToken$1 = "237,198,141,3,123,34,99,114,101,97,116,111,114,34,58,34,56,71,85,107,103,52,120,87,113,109,110,83,56,75,101,122,56,107,54,68,115,82,120,90,66,68,97,54,114,71,74,109,104,107,122,67,75,113,78,75,102,85,110,103,90,122,109,54,97,81,34,44,34,99,111,110,116,114,97,99,116,34,58,34,99,108,97,115,115,32,82,111,108,101,115,123,35,114,111,108,101,115,61,123,79,87,78,69,82,58,91,93,44,77,73,78,84,58,91,93,44,66,85,82,78,58,91,93,125,59,99,111,110,115,116,114,117,99,116,111,114,40,114,111,108,101,115,41,123,105,102,40,114,111,108,101,115,41,123,105,102,40,33,40,114,111,108,101,115,32,105,110,115,116,97,110,99,101,111,102,32,79,98,106,101,99,116,41,41,116,104,114,111,119,32,110,101,119,32,84,121,112,101,69,114,114,111,114,40,92,34,101,120,112,101,99,116,101,100,32,114,111,108,101,115,32,116,111,32,98,101,32,97,110,32,111,98,106,101,99,116,92,34,41,59,116,104,105,115,46,35,114,111,108,101,115,61,123,46,46,46,114,111,108,101,115,44,46,46,46,116,104,105,115,46,35,114,111,108,101,115,125,125,101,108,115,101,32,116,104,105,115,46,35,103,114,97,110,116,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,92,34,79,87,78,69,82,92,34,41,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,114,111,108,101,115,58,116,104,105,115,46,114,111,108,101,115,125,125,103,101,116,32,114,111,108,101,115,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,114,111,108,101,115,125,125,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,114,101,116,117,114,110,33,33,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,38,38,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,105,110,99,108,117,100,101,115,40,97,100,100,114,101,115,115,41,125,35,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,36,123,114,111,108,101,125,32,114,111,108,101,32,97,108,114,101,97,100,121,32,103,114,97,110,116,101,100,32,102,111,114,32,36,123,97,100,100,114,101,115,115,125,96,41,59,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,112,117,115,104,40,97,100,100,114,101,115,115,41,125,35,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,36,123,114,111,108,101,125,32,114,111,108,101,32,97,108,114,101,97,100,121,32,114,101,118,111,107,101,100,32,102,111,114,32,36,123,97,100,100,114,101,115,115,125,96,41,59,105,102,40,92,34,79,87,78,69,82,92,34,61,61,61,114,111,108,101,38,38,49,61,61,61,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,108,101,110,103,116,104,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,97,116,108,101,97,115,116,32,111,110,101,32,111,119,110,101,114,32,105,115,32,110,101,101,100,101,100,33,92,34,41,59,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,115,112,108,105,99,101,40,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,105,110,100,101,120,79,102,40,97,100,100,114,101,115,115,41,41,125,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,92,34,79,87,78,69,82,92,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,78,111,116,32,97,108,108,111,119,101,100,92,34,41,59,116,104,105,115,46,35,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,125,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,92,34,79,87,78,69,82,92,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,78,111,116,32,97,108,108,111,119,101,100,92,34,41,59,116,104,105,115,46,35,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,125,125,99,108,97,115,115,32,84,111,107,101,110,32,101,120,116,101,110,100,115,32,82,111,108,101,115,123,35,110,97,109,101,59,35,115,121,109,98,111,108,59,35,104,111,108,100,101,114,115,61,48,59,35,98,97,108,97,110,99,101,115,61,123,125,59,35,97,112,112,114,111,118,97,108,115,61,123,125,59,35,100,101,99,105,109,97,108,115,61,49,56,59,35,116,111,116,97,108,83,117,112,112,108,121,61,66,105,103,78,117,109,98,101,114,46,102,114,111,109,40,48,41,59,99,111,110,115,116,114,117,99,116,111,114,40,110,97,109,101,44,115,121,109,98,111,108,44,100,101,99,105,109,97,108,115,61,49,56,44,115,116,97,116,101,41,123,105,102,40,33,110,97,109,101,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,97,109,101,32,117,110,100,101,102,105,110,101,100,92,34,41,59,105,102,40,33,115,121,109,98,111,108,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,115,121,109,98,111,108,32,117,110,100,101,102,105,110,101,100,92,34,41,59,115,117,112,101,114,40,115,116,97,116,101,63,46,114,111,108,101,115,41,44,116,104,105,115,46,35,110,97,109,101,61,110,97,109,101,44,116,104,105,115,46,35,115,121,109,98,111,108,61,115,121,109,98,111,108,44,116,104,105,115,46,35,100,101,99,105,109,97,108,115,61,100,101,99,105,109,97,108,115,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,46,46,46,115,117,112,101,114,46,115,116,97,116,101,44,104,111,108,100,101,114,115,58,116,104,105,115,46,104,111,108,100,101,114,115,44,98,97,108,97,110,99,101,115,58,116,104,105,115,46,98,97,108,97,110,99,101,115,44,97,112,112,114,111,118,97,108,115,58,123,46,46,46,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,125,44,116,111,116,97,108,83,117,112,112,108,121,58,116,104,105,115,46,116,111,116,97,108,83,117,112,112,108,121,125,125,103,101,116,32,116,111,116,97,108,83,117,112,112,108,121,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,125,103,101,116,32,110,97,109,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,110,97,109,101,125,103,101,116,32,115,121,109,98,111,108,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,115,121,109,98,111,108,125,103,101,116,32,104,111,108,100,101,114,115,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,104,111,108,100,101,114,115,125,103,101,116,32,98,97,108,97,110,99,101,115,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,98,97,108,97,110,99,101,115,125,125,109,105,110,116,40,116,111,44,97,109,111,117,110,116,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,92,34,77,73,78,84,92,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,116,32,97,108,108,111,119,101,100,92,34,41,59,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,61,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,46,97,100,100,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,105,110,99,114,101,97,115,101,66,97,108,97,110,99,101,40,116,111,44,97,109,111,117,110,116,41,125,98,117,114,110,40,102,114,111,109,44,97,109,111,117,110,116,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,92,34,66,85,82,78,92,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,116,32,97,108,108,111,119,101,100,92,34,41,59,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,61,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,46,115,117,98,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,100,101,99,114,101,97,115,101,66,97,108,97,110,99,101,40,102,114,111,109,44,97,109,111,117,110,116,41,125,35,98,101,102,111,114,101,84,114,97,110,115,102,101,114,40,102,114,111,109,44,116,111,44,97,109,111,117,110,116,41,123,105,102,40,33,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,102,114,111,109,93,124,124,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,102,114,111,109,93,60,97,109,111,117,110,116,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,97,109,111,117,110,116,32,101,120,99,101,101,100,115,32,98,97,108,97,110,99,101,92,34,41,125,35,117,112,100,97,116,101,72,111,108,100,101,114,115,40,97,100,100,114,101,115,115,44,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,41,123,92,34,48,120,48,48,92,34,61,61,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,116,111,72,101,120,83,116,114,105,110,103,40,41,63,116,104,105,115,46,35,104,111,108,100,101,114,115,45,61,49,58,92,34,48,120,48,48,92,34,33,61,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,116,111,72,101,120,83,116,114,105,110,103,40,41,38,38,92,34,48,120,48,48,92,34,61,61,61,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,46,116,111,72,101,120,83,116,114,105,110,103,40,41,38,38,40,116,104,105,115,46,35,104,111,108,100,101,114,115,43,61,49,41,125,35,105,110,99,114,101,97,115,101,66,97,108,97,110,99,101,40,97,100,100,114,101,115,115,44,97,109,111,117,110,116,41,123,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,124,124,40,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,61,66,105,103,78,117,109,98,101,114,46,102,114,111,109,40,48,41,41,59,99,111,110,115,116,32,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,59,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,97,100,100,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,117,112,100,97,116,101,72,111,108,100,101,114,115,40,97,100,100,114,101,115,115,44,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,41,125,35,100,101,99,114,101,97,115,101,66,97,108,97,110,99,101,40,97,100,100,114,101,115,115,44,97,109,111,117,110,116,41,123,99,111,110,115,116,32,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,59,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,115,117,98,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,117,112,100,97,116,101,72,111,108,100,101,114,115,40,97,100,100,114,101,115,115,44,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,41,125,98,97,108,97,110,99,101,79,102,40,97,100,100,114,101,115,115,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,125,115,101,116,65,112,112,114,111,118,97,108,40,111,112,101,114,97,116,111,114,44,97,109,111,117,110,116,41,123,99,111,110,115,116,32,111,119,110,101,114,61,103,108,111,98,97,108,84,104,105,115,46,109,115,103,46,115,101,110,100,101,114,59,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,124,124,40,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,61,123,125,41,44,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,91,111,112,101,114,97,116,111,114,93,61,97,109,111,117,110,116,125,97,112,112,114,111,118,101,100,40,111,119,110,101,114,44,111,112,101,114,97,116,111,114,44,97,109,111,117,110,116,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,91,111,112,101,114,97,116,111,114,93,61,61,61,97,109,111,117,110,116,125,116,114,97,110,115,102,101,114,40,102,114,111,109,44,116,111,44,97,109,111,117,110,116,41,123,97,109,111,117,110,116,61,66,105,103,78,117,109,98,101,114,46,102,114,111,109,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,98,101,102,111,114,101,84,114,97,110,115,102,101,114,40,102,114,111,109,44,116,111,44,97,109,111,117,110,116,41,44,116,104,105,115,46,35,100,101,99,114,101,97,115,101,66,97,108,97,110,99,101,40,102,114,111,109,44,97,109,111,117,110,116,41,44,116,104,105,115,46,35,105,110,99,114,101,97,115,101,66,97,108,97,110,99,101,40,116,111,44,97,109,111,117,110,116,41,125,125,99,108,97,115,115,32,65,114,116,79,110,108,105,110,101,32,101,120,116,101,110,100,115,32,84,111,107,101,110,123,99,111,110,115,116,114,117,99,116,111,114,40,115,116,97,116,101,41,123,115,117,112,101,114,40,92,34,65,114,116,79,110,108,105,110,101,92,34,44,92,34,65,82,84,92,34,44,49,56,44,115,116,97,116,101,41,125,125,114,101,116,117,114,110,32,65,114,116,79,110,108,105,110,101,59,34,44,34,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,34,58,91,93,125";
9
- var nameService$1 = "237,198,141,3,123,34,99,114,101,97,116,111,114,34,58,34,56,71,85,107,103,52,120,87,113,109,110,83,56,75,101,122,56,107,54,68,115,82,120,90,66,68,97,54,114,71,74,109,104,107,122,67,75,113,78,75,102,85,110,103,90,122,109,54,97,81,34,44,34,99,111,110,116,114,97,99,116,34,58,34,99,108,97,115,115,32,78,97,109,101,83,101,114,118,105,99,101,123,35,110,97,109,101,61,92,34,65,114,116,79,110,108,105,110,101,78,97,109,101,83,101,114,118,105,99,101,92,34,59,35,111,119,110,101,114,59,35,112,114,105,99,101,61,48,59,35,114,101,103,105,115,116,114,121,61,123,125,59,35,99,117,114,114,101,110,99,121,59,103,101,116,32,110,97,109,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,110,97,109,101,125,103,101,116,32,114,101,103,105,115,116,114,121,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,114,101,103,105,115,116,114,121,125,125,103,101,116,32,115,116,97,116,101,40,41,123,125,99,111,110,115,116,114,117,99,116,111,114,40,102,97,99,116,111,114,121,65,100,100,114,101,115,115,44,99,117,114,114,101,110,99,121,44,118,97,108,105,100,97,116,111,114,65,100,100,114,101,115,115,44,112,114,105,99,101,44,115,116,97,116,101,41,123,115,116,97,116,101,63,40,116,104,105,115,46,35,111,119,110,101,114,61,115,116,97,116,101,46,111,119,110,101,114,44,116,104,105,115,46,35,114,101,103,105,115,116,114,121,61,115,116,97,116,101,46,114,101,103,105,115,116,114,121,44,116,104,105,115,46,35,99,117,114,114,101,110,99,121,61,115,116,97,116,101,46,99,117,114,114,101,110,99,121,44,116,104,105,115,46,35,112,114,105,99,101,61,115,116,97,116,101,46,112,114,105,99,101,41,58,40,116,104,105,115,46,35,111,119,110,101,114,61,109,115,103,46,115,101,110,100,101,114,44,116,104,105,115,46,35,112,114,105,99,101,61,112,114,105,99,101,44,116,104,105,115,46,35,114,101,103,105,115,116,114,121,46,65,114,116,79,110,108,105,110,101,67,111,110,116,114,97,99,116,70,97,99,116,111,114,121,61,123,111,119,110,101,114,58,109,115,103,46,115,101,110,100,101,114,44,97,100,100,114,101,115,115,58,102,97,99,116,111,114,121,65,100,100,114,101,115,115,125,44,116,104,105,115,46,35,114,101,103,105,115,116,114,121,46,65,114,116,79,110,108,105,110,101,84,111,107,101,110,61,123,111,119,110,101,114,58,109,115,103,46,115,101,110,100,101,114,44,97,100,100,114,101,115,115,58,99,117,114,114,101,110,99,121,125,44,116,104,105,115,46,35,114,101,103,105,115,116,114,121,46,65,114,116,79,110,108,105,110,101,86,97,108,105,100,97,116,111,114,115,61,123,111,119,110,101,114,58,109,115,103,46,115,101,110,100,101,114,44,97,100,100,114,101,115,115,58,118,97,108,105,100,97,116,111,114,65,100,100,114,101,115,115,125,44,116,104,105,115,46,35,99,117,114,114,101,110,99,121,61,99,117,114,114,101,110,99,121,41,125,99,104,97,110,103,101,79,119,110,101,114,40,111,119,110,101,114,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,32,111,119,110,101,114,92,34,41,59,116,104,105,115,46,35,111,119,110,101,114,61,111,119,110,101,114,125,99,104,97,110,103,101,80,114,105,99,101,40,112,114,105,99,101,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,32,111,119,110,101,114,92,34,41,59,116,104,105,115,46,35,112,114,105,99,101,61,112,114,105,99,101,125,99,104,97,110,103,101,67,117,114,114,101,110,99,121,40,99,117,114,114,101,110,99,121,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,32,111,119,110,101,114,92,34,41,59,116,104,105,115,46,35,99,117,114,114,101,110,99,121,61,99,117,114,114,101,110,99,121,125,97,115,121,110,99,32,112,117,114,99,104,97,115,101,78,97,109,101,40,110,97,109,101,44,97,100,100,114,101,115,115,41,123,105,102,40,97,119,97,105,116,32,109,115,103,46,99,97,108,108,40,116,104,105,115,46,35,99,117,114,114,101,110,99,121,44,92,34,98,97,108,97,110,99,101,79,102,92,34,44,91,109,115,103,46,115,101,110,100,101,114,93,41,60,116,104,105,115,46,35,112,114,105,99,101,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,112,114,105,99,101,32,101,120,99,101,101,100,115,32,98,97,108,97,110,99,101,92,34,41,59,116,114,121,123,97,119,97,105,116,32,109,115,103,46,99,97,108,108,40,116,104,105,115,46,35,99,117,114,114,101,110,99,121,44,92,34,116,114,97,110,115,102,101,114,92,34,44,91,109,115,103,46,115,101,110,100,101,114,44,116,104,105,115,46,35,111,119,110,101,114,44,116,104,105,115,46,35,112,114,105,99,101,93,41,125,99,97,116,99,104,40,101,114,114,111,114,41,123,116,104,114,111,119,32,101,114,114,111,114,125,116,104,105,115,46,35,114,101,103,105,115,116,114,121,91,110,97,109,101,93,61,123,111,119,110,101,114,58,109,115,103,46,115,101,110,100,101,114,44,97,100,100,114,101,115,115,125,125,108,111,111,107,117,112,40,110,97,109,101,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,114,101,103,105,115,116,114,121,91,110,97,109,101,93,125,116,114,97,110,115,102,101,114,79,119,110,101,114,115,104,105,112,40,110,97,109,101,44,116,111,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,114,101,103,105,115,116,114,121,46,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,116,32,97,32,111,119,110,101,114,92,34,41,59,116,104,105,115,46,35,114,101,103,105,115,116,114,121,91,110,97,109,101,93,46,111,119,110,101,114,61,116,111,125,99,104,97,110,103,101,65,100,100,114,101,115,115,40,110,97,109,101,44,97,100,100,114,101,115,115,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,114,101,103,105,115,116,114,121,46,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,116,32,97,32,111,119,110,101,114,92,34,41,59,116,104,105,115,46,35,114,101,103,105,115,116,114,121,91,110,97,109,101,93,46,97,100,100,114,101,115,115,61,97,100,100,114,101,115,115,125,125,114,101,116,117,114,110,32,78,97,109,101,83,101,114,118,105,99,101,59,34,44,34,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,34,58,91,34,105,104,110,121,50,103,113,103,54,99,54,109,119,121,53,109,104,98,114,115,53,117,108,107,107,111,122,115,103,119,116,107,53,118,117,122,53,107,114,106,105,100,111,117,121,52,109,98,119,102,100,98,106,110,98,109,107,122,122,34,44,34,105,104,110,121,50,103,113,104,111,111,99,107,121,103,55,121,103,52,110,53,98,112,120,117,108,100,97,104,102,97,118,112,113,110,109,112,111,101,50,98,110,52,105,118,110,120,109,107,55,114,101,100,99,50,108,116,119,107,98,34,44,34,105,104,110,121,50,103,113,104,52,101,50,112,114,52,112,98,116,112,107,97,109,104,106,51,104,116,115,118,117,111,121,100,121,51,119,111,116,97,117,100,111,101,97,107,116,103,99,100,119,109,111,105,106,54,54,112,101,99,112,34,44,34,49,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,34,93,125";
10
- var validators$2 = "237,198,141,3,123,34,99,114,101,97,116,111,114,34,58,34,56,71,85,107,103,52,120,87,113,109,110,83,56,75,101,122,56,107,54,68,115,82,120,90,66,68,97,54,114,71,74,109,104,107,122,67,75,113,78,75,102,85,110,103,90,122,109,54,97,81,34,44,34,99,111,110,116,114,97,99,116,34,58,34,99,108,97,115,115,32,82,111,108,101,115,123,35,114,111,108,101,115,61,123,79,87,78,69,82,58,91,93,44,77,73,78,84,58,91,93,44,66,85,82,78,58,91,93,125,59,99,111,110,115,116,114,117,99,116,111,114,40,114,111,108,101,115,41,123,105,102,40,114,111,108,101,115,41,123,105,102,40,33,40,114,111,108,101,115,32,105,110,115,116,97,110,99,101,111,102,32,79,98,106,101,99,116,41,41,116,104,114,111,119,32,110,101,119,32,84,121,112,101,69,114,114,111,114,40,92,34,101,120,112,101,99,116,101,100,32,114,111,108,101,115,32,116,111,32,98,101,32,97,110,32,111,98,106,101,99,116,92,34,41,59,116,104,105,115,46,35,114,111,108,101,115,61,123,46,46,46,114,111,108,101,115,44,46,46,46,116,104,105,115,46,35,114,111,108,101,115,125,125,101,108,115,101,32,116,104,105,115,46,35,103,114,97,110,116,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,92,34,79,87,78,69,82,92,34,41,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,114,111,108,101,115,58,116,104,105,115,46,114,111,108,101,115,125,125,103,101,116,32,114,111,108,101,115,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,114,111,108,101,115,125,125,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,114,101,116,117,114,110,33,33,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,38,38,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,105,110,99,108,117,100,101,115,40,97,100,100,114,101,115,115,41,125,35,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,36,123,114,111,108,101,125,32,114,111,108,101,32,97,108,114,101,97,100,121,32,103,114,97,110,116,101,100,32,102,111,114,32,36,123,97,100,100,114,101,115,115,125,96,41,59,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,112,117,115,104,40,97,100,100,114,101,115,115,41,125,35,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,36,123,114,111,108,101,125,32,114,111,108,101,32,97,108,114,101,97,100,121,32,114,101,118,111,107,101,100,32,102,111,114,32,36,123,97,100,100,114,101,115,115,125,96,41,59,105,102,40,92,34,79,87,78,69,82,92,34,61,61,61,114,111,108,101,38,38,49,61,61,61,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,108,101,110,103,116,104,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,97,116,108,101,97,115,116,32,111,110,101,32,111,119,110,101,114,32,105,115,32,110,101,101,100,101,100,33,92,34,41,59,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,115,112,108,105,99,101,40,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,105,110,100,101,120,79,102,40,97,100,100,114,101,115,115,41,41,125,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,92,34,79,87,78,69,82,92,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,78,111,116,32,97,108,108,111,119,101,100,92,34,41,59,116,104,105,115,46,35,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,125,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,92,34,79,87,78,69,82,92,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,78,111,116,32,97,108,108,111,119,101,100,92,34,41,59,116,104,105,115,46,35,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,125,125,99,108,97,115,115,32,86,97,108,105,100,97,116,111,114,115,32,101,120,116,101,110,100,115,32,82,111,108,101,115,123,35,110,97,109,101,61,92,34,65,114,116,79,110,108,105,110,101,86,97,108,105,100,97,116,111,114,115,92,34,59,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,61,48,59,35,97,99,116,105,118,101,86,97,108,105,100,97,116,111,114,115,61,48,59,35,118,97,108,105,100,97,116,111,114,115,61,123,125,59,35,99,117,114,114,101,110,99,121,59,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,59,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,46,46,46,115,117,112,101,114,46,115,116,97,116,101,44,109,105,110,105,109,117,109,66,97,108,97,110,99,101,58,116,104,105,115,46,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,44,99,117,114,114,101,110,99,121,58,116,104,105,115,46,35,99,117,114,114,101,110,99,121,44,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,58,116,104,105,115,46,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,44,97,99,116,105,118,101,86,97,108,105,100,97,116,111,114,115,58,116,104,105,115,46,35,97,99,116,105,118,101,86,97,108,105,100,97,116,111,114,115,44,118,97,108,105,100,97,116,111,114,115,58,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,125,125,99,111,110,115,116,114,117,99,116,111,114,40,116,111,107,101,110,65,100,100,114,101,115,115,44,115,116,97,116,101,41,123,115,117,112,101,114,40,115,116,97,116,101,63,46,114,111,108,101,115,41,44,115,116,97,116,101,63,40,116,104,105,115,46,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,61,115,116,97,116,101,46,109,105,110,105,109,117,109,66,97,108,97,110,99,101,44,116,104,105,115,46,35,99,117,114,114,101,110,99,121,61,115,116,97,116,101,46,99,117,114,114,101,110,99,121,44,116,104,105,115,46,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,61,115,116,97,116,101,46,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,44,116,104,105,115,46,35,97,99,116,105,118,101,86,97,108,105,100,97,116,111,114,115,61,115,116,97,116,101,46,97,99,116,105,118,101,86,97,108,105,100,97,116,111,114,115,44,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,61,115,116,97,116,101,46,118,97,108,105,100,97,116,111,114,115,41,58,40,116,104,105,115,46,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,61,53,101,52,44,116,104,105,115,46,35,99,117,114,114,101,110,99,121,61,116,111,107,101,110,65,100,100,114,101,115,115,44,116,104,105,115,46,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,43,61,49,44,116,104,105,115,46,35,97,99,116,105,118,101,86,97,108,105,100,97,116,111,114,115,43,61,49,44,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,109,115,103,46,115,101,110,100,101,114,93,61,123,102,105,114,115,116,83,101,101,110,58,68,97,116,101,46,110,111,119,40,41,44,108,97,115,116,83,101,101,110,58,68,97,116,101,46,110,111,119,40,41,44,97,99,116,105,118,101,58,33,48,125,41,125,103,101,116,32,110,97,109,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,110,97,109,101,125,103,101,116,32,99,117,114,114,101,110,99,121,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,99,117,114,114,101,110,99,121,125,103,101,116,32,118,97,108,105,100,97,116,111,114,115,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,125,125,103,101,116,32,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,125,103,101,116,32,109,105,110,105,109,117,109,66,97,108,97,110,99,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,125,99,104,97,110,103,101,67,117,114,114,101,110,99,121,40,99,117,114,114,101,110,99,121,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,92,34,79,87,78,69,82,92,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,116,32,97,110,32,111,119,110,101,114,92,34,41,59,116,104,105,115,46,35,99,117,114,114,101,110,99,121,61,99,117,114,114,101,110,99,121,125,104,97,115,40,118,97,108,105,100,97,116,111,114,41,123,114,101,116,117,114,110,32,66,111,111,108,101,97,110,40,118,111,105,100,32,48,33,61,61,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,118,97,108,105,100,97,116,111,114,93,41,125,35,105,115,65,108,108,111,119,101,100,40,97,100,100,114,101,115,115,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,97,100,100,114,101,115,115,38,38,33,116,104,105,115,46,104,97,115,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,92,34,79,87,78,69,82,92,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,115,101,110,100,101,114,32,105,115,32,110,111,116,32,116,104,101,32,118,97,108,105,100,97,116,111,114,32,111,114,32,111,119,110,101,114,92,34,41,59,114,101,116,117,114,110,33,48,125,97,115,121,110,99,32,97,100,100,86,97,108,105,100,97,116,111,114,40,118,97,108,105,100,97,116,111,114,41,123,105,102,40,116,104,105,115,46,35,105,115,65,108,108,111,119,101,100,40,118,97,108,105,100,97,116,111,114,41,44,116,104,105,115,46,104,97,115,40,118,97,108,105,100,97,116,111,114,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,97,108,114,101,97,100,121,32,97,32,118,97,108,105,100,97,116,111,114,92,34,41,59,99,111,110,115,116,32,98,97,108,97,110,99,101,61,97,119,97,105,116,32,109,115,103,46,115,116,97,116,105,99,67,97,108,108,40,116,104,105,115,46,99,117,114,114,101,110,99,121,44,92,34,98,97,108,97,110,99,101,79,102,92,34,44,91,118,97,108,105,100,97,116,111,114,93,41,59,105,102,40,98,97,108,97,110,99,101,60,116,104,105,115,46,109,105,110,105,109,117,109,66,97,108,97,110,99,101,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,98,97,108,97,110,99,101,32,116,111,32,108,111,119,33,32,103,111,116,58,32,36,123,98,97,108,97,110,99,101,125,32,110,101,101,100,58,32,36,123,116,104,105,115,46,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,125,96,41,59,116,104,105,115,46,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,43,61,49,44,116,104,105,115,46,35,97,99,116,105,118,101,86,97,108,105,100,97,116,111,114,115,43,61,49,44,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,118,97,108,105,100,97,116,111,114,93,61,123,102,105,114,115,116,83,101,101,110,58,68,97,116,101,46,110,111,119,40,41,44,108,97,115,116,83,101,101,110,58,68,97,116,101,46,110,111,119,40,41,44,97,99,116,105,118,101,58,33,48,125,125,114,101,109,111,118,101,86,97,108,105,100,97,116,111,114,40,118,97,108,105,100,97,116,111,114,41,123,105,102,40,116,104,105,115,46,35,105,115,65,108,108,111,119,101,100,40,118,97,108,105,100,97,116,111,114,41,44,33,116,104,105,115,46,104,97,115,40,118,97,108,105,100,97,116,111,114,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,118,97,108,105,100,97,116,111,114,32,110,111,116,32,102,111,117,110,100,92,34,41,59,116,104,105,115,46,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,45,61,49,44,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,118,97,108,105,100,97,116,111,114,93,46,97,99,116,105,118,101,38,38,40,116,104,105,115,46,35,97,99,116,105,118,101,86,97,108,105,100,97,116,111,114,115,45,61,49,41,44,100,101,108,101,116,101,32,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,118,97,108,105,100,97,116,111,114,93,125,97,115,121,110,99,32,117,112,100,97,116,101,86,97,108,105,100,97,116,111,114,40,118,97,108,105,100,97,116,111,114,44,97,99,116,105,118,101,41,123,105,102,40,116,104,105,115,46,35,105,115,65,108,108,111,119,101,100,40,118,97,108,105,100,97,116,111,114,41,44,33,116,104,105,115,46,104,97,115,40,118,97,108,105,100,97,116,111,114,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,118,97,108,105,100,97,116,111,114,32,110,111,116,32,102,111,117,110,100,92,34,41,59,99,111,110,115,116,32,98,97,108,97,110,99,101,61,97,119,97,105,116,32,109,115,103,46,115,116,97,116,105,99,67,97,108,108,40,116,104,105,115,46,99,117,114,114,101,110,99,121,44,92,34,98,97,108,97,110,99,101,79,102,92,34,44,91,118,97,108,105,100,97,116,111,114,93,41,59,105,102,40,98,97,108,97,110,99,101,60,116,104,105,115,46,109,105,110,105,109,117,109,66,97,108,97,110,99,101,38,38,97,99,116,105,118,101,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,98,97,108,97,110,99,101,32,116,111,32,108,111,119,33,32,103,111,116,58,32,36,123,98,97,108,97,110,99,101,125,32,110,101,101,100,58,32,36,123,116,104,105,115,46,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,125,96,41,59,105,102,40,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,118,97,108,105,100,97,116,111,114,93,46,97,99,116,105,118,101,61,61,61,97,99,116,105,118,101,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,97,108,114,101,97,100,121,32,92,34,43,40,97,99,116,105,118,101,63,92,34,97,99,116,105,118,97,116,101,100,92,34,58,92,34,100,101,97,99,116,105,118,97,116,101,100,92,34,41,41,59,97,99,116,105,118,101,63,116,104,105,115,46,35,97,99,116,105,118,101,86,97,108,105,100,97,116,111,114,115,43,61,49,58,116,104,105,115,46,35,97,99,116,105,118,101,86,97,108,105,100,97,116,111,114,115,45,61,49,44,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,118,97,108,105,100,97,116,111,114,93,46,97,99,116,105,118,101,61,97,99,116,105,118,101,125,125,114,101,116,117,114,110,32,86,97,108,105,100,97,116,111,114,115,59,34,44,34,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,34,58,91,34,105,104,110,121,50,103,113,104,111,111,99,107,121,103,55,121,103,52,110,53,98,112,120,117,108,100,97,104,102,97,118,112,113,110,109,112,111,101,50,98,110,52,105,118,110,120,109,107,55,114,101,100,99,50,108,116,119,107,98,34,93,125";
11
- var bytecodes = {
12
- contractFactory: contractFactory$1,
13
- nativeToken: nativeToken$1,
14
- nameService: nameService$1,
15
- validators: validators$2
16
- };
17
-
18
- var proto$4 = `
19
- message ContractMessage {
20
- required string creator = 1;
21
- required bytes contract = 2;
22
- repeated string constructorParameters = 3;
23
- }
24
- `;
25
-
26
- class ContractMessage extends codecFormatInterface.FormatInterface {
27
- get keys() {
28
- return ['creator', 'contract', 'constructorParameters']
29
- }
30
-
31
- get messageName() {
32
- return 'ContractMessage'
33
- }
34
-
35
- constructor(buffer) {
36
- super(buffer, proto$4, {name: 'contract-message'});
37
- }
38
- }
39
-
40
- var proto$3 = `
41
-
42
- message TransactionMessage {
43
- required uint64 timestamp = 1;
44
- required string from = 2;
45
- required string to = 3;
46
- required uint64 nonce = 4;
47
- required string method = 5;
48
- repeated string params = 6;
49
- required string signature = 7;
50
- }
51
- `;
52
-
53
- class TransactionMessage extends codecFormatInterface.FormatInterface {
54
- get keys() {
55
- return ['timestamp', 'from', 'to', 'nonce', 'method', 'params', 'signature']
56
- }
57
-
58
- get messageName() {
59
- return 'TransactionMessage'
60
- }
61
-
62
- constructor(buffer) {
63
- const name = 'transaction-message';
64
- super(buffer, proto$3, {name});
65
- }
66
- }
67
-
68
- var proto$2 = `
69
- message ValidatorMessage {
70
- required string address = 1;
71
- required string reward = 2;
72
- }
73
-
74
- message Transaction {
75
- required string hash = 1;
76
- required uint64 timestamp = 2;
77
- required string from = 3;
78
- required string to = 4;
79
- required uint64 nonce = 5;
80
- required string method = 6;
81
- repeated string params = 7;
82
- }
83
-
84
- message BlockMessage {
85
- required uint64 index = 1;
86
- required string previousHash = 3;
87
- required uint64 timestamp = 4;
88
- required uint64 reward = 5;
89
- required string fees = 6;
90
- repeated Transaction transactions = 7;
91
- repeated ValidatorMessage validators = 8;
92
- }
93
- `;
94
-
95
- class BlockMessage extends codecFormatInterface.FormatInterface {
96
- get keys() {
97
- return ['index', 'previousHash', 'timestamp', 'reward', 'fees', 'transactions', 'validators']
98
- }
99
-
100
- get messageName() {
101
- return 'BlockMessage'
102
- }
103
-
104
- constructor(buffer) {
105
- const name = 'block-message';
106
- super(buffer, proto$2, {name});
107
- }
108
- }
109
-
110
- var proto$1 = `
111
-
112
- message BWMessage {
113
- required uint64 up = 1;
114
- required uint64 down = 2;
115
- }
116
- `;
117
-
118
- class BWMessage extends codecFormatInterface.FormatInterface {
119
- get keys() {
120
- return ['up', 'down']
121
- }
122
-
123
- get messageName() {
124
- return 'BWMessage'
125
- }
126
-
127
- constructor(buffer) {
128
- const name = 'bw-message';
129
- super(buffer, proto$1, {name});
130
- }
131
- }
132
-
133
- var proto = `
134
-
135
- message BWRequestMessage {
136
- }
137
- `;
138
-
139
- class BWRequestMessage extends codecFormatInterface.FormatInterface {
140
- get keys() {
141
- return []
142
- }
143
-
144
- get messageName() {
145
- return 'BWRequestMessage'
146
- }
147
-
148
- constructor(buffer) {
149
- const name = 'bw-request-message';
150
- super(buffer, proto, {name});
151
- }
152
- }
153
-
154
- var contractFactory = "ihny2gqg6c6mwy5mhbrs5ulkkozsgwtk5vuz5krjidouy4mbwfdbjnbmkzz";
155
- var nativeToken = "ihny2gqhoockyg7yg4n5bpxuldahfavpqnmpoe2bn4ivnxmk7redc2ltwkb";
156
- var nameService = "ihny2gqgztp3vj6qy7fgrfer7y5c5hxnp6imdz6v5spi4edkwtm5fkd5z2h";
157
- var validators$1 = "ihny2gqh4e2pr4pbtpkamhj3htsvuoydy3wotaudoeaktgcdwmoij66pecp";
158
- var addresses = {
159
- contractFactory: contractFactory,
160
- nativeToken: nativeToken,
161
- nameService: nameService,
162
- validators: validators$1
163
- };
164
-
165
- const validators = addresses.validators;
166
-
167
- var _nodeConfig = async (config = {
168
- network: 'leofcoin:peach',
169
- networkName: 'leofcoin:peach',
170
- networkVersion: 'v1.0.0'
171
- }) => {
172
- await peernet.addProto('contract-message', ContractMessage);
173
- await peernet.addProto('transaction-message', TransactionMessage);
174
- await peernet.addProto('block-message', BlockMessage);
175
- await peernet.addProto('bw-message', BWMessage);
176
- await peernet.addProto('bw-request-message', BWRequestMessage);
177
-
178
- await peernet.addCodec('contract-message', {
179
- codec: parseInt('63636d', 16),
180
- hashAlg: 'keccak-256'
181
- });
182
- await peernet.addCodec('transaction-message', {
183
- codec: parseInt('746d', 16),
184
- hashAlg: 'keccak-256'
185
- });
186
-
187
- await peernet.addCodec('block-message', {
188
- codec: parseInt('626d', 16),
189
- hashAlg: 'keccak-256'
190
- });
191
-
192
- await peernet.addCodec('bw-message', {
193
- codec: parseInt('62776d', 16),
194
- hashAlg: 'keccak-256'
195
- });
196
-
197
- await peernet.addCodec('bw-request-message', {
198
- codec: parseInt('6277726d', 16),
199
- hashAlg: 'keccak-256'
200
- });
201
-
202
-
203
- await peernet.addCodec('validator-message', {
204
- codec: parseInt('766d', 16),
205
- hashAlg: 'keccak-256'
206
- })
207
- let name = `.${config.network}`;
208
- const parts = config.network.split(':');
209
- if (parts[1]) name = `.${parts[0]}/${parts[1]}`;
210
- await peernet.addStore('contract', 'lfc', name, false);
211
- await peernet.addStore('accounts', 'lfc', name, false);
212
- await peernet.addStore('transactionPool', 'lfc', name, false);
213
- };
214
-
215
- const nodeConfig = _nodeConfig;
216
-
217
- const contractFactoryMessage = bytecodes.contractFactory;
218
- const nativeTokenMessage = bytecodes.nativeToken;
219
-
220
- const nameServiceMessage = bytecodes.nameService;
221
- const validatorsMessage = bytecodes.validators;
222
-
223
- const createContractMessage = async (creator, contract, constructorParameters = []) => {
224
- return new ContractMessage({
225
- creator,
226
- contract,
227
- constructorParameters
228
- })
229
- };
230
-
231
- const calculateFee = async transaction => {
232
- // excluded from fees
233
- if (transaction.to === validators) return 0
234
- // fee per gb
235
- transaction = await new TransactionMessage(transaction);
236
- let fee = transaction.encoded.length;
237
- fee = fee / 1024;
238
- fee = fee / 1000000;
239
- const parts = String(fee).split('.');
240
- let decimals = 0;
241
- if (parts[1]) {
242
- const potentional = parts[1].split('e');
243
- parts[1] = potentional[0];
244
- decimals = Number(potentional[1].replace(/\-|\+/g, '')) + Number(potentional[0].length);
245
- }
246
-
247
- return Number.parseFloat(fee.toString()).toFixed(decimals)
248
- };
249
-
250
- const calculateTransactionFee = transaction => {
251
- transaction = new TransactionMessage(transaction);
252
- return calculateFee(transaction)
253
- };
254
-
255
- const calculateReward = (validators, fees) => {
256
- validators = Object.keys(validators).reduce((set, key) => {
257
- if (validators[key].active) set.push({
258
- address: key,
259
- reward: 0
260
- });
261
-
262
- }, []);
263
- };
264
-
265
- exports.calculateFee = calculateFee;
266
- exports.calculateReward = calculateReward;
267
- exports.calculateTransactionFee = calculateTransactionFee;
268
- exports.contractFactoryMessage = contractFactoryMessage;
269
- exports.createContractMessage = createContractMessage;
270
- exports.nameServiceMessage = nameServiceMessage;
271
- exports.nativeTokenMessage = nativeTokenMessage;
272
- exports.nodeConfig = nodeConfig;
273
- exports.validatorsMessage = validatorsMessage;