mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-25 11:05:10 +00:00
Working get via api
This commit is contained in:
parent
53e24a047b
commit
3e40fab58d
62 changed files with 3 additions and 2054 deletions
|
|
@ -27,7 +27,7 @@ export class Djinn extends Contract {
|
||||||
const ageToValidate = Number(age);
|
const ageToValidate = Number(age);
|
||||||
// Validate age
|
// Validate age
|
||||||
validation.isValid = (minimumAge <= ageToValidate);
|
validation.isValid = (minimumAge <= ageToValidate);
|
||||||
|
validation.age = Number(age);
|
||||||
await ctx.stub.putState('VALIDATION' + validation.id, Buffer.from(JSON.stringify(validation.toString())));
|
await ctx.stub.putState('VALIDATION' + validation.id, Buffer.from(JSON.stringify(validation.toString())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
export class Validation {
|
export class Validation {
|
||||||
public executeDate: Date = new Date();
|
public executeDate: Date = new Date();
|
||||||
public id: number;
|
public id: number;
|
||||||
|
public age: number;
|
||||||
public isValid: boolean;
|
public isValid: boolean;
|
||||||
public toString(): string {
|
public toString(): string {
|
||||||
return '{id: ' + this.id + '; executeDate: ' + this.executeDate + '; isValid: ' + this.isValid + '}' ;
|
return '{id: ' + this.id + '; executeDate: ' + this.executeDate + '; age: ' + this.age + '; isValid: ' + this.isValid + '}' ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
4
commercial-paper/.gitignore
vendored
4
commercial-paper/.gitignore
vendored
|
|
@ -1,4 +0,0 @@
|
||||||
cp.tar.gz
|
|
||||||
**/.gradle
|
|
||||||
**/gateway/connection-org1.yaml
|
|
||||||
**/gateway/connection-org2.yaml
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 0 B |
Binary file not shown.
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 0 B |
26
commercial-paper/network-clean.sh
Executable file → Normal file
26
commercial-paper/network-clean.sh
Executable file → Normal file
|
|
@ -1,26 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
function _exit(){
|
|
||||||
printf "Exiting:%s\n" "$1"
|
|
||||||
exit -1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Exit on first error, print all commands.
|
|
||||||
set -ev
|
|
||||||
set -o pipefail
|
|
||||||
|
|
||||||
# Where am I?
|
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
||||||
|
|
||||||
export FABRIC_CFG_PATH="${DIR}/../config"
|
|
||||||
|
|
||||||
cd "${DIR}/../test-network/"
|
|
||||||
|
|
||||||
docker kill cliDigiBank cliMagnetoCorp logspout || true
|
|
||||||
./network.sh down
|
|
||||||
|
|
||||||
# remove any stopped containers
|
|
||||||
docker rm $(docker ps -aq)
|
|
||||||
|
|
||||||
36
commercial-paper/network-starter.sh
Executable file → Normal file
36
commercial-paper/network-starter.sh
Executable file → Normal file
|
|
@ -1,36 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
function _exit(){
|
|
||||||
printf "Exiting:%s\n" "$1"
|
|
||||||
exit -1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Exit on first error, print all commands.
|
|
||||||
set -ev
|
|
||||||
set -o pipefail
|
|
||||||
|
|
||||||
# Where am I?
|
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
||||||
|
|
||||||
export FABRIC_CFG_PATH="${DIR}/../config"
|
|
||||||
|
|
||||||
cd "${DIR}/../test-network/"
|
|
||||||
|
|
||||||
docker kill cliDigiBank cliMagnetoCorp logspout || true
|
|
||||||
./network.sh down
|
|
||||||
./network.sh up createChannel -ca -s couchdb
|
|
||||||
|
|
||||||
# Copy the connection profiles so they are in the correct organizations.
|
|
||||||
cp "${DIR}/../test-network/organizations/peerOrganizations/org1.example.com/connection-org1.yaml" "${DIR}/organization/digibank/gateway/"
|
|
||||||
cp "${DIR}/../test-network/organizations/peerOrganizations/org2.example.com/connection-org2.yaml" "${DIR}/organization/magnetocorp/gateway/"
|
|
||||||
|
|
||||||
cp "${DIR}/../test-network/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/signcerts/"* "${DIR}/../test-network/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/signcerts/User1@org1.example.com-cert.pem"
|
|
||||||
cp "${DIR}/../test-network/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/keystore/"* "${DIR}/../test-network/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/keystore/priv_sk"
|
|
||||||
|
|
||||||
cp "${DIR}/../test-network/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/signcerts/"* "${DIR}/../test-network/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/signcerts/User1@org2.example.com-cert.pem"
|
|
||||||
cp "${DIR}/../test-network/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/keystore/"* "${DIR}/../test-network/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/keystore/priv_sk"
|
|
||||||
|
|
||||||
echo Suggest that you monitor the docker containers by running
|
|
||||||
echo "./organization/magnetocorp/configuration/cli/monitordocker.sh fabric_test"
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
identity
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
target/
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
eclipse.preferences.version=1
|
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
|
||||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
|
||||||
org.eclipse.jdt.core.compiler.release=disabled
|
|
||||||
org.eclipse.jdt.core.compiler.source=1.8
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
activeProfiles=
|
|
||||||
eclipse.preferences.version=1
|
|
||||||
resolveWorkspaceProjects=true
|
|
||||||
version=1
|
|
||||||
|
|
@ -1,96 +0,0 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<groupId>commercial-paper</groupId>
|
|
||||||
<artifactId>commercial-paper</artifactId>
|
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
|
|
||||||
<!-- Generic properties -->
|
|
||||||
<java.version>1.8</java.version>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
|
||||||
|
|
||||||
<!-- fabric-chaincode-java -->
|
|
||||||
<fabric-chaincode-java.version>2.1.0</fabric-chaincode-java.version>
|
|
||||||
<!-- fabric-gateway-java -->
|
|
||||||
<fabric-gateway-java.version>2.1.0</fabric-gateway-java.version>
|
|
||||||
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<sourceDirectory>src</sourceDirectory>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>3.8.0</version>
|
|
||||||
<configuration>
|
|
||||||
<source>1.8</source>
|
|
||||||
<target>1.8</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<version>3.2.0</version>
|
|
||||||
<executions>
|
|
||||||
<!-- Attach the shade goal into the package phase -->
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>shade</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
|
||||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
|
||||||
<filters>
|
|
||||||
<filter>
|
|
||||||
<artifact>*:*</artifact>
|
|
||||||
<excludes>
|
|
||||||
<exclude>META-INF/*.SF</exclude>
|
|
||||||
<exclude>META-INF/*.DSA</exclude>
|
|
||||||
<exclude>META-INF/*.RSA</exclude>
|
|
||||||
</excludes>
|
|
||||||
</filter>
|
|
||||||
</filters>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>jitpack.io</id>
|
|
||||||
<url>https://jitpack.io</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.hyperledger.fabric</groupId>
|
|
||||||
<artifactId>fabric-gateway-java</artifactId>
|
|
||||||
<version>${fabric-gateway-java.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Used for datatype annotations only -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.hyperledger.fabric-chaincode-java</groupId>
|
|
||||||
<artifactId>fabric-chaincode-shim</artifactId>
|
|
||||||
<version>${fabric-chaincode-java.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.json/json -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.json</groupId>
|
|
||||||
<artifactId>json</artifactId>
|
|
||||||
<version>20180813</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
||||||
/*
|
|
||||||
SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.digibank;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.security.InvalidKeyException;
|
|
||||||
import java.security.PrivateKey;
|
|
||||||
import java.security.cert.CertificateException;
|
|
||||||
import java.security.cert.X509Certificate;
|
|
||||||
import org.hyperledger.fabric.gateway.Identities;
|
|
||||||
import org.hyperledger.fabric.gateway.Identity;
|
|
||||||
import org.hyperledger.fabric.gateway.Wallet;
|
|
||||||
import org.hyperledger.fabric.gateway.Wallets;
|
|
||||||
|
|
||||||
public class AddToWallet {
|
|
||||||
|
|
||||||
private static X509Certificate readX509Certificate(final Path certificatePath) throws IOException, CertificateException {
|
|
||||||
try (Reader certificateReader = Files.newBufferedReader(certificatePath, StandardCharsets.UTF_8)) {
|
|
||||||
return Identities.readX509Certificate(certificateReader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static PrivateKey getPrivateKey(final Path privateKeyPath) throws IOException, InvalidKeyException {
|
|
||||||
try (Reader privateKeyReader = Files.newBufferedReader(privateKeyPath, StandardCharsets.UTF_8)) {
|
|
||||||
return Identities.readPrivateKey(privateKeyReader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
try {
|
|
||||||
// A wallet stores a collection of identities
|
|
||||||
Path walletPath = Paths.get(".", "wallet");
|
|
||||||
Wallet wallet = Wallets.newFileSystemWallet(walletPath);
|
|
||||||
|
|
||||||
Path credentialPath = Paths.get("..", "..", "..",".." ,"test-network", "organizations",
|
|
||||||
"peerOrganizations", "org1.example.com", "users", "User1@org1.example.com", "msp");
|
|
||||||
System.out.println("credentialPath: " + credentialPath.toString());
|
|
||||||
Path certificatePath = credentialPath.resolve(Paths.get("signcerts",
|
|
||||||
"User1@org1.example.com-cert.pem"));
|
|
||||||
System.out.println("certificatePem: " + certificatePath.toString());
|
|
||||||
Path privateKeyPath = credentialPath.resolve(Paths.get("keystore",
|
|
||||||
"priv_sk"));
|
|
||||||
|
|
||||||
X509Certificate certificate = readX509Certificate(certificatePath);
|
|
||||||
PrivateKey privateKey = getPrivateKey(privateKeyPath);
|
|
||||||
|
|
||||||
Identity identity = Identities.newX509Identity("Org1MSP", certificate, privateKey);
|
|
||||||
|
|
||||||
|
|
||||||
String identityLabel = "User1@org1.example.com";
|
|
||||||
wallet.put(identityLabel, identity);
|
|
||||||
|
|
||||||
System.out.println("Write wallet info into " + walletPath.toString() + " successfully.");
|
|
||||||
|
|
||||||
} catch (IOException | CertificateException | InvalidKeyException e) {
|
|
||||||
System.err.println("Error adding to wallet");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
||||||
/*
|
|
||||||
SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.digibank;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
|
|
||||||
import org.hyperledger.fabric.gateway.Contract;
|
|
||||||
import org.hyperledger.fabric.gateway.Gateway;
|
|
||||||
import org.hyperledger.fabric.gateway.GatewayException;
|
|
||||||
import org.hyperledger.fabric.gateway.Network;
|
|
||||||
import org.hyperledger.fabric.gateway.Wallet;
|
|
||||||
import org.hyperledger.fabric.gateway.Wallets;
|
|
||||||
import org.papernet.CommercialPaper;
|
|
||||||
|
|
||||||
public class Buy {
|
|
||||||
|
|
||||||
private static final String ENVKEY="CONTRACT_NAME";
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Gateway.Builder builder = Gateway.createBuilder();
|
|
||||||
|
|
||||||
String contractName="papercontract";
|
|
||||||
// get the name of the contract, in case it is overridden
|
|
||||||
Map<String,String> envvar = System.getenv();
|
|
||||||
if (envvar.containsKey(ENVKEY)){
|
|
||||||
contractName=envvar.get(ENVKEY);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
// A wallet stores a collection of identities
|
|
||||||
Path walletPath = Paths.get(".", "wallet");
|
|
||||||
Wallet wallet = Wallets.newFileSystemWallet(walletPath);
|
|
||||||
System.out.println("Read wallet info from: " + walletPath);
|
|
||||||
|
|
||||||
String userName = "User1@org1.example.com";
|
|
||||||
|
|
||||||
Path connectionProfile = Paths.get("..", "gateway", "connection-org1.yaml");
|
|
||||||
|
|
||||||
// Set connection options on the gateway builder
|
|
||||||
builder.identity(wallet, userName).networkConfig(connectionProfile).discovery(false);
|
|
||||||
|
|
||||||
// Connect to gateway using application specified parameters
|
|
||||||
try(Gateway gateway = builder.connect()) {
|
|
||||||
|
|
||||||
// Access PaperNet network
|
|
||||||
System.out.println("Use network channel: mychannel.");
|
|
||||||
Network network = gateway.getNetwork("mychannel");
|
|
||||||
|
|
||||||
// Get addressability to commercial paper contract
|
|
||||||
System.out.println("Use org.papernet.commercialpaper smart contract.");
|
|
||||||
Contract contract = network.getContract(contractName, "org.papernet.commercialpaper");
|
|
||||||
|
|
||||||
// Buy commercial paper
|
|
||||||
System.out.println("Submit commercial paper buy transaction.");
|
|
||||||
byte[] response = contract.submitTransaction("buy", "MagnetoCorp", "00001", "MagnetoCorp", "DigiBank", "4900000", "2020-05-31");
|
|
||||||
|
|
||||||
// Process response
|
|
||||||
System.out.println("Process buy transaction response.");
|
|
||||||
CommercialPaper paper = CommercialPaper.deserialize(response);
|
|
||||||
System.out.println(paper);
|
|
||||||
}
|
|
||||||
} catch (GatewayException | IOException | TimeoutException | InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
System.exit(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,73 +0,0 @@
|
||||||
/*
|
|
||||||
SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.digibank;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
|
|
||||||
import org.hyperledger.fabric.gateway.Contract;
|
|
||||||
import org.hyperledger.fabric.gateway.Gateway;
|
|
||||||
import org.hyperledger.fabric.gateway.GatewayException;
|
|
||||||
import org.hyperledger.fabric.gateway.Network;
|
|
||||||
import org.hyperledger.fabric.gateway.Wallet;
|
|
||||||
import org.hyperledger.fabric.gateway.Wallets;
|
|
||||||
import org.papernet.CommercialPaper;
|
|
||||||
|
|
||||||
public class Redeem {
|
|
||||||
|
|
||||||
private static final String ENVKEY="CONTRACT_NAME";
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Gateway.Builder builder = Gateway.createBuilder();
|
|
||||||
|
|
||||||
String contractName="papercontract";
|
|
||||||
// get the name of the contract, in case it is overridden
|
|
||||||
Map<String,String> envvar = System.getenv();
|
|
||||||
if (envvar.containsKey(ENVKEY)){
|
|
||||||
contractName=envvar.get(ENVKEY);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
// A wallet stores a collection of identities
|
|
||||||
Path walletPath = Paths.get(".", "wallet");
|
|
||||||
Wallet wallet = Wallets.newFileSystemWallet(walletPath);
|
|
||||||
|
|
||||||
String userName = "User1@org1.example.com";
|
|
||||||
|
|
||||||
Path connectionProfile = Paths.get("..", "gateway", "connection-org1.yaml");
|
|
||||||
|
|
||||||
// Set connection options on the gateway builder
|
|
||||||
builder.identity(wallet, userName).networkConfig(connectionProfile).discovery(false);
|
|
||||||
|
|
||||||
// Connect to gateway using application specified parameters
|
|
||||||
try(Gateway gateway = builder.connect()) {
|
|
||||||
|
|
||||||
// Access PaperNet network
|
|
||||||
System.out.println("Use network channel: mychannel.");
|
|
||||||
Network network = gateway.getNetwork("mychannel");
|
|
||||||
|
|
||||||
// Get addressability to commercial paper contract
|
|
||||||
System.out.println("Use org.papernet.commercialpaper smart contract.");
|
|
||||||
Contract contract = network.getContract("papercontract", "org.papernet.commercialpaper");
|
|
||||||
|
|
||||||
// Redeem commercial paper
|
|
||||||
System.out.println("Submit commercial paper redeem transaction.");
|
|
||||||
byte[] response = contract.submitTransaction("redeem", "MagnetoCorp", "00001", "DigiBank", "2020-11-30");
|
|
||||||
|
|
||||||
// Process response
|
|
||||||
System.out.println("Process redeem transaction response.");
|
|
||||||
CommercialPaper paper = CommercialPaper.deserialize(response);
|
|
||||||
System.out.println(paper);
|
|
||||||
}
|
|
||||||
} catch (GatewayException | IOException | TimeoutException | InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
System.exit(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
/*
|
|
||||||
SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
env: {
|
|
||||||
node: true,
|
|
||||||
mocha: true
|
|
||||||
},
|
|
||||||
parserOptions: {
|
|
||||||
ecmaVersion: 8,
|
|
||||||
sourceType: 'script'
|
|
||||||
},
|
|
||||||
extends: "eslint:recommended",
|
|
||||||
rules: {
|
|
||||||
indent: ['error', 4],
|
|
||||||
'linebreak-style': ['error', 'unix'],
|
|
||||||
quotes: ['error', 'single'],
|
|
||||||
semi: ['error', 'always'],
|
|
||||||
'no-unused-vars': ['error', { args: 'none' }],
|
|
||||||
'no-console': 'off',
|
|
||||||
curly: 'error',
|
|
||||||
eqeqeq: 'error',
|
|
||||||
'no-throw-literal': 'error',
|
|
||||||
strict: 'error',
|
|
||||||
'no-var': 'error',
|
|
||||||
'dot-notation': 'error',
|
|
||||||
'no-tabs': 'error',
|
|
||||||
'no-trailing-spaces': 'error',
|
|
||||||
'no-use-before-define': 'error',
|
|
||||||
'no-useless-call': 'error',
|
|
||||||
'no-with': 'error',
|
|
||||||
'operator-linebreak': 'error',
|
|
||||||
yoda: 'error',
|
|
||||||
'quote-props': ['error', 'as-needed']
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
node_modules
|
|
||||||
|
|
@ -1,55 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright IBM Corp. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
// Bring key classes into scope, most importantly Fabric SDK network class
|
|
||||||
const fs = require('fs');
|
|
||||||
const { Wallets } = require('fabric-network');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const fixtures = path.resolve(__dirname, '../../../../test-network');
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
|
|
||||||
// Main try/catch block
|
|
||||||
try {
|
|
||||||
|
|
||||||
// A wallet stores a collection of identities
|
|
||||||
const wallet = await Wallets.newFileSystemWallet('../identity/user/balaji/wallet');
|
|
||||||
|
|
||||||
// Identity to credentials to be stored in the wallet
|
|
||||||
const credPath = path.join(fixtures, '/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com');
|
|
||||||
const certificate = fs.readFileSync(path.join(credPath, '/msp/signcerts/User1@org1.example.com-cert.pem')).toString();
|
|
||||||
const privateKey = fs.readFileSync(path.join(credPath, '/msp/keystore/priv_sk')).toString();
|
|
||||||
|
|
||||||
// Load credentials into wallet
|
|
||||||
const identityLabel = 'balaji';
|
|
||||||
|
|
||||||
const identity = {
|
|
||||||
credentials: {
|
|
||||||
certificate,
|
|
||||||
privateKey
|
|
||||||
},
|
|
||||||
mspId: 'Org1MSP',
|
|
||||||
type: 'X.509'
|
|
||||||
}
|
|
||||||
|
|
||||||
await wallet.put(identityLabel, identity);
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
console.log(`Error adding to wallet. ${error}`);
|
|
||||||
console.log(error.stack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
main().then(() => {
|
|
||||||
console.log('done');
|
|
||||||
}).catch((e) => {
|
|
||||||
console.log(e);
|
|
||||||
console.log(e.stack);
|
|
||||||
process.exit(-1);
|
|
||||||
});
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright IBM Corp. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const FabricCAServices = require('fabric-ca-client');
|
|
||||||
const { Wallets } = require('fabric-network');
|
|
||||||
const fs = require('fs');
|
|
||||||
const yaml = require('js-yaml');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
try {
|
|
||||||
// load the network configuration
|
|
||||||
let connectionProfile = yaml.safeLoad(fs.readFileSync('../gateway/connection-org1.yaml', 'utf8'));
|
|
||||||
|
|
||||||
// Create a new CA client for interacting with the CA.
|
|
||||||
const caInfo = connectionProfile.certificateAuthorities['ca.org1.example.com'];
|
|
||||||
const caTLSCACerts = caInfo.tlsCACerts.pem;
|
|
||||||
const ca = new FabricCAServices(caInfo.url, { trustedRoots: caTLSCACerts, verify: false }, caInfo.caName);
|
|
||||||
|
|
||||||
// Create a new file system based wallet for managing identities.
|
|
||||||
const walletPath = path.join(process.cwd(), '../identity/user/balaji/wallet');
|
|
||||||
const wallet = await Wallets.newFileSystemWallet(walletPath);
|
|
||||||
console.log(`Wallet path: ${walletPath}`);
|
|
||||||
|
|
||||||
// Check to see if we've already enrolled the admin user.
|
|
||||||
const userExists = await wallet.get('balaji');
|
|
||||||
if (userExists) {
|
|
||||||
console.log('An identity for the client user "balaji" already exists in the wallet');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enroll the admin user, and import the new identity into the wallet.
|
|
||||||
const enrollment = await ca.enroll({ enrollmentID: 'user1', enrollmentSecret: 'user1pw' });
|
|
||||||
const x509Identity = {
|
|
||||||
credentials: {
|
|
||||||
certificate: enrollment.certificate,
|
|
||||||
privateKey: enrollment.key.toBytes(),
|
|
||||||
},
|
|
||||||
mspId: 'Org1MSP',
|
|
||||||
type: 'X.509',
|
|
||||||
};
|
|
||||||
await wallet.put('balaji', x509Identity);
|
|
||||||
console.log('Successfully enrolled client user "balaji" and imported it into the wallet');
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
console.error(`Failed to enroll client user "balaji": ${error}`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
main();
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
{
|
|
||||||
"name": "nodejs",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "",
|
|
||||||
"main": "buy.js",
|
|
||||||
"scripts": {
|
|
||||||
"test": "rm -rf _idwallet && node addToWallet.js && node buy.js"
|
|
||||||
},
|
|
||||||
"keywords": [],
|
|
||||||
"author": "",
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"dependencies": {
|
|
||||||
"fabric-network": "^2.2.4",
|
|
||||||
"fabric-ca-client": "^2.2.4",
|
|
||||||
"js-yaml": "^3.12.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"eslint": "^5.6.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
31
commercial-paper/organization/digibank/configuration/cli/monitordocker.sh
Executable file → Normal file
31
commercial-paper/organization/digibank/configuration/cli/monitordocker.sh
Executable file → Normal file
|
|
@ -1,31 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# This script uses the logspout and http stream tools to let you watch the docker containers
|
|
||||||
# in action.
|
|
||||||
#
|
|
||||||
# More information at https://github.com/gliderlabs/logspout/tree/master/httpstream
|
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
|
||||||
DOCKER_NETWORK=basicnetwork_basic
|
|
||||||
else
|
|
||||||
DOCKER_NETWORK="$1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$2" ]; then
|
|
||||||
PORT=8000
|
|
||||||
else
|
|
||||||
PORT="$2"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo Starting monitoring on all containers on the network ${DOCKER_NETWORK}
|
|
||||||
|
|
||||||
docker kill logspout 2> /dev/null 1>&2 || true
|
|
||||||
docker rm logspout 2> /dev/null 1>&2 || true
|
|
||||||
|
|
||||||
docker run -d --name="logspout" \
|
|
||||||
--volume=/var/run/docker.sock:/var/run/docker.sock \
|
|
||||||
--publish=127.0.0.1:${PORT}:80 \
|
|
||||||
--network ${DOCKER_NETWORK} \
|
|
||||||
gliderlabs/logspout
|
|
||||||
sleep 3
|
|
||||||
curl http://127.0.0.1:${PORT}/logs
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
/.classpath
|
|
||||||
/.gradle/
|
|
||||||
/.project
|
|
||||||
/.settings/
|
|
||||||
/bin/
|
|
||||||
/build/
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
plugins {
|
|
||||||
id 'java-library-distribution'
|
|
||||||
}
|
|
||||||
|
|
||||||
version '0.0.1'
|
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
maven {
|
|
||||||
url 'https://jitpack.io'
|
|
||||||
}
|
|
||||||
maven {
|
|
||||||
url "https://hyperledger.jfrog.io/hyperledger/fabric-maven"
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
compileOnly group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '2.+'
|
|
||||||
compile group: 'org.json', name: 'json', version: '20180813'
|
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2'
|
|
||||||
testImplementation 'org.assertj:assertj-core:3.11.1'
|
|
||||||
testImplementation 'org.mockito:mockito-core:2.+'
|
|
||||||
}
|
|
||||||
|
|
||||||
test {
|
|
||||||
useJUnitPlatform()
|
|
||||||
testLogging {
|
|
||||||
events "passed", "skipped", "failed"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
|
||||||
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" << "-parameters"
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
|
@ -1,5 +0,0 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
|
||||||
distributionPath=wrapper/dists
|
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
|
||||||
zipStorePath=wrapper/dists
|
|
||||||
188
commercial-paper/organization/digibank/contract-java/gradlew
vendored
Executable file → Normal file
188
commercial-paper/organization/digibank/contract-java/gradlew
vendored
Executable file → Normal file
|
|
@ -1,188 +0,0 @@
|
||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
#
|
|
||||||
# Copyright 2015 the original author or authors.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
##
|
|
||||||
## Gradle start up script for UN*X
|
|
||||||
##
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
|
||||||
# Resolve links: $0 may be a link
|
|
||||||
PRG="$0"
|
|
||||||
# Need this for relative symlinks.
|
|
||||||
while [ -h "$PRG" ] ; do
|
|
||||||
ls=`ls -ld "$PRG"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
PRG="$link"
|
|
||||||
else
|
|
||||||
PRG=`dirname "$PRG"`"/$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
SAVED="`pwd`"
|
|
||||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
|
||||||
APP_HOME="`pwd -P`"
|
|
||||||
cd "$SAVED" >/dev/null
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=`basename "$0"`
|
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
||||||
MAX_FD="maximum"
|
|
||||||
|
|
||||||
warn () {
|
|
||||||
echo "$*"
|
|
||||||
}
|
|
||||||
|
|
||||||
die () {
|
|
||||||
echo
|
|
||||||
echo "$*"
|
|
||||||
echo
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
|
||||||
cygwin=false
|
|
||||||
msys=false
|
|
||||||
darwin=false
|
|
||||||
nonstop=false
|
|
||||||
case "`uname`" in
|
|
||||||
CYGWIN* )
|
|
||||||
cygwin=true
|
|
||||||
;;
|
|
||||||
Darwin* )
|
|
||||||
darwin=true
|
|
||||||
;;
|
|
||||||
MINGW* )
|
|
||||||
msys=true
|
|
||||||
;;
|
|
||||||
NONSTOP* )
|
|
||||||
nonstop=true
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
|
||||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
|
||||||
else
|
|
||||||
JAVACMD="$JAVA_HOME/bin/java"
|
|
||||||
fi
|
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
location of your Java installation."
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
JAVACMD="java"
|
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
location of your Java installation."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
|
||||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
|
||||||
if [ $? -eq 0 ] ; then
|
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
|
||||||
MAX_FD="$MAX_FD_LIMIT"
|
|
||||||
fi
|
|
||||||
ulimit -n $MAX_FD
|
|
||||||
if [ $? -ne 0 ] ; then
|
|
||||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Darwin, add options to specify how the application appears in the dock
|
|
||||||
if $darwin; then
|
|
||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
||||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
|
||||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
|
||||||
SEP=""
|
|
||||||
for dir in $ROOTDIRSRAW ; do
|
|
||||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
|
||||||
SEP="|"
|
|
||||||
done
|
|
||||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
|
||||||
# Add a user-defined pattern to the cygpath arguments
|
|
||||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
|
||||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
|
||||||
fi
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
||||||
i=0
|
|
||||||
for arg in "$@" ; do
|
|
||||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
|
||||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
|
||||||
|
|
||||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
|
||||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
|
||||||
else
|
|
||||||
eval `echo args$i`="\"$arg\""
|
|
||||||
fi
|
|
||||||
i=$((i+1))
|
|
||||||
done
|
|
||||||
case $i in
|
|
||||||
(0) set -- ;;
|
|
||||||
(1) set -- "$args0" ;;
|
|
||||||
(2) set -- "$args0" "$args1" ;;
|
|
||||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
|
||||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
|
||||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
|
||||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
|
||||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
|
||||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
|
||||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Escape application args
|
|
||||||
save () {
|
|
||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
|
||||||
echo " "
|
|
||||||
}
|
|
||||||
APP_ARGS=$(save "$@")
|
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
|
||||||
|
|
||||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
|
||||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
|
||||||
cd "$(dirname "$0")"
|
|
||||||
fi
|
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
|
||||||
|
|
@ -1,100 +0,0 @@
|
||||||
@rem
|
|
||||||
@rem Copyright 2015 the original author or authors.
|
|
||||||
@rem
|
|
||||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
@rem you may not use this file except in compliance with the License.
|
|
||||||
@rem You may obtain a copy of the License at
|
|
||||||
@rem
|
|
||||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
@rem
|
|
||||||
@rem Unless required by applicable law or agreed to in writing, software
|
|
||||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
@rem See the License for the specific language governing permissions and
|
|
||||||
@rem limitations under the License.
|
|
||||||
@rem
|
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
|
||||||
@rem ##########################################################################
|
|
||||||
@rem
|
|
||||||
@rem Gradle startup script for Windows
|
|
||||||
@rem
|
|
||||||
@rem ##########################################################################
|
|
||||||
|
|
||||||
@rem Set local scope for the variables with windows NT shell
|
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
|
||||||
set APP_BASE_NAME=%~n0
|
|
||||||
set APP_HOME=%DIRNAME%
|
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
|
||||||
|
|
||||||
@rem Find java.exe
|
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
|
||||||
if "%ERRORLEVEL%" == "0" goto init
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
||||||
echo.
|
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
echo location of your Java installation.
|
|
||||||
|
|
||||||
goto fail
|
|
||||||
|
|
||||||
:findJavaFromJavaHome
|
|
||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto init
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
|
||||||
echo.
|
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
echo location of your Java installation.
|
|
||||||
|
|
||||||
goto fail
|
|
||||||
|
|
||||||
:init
|
|
||||||
@rem Get command-line arguments, handling Windows variants
|
|
||||||
|
|
||||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
|
||||||
|
|
||||||
:win9xME_args
|
|
||||||
@rem Slurp the command line arguments.
|
|
||||||
set CMD_LINE_ARGS=
|
|
||||||
set _SKIP=2
|
|
||||||
|
|
||||||
:win9xME_args_slurp
|
|
||||||
if "x%~1" == "x" goto execute
|
|
||||||
|
|
||||||
set CMD_LINE_ARGS=%*
|
|
||||||
|
|
||||||
:execute
|
|
||||||
@rem Setup the command line
|
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
|
||||||
|
|
||||||
:end
|
|
||||||
@rem End local scope for the variables with windows NT shell
|
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
|
||||||
|
|
||||||
:fail
|
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
|
||||||
rem the _cmd.exe /c_ return code!
|
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
|
||||||
exit /b 1
|
|
||||||
|
|
||||||
:mainEnd
|
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
|
||||||
|
|
||||||
:omega
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
rootProject.name = 'papercontract'
|
|
||||||
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
/*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
plugins {
|
|
||||||
id 'com.github.johnrengelman.shadow' version '5.1.0'
|
|
||||||
id 'java'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
version '0.0.1'
|
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
maven {
|
|
||||||
url 'https://jitpack.io'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '2.+'
|
|
||||||
implementation group: 'org.json', name: 'json', version: '20180813'
|
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2'
|
|
||||||
testImplementation 'org.assertj:assertj-core:3.11.1'
|
|
||||||
testImplementation 'org.mockito:mockito-core:2.+'
|
|
||||||
}
|
|
||||||
|
|
||||||
test {
|
|
||||||
useJUnitPlatform()
|
|
||||||
testLogging {
|
|
||||||
events "passed", "skipped", "failed"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
shadowJar {
|
|
||||||
baseName = 'chaincode'
|
|
||||||
version = null
|
|
||||||
classifier = null
|
|
||||||
|
|
||||||
manifest {
|
|
||||||
attributes 'Main-Class': 'org.hyperledger.fabric.contract.ContractRouter'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
|
||||||
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" << "-parameters"
|
|
||||||
}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
package org.example;
|
|
||||||
|
|
||||||
import org.hyperledger.fabric.contract.Context;
|
|
||||||
import org.hyperledger.fabric.shim.ChaincodeStub;
|
|
||||||
|
|
||||||
class CommercialPaperContext extends Context {
|
|
||||||
|
|
||||||
public CommercialPaperContext(ChaincodeStub stub) {
|
|
||||||
super(stub);
|
|
||||||
this.paperList = new PaperList(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PaperList paperList;
|
|
||||||
|
|
||||||
}
|
|
||||||
16
commercial-paper/organization/digibank/contract/.editorconfig
Executable file → Normal file
16
commercial-paper/organization/digibank/contract/.editorconfig
Executable file → Normal file
|
|
@ -1,16 +0,0 @@
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
root = true
|
|
||||||
|
|
||||||
[*]
|
|
||||||
indent_style = space
|
|
||||||
indent_size = 4
|
|
||||||
end_of_line = lf
|
|
||||||
charset = utf-8
|
|
||||||
trim_trailing_whitespace = true
|
|
||||||
insert_final_newline = true
|
|
||||||
|
|
||||||
[*.md]
|
|
||||||
trim_trailing_whitespace = false
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
coverage
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
/*
|
|
||||||
SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
env: {
|
|
||||||
node: true,
|
|
||||||
mocha: true
|
|
||||||
},
|
|
||||||
parserOptions: {
|
|
||||||
ecmaVersion: 8,
|
|
||||||
sourceType: 'script'
|
|
||||||
},
|
|
||||||
extends: "eslint:recommended",
|
|
||||||
rules: {
|
|
||||||
indent: ['error', 4],
|
|
||||||
'linebreak-style': ['error', 'unix'],
|
|
||||||
quotes: ['error', 'single'],
|
|
||||||
semi: ['error', 'always'],
|
|
||||||
'no-unused-vars': ['error', { args: 'none' }],
|
|
||||||
'no-console': 'off',
|
|
||||||
curly: 'error',
|
|
||||||
eqeqeq: 'error',
|
|
||||||
'no-throw-literal': 'error',
|
|
||||||
strict: 'error',
|
|
||||||
'no-var': 'error',
|
|
||||||
'dot-notation': 'error',
|
|
||||||
'no-tabs': 'error',
|
|
||||||
'no-trailing-spaces': 'error',
|
|
||||||
'no-use-before-define': 'error',
|
|
||||||
'no-useless-call': 'error',
|
|
||||||
'no-with': 'error',
|
|
||||||
'operator-linebreak': 'error',
|
|
||||||
yoda: 'error',
|
|
||||||
'quote-props': ['error', 'as-needed']
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright IBM Corp. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const cpcontract = require('./lib/papercontract.js');
|
|
||||||
module.exports.contracts = [cpcontract];
|
|
||||||
38
commercial-paper/organization/digibank/digibank.sh
Executable file → Normal file
38
commercial-paper/organization/digibank/digibank.sh
Executable file → Normal file
|
|
@ -1,38 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
TMPFILE=`mktemp`
|
|
||||||
shopt -s extglob
|
|
||||||
|
|
||||||
function _exit(){
|
|
||||||
printf "Exiting:%s\n" "$1"
|
|
||||||
exit -1
|
|
||||||
}
|
|
||||||
|
|
||||||
: ${CHANNEL_NAME:="mychannel"}
|
|
||||||
: ${DELAY:="3"}
|
|
||||||
: ${MAX_RETRY:="5"}
|
|
||||||
: ${VERBOSE:="false"}
|
|
||||||
|
|
||||||
# Where am I?
|
|
||||||
DIR=${PWD}
|
|
||||||
|
|
||||||
# Locate the test network
|
|
||||||
cd "${DIR}/../../../test-network"
|
|
||||||
env | sort > $TMPFILE
|
|
||||||
|
|
||||||
OVERRIDE_ORG="1"
|
|
||||||
. ./scripts/envVar.sh
|
|
||||||
|
|
||||||
parsePeerConnectionParameters 1 2
|
|
||||||
|
|
||||||
# set the fabric config path
|
|
||||||
export FABRIC_CFG_PATH="${DIR}/../../../config"
|
|
||||||
export PATH="${DIR}/../../../bin:${PWD}:$PATH"
|
|
||||||
|
|
||||||
env | sort | comm -1 -3 $TMPFILE - | sed -E 's/(.*)=(.*)/export \1="\2"/'
|
|
||||||
|
|
||||||
rm $TMPFILE
|
|
||||||
|
|
||||||
cd "${DIR}"
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
identity
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
target/
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
eclipse.preferences.version=1
|
|
||||||
encoding/<project>=UTF-8
|
|
||||||
encoding/src=UTF-8
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
activeProfiles=
|
|
||||||
eclipse.preferences.version=1
|
|
||||||
resolveWorkspaceProjects=true
|
|
||||||
version=1
|
|
||||||
|
|
@ -1,96 +0,0 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<groupId>commercial-paper</groupId>
|
|
||||||
<artifactId>commercial-paper</artifactId>
|
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
|
|
||||||
<!-- Generic properties -->
|
|
||||||
<java.version>1.8</java.version>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
|
||||||
|
|
||||||
<!-- fabric-chaincode-java -->
|
|
||||||
<fabric-chaincode-java.version>2.1.0</fabric-chaincode-java.version>
|
|
||||||
<!-- fabric-gateway-java -->
|
|
||||||
<fabric-gateway-java.version>2.1.0</fabric-gateway-java.version>
|
|
||||||
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<sourceDirectory>src</sourceDirectory>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>3.8.0</version>
|
|
||||||
<configuration>
|
|
||||||
<source>1.8</source>
|
|
||||||
<target>1.8</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<version>3.2.0</version>
|
|
||||||
<executions>
|
|
||||||
<!-- Attach the shade goal into the package phase -->
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>shade</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
|
||||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
|
||||||
<filters>
|
|
||||||
<filter>
|
|
||||||
<artifact>*:*</artifact>
|
|
||||||
<excludes>
|
|
||||||
<exclude>META-INF/*.SF</exclude>
|
|
||||||
<exclude>META-INF/*.DSA</exclude>
|
|
||||||
<exclude>META-INF/*.RSA</exclude>
|
|
||||||
</excludes>
|
|
||||||
</filter>
|
|
||||||
</filters>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>jitpack.io</id>
|
|
||||||
<url>https://jitpack.io</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.hyperledger.fabric</groupId>
|
|
||||||
<artifactId>fabric-gateway-java</artifactId>
|
|
||||||
<version>${fabric-gateway-java.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Used for datatype annotations only -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.hyperledger.fabric-chaincode-java</groupId>
|
|
||||||
<artifactId>fabric-chaincode-shim</artifactId>
|
|
||||||
<version>${fabric-chaincode-java.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.json/json -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.json</groupId>
|
|
||||||
<artifactId>json</artifactId>
|
|
||||||
<version>20180813</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
||||||
/*
|
|
||||||
SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.magnetocorp;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.security.InvalidKeyException;
|
|
||||||
import java.security.PrivateKey;
|
|
||||||
import java.security.cert.CertificateException;
|
|
||||||
import java.security.cert.X509Certificate;
|
|
||||||
import org.hyperledger.fabric.gateway.Identities;
|
|
||||||
import org.hyperledger.fabric.gateway.Wallet;
|
|
||||||
import org.hyperledger.fabric.gateway.Wallets;
|
|
||||||
import org.hyperledger.fabric.gateway.Identity;
|
|
||||||
|
|
||||||
public class AddToWallet {
|
|
||||||
|
|
||||||
private static X509Certificate readX509Certificate(final Path certificatePath) throws IOException, CertificateException {
|
|
||||||
try (Reader certificateReader = Files.newBufferedReader(certificatePath, StandardCharsets.UTF_8)) {
|
|
||||||
return Identities.readX509Certificate(certificateReader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static PrivateKey getPrivateKey(final Path privateKeyPath) throws IOException, InvalidKeyException {
|
|
||||||
try (Reader privateKeyReader = Files.newBufferedReader(privateKeyPath, StandardCharsets.UTF_8)) {
|
|
||||||
return Identities.readPrivateKey(privateKeyReader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
try {
|
|
||||||
// A wallet stores a collection of identities
|
|
||||||
Path walletPath = Paths.get(".", "wallet");
|
|
||||||
Wallet wallet = Wallets.newFileSystemWallet(walletPath);
|
|
||||||
|
|
||||||
Path credentialPath = Paths.get("..", "..", "..",".." ,"test-network", "organizations",
|
|
||||||
"peerOrganizations", "org2.example.com", "users", "User1@org2.example.com", "msp");
|
|
||||||
System.out.println("credentialPath: " + credentialPath.toString());
|
|
||||||
Path certificatePath = credentialPath.resolve(Paths.get("signcerts",
|
|
||||||
"User1@org2.example.com-cert.pem"));
|
|
||||||
System.out.println("certificatePem: " + certificatePath.toString());
|
|
||||||
Path privateKeyPath = credentialPath.resolve(Paths.get("keystore",
|
|
||||||
"priv_sk"));
|
|
||||||
|
|
||||||
X509Certificate certificate = readX509Certificate(certificatePath);
|
|
||||||
PrivateKey privateKey = getPrivateKey(privateKeyPath);
|
|
||||||
|
|
||||||
Identity identity = Identities.newX509Identity("Org2MSP", certificate, privateKey);
|
|
||||||
|
|
||||||
|
|
||||||
String identityLabel = "User1@org2.example.com";
|
|
||||||
wallet.put(identityLabel, identity);
|
|
||||||
|
|
||||||
System.out.println("Write wallet info into " + walletPath.toString() + " successfully.");
|
|
||||||
|
|
||||||
} catch (IOException | CertificateException | InvalidKeyException e) {
|
|
||||||
System.err.println("Error adding to wallet");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,75 +0,0 @@
|
||||||
/*
|
|
||||||
SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.magnetocorp;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
|
|
||||||
import org.hyperledger.fabric.gateway.Contract;
|
|
||||||
import org.hyperledger.fabric.gateway.Gateway;
|
|
||||||
import org.hyperledger.fabric.gateway.GatewayException;
|
|
||||||
import org.hyperledger.fabric.gateway.Network;
|
|
||||||
import org.hyperledger.fabric.gateway.Wallet;
|
|
||||||
import org.hyperledger.fabric.gateway.Wallets;
|
|
||||||
import org.papernet.CommercialPaper;
|
|
||||||
|
|
||||||
public class Issue {
|
|
||||||
|
|
||||||
private static final String ENVKEY="CONTRACT_NAME";
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
|
|
||||||
String contractName="papercontract";
|
|
||||||
// get the name of the contract, in case it is overridden
|
|
||||||
Map<String,String> envvar = System.getenv();
|
|
||||||
if (envvar.containsKey(ENVKEY)){
|
|
||||||
contractName=envvar.get(ENVKEY);
|
|
||||||
}
|
|
||||||
|
|
||||||
Gateway.Builder builder = Gateway.createBuilder();
|
|
||||||
|
|
||||||
try {
|
|
||||||
// A wallet stores a collection of identities
|
|
||||||
Path walletPath = Paths.get(".", "wallet");
|
|
||||||
Wallet wallet = Wallets.newFileSystemWallet(walletPath);
|
|
||||||
System.out.println("Read wallet info from: " + walletPath.toString());
|
|
||||||
|
|
||||||
String userName = "User1@org2.example.com";
|
|
||||||
|
|
||||||
Path connectionProfile = Paths.get("..", "gateway", "connection-org2.yaml");
|
|
||||||
|
|
||||||
// Set connection options on the gateway builder
|
|
||||||
builder.identity(wallet, userName).networkConfig(connectionProfile).discovery(false);
|
|
||||||
|
|
||||||
// Connect to gateway using application specified parameters
|
|
||||||
try(Gateway gateway = builder.connect()) {
|
|
||||||
|
|
||||||
// Access PaperNet network
|
|
||||||
System.out.println("Use network channel: mychannel.");
|
|
||||||
Network network = gateway.getNetwork("mychannel");
|
|
||||||
|
|
||||||
// Get addressability to commercial paper contract
|
|
||||||
System.out.println("Use org.papernet.commercialpaper smart contract.");
|
|
||||||
Contract contract = network.getContract(contractName, "org.papernet.commercialpaper");
|
|
||||||
|
|
||||||
// Issue commercial paper
|
|
||||||
System.out.println("Submit commercial paper issue transaction.");
|
|
||||||
byte[] response = contract.submitTransaction("issue", "MagnetoCorp", "00001", "2020-05-31", "2020-11-30", "5000000");
|
|
||||||
|
|
||||||
// Process response
|
|
||||||
System.out.println("Process issue transaction response.");
|
|
||||||
CommercialPaper paper = CommercialPaper.deserialize(response);
|
|
||||||
System.out.println(paper);
|
|
||||||
}
|
|
||||||
} catch (GatewayException | IOException | TimeoutException | InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
System.exit(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
/*
|
|
||||||
SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
env: {
|
|
||||||
node: true,
|
|
||||||
mocha: true
|
|
||||||
},
|
|
||||||
parserOptions: {
|
|
||||||
ecmaVersion: 8,
|
|
||||||
sourceType: 'script'
|
|
||||||
},
|
|
||||||
extends: "eslint:recommended",
|
|
||||||
rules: {
|
|
||||||
indent: ['error', 4],
|
|
||||||
'linebreak-style': ['error', 'unix'],
|
|
||||||
quotes: ['error', 'single'],
|
|
||||||
semi: ['error', 'always'],
|
|
||||||
'no-unused-vars': ['error', { args: 'none' }],
|
|
||||||
'no-console': 'off',
|
|
||||||
curly: 'error',
|
|
||||||
eqeqeq: 'error',
|
|
||||||
'no-throw-literal': 'error',
|
|
||||||
strict: 'error',
|
|
||||||
'no-var': 'error',
|
|
||||||
'dot-notation': 'error',
|
|
||||||
'no-tabs': 'error',
|
|
||||||
'no-trailing-spaces': 'error',
|
|
||||||
'no-use-before-define': 'error',
|
|
||||||
'no-useless-call': 'error',
|
|
||||||
'no-with': 'error',
|
|
||||||
'operator-linebreak': 'error',
|
|
||||||
yoda: 'error',
|
|
||||||
'quote-props': ['error', 'as-needed']
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
node_modules
|
|
||||||
|
|
@ -1,55 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright IBM Corp. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
// Bring key classes into scope, most importantly Fabric SDK network class
|
|
||||||
const fs = require('fs');
|
|
||||||
const { Wallets } = require('fabric-network');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const fixtures = path.resolve(__dirname, '../../../../test-network');
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
|
|
||||||
// Main try/catch block
|
|
||||||
try {
|
|
||||||
// A wallet stores a collection of identities
|
|
||||||
const wallet = await Wallets.newFileSystemWallet('../identity/user/isabella/wallet');
|
|
||||||
|
|
||||||
// Identity to credentials to be stored in the wallet
|
|
||||||
const credPath = path.join(fixtures, '/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com');
|
|
||||||
const certificate = fs.readFileSync(path.join(credPath, '/msp/signcerts/User1@org2.example.com-cert.pem')).toString();
|
|
||||||
const privateKey = fs.readFileSync(path.join(credPath, '/msp/keystore/priv_sk')).toString();
|
|
||||||
|
|
||||||
// Load credentials into wallet
|
|
||||||
const identityLabel = 'isabella';
|
|
||||||
|
|
||||||
const identity = {
|
|
||||||
credentials: {
|
|
||||||
certificate,
|
|
||||||
privateKey
|
|
||||||
},
|
|
||||||
mspId: 'Org2MSP',
|
|
||||||
type: 'X.509'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
await wallet.put(identityLabel,identity);
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
console.log(`Error adding to wallet. ${error}`);
|
|
||||||
console.log(error.stack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
main().then(() => {
|
|
||||||
console.log('done');
|
|
||||||
}).catch((e) => {
|
|
||||||
console.log(e);
|
|
||||||
console.log(e.stack);
|
|
||||||
process.exit(-1);
|
|
||||||
});
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright IBM Corp. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const FabricCAServices = require('fabric-ca-client');
|
|
||||||
const { Wallets } = require('fabric-network');
|
|
||||||
const fs = require('fs');
|
|
||||||
const yaml = require('js-yaml');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
try {
|
|
||||||
// load the network configuration
|
|
||||||
let connectionProfile = yaml.safeLoad(fs.readFileSync('../gateway/connection-org2.yaml', 'utf8'));
|
|
||||||
|
|
||||||
// Create a new CA client for interacting with the CA.
|
|
||||||
const caInfo = connectionProfile.certificateAuthorities['ca.org2.example.com'];
|
|
||||||
const caTLSCACerts = caInfo.tlsCACerts.pem;
|
|
||||||
const ca = new FabricCAServices(caInfo.url, { trustedRoots: caTLSCACerts, verify: false }, caInfo.caName);
|
|
||||||
|
|
||||||
// Create a new file system based wallet for managing identities.
|
|
||||||
const walletPath = path.join(process.cwd(), '../identity/user/isabella/wallet');
|
|
||||||
const wallet = await Wallets.newFileSystemWallet(walletPath);
|
|
||||||
console.log(`Wallet path: ${walletPath}`);
|
|
||||||
|
|
||||||
// Check to see if we've already enrolled the admin user.
|
|
||||||
const userExists = await wallet.get('isabella');
|
|
||||||
if (userExists) {
|
|
||||||
console.log('An identity for the client user "user1" already exists in the wallet');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enroll the admin user, and import the new identity into the wallet.
|
|
||||||
const enrollment = await ca.enroll({ enrollmentID: 'user1', enrollmentSecret: 'user1pw' });
|
|
||||||
const x509Identity = {
|
|
||||||
credentials: {
|
|
||||||
certificate: enrollment.certificate,
|
|
||||||
privateKey: enrollment.key.toBytes(),
|
|
||||||
},
|
|
||||||
mspId: 'Org2MSP',
|
|
||||||
type: 'X.509',
|
|
||||||
};
|
|
||||||
await wallet.put('isabella', x509Identity);
|
|
||||||
console.log('Successfully enrolled client user "isabella" and imported it into the wallet');
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
console.error(`Failed to enroll client user "isabella": ${error}`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
main();
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
{
|
|
||||||
"name": "nodejs",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "",
|
|
||||||
"main": "issue.js",
|
|
||||||
"scripts": {
|
|
||||||
"test": "rm -rf _idwallet && node addToWallet.js && node issue.js"
|
|
||||||
},
|
|
||||||
"keywords": [],
|
|
||||||
"author": "",
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"dependencies": {
|
|
||||||
"fabric-network": "^2.2.4",
|
|
||||||
"fabric-ca-client": "^2.2.4",
|
|
||||||
"js-yaml": "^3.12.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"eslint": "^5.6.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
#
|
|
||||||
# Copyright IBM Corp All Rights Reserved
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
version: '2'
|
|
||||||
|
|
||||||
networks:
|
|
||||||
basic:
|
|
||||||
external:
|
|
||||||
name: fabric_test
|
|
||||||
|
|
||||||
services:
|
|
||||||
cliMagnetoCorp:
|
|
||||||
container_name: cliMagnetoCorp
|
|
||||||
image: hyperledger/fabric-tools:2.0.0-beta
|
|
||||||
tty: true
|
|
||||||
environment:
|
|
||||||
- GOPATH=/opt/gopath
|
|
||||||
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
|
|
||||||
- FABRIC_LOGGING_SPEC=info
|
|
||||||
- CORE_PEER_ID=cli
|
|
||||||
- CORE_PEER_ADDRESS=peer0.org2.example.com:9051
|
|
||||||
- CORE_PEER_LOCALMSPID=Org2MSP
|
|
||||||
- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
|
|
||||||
- CORE_CHAINCODE_KEEPALIVE=10
|
|
||||||
- CORE_PEER_TLS_ENABLED=true
|
|
||||||
- CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
|
|
||||||
- ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
|
|
||||||
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
|
|
||||||
command: /bin/bash
|
|
||||||
volumes:
|
|
||||||
- /var/run/docker.sock:/host/var/run/docker.sock
|
|
||||||
- ./../../../../organization/magnetocorp:/opt/gopath/src/github.com/
|
|
||||||
- ./../../../../../test-network/organizations:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
|
|
||||||
networks:
|
|
||||||
- test
|
|
||||||
31
commercial-paper/organization/magnetocorp/configuration/cli/monitordocker.sh
Executable file → Normal file
31
commercial-paper/organization/magnetocorp/configuration/cli/monitordocker.sh
Executable file → Normal file
|
|
@ -1,31 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# This script uses the logspout and http stream tools to let you watch the docker containers
|
|
||||||
# in action.
|
|
||||||
#
|
|
||||||
# More information at https://github.com/gliderlabs/logspout/tree/master/httpstream
|
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
|
||||||
DOCKER_NETWORK=fabric_test
|
|
||||||
else
|
|
||||||
DOCKER_NETWORK="$1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$2" ]; then
|
|
||||||
PORT=8000
|
|
||||||
else
|
|
||||||
PORT="$2"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo Starting monitoring on all containers on the network ${DOCKER_NETWORK}
|
|
||||||
|
|
||||||
docker kill logspout 2> /dev/null 1>&2 || true
|
|
||||||
docker rm logspout 2> /dev/null 1>&2 || true
|
|
||||||
|
|
||||||
docker run -d --name="logspout" \
|
|
||||||
--volume=/var/run/docker.sock:/var/run/docker.sock \
|
|
||||||
--publish=127.0.0.1:${PORT}:80 \
|
|
||||||
--network ${DOCKER_NETWORK} \
|
|
||||||
gliderlabs/logspout
|
|
||||||
sleep 3
|
|
||||||
curl http://127.0.0.1:${PORT}/logs
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
/*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
plugins {
|
|
||||||
id 'com.github.johnrengelman.shadow' version '5.1.0'
|
|
||||||
id 'java'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
version '0.0.1'
|
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
maven {
|
|
||||||
url 'https://jitpack.io'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '2.+'
|
|
||||||
implementation group: 'org.json', name: 'json', version: '20180813'
|
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2'
|
|
||||||
testImplementation 'org.assertj:assertj-core:3.11.1'
|
|
||||||
testImplementation 'org.mockito:mockito-core:2.+'
|
|
||||||
}
|
|
||||||
|
|
||||||
test {
|
|
||||||
useJUnitPlatform()
|
|
||||||
testLogging {
|
|
||||||
events "passed", "skipped", "failed"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
shadowJar {
|
|
||||||
baseName = 'chaincode'
|
|
||||||
version = null
|
|
||||||
classifier = null
|
|
||||||
|
|
||||||
manifest {
|
|
||||||
attributes 'Main-Class': 'org.hyperledger.fabric.contract.ContractRouter'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
|
||||||
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" << "-parameters"
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
|
@ -1,5 +0,0 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
|
||||||
distributionPath=wrapper/dists
|
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
|
||||||
zipStorePath=wrapper/dists
|
|
||||||
188
commercial-paper/organization/magnetocorp/contract-java/gradlew
vendored
Executable file → Normal file
188
commercial-paper/organization/magnetocorp/contract-java/gradlew
vendored
Executable file → Normal file
|
|
@ -1,188 +0,0 @@
|
||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
#
|
|
||||||
# Copyright 2015 the original author or authors.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
##
|
|
||||||
## Gradle start up script for UN*X
|
|
||||||
##
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
|
||||||
# Resolve links: $0 may be a link
|
|
||||||
PRG="$0"
|
|
||||||
# Need this for relative symlinks.
|
|
||||||
while [ -h "$PRG" ] ; do
|
|
||||||
ls=`ls -ld "$PRG"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
PRG="$link"
|
|
||||||
else
|
|
||||||
PRG=`dirname "$PRG"`"/$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
SAVED="`pwd`"
|
|
||||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
|
||||||
APP_HOME="`pwd -P`"
|
|
||||||
cd "$SAVED" >/dev/null
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=`basename "$0"`
|
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
||||||
MAX_FD="maximum"
|
|
||||||
|
|
||||||
warn () {
|
|
||||||
echo "$*"
|
|
||||||
}
|
|
||||||
|
|
||||||
die () {
|
|
||||||
echo
|
|
||||||
echo "$*"
|
|
||||||
echo
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
|
||||||
cygwin=false
|
|
||||||
msys=false
|
|
||||||
darwin=false
|
|
||||||
nonstop=false
|
|
||||||
case "`uname`" in
|
|
||||||
CYGWIN* )
|
|
||||||
cygwin=true
|
|
||||||
;;
|
|
||||||
Darwin* )
|
|
||||||
darwin=true
|
|
||||||
;;
|
|
||||||
MINGW* )
|
|
||||||
msys=true
|
|
||||||
;;
|
|
||||||
NONSTOP* )
|
|
||||||
nonstop=true
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
|
||||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
|
||||||
else
|
|
||||||
JAVACMD="$JAVA_HOME/bin/java"
|
|
||||||
fi
|
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
location of your Java installation."
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
JAVACMD="java"
|
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
location of your Java installation."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
|
||||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
|
||||||
if [ $? -eq 0 ] ; then
|
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
|
||||||
MAX_FD="$MAX_FD_LIMIT"
|
|
||||||
fi
|
|
||||||
ulimit -n $MAX_FD
|
|
||||||
if [ $? -ne 0 ] ; then
|
|
||||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Darwin, add options to specify how the application appears in the dock
|
|
||||||
if $darwin; then
|
|
||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
||||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
|
||||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
|
||||||
SEP=""
|
|
||||||
for dir in $ROOTDIRSRAW ; do
|
|
||||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
|
||||||
SEP="|"
|
|
||||||
done
|
|
||||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
|
||||||
# Add a user-defined pattern to the cygpath arguments
|
|
||||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
|
||||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
|
||||||
fi
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
||||||
i=0
|
|
||||||
for arg in "$@" ; do
|
|
||||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
|
||||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
|
||||||
|
|
||||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
|
||||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
|
||||||
else
|
|
||||||
eval `echo args$i`="\"$arg\""
|
|
||||||
fi
|
|
||||||
i=$((i+1))
|
|
||||||
done
|
|
||||||
case $i in
|
|
||||||
(0) set -- ;;
|
|
||||||
(1) set -- "$args0" ;;
|
|
||||||
(2) set -- "$args0" "$args1" ;;
|
|
||||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
|
||||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
|
||||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
|
||||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
|
||||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
|
||||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
|
||||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Escape application args
|
|
||||||
save () {
|
|
||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
|
||||||
echo " "
|
|
||||||
}
|
|
||||||
APP_ARGS=$(save "$@")
|
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
|
||||||
|
|
||||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
|
||||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
|
||||||
cd "$(dirname "$0")"
|
|
||||||
fi
|
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
|
||||||
|
|
@ -1,100 +0,0 @@
|
||||||
@rem
|
|
||||||
@rem Copyright 2015 the original author or authors.
|
|
||||||
@rem
|
|
||||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
@rem you may not use this file except in compliance with the License.
|
|
||||||
@rem You may obtain a copy of the License at
|
|
||||||
@rem
|
|
||||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
@rem
|
|
||||||
@rem Unless required by applicable law or agreed to in writing, software
|
|
||||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
@rem See the License for the specific language governing permissions and
|
|
||||||
@rem limitations under the License.
|
|
||||||
@rem
|
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
|
||||||
@rem ##########################################################################
|
|
||||||
@rem
|
|
||||||
@rem Gradle startup script for Windows
|
|
||||||
@rem
|
|
||||||
@rem ##########################################################################
|
|
||||||
|
|
||||||
@rem Set local scope for the variables with windows NT shell
|
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
|
||||||
set APP_BASE_NAME=%~n0
|
|
||||||
set APP_HOME=%DIRNAME%
|
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
|
||||||
|
|
||||||
@rem Find java.exe
|
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
|
||||||
if "%ERRORLEVEL%" == "0" goto init
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
||||||
echo.
|
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
echo location of your Java installation.
|
|
||||||
|
|
||||||
goto fail
|
|
||||||
|
|
||||||
:findJavaFromJavaHome
|
|
||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto init
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
|
||||||
echo.
|
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
echo location of your Java installation.
|
|
||||||
|
|
||||||
goto fail
|
|
||||||
|
|
||||||
:init
|
|
||||||
@rem Get command-line arguments, handling Windows variants
|
|
||||||
|
|
||||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
|
||||||
|
|
||||||
:win9xME_args
|
|
||||||
@rem Slurp the command line arguments.
|
|
||||||
set CMD_LINE_ARGS=
|
|
||||||
set _SKIP=2
|
|
||||||
|
|
||||||
:win9xME_args_slurp
|
|
||||||
if "x%~1" == "x" goto execute
|
|
||||||
|
|
||||||
set CMD_LINE_ARGS=%*
|
|
||||||
|
|
||||||
:execute
|
|
||||||
@rem Setup the command line
|
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
|
||||||
|
|
||||||
:end
|
|
||||||
@rem End local scope for the variables with windows NT shell
|
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
|
||||||
|
|
||||||
:fail
|
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
|
||||||
rem the _cmd.exe /c_ return code!
|
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
|
||||||
exit /b 1
|
|
||||||
|
|
||||||
:mainEnd
|
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
|
||||||
|
|
||||||
:omega
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
rootProject.name = 'papercontract'
|
|
||||||
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
package org.example;
|
|
||||||
|
|
||||||
import org.hyperledger.fabric.contract.Context;
|
|
||||||
import org.hyperledger.fabric.shim.ChaincodeStub;
|
|
||||||
|
|
||||||
class CommercialPaperContext extends Context {
|
|
||||||
|
|
||||||
public CommercialPaperContext(ChaincodeStub stub) {
|
|
||||||
super(stub);
|
|
||||||
this.paperList = new PaperList(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PaperList paperList;
|
|
||||||
|
|
||||||
}
|
|
||||||
16
commercial-paper/organization/magnetocorp/contract/.editorconfig
Executable file → Normal file
16
commercial-paper/organization/magnetocorp/contract/.editorconfig
Executable file → Normal file
|
|
@ -1,16 +0,0 @@
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
root = true
|
|
||||||
|
|
||||||
[*]
|
|
||||||
indent_style = space
|
|
||||||
indent_size = 4
|
|
||||||
end_of_line = lf
|
|
||||||
charset = utf-8
|
|
||||||
trim_trailing_whitespace = true
|
|
||||||
insert_final_newline = true
|
|
||||||
|
|
||||||
[*.md]
|
|
||||||
trim_trailing_whitespace = false
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
coverage
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
/*
|
|
||||||
SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
env: {
|
|
||||||
node: true,
|
|
||||||
mocha: true
|
|
||||||
},
|
|
||||||
parserOptions: {
|
|
||||||
ecmaVersion: 8,
|
|
||||||
sourceType: 'script'
|
|
||||||
},
|
|
||||||
extends: "eslint:recommended",
|
|
||||||
rules: {
|
|
||||||
indent: ['error', 4],
|
|
||||||
'linebreak-style': ['error', 'unix'],
|
|
||||||
quotes: ['error', 'single'],
|
|
||||||
semi: ['error', 'always'],
|
|
||||||
'no-unused-vars': ['error', { args: 'none' }],
|
|
||||||
'no-console': 'off',
|
|
||||||
curly: 'error',
|
|
||||||
eqeqeq: 'error',
|
|
||||||
'no-throw-literal': 'error',
|
|
||||||
strict: 'error',
|
|
||||||
'no-var': 'error',
|
|
||||||
'dot-notation': 'error',
|
|
||||||
'no-tabs': 'error',
|
|
||||||
'no-trailing-spaces': 'error',
|
|
||||||
'no-use-before-define': 'error',
|
|
||||||
'no-useless-call': 'error',
|
|
||||||
'no-with': 'error',
|
|
||||||
'operator-linebreak': 'error',
|
|
||||||
yoda: 'error',
|
|
||||||
'quote-props': ['error', 'as-needed']
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright IBM Corp. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const cpcontract = require('./lib/papercontract.js');
|
|
||||||
module.exports.contracts = [cpcontract];
|
|
||||||
38
commercial-paper/organization/magnetocorp/magnetocorp.sh
Executable file → Normal file
38
commercial-paper/organization/magnetocorp/magnetocorp.sh
Executable file → Normal file
|
|
@ -1,38 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
TMPFILE=`mktemp`
|
|
||||||
shopt -s extglob
|
|
||||||
|
|
||||||
function _exit(){
|
|
||||||
printf "Exiting:%s\n" "$1"
|
|
||||||
exit -1
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
: ${CHANNEL_NAME:="mychannel"}
|
|
||||||
: ${DELAY:="3"}
|
|
||||||
: ${MAX_RETRY:="5"}
|
|
||||||
: ${VERBOSE:="false"}
|
|
||||||
|
|
||||||
# Where am I?
|
|
||||||
DIR=${PWD}
|
|
||||||
|
|
||||||
# Locate the test-network
|
|
||||||
cd "${DIR}/../../../test-network"
|
|
||||||
env | sort > $TMPFILE
|
|
||||||
|
|
||||||
OVERRIDE_ORG="2"
|
|
||||||
. ./scripts/envVar.sh
|
|
||||||
|
|
||||||
|
|
||||||
parsePeerConnectionParameters 1 2
|
|
||||||
|
|
||||||
# set the fabric config path
|
|
||||||
export FABRIC_CFG_PATH="${DIR}/../../../config"
|
|
||||||
export PATH="${DIR}/../../../bin:${PWD}:$PATH"
|
|
||||||
|
|
||||||
env | sort | comm -1 -3 $TMPFILE - | sed -E 's/(.*)=(.*)/export \1="\2"/'
|
|
||||||
rm $TMPFILE
|
|
||||||
|
|
||||||
cd "${DIR}"
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
console.log(process.argv);
|
|
||||||
Loading…
Reference in a new issue