@leofcoin/messages 1.2.0 → 1.3.1
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 +8 -0
- package/exports/messages/block.js +55 -0
- package/exports/messages/bw-request.js +16 -0
- package/exports/messages/bw.js +18 -0
- package/exports/messages/contract.js +18 -0
- package/exports/messages/last-block-request.js +16 -0
- package/exports/messages/last-block.js +18 -0
- package/exports/messages/transaction.js +23 -0
- package/exports/messages/validator.js +18 -0
- package/exports/typings/index.d.ts +8 -0
- package/exports/typings/messages/block.d.ts +24 -0
- package/exports/typings/messages/bw-request.d.ts +5 -0
- package/exports/typings/messages/bw.d.ts +5 -0
- package/exports/typings/messages/contract.d.ts +5 -0
- package/exports/typings/messages/last-block-request.d.ts +5 -0
- package/exports/typings/messages/last-block.d.ts +5 -0
- package/exports/typings/messages/transaction.d.ts +5 -0
- package/exports/typings/messages/validator.d.ts +5 -0
- package/exports/typings/protos/block.proto.d.ts +10 -0
- package/exports/typings/protos/bw-request.proto.d.ts +2 -0
- package/exports/typings/protos/bw.proto.d.ts +5 -0
- package/exports/typings/protos/contract.proto.d.ts +6 -0
- package/exports/typings/protos/last-block-request.proto.d.ts +2 -0
- package/exports/typings/protos/last-block.proto.d.ts +5 -0
- package/exports/typings/protos/transaction.proto.d.ts +10 -0
- package/exports/typings/protos/validator.proto.d.ts +5 -0
- package/exports/typings/workers/transaction-worker.d.ts +1 -0
- package/exports/workers/transaction-worker.js +23 -0
- package/package.json +19 -7
- package/rollup.config.js +54 -5
- package/src/index.ts +10 -0
- package/src/messages/block.ts +56 -0
- package/src/messages/{bw-request.js → bw-request.ts} +2 -6
- package/src/messages/{bw.js → bw.ts} +2 -6
- package/src/messages/{contract.js → contract.ts} +2 -6
- package/src/messages/{last-block-request.js → last-block-request.ts} +2 -6
- package/src/messages/{last-block.js → last-block.ts} +2 -6
- package/src/messages/{transaction.js → transaction.ts} +2 -6
- package/src/messages/validator.ts +13 -0
- package/src/protos/block.proto.js +8 -25
- package/src/protos/bw-request.proto.js +1 -4
- package/src/protos/bw.proto.js +3 -6
- package/src/protos/contract.proto.js +4 -6
- package/src/protos/last-block-request.proto.js +1 -4
- package/src/protos/last-block.proto.js +3 -6
- package/src/protos/transaction.proto.js +8 -11
- package/src/protos/validator.proto.js +4 -0
- package/src/types.d.ts +1 -0
- package/test.js +83 -0
- package/tsconfig.json +16 -0
- package/dist/messages.esm +0 -7887
- package/dist/messages.js +0 -147
- package/dist/protons.esm +0 -3786
- package/src/messages/block.js +0 -17
- package/src/messages.js +0 -5
- package/webpack.config.js +0 -22
package/exports/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as BlockMessage } from './messages/block.js';
|
|
2
|
+
export { default as BWMessage } from './messages/bw.js';
|
|
3
|
+
export { default as BWRequestMessage } from './messages/bw-request.js';
|
|
4
|
+
export { default as ContractMessage } from './messages/contract.js';
|
|
5
|
+
export { default as LastBlockMessage } from './messages/last-block.js';
|
|
6
|
+
export { default as LastBlockRequestMessage } from './messages/last-block-request.js';
|
|
7
|
+
export { default as TransactionMessage } from './messages/transaction.js';
|
|
8
|
+
export { default as ValidatorMessage } from './messages/validator.js';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { FormatInterface } from '@leofcoin/codec-format-interface';
|
|
2
|
+
import TransactionMessage from './transaction.js';
|
|
3
|
+
import ValidatorMessage from './validator.js';
|
|
4
|
+
import smartConcat from '@vandeurenglenn/typed-array-smart-concat';
|
|
5
|
+
import smartDeconcat from '@vandeurenglenn/typed-array-smart-deconcat';
|
|
6
|
+
|
|
7
|
+
var proto = {
|
|
8
|
+
index: Number(),
|
|
9
|
+
previousHash: String(),
|
|
10
|
+
timestamp: Number(),
|
|
11
|
+
reward: Number(),
|
|
12
|
+
fees: Number(),
|
|
13
|
+
transactions: new Uint8Array(),
|
|
14
|
+
validators: new Uint8Array()
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
class BlockMessage extends FormatInterface {
|
|
18
|
+
get messageName() {
|
|
19
|
+
return 'BlockMessage';
|
|
20
|
+
}
|
|
21
|
+
constructor(buffer) {
|
|
22
|
+
const name = 'block-message';
|
|
23
|
+
super(buffer, proto, { name });
|
|
24
|
+
}
|
|
25
|
+
encode() {
|
|
26
|
+
const decoded = this.decoded;
|
|
27
|
+
const validators = [];
|
|
28
|
+
const transactions = [];
|
|
29
|
+
for (const validator of decoded.validators) {
|
|
30
|
+
if (validator instanceof ValidatorMessage)
|
|
31
|
+
validators.push(validator.encoded);
|
|
32
|
+
else
|
|
33
|
+
validators.push(new ValidatorMessage(validator).encoded);
|
|
34
|
+
}
|
|
35
|
+
for (const transaction of decoded.transactions) {
|
|
36
|
+
if (transaction instanceof TransactionMessage)
|
|
37
|
+
transactions.push(transaction.encoded);
|
|
38
|
+
else
|
|
39
|
+
transactions.push(new TransactionMessage(transaction).encoded);
|
|
40
|
+
}
|
|
41
|
+
return super.encode({
|
|
42
|
+
...decoded,
|
|
43
|
+
validators: smartConcat(validators),
|
|
44
|
+
transactions: smartConcat(transactions)
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
decode() {
|
|
48
|
+
super.decode();
|
|
49
|
+
this.decoded.transactions = smartDeconcat(this.decoded.transactions).map(transaction => new TransactionMessage(transaction).decoded);
|
|
50
|
+
this.decoded.validators = smartDeconcat(this.decoded.validators).map(validator => new ValidatorMessage(validator).decoded);
|
|
51
|
+
return this.decoded;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { BlockMessage as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FormatInterface } from '@leofcoin/codec-format-interface';
|
|
2
|
+
|
|
3
|
+
var proto = {
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
class BWRequestMessage extends FormatInterface {
|
|
7
|
+
get messageName() {
|
|
8
|
+
return 'BWRequestMessage';
|
|
9
|
+
}
|
|
10
|
+
constructor(buffer) {
|
|
11
|
+
const name = 'bw-request-message';
|
|
12
|
+
super(buffer, proto, { name });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { BWRequestMessage as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FormatInterface } from '@leofcoin/codec-format-interface';
|
|
2
|
+
|
|
3
|
+
var proto = {
|
|
4
|
+
up: Number(),
|
|
5
|
+
down: Number()
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
class BWMessage extends FormatInterface {
|
|
9
|
+
get messageName() {
|
|
10
|
+
return 'BWMessage';
|
|
11
|
+
}
|
|
12
|
+
constructor(buffer) {
|
|
13
|
+
const name = 'bw-message';
|
|
14
|
+
super(buffer, proto, { name });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { BWMessage as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FormatInterface } from '@leofcoin/codec-format-interface';
|
|
2
|
+
|
|
3
|
+
var proto = {
|
|
4
|
+
creator: String(),
|
|
5
|
+
contract: new Uint8Array(),
|
|
6
|
+
constructorParameters: Array()
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
class ContractMessage extends FormatInterface {
|
|
10
|
+
get messageName() {
|
|
11
|
+
return 'ContractMessage';
|
|
12
|
+
}
|
|
13
|
+
constructor(buffer) {
|
|
14
|
+
super(buffer, proto, { name: 'contract-message' });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { ContractMessage as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FormatInterface } from '@leofcoin/codec-format-interface';
|
|
2
|
+
|
|
3
|
+
var proto = {
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
class LastBlockRequestMessage extends FormatInterface {
|
|
7
|
+
get messageName() {
|
|
8
|
+
return 'LastBlockRequestMessage';
|
|
9
|
+
}
|
|
10
|
+
constructor(buffer) {
|
|
11
|
+
const name = 'last-block-request-message';
|
|
12
|
+
super(buffer, proto, { name });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { LastBlockRequestMessage as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FormatInterface } from '@leofcoin/codec-format-interface';
|
|
2
|
+
|
|
3
|
+
var proto = {
|
|
4
|
+
hash: String(),
|
|
5
|
+
index: Number()
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
class LastBlockMessage extends FormatInterface {
|
|
9
|
+
get messageName() {
|
|
10
|
+
return 'LastBlockMessage';
|
|
11
|
+
}
|
|
12
|
+
constructor(buffer) {
|
|
13
|
+
const name = 'last-block-message';
|
|
14
|
+
super(buffer, proto, { name });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { LastBlockMessage as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FormatInterface } from '@leofcoin/codec-format-interface';
|
|
2
|
+
|
|
3
|
+
var proto = {
|
|
4
|
+
timestamp: Number(),
|
|
5
|
+
from: String(),
|
|
6
|
+
to: String(),
|
|
7
|
+
nonce: Number(),
|
|
8
|
+
method: String(),
|
|
9
|
+
params: Array(),
|
|
10
|
+
signature: new Uint8Array()
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
class TransactionMessage extends FormatInterface {
|
|
14
|
+
get messageName() {
|
|
15
|
+
return 'TransactionMessage';
|
|
16
|
+
}
|
|
17
|
+
constructor(buffer) {
|
|
18
|
+
const name = 'transaction-message';
|
|
19
|
+
super(buffer, proto, { name });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { TransactionMessage as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FormatInterface } from '@leofcoin/codec-format-interface';
|
|
2
|
+
|
|
3
|
+
var proto = {
|
|
4
|
+
address: String(),
|
|
5
|
+
reward: Number()
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
class ValidatorMessage extends FormatInterface {
|
|
9
|
+
get messageName() {
|
|
10
|
+
return 'ValidatorMessage';
|
|
11
|
+
}
|
|
12
|
+
constructor(buffer) {
|
|
13
|
+
const name = 'validator-message';
|
|
14
|
+
super(buffer, proto, { name });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { ValidatorMessage as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as BlockMessage } from './messages/block.js';
|
|
2
|
+
export { default as BWMessage } from './messages/bw.js';
|
|
3
|
+
export { default as BWRequestMessage } from './messages/bw-request.js';
|
|
4
|
+
export { default as ContractMessage } from './messages/contract.js';
|
|
5
|
+
export { default as LastBlockMessage } from './messages/last-block.js';
|
|
6
|
+
export { default as LastBlockRequestMessage } from './messages/last-block-request.js';
|
|
7
|
+
export { default as TransactionMessage } from './messages/transaction.js';
|
|
8
|
+
export { default as ValidatorMessage } from './messages/validator.js';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FormatInterface } from '@leofcoin/codec-format-interface';
|
|
2
|
+
export default class BlockMessage extends FormatInterface {
|
|
3
|
+
decoded: {
|
|
4
|
+
index: Number;
|
|
5
|
+
previousHash: String;
|
|
6
|
+
timestamp: String;
|
|
7
|
+
reward: Number;
|
|
8
|
+
fees: Number;
|
|
9
|
+
transactions: Uint8Array[] | Object[] | Uint8Array;
|
|
10
|
+
validators: Uint8Array[] | Object[] | Uint8Array;
|
|
11
|
+
};
|
|
12
|
+
get messageName(): string;
|
|
13
|
+
constructor(buffer: messageInput);
|
|
14
|
+
encode(): Uint8Array;
|
|
15
|
+
decode(): {
|
|
16
|
+
index: Number;
|
|
17
|
+
previousHash: String;
|
|
18
|
+
timestamp: String;
|
|
19
|
+
reward: Number;
|
|
20
|
+
fees: Number;
|
|
21
|
+
transactions: Uint8Array | Uint8Array[] | Object[];
|
|
22
|
+
validators: Uint8Array | Uint8Array[] | Object[];
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import '../messages/block.js';
|
|
2
|
+
import '../messages/bw.js';
|
|
3
|
+
import '../messages/bw-request.js';
|
|
4
|
+
import '../messages/contract.js';
|
|
5
|
+
import '../messages/last-block.js';
|
|
6
|
+
import '../messages/last-block-request.js';
|
|
7
|
+
import TransactionMessage from '../messages/transaction.js';
|
|
8
|
+
import '../messages/validator.js';
|
|
9
|
+
import EasyWorker from '@vandeurenglenn/easy-worker';
|
|
10
|
+
|
|
11
|
+
globalThis.peernet = globalThis.peernet || {};
|
|
12
|
+
globalThis.contracts = {};
|
|
13
|
+
const worker = new EasyWorker();
|
|
14
|
+
worker.onmessage(async (transactions) => {
|
|
15
|
+
globalThis.peernet.codecs = {
|
|
16
|
+
'transaction-message': {
|
|
17
|
+
codec: parseInt('746d', 16),
|
|
18
|
+
hashAlg: 'keccak-256'
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
transactions = await Promise.all(transactions.map(async (message) => (message instanceof TransactionMessage ? new Uint8Array(message.encoded) : new TransactionMessage({ ...message, signature: new Uint8Array(message.signature) }).encoded)));
|
|
22
|
+
worker.postMessage(transactions);
|
|
23
|
+
});
|
package/package.json
CHANGED
|
@@ -1,21 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/messages",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "",
|
|
5
|
-
"
|
|
6
|
-
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./exports/index.js",
|
|
7
|
+
"./block": "./exports/block.js",
|
|
8
|
+
"./bw-request": "./exports/bw-request.js",
|
|
9
|
+
"./bw": "./exports/bw.js",
|
|
10
|
+
"./contract": "./exports/contract.js",
|
|
11
|
+
"./last-block-request": "./exports/last-block-request.js",
|
|
12
|
+
"./last-block": "./exports/last-block.js",
|
|
13
|
+
"./transaction": "./exports/transaction.js"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"typings": "./exports/typings/index.d.ts",
|
|
7
17
|
"scripts": {
|
|
8
|
-
"build": "rollup -c
|
|
18
|
+
"build": "rollup -c",
|
|
9
19
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
10
20
|
},
|
|
11
21
|
"keywords": [],
|
|
12
22
|
"author": "",
|
|
13
23
|
"license": "MIT",
|
|
14
24
|
"devDependencies": {
|
|
15
|
-
"
|
|
16
|
-
"
|
|
25
|
+
"@rollup/plugin-typescript": "^11.0.0",
|
|
26
|
+
"rollup": "^3.10.0",
|
|
27
|
+
"tslib": "^2.4.1"
|
|
17
28
|
},
|
|
18
29
|
"dependencies": {
|
|
19
|
-
"@leofcoin/codec-format-interface": "^1.
|
|
30
|
+
"@leofcoin/codec-format-interface": "^1.4.0",
|
|
31
|
+
"@vandeurenglenn/easy-worker": "^1.0.2"
|
|
20
32
|
}
|
|
21
33
|
}
|
package/rollup.config.js
CHANGED
|
@@ -1,7 +1,56 @@
|
|
|
1
|
+
import typescript from "@rollup/plugin-typescript"
|
|
2
|
+
import tsConfig from './tsconfig.json' assert { type: 'json'}
|
|
3
|
+
|
|
4
|
+
|
|
1
5
|
export default [{
|
|
2
|
-
input: ['./src/
|
|
6
|
+
input: ['./src/index.ts'],
|
|
3
7
|
output: {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
+
format: 'es',
|
|
9
|
+
dir: './exports'
|
|
10
|
+
},
|
|
11
|
+
external: [
|
|
12
|
+
'./messages/block.js',
|
|
13
|
+
'./messages/bw.js',
|
|
14
|
+
'./messages/bw-request.js',
|
|
15
|
+
'./messages/contract.js',
|
|
16
|
+
'./messages/last-block.js',
|
|
17
|
+
'./messages/last-block-request.js',
|
|
18
|
+
'./messages/transaction.js',
|
|
19
|
+
'./messages/validator.js'
|
|
20
|
+
],
|
|
21
|
+
plugins: [
|
|
22
|
+
typescript(tsConfig)
|
|
23
|
+
]
|
|
24
|
+
}, {
|
|
25
|
+
input: [
|
|
26
|
+
'./src/messages/block.ts',
|
|
27
|
+
'./src/messages/bw.ts',
|
|
28
|
+
'./src/messages/bw-request.ts',
|
|
29
|
+
'./src/messages/contract.ts',
|
|
30
|
+
'./src/messages/last-block.ts',
|
|
31
|
+
'./src/messages/last-block-request.ts',
|
|
32
|
+
'./src/messages/transaction.ts',
|
|
33
|
+
'./src/messages/validator.ts'
|
|
34
|
+
],
|
|
35
|
+
output: {
|
|
36
|
+
format: 'es',
|
|
37
|
+
dir: './exports/messages'
|
|
38
|
+
},
|
|
39
|
+
external: [
|
|
40
|
+
'./messages/block.js',
|
|
41
|
+
'./messages/bw.js',
|
|
42
|
+
'./messages/bw-request.js',
|
|
43
|
+
'./messages/contract.js',
|
|
44
|
+
'./messages/last-block.js',
|
|
45
|
+
'./messages/last-block-request.js',
|
|
46
|
+
'./messages/transaction.js',
|
|
47
|
+
'./messages/validator.js'
|
|
48
|
+
],
|
|
49
|
+
plugins: [
|
|
50
|
+
typescript({"module": "ES2022",
|
|
51
|
+
"target": "es2022",
|
|
52
|
+
"moduleResolution":"NodeNext",
|
|
53
|
+
"allowJs": true,
|
|
54
|
+
"allowSyntheticDefaultImports": true, declaration: false, declarationDir: './exports/messages', outDir: './exports/messages'})
|
|
55
|
+
]
|
|
56
|
+
}]
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare type messageInput = Uint8Array | String | Object | ArrayBuffer
|
|
2
|
+
|
|
3
|
+
export { default as BlockMessage } from './messages/block.js'
|
|
4
|
+
export { default as BWMessage } from './messages/bw.js'
|
|
5
|
+
export { default as BWRequestMessage } from './messages/bw-request.js'
|
|
6
|
+
export { default as ContractMessage } from './messages/contract.js'
|
|
7
|
+
export { default as LastBlockMessage } from './messages/last-block.js'
|
|
8
|
+
export { default as LastBlockRequestMessage } from './messages/last-block-request.js'
|
|
9
|
+
export { default as TransactionMessage } from './messages/transaction.js'
|
|
10
|
+
export { default as ValidatorMessage } from './messages/validator.js'
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import proto from '../protos/block.proto.js'
|
|
2
|
+
import { FormatInterface } from '@leofcoin/codec-format-interface'
|
|
3
|
+
import TransactionMessage from './transaction.js'
|
|
4
|
+
import ValidatorMessage from './validator.js'
|
|
5
|
+
import smartConcat from '@vandeurenglenn/typed-array-smart-concat'
|
|
6
|
+
import smartDeconcat from '@vandeurenglenn/typed-array-smart-deconcat'
|
|
7
|
+
|
|
8
|
+
export default class BlockMessage extends FormatInterface {
|
|
9
|
+
declare decoded: {
|
|
10
|
+
index: Number,
|
|
11
|
+
previousHash: String,
|
|
12
|
+
timestamp: String,
|
|
13
|
+
reward: Number,
|
|
14
|
+
fees: Number,
|
|
15
|
+
transactions: Uint8Array[] | Object[] | Uint8Array,
|
|
16
|
+
validators: Uint8Array[] | Object[] | Uint8Array
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get messageName() {
|
|
20
|
+
return 'BlockMessage'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
constructor(buffer: messageInput) {
|
|
24
|
+
const name = 'block-message'
|
|
25
|
+
super(buffer, proto, {name})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
encode(): Uint8Array {
|
|
29
|
+
const decoded = this.decoded
|
|
30
|
+
const validators: Uint8Array[] = []
|
|
31
|
+
const transactions: Uint8Array[] = []
|
|
32
|
+
|
|
33
|
+
for (const validator of decoded.validators) {
|
|
34
|
+
if (validator instanceof ValidatorMessage) validators.push(validator.encoded)
|
|
35
|
+
else validators.push(new ValidatorMessage(validator).encoded)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
for (const transaction of decoded.transactions) {
|
|
39
|
+
if (transaction instanceof TransactionMessage) transactions.push(transaction.encoded)
|
|
40
|
+
else transactions.push(new TransactionMessage(transaction).encoded)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return super.encode({
|
|
44
|
+
...decoded,
|
|
45
|
+
validators: smartConcat(validators),
|
|
46
|
+
transactions: smartConcat(transactions)
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
decode() {
|
|
51
|
+
super.decode()
|
|
52
|
+
this.decoded.transactions = smartDeconcat(this.decoded.transactions as Uint8Array).map(transaction => new TransactionMessage(transaction).decoded)
|
|
53
|
+
this.decoded.validators = smartDeconcat(this.decoded.validators as Uint8Array).map(validator => new ValidatorMessage(validator).decoded)
|
|
54
|
+
return this.decoded
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import proto from '
|
|
1
|
+
import proto from '../protos/bw-request.proto.js'
|
|
2
2
|
import { FormatInterface } from '@leofcoin/codec-format-interface'
|
|
3
3
|
|
|
4
4
|
export default class BWRequestMessage extends FormatInterface {
|
|
5
|
-
get keys() {
|
|
6
|
-
return []
|
|
7
|
-
}
|
|
8
|
-
|
|
9
5
|
get messageName() {
|
|
10
6
|
return 'BWRequestMessage'
|
|
11
7
|
}
|
|
12
8
|
|
|
13
|
-
constructor(buffer) {
|
|
9
|
+
constructor(buffer: messageInput) {
|
|
14
10
|
const name = 'bw-request-message'
|
|
15
11
|
super(buffer, proto, {name})
|
|
16
12
|
}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import proto from '
|
|
1
|
+
import proto from '../protos/bw.proto.js'
|
|
2
2
|
import { FormatInterface } from '@leofcoin/codec-format-interface'
|
|
3
3
|
|
|
4
4
|
export default class BWMessage extends FormatInterface {
|
|
5
|
-
get keys() {
|
|
6
|
-
return ['up', 'down']
|
|
7
|
-
}
|
|
8
|
-
|
|
9
5
|
get messageName() {
|
|
10
6
|
return 'BWMessage'
|
|
11
7
|
}
|
|
12
8
|
|
|
13
|
-
constructor(buffer) {
|
|
9
|
+
constructor(buffer: messageInput) {
|
|
14
10
|
const name = 'bw-message'
|
|
15
11
|
super(buffer, proto, {name})
|
|
16
12
|
}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import proto from '
|
|
1
|
+
import proto from '../protos/contract.proto.js'
|
|
2
2
|
import { FormatInterface } from '@leofcoin/codec-format-interface'
|
|
3
3
|
|
|
4
4
|
export default class ContractMessage extends FormatInterface {
|
|
5
|
-
get keys() {
|
|
6
|
-
return ['creator', 'contract', 'constructorParameters']
|
|
7
|
-
}
|
|
8
|
-
|
|
9
5
|
get messageName() {
|
|
10
6
|
return 'ContractMessage'
|
|
11
7
|
}
|
|
12
8
|
|
|
13
|
-
constructor(buffer) {
|
|
9
|
+
constructor(buffer: messageInput) {
|
|
14
10
|
super(buffer, proto, {name: 'contract-message'})
|
|
15
11
|
}
|
|
16
12
|
}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import proto from '
|
|
1
|
+
import proto from '../protos/last-block-request.proto.js'
|
|
2
2
|
import { FormatInterface } from '@leofcoin/codec-format-interface'
|
|
3
3
|
|
|
4
4
|
export default class LastBlockRequestMessage extends FormatInterface {
|
|
5
|
-
get keys() {
|
|
6
|
-
return []
|
|
7
|
-
}
|
|
8
|
-
|
|
9
5
|
get messageName() {
|
|
10
6
|
return 'LastBlockRequestMessage'
|
|
11
7
|
}
|
|
12
8
|
|
|
13
|
-
constructor(buffer) {
|
|
9
|
+
constructor(buffer: messageInput) {
|
|
14
10
|
const name = 'last-block-request-message'
|
|
15
11
|
super(buffer, proto, {name})
|
|
16
12
|
}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import proto from '
|
|
1
|
+
import proto from '../protos/last-block.proto.js'
|
|
2
2
|
import { FormatInterface } from '@leofcoin/codec-format-interface'
|
|
3
3
|
|
|
4
4
|
export default class LastBlockMessage extends FormatInterface {
|
|
5
|
-
get keys() {
|
|
6
|
-
return ['hash', 'index']
|
|
7
|
-
}
|
|
8
|
-
|
|
9
5
|
get messageName() {
|
|
10
6
|
return 'LastBlockMessage'
|
|
11
7
|
}
|
|
12
8
|
|
|
13
|
-
constructor(buffer) {
|
|
9
|
+
constructor(buffer: messageInput) {
|
|
14
10
|
const name = 'last-block-message'
|
|
15
11
|
super(buffer, proto, {name})
|
|
16
12
|
}
|