@leofcoin/messages 1.3.17 → 1.4.0
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/block.js +13 -10
- package/exports/bw-request.js +2 -0
- package/exports/bw.js +2 -0
- package/exports/contract.js +2 -0
- package/exports/index.js +6 -1
- package/exports/last-block-request.js +2 -0
- package/exports/last-block.js +2 -0
- package/exports/messages/block.d.ts +2 -2
- package/exports/messages/publish.d.ts +1 -1
- package/exports/protos/block.proto.d.ts +1 -1
- package/exports/protos/validator.proto.d.ts +1 -1
- package/exports/transaction.js +6 -2
- package/exports/validator.js +2 -0
- package/package.json +62 -61
package/exports/block.js
CHANGED
|
@@ -20,24 +20,26 @@ class BlockMessage extends FormatInterface {
|
|
|
20
20
|
return 'BlockMessage';
|
|
21
21
|
}
|
|
22
22
|
constructor(buffer) {
|
|
23
|
+
if (buffer instanceof BlockMessage)
|
|
24
|
+
return buffer;
|
|
23
25
|
const name = 'block-message';
|
|
24
26
|
super(buffer, proto, { name });
|
|
25
27
|
}
|
|
26
|
-
encode() {
|
|
27
|
-
|
|
28
|
+
encode(decoded) {
|
|
29
|
+
decoded = decoded || this.decoded;
|
|
28
30
|
const validators = [];
|
|
29
31
|
const transactions = [];
|
|
30
32
|
for (const validator of decoded.validators) {
|
|
31
33
|
if (validator instanceof ValidatorMessage)
|
|
32
|
-
validators.push(validator.
|
|
34
|
+
validators.push(validator.encode());
|
|
33
35
|
else
|
|
34
|
-
validators.push(new ValidatorMessage(validator).
|
|
36
|
+
validators.push(new ValidatorMessage(validator).encode());
|
|
35
37
|
}
|
|
36
38
|
for (const transaction of decoded.transactions) {
|
|
37
39
|
if (transaction instanceof TransactionMessage)
|
|
38
|
-
transactions.push(transaction.
|
|
40
|
+
transactions.push(transaction.encode());
|
|
39
41
|
else
|
|
40
|
-
transactions.push(new TransactionMessage(transaction).
|
|
42
|
+
transactions.push(new TransactionMessage(transaction).encode());
|
|
41
43
|
}
|
|
42
44
|
return super.encode({
|
|
43
45
|
...decoded,
|
|
@@ -45,12 +47,13 @@ class BlockMessage extends FormatInterface {
|
|
|
45
47
|
transactions: smartConcat(transactions)
|
|
46
48
|
});
|
|
47
49
|
}
|
|
48
|
-
decode() {
|
|
49
|
-
|
|
50
|
+
decode(encoded) {
|
|
51
|
+
encoded = encoded || this.encoded;
|
|
52
|
+
super.decode(encoded);
|
|
50
53
|
// @ts-ignore
|
|
51
|
-
this.decoded.transactions = smartDeconcat(this.decoded.transactions).map(transaction => new TransactionMessage(transaction).decoded);
|
|
54
|
+
this.decoded.transactions = smartDeconcat(this.decoded.transactions).map((transaction) => new TransactionMessage(transaction).decoded);
|
|
52
55
|
// @ts-ignore
|
|
53
|
-
this.decoded.validators = smartDeconcat(this.decoded.validators).map(validator => new ValidatorMessage(validator).decoded);
|
|
56
|
+
this.decoded.validators = smartDeconcat(this.decoded.validators).map((validator) => new ValidatorMessage(validator).decoded);
|
|
54
57
|
return this.decoded;
|
|
55
58
|
}
|
|
56
59
|
}
|
package/exports/bw-request.js
CHANGED
package/exports/bw.js
CHANGED
package/exports/contract.js
CHANGED
package/exports/index.js
CHANGED
|
@@ -17,7 +17,10 @@ var proto = {
|
|
|
17
17
|
to: String(),
|
|
18
18
|
nonce: Number(),
|
|
19
19
|
method: String(),
|
|
20
|
-
params: Array()
|
|
20
|
+
params: Array(),
|
|
21
|
+
'nonce?': Number(),
|
|
22
|
+
'dependsOn?': Array(),
|
|
23
|
+
'priority?': Boolean()
|
|
21
24
|
};
|
|
22
25
|
|
|
23
26
|
class RawTransactionMessage extends FormatInterface {
|
|
@@ -25,6 +28,8 @@ class RawTransactionMessage extends FormatInterface {
|
|
|
25
28
|
return 'RawTransactionMessage';
|
|
26
29
|
}
|
|
27
30
|
constructor(buffer) {
|
|
31
|
+
if (buffer instanceof RawTransactionMessage)
|
|
32
|
+
return buffer;
|
|
28
33
|
const name = 'raw-transaction-message';
|
|
29
34
|
super(buffer, proto, { name });
|
|
30
35
|
}
|
|
@@ -7,6 +7,8 @@ class LastBlockRequestMessage extends FormatInterface {
|
|
|
7
7
|
return 'LastBlockRequestMessage';
|
|
8
8
|
}
|
|
9
9
|
constructor(buffer) {
|
|
10
|
+
if (buffer instanceof LastBlockRequestMessage)
|
|
11
|
+
return buffer;
|
|
10
12
|
const name = 'last-block-request-message';
|
|
11
13
|
super(buffer, proto, { name });
|
|
12
14
|
}
|
package/exports/last-block.js
CHANGED
|
@@ -15,8 +15,8 @@ export default class BlockMessage extends FormatInterface {
|
|
|
15
15
|
};
|
|
16
16
|
get messageName(): string;
|
|
17
17
|
constructor(buffer: messageInput);
|
|
18
|
-
encode(): Uint8Array;
|
|
19
|
-
decode(): {
|
|
18
|
+
encode(decoded?: any): Uint8Array;
|
|
19
|
+
decode(encoded?: any): {
|
|
20
20
|
index: Number;
|
|
21
21
|
previousHash: String;
|
|
22
22
|
timestamp: String;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import proto from '../protos/publish.proto.js';
|
|
2
2
|
import { FormatInterface } from '@leofcoin/codec-format-interface';
|
|
3
3
|
import type { messageInput } from '../types.js';
|
|
4
|
-
export default class
|
|
4
|
+
export default class publishMessage extends FormatInterface {
|
|
5
5
|
decoded: typeof proto;
|
|
6
6
|
get messageName(): string;
|
|
7
7
|
constructor(buffer: messageInput);
|
package/exports/transaction.js
CHANGED
|
@@ -4,10 +4,12 @@ var proto = {
|
|
|
4
4
|
timestamp: Number(),
|
|
5
5
|
from: String(),
|
|
6
6
|
to: String(),
|
|
7
|
-
nonce: Number(),
|
|
8
7
|
method: String(),
|
|
9
8
|
params: Array(),
|
|
10
|
-
signature: String()
|
|
9
|
+
signature: String(),
|
|
10
|
+
'nonce?': Number(),
|
|
11
|
+
'dependsOn?': Array(),
|
|
12
|
+
'priority?': Boolean()
|
|
11
13
|
};
|
|
12
14
|
|
|
13
15
|
class TransactionMessage extends FormatInterface {
|
|
@@ -15,6 +17,8 @@ class TransactionMessage extends FormatInterface {
|
|
|
15
17
|
return 'TransactionMessage';
|
|
16
18
|
}
|
|
17
19
|
constructor(buffer) {
|
|
20
|
+
if (buffer instanceof TransactionMessage)
|
|
21
|
+
return buffer;
|
|
18
22
|
const name = 'transaction-message';
|
|
19
23
|
super(buffer, proto, { name });
|
|
20
24
|
}
|
package/exports/validator.js
CHANGED
package/package.json
CHANGED
|
@@ -1,61 +1,62 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@leofcoin/messages",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "",
|
|
5
|
-
"exports": {
|
|
6
|
-
".": {
|
|
7
|
-
"import": "./exports/index.js",
|
|
8
|
-
"types": "./exports/index.d.ts"
|
|
9
|
-
},
|
|
10
|
-
"./block": {
|
|
11
|
-
"import": "./exports/block.js",
|
|
12
|
-
"types": "./exports/block.d.ts"
|
|
13
|
-
},
|
|
14
|
-
"./bw-request": {
|
|
15
|
-
"import": "./exports/bw-request.js",
|
|
16
|
-
"types": "./exports/bw-request.d.ts"
|
|
17
|
-
},
|
|
18
|
-
"./bw": {
|
|
19
|
-
"import": "./exports/bw.js",
|
|
20
|
-
"types": "./exports/bw.d.ts"
|
|
21
|
-
},
|
|
22
|
-
"./contract": {
|
|
23
|
-
"import": "./exports/contract.js",
|
|
24
|
-
"types": "./exports/contract.d.ts"
|
|
25
|
-
},
|
|
26
|
-
"./last-block-request": {
|
|
27
|
-
"import": "./exports/last-block-request.js",
|
|
28
|
-
"types": "./exports/last-block-request.d.ts"
|
|
29
|
-
},
|
|
30
|
-
"./last-block": {
|
|
31
|
-
"import": "./exports/last-block.js",
|
|
32
|
-
"types": "./exports/last-block.d.ts"
|
|
33
|
-
},
|
|
34
|
-
"./transaction": {
|
|
35
|
-
"import": "./exports/transaction.js",
|
|
36
|
-
"types": "./exports/transaction.d.ts"
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
"files": [
|
|
40
|
-
"exports"
|
|
41
|
-
],
|
|
42
|
-
"type": "module",
|
|
43
|
-
"scripts": {
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
"rollup": "^
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"@leofcoin/
|
|
59
|
-
"@
|
|
60
|
-
|
|
61
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@leofcoin/messages",
|
|
3
|
+
"version": "1.4.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"import": "./exports/index.js",
|
|
8
|
+
"types": "./exports/index.d.ts"
|
|
9
|
+
},
|
|
10
|
+
"./block": {
|
|
11
|
+
"import": "./exports/block.js",
|
|
12
|
+
"types": "./exports/block.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"./bw-request": {
|
|
15
|
+
"import": "./exports/bw-request.js",
|
|
16
|
+
"types": "./exports/bw-request.d.ts"
|
|
17
|
+
},
|
|
18
|
+
"./bw": {
|
|
19
|
+
"import": "./exports/bw.js",
|
|
20
|
+
"types": "./exports/bw.d.ts"
|
|
21
|
+
},
|
|
22
|
+
"./contract": {
|
|
23
|
+
"import": "./exports/contract.js",
|
|
24
|
+
"types": "./exports/contract.d.ts"
|
|
25
|
+
},
|
|
26
|
+
"./last-block-request": {
|
|
27
|
+
"import": "./exports/last-block-request.js",
|
|
28
|
+
"types": "./exports/last-block-request.d.ts"
|
|
29
|
+
},
|
|
30
|
+
"./last-block": {
|
|
31
|
+
"import": "./exports/last-block.js",
|
|
32
|
+
"types": "./exports/last-block.d.ts"
|
|
33
|
+
},
|
|
34
|
+
"./transaction": {
|
|
35
|
+
"import": "./exports/transaction.js",
|
|
36
|
+
"types": "./exports/transaction.d.ts"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"exports"
|
|
41
|
+
],
|
|
42
|
+
"type": "module",
|
|
43
|
+
"scripts": {
|
|
44
|
+
"prettier": "prettier src --config ./../../.prettierrc --write",
|
|
45
|
+
"test": "node test",
|
|
46
|
+
"build": "rollup -c"
|
|
47
|
+
},
|
|
48
|
+
"keywords": [],
|
|
49
|
+
"author": "",
|
|
50
|
+
"license": "MIT",
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@rollup/plugin-typescript": "^11.0.0",
|
|
53
|
+
"rollup": "^3.10.0",
|
|
54
|
+
"tslib": "^2.4.1",
|
|
55
|
+
"typescript": "^5.2.2"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@leofcoin/codec-format-interface": "^1.6.18",
|
|
59
|
+
"@leofcoin/utils": "^1.1.5",
|
|
60
|
+
"@vandeurenglenn/easy-worker": "^1.0.2"
|
|
61
|
+
}
|
|
62
|
+
}
|