@leofcoin/lib 1.2.28 → 1.2.30
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { TransactionMessage, RawTransactionMessage } from '@leofcoin/messages';
|
|
1
|
+
import { ContractMessage, TransactionMessage, RawTransactionMessage } from '@leofcoin/messages';
|
|
2
2
|
export { default as nodeConfig } from './node-config.js';
|
|
3
|
+
import { BigNumber } from '@leofcoin/utils';
|
|
3
4
|
import '@vandeurenglenn/base58';
|
|
4
5
|
declare type address = string;
|
|
5
6
|
declare type rawTransaction = {
|
|
@@ -18,15 +19,15 @@ declare type signedTransaction = {
|
|
|
18
19
|
signature: base58String;
|
|
19
20
|
};
|
|
20
21
|
declare type signable = {
|
|
21
|
-
sign: (transaction:
|
|
22
|
+
sign: (transaction: Uint8Array) => Uint8Array;
|
|
22
23
|
};
|
|
23
24
|
export declare const contractFactoryMessage: string;
|
|
24
25
|
export declare const nativeTokenMessage: string;
|
|
25
26
|
export declare const nameServiceMessage: string;
|
|
26
27
|
export declare const validatorsMessage: string;
|
|
27
|
-
export declare const createContractMessage: (creator: any, contract: any, constructorParameters?: any[]) => Promise<
|
|
28
|
-
export declare const calculateFee: (transaction: any, format?: boolean) => Promise<
|
|
29
|
-
export declare const calculateTransactionFee: (transaction: any) => Promise<
|
|
28
|
+
export declare const createContractMessage: (creator: any, contract: any, constructorParameters?: any[]) => Promise<ContractMessage>;
|
|
29
|
+
export declare const calculateFee: (transaction: any, format?: boolean) => Promise<string | 0 | BigNumber>;
|
|
30
|
+
export declare const calculateTransactionFee: (transaction: any) => Promise<string | 0 | BigNumber>;
|
|
30
31
|
export declare const calculateReward: (validators: any, fees: any) => [];
|
|
31
32
|
export declare const createTransactionHash: (transaction: rawTransaction | TransactionMessage | RawTransactionMessage) => Promise<Uint8Array>;
|
|
32
33
|
export declare const signTransaction: (transaction: rawTransaction, wallet: signable) => Promise<signedTransaction>;
|
package/exports/index.js
CHANGED
|
@@ -55,18 +55,16 @@ const calculateReward = (validators, fees) => {
|
|
|
55
55
|
};
|
|
56
56
|
const createTransactionHash = async (transaction) => {
|
|
57
57
|
const isRawTransactionMessage = transaction instanceof RawTransactionMessage;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return (await transaction.peernetHash).digest;
|
|
58
|
+
let message;
|
|
59
|
+
if (!isRawTransactionMessage)
|
|
60
|
+
message = await new RawTransactionMessage(transaction instanceof TransactionMessage ? transaction.decoded : transaction);
|
|
61
|
+
else
|
|
62
|
+
message = transaction;
|
|
63
|
+
return (await message.peernetHash).digest;
|
|
65
64
|
};
|
|
66
65
|
const signTransaction = async (transaction, wallet) => {
|
|
67
66
|
const signature = toBase58(await wallet.sign(await createTransactionHash(transaction)));
|
|
68
|
-
|
|
69
|
-
return signedTransaction;
|
|
67
|
+
return { ...transaction, signature };
|
|
70
68
|
};
|
|
71
69
|
const prepareContractTransaction = async (owner, contract, constructorParameters = []) => {
|
|
72
70
|
const message = await createContractMessage(owner, contract, constructorParameters);
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import Storage from '@leofcoin/storage';
|
|
1
2
|
declare global {
|
|
2
|
-
var transactionPoolStore:
|
|
3
|
+
var transactionPoolStore: Storage;
|
|
4
|
+
var accountsStore: Storage;
|
|
5
|
+
var contractStore: Storage;
|
|
3
6
|
}
|
|
4
7
|
declare const _default: (config?: {
|
|
5
8
|
network: string;
|
package/exports/node-config.js
CHANGED
|
@@ -15,7 +15,7 @@ var nodeConfig = async (config = {
|
|
|
15
15
|
const parts = config.network.split(':');
|
|
16
16
|
if (parts[1])
|
|
17
17
|
name = `.${parts[0]}/${parts[1]}`;
|
|
18
|
-
await
|
|
18
|
+
await peernet.addStore('contract', 'lfc', name, false);
|
|
19
19
|
await globalThis.peernet.addStore('accounts', 'lfc', name, false);
|
|
20
20
|
await globalThis.peernet.addStore('transactionPool', 'lfc', name, false);
|
|
21
21
|
};
|
package/package.json
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/lib",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.30",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"typings": "./exports/typings/index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
|
-
".":
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"./
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./exports/index.js",
|
|
10
|
+
"types": "./exports/index.d.ts"
|
|
11
|
+
},
|
|
12
|
+
"./node-config": {
|
|
13
|
+
"import": "./exports/node-config.js",
|
|
14
|
+
"types": "./exports/node-config.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./node-config.js": {
|
|
17
|
+
"import": "./exports/node-config.js",
|
|
18
|
+
"types": "./exports/node-config.d.s"
|
|
19
|
+
},
|
|
20
|
+
"./bytecodes": {
|
|
21
|
+
"import": "./src/bytecodes.json"
|
|
22
|
+
},
|
|
23
|
+
"./bytecodes.json": {
|
|
24
|
+
"import": "./src/bytecodes.json"
|
|
25
|
+
}
|
|
13
26
|
},
|
|
14
27
|
"files": [
|
|
15
28
|
"exports",
|
|
@@ -17,12 +30,7 @@
|
|
|
17
30
|
],
|
|
18
31
|
"scripts": {
|
|
19
32
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
20
|
-
"build": "
|
|
21
|
-
},
|
|
22
|
-
"wireit": {
|
|
23
|
-
"build": {
|
|
24
|
-
"command": "rollup -c --silent error --cache true"
|
|
25
|
-
}
|
|
33
|
+
"build": "rollup -c"
|
|
26
34
|
},
|
|
27
35
|
"keywords": [],
|
|
28
36
|
"author": "",
|
package/exports/typings/lib.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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) => [];
|