Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat 4 #67

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .Github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# In this example, documentation and Header.txt are part # of the
default match. Default owners if nothing else
# matches.
* @yunzhishang
# Code related should be validated by Rama.
# JavaScripts files could have been separated
# into tests versus logic by using folder's structure
*.qry @rama
*.acl @rama
*.cto @rama
*.js @rama
# Package.json should be reviewed by everyone
package.json @yunzhishang @rama @ODOWDAIBM
6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/trade-finance-logistics.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

348 changes: 348 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ script:
deploy:
provider: releases
api_key: ${OAUTH_TOKEN}
file_glob: true
file: ./dist/*
skip_cleanup: true
file: "./dist/*"
on:
repo: yunzhishang/trade-finance-logistics
tags: true
Binary file added bin/configtxgen
Binary file not shown.
Binary file added bin/configtxlator
Binary file not shown.
Binary file added bin/cryptogen
Binary file not shown.
24 changes: 24 additions & 0 deletions bin/get-docker-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash -eu
# Copyright London Stock Exchange Group All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# This script pulls docker images from the Dockerhub hyperledger repositories

# set the default Docker namespace and tag
DOCKER_NS=hyperledger
ARCH=x86_64
VERSION=1.1.1
BASE_DOCKER_TAG=x86_64-0.4.6

# set of Hyperledger Fabric images
FABRIC_IMAGES=(fabric-peer fabric-orderer fabric-ccenv fabric-javaenv fabric-kafka fabric-zookeeper \
fabric-couchdb fabric-tools)

for image in ${FABRIC_IMAGES[@]}; do
echo "Pulling ${DOCKER_NS}/$image:${ARCH}-${VERSION}"
docker pull ${DOCKER_NS}/$image:${ARCH}-${VERSION}
done

echo "Pulling ${DOCKER_NS}/fabric-baseos:${BASE_DOCKER_TAG}"
docker pull ${DOCKER_NS}/fabric-baseos:${BASE_DOCKER_TAG}
Binary file added bin/orderer
Binary file not shown.
Binary file added bin/peer
Binary file not shown.
23 changes: 23 additions & 0 deletions composer/lib/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,26 @@ async function sampleTransaction(tx) {
event.newValue = tx.newValue;
emit(event);
}

/**
* Sample transaction
* @param {org.trade.net.MergeAssets} tx
* @transaction
*/
function onMergeAssets(tx) {
var assetRegistry;
var mergeFromAsset = tx.mergeFrom;
var mergeToAsset = tx.mergeTo;
var toNum = parseInt(mergeToAsset.value);
var fromNum = parseInt(mergeFromAsset.value);
mergeToAsset.value = toNum + fromNum + '';
// hahasdfasdfasdfasdf
return getAssetRegistry('org.trade.net.SampleAsset')
.then(function(ar) {
assetRegistry = ar;
return assetRegistry.update(mergeToAsset);
})
.then(function() {
return assetRegistry.remove(mergeFromAsset);
});
}
5 changes: 5 additions & 0 deletions composer/models/org.trade.net.cto
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ event SampleEvent {
o String oldValue
o String newValue
}

transaction MergeAssets {
--> Asset mergeFrom
--> Asset mergeTo
}
31 changes: 31 additions & 0 deletions composer/test/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,4 +460,35 @@ describe('#' + namespace, () => {
businessNetworkConnection.submitTransaction(transaction).should.be.rejectedWith(/does not have .* access to resource/);
});

it('should change the value to ' + assetType + ' to 200', () => {
const factory =
businessNetworkConnection.getBusinessNetwork().getFactory();
// Create the asset 1
const asset1 = factory.newResource(namespace, assetType, 'ASSET_001');
asset1.value = '100';
asset1.owner = factory.newRelationship(namespace, participantType, '[email protected]');
// Create the asset 2
const asset2 = factory.newResource(namespace, assetType, 'ASSET_002');
asset2.value = '100';
asset2.owner = factory.newRelationship(namespace, participantType, '[email protected]');
// Create a transaction to change the asset's value property
const mergeAssetTx = factory.newTransaction(namespace, 'MergeAssets');
mergeAssetTx.mergeFrom = factory.newRelationship(namespace, assetType, asset1.$identifier);
mergeAssetTx.mergeTo = factory.newRelationship(namespace, assetType, asset2.$identifier);
let assetRegistry;
return businessNetworkConnection.getAssetRegistry(namespace + '.' + assetType).then(registry => {
assetRegistry = registry;
return assetRegistry.add(asset1);
}).then(() => {
return assetRegistry.add(asset2);
}).then(() => {
// Submit the transaction
return businessNetworkConnection.submitTransaction(mergeAssetTx);
}).then(() => {
return assetRegistry.get(asset2.$identifier);
}).then(newAsset => {
newAsset.value.should.equal('200');
});
});

});
4 changes: 2 additions & 2 deletions network/base/peer-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ services:
# bridge network as the peers
# https://docs.docker.com/compose/networking/
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_trade
- CORE_LOGGING_LEVEL=INFO
#- CORE_LOGGING_LEVEL=DEBUG
#- CORE_LOGGING_LEVEL=INFO
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_TLS_ENABLED=true
- CORE_PEER_GOSSIP_USELEADERELECTION=true
- CORE_PEER_GOSSIP_ORGLEADER=false
Expand Down
2 changes: 1 addition & 1 deletion network/configtx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
Profiles:

FourOrgsTradeOrdererGenesis:
Capabilities:
Capabilities:
<<: *ChannelCapabilities
Orderer:
<<: *OrdererDefaults
Expand Down