Skip to content

Commit

Permalink
refactor(examples): include sample apps in monorepo build
Browse files Browse the repository at this point in the history
- Include discounted-cartrade and electricity trade in monorepo setup,
- Update the devcontainer and include new environment setup instructions in BUILD.md,
- Fix sample apps build error,
- Rename of sample apps to cactus-example-*,
- Change any "car" references to "asset" (in code, comments, documentation, etc..),
- Rename asset-trade files to match the format of the rest of this repository.
- Remove asset-trade eth asset management class and endpoint
  (not used right now, and it would confuse with fabric asset).
- Renamed some uses of cartrade to asset-trade,
  (more complete changes are included in follow-up commit),
- Add indy build artifacts to .gitignore,
- Add cmake to devcontainer build (fixed warning during npm dependency build stage),
- Fix random whitespace and typos errors,

BREAKING CHANGE: building discounted-asset-trade app (or any future app that use indy validator)
                 requires Indy SDK to be installed on the build machine.

Closes: 2029

Signed-off-by: Michal Bajer <michal.bajer@fujitsu.com>
  • Loading branch information
outSH committed Jul 14, 2022
1 parent 7c76438 commit 7ae332e
Show file tree
Hide file tree
Showing 112 changed files with 786 additions and 784 deletions.
2 changes: 1 addition & 1 deletion .dcilintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tools/docker/besu-all-in-one/supervisord.conf
docs/source/conf.py

# Cannot be edited due to configuration schema of third party software
examples/register-indy-data/req_discounted_cartrade.py
examples/register-indy-data/register-indy-data.py

# Cannot be edited due to configuration schema of third party software
tools/docker/indy-testnet/Dockerfile
Expand Down
17 changes: 16 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ RUN apt-get update \
RUN apt-get update \
&& apt-get -y install curl git mercurial make binutils bison gcc build-essential

# Install Indy-SDK
# Add Sovrin repository (only bionic release available, but works in recent ubuntu as well)
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CE7709D068DB5E88 \
&& add-apt-repository "deb https://repo.sovrin.org/sdk/deb bionic stable" \
# Install Indy SDK
&& apt-get update \
&& apt-get install -y \
libindy \
libnullpay \
libvcx \
indy-cli \
# Remove auto repo entry for focal release (use one from /etc/apt/sources.list)
&& rm -f /etc/apt/sources.list.d/sovrin.list* \
# Clean up
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts/

VOLUME [ "/var/lib/docker" ]

Expand All @@ -46,7 +61,7 @@ CMD [ "sleep", "infinity" ]

# [Optional] Uncomment this section to install additional OS packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends openjdk-11-jdk
&& apt-get -y install --no-install-recommends openjdk-11-jdk cmake

COPY post-create-commands.sh /home/vscode/bin/

Expand Down
20 changes: 16 additions & 4 deletions .github/workflows/.dast-nuclei-cmd-api-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ jobs:
nuclei-scan:
runs-on: ubuntu-20.04
steps:
- name: Install Indy SDK
run: >
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CE7709D068DB5E88 \
&& sudo add-apt-repository "deb https://repo.sovrin.org/sdk/deb bionic stable" \
&& sudo apt-get update \
&& sudo apt-get install -y \
libindy \
libnullpay \
libvcx \
indy-cli \
&& sudo rm -f /etc/apt/sources.list.d/sovrin.list*
- name: Set up NodeJS v16.9.1
uses: actions/setup-node@v2.1.2
with:
Expand All @@ -27,7 +39,7 @@ jobs:
- uses: actions/setup-go@v3.0.0
with:
go-version: 1.17

- run: go install -v github.com/projectdiscovery/nuclei/v2/cmd/nuclei@v2.6.3

- run: nuclei --version
Expand Down Expand Up @@ -72,7 +84,7 @@ jobs:

- name: Install Fabric connector into the API server
run: echo "$(jq '.plugins += [{"packageName":"@hyperledger/cactus-plugin-ledger-connector-fabric", "type":"org.hyperledger.cactus.plugin_import_type.LOCAL", "action":"org.hyperledger.cactus.plugin_import_action.INSTALL", "options":{"instanceId":"some-unique-fabric-connector-instance-id", "peerBinary":"/fabric-samples/bin/peer", "connectionProfile":"{}", "dockerBinary":"usr/local/bin/docker","cliContainerEnv":{"CORE_PEER_LOCALMSPID":"Org1MSP","CORE_PEER_ADDRESS":"peer0.org1.example.com:7051","CORE_PEER_MSPCONFIGPATH":"/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp","CORE_PEER_TLS_ROOTCERT_FILE":"/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt","ORDERER_TLS_ROOTCERT_FILE":"/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem"},"discoveryOptions":{"enabled":true,"asLocalhost":true}}}] ' .config.json)" > .config.json

- name: Install Besu connector into the API server
run: echo "$(jq '.plugins += [{"packageName":"@hyperledger/cactus-plugin-ledger-connector-besu","type":"org.hyperledger.cactus.plugin_import_type.LOCAL","action":"org.hyperledger.cactus.plugin_import_action.INSTALL","options":{"rpcApiHttpHost":"http://localhost:8545", "rpcApiWsHost":"ws://localhost:8546", "instanceId":"some-unique-besu-connector-instance-id"}}]' .config.json)" > .config.json

Expand All @@ -91,7 +103,7 @@ jobs:
# && echo -e " project-name: \"${GITHUB_REPOSITORY#*/}\"" >> ~/nuclei-github-config.yaml \
# && echo -e " issue-label: \"Nuclei\"" >> ~/nuclei-github-config.yaml \
# && echo "githubconfig=-rc ~/nuclei-github-config.yaml" >> $GITHUB_ENV

# shell: bash

# - run: ls -alt
Expand All @@ -102,7 +114,7 @@ jobs:
# Needed because the wait-on syntax otherwise keeps thinking that
# there is a problem due to our self signed certificates on the
# test instance of the API server
NODE_TLS_REJECT_UNAUTHORIZED: 0
NODE_TLS_REJECT_UNAUTHORIZED: 0
with:
build: yarn --version
start: yarn start:api-server
Expand Down
25 changes: 14 additions & 11 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ The `npm run watch` script in action:
![Fast Developer Flow / Code Iterations](./docs/hyperledger-cactus-watch-script-tutorial-2021-03-06.gif)

## Getting Started

* Install OS level dependencies:
* Use preset environment:
* [VSCode docker container](./.devcontainer)
* ... or install OS level dependencies manually:
* Windows Only
* WSL2 or any virtual machine running Ubuntu 20.04 LTS
* Git
Expand All @@ -98,13 +99,15 @@ The `npm run watch` script in action:
nvm install 16.14.2
nvm use 16.14.2
```
* Yarn
* Yarn
* `npm run install-yarn` (from within the project directory)
* [Docker Engine](https://docs.docker.com/engine/install/ubuntu/). Make sure that Docker is working and running, for example, running ``docker ps -aq``
* Docker Compose
* [Docker Engine](https://docs.docker.com/engine/install/ubuntu/). Make sure that Docker is working and running, for example, running ``docker ps -aq``
* Docker Compose
* OpenJDK (Corda support Java 8 JDK but do not currently support Java 9 or higher)
* `sudo apt install openjdk-8-jdk-headless`
* Indy SDK
* [Installing the SDK](https://github.com/hyperledger/indy-sdk#installing-the-sdk)
* [Build the SDK from source](https://github.com/hyperledger/indy-sdk#how-to-build-indy-sdk-from-source)
* Clone the repository
Expand Down Expand Up @@ -220,16 +223,16 @@ the following decision tree (and keep in mind that we have `npm run watch` too)
## Configuring SSH to use upterm
Upload your public key onto github if not done so already. A public key is necessary to join the ssh connection to use upterm. For a comprehensive guide, see the [Generating a new SSH key and adding it to the ssh-agent](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent).

Locate the `ci.yml` within `.github/workflows` and add to the `ci.yml` code listed below:
Locate the `ci.yml` within `.github/workflows` and add to the `ci.yml` code listed below:
- name: Setup upterm session
uses: lhotari/action-upterm@v1
with:
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

Keep in mind that the SSH upterm session should come after the checkout step (uses: actions/checkout@v2.3.4) to ensure that the CI doesn't hang without before the debugging step occurs. Editing the `ci.yml` will create a new upterm session within `.github/workflows` by adding a new build step. For more details, see the [Debug your GitHub Actions by using ssh](https://github.com/marketplace/actions/debugging-with-ssh).
Keep in mind that the SSH upterm session should come after the checkout step (uses: actions/checkout@v2.3.4) to ensure that the CI doesn't hang without before the debugging step occurs. Editing the `ci.yml` will create a new upterm session within `.github/workflows` by adding a new build step. For more details, see the [Debug your GitHub Actions by using ssh](https://github.com/marketplace/actions/debugging-with-ssh).

By creating a PR for the edited `ci.yml` file, this will the CI to run their tests. There are two ways to navigate to CIs.
By creating a PR for the edited `ci.yml` file, this will the CI to run their tests. There are two ways to navigate to CIs.
1) Go to the PR and click the `checks` tab
2) Go to the `Actions` tab within the main Hyperledger Cactus Repository

Click on the `CI Cactus workflow`. There should be a new job you've created be listed underneath the `build (ubuntu-20.04)` jobs. Click on the the new job (what's you've named your build) and locate the SSH Session within the `Setup Upterm Session` dropdown. Copy the SSH command that start with `ssh` and ends in `.dev` (ex. ssh **********:***********@uptermd.upterm.dev). Open your OS and paste the SSH command script in order to begin an upterm session.
Click on the `CI Cactus workflow`. There should be a new job you've created be listed underneath the `build (ubuntu-20.04)` jobs. Click on the the new job (what's you've named your build) and locate the SSH Session within the `Setup Upterm Session` dropdown. Copy the SSH command that start with `ssh` and ends in `.dev` (ex. ssh **********:***********@uptermd.upterm.dev). Open your OS and paste the SSH command script in order to begin an upterm session.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ As blockchain technology proliferates, blockchain integration will become an inc

Once the last command has finished executing, open link printed on the console with a web browser of your choice

### Discounted Car Trade Example
### Discounted Asset Trade Example

- The guidance is [here](./examples/discounted-cartrade/README.md).
- The guidance is [here](./examples/cactus-example-discounted-asset-trade/README.md).

### Electricity Trade Example

- The guidance is [here](./examples/electricity-trade/README.md).
- The guidance is [here](./examples/cactus-example-electricity-trade/README.md).


## Documentation
Expand All @@ -62,8 +62,8 @@ Once the last command has finished executing, open link printed on the console w

## Inclusive Language Statement

These guiding principles are very important to the maintainers and therefore
we respectfully ask all contributors to abide by them as well:
These guiding principles are very important to the maintainers and therefore
we respectfully ask all contributors to abide by them as well:

- Consider that users who will read the docs are from different backgrounds and
cultures and that they have different preferences.
Expand All @@ -73,9 +73,9 @@ deny list" to "white list and black list".
writing inclusive documentation might not look like a huge improvement, it's a
first step in the right direction.
- We suggest to refer to
[Microsoft bias free writing guidelines](https://docs.microsoft.com/en-us/style-guide/bias-free-communication)
and
[Google inclusive doc writing guide](https://developers.google.com/style/inclusive-documentation)
[Microsoft bias free writing guidelines](https://docs.microsoft.com/en-us/style-guide/bias-free-communication)
and
[Google inclusive doc writing guide](https://developers.google.com/style/inclusive-documentation)
as starting points.
## Roadmap
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# BLP artifacts
TransactionInfo.json
transaction-Info.json
etc/

# don't commit package-lock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ FROM cactus-cmd-socketio-server:latest

ARG NPM_PKG_VERSION=latest

ENV CARTRADE_HOME=/root/cactus
ENV APP_HOME=/root/cactus

WORKDIR ${CARTRADE_HOME}
WORKDIR ${APP_HOME}

# Required by indy-sdk
RUN apt-get update \
Expand Down
Loading

0 comments on commit 7ae332e

Please sign in to comment.