@leofcoin/messages 1.0.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/dist/messages.js +156 -0
- package/package.json +17 -0
- package/rollup.config.js +7 -0
- package/src/messages/block.js +14 -0
- package/src/messages/bw-request.js +14 -0
- package/src/messages/bw.js +14 -0
- package/src/messages/contract.js +13 -0
- package/src/messages/last-block-request.js +14 -0
- package/src/messages/last-block.js +14 -0
- package/src/messages/transaction.js +14 -0
- package/src/messages.js +5 -0
- package/src/protos/block.proto.js +26 -0
- package/src/protos/bw-request.proto.js +5 -0
- package/src/protos/bw.proto.js +7 -0
- package/src/protos/contract.proto.js +7 -0
- package/src/protos/last-block-request.proto.js +5 -0
- package/src/protos/last-block.proto.js +7 -0
- package/src/protos/transaction.proto.js +11 -0
package/dist/messages.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var protons = require('protons');
|
|
6
|
+
var codecFormatInterface = require('@leofcoin/codec-format-interface');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var protons__default = /*#__PURE__*/_interopDefaultLegacy(protons);
|
|
11
|
+
|
|
12
|
+
var proto$4 = `
|
|
13
|
+
message ContractMessage {
|
|
14
|
+
required string creator = 1;
|
|
15
|
+
required bytes contract = 2;
|
|
16
|
+
repeated string constructorParameters = 3;
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
class ContractMessage extends codecFormatInterface.FormatInterface {
|
|
21
|
+
get keys() {
|
|
22
|
+
return ['creator', 'contract', 'constructorParameters']
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
constructor(buffer) {
|
|
26
|
+
super(buffer, protons__default['default'](proto$4).ContractMessage, {name: 'contract-message'});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var contract = /*#__PURE__*/Object.freeze({
|
|
31
|
+
__proto__: null,
|
|
32
|
+
'default': ContractMessage
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
var proto$3 = `
|
|
36
|
+
|
|
37
|
+
message TransactionMessage {
|
|
38
|
+
required uint64 timestamp = 1;
|
|
39
|
+
required string from = 2;
|
|
40
|
+
required string to = 3;
|
|
41
|
+
required uint64 nonce = 4;
|
|
42
|
+
required string method = 5;
|
|
43
|
+
repeated string params = 6;
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
class TransactionMessage extends codecFormatInterface.FormatInterface {
|
|
48
|
+
get keys() {
|
|
49
|
+
return ['timestamp', 'from', 'to', 'nonce', 'method', 'params']
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
constructor(buffer) {
|
|
53
|
+
const name = 'transaction-message';
|
|
54
|
+
super(buffer, protons__default['default'](proto$3).TransactionMessage, {name});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
var transaction = /*#__PURE__*/Object.freeze({
|
|
59
|
+
__proto__: null,
|
|
60
|
+
'default': TransactionMessage
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
var proto$2 = `
|
|
64
|
+
message ValidatorMessage {
|
|
65
|
+
required string address = 1;
|
|
66
|
+
required string reward = 2;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
message Transaction {
|
|
70
|
+
required string hash = 1;
|
|
71
|
+
required uint64 timestamp = 2;
|
|
72
|
+
required string from = 3;
|
|
73
|
+
required string to = 4;
|
|
74
|
+
required uint64 nonce = 5;
|
|
75
|
+
required string method = 6;
|
|
76
|
+
repeated string params = 7;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
message BlockMessage {
|
|
80
|
+
required uint64 index = 1;
|
|
81
|
+
required string previousHash = 3;
|
|
82
|
+
required uint64 timestamp = 4;
|
|
83
|
+
required uint64 reward = 5;
|
|
84
|
+
required string fees = 6;
|
|
85
|
+
repeated Transaction transactions = 7;
|
|
86
|
+
repeated ValidatorMessage validators = 8;
|
|
87
|
+
}
|
|
88
|
+
`;
|
|
89
|
+
|
|
90
|
+
class BlockMessage extends codecFormatInterface.FormatInterface {
|
|
91
|
+
get keys() {
|
|
92
|
+
return ['index', 'previousHash', 'timestamp', 'reward', 'fees', 'transactions', 'validators']
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
constructor(buffer) {
|
|
96
|
+
const name = 'block-message';
|
|
97
|
+
super(buffer, protons__default['default'](proto$2).BlockMessage, {name});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
var block = /*#__PURE__*/Object.freeze({
|
|
102
|
+
__proto__: null,
|
|
103
|
+
'default': BlockMessage
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
var proto$1 = `
|
|
107
|
+
|
|
108
|
+
message BWMessage {
|
|
109
|
+
required uint64 up = 1;
|
|
110
|
+
required uint64 down = 2;
|
|
111
|
+
}
|
|
112
|
+
`;
|
|
113
|
+
|
|
114
|
+
class BWMessage extends codecFormatInterface.FormatInterface {
|
|
115
|
+
get keys() {
|
|
116
|
+
return ['up', 'down']
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
constructor(buffer) {
|
|
120
|
+
const name = 'bw-message';
|
|
121
|
+
super(buffer, protons__default['default'](proto$1).BWMessage, {name});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
var bw = /*#__PURE__*/Object.freeze({
|
|
126
|
+
__proto__: null,
|
|
127
|
+
'default': BWMessage
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
var proto = `
|
|
131
|
+
|
|
132
|
+
message BWRequestMessage {
|
|
133
|
+
}
|
|
134
|
+
`;
|
|
135
|
+
|
|
136
|
+
class BWRequestMessage extends codecFormatInterface.FormatInterface {
|
|
137
|
+
get keys() {
|
|
138
|
+
return []
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
constructor(buffer) {
|
|
142
|
+
const name = 'bw-request-message';
|
|
143
|
+
super(buffer, protons__default['default'](proto).BWRequestMessage, {name});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
var bwRequest = /*#__PURE__*/Object.freeze({
|
|
148
|
+
__proto__: null,
|
|
149
|
+
'default': BWRequestMessage
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
exports.BWMessage = bw;
|
|
153
|
+
exports.BWRequestMessage = bwRequest;
|
|
154
|
+
exports.BlockMessage = block;
|
|
155
|
+
exports.ContractMessage = contract;
|
|
156
|
+
exports.TransactionMessage = transaction;
|
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@leofcoin/messages",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/messages.js",
|
|
6
|
+
"module": "src/messages/js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "rollup -c",
|
|
9
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [],
|
|
12
|
+
"author": "",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@leofcoin/codec-format-interface": "^1.0.1"
|
|
16
|
+
}
|
|
17
|
+
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import protons from 'protons'
|
|
2
|
+
import proto from './../protos/block.proto.js'
|
|
3
|
+
import { FormatInterface as CodecFormat } from '@leofcoin/codec-format-interface'
|
|
4
|
+
|
|
5
|
+
export default class BlockMessage extends CodecFormat {
|
|
6
|
+
get keys() {
|
|
7
|
+
return ['index', 'previousHash', 'timestamp', 'reward', 'fees', 'transactions', 'validators']
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
constructor(buffer) {
|
|
11
|
+
const name = 'block-message'
|
|
12
|
+
super(buffer, protons(proto).BlockMessage, {name})
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import protons from 'protons'
|
|
2
|
+
import proto from './../protos/bw-request.proto.js'
|
|
3
|
+
import {FormatInterface as CodecFormat} from '@leofcoin/codec-format-interface'
|
|
4
|
+
|
|
5
|
+
export default class BWRequestMessage extends CodecFormat {
|
|
6
|
+
get keys() {
|
|
7
|
+
return []
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
constructor(buffer) {
|
|
11
|
+
const name = 'bw-request-message'
|
|
12
|
+
super(buffer, protons(proto).BWRequestMessage, {name})
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import protons from 'protons'
|
|
2
|
+
import proto from './../protos/bw.proto.js'
|
|
3
|
+
import { FormatInterface as CodecFormat } from '@leofcoin/codec-format-interface'
|
|
4
|
+
|
|
5
|
+
export default class BWMessage extends CodecFormat {
|
|
6
|
+
get keys() {
|
|
7
|
+
return ['up', 'down']
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
constructor(buffer) {
|
|
11
|
+
const name = 'bw-message'
|
|
12
|
+
super(buffer, protons(proto).BWMessage, {name})
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import protons from 'protons'
|
|
2
|
+
import proto from './../protos/contract.proto.js'
|
|
3
|
+
import { FormatInterface as CodecFormat } from '@leofcoin/codec-format-interface'
|
|
4
|
+
|
|
5
|
+
export default class ContractMessage extends CodecFormat {
|
|
6
|
+
get keys() {
|
|
7
|
+
return ['creator', 'contract', 'constructorParameters']
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
constructor(buffer) {
|
|
11
|
+
super(buffer, protons(proto).ContractMessage, {name: 'contract-message'})
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import protons from 'protons'
|
|
2
|
+
import proto from './../protos/last-block-request.proto.js'
|
|
3
|
+
import { FormatInterface as CodecFormat } from '@leofcoin/codec-format-interface'
|
|
4
|
+
|
|
5
|
+
export default class LastBlockRequestMessage extends CodecFormat {
|
|
6
|
+
get keys() {
|
|
7
|
+
return []
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
constructor(buffer) {
|
|
11
|
+
const name = 'last-block-request-message'
|
|
12
|
+
super(buffer, protons(proto).LastBlockRequestMessage, {name})
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import protons from 'protons'
|
|
2
|
+
import proto from './../protos/last-block.proto.js'
|
|
3
|
+
import { FormatInterface as CodecFormat } from '@leofcoin/codec-format-interface'
|
|
4
|
+
|
|
5
|
+
export default class LastBlockMessage extends CodecFormat {
|
|
6
|
+
get keys() {
|
|
7
|
+
return ['hash', 'index']
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
constructor(buffer) {
|
|
11
|
+
const name = 'last-block-message'
|
|
12
|
+
super(buffer, protons(proto).LastBlockMessage, {name})
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import protons from 'protons'
|
|
2
|
+
import proto from './../protos/transaction.proto.js'
|
|
3
|
+
import { FormatInterface as CodecFormat } from '@leofcoin/codec-format-interface'
|
|
4
|
+
|
|
5
|
+
export default class TransactionMessage extends CodecFormat {
|
|
6
|
+
get keys() {
|
|
7
|
+
return ['timestamp', 'from', 'to', 'nonce', 'method', 'params']
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
constructor(buffer) {
|
|
11
|
+
const name = 'transaction-message'
|
|
12
|
+
super(buffer, protons(proto).TransactionMessage, {name})
|
|
13
|
+
}
|
|
14
|
+
}
|
package/src/messages.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * as ContractMessage from './messages/contract'
|
|
2
|
+
export * as TransactionMessage from './messages/transaction'
|
|
3
|
+
export * as BlockMessage from './messages/block'
|
|
4
|
+
export * as BWMessage from './messages/bw'
|
|
5
|
+
export * as BWRequestMessage from './messages/bw-request'
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default `
|
|
2
|
+
message ValidatorMessage {
|
|
3
|
+
required string address = 1;
|
|
4
|
+
required string reward = 2;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
message Transaction {
|
|
8
|
+
required string hash = 1;
|
|
9
|
+
required uint64 timestamp = 2;
|
|
10
|
+
required string from = 3;
|
|
11
|
+
required string to = 4;
|
|
12
|
+
required uint64 nonce = 5;
|
|
13
|
+
required string method = 6;
|
|
14
|
+
repeated string params = 7;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
message BlockMessage {
|
|
18
|
+
required uint64 index = 1;
|
|
19
|
+
required string previousHash = 3;
|
|
20
|
+
required uint64 timestamp = 4;
|
|
21
|
+
required uint64 reward = 5;
|
|
22
|
+
required string fees = 6;
|
|
23
|
+
repeated Transaction transactions = 7;
|
|
24
|
+
repeated ValidatorMessage validators = 8;
|
|
25
|
+
}
|
|
26
|
+
`
|