From be55efd877e86c05e523481fc63f2d9251fd623f Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Mon, 26 May 2025 16:34:39 +0530 Subject: [PATCH] Add GQL schema in run script --- db-schema.graphql | 3 + .../docker-compose-cosmos-multisig-ui.yml | 33 +++++----- .../compose/docker-compose-dgraph.yml | 18 +++--- .../cosmos-multisig-ui/db-schema.graphql | 30 +++++++++ .../config/cosmos-multisig-ui/run.sh | 4 ++ .../stacks/cosmos-multisig-ui/README.md | 63 +++++++++++++++++++ 6 files changed, 124 insertions(+), 27 deletions(-) create mode 100644 stack-orchestrator/config/cosmos-multisig-ui/db-schema.graphql diff --git a/db-schema.graphql b/db-schema.graphql index 2196eda..c362df6 100644 --- a/db-schema.graphql +++ b/db-schema.graphql @@ -1,5 +1,8 @@ type Multisig { id: ID! + # The @search annotation allows us to query the list of multisigs and filter + # by (chainId, address) pairs. We use "hash" since we only need exact matches. + # See https://dgraph.io/docs/graphql/schema/directives/search/#string chainId: String! @search(by: [hash]) address: String! @search(by: [hash]) creator: String @search(by: [hash]) diff --git a/stack-orchestrator/compose/docker-compose-cosmos-multisig-ui.yml b/stack-orchestrator/compose/docker-compose-cosmos-multisig-ui.yml index c60ea0f..885f9d2 100644 --- a/stack-orchestrator/compose/docker-compose-cosmos-multisig-ui.yml +++ b/stack-orchestrator/compose/docker-compose-cosmos-multisig-ui.yml @@ -1,32 +1,31 @@ -version: '3.8' - services: cosmos-multisig-ui: image: cerc/cosmos-multisig-ui:local restart: unless-stopped depends_on: - alpha - network_mode: "host" + network_mode: "host" # For local testing, to allow the container to directly access host machine ports from container environment: DGRAPH_URL: ${DGRAPH_URL:-http://localhost:8080/graphql} - NEXT_PUBLIC_MULTICHAIN: ${NEXT_PUBLIC_MULTICHAIN:-true} - NEXT_PUBLIC_REGISTRY_NAME: ${NEXT_PUBLIC_REGISTRY_NAME:-laconic} - NEXT_PUBLIC_LOGO: ${NEXT_PUBLIC_LOGO:-} - NEXT_PUBLIC_CHAIN_ID: ${NEXT_PUBLIC_CHAIN_ID:-laconic_9000-1} - NEXT_PUBLIC_CHAIN_DISPLAY_NAME: ${NEXT_PUBLIC_CHAIN_DISPLAY_NAME:-Laconic Network} - NEXT_PUBLIC_NODE_ADDRESSES: ${NEXT_PUBLIC_NODE_ADDRESSES:-["http://localhost:26657"]} - NEXT_PUBLIC_DENOM: ${NEXT_PUBLIC_DENOM:-alnt} - NEXT_PUBLIC_DISPLAY_DENOM: ${NEXT_PUBLIC_DISPLAY_DENOM:-ALNT} - NEXT_PUBLIC_DISPLAY_DENOM_EXPONENT: ${NEXT_PUBLIC_DISPLAY_DENOM_EXPONENT:-18} - NEXT_PUBLIC_ASSETS: ${NEXT_PUBLIC_ASSETS:-[{"denom_units":[{"denom":"alnt","exponent":0},{"denom":"alnt","exponent":6}],"base":"alnt","name":"Laconic Token","display":"ALNT","symbol":"alnt"}]} - NEXT_PUBLIC_GAS_PRICE: ${NEXT_PUBLIC_GAS_PRICE:-0.01alnt} - NEXT_PUBLIC_ADDRESS_PREFIX: ${NEXT_PUBLIC_ADDRESS_PREFIX:-laconic} - NEXT_PUBLIC_IS_HTTP_ENABLED: ${NEXT_PUBLIC_IS_HTTP_ENABLED:-true} + NEXT_PUBLIC_MULTICHAIN: ${NEXT_PUBLIC_MULTICHAIN} + NEXT_PUBLIC_REGISTRY_NAME: ${NEXT_PUBLIC_REGISTRY_NAME} + NEXT_PUBLIC_LOGO: ${NEXT_PUBLIC_LOGO} + NEXT_PUBLIC_CHAIN_ID: ${NEXT_PUBLIC_CHAIN_ID} + NEXT_PUBLIC_CHAIN_DISPLAY_NAME: ${NEXT_PUBLIC_CHAIN_DISPLAY_NAME} + NEXT_PUBLIC_NODE_ADDRESSES: ${NEXT_PUBLIC_NODE_ADDRESSES} + NEXT_PUBLIC_DENOM: ${NEXT_PUBLIC_DENOM} + NEXT_PUBLIC_DISPLAY_DENOM: ${NEXT_PUBLIC_DISPLAY_DENOM} + NEXT_PUBLIC_DISPLAY_DENOM_EXPONENT: ${NEXT_PUBLIC_DISPLAY_DENOM_EXPONENT} + NEXT_PUBLIC_ASSETS: ${NEXT_PUBLIC_ASSETS} + NEXT_PUBLIC_GAS_PRICE: ${NEXT_PUBLIC_GAS_PRICE} + NEXT_PUBLIC_ADDRESS_PREFIX: ${NEXT_PUBLIC_ADDRESS_PREFIX} + NEXT_PUBLIC_IS_HTTP_ENABLED: ${NEXT_PUBLIC_IS_HTTP_ENABLED:-false} command: ["bash", "/cosmos-script/run.sh"] volumes: - ../config/cosmos-multisig-ui/run.sh:/cosmos-script/run.sh + - ../config/cosmos-multisig-ui/db-schema.graphql:/cosmos-script/db-schema.graphql ports: - - "3000:3000" + - "3000" healthcheck: test: ["CMD", "nc", "-vz", "127.0.0.1", "3000"] interval: 20s diff --git a/stack-orchestrator/compose/docker-compose-dgraph.yml b/stack-orchestrator/compose/docker-compose-dgraph.yml index 649e48c..1c38c87 100644 --- a/stack-orchestrator/compose/docker-compose-dgraph.yml +++ b/stack-orchestrator/compose/docker-compose-dgraph.yml @@ -1,32 +1,30 @@ -version: '3.8' - services: zero: - image: dgraph/dgraph:latest + image: dgraph/dgraph:v21.03.2 volumes: - zero-data:/dgraph ports: - - "5080:5080" - - "6080:6080" + - "5080" + - "6080" restart: on-failure command: dgraph zero --my=zero:5080 alpha: - image: dgraph/dgraph:latest + image: dgraph/dgraph:v21.03.2 depends_on: - zero volumes: - alpha-data:/dgraph ports: - - "8080:8080" - - "9080:9080" + - "8080" + - "9080" restart: on-failure command: dgraph alpha --my=alpha:7080 --zero=zero:5080 --security "whitelist=0.0.0.0/0" ratel: - image: dgraph/ratel:latest + image: dgraph/ratel:v21.03.0 ports: - - "8000:8000" + - "8000" depends_on: - alpha diff --git a/stack-orchestrator/config/cosmos-multisig-ui/db-schema.graphql b/stack-orchestrator/config/cosmos-multisig-ui/db-schema.graphql new file mode 100644 index 0000000..2196eda --- /dev/null +++ b/stack-orchestrator/config/cosmos-multisig-ui/db-schema.graphql @@ -0,0 +1,30 @@ +type Multisig { + id: ID! + chainId: String! @search(by: [hash]) + address: String! @search(by: [hash]) + creator: String @search(by: [hash]) + pubkeyJSON: String! @search(by: [fulltext]) + transactions: [Transaction] @hasInverse(field: creator) +} + +type Transaction { + id: ID! + txHash: String + creator: Multisig + dataJSON: String! + signatures: [Signature] @hasInverse(field: transaction) +} + +type Signature { + transaction: Transaction! + bodyBytes: String! + signature: String! + address: String! +} + +type Nonce { + id: ID! + chainId: String! @search(by: [hash]) + address: String! @search(by: [hash]) + nonce: Int! +} diff --git a/stack-orchestrator/config/cosmos-multisig-ui/run.sh b/stack-orchestrator/config/cosmos-multisig-ui/run.sh index a369c67..1f9ae0f 100644 --- a/stack-orchestrator/config/cosmos-multisig-ui/run.sh +++ b/stack-orchestrator/config/cosmos-multisig-ui/run.sh @@ -5,6 +5,10 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then set -x fi +# Load Dgraph schema +echo "Posting schema to Dgraph..." +curl -X POST localhost:8080/admin/schema -d @/cosmos-script/db-schema.graphql + echo "Using the following env variables:" echo "DGRAPH_URL: ${DGRAPH_URL}" echo "NEXT_PUBLIC_MULTICHAIN: ${NEXT_PUBLIC_MULTICHAIN}" diff --git a/stack-orchestrator/stacks/cosmos-multisig-ui/README.md b/stack-orchestrator/stacks/cosmos-multisig-ui/README.md index a5055a4..5629b34 100644 --- a/stack-orchestrator/stacks/cosmos-multisig-ui/README.md +++ b/stack-orchestrator/stacks/cosmos-multisig-ui/README.md @@ -26,12 +26,75 @@ Instructions for running the `cosmos-multisig-ui` using [laconic-so](https://git laconic-so --stack ~/cerc/cosmos-multisig-ui/stack-orchestrator/stacks/cosmos-multisig-ui deploy init --output cosmos-multisig-ui-spec.yml ``` +* Edit `network` in the spec file to map container ports to host ports as required: + + ```bash + # cosmos-multisig-ui-spec.yml + ... + network: + ports: + cosmos-multisig-ui: + - 3000:3000 + zero: + - 5080:5080 + - 6080:6080 + alpha: + - 8080:8080 + - 9080:9080 + ratel: + - 8000:8000 + ... + ``` + * Create a deployment from the spec file: ```bash laconic-so --stack ~/cerc/cosmos-multisig-ui/stack-orchestrator/stacks/cosmos-multisig-ui/ deploy create --spec-file cosmos-multisig-ui-spec.yml --deployment-dir cosmos-multisig-deployment ``` +* Inside the `cosmos-multisig-deployment` deployment directory, open `config.env` file and set following env variables: + + ```bash + # Allow multiple networks/chains in app + NEXT_PUBLIC_MULTICHAIN=false + + # Name of the chain registry + NEXT_PUBLIC_REGISTRY_NAME=laconic + + # Path or URL to the logo asset (can be left empty if not needed) + NEXT_PUBLIC_LOGO= + + # Chain ID + NEXT_PUBLIC_CHAIN_ID=laconic_9000-1 + + # Display name for the chain + NEXT_PUBLIC_CHAIN_DISPLAY_NAME="Laconic Network" + + # JSON array of RPC node URLs + NEXT_PUBLIC_NODE_ADDRESSES='["http://localhost:26657"]' + + # Native token base denom + NEXT_PUBLIC_DENOM=alnt + + # Display name for the token (used in UI) + NEXT_PUBLIC_DISPLAY_DENOM=ALNT + + # Exponent used to convert from base denom + NEXT_PUBLIC_DISPLAY_DENOM_EXPONENT=18 + + # JSON array of asset metadata + NEXT_PUBLIC_ASSETS='[{"denom_units":[{"denom":"alnt","exponent":0},{"denom":"alnt","exponent":6}],"base":"alnt","name":"Laconic Token","display":"ALNT","symbol":"alnt"}]' + + # Minimum gas price + NEXT_PUBLIC_GAS_PRICE=0.01alnt + + # Bech32 address prefix for the chain + NEXT_PUBLIC_ADDRESS_PREFIX=laconic + + # Whether to use HTTP (true/false) + NEXT_PUBLIC_IS_HTTP_ENABLED=true + ``` + ## Start the deployment * Run: