diff --git a/Makefile b/Makefile index a509456a..afaeb2cb 100644 --- a/Makefile +++ b/Makefile @@ -2,19 +2,20 @@ # gitlab options PROTO_REPO=pkg -PROTO_DIST_DIR=proto +PROTO_DIST_DIR=types PROTO_SRC_DIR=types GITLAB_PATH=ConsenSys/client/fr/core-stack -PROTO_TAG=v0.6.1 +PROTO_TAG=v0.7.0 protobuf: ## Generate protobuf stubs @docker-compose -f scripts/docker-compose.yml up + @sh scripts/update-permissions.sh import-proto: - rm -rf $(PROTO_REPO) $(PROTO_DIST_DIR) - git clone -b $(PROTO_TAG) --single-branch git@gitlab.com:$(GITLAB_PATH)/$(PROTO_REPO).git; - mkdir -p $(PROTO_DIST_DIR); - mv $(PROTO_REPO)/$(PROTO_SRC_DIR)/* $(PROTO_DIST_DIR); - rm -rf $(PROTO_REPO)/; - rm $(PROTO_DIST_DIR)/*/*.go; + @rm -rf $(PROTO_REPO) $(PROTO_DIST_DIR) + @git clone -b $(PROTO_TAG) --single-branch git@gitlab.com:$(GITLAB_PATH)/$(PROTO_REPO).git; + @mkdir -p $(PROTO_DIST_DIR); + @mv $(PROTO_REPO)/$(PROTO_SRC_DIR)/* $(PROTO_DIST_DIR); + @rm -rf $(PROTO_REPO)/; + @rm $(PROTO_DIST_DIR)/*/*.go; diff --git a/package-lock.json b/package-lock.json index da89d08c..e8f40616 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { - "name": "core-stack-sdk", - "version": "0.3.0", + "name": "corestack-sdk", + "version": "0.3.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1889,6 +1889,11 @@ "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", "dev": true }, + "bimap": { + "version": "0.0.15", + "resolved": "https://nexus.solutions.consensys-uk.net/repository/komgo-npm-group/bimap/-/bimap-0.0.15.tgz", + "integrity": "sha1-V6txrJ6GlVywoOtAbuW7JzMteHk=" + }, "binary": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz", @@ -2469,8 +2474,7 @@ "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", - "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "optional": true + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" }, "constants-browserify": { "version": "1.0.0", @@ -3931,8 +3935,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -3953,14 +3956,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3975,20 +3976,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -4105,8 +4103,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -4118,7 +4115,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -4133,7 +4129,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -4141,14 +4136,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -4167,7 +4160,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -4248,8 +4240,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -4261,7 +4252,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -4347,8 +4337,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -4384,7 +4373,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -4404,7 +4392,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -4448,14 +4435,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -4500,8 +4485,7 @@ "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "optional": true + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" }, "is-fullwidth-code-point": { "version": "1.0.0", @@ -4527,7 +4511,6 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "optional": true, "requires": { "ansi-regex": "^2.0.0" } diff --git a/package.json b/package.json index f543dd6e..52930fa7 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.3.1", "description": "CoreStack SDK", "main": "./lib/index.js", - "types": "./types/index.d.ts", + "types": "./typedefinitions/index.d.ts", "scripts": { "clean": "rimraf ./coverage ./lib", "test": "cross-env NODE_ENV=test jest", @@ -56,6 +56,7 @@ "webpack-node-externals": "~1.7.2" }, "dependencies": { + "bimap": "0.0.15", "google-protobuf": "~3.8.0", "kafka-node": "~4.1.3", "uuid": "~3.3.2", diff --git a/scripts/update-permissions.sh b/scripts/update-permissions.sh new file mode 100644 index 00000000..55ea7aa2 --- /dev/null +++ b/scripts/update-permissions.sh @@ -0,0 +1,7 @@ + for file in `find . -name *_pb.js -not -path "*/node_modules/*"`; do + echo "# $file" + sudo chown -R $USER $file + sudo chmod 775 $file + sudo chown -R $USER $(dirname "$file") + sudo chmod 775 $(dirname "$file") + done \ No newline at end of file diff --git a/src/broker/types/abi/abi_pb.js b/src/broker/types/abi/abi_pb.js old mode 100644 new mode 100755 diff --git a/src/broker/types/args/call_pb.js b/src/broker/types/args/call_pb.js old mode 100644 new mode 100755 diff --git a/src/broker/types/args/private_pb.js b/src/broker/types/args/private_pb.js old mode 100644 new mode 100755 diff --git a/src/broker/types/chain/__tests__/protocol.test.js b/src/broker/types/chain/__tests__/protocol.test.js index 2f683b9a..05bd0f90 100644 --- a/src/broker/types/chain/__tests__/protocol.test.js +++ b/src/broker/types/chain/__tests__/protocol.test.js @@ -1,5 +1,5 @@ -import { marshallProtocol, unmarshallProtocol } from '../protocol' import envelope_pb from '../../envelope/envelope_pb' +import { marshallProtocol, ProtocolType, unmarshallProtocol } from '../protocol' let envelope @@ -13,7 +13,7 @@ describe("# marshallTransaction ", () => { expect(() => { marshallProtocol(envelope, testMsg) - }).toThrow(); + }).toThrow('Protocol message has invalid format'); }) test("set invalid object format", () => { @@ -21,29 +21,45 @@ describe("# marshallTransaction ", () => { expect(() => { marshallProtocol(envelope, testMsg) - }).toThrow(); + }).toThrow('Protocol message do not expect "error" field'); }) + + test("invalid protocol type", () => { + const testMsg = { + type: 'invalid.protocol' + } + + expect(() => { + marshallProtocol(envelope, testMsg) + }).toThrow('Cannot convert protocol type "invalid.protocol"'); + }) + + test("should unmarshall unknown protocol type", () => { + const pbMessage = { + type: 123, + extraMap: {} + } + + const receipt = unmarshallProtocol(pbMessage) + const expected = { + type: undefined, + extra: {} + } + expect(receipt).toEqual(expected) + }) + test("set object", () => { const testMsg = { - name: 'test', - tag: 'test', + type: ProtocolType.EthereumConstantinople, extra: { extra1: 'testExtra1', extra2: 'testExtra2' } } + marshallProtocol(envelope, testMsg) const receipt = unmarshallProtocol(envelope.getProtocol().toObject()) - const expected = { - name: 'test', - tag: 'test', - extraMap: { - extra1: 'testExtra1', - extra2: 'testExtra2' - } - } - expect(receipt).toEqual(expected) - + expect(receipt).toEqual(testMsg) }) - + }) \ No newline at end of file diff --git a/src/broker/types/chain/chain_pb.js b/src/broker/types/chain/chain_pb.js old mode 100644 new mode 100755 diff --git a/src/broker/types/chain/protocol.js b/src/broker/types/chain/protocol.js index a0fc892c..9933a467 100644 --- a/src/broker/types/chain/protocol.js +++ b/src/broker/types/chain/protocol.js @@ -1,5 +1,19 @@ import protocol_pb from './protocol_pb' -import { capitalize, arrayToObject } from '../../utils/formatters'; +import { arrayToObject } from '../../utils/formatters' +import BiMap from 'bimap' + +export const ProtocolType = { + EthereumConstantinople: 'ethereum.constantinople', + QuorumConstellation: 'quorum.constellation', + QuorumTessera: 'quorum.tessera', + PantheonOrion: 'pantheon.orion', +} + +const bimap = new BiMap() +bimap.push(ProtocolType.EthereumConstantinople, protocol_pb.ProtocolType.ETHEREUM_CONSTANTINOPLE) +bimap.push(ProtocolType.QuorumConstellation, protocol_pb.ProtocolType.QUORUM_CONSTELLATION) +bimap.push(ProtocolType.QuorumTessera, protocol_pb.ProtocolType.QUORUM_TESSERA) +bimap.push(ProtocolType.PantheonOrion, protocol_pb.ProtocolType.PANTHEON_ORION) export const marshallProtocol = (envelope, msg) => { let protocol = envelope.getProtocol() @@ -10,9 +24,8 @@ export const marshallProtocol = (envelope, msg) => { case 'object': Object.entries(msg).forEach(([key, value]) => { switch(key) { - case 'name': - case 'tag': - protocol[`set${capitalize(key)}`](value) + case 'type': + protocol.setType(toProtobufProtocolType(value)) break; case 'extra': const extra = protocol.getExtraMap() @@ -21,19 +34,35 @@ export const marshallProtocol = (envelope, msg) => { }) break; default: - throw new Error(`Protocol message do not expect a "${key}" field`) + throw new Error(`Protocol message do not expect "${key}" field`) } }) break; default: - throw new Error('Protocol message not in a valid format') + throw new Error('Protocol message has invalid format') } envelope.setProtocol(protocol) } export const unmarshallProtocol = protocol => { - if (protocol['extraMap'].length > 0) { - protocol['extraMap'] = arrayToObject(protocol['extraMap']) + const result = {} + if (protocol.extraMap.length > 0) { + result.extra = arrayToObject(protocol.extraMap) + } else { + result.extra = {} } - return protocol -} \ No newline at end of file + result.type = fromProtobufProtocolType(protocol.type) + return result +} + +function toProtobufProtocolType(protocolType) { + const pbProtoType = bimap.key(protocolType) + if (pbProtoType === undefined) { + throw new Error(`Cannot convert protocol type "${protocolType}"`) + } + return pbProtoType +} + +function fromProtobufProtocolType(pbProtoType) { + return bimap.val(pbProtoType) +} diff --git a/src/broker/types/chain/protocol_pb.js b/src/broker/types/chain/protocol_pb.js old mode 100644 new mode 100755 index 93b8bb73..5d880d80 --- a/src/broker/types/chain/protocol_pb.js +++ b/src/broker/types/chain/protocol_pb.js @@ -12,6 +12,7 @@ var goog = jspb; var global = Function('return this')(); goog.exportSymbol('proto.chain.Protocol', null, global); +goog.exportSymbol('proto.chain.ProtocolType', null, global); /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -65,8 +66,7 @@ proto.chain.Protocol.prototype.toObject = function(opt_includeInstance) { */ proto.chain.Protocol.toObject = function(includeInstance, msg) { var f, obj = { - name: jspb.Message.getFieldWithDefault(msg, 1, ""), - tag: jspb.Message.getFieldWithDefault(msg, 2, ""), + type: jspb.Message.getFieldWithDefault(msg, 1, 0), extraMap: (f = msg.getExtraMap()) ? f.toObject(includeInstance, undefined) : [] }; @@ -105,12 +105,8 @@ proto.chain.Protocol.deserializeBinaryFromReader = function(msg, reader) { var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setName(value); - break; - case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setTag(value); + var value = /** @type {!proto.chain.ProtocolType} */ (reader.readEnum()); + msg.setType(value); break; case 3: var value = msg.getExtraMap(); @@ -147,20 +143,13 @@ proto.chain.Protocol.prototype.serializeBinary = function() { */ proto.chain.Protocol.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getName(); - if (f.length > 0) { - writer.writeString( + f = message.getType(); + if (f !== 0.0) { + writer.writeEnum( 1, f ); } - f = message.getTag(); - if (f.length > 0) { - writer.writeString( - 2, - f - ); - } f = message.getExtraMap(true); if (f && f.getLength() > 0) { f.serializeBinary(3, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); @@ -169,32 +158,17 @@ proto.chain.Protocol.serializeBinaryToWriter = function(message, writer) { /** - * optional string name = 1; - * @return {string} - */ -proto.chain.Protocol.prototype.getName = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** @param {string} value */ -proto.chain.Protocol.prototype.setName = function(value) { - jspb.Message.setProto3StringField(this, 1, value); -}; - - -/** - * optional string tag = 2; - * @return {string} + * optional ProtocolType type = 1; + * @return {!proto.chain.ProtocolType} */ -proto.chain.Protocol.prototype.getTag = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +proto.chain.Protocol.prototype.getType = function() { + return /** @type {!proto.chain.ProtocolType} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); }; -/** @param {string} value */ -proto.chain.Protocol.prototype.setTag = function(value) { - jspb.Message.setProto3StringField(this, 2, value); +/** @param {!proto.chain.ProtocolType} value */ +proto.chain.Protocol.prototype.setType = function(value) { + jspb.Message.setProto3EnumField(this, 1, value); }; @@ -219,4 +193,14 @@ proto.chain.Protocol.prototype.clearExtraMap = function() { }; +/** + * @enum {number} + */ +proto.chain.ProtocolType = { + ETHEREUM_CONSTANTINOPLE: 0, + QUORUM_CONSTELLATION: 1, + QUORUM_TESSERA: 2, + PANTHEON_ORION: 3 +}; + goog.object.extend(exports, proto.chain); diff --git a/src/broker/types/common/account_instance_pb.js b/src/broker/types/common/account_instance_pb.js old mode 100644 new mode 100755 diff --git a/src/broker/types/common/error_pb.js b/src/broker/types/common/error_pb.js old mode 100644 new mode 100755 diff --git a/src/broker/types/contract-registry/registry_pb.js b/src/broker/types/contract-registry/registry_pb.js index 396826d4..6531f6e5 100755 --- a/src/broker/types/contract-registry/registry_pb.js +++ b/src/broker/types/contract-registry/registry_pb.js @@ -13,8 +13,8 @@ var global = Function('return this')(); var types_abi_abi_pb = require('../../types/abi/abi_pb.js'); goog.object.extend(proto, types_abi_abi_pb); -var types_common_account_pb = require('../../types/common/account_pb.js'); -goog.object.extend(proto, types_common_account_pb); +var types_common_account_instance_pb = require('../../types/common/account_instance_pb.js'); +goog.object.extend(proto, types_common_account_instance_pb); goog.exportSymbol('proto.contractregistry.AddressUpdateRequest', null, global); goog.exportSymbol('proto.contractregistry.AddressUpdateResponse', null, global); goog.exportSymbol('proto.contractregistry.GetContractABIResponse', null, global); @@ -1160,7 +1160,7 @@ proto.contractregistry.GetMethodsBySelectorRequest.prototype.toObject = function proto.contractregistry.GetMethodsBySelectorRequest.toObject = function(includeInstance, msg) { var f, obj = { selector: msg.getSelector_asB64(), - accountinstance: (f = msg.getAccountinstance()) && types_common_account_pb.AccountInstance.toObject(includeInstance, f) + accountinstance: (f = msg.getAccountinstance()) && types_common_account_instance_pb.AccountInstance.toObject(includeInstance, f) }; if (includeInstance) { @@ -1202,8 +1202,8 @@ proto.contractregistry.GetMethodsBySelectorRequest.deserializeBinaryFromReader = msg.setSelector(value); break; case 2: - var value = new types_common_account_pb.AccountInstance; - reader.readMessage(value,types_common_account_pb.AccountInstance.deserializeBinaryFromReader); + var value = new types_common_account_instance_pb.AccountInstance; + reader.readMessage(value,types_common_account_instance_pb.AccountInstance.deserializeBinaryFromReader); msg.setAccountinstance(value); break; default: @@ -1247,7 +1247,7 @@ proto.contractregistry.GetMethodsBySelectorRequest.serializeBinaryToWriter = fun writer.writeMessage( 2, f, - types_common_account_pb.AccountInstance.serializeBinaryToWriter + types_common_account_instance_pb.AccountInstance.serializeBinaryToWriter ); } }; @@ -1298,7 +1298,7 @@ proto.contractregistry.GetMethodsBySelectorRequest.prototype.setSelector = funct */ proto.contractregistry.GetMethodsBySelectorRequest.prototype.getAccountinstance = function() { return /** @type{?proto.common.AccountInstance} */ ( - jspb.Message.getWrapperField(this, types_common_account_pb.AccountInstance, 2)); + jspb.Message.getWrapperField(this, types_common_account_instance_pb.AccountInstance, 2)); }; @@ -1584,7 +1584,7 @@ proto.contractregistry.GetEventsBySigHashRequest.prototype.toObject = function(o proto.contractregistry.GetEventsBySigHashRequest.toObject = function(includeInstance, msg) { var f, obj = { sighash: msg.getSighash_asB64(), - accountinstance: (f = msg.getAccountinstance()) && types_common_account_pb.AccountInstance.toObject(includeInstance, f), + accountinstance: (f = msg.getAccountinstance()) && types_common_account_instance_pb.AccountInstance.toObject(includeInstance, f), indexedinputcount: jspb.Message.getFieldWithDefault(msg, 3, 0) }; @@ -1627,8 +1627,8 @@ proto.contractregistry.GetEventsBySigHashRequest.deserializeBinaryFromReader = f msg.setSighash(value); break; case 2: - var value = new types_common_account_pb.AccountInstance; - reader.readMessage(value,types_common_account_pb.AccountInstance.deserializeBinaryFromReader); + var value = new types_common_account_instance_pb.AccountInstance; + reader.readMessage(value,types_common_account_instance_pb.AccountInstance.deserializeBinaryFromReader); msg.setAccountinstance(value); break; case 3: @@ -1676,7 +1676,7 @@ proto.contractregistry.GetEventsBySigHashRequest.serializeBinaryToWriter = funct writer.writeMessage( 2, f, - types_common_account_pb.AccountInstance.serializeBinaryToWriter + types_common_account_instance_pb.AccountInstance.serializeBinaryToWriter ); } f = message.getIndexedinputcount(); @@ -1734,7 +1734,7 @@ proto.contractregistry.GetEventsBySigHashRequest.prototype.setSighash = function */ proto.contractregistry.GetEventsBySigHashRequest.prototype.getAccountinstance = function() { return /** @type{?proto.common.AccountInstance} */ ( - jspb.Message.getWrapperField(this, types_common_account_pb.AccountInstance, 2)); + jspb.Message.getWrapperField(this, types_common_account_instance_pb.AccountInstance, 2)); }; @@ -2034,7 +2034,7 @@ proto.contractregistry.AddressUpdateRequest.prototype.toObject = function(opt_in */ proto.contractregistry.AddressUpdateRequest.toObject = function(includeInstance, msg) { var f, obj = { - accountinstance: (f = msg.getAccountinstance()) && types_common_account_pb.AccountInstance.toObject(includeInstance, f) + accountinstance: (f = msg.getAccountinstance()) && types_common_account_instance_pb.AccountInstance.toObject(includeInstance, f) }; if (includeInstance) { @@ -2072,8 +2072,8 @@ proto.contractregistry.AddressUpdateRequest.deserializeBinaryFromReader = functi var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new types_common_account_pb.AccountInstance; - reader.readMessage(value,types_common_account_pb.AccountInstance.deserializeBinaryFromReader); + var value = new types_common_account_instance_pb.AccountInstance; + reader.readMessage(value,types_common_account_instance_pb.AccountInstance.deserializeBinaryFromReader); msg.setAccountinstance(value); break; default: @@ -2110,7 +2110,7 @@ proto.contractregistry.AddressUpdateRequest.serializeBinaryToWriter = function(m writer.writeMessage( 1, f, - types_common_account_pb.AccountInstance.serializeBinaryToWriter + types_common_account_instance_pb.AccountInstance.serializeBinaryToWriter ); } }; @@ -2122,7 +2122,7 @@ proto.contractregistry.AddressUpdateRequest.serializeBinaryToWriter = function(m */ proto.contractregistry.AddressUpdateRequest.prototype.getAccountinstance = function() { return /** @type{?proto.common.AccountInstance} */ ( - jspb.Message.getWrapperField(this, types_common_account_pb.AccountInstance, 1)); + jspb.Message.getWrapperField(this, types_common_account_instance_pb.AccountInstance, 1)); }; diff --git a/src/broker/types/envelope-store/store_pb.js b/src/broker/types/envelope-store/store_pb.js old mode 100644 new mode 100755 index 8c053839..2802d000 --- a/src/broker/types/envelope-store/store_pb.js +++ b/src/broker/types/envelope-store/store_pb.js @@ -13,8 +13,8 @@ var global = Function('return this')(); var types_envelope_envelope_pb = require('../../types/envelope/envelope_pb.js'); goog.object.extend(proto, types_envelope_envelope_pb); -var types_common_error_pb = require('../../types/common/error_pb.js'); -goog.object.extend(proto, types_common_error_pb); +var types_error_error_pb = require('../../types/error/error_pb.js'); +goog.object.extend(proto, types_error_error_pb); var google_protobuf_timestamp_pb = require('google-protobuf/google/protobuf/timestamp_pb.js'); goog.object.extend(proto, google_protobuf_timestamp_pb); goog.exportSymbol('proto.envelopestore.IDRequest', null, global); @@ -353,7 +353,7 @@ proto.envelopestore.StoreResponse.toObject = function(includeInstance, msg) { status: jspb.Message.getFieldWithDefault(msg, 1, ""), lastUpdated: (f = msg.getLastUpdated()) && google_protobuf_timestamp_pb.Timestamp.toObject(includeInstance, f), envelope: (f = msg.getEnvelope()) && types_envelope_envelope_pb.Envelope.toObject(includeInstance, f), - err: (f = msg.getErr()) && types_common_error_pb.Error.toObject(includeInstance, f) + err: (f = msg.getErr()) && types_error_error_pb.Error.toObject(includeInstance, f) }; if (includeInstance) { @@ -405,8 +405,8 @@ proto.envelopestore.StoreResponse.deserializeBinaryFromReader = function(msg, re msg.setEnvelope(value); break; case 4: - var value = new types_common_error_pb.Error; - reader.readMessage(value,types_common_error_pb.Error.deserializeBinaryFromReader); + var value = new types_error_error_pb.Error; + reader.readMessage(value,types_error_error_pb.Error.deserializeBinaryFromReader); msg.setErr(value); break; default: @@ -466,7 +466,7 @@ proto.envelopestore.StoreResponse.serializeBinaryToWriter = function(message, wr writer.writeMessage( 4, f, - types_common_error_pb.Error.serializeBinaryToWriter + types_error_error_pb.Error.serializeBinaryToWriter ); } }; @@ -554,16 +554,16 @@ proto.envelopestore.StoreResponse.prototype.hasEnvelope = function() { /** - * optional common.Error err = 4; - * @return {?proto.common.Error} + * optional error.Error err = 4; + * @return {?proto.error.Error} */ proto.envelopestore.StoreResponse.prototype.getErr = function() { - return /** @type{?proto.common.Error} */ ( - jspb.Message.getWrapperField(this, types_common_error_pb.Error, 4)); + return /** @type{?proto.error.Error} */ ( + jspb.Message.getWrapperField(this, types_error_error_pb.Error, 4)); }; -/** @param {?proto.common.Error|undefined} value */ +/** @param {?proto.error.Error|undefined} value */ proto.envelopestore.StoreResponse.prototype.setErr = function(value) { jspb.Message.setWrapperField(this, 4, value); }; @@ -1189,7 +1189,7 @@ proto.envelopestore.LoadPendingResponse.toObject = function(includeInstance, msg var f, obj = { envelopesList: jspb.Message.toObjectList(msg.getEnvelopesList(), types_envelope_envelope_pb.Envelope.toObject, includeInstance), - err: (f = msg.getErr()) && types_common_error_pb.Error.toObject(includeInstance, f) + err: (f = msg.getErr()) && types_error_error_pb.Error.toObject(includeInstance, f) }; if (includeInstance) { @@ -1232,8 +1232,8 @@ proto.envelopestore.LoadPendingResponse.deserializeBinaryFromReader = function(m msg.addEnvelopes(value); break; case 2: - var value = new types_common_error_pb.Error; - reader.readMessage(value,types_common_error_pb.Error.deserializeBinaryFromReader); + var value = new types_error_error_pb.Error; + reader.readMessage(value,types_error_error_pb.Error.deserializeBinaryFromReader); msg.setErr(value); break; default: @@ -1278,7 +1278,7 @@ proto.envelopestore.LoadPendingResponse.serializeBinaryToWriter = function(messa writer.writeMessage( 2, f, - types_common_error_pb.Error.serializeBinaryToWriter + types_error_error_pb.Error.serializeBinaryToWriter ); } }; @@ -1319,16 +1319,16 @@ proto.envelopestore.LoadPendingResponse.prototype.clearEnvelopesList = function( /** - * optional common.Error err = 2; - * @return {?proto.common.Error} + * optional error.Error err = 2; + * @return {?proto.error.Error} */ proto.envelopestore.LoadPendingResponse.prototype.getErr = function() { - return /** @type{?proto.common.Error} */ ( - jspb.Message.getWrapperField(this, types_common_error_pb.Error, 2)); + return /** @type{?proto.error.Error} */ ( + jspb.Message.getWrapperField(this, types_error_error_pb.Error, 2)); }; -/** @param {?proto.common.Error|undefined} value */ +/** @param {?proto.error.Error|undefined} value */ proto.envelopestore.LoadPendingResponse.prototype.setErr = function(value) { jspb.Message.setWrapperField(this, 2, value); }; diff --git a/src/broker/types/envelope/__tests__/enveloppe.test.js b/src/broker/types/envelope/__tests__/enveloppe.test.js index 471a7dd8..d0bb8b56 100644 --- a/src/broker/types/envelope/__tests__/enveloppe.test.js +++ b/src/broker/types/envelope/__tests__/enveloppe.test.js @@ -1,5 +1,7 @@ -import { marshallEnvelope, marshallMetadata, unmarshallEnvelope } from '../envelope' +import { ProtocolType } from '../../../..' +import protocol_pb from '../../chain/protocol_pb' import { marshallReceipt } from '../../ethereum/receipt' +import { marshallEnvelope, marshallMetadata, unmarshallEnvelope } from '../envelope' import envelope_pb from '../envelope_pb' let envelope @@ -26,7 +28,7 @@ describe("# marshallEnvelope ", () => { test("set invalid object format of other marshaller methods", () => { const testMsg = {chainId: {error: false}} try { - marshallEnvelope(testMsg) + marshallEnvelope(testMsg) } catch(e) { expect(e.message).toBe('marshallChain: "[object Object]" is not a number') } @@ -37,7 +39,7 @@ describe("# marshallEnvelope ", () => { const testMsg = { chainId: '3', protocol: { - name: 'pantheon', + type: ProtocolType.PantheonOrion, extra: { test: 'test' } @@ -67,8 +69,7 @@ describe("# marshallEnvelope ", () => { chain: { id: '3' }, protocol: { extraMap: {test: 'test'}, - name: 'pantheon', - tag: '', + type: protocol_pb.ProtocolType.PANTHEON_ORION }, from: '0xaf84242d70ae9d268e2be3616ed497ba28a7b62c', tx: { diff --git a/src/broker/types/envelope/envelope_pb.js b/src/broker/types/envelope/envelope_pb.js old mode 100644 new mode 100755 index 9316b144..ffde2810 --- a/src/broker/types/envelope/envelope_pb.js +++ b/src/broker/types/envelope/envelope_pb.js @@ -15,8 +15,6 @@ var types_chain_chain_pb = require('../../types/chain/chain_pb.js'); goog.object.extend(proto, types_chain_chain_pb); var types_chain_protocol_pb = require('../../types/chain/protocol_pb.js'); goog.object.extend(proto, types_chain_protocol_pb); -var types_common_error_pb = require('../../types/common/error_pb.js'); -goog.object.extend(proto, types_common_error_pb); var types_ethereum_base_pb = require('../../types/ethereum/base_pb.js'); goog.object.extend(proto, types_ethereum_base_pb); var types_ethereum_transaction_pb = require('../../types/ethereum/transaction_pb.js'); @@ -27,6 +25,8 @@ var types_args_private_pb = require('../../types/args/private_pb.js'); goog.object.extend(proto, types_args_private_pb); var types_args_call_pb = require('../../types/args/call_pb.js'); goog.object.extend(proto, types_args_call_pb); +var types_error_error_pb = require('../../types/error/error_pb.js'); +goog.object.extend(proto, types_error_error_pb); goog.exportSymbol('proto.envelope.Args', null, global); goog.exportSymbol('proto.envelope.Envelope', null, global); goog.exportSymbol('proto.envelope.Metadata', null, global); @@ -491,7 +491,7 @@ proto.envelope.Envelope.toObject = function(includeInstance, msg) { tx: (f = msg.getTx()) && types_ethereum_transaction_pb.Transaction.toObject(includeInstance, f), receipt: (f = msg.getReceipt()) && types_ethereum_receipt_pb.Receipt.toObject(includeInstance, f), errorsList: jspb.Message.toObjectList(msg.getErrorsList(), - types_common_error_pb.Error.toObject, includeInstance), + types_error_error_pb.Error.toObject, includeInstance), args: (f = msg.getArgs()) && proto.envelope.Args.toObject(includeInstance, f), metadata: (f = msg.getMetadata()) && proto.envelope.Metadata.toObject(includeInstance, f) }; @@ -556,8 +556,8 @@ proto.envelope.Envelope.deserializeBinaryFromReader = function(msg, reader) { msg.setReceipt(value); break; case 6: - var value = new types_common_error_pb.Error; - reader.readMessage(value,types_common_error_pb.Error.deserializeBinaryFromReader); + var value = new types_error_error_pb.Error; + reader.readMessage(value,types_error_error_pb.Error.deserializeBinaryFromReader); msg.addErrors(value); break; case 7: @@ -644,7 +644,7 @@ proto.envelope.Envelope.serializeBinaryToWriter = function(message, writer) { writer.writeRepeatedMessage( 6, f, - types_common_error_pb.Error.serializeBinaryToWriter + types_error_error_pb.Error.serializeBinaryToWriter ); } f = message.getArgs(); @@ -832,28 +832,28 @@ proto.envelope.Envelope.prototype.hasReceipt = function() { /** - * repeated common.Error errors = 6; - * @return {!Array} + * repeated error.Error errors = 6; + * @return {!Array} */ proto.envelope.Envelope.prototype.getErrorsList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, types_common_error_pb.Error, 6)); + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, types_error_error_pb.Error, 6)); }; -/** @param {!Array} value */ +/** @param {!Array} value */ proto.envelope.Envelope.prototype.setErrorsList = function(value) { jspb.Message.setRepeatedWrapperField(this, 6, value); }; /** - * @param {!proto.common.Error=} opt_value + * @param {!proto.error.Error=} opt_value * @param {number=} opt_index - * @return {!proto.common.Error} + * @return {!proto.error.Error} */ proto.envelope.Envelope.prototype.addErrors = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 6, opt_value, proto.common.Error, opt_index); + return jspb.Message.addToRepeatedWrapperField(this, 6, opt_value, proto.error.Error, opt_index); }; diff --git a/src/broker/types/error/error_pb.js b/src/broker/types/error/error_pb.js new file mode 100755 index 00000000..d3abe187 --- /dev/null +++ b/src/broker/types/error/error_pb.js @@ -0,0 +1,249 @@ +/** + * @fileoverview + * @enhanceable + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = Function('return this')(); + +goog.exportSymbol('proto.error.Error', null, global); +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.error.Error = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.error.Error, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.error.Error.displayName = 'proto.error.Error'; +} + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.error.Error.prototype.toObject = function(opt_includeInstance) { + return proto.error.Error.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.error.Error} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.error.Error.toObject = function(includeInstance, msg) { + var f, obj = { + message: jspb.Message.getFieldWithDefault(msg, 1, ""), + code: jspb.Message.getFieldWithDefault(msg, 2, 0), + component: jspb.Message.getFieldWithDefault(msg, 3, ""), + extraMap: (f = msg.getExtraMap()) ? f.toObject(includeInstance, undefined) : [] + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.error.Error} + */ +proto.error.Error.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.error.Error; + return proto.error.Error.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.error.Error} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.error.Error} + */ +proto.error.Error.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setMessage(value); + break; + case 2: + var value = /** @type {number} */ (reader.readUint64()); + msg.setCode(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setComponent(value); + break; + case 4: + var value = msg.getExtraMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, ""); + }); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.error.Error.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.error.Error.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.error.Error} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.error.Error.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getMessage(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getCode(); + if (f !== 0) { + writer.writeUint64( + 2, + f + ); + } + f = message.getComponent(); + if (f.length > 0) { + writer.writeString( + 3, + f + ); + } + f = message.getExtraMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(4, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } +}; + + +/** + * optional string message = 1; + * @return {string} + */ +proto.error.Error.prototype.getMessage = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** @param {string} value */ +proto.error.Error.prototype.setMessage = function(value) { + jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional uint64 code = 2; + * @return {number} + */ +proto.error.Error.prototype.getCode = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** @param {number} value */ +proto.error.Error.prototype.setCode = function(value) { + jspb.Message.setProto3IntField(this, 2, value); +}; + + +/** + * optional string component = 3; + * @return {string} + */ +proto.error.Error.prototype.getComponent = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** @param {string} value */ +proto.error.Error.prototype.setComponent = function(value) { + jspb.Message.setProto3StringField(this, 3, value); +}; + + +/** + * map extra = 4; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.error.Error.prototype.getExtraMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 4, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + */ +proto.error.Error.prototype.clearExtraMap = function() { + this.getExtraMap().clear(); +}; + + +goog.object.extend(exports, proto.error); diff --git a/src/broker/types/ethereum/base_pb.js b/src/broker/types/ethereum/base_pb.js old mode 100644 new mode 100755 diff --git a/src/broker/types/ethereum/receipt_pb.js b/src/broker/types/ethereum/receipt_pb.js old mode 100644 new mode 100755 diff --git a/src/broker/types/ethereum/transaction_pb.js b/src/broker/types/ethereum/transaction_pb.js old mode 100644 new mode 100755 diff --git a/src/index.js b/src/index.js index 27444b0a..5afd7d88 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,8 @@ import CoreStackBroker from './broker' import { CoreStackWeb3 } from './web3' +export { ProtocolType } from './broker/types/chain/protocol' + /** * [CoreStack with broker and web3] * @type {class} @@ -35,4 +37,4 @@ export default class CoreStack { this.web3Client = new CoreStackWeb3(endpoints, options); return this.web3Client } -} \ No newline at end of file +} diff --git a/types/index.d.ts b/typedefinitions/index.d.ts similarity index 95% rename from types/index.d.ts rename to typedefinitions/index.d.ts index c5fa77b7..8809c5f1 100644 --- a/types/index.d.ts +++ b/typedefinitions/index.d.ts @@ -2,9 +2,7 @@ import { Web3ModuleOptions } from 'web3-core' import Web3 from 'web3' import { EventEmitter } from 'events'; import { - KafkaClient, KafkaClientOptions, - ProduceRequest, Message } from 'kafka-node' @@ -95,10 +93,17 @@ export interface CoreStackRequest { } export interface Protocol { - name: string - tag?: string + type: ProtocolType extra?: object } + +export declare enum ProtocolType { + EthereumConstantinople, + QuorumConstellation, + QuorumTessera, + PantheonOrion, +} + export interface Metadata { id: string extra?: object diff --git a/proto/abi/abi.proto b/types/abi/abi.proto similarity index 100% rename from proto/abi/abi.proto rename to types/abi/abi.proto diff --git a/proto/args/call.proto b/types/args/call.proto similarity index 91% rename from proto/args/call.proto rename to types/args/call.proto index 17736e58..ffcd59ce 100644 --- a/proto/args/call.proto +++ b/types/args/call.proto @@ -1,7 +1,6 @@ syntax = "proto3"; import "types/abi/abi.proto"; -import "types/ethereum/base.proto"; option go_package = "gitlab.com/ConsenSys/client/fr/core-stack/pkg.git/types/args"; diff --git a/proto/args/private.proto b/types/args/private.proto similarity index 100% rename from proto/args/private.proto rename to types/args/private.proto diff --git a/proto/chain/chain.proto b/types/chain/chain.proto similarity index 100% rename from proto/chain/chain.proto rename to types/chain/chain.proto diff --git a/proto/chain/protocol.proto b/types/chain/protocol.proto similarity index 54% rename from proto/chain/protocol.proto rename to types/chain/protocol.proto index d9d5c0ce..e8e19728 100644 --- a/proto/chain/protocol.proto +++ b/types/chain/protocol.proto @@ -6,13 +6,17 @@ package chain; // Information about a Chain message Protocol { - // Name of the protocol (e.g. `pantheon`, `quorum`, etc.) - string name = 1; - - // Version tag of the protocol - string tag = 2; + // Type of a protocol that should be used + ProtocolType type = 1; // Extra information (optional) map extra = 3; } +enum ProtocolType { + ETHEREUM_CONSTANTINOPLE = 0; + QUORUM_CONSTELLATION = 1; + QUORUM_TESSERA = 2; + PANTHEON_ORION = 3; +} + diff --git a/proto/common/account_instance.proto b/types/common/account_instance.proto similarity index 100% rename from proto/common/account_instance.proto rename to types/common/account_instance.proto diff --git a/proto/contract-registry/registry.proto b/types/contract-registry/registry.proto similarity index 100% rename from proto/contract-registry/registry.proto rename to types/contract-registry/registry.proto diff --git a/proto/envelope-store/store.proto b/types/envelope-store/store.proto similarity index 92% rename from proto/envelope-store/store.proto rename to types/envelope-store/store.proto index 3af3bbbc..f2477263 100644 --- a/proto/envelope-store/store.proto +++ b/types/envelope-store/store.proto @@ -1,7 +1,7 @@ syntax = "proto3"; import "types/envelope/envelope.proto"; -import "types/common/error.proto"; +import "types/error/error.proto"; import "google/protobuf/timestamp.proto"; option go_package = "gitlab.com/ConsenSys/client/fr/core-stack/pkg.git/types/envelope-store"; @@ -23,7 +23,7 @@ service Store { rpc GetStatus(IDRequest) returns (StoreResponse); // SetStatus set an envelope status - rpc SetStatus(SetStatusRequest) returns (common.Error); + rpc SetStatus(SetStatusRequest) returns (error.Error); // LoadPending load envelopes of pending transactions rpc LoadPending(LoadPendingRequest) returns (LoadPendingResponse); @@ -44,7 +44,7 @@ message StoreResponse{ envelope.Envelope envelope = 3; // Error - common.Error err = 4; + error.Error err = 4; } message TxHashRequest{ @@ -78,5 +78,5 @@ message LoadPendingResponse { repeated envelope.Envelope envelopes = 1; // Error - common.Error err = 2; + error.Error err = 2; } diff --git a/proto/envelope/envelope.proto b/types/envelope/envelope.proto similarity index 95% rename from proto/envelope/envelope.proto rename to types/envelope/envelope.proto index 4a806863..0464f16d 100644 --- a/proto/envelope/envelope.proto +++ b/types/envelope/envelope.proto @@ -2,12 +2,12 @@ syntax = "proto3"; import "types/chain/chain.proto"; import "types/chain/protocol.proto"; -import "types/common/error.proto"; import "types/ethereum/base.proto"; import "types/ethereum/transaction.proto"; import "types/ethereum/receipt.proto"; import "types/args/private.proto"; import "types/args/call.proto"; +import "types/error/error.proto"; option go_package = "gitlab.com/ConsenSys/client/fr/core-stack/pkg.git/types/envelope"; @@ -52,7 +52,7 @@ message Envelope { ethereum.Receipt receipt = 5; // Errors encountered while orchestrating the transaction - repeated common.Error errors = 6; + repeated error.Error errors = 6; // Arguments provided by user Args args = 7; diff --git a/proto/common/error.proto b/types/error/error.proto similarity index 67% rename from proto/common/error.proto rename to types/error/error.proto index 5bb7c0e3..f5762fdd 100644 --- a/proto/common/error.proto +++ b/types/error/error.proto @@ -1,8 +1,8 @@ syntax = "proto3"; -option go_package = "gitlab.com/ConsenSys/client/fr/core-stack/pkg.git/types/common"; +option go_package = "gitlab.com/ConsenSys/client/fr/core-stack/pkg.git/types/error"; -package common; +package error; // Error message Error { @@ -12,6 +12,9 @@ message Error { // Error Code of the error uint64 code = 2; + // Component + string component = 3; + // Extra information - map extra = 3; + map extra = 4; } \ No newline at end of file diff --git a/proto/ethereum/base.proto b/types/ethereum/base.proto similarity index 100% rename from proto/ethereum/base.proto rename to types/ethereum/base.proto diff --git a/proto/ethereum/receipt.proto b/types/ethereum/receipt.proto similarity index 100% rename from proto/ethereum/receipt.proto rename to types/ethereum/receipt.proto diff --git a/proto/ethereum/transaction.proto b/types/ethereum/transaction.proto similarity index 100% rename from proto/ethereum/transaction.proto rename to types/ethereum/transaction.proto