@leofcoin/messages 1.3.11 → 1.3.13

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.
Files changed (46) hide show
  1. package/exports/block.js +56 -0
  2. package/exports/bw-request.js +16 -0
  3. package/exports/bw.js +18 -0
  4. package/exports/contract.js +18 -0
  5. package/{src/index.ts → exports/index.d.ts} +9 -11
  6. package/exports/index.js +33 -0
  7. package/exports/last-block-request.js +16 -0
  8. package/exports/last-block.js +18 -0
  9. package/exports/messages/block.d.ts +25 -0
  10. package/exports/messages/bw-request.d.ts +5 -0
  11. package/exports/messages/bw.d.ts +5 -0
  12. package/exports/messages/contract.d.ts +5 -0
  13. package/exports/messages/last-block-request.d.ts +5 -0
  14. package/exports/messages/last-block.d.ts +5 -0
  15. package/exports/messages/publish.d.ts +5 -0
  16. package/exports/messages/raw-transaction.d.ts +5 -0
  17. package/exports/messages/transaction.d.ts +5 -0
  18. package/exports/messages/validator.d.ts +5 -0
  19. package/exports/protos/transaction.proto.d.ts +3 -0
  20. package/exports/transaction.js +23 -0
  21. package/exports/validator.js +19 -0
  22. package/package.json +40 -18
  23. package/rollup.config.js +0 -56
  24. package/src/messages/block.ts +0 -57
  25. package/src/messages/bw-request.ts +0 -13
  26. package/src/messages/bw.ts +0 -13
  27. package/src/messages/contract.ts +0 -12
  28. package/src/messages/last-block-request.ts +0 -13
  29. package/src/messages/last-block.ts +0 -13
  30. package/src/messages/publish.ts +0 -13
  31. package/src/messages/raw-transaction.ts +0 -13
  32. package/src/messages/transaction.ts +0 -13
  33. package/src/messages/validator.ts +0 -13
  34. package/src/protos/block.proto.js +0 -11
  35. package/src/protos/bw-request.proto.js +0 -2
  36. package/src/protos/bw.proto.js +0 -4
  37. package/src/protos/contract.proto.js +0 -5
  38. package/src/protos/last-block-request.proto.js +0 -2
  39. package/src/protos/last-block.proto.js +0 -4
  40. package/src/protos/publish.proto.js +0 -7
  41. package/src/protos/raw-transaction.proto.js +0 -8
  42. package/src/protos/transaction.proto.js +0 -9
  43. package/src/protos/validator.proto.js +0 -6
  44. package/src/types.d.ts +0 -1
  45. package/test.js +0 -49
  46. package/tsconfig.json +0 -16
@@ -0,0 +1,56 @@
1
+ import { BigNumber } from '@leofcoin/utils';
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
+ var proto = {
9
+ index: Number(),
10
+ previousHash: String(),
11
+ timestamp: Number(),
12
+ reward: BigNumber.from(0),
13
+ fees: BigNumber.from(0),
14
+ transactions: new Uint8Array(),
15
+ validators: new Uint8Array()
16
+ };
17
+
18
+ class BlockMessage extends FormatInterface {
19
+ get messageName() {
20
+ return 'BlockMessage';
21
+ }
22
+ constructor(buffer) {
23
+ const name = 'block-message';
24
+ super(buffer, proto, { name });
25
+ }
26
+ encode() {
27
+ const decoded = this.decoded;
28
+ const validators = [];
29
+ const transactions = [];
30
+ for (const validator of decoded.validators) {
31
+ if (validator instanceof ValidatorMessage)
32
+ validators.push(validator.encoded);
33
+ else
34
+ validators.push(new ValidatorMessage(validator).encoded);
35
+ }
36
+ for (const transaction of decoded.transactions) {
37
+ if (transaction instanceof TransactionMessage)
38
+ transactions.push(transaction.encoded);
39
+ else
40
+ transactions.push(new TransactionMessage(transaction).encoded);
41
+ }
42
+ return super.encode({
43
+ ...decoded,
44
+ validators: smartConcat(validators),
45
+ transactions: smartConcat(transactions)
46
+ });
47
+ }
48
+ decode() {
49
+ super.decode();
50
+ this.decoded.transactions = smartDeconcat(this.decoded.transactions).map(transaction => new TransactionMessage(transaction).decoded);
51
+ this.decoded.validators = smartDeconcat(this.decoded.validators).map(validator => new ValidatorMessage(validator).decoded);
52
+ return this.decoded;
53
+ }
54
+ }
55
+
56
+ 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 };
package/exports/bw.js ADDED
@@ -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 };
@@ -1,11 +1,9 @@
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 RawTransactionMessage } from './messages/raw-transaction.js'
11
- export { default as ValidatorMessage } from './messages/validator.js'
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 RawTransactionMessage } from './messages/raw-transaction.js';
9
+ export { default as ValidatorMessage } from './messages/validator.js';
@@ -0,0 +1,33 @@
1
+ export { default as BlockMessage } from './block.js';
2
+ export { default as BWMessage } from './bw.js';
3
+ export { default as BWRequestMessage } from './bw-request.js';
4
+ export { default as ContractMessage } from './contract.js';
5
+ export { default as LastBlockMessage } from './last-block.js';
6
+ export { default as LastBlockRequestMessage } from './last-block-request.js';
7
+ export { default as TransactionMessage } from './transaction.js';
8
+ import { FormatInterface } from '@leofcoin/codec-format-interface';
9
+ export { default as ValidatorMessage } from './validator.js';
10
+ import '@leofcoin/utils';
11
+ import '@vandeurenglenn/typed-array-smart-concat';
12
+ import '@vandeurenglenn/typed-array-smart-deconcat';
13
+
14
+ var proto = {
15
+ timestamp: Number(),
16
+ from: String(),
17
+ to: String(),
18
+ nonce: Number(),
19
+ method: String(),
20
+ params: Array()
21
+ };
22
+
23
+ class RawTransactionMessage extends FormatInterface {
24
+ get messageName() {
25
+ return 'RawTransactionMessage';
26
+ }
27
+ constructor(buffer) {
28
+ const name = 'raw-transaction-message';
29
+ super(buffer, proto, { name });
30
+ }
31
+ }
32
+
33
+ export { RawTransactionMessage };
@@ -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,25 @@
1
+ import { FormatInterface } from '@leofcoin/codec-format-interface';
2
+ import { BigNumber } from '@leofcoin/utils';
3
+ export default class BlockMessage extends FormatInterface {
4
+ decoded: {
5
+ index: Number;
6
+ previousHash: String;
7
+ timestamp: String;
8
+ reward: BigNumber;
9
+ fees: BigNumber;
10
+ transactions: Uint8Array[] | Object[] | Uint8Array;
11
+ validators: Uint8Array[] | Object[] | Uint8Array;
12
+ };
13
+ get messageName(): string;
14
+ constructor(buffer: messageInput);
15
+ encode(): Uint8Array;
16
+ decode(): {
17
+ index: Number;
18
+ previousHash: String;
19
+ timestamp: String;
20
+ reward: BigNumber;
21
+ fees: BigNumber;
22
+ transactions: Uint8Array | Uint8Array[] | Object[];
23
+ validators: Uint8Array | Uint8Array[] | Object[];
24
+ };
25
+ }
@@ -0,0 +1,5 @@
1
+ import { FormatInterface } from '@leofcoin/codec-format-interface';
2
+ export default class BWRequestMessage extends FormatInterface {
3
+ get messageName(): string;
4
+ constructor(buffer: messageInput);
5
+ }
@@ -0,0 +1,5 @@
1
+ import { FormatInterface } from '@leofcoin/codec-format-interface';
2
+ export default class BWMessage extends FormatInterface {
3
+ get messageName(): string;
4
+ constructor(buffer: messageInput);
5
+ }
@@ -0,0 +1,5 @@
1
+ import { FormatInterface } from '@leofcoin/codec-format-interface';
2
+ export default class ContractMessage extends FormatInterface {
3
+ get messageName(): string;
4
+ constructor(buffer: messageInput);
5
+ }
@@ -0,0 +1,5 @@
1
+ import { FormatInterface } from '@leofcoin/codec-format-interface';
2
+ export default class LastBlockRequestMessage extends FormatInterface {
3
+ get messageName(): string;
4
+ constructor(buffer: messageInput);
5
+ }
@@ -0,0 +1,5 @@
1
+ import { FormatInterface } from '@leofcoin/codec-format-interface';
2
+ export default class LastBlockMessage extends FormatInterface {
3
+ get messageName(): string;
4
+ constructor(buffer: messageInput);
5
+ }
@@ -0,0 +1,5 @@
1
+ import { FormatInterface } from '@leofcoin/codec-format-interface';
2
+ export default class BWRequestMessage extends FormatInterface {
3
+ get messageName(): string;
4
+ constructor(buffer: messageInput);
5
+ }
@@ -0,0 +1,5 @@
1
+ import { FormatInterface } from '@leofcoin/codec-format-interface';
2
+ export default class RawTransactionMessage extends FormatInterface {
3
+ get messageName(): string;
4
+ constructor(buffer: messageInput);
5
+ }
@@ -0,0 +1,5 @@
1
+ import { FormatInterface } from '@leofcoin/codec-format-interface';
2
+ export default class TransactionMessage extends FormatInterface {
3
+ get messageName(): string;
4
+ constructor(buffer: messageInput);
5
+ }
@@ -0,0 +1,5 @@
1
+ import { FormatInterface } from '@leofcoin/codec-format-interface';
2
+ export default class ValidatorMessage extends FormatInterface {
3
+ get messageName(): string;
4
+ constructor(buffer: messageInput);
5
+ }
@@ -0,0 +1,3 @@
1
+ import { Transaction } from '@leofcoin/types';
2
+ declare const _default: Transaction;
3
+ export default _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: String()
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,19 @@
1
+ import { BigNumber } from '@leofcoin/utils';
2
+ import { FormatInterface } from '@leofcoin/codec-format-interface';
3
+
4
+ var proto = {
5
+ address: String(),
6
+ reward: BigNumber.from(0)
7
+ };
8
+
9
+ class ValidatorMessage extends FormatInterface {
10
+ get messageName() {
11
+ return 'ValidatorMessage';
12
+ }
13
+ constructor(buffer) {
14
+ const name = 'validator-message';
15
+ super(buffer, proto, { name });
16
+ }
17
+ }
18
+
19
+ export { ValidatorMessage as default };
package/package.json CHANGED
@@ -1,27 +1,48 @@
1
1
  {
2
2
  "name": "@leofcoin/messages",
3
- "version": "1.3.11",
3
+ "version": "1.3.13",
4
4
  "description": "",
5
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"
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
+ }
14
38
  },
39
+ "files": [
40
+ "exports"
41
+ ],
15
42
  "type": "module",
16
- "typings": "./exports/typings/index.d.ts",
17
43
  "scripts": {
18
44
  "test": "echo \"Error: no test specified\" && exit 1",
19
- "build": "wireit"
20
- },
21
- "wireit": {
22
- "build": {
23
- "command": "rollup -c --silent error --cache true"
24
- }
45
+ "build": "rollup -c"
25
46
  },
26
47
  "keywords": [],
27
48
  "author": "",
@@ -29,10 +50,11 @@
29
50
  "devDependencies": {
30
51
  "@rollup/plugin-typescript": "^11.0.0",
31
52
  "rollup": "^3.10.0",
32
- "tslib": "^2.4.1"
53
+ "tslib": "^2.4.1",
54
+ "typescript": "^5.2.2"
33
55
  },
34
56
  "dependencies": {
35
- "@leofcoin/codec-format-interface": "^1.6.5",
57
+ "@leofcoin/codec-format-interface": "^1.6.18",
36
58
  "@leofcoin/utils": "^1.1.5",
37
59
  "@vandeurenglenn/easy-worker": "^1.0.2"
38
60
  }
package/rollup.config.js DELETED
@@ -1,56 +0,0 @@
1
- import typescript from "@rollup/plugin-typescript"
2
- import tsConfig from './tsconfig.json' assert { type: 'json'}
3
-
4
-
5
- export default [{
6
- input: ['./src/index.ts'],
7
- output: {
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
- }]
@@ -1,57 +0,0 @@
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
- import { BigNumber } from '@leofcoin/utils'
8
-
9
- export default class BlockMessage extends FormatInterface {
10
- declare decoded: {
11
- index: Number,
12
- previousHash: String,
13
- timestamp: String,
14
- reward: BigNumber,
15
- fees: BigNumber,
16
- transactions: Uint8Array[] | Object[] | Uint8Array,
17
- validators: Uint8Array[] | Object[] | Uint8Array
18
- }
19
-
20
- get messageName() {
21
- return 'BlockMessage'
22
- }
23
-
24
- constructor(buffer: messageInput) {
25
- const name = 'block-message'
26
- super(buffer, proto, {name})
27
- }
28
-
29
- encode(): Uint8Array {
30
- const decoded = this.decoded
31
- const validators: Uint8Array[] = []
32
- const transactions: Uint8Array[] = []
33
-
34
- for (const validator of decoded.validators) {
35
- if (validator instanceof ValidatorMessage) validators.push(validator.encoded)
36
- else validators.push(new ValidatorMessage(validator).encoded)
37
- }
38
-
39
- for (const transaction of decoded.transactions) {
40
- if (transaction instanceof TransactionMessage) transactions.push(transaction.encoded)
41
- else transactions.push(new TransactionMessage(transaction).encoded)
42
- }
43
-
44
- return super.encode({
45
- ...decoded,
46
- validators: smartConcat(validators),
47
- transactions: smartConcat(transactions)
48
- })
49
- }
50
-
51
- decode() {
52
- super.decode()
53
- this.decoded.transactions = smartDeconcat(this.decoded.transactions as Uint8Array).map(transaction => new TransactionMessage(transaction).decoded)
54
- this.decoded.validators = smartDeconcat(this.decoded.validators as Uint8Array).map(validator => new ValidatorMessage(validator).decoded)
55
- return this.decoded
56
- }
57
- }
@@ -1,13 +0,0 @@
1
- import proto from '../protos/bw-request.proto.js'
2
- import { FormatInterface } from '@leofcoin/codec-format-interface'
3
-
4
- export default class BWRequestMessage extends FormatInterface {
5
- get messageName() {
6
- return 'BWRequestMessage'
7
- }
8
-
9
- constructor(buffer: messageInput) {
10
- const name = 'bw-request-message'
11
- super(buffer, proto, {name})
12
- }
13
- }
@@ -1,13 +0,0 @@
1
- import proto from '../protos/bw.proto.js'
2
- import { FormatInterface } from '@leofcoin/codec-format-interface'
3
-
4
- export default class BWMessage extends FormatInterface {
5
- get messageName() {
6
- return 'BWMessage'
7
- }
8
-
9
- constructor(buffer: messageInput) {
10
- const name = 'bw-message'
11
- super(buffer, proto, {name})
12
- }
13
- }
@@ -1,12 +0,0 @@
1
- import proto from '../protos/contract.proto.js'
2
- import { FormatInterface } from '@leofcoin/codec-format-interface'
3
-
4
- export default class ContractMessage extends FormatInterface {
5
- get messageName() {
6
- return 'ContractMessage'
7
- }
8
-
9
- constructor(buffer: messageInput) {
10
- super(buffer, proto, {name: 'contract-message'})
11
- }
12
- }
@@ -1,13 +0,0 @@
1
- import proto from '../protos/last-block-request.proto.js'
2
- import { FormatInterface } from '@leofcoin/codec-format-interface'
3
-
4
- export default class LastBlockRequestMessage extends FormatInterface {
5
- get messageName() {
6
- return 'LastBlockRequestMessage'
7
- }
8
-
9
- constructor(buffer: messageInput) {
10
- const name = 'last-block-request-message'
11
- super(buffer, proto, {name})
12
- }
13
- }
@@ -1,13 +0,0 @@
1
- import proto from '../protos/last-block.proto.js'
2
- import { FormatInterface } from '@leofcoin/codec-format-interface'
3
-
4
- export default class LastBlockMessage extends FormatInterface {
5
- get messageName() {
6
- return 'LastBlockMessage'
7
- }
8
-
9
- constructor(buffer: messageInput) {
10
- const name = 'last-block-message'
11
- super(buffer, proto, {name})
12
- }
13
- }
@@ -1,13 +0,0 @@
1
- import proto from '../protos/publish.proto.js'
2
- import { FormatInterface } from '@leofcoin/codec-format-interface'
3
-
4
- export default class BWRequestMessage extends FormatInterface {
5
- get messageName() {
6
- return 'PublishMessage'
7
- }
8
-
9
- constructor(buffer: messageInput) {
10
- const name = 'publish-message'
11
- super(buffer, proto, {name})
12
- }
13
- }
@@ -1,13 +0,0 @@
1
- import proto from '../protos/raw-transaction.proto.js'
2
- import { FormatInterface } from '@leofcoin/codec-format-interface'
3
-
4
- export default class RawTransactionMessage extends FormatInterface {
5
- get messageName() {
6
- return 'RawTransactionMessage'
7
- }
8
-
9
- constructor(buffer: messageInput) {
10
- const name = 'raw-transaction-message'
11
- super(buffer, proto, {name})
12
- }
13
- }
@@ -1,13 +0,0 @@
1
- import proto from '../protos/transaction.proto.js'
2
- import { FormatInterface } from '@leofcoin/codec-format-interface'
3
-
4
- export default class TransactionMessage extends FormatInterface {
5
- get messageName() {
6
- return 'TransactionMessage'
7
- }
8
-
9
- constructor(buffer: messageInput) {
10
- const name = 'transaction-message'
11
- super(buffer, proto, {name})
12
- }
13
- }
@@ -1,13 +0,0 @@
1
- import proto from '../protos/validator.proto.js'
2
- import { FormatInterface } from '@leofcoin/codec-format-interface'
3
-
4
- export default class ValidatorMessage extends FormatInterface {
5
- get messageName() {
6
- return 'ValidatorMessage'
7
- }
8
-
9
- constructor(buffer: messageInput) {
10
- const name = 'validator-message'
11
- super(buffer, proto, {name})
12
- }
13
- }
@@ -1,11 +0,0 @@
1
- import { BigNumber } from "@leofcoin/utils"
2
-
3
- export default {
4
- index: Number(),
5
- previousHash: String(),
6
- timestamp: Number(),
7
- reward: BigNumber.from(0),
8
- fees: BigNumber.from(0),
9
- transactions: new Uint8Array(),
10
- validators: new Uint8Array()
11
- }
@@ -1,2 +0,0 @@
1
- export default {
2
- }
@@ -1,4 +0,0 @@
1
- export default {
2
- up: Number(),
3
- down: Number()
4
- }
@@ -1,5 +0,0 @@
1
- export default {
2
- creator: String(),
3
- contract: new Uint8Array(),
4
- constructorParameters: Array()
5
- }
@@ -1,2 +0,0 @@
1
- export default {
2
- }
@@ -1,4 +0,0 @@
1
- export default {
2
- hash: String(),
3
- index: Number()
4
- }
@@ -1,7 +0,0 @@
1
- export default {
2
- name: String(),
3
- version: Number(),
4
- publisher: String(),
5
- entry: String(),
6
- files: new Uint8Array()
7
- }
@@ -1,8 +0,0 @@
1
- export default {
2
- timestamp: Number(),
3
- from: String(),
4
- to: String(),
5
- nonce: Number(),
6
- method: String(),
7
- params: Array()
8
- }
@@ -1,9 +0,0 @@
1
- export default {
2
- timestamp: Number(),
3
- from: String(),
4
- to: String(),
5
- nonce: Number(),
6
- method: String(),
7
- params: Array(),
8
- signature: String()
9
- }
@@ -1,6 +0,0 @@
1
- import { BigNumber } from "@leofcoin/utils"
2
-
3
- export default {
4
- address: String(),
5
- reward: BigNumber.from(0)
6
- }
package/src/types.d.ts DELETED
@@ -1 +0,0 @@
1
- declare type messageInput = Uint8Array | String | Object | ArrayBuffer
package/test.js DELETED
@@ -1,49 +0,0 @@
1
- import BlockMessage from "./exports/messages/block.js";
2
- import BWRequestMessage from "./exports/messages/bw-request.js";
3
- import { ContractMessage } from "./exports/index.js";
4
- import { BigNumber } from "@leofcoin/utils";
5
-
6
- console.log(globalThis.peernet);
7
- // globalThis.peernet.codecs
8
- const validators = [{
9
- address: 'address',
10
- reward: new BigNumber.from(0)
11
- }]
12
-
13
- const transactions = []
14
- for (let i = 0; i <= 1; i++) {
15
- transactions.push(
16
- {
17
- timestamp: new Date().getTime(),
18
- from: 'fromAddress',
19
- to: 'toAddress',
20
- nonce: 0,
21
- method: 'getAddress',
22
- params: [],
23
- signature: new Uint8Array(32)
24
- }
25
- )
26
- }
27
-
28
- const block = {
29
- index: 0,
30
- previousHash: 'hash',
31
- timestamp: new Date().getTime(),
32
- reward: new BigNumber.from('0'),
33
- fees: new BigNumber.from('0'),
34
- transactions,
35
- validators
36
- }
37
- const contractMessage = new ContractMessage({
38
- creator: 'aaa',
39
- contract: new Uint8Array(),
40
- constructorParameters: []
41
- })
42
-
43
- const message = new BlockMessage(block)
44
- console.time('message encoded')
45
- console.timeEnd('message encoded')
46
- console.time('normal encoded')
47
- console.timeEnd('normal encoded')
48
-
49
- const contract = new ContractMessage(contractMessage.encoded)
package/tsconfig.json DELETED
@@ -1,16 +0,0 @@
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
- },
12
- "include": [
13
- "./src/**/*"
14
- ],
15
- "exclude": ["./node_modules"]
16
- }