Fixed build errors, added protos-rs publish action, updated tutorial instructions #491
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a basic workflow to help you get started with Actions | |
name: Test Asset Exchange Besu | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push or pull request events but only for the main branch | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
asset-exchange-besu: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
app_contract: ["AliceERC1155", "AliceERC20", "AliceERC721"] | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/[email protected] | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'adopt' | |
- name: Use Node.js 16.x | |
uses: actions/[email protected] | |
with: | |
node-version: 16.x | |
- name: Use Protoc 3.15 | |
run: | | |
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.15.6/protoc-3.15.6-linux-x86_64.zip | |
unzip protoc-3.15.6-linux-x86_64.zip -d protoc | |
# PROTOS | |
- name: Build Solidity Protos | |
run: | | |
export PATH="$PATH:${GITHUB_WORKSPACE}/protoc/bin" | |
make build | |
working-directory: common/protos-sol | |
# BESU NETWORK | |
- name: Start Besu Network | |
run: | | |
sudo apt install -y tmux jq | |
wget https://hyperledger.jfrog.io/artifactory/besu-binaries/besu/22.7.0/besu-22.7.0.zip | |
unzip besu-22.7.0.zip | |
export PATH="${PWD}/besu-22.7.0/bin:$PATH" | |
wget https://artifacts.consensys.net/public/ethsigner/raw/names/ethsigner.zip/versions/22.1.3/ethsigner-22.1.3.zip | |
unzip ethsigner-22.1.3.zip | |
export PATH="${PWD}/ethsigner-22.1.3/bin:$PATH" | |
make start | |
sleep 100 | |
working-directory: tests/network-setups/besu | |
# Deploy contracts | |
- name: Deploy contracts | |
run: | | |
make deploy-contracts | |
working-directory: samples/besu/simpleasset | |
# BESU CLI | |
- name: Setup BESU CLI .npmrc | |
run: | | |
cp .npmrc.template .npmrc | |
sed -i "s/<personal-access-token>/${{ secrets.GITHUB_TOKEN }}/g" .npmrc | |
cat .npmrc | |
working-directory: samples/besu/besu-cli | |
- name: Setup BESU CLI init | |
run: | | |
make build | |
cp config.template.json tmp.json | |
cp config.template.json tmp.json | |
jq -r '.network1.tokenContract |= "../simpleasset/build/contracts/${{ matrix.app_contract }}.json"' tmp.json > config.json | |
cp config.json tmp.json | |
jq -r '.network2.tokenContract |= "../simpleasset/build/contracts/BobERC20.json"' tmp.json > config.json | |
rm tmp.json | |
working-directory: samples/besu/besu-cli | |
- name: Asset Exchange Besu CLI Tests | |
run: | | |
export PATH="${PWD}/bin:$PATH" | |
COUNT=0 | |
TOTAL=10 | |
# HTLC Params | |
timeout=1000 | |
hashBase64="ivHErp1x4bJDKuRo6L5bApO/DdoyD/dG0mAZrzLZEIs=" | |
preimage="secrettext" | |
# issue tokens to account 1 | |
initAmount=10 | |
transferAmount=5 | |
tokenId=0 | |
# & lock 5 token for account 2 in network 1 | |
if [ ${{ matrix.app_contract }} == "AliceERC20" ]; then | |
besu-cli asset issue --network=network1 --account=1 --amount=${initAmount} --asset_type=ERC20 | |
besu-cli asset lock --network=network1 --sender_account=1 --recipient_account=2 --amount=${transferAmount} --timeout=${timeout} --hash_base64=${hashBase64} 1> tmp.out | |
elif [ ${{ matrix.app_contract }} == "AliceERC1155" ]; then | |
besu-cli asset issue --network=network1 --account=1 --amount=${initAmount} --token_id=${tokenId} --token_data="" --asset_type=ERC1155 | |
besu-cli asset lock --network=network1 --sender_account=1 --recipient_account=2 --amount=${transferAmount} --token_id=${tokenId} --timeout=${timeout} --asset_type=ERC1155 --hash_base64=${hashBase64} 1> tmp.out | |
else | |
initAmount=1 | |
transferAmount=1 | |
besu-cli asset issue --network=network1 --account=1 --token_id=${tokenId} --asset_type=ERC721 1> tmp.out | |
tokenId=$(cat tmp.out | grep "New ERC721 token minted with id " | sed -e 's/New ERC721 token minted with id //') | |
cat tmp.out | |
echo $tokenId | |
besu-cli asset lock --network=network1 --sender_account=1 --recipient_account=2 --token_id=${tokenId} --asset_type=ERC721 --timeout=${timeout} --hash_base64=${hashBase64} 1> tmp.out | |
fi | |
balanceRem=$((initAmount-transferAmount)) | |
cat tmp.out | grep "Account balance of the sender in Network network1: ${initAmount} " && COUNT=$(( COUNT + 1 )) && echo "PASS" | |
cat tmp.out | grep "Account balance of the sender in Network network1: ${balanceRem}" && COUNT=$(( COUNT + 1 )) && echo "PASS" | |
cat tmp.out | grep "Account balance of the recipient in Network network1: 0" && COUNT=$(( COUNT + 1 )) && echo "PASS" | |
cat tmp.out | |
tmp_string=$(cat tmp.out | grep "Lock contract ID:") | |
arrIN=(${tmp_string//:/ }) | |
LOCK_ID=${arrIN[3]} | |
# Is Asset locked | |
besu-cli asset is-locked --network=network1 --lock_contract_id=$LOCK_ID 1> tmp.out | |
cat tmp.out | grep "in Network network1: true" && COUNT=$(( COUNT + 1 )) && echo "PASS" | |
cat tmp.out | |
# Claim asset | |
besu-cli asset claim --network=network1 --recipient_account=2 --preimage=${preimage} --token_id=${tokenId} --lock_contract_id=$LOCK_ID 1> tmp.out | |
cat tmp.out | grep "Account balance of the recipient in Network network1 before claiming: 0" && COUNT=$(( COUNT + 1 )) && echo "PASS" | |
cat tmp.out | grep "Account balance of the recipient in Network network1 after claiming: ${transferAmount}" && COUNT=$(( COUNT + 1 )) && echo "PASS" | |
cat tmp.out | |
###### test unlock ####### | |
timeout=20 | |
initAmount=5 | |
recipientAmt=0 | |
transferAmount=2 | |
tokenId=1 | |
if [ ${{ matrix.app_contract }} == "AliceERC20" ]; then | |
recipientAmt=5 | |
besu-cli asset lock --network=network1 --sender_account=1 --recipient_account=2 --amount=${transferAmount} --timeout=${timeout} --hash_base64=${hashBase64} 1> tmp.out | |
elif [ ${{ matrix.app_contract }} == "AliceERC1155" ]; then | |
besu-cli asset issue --network=network1 --account=1 --amount=${initAmount} --token_id=${tokenId} --token_data="" --asset_type=ERC1155 | |
besu-cli asset lock --network=network1 --sender_account=1 --recipient_account=2 --amount=${transferAmount} --token_id=${tokenId} --timeout=${timeout} --asset_type=ERC1155 --hash_base64=${hashBase64} 1> tmp.out | |
else | |
initAmount=1 | |
transferAmount=1 | |
recipientAmt=1 | |
besu-cli asset issue --network=network1 --account=1 --token_id=${tokenId} --asset_type=ERC721 1> tmp.out | |
tokenId=$(cat tmp.out | grep "New ERC721 token minted with id " | sed -e 's/New ERC721 token minted with id //') | |
cat tmp.out | |
echo $tokenId | |
besu-cli asset lock --network=network1 --sender_account=1 --recipient_account=2 --token_id=${tokenId} --asset_type=ERC721 --timeout=${timeout} --hash_base64=${hashBase64} 1> tmp.out | |
fi | |
balanceRem=$((initAmount-transferAmount)) | |
cat tmp.out | grep "Account balance of the sender in Network network1: ${initAmount}" && COUNT=$(( COUNT + 1 )) && echo "PASS" | |
cat tmp.out | grep "Account balance of the sender in Network network1: ${balanceRem}" && COUNT=$(( COUNT + 1 )) && echo "PASS" | |
cat tmp.out | grep "Account balance of the recipient in Network network1: ${recipientAmt}" && COUNT=$(( COUNT + 1 )) && echo "PASS" | |
cat tmp.out | |
tmp_string=$(cat tmp.out | grep "Lock contract ID:") | |
arrIN=(${tmp_string//:/ }) | |
LOCK_ID=${arrIN[3]} | |
sleep $timeout | |
besu-cli asset unlock --network=network1 --lock_contract_id=$LOCK_ID --sender_account=1 --token_id=${tokenId} 1> tmp.out | |
cat tmp.out | grep "before unlocking: ${balanceRem}" && COUNT=$(( COUNT + 1 )) && echo "PASS" | |
cat tmp.out | grep "after unlocking: ${initAmount}" && COUNT=$(( COUNT + 1 )) && echo "PASS" | |
cat tmp.out | |
# RESULT | |
echo "Passed $COUNT/$TOTAL Tests." | |
if [ $COUNT == $TOTAL ]; then | |
exit 0 | |
else | |
exit 1 | |
fi | |
working-directory: samples/besu/besu-cli | |
asset-exchange-besu-local: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
app_contract: ["AliceERC1155", "AliceERC20", "AliceERC721"] | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/[email protected] | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'adopt' | |
- name: Use Node.js 16.x | |
uses: actions/[email protected] | |
with: | |
node-version: 16.x | |
- name: Use Protoc 3.15 | |
run: | | |
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.15.6/protoc-3.15.6-linux-x86_64.zip | |
unzip protoc-3.15.6-linux-x86_64.zip -d protoc | |
# PROTOS | |
- name: Build JS Protos | |
run: | | |
export PATH="$PATH:${GITHUB_WORKSPACE}/protoc/bin" | |
make build | |
working-directory: common/protos-js | |
# PROTOS | |
- name: Build Solidity Protos | |
run: | | |
export PATH="$PATH:${GITHUB_WORKSPACE}/protoc/bin" | |
make build | |
working-directory: common/protos-sol | |
# BESU SDK | |
- name: Setup BESU SDK | |
run: make build-local | |
working-directory: sdks/besu/interoperation-node-sdk | |
# BESU NETWORK | |
- name: Start Besu Network | |
run: | | |
sudo apt install -y tmux jq | |
wget https://hyperledger.jfrog.io/artifactory/besu-binaries/besu/22.7.0/besu-22.7.0.zip | |
unzip besu-22.7.0.zip | |
export PATH="${PWD}/besu-22.7.0/bin:$PATH" | |
wget https://artifacts.consensys.net/public/ethsigner/raw/names/ethsigner.zip/versions/22.1.3/ethsigner-22.1.3.zip | |
unzip ethsigner-22.1.3.zip | |
export PATH="${PWD}/ethsigner-22.1.3/bin:$PATH" | |
make start | |
sleep 100 | |
working-directory: tests/network-setups/besu | |
# Deploy contracts | |
- name: Deploy contracts | |
run: | | |
make deploy-contracts | |
working-directory: samples/besu/simpleasset | |
# BESU CLI | |
- name: Setup BESU CLI init | |
run: | | |
make build-local | |
cp config.template.json tmp.json | |
cp config.template.json tmp.json | |
jq -r '.network1.tokenContract |= "../simpleasset/build/contracts/${{ matrix.app_contract }}.json"' tmp.json > config.json | |
cp config.json tmp.json | |
jq -r '.network2.tokenContract |= "../simpleasset/build/contracts/BobERC20.json"' tmp.json > config.json | |
rm tmp.json | |
working-directory: samples/besu/besu-cli | |
- name: Asset Exchange Besu CLI Tests | |
run: | | |
export PATH="${PWD}/bin:$PATH" | |
COUNT=0 | |
TOTAL=10 | |
# HTLC Params | |
timeout=1000 | |
hashBase64="ivHErp1x4bJDKuRo6L5bApO/DdoyD/dG0mAZrzLZEIs=" | |
preimage="secrettext" | |
# issue tokens to account 1 | |
initAmount=10 | |
transferAmount=5 | |
tokenId=0 | |
# & lock 5 token for account 2 in network 1 | |
if [ ${{ matrix.app_contract }} == "AliceERC20" ]; then | |
besu-cli asset issue --network=network1 --account=1 --amount=${initAmount} --asset_type=ERC20 | |
besu-cli asset lock --network=network1 --sender_account=1 --recipient_account=2 --amount=${transferAmount} --timeout=${timeout} --hash_base64=${hashBase64} 1> tmp.out | |
elif [ ${{ matrix.app_contract }} == "AliceERC1155" ]; then | |
besu-cli asset issue --network=network1 --account=1 --amount=${initAmount} --token_id=${tokenId} --token_data="" --asset_type=ERC1155 | |
besu-cli asset lock --network=network1 --sender_account=1 --recipient_account=2 --amount=${transferAmount} --token_id=${tokenId} --timeout=${timeout} --asset_type=ERC1155 --hash_base64=${hashBase64} 1> tmp.out | |
else | |
initAmount=1 | |
transferAmount=1 | |
besu-cli asset issue --network=network1 --account=1 --token_id=${tokenId} --asset_type=ERC721 1> tmp.out | |
tokenId=$(cat tmp.out | grep "New ERC721 token minted with id " | sed -e 's/New ERC721 token minted with id //') | |
cat tmp.out | |
echo $tokenId | |
besu-cli asset lock --network=network1 --sender_account=1 --recipient_account=2 --token_id=${tokenId} --asset_type=ERC721 --timeout=${timeout} --hash_base64=${hashBase64} 1> tmp.out | |
fi | |
balanceRem=$((initAmount-transferAmount)) | |
cat tmp.out | grep "Account balance of the sender in Network network1: ${initAmount} " && COUNT=$(( COUNT + 1 )) && echo "PASS" | |
cat tmp.out | grep "Account balance of the sender in Network network1: ${balanceRem}" && COUNT=$(( COUNT + 1 )) && echo "PASS" | |
cat tmp.out | grep "Account balance of the recipient in Network network1: 0" && COUNT=$(( COUNT + 1 )) && echo "PASS" | |
cat tmp.out | |
tmp_string=$(cat tmp.out | grep "Lock contract ID:") | |
arrIN=(${tmp_string//:/ }) | |
LOCK_ID=${arrIN[3]} | |
# Is Asset locked | |
besu-cli asset is-locked --network=network1 --lock_contract_id=$LOCK_ID 1> tmp.out | |
cat tmp.out | grep "in Network network1: true" && COUNT=$(( COUNT + 1 )) && echo "PASS" | |
cat tmp.out | |
# Claim asset | |
besu-cli asset claim --network=network1 --recipient_account=2 --preimage=${preimage} --token_id=${tokenId} --lock_contract_id=$LOCK_ID 1> tmp.out | |
cat tmp.out | grep "Account balance of the recipient in Network network1 before claiming: 0" && COUNT=$(( COUNT + 1 )) && echo "PASS" | |
cat tmp.out | grep "Account balance of the recipient in Network network1 after claiming: ${transferAmount}" && COUNT=$(( COUNT + 1 )) && echo "PASS" | |
cat tmp.out | |
###### test unlock ####### | |
timeout=20 | |
initAmount=5 | |
recipientAmt=0 | |
transferAmount=2 | |
tokenId=1 | |
if [ ${{ matrix.app_contract }} == "AliceERC20" ]; then | |
recipientAmt=5 | |
besu-cli asset lock --network=network1 --sender_account=1 --recipient_account=2 --amount=${transferAmount} --timeout=${timeout} --hash_base64=${hashBase64} 1> tmp.out | |
elif [ ${{ matrix.app_contract }} == "AliceERC1155" ]; then | |
besu-cli asset issue --network=network1 --account=1 --amount=${initAmount} --token_id=${tokenId} --token_data="" --asset_type=ERC1155 | |
besu-cli asset lock --network=network1 --sender_account=1 --recipient_account=2 --amount=${transferAmount} --token_id=${tokenId} --timeout=${timeout} --asset_type=ERC1155 --hash_base64=${hashBase64} 1> tmp.out | |
else | |
initAmount=1 | |
transferAmount=1 | |
recipientAmt=1 | |
besu-cli asset issue --network=network1 --account=1 --token_id=${tokenId} --asset_type=ERC721 1> tmp.out | |
tokenId=$(cat tmp.out | grep "New ERC721 token minted with id " | sed -e 's/New ERC721 token minted with id //') | |
cat tmp.out | |
echo $tokenId | |
besu-cli asset lock --network=network1 --sender_account=1 --recipient_account=2 --token_id=${tokenId} --asset_type=ERC721 --timeout=${timeout} --hash_base64=${hashBase64} 1> tmp.out | |
fi | |
balanceRem=$((initAmount-transferAmount)) | |
cat tmp.out | grep "Account balance of the sender in Network network1: ${initAmount}" && COUNT=$(( COUNT + 1 )) && echo "PASS" | |
cat tmp.out | grep "Account balance of the sender in Network network1: ${balanceRem}" && COUNT=$(( COUNT + 1 )) && echo "PASS" | |
cat tmp.out | grep "Account balance of the recipient in Network network1: ${recipientAmt}" && COUNT=$(( COUNT + 1 )) && echo "PASS" | |
cat tmp.out | |
tmp_string=$(cat tmp.out | grep "Lock contract ID:") | |
arrIN=(${tmp_string//:/ }) | |
LOCK_ID=${arrIN[3]} | |
sleep $timeout | |
besu-cli asset unlock --network=network1 --lock_contract_id=$LOCK_ID --sender_account=1 --token_id=${tokenId} 1> tmp.out | |
cat tmp.out | grep "before unlocking: ${balanceRem}" && COUNT=$(( COUNT + 1 )) && echo "PASS" | |
cat tmp.out | grep "after unlocking: ${initAmount}" && COUNT=$(( COUNT + 1 )) && echo "PASS" | |
cat tmp.out | |
# RESULT | |
echo "Passed $COUNT/$TOTAL Tests." | |
if [ $COUNT == $TOTAL ]; then | |
exit 0 | |
else | |
exit 1 | |
fi | |
working-directory: samples/besu/besu-cli | |