diff --git a/package.json b/package.json index ad2fdbe4fd..c13d390662 100644 --- a/package.json +++ b/package.json @@ -80,4 +80,4 @@ } } } -} \ No newline at end of file +} diff --git a/packages/composer-admin/lib/adminconnection.js b/packages/composer-admin/lib/adminconnection.js index 694fe7bff2..60996fdbd2 100644 --- a/packages/composer-admin/lib/adminconnection.js +++ b/packages/composer-admin/lib/adminconnection.js @@ -20,7 +20,6 @@ const Factory = require('composer-common').Factory; const Logger = require('composer-common').Logger; const ModelManager = require('composer-common').ModelManager; const Util = require('composer-common').Util; -const uuid = require('uuid'); const IdCard = require('composer-common').IdCard; const Serializer = require('composer-common').Serializer; @@ -287,11 +286,12 @@ class AdminConnection { // Get the current identity - we may need it to bind the // identity to a network admin participant. return Promise.resolve() - .then(() => { + .then(()=>{ // Create a new instance of a start transaction. - const startTransaction = systemFactory.newTransaction('org.hyperledger.composer.system', 'StartBusinessNetwork'); + const startTransaction = systemFactory.newTransaction('org.hyperledger.composer.system', 'StartBusinessNetwork',startOptions.transactionId.idStr); const classDeclaration = startTransaction.getClassDeclaration(); + delete startOptions.transactionId; let hasNetworkAdmins = startOptions && startOptions.networkAdmins && startOptions.networkAdmins.length > 0; let hasBootStrapTransactions = startOptions && startOptions.bootstrapTransactions && startOptions.bootstrapTransactions.length > 0; @@ -444,7 +444,11 @@ class AdminConnection { Util.securityCheck(this.securityContext); let networkAdmins = startOptions.networkAdmins; // Build the start transaction. - return this._buildStartTransaction(startOptions) + return Util.createTransactionId(this.securityContext) + .then((id) =>{ + startOptions.transactionId = id; + return this._buildStartTransaction(startOptions); + }) .then((startTransactionJSON) => { // Now we can start the business network. return this.connection.start(this.securityContext, networkName, networkVersion, JSON.stringify(startTransactionJSON), startOptions); @@ -619,13 +623,13 @@ class AdminConnection { LOG.entry(method); const json = { $class : 'org.hyperledger.composer.system.ActivateCurrentIdentity', - transactionId : uuid.v4(), timestamp : new Date().toISOString() }; - return Util.invokeChainCode(this.securityContext, 'submitTransaction', [JSON.stringify(json)]) + return Util.submitTransaction(this.securityContext,json) .then(() => { LOG.exit(method); }); + } /** diff --git a/packages/composer-admin/test/adminconnection.js b/packages/composer-admin/test/adminconnection.js index a2b0f83fd6..5da134f050 100644 --- a/packages/composer-admin/test/adminconnection.js +++ b/packages/composer-admin/test/adminconnection.js @@ -22,7 +22,7 @@ const IdCard = require('composer-common').IdCard; const NetworkCardStoreManager = require('composer-common').NetworkCardStoreManager; const SecurityContext = require('composer-common').SecurityContext; const Util = require('composer-common').Util; -const uuid = require('uuid'); + const version = require('../package.json').version; @@ -40,7 +40,7 @@ describe('AdminConnection', () => { name: testProfileName, 'x-type': 'hlfv1' }; - + const startTxId = {idStr:'c89291eb-969f-4b04-b653-82deb5ee0ba1'}; let mockConnectionManager; let mockConnection; let mockSecurityContext; @@ -107,7 +107,7 @@ describe('AdminConnection', () => { faultyCard = new IdCard(faultyMetaData, minimalConnectionProfile); credentialsCard = new IdCard(minimalMetadata, minimalConnectionProfile); credentialsCard.setCredentials(validCredentials); - + sandbox.stub(Util, 'createTransactionId').resolves(startTxId); }); afterEach(() => { @@ -236,6 +236,7 @@ describe('AdminConnection', () => { }); describe('#start', () => { + const networkName = 'network-name'; const networkVersion = '1.0.0-test'; const identityName = 'admin'; @@ -268,7 +269,7 @@ describe('AdminConnection', () => { const expectedStartTransaction = { $class : 'org.hyperledger.composer.system.StartBusinessNetwork', timestamp : '1970-01-01T00:00:00.000Z', - transactionId : sinon.match.string + transactionId : startTxId.idStr }; const expectedNetworkAdminBootstrapTransactions = { bootstrapTransactions : [ @@ -317,6 +318,7 @@ describe('AdminConnection', () => { mockSecurityContext.getUser.returns(identityName); adminConnection.connection = mockConnection; adminConnection.securityContext = mockSecurityContext; + }); it('should error if neither networkAdmins or bootstrapTransactions specified', () => { @@ -494,14 +496,14 @@ describe('AdminConnection', () => { mockConnection.ping.onSecondCall().resolves(Buffer.from(JSON.stringify({ version : version }))); - sandbox.stub(uuid, 'v4').returns('c89291eb-969f-4b04-b653-82deb5ee0ba1'); + mockConnection.invokeChainCode.resolves(); adminConnection.connection = mockConnection; return adminConnection.ping() .then(() => { sinon.assert.calledTwice(mockConnection.ping); sinon.assert.calledOnce(mockConnection.invokeChainCode); - sinon.assert.calledWith(mockConnection.invokeChainCode, mockSecurityContext, 'submitTransaction', ['{"$class":"org.hyperledger.composer.system.ActivateCurrentIdentity","transactionId":"c89291eb-969f-4b04-b653-82deb5ee0ba1","timestamp":"1970-01-01T00:00:00.000Z"}']); + sinon.assert.calledWith(mockConnection.invokeChainCode, mockSecurityContext, 'submitTransaction', ['{"$class":"org.hyperledger.composer.system.ActivateCurrentIdentity","timestamp":"1970-01-01T00:00:00.000Z","transactionId":"c89291eb-969f-4b04-b653-82deb5ee0ba1"}']); }); }); @@ -538,23 +540,23 @@ describe('AdminConnection', () => { it('should perform a security check', () => { sandbox.stub(Util, 'securityCheck'); - sandbox.stub(uuid, 'v4').returns('c89291eb-969f-4b04-b653-82deb5ee0ba1'); + mockConnection.invokeChainCode.resolves(); adminConnection.connection = mockConnection; return adminConnection.activate() .then(() => { - sinon.assert.calledOnce(Util.securityCheck); + sinon.assert.calledTwice(Util.securityCheck); }); }); it('should submit a request to the chaincode for activation', () => { - sandbox.stub(uuid, 'v4').returns('c89291eb-969f-4b04-b653-82deb5ee0ba1'); + mockConnection.invokeChainCode.resolves(); adminConnection.connection = mockConnection; return adminConnection.activate() .then(() => { sinon.assert.calledOnce(mockConnection.invokeChainCode); - sinon.assert.calledWith(mockConnection.invokeChainCode, mockSecurityContext, 'submitTransaction', ['{"$class":"org.hyperledger.composer.system.ActivateCurrentIdentity","transactionId":"c89291eb-969f-4b04-b653-82deb5ee0ba1","timestamp":"1970-01-01T00:00:00.000Z"}']); + sinon.assert.calledWith(mockConnection.invokeChainCode, mockSecurityContext, 'submitTransaction', ['{"$class":"org.hyperledger.composer.system.ActivateCurrentIdentity","timestamp":"1970-01-01T00:00:00.000Z","transactionId":"c89291eb-969f-4b04-b653-82deb5ee0ba1"}']); }); }); diff --git a/packages/composer-client/lib/businessnetworkconnection.js b/packages/composer-client/lib/businessnetworkconnection.js index a0ec3b46fa..6bc913233c 100644 --- a/packages/composer-client/lib/businessnetworkconnection.js +++ b/packages/composer-client/lib/businessnetworkconnection.js @@ -28,7 +28,6 @@ const Resource = require('composer-common').Resource; const TransactionDeclaration = require('composer-common').TransactionDeclaration; const TransactionRegistry = require('./transactionregistry'); const Util = require('composer-common').Util; -const uuid = require('uuid'); const Registry = require('./registry'); const NetworkCardStoreManager = require('composer-common').NetworkCardStoreManager; const LOG = Logger.getLog('BusinessNetworkConnection'); @@ -519,15 +518,9 @@ class BusinessNetworkConnection extends EventEmitter { if (!(classDeclaration instanceof TransactionDeclaration)) { throw new Error(classDeclaration.getFullyQualifiedName() + ' is not a transaction'); } + transaction.timestamp = new Date(); - return Util.createTransactionId(this.securityContext) - .then((id) => { - transaction.setIdentifier(id.idStr); - transaction.timestamp = new Date(); - let data = this.getBusinessNetwork().getSerializer().toJSON(transaction); - return Util.invokeChainCode(this.securityContext, 'submitTransaction', [JSON.stringify(data)], { transactionId: id.id }); - }); - + return Util.submitTransaction(this.securityContext,transaction,this.getBusinessNetwork().getSerializer()); } /** @@ -665,10 +658,9 @@ class BusinessNetworkConnection extends EventEmitter { LOG.entry(method); const json = { $class: 'org.hyperledger.composer.system.ActivateCurrentIdentity', - transactionId: uuid.v4(), timestamp: new Date().toISOString() }; - return Util.invokeChainCode(this.securityContext, 'submitTransaction', [JSON.stringify(json)]) + return Util.submitTransaction(this.securityContext, json) .then(() => { LOG.exit(method); }); diff --git a/packages/composer-client/test/businessnetworkconnection.js b/packages/composer-client/test/businessnetworkconnection.js index 8fc2a382c7..034c98e1d5 100644 --- a/packages/composer-client/test/businessnetworkconnection.js +++ b/packages/composer-client/test/businessnetworkconnection.js @@ -815,9 +815,6 @@ describe('BusinessNetworkConnection', () => { const tx = factory.newTransaction('org.acme.sample', 'SampleTransaction'); delete tx.$identifier; - // Stub the UUID generator. - sandbox.stub(uuid, 'v4').returns('c89291eb-969f-4b04-b653-82deb5ee0ba1'); - // Set up the responses from the chain-code. sandbox.stub(Util, 'invokeChainCode').resolves(); sandbox.stub(Util, 'createTransactionId').resolves({ @@ -1044,14 +1041,17 @@ describe('BusinessNetworkConnection', () => { mockConnection.ping.onSecondCall().resolves(Buffer.from(JSON.stringify({ version : version }))); - sandbox.stub(uuid, 'v4').returns('c89291eb-969f-4b04-b653-82deb5ee0ba1'); + sandbox.stub(Util, 'createTransactionId').resolves({ + id : 'c89291eb-969f-4b04-b653-82deb5ee0ba1', + idStr : 'c89291eb-969f-4b04-b653-82deb5ee0ba1' + }); mockConnection.invokeChainCode.resolves(); businessNetworkConnection.connection = mockConnection; return businessNetworkConnection.ping() .then(() => { sinon.assert.calledTwice(mockConnection.ping); sinon.assert.calledOnce(mockConnection.invokeChainCode); - sinon.assert.calledWith(mockConnection.invokeChainCode, mockSecurityContext, 'submitTransaction', ['{"$class":"org.hyperledger.composer.system.ActivateCurrentIdentity","transactionId":"c89291eb-969f-4b04-b653-82deb5ee0ba1","timestamp":"1970-01-01T00:00:00.000Z"}']); + sinon.assert.calledWith(mockConnection.invokeChainCode, mockSecurityContext, 'submitTransaction', ['{"$class":"org.hyperledger.composer.system.ActivateCurrentIdentity","timestamp":"1970-01-01T00:00:00.000Z","transactionId":"c89291eb-969f-4b04-b653-82deb5ee0ba1"}']); }); }); @@ -1089,21 +1089,28 @@ describe('BusinessNetworkConnection', () => { it('should perform a security check', () => { sandbox.stub(Util, 'securityCheck'); mockConnection.invokeChainCode.resolves(); + sandbox.stub(Util, 'createTransactionId').resolves({ + id : 'c89291eb-969f-4b04-b653-82deb5ee0ba1', + idStr : 'c89291eb-969f-4b04-b653-82deb5ee0ba1' + }); businessNetworkConnection.connection = mockConnection; return businessNetworkConnection.activate() .then(() => { - sinon.assert.calledOnce(Util.securityCheck); + sinon.assert.calledTwice(Util.securityCheck); }); }); it('should submit a request to the chaincode for activation', () => { - sandbox.stub(uuid, 'v4').returns('c89291eb-969f-4b04-b653-82deb5ee0ba1'); + sandbox.stub(Util, 'createTransactionId').resolves({ + id : 'c89291eb-969f-4b04-b653-82deb5ee0ba1', + idStr : 'c89291eb-969f-4b04-b653-82deb5ee0ba1' + }); mockConnection.invokeChainCode.resolves(); businessNetworkConnection.connection = mockConnection; return businessNetworkConnection.activate() .then(() => { sinon.assert.calledOnce(mockConnection.invokeChainCode); - sinon.assert.calledWith(mockConnection.invokeChainCode, mockSecurityContext, 'submitTransaction', ['{"$class":"org.hyperledger.composer.system.ActivateCurrentIdentity","transactionId":"c89291eb-969f-4b04-b653-82deb5ee0ba1","timestamp":"1970-01-01T00:00:00.000Z"}']); + sinon.assert.calledWith(mockConnection.invokeChainCode, mockSecurityContext, 'submitTransaction', ['{"$class":"org.hyperledger.composer.system.ActivateCurrentIdentity","timestamp":"1970-01-01T00:00:00.000Z","transactionId":"c89291eb-969f-4b04-b653-82deb5ee0ba1"}']); }); }); diff --git a/packages/composer-common/lib/connection.js b/packages/composer-common/lib/connection.js index 465d379fb4..8e79ec3b33 100644 --- a/packages/composer-common/lib/connection.js +++ b/packages/composer-common/lib/connection.js @@ -18,7 +18,6 @@ const BusinessNetworkDefinition = require('./businessnetworkdefinition.js'); const ConnectionManager = require('./connectionmanager'); const EventEmitter = require('events'); const Util = require('./util'); -const uuid = require('uuid'); /** * Base class representing a connection to a business network. @@ -167,17 +166,7 @@ class Connection extends EventEmitter { } let transaction = currentDeployedNetwork.getFactory().newTransaction('org.hyperledger.composer.system','ResetBusinessNetwork'); - let id = transaction.getIdentifier(); - if (id === null || id === undefined) { - id = uuid.v4(); - transaction.setIdentifier(id); - } - let timestamp = transaction.timestamp; - if (timestamp === null || timestamp === undefined) { - timestamp = transaction.timestamp = new Date(); - } - let data = currentDeployedNetwork.getSerializer().toJSON(transaction); - await Util.invokeChainCode(securityContext, 'submitTransaction', [JSON.stringify(data)]); + return Util.submitTransaction(securityContext,transaction,currentDeployedNetwork.getSerializer()); } /** @@ -200,18 +189,8 @@ class Connection extends EventEmitter { let currentDeployedNetwork = await BusinessNetworkDefinition.fromArchive(businessNetworkArchive); let transaction = currentDeployedNetwork.getFactory().newTransaction('org.hyperledger.composer.system','SetLogLevel'); - let id = transaction.getIdentifier(); - if (id === null || id === undefined) { - id = uuid.v4(); - transaction.setIdentifier(id); - } - let timestamp = transaction.timestamp; - if (timestamp === null || timestamp === undefined) { - timestamp = transaction.timestamp = new Date(); - } transaction.newLogLevel = loglevel; - let data = currentDeployedNetwork.getSerializer().toJSON(transaction); - await Util.invokeChainCode(securityContext, 'submitTransaction', [JSON.stringify(data)]); + return Util.submitTransaction(securityContext,transaction,currentDeployedNetwork.getSerializer()); } /** diff --git a/packages/composer-common/lib/util.js b/packages/composer-common/lib/util.js index 3e13d69672..2371d69e29 100644 --- a/packages/composer-common/lib/util.js +++ b/packages/composer-common/lib/util.js @@ -13,7 +13,7 @@ */ 'use strict'; - +const Resource = require('./model/resource'); const Globalize = require('./globalize'); const os = require('os'); const path = require('path'); @@ -96,6 +96,34 @@ class Util { return securityContext.getConnection().invokeChainCode(securityContext, functionName, args, options); } + /** + * Takes a json structure of a transaction, and processes this for transaction id + * Passes it on to the invokeChainCode fn + * + * @param {SecurityContext} securityContext - The user's security context + * @param {resource|object} transaction - the transaction + * @param {Serializer} [serializer] needed ONLY if the transaction passed is not a resource but pure json + * @param {string} [functionName] The name of the function to call default is submitTransaction. + */ + static async submitTransaction(securityContext, transaction, serializer,functionName = 'submitTransaction'){ + Util.securityCheck(securityContext); + + let txId = await Util.createTransactionId(securityContext); + let json; + + if (transaction instanceof Resource){ + transaction.setIdentifier(txId.idStr); + json = serializer.toJSON(transaction); + + } else { + transaction.transactionId = txId.idStr; + json=transaction; + } + + await Util.invokeChainCode(securityContext, functionName, [JSON.stringify(json)], { transactionId: txId.id }); + + } + /** * Returns true if the typeof the object === 'undefined' or * the object === null. diff --git a/packages/composer-common/package.json b/packages/composer-common/package.json index 3355fbb92c..02cf11de64 100644 --- a/packages/composer-common/package.json +++ b/packages/composer-common/package.json @@ -104,7 +104,8 @@ ".yml", ".yaml", ".txt", - ".zip" + ".zip", + ".tgz" ], "insert_license": false, "license_formats": { diff --git a/packages/composer-common/test/connection.js b/packages/composer-common/test/connection.js index 1e69103231..05d5f51898 100644 --- a/packages/composer-common/test/connection.js +++ b/packages/composer-common/test/connection.js @@ -35,7 +35,7 @@ describe('Connection', () => { let mockBusinessNetworkDefinition; let connection; let sandbox; - + const startTxId = {idStr:'c89291eb-969f-4b04-b653-82deb5ee0ba1'}; beforeEach(() => { sandbox = sinon.sandbox.create(); @@ -43,6 +43,7 @@ describe('Connection', () => { mockSecurityContext = sinon.createStubInstance(SecurityContext); mockBusinessNetworkDefinition = sinon.createStubInstance(BusinessNetworkDefinition); connection = new Connection(mockConnectionManager, 'devFabric1', 'org.acme.Business'); + sandbox.stub(Util, 'createTransactionId').resolves(startTxId); }); afterEach(() => { @@ -174,7 +175,7 @@ describe('Connection', () => { }); - it('should handle valid data', async () => { + it('should handle valid data - 1', async () => { const buffer = Buffer.from(JSON.stringify({ data: 'aGVsbG8=' })); @@ -202,34 +203,6 @@ describe('Connection', () => { sinon.assert.called(Util.queryChainCode); }); - it('should handle valid data', async () => { - const buffer = Buffer.from(JSON.stringify({ - data: 'aGVsbG8=' - })); - - const buffer2 = Buffer.from(JSON.stringify({ - data: 'aGsad33VsbG8=' - })); - sandbox.stub(Util, 'queryChainCode').withArgs(mockSecurityContext, 'getBusinessNetwork', []).resolves(buffer); - sandbox.stub(Util, 'invokeChainCode').resolves(); - sandbox.stub(BusinessNetworkDefinition, 'fromArchive').resolves(mockBusinessNetworkDefinition); - mockBusinessNetworkDefinition.toArchive.resolves(buffer2); - let mockFactory = sinon.createStubInstance(Factory); - let mockSerializer = sinon.createStubInstance(Serializer); - let mockTransaction = sinon.createStubInstance(Resource); - - mockFactory.newTransaction.returns(mockTransaction); - mockBusinessNetworkDefinition.getFactory.returns(mockFactory); - mockBusinessNetworkDefinition.getSerializer.returns(mockSerializer); - mockBusinessNetworkDefinition.getName.returns('acme-network'); - mockTransaction.getIdentifier.returns(null); - mockTransaction.timestamp=new Date(); - - await connection.reset(mockSecurityContext,'acme-network'); - sinon.assert.called(Util.invokeChainCode); - sinon.assert.called(Util.queryChainCode); - }); - }); describe('#upgrade', () => { diff --git a/packages/composer-common/test/util.js b/packages/composer-common/test/util.js index 7d35eb1435..3261c00120 100644 --- a/packages/composer-common/test/util.js +++ b/packages/composer-common/test/util.js @@ -24,23 +24,47 @@ const uuid = require('uuid'); const chai = require('chai'); const chaiAsPromised = require('chai-as-promised'); const sinon = require('sinon'); - +const Resource = require('../lib/model/resource'); +const Serializer = require('../lib/serializer'); +const ModelManager = require('../lib/modelmanager'); chai.use(chaiAsPromised); chai.should(); describe('Util', function () { + const levelOneModel = `namespace org.acme.l1 + participant Person identified by ssn { + o String ssn + } + asset Car identified by vin { + o String vin + -->Person owner + } + transaction ScrapCar { + -->Car car + } + `; + + let modelManager = null; let mockConnection; let mockSecurityContext; let sandbox; + let mockSerializer; + beforeEach(function () { sandbox = sinon.sandbox.create(); mockConnection = sinon.createStubInstance(Connection); mockConnection.invokeChainCode.returns(Promise.resolve()); mockConnection.queryChainCode.returns(Promise.resolve()); + mockConnection.createTransactionId.resolves({id:'tx1234567890',idStr:'1234567890'}); mockSecurityContext = sinon.createStubInstance(SecurityContext); mockSecurityContext.getConnection.returns(mockConnection); + + mockSerializer = sinon.createStubInstance(Serializer); + + modelManager = new ModelManager(); + modelManager.addModelFile(levelOneModel); }); afterEach(function () { @@ -73,6 +97,52 @@ describe('Util', function () { }); + describe('#submitTransaction', function() { + + it('should process a transaction as json', function () { + let stub = sandbox.stub(Util, 'securityCheck'); + let json = { + $class: 'org.acme.l1.ScrapCar', + car: 'resource:org.acme.l1.Car#456', + timestamp: '1970-01-01T00:00:00.000Z', + transactionId: '789' + }; + return Util + .submitTransaction(mockSecurityContext,json) + .then(() => { + sinon.assert.called(stub); + sinon.assert.called(mockConnection.invokeChainCode); + sinon.assert.calledWith(mockConnection.invokeChainCode,mockSecurityContext,'submitTransaction',[JSON.stringify(json)],{transactionId:'tx1234567890'}); + }); + }); + + it('should process a transaction as resource', function () { + let stub = sandbox.stub(Util, 'securityCheck'); + let json = { + $class: 'org.acme.l1.ScrapCar', + car: 'resource:org.acme.l1.Car#456', + timestamp: '1970-01-01T00:00:00.000Z', + transactionId: '789' + }; + const classDecl = modelManager.getType('org.acme.l1.ScrapCar'); + const resource = new Resource(modelManager, classDecl, 'org.acme.l1', 'ScrapCar', '789' ); + let setIdSpy = sinon.spy(resource,'setIdentifier'); + mockSerializer.toJSON.returns(json); + resource.timestamp = new Date(0); + resource.car = modelManager.getFactory().newRelationship('org.acme.l1', 'Car', '456'); + return Util + .submitTransaction(mockSecurityContext,resource,mockSerializer) + .then(() => { + sinon.assert.called(setIdSpy); + sinon.assert.called(stub); + sinon.assert.called(mockConnection.invokeChainCode); + sinon.assert.calledWith(mockConnection.invokeChainCode,mockSecurityContext,'submitTransaction',[JSON.stringify(json)],{transactionId:'tx1234567890'}); + }); + }); + + }); + + describe('#queryChainCode', function () { it('should perform a security check', function () { diff --git a/packages/composer-connector-hlfv1/lib/hlfconnection.js b/packages/composer-connector-hlfv1/lib/hlfconnection.js index b4d157f216..637d3c6570 100644 --- a/packages/composer-connector-hlfv1/lib/hlfconnection.js +++ b/packages/composer-connector-hlfv1/lib/hlfconnection.js @@ -635,7 +635,8 @@ class HLFConnection extends Connection { // check the event hubs and reconnect if possible. Do it here as the connection attempts are asynchronous this._checkEventhubs(); - const transactionId = this.client.newTransactionID(); + + const transactionId = this._validateTxId(startOptions); const proposal = { chaincodeType: 'node', chaincodeId: businessNetworkName, @@ -898,19 +899,8 @@ class HLFConnection extends Connection { return Promise.reject(error); } - let txId; - if (options && options.transactionId) { + let txId = this._validateTxId(options); - // see if we have a proper transactionID object or perhaps its the data of a transactionId - if (options.transactionId instanceof TransactionID) { - txId = options.transactionId; - } else { - txId = this.client.newTransactionID(); - Object.assign(txId, options.transactionId); - } - } else { - txId = this.client.newTransactionID(); - } let eventHandler; // initialize the channel if it hasn't been initialized already otherwise verification will fail. @@ -1180,6 +1170,28 @@ class HLFConnection extends Connection { */ getNativeAPI() { return this.client; + + } + + /** Based on the options passed in, determine the transaction id that is to be used + * @param {Object} options options to process + * @return {TransactionId} transactionId object + */ + _validateTxId(options){ + let txId; + if (options && options.transactionId) { + + // see if we have a proper transactionID object or perhaps its the data of a transactionId + if (options.transactionId instanceof TransactionID) { + txId = options.transactionId; + } else { + txId = this.client.newTransactionID(); + Object.assign(txId, options.transactionId); + } + } else { + txId = this.client.newTransactionID(); + } + return txId; } } diff --git a/packages/composer-runtime-hlfv1/package.json b/packages/composer-runtime-hlfv1/package.json index cc5c36e34b..0f2fdbeaf4 100644 --- a/packages/composer-runtime-hlfv1/package.json +++ b/packages/composer-runtime-hlfv1/package.json @@ -61,6 +61,7 @@ "file_type_method": "EXCLUDE", "file_types": [ ".yml" + ,".tgz" ], "insert_license": false, "default_format": { diff --git a/packages/composer-runtime/package.json b/packages/composer-runtime/package.json index c77e33f948..5fd198f992 100644 --- a/packages/composer-runtime/package.json +++ b/packages/composer-runtime/package.json @@ -63,7 +63,9 @@ ], "file_type_method": "EXCLUDE", "file_types": [ - ".yml" + ".yml", + ".tgz" + ], "insert_license": false, "license_formats": { diff --git a/packages/composer-tests-functional/package.json b/packages/composer-tests-functional/package.json index 525f9379c0..f5b4c29f2d 100644 --- a/packages/composer-tests-functional/package.json +++ b/packages/composer-tests-functional/package.json @@ -83,15 +83,26 @@ "exact_paths_method": "EXCLUDE", "exact_paths": [ "node_modules", - ".tern-project" + ".tern-project", + ".pm2" + ], "file_type_method": "EXCLUDE", "file_types": [ ".yml", ".yaml", + ".tgz", + ".key", + ".card", ".gz", + ".pem", + ".bna", + ".crt", ".tx", - ".block" + ".block", + ".log", + ".pid", + ".port" ], "insert_license": false, "license_formats": { diff --git a/packages/composer-tests-integration/package.json b/packages/composer-tests-integration/package.json index 98e186b99d..444c0e2901 100644 --- a/packages/composer-tests-integration/package.json +++ b/packages/composer-tests-integration/package.json @@ -75,7 +75,9 @@ ".bna", ".crt", ".tx", - ".block" + ".block", + ".log", + ".pid" ], "insert_license": false, "license_formats": {