From 5a50e46718af089d768044e71849ed80e62f552d Mon Sep 17 00:00:00 2001 From: David Boreham Date: Sun, 16 Apr 2023 20:14:15 -0600 Subject: [PATCH] Support for complete laconic stack with console and test registration record (#335) * Configure cli with necessary gas and fees args and address * Update version Former-commit-id: 0068a994f63c7a420ab223dd67b969ebaa604200 --- .../docker-compose-fixturenet-laconicd.yml | 1 + .../fixturenet-laconicd/export-myaddress.sh | 2 ++ .../registry-cli-config-template.yml | 2 ++ .../cerc-laconic-registry-cli/Dockerfile | 2 ++ .../create-demo-records.sh | 29 +++++++++++++++++++ .../import-address.sh | 2 ++ .../fixturenet-laconic-loaded/README.md | 15 ++++++++++ .../fixturenet-laconic-loaded/stack.yml | 4 ++- app/data/stacks/fixturenet-laconicd/stack.yml | 1 + 9 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 app/data/config/fixturenet-laconicd/export-myaddress.sh create mode 100755 app/data/container-build/cerc-laconic-registry-cli/create-demo-records.sh create mode 100644 app/data/container-build/cerc-laconic-registry-cli/import-address.sh diff --git a/app/data/compose/docker-compose-fixturenet-laconicd.yml b/app/data/compose/docker-compose-fixturenet-laconicd.yml index 5d777b5d..9a974e90 100644 --- a/app/data/compose/docker-compose-fixturenet-laconicd.yml +++ b/app/data/compose/docker-compose-fixturenet-laconicd.yml @@ -8,6 +8,7 @@ services: # TODO: look at folding these scripts into the container - ../config/fixturenet-laconicd/create-fixturenet.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh - ../config/fixturenet-laconicd/export-mykey.sh:/docker-entrypoint-scripts.d/export-mykey.sh + - ../config/fixturenet-laconicd/export-myaddress.sh:/docker-entrypoint-scripts.d/export-myaddress.sh # TODO: determine which of the ports below is really needed ports: - "6060" diff --git a/app/data/config/fixturenet-laconicd/export-myaddress.sh b/app/data/config/fixturenet-laconicd/export-myaddress.sh new file mode 100644 index 00000000..e454c0b0 --- /dev/null +++ b/app/data/config/fixturenet-laconicd/export-myaddress.sh @@ -0,0 +1,2 @@ +#!/bin/sh +laconicd keys show mykey | grep address | cut -d ' ' -f 3 diff --git a/app/data/config/fixturenet-laconicd/registry-cli-config-template.yml b/app/data/config/fixturenet-laconicd/registry-cli-config-template.yml index 6074cc6d..16432c18 100644 --- a/app/data/config/fixturenet-laconicd/registry-cli-config-template.yml +++ b/app/data/config/fixturenet-laconicd/registry-cli-config-template.yml @@ -5,3 +5,5 @@ services: userKey: REPLACE_WITH_MYKEY bondId: chainId: laconic_9000-1 + gas: 250000 + fees: 200000aphoton diff --git a/app/data/container-build/cerc-laconic-registry-cli/Dockerfile b/app/data/container-build/cerc-laconic-registry-cli/Dockerfile index b7e87475..da7ff19a 100644 --- a/app/data/container-build/cerc-laconic-registry-cli/Dockerfile +++ b/app/data/container-build/cerc-laconic-registry-cli/Dockerfile @@ -55,7 +55,9 @@ RUN yarn global add @cerc-io/laconic-registry-cli # Add scripts RUN mkdir /scripts ENV PATH="${PATH}:/scripts" +COPY ./create-demo-records.sh /scripts COPY ./import-key.sh /scripts +COPY ./import-address.sh /scripts # Default command sleeps forever so docker doesn't kill it CMD ["sh", "-c", "while :; do sleep 600; done"] diff --git a/app/data/container-build/cerc-laconic-registry-cli/create-demo-records.sh b/app/data/container-build/cerc-laconic-registry-cli/create-demo-records.sh new file mode 100755 index 00000000..0d90da8d --- /dev/null +++ b/app/data/container-build/cerc-laconic-registry-cli/create-demo-records.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# Create some demo/test records in the registry +set -e +if [ -n "$CERC_SCRIPT_DEBUG" ]; then + set -x +fi +registry_command="laconic cns" +record_1_filename=demo-record-1.yml +cat < ${record_1_filename} +record: + type: WebsiteRegistrationRecord + url: 'https://cerc.io' + repo_registration_record_cid: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D + build_artifact_cid: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9 + tls_cert_cid: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR + version: 1.0.23 +EOF +# Check we have funds +funds_response=$(${registry_command} account get --address $(cat my-address.txt)) +funds_balance=$(echo ${funds_response} | jq -r .[0].balance[0].quantity) +echo "Balance is: ${funds_balance}" +# Create a bond +bond_create_result=$(${registry_command} bond create --type aphoton --quantity 1000000000) +bond_id=$(echo ${bond_create_result} | jq -r .bondId) +echo "Created bond with id: ${bond_id}" +# Publish a demo record +publish_response=$(${registry_command} record publish --filename ${record_1_filename} --bond-id ${bond_id}) +published_record_id=$(echo ${publish_response} | jq -r .id) +echo "Published ${record_1_filename} with id: ${published_record_id}" diff --git a/app/data/container-build/cerc-laconic-registry-cli/import-address.sh b/app/data/container-build/cerc-laconic-registry-cli/import-address.sh new file mode 100644 index 00000000..06b5d08d --- /dev/null +++ b/app/data/container-build/cerc-laconic-registry-cli/import-address.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ${1} > my-address.txt diff --git a/app/data/stacks/fixturenet-laconic-loaded/README.md b/app/data/stacks/fixturenet-laconic-loaded/README.md index 000596ee..a2e48efb 100644 --- a/app/data/stacks/fixturenet-laconic-loaded/README.md +++ b/app/data/stacks/fixturenet-laconic-loaded/README.md @@ -48,3 +48,18 @@ $ laconic-so --stack fixturenet-laconicd deploy logs ``` $ laconic-so --stack fixturenet-laconicd deploy exec cli "laconic cns status" ``` +## 7. View the laconic console +Get the URL for the console web app with this command (the port number will be different for each deployment): +``` +$ echo http://localhost:$(laconic-so --stack fixturenet-laconic-loaded deploy port laconic-console 80 | cut -d ':' -f 2) +http://localhost:58364 +``` +Open that address with a browser. The console should display +## 8. Load demo data into the registry +``` +$ laconic-so --stack fixturenet-laconic-loaded deploy exec cli ./scripts/create-demo-records.sh +Balance is: 99998999999999998999600000 +Created bond with id: dd88e8d6f9567b32b28e70552aea4419c5dd3307ebae85a284d1fe38904e301a +Published demo-record-1.yml with id: bafyreierh3xnfivexlscdwubvczmddsnf46uytyfvrbdhkjzztvsz6ruly +``` +The published record should be visible in the console. \ No newline at end of file diff --git a/app/data/stacks/fixturenet-laconic-loaded/stack.yml b/app/data/stacks/fixturenet-laconic-loaded/stack.yml index 03d0a4c9..009212f0 100644 --- a/app/data/stacks/fixturenet-laconic-loaded/stack.yml +++ b/app/data/stacks/fixturenet-laconic-loaded/stack.yml @@ -1,4 +1,4 @@ -version: "1.0" +version: "1.1" name: fixturenet-laconic-loaded description: "A full featured laconic fixturenet" repos: @@ -28,3 +28,5 @@ pods: config: cli: key: laconicd.mykey + address: laconicd.myaddress + diff --git a/app/data/stacks/fixturenet-laconicd/stack.yml b/app/data/stacks/fixturenet-laconicd/stack.yml index 86fb2144..54c5dba6 100644 --- a/app/data/stacks/fixturenet-laconicd/stack.yml +++ b/app/data/stacks/fixturenet-laconicd/stack.yml @@ -16,3 +16,4 @@ pods: config: cli: key: laconicd.mykey + address: laconicd.myaddress