@leofcoin/messages 1.0.1 → 1.1.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/package.json CHANGED
@@ -1,17 +1,21 @@
1
1
  {
2
2
  "name": "@leofcoin/messages",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "",
5
5
  "main": "dist/messages.js",
6
- "module": "src/messages/js",
6
+ "module": "src/messages.js",
7
7
  "scripts": {
8
- "build": "rollup -c",
8
+ "build": "rollup -c && webpack",
9
9
  "test": "echo \"Error: no test specified\" && exit 1"
10
10
  },
11
11
  "keywords": [],
12
12
  "author": "",
13
13
  "license": "MIT",
14
+ "devDependencies": {
15
+ "webpack": "^5.73.0",
16
+ "webpack-cli": "^4.9.2"
17
+ },
14
18
  "dependencies": {
15
- "@leofcoin/codec-format-interface": "^1.0.1"
19
+ "@leofcoin/codec-format-interface": "^1.2.0"
16
20
  }
17
21
  }
@@ -1,14 +1,17 @@
1
- import protons from 'protons'
2
1
  import proto from './../protos/block.proto.js'
3
- import { FormatInterface as CodecFormat } from '@leofcoin/codec-format-interface'
2
+ import { FormatInterface } from '@leofcoin/codec-format-interface'
4
3
 
5
- export default class BlockMessage extends CodecFormat {
4
+ export default class BlockMessage extends FormatInterface {
6
5
  get keys() {
7
6
  return ['index', 'previousHash', 'timestamp', 'reward', 'fees', 'transactions', 'validators']
8
7
  }
9
8
 
9
+ get messageName() {
10
+ return 'BlockMessage'
11
+ }
12
+
10
13
  constructor(buffer) {
11
14
  const name = 'block-message'
12
- super(buffer, protons(proto).BlockMessage, {name})
15
+ super(buffer, proto, {name})
13
16
  }
14
17
  }
@@ -1,14 +1,17 @@
1
- import protons from 'protons'
2
- import proto from './../protos/bw-request.proto.js'
3
- import {FormatInterface as CodecFormat} from '@leofcoin/codec-format-interface'
1
+ import proto from './../protos/block.proto.js'
2
+ import { FormatInterface } from '@leofcoin/codec-format-interface'
4
3
 
5
- export default class BWRequestMessage extends CodecFormat {
4
+ export default class BWRequestMessage extends FormatInterface {
6
5
  get keys() {
7
6
  return []
8
7
  }
9
8
 
9
+ get messageName() {
10
+ return 'BWRequestMessage'
11
+ }
12
+
10
13
  constructor(buffer) {
11
14
  const name = 'bw-request-message'
12
- super(buffer, protons(proto).BWRequestMessage, {name})
15
+ super(buffer, proto, {name})
13
16
  }
14
17
  }
@@ -1,14 +1,17 @@
1
- import protons from 'protons'
2
- import proto from './../protos/bw.proto.js'
3
- import { FormatInterface as CodecFormat } from '@leofcoin/codec-format-interface'
1
+ import proto from './../protos/block.proto.js'
2
+ import { FormatInterface } from '@leofcoin/codec-format-interface'
4
3
 
5
- export default class BWMessage extends CodecFormat {
4
+ export default class BWMessage extends FormatInterface {
6
5
  get keys() {
7
6
  return ['up', 'down']
8
7
  }
9
8
 
9
+ get messageName() {
10
+ return 'BWMessage'
11
+ }
12
+
10
13
  constructor(buffer) {
11
14
  const name = 'bw-message'
12
- super(buffer, protons(proto).BWMessage, {name})
15
+ super(buffer, proto, {name})
13
16
  }
14
17
  }
@@ -1,13 +1,16 @@
1
- import protons from 'protons'
2
- import proto from './../protos/contract.proto.js'
3
- import { FormatInterface as CodecFormat } from '@leofcoin/codec-format-interface'
1
+ import proto from './../protos/block.proto.js'
2
+ import { FormatInterface } from '@leofcoin/codec-format-interface'
4
3
 
5
- export default class ContractMessage extends CodecFormat {
4
+ export default class ContractMessage extends FormatInterface {
6
5
  get keys() {
7
6
  return ['creator', 'contract', 'constructorParameters']
8
7
  }
9
8
 
9
+ get messageName() {
10
+ return 'ContractMessage'
11
+ }
12
+
10
13
  constructor(buffer) {
11
- super(buffer, protons(proto).ContractMessage, {name: 'contract-message'})
14
+ super(buffer, proto, {name: 'contract-message'})
12
15
  }
13
16
  }
@@ -1,14 +1,17 @@
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'
1
+ import proto from './../protos/block.proto.js'
2
+ import { FormatInterface } from '@leofcoin/codec-format-interface'
4
3
 
5
- export default class LastBlockRequestMessage extends CodecFormat {
4
+ export default class LastBlockRequestMessage extends FormatInterface {
6
5
  get keys() {
7
6
  return []
8
7
  }
9
8
 
9
+ get messageName() {
10
+ return 'LastBlockRequestMessage'
11
+ }
12
+
10
13
  constructor(buffer) {
11
14
  const name = 'last-block-request-message'
12
- super(buffer, protons(proto).LastBlockRequestMessage, {name})
15
+ super(buffer, proto, {name})
13
16
  }
14
17
  }
@@ -1,14 +1,17 @@
1
- import protons from 'protons'
2
- import proto from './../protos/last-block.proto.js'
3
- import { FormatInterface as CodecFormat } from '@leofcoin/codec-format-interface'
1
+ import proto from './../protos/block.proto.js'
2
+ import { FormatInterface } from '@leofcoin/codec-format-interface'
4
3
 
5
- export default class LastBlockMessage extends CodecFormat {
4
+ export default class LastBlockMessage extends FormatInterface {
6
5
  get keys() {
7
6
  return ['hash', 'index']
8
7
  }
9
8
 
9
+ get messageName() {
10
+ return 'LastBlockMessage'
11
+ }
12
+
10
13
  constructor(buffer) {
11
14
  const name = 'last-block-message'
12
- super(buffer, protons(proto).LastBlockMessage, {name})
15
+ super(buffer, proto, {name})
13
16
  }
14
17
  }
@@ -1,14 +1,17 @@
1
- import protons from 'protons'
2
- import proto from './../protos/transaction.proto.js'
3
- import { FormatInterface as CodecFormat } from '@leofcoin/codec-format-interface'
1
+ import proto from './../protos/block.proto.js'
2
+ import { FormatInterface } from '@leofcoin/codec-format-interface'
4
3
 
5
- export default class TransactionMessage extends CodecFormat {
4
+ export default class TransactionMessage extends FormatInterface {
6
5
  get keys() {
7
6
  return ['timestamp', 'from', 'to', 'nonce', 'method', 'params']
8
7
  }
9
8
 
9
+ get messageName() {
10
+ return 'TransactionMessage'
11
+ }
12
+
10
13
  constructor(buffer) {
11
14
  const name = 'transaction-message'
12
- super(buffer, protons(proto).TransactionMessage, {name})
15
+ super(buffer, proto, {name})
13
16
  }
14
17
  }
package/src/messages.js CHANGED
@@ -1,13 +1,5 @@
1
- import ContractMessage from './messages/contract'
2
- import TransactionMessage from './messages/transaction'
3
- import BlockMessage from './messages/block'
4
- import BWMessage from './messages/bw'
5
- import BWRequestMessage from './messages/bw-request'
6
-
7
- export default {
8
- ContractMessage,
9
- TransactionMessage,
10
- BlockMessage,
11
- BWMessage,
12
- BWRequestMessage
13
- }
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,22 @@
1
+ const path = require('path');
2
+ const webpack = require('webpack');
3
+ module.exports = [{
4
+ mode: 'production',
5
+ entry: {
6
+ messages: './src/messages.js'
7
+ },
8
+ optimization: {
9
+ minimize: false
10
+ },
11
+ experiments: {
12
+ outputModule: true
13
+ },
14
+ output: {
15
+ library: {
16
+ type: 'module'
17
+ },
18
+ chunkFilename: '[name].esm',
19
+ filename: '[name].esm',
20
+ path: path.resolve(__dirname, 'dist'),
21
+ }
22
+ }];