diff --git a/context/ChainsContext/helpers.tsx b/context/ChainsContext/helpers.tsx index 20d1cd8..965bd73 100644 --- a/context/ChainsContext/helpers.tsx +++ b/context/ChainsContext/helpers.tsx @@ -28,7 +28,7 @@ export const isChainInfoFilled = (chain: Partial): chain is ChainInfo chain.displayDenom && Number.isSafeInteger(chain.displayDenomExponent) && typeof chain.displayDenomExponent === "number" && - // chain.displayDenomExponent >= 0 && + chain.displayDenomExponent >= 0 && chain.assets?.length && chain.gasPrice && chain.addressPrefix, diff --git a/context/ChainsContext/index.tsx b/context/ChainsContext/index.tsx index aba3363..9b83ca6 100644 --- a/context/ChainsContext/index.tsx +++ b/context/ChainsContext/index.tsx @@ -78,7 +78,7 @@ export const ChainsProvider = ({ children }: ChainsProviderProps) => { const loadedChain = getChain(chainItems); if (chainItems.mainnets.size && loadedChain === emptyChain) { - setChain(dispatch, emptyChain); + setChain(dispatch, chainItems.mainnets.get("cosmoshub") ?? emptyChain); } else { setChain(dispatch, loadedChain); } diff --git a/context/ChainsContext/service.tsx b/context/ChainsContext/service.tsx index 12e7a12..b6a2328 100644 --- a/context/ChainsContext/service.tsx +++ b/context/ChainsContext/service.tsx @@ -112,7 +112,7 @@ export const getChain = (chains: ChainItems) => { const urlChain = getChainFromUrl(chainNameFromUrl); const envfileChain = getChainFromEnvfile(chainNameFromUrl); const storedChain = getChainFromStorage( - chainNameFromUrl || envfileChain.registryName || "laconic", + chainNameFromUrl || envfileChain.registryName || "cosmoshub", chains, ); diff --git a/context/ChainsContext/storage.tsx b/context/ChainsContext/storage.tsx index d530a92..f5e80da 100644 --- a/context/ChainsContext/storage.tsx +++ b/context/ChainsContext/storage.tsx @@ -142,6 +142,11 @@ export const getChainFromUrl = (chainName: string) => { }; export const getChainFromEnvfile = (chainName: string) => { + const registryName = process.env.NEXT_PUBLIC_REGISTRY_NAME || ""; + if (chainName && registryName !== chainName) { + return { registryName: chainName }; + } + const logo = process.env.NEXT_PUBLIC_LOGO; const chainId = process.env.NEXT_PUBLIC_CHAIN_ID; const chainDisplayName = process.env.NEXT_PUBLIC_CHAIN_DISPLAY_NAME; diff --git a/db-schema.graphql b/db-schema.graphql index c362df6..2196eda 100644 --- a/db-schema.graphql +++ b/db-schema.graphql @@ -1,8 +1,5 @@ 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 752e507..91ccd12 100644 --- a/stack-orchestrator/compose/docker-compose-cosmos-multisig-ui.yml +++ b/stack-orchestrator/compose/docker-compose-cosmos-multisig-ui.yml @@ -1,62 +1,34 @@ version: '3.8' services: - zero: - image: dgraph/dgraph:latest - volumes: - - ./data/zero:/dgraph - ports: - - "5080:5080" - - "6080:6080" - restart: on-failure - command: dgraph zero --my=zero:5080 - - alpha: - image: dgraph/dgraph:latest - depends_on: - - zero - volumes: - - ./data/alpha:/dgraph - ports: - - "8080:8080" - - "9080: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 - ports: - - "8000:8000" - depends_on: - - alpha - cosmos-multisig-ui: image: cerc/cosmos-multisig-ui:local restart: unless-stopped depends_on: - alpha environment: - DGRAPH_URL: ${DGRAPH_URL:-http://alpha: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:-["https://8d1e-14-140-185-73.ngrok-free.app"]} - 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"} + DGRAPH_URL: ${DGRAPH_URL} + 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:-"0.01alnt"} - NEXT_PUBLIC_ADDRESS_PREFIX: ${NEXT_PUBLIC_ADDRESS_PREFIX:-"laconic"} - NEXT_PUBLIC_IS_HTTP_ENABLED: ${NEXT_PUBLIC_IS_HTTP_ENABLED:-false} + 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} + NEXT_PUBLIC_EXPLORER_LINKS: ${NEXT_PUBLIC_EXPLORER_LINKS} command: ["bash", "/cosmos-script/run.sh"] volumes: - ../config/cosmos-multisig-ui/run.sh:/cosmos-script/run.sh ports: - - "3000:3000" + - "3000" healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:3000"] + test: ["CMD", "nc", "-vz", "127.0.0.1", "3000"] interval: 20s timeout: 5s retries: 15 diff --git a/stack-orchestrator/compose/docker-compose-dgraph.yml b/stack-orchestrator/compose/docker-compose-dgraph.yml new file mode 100644 index 0000000..649e48c --- /dev/null +++ b/stack-orchestrator/compose/docker-compose-dgraph.yml @@ -0,0 +1,35 @@ +version: '3.8' + +services: + zero: + image: dgraph/dgraph:latest + volumes: + - zero-data:/dgraph + ports: + - "5080:5080" + - "6080:6080" + restart: on-failure + command: dgraph zero --my=zero:5080 + + alpha: + image: dgraph/dgraph:latest + depends_on: + - zero + volumes: + - alpha-data:/dgraph + ports: + - "8080:8080" + - "9080: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 + ports: + - "8000:8000" + depends_on: + - alpha + +volumes: + zero-data: + alpha-data: diff --git a/stack-orchestrator/config/cosmos-multisig-ui/run.sh b/stack-orchestrator/config/cosmos-multisig-ui/run.sh index a4d0b1b..ddd5b31 100644 --- a/stack-orchestrator/config/cosmos-multisig-ui/run.sh +++ b/stack-orchestrator/config/cosmos-multisig-ui/run.sh @@ -8,10 +8,13 @@ fi echo "Using the following env variables:" echo "NEXT_PUBLIC_IS_HTTP_ENABLED: ${NEXT_PUBLIC_IS_HTTP_ENABLED}" -# Build with required env NEXT_PUBLIC_IS_HTTP_ENABLED=$NEXT_PUBLIC_IS_HTTP_ENABLED +# Install dependencies npm install -echo "Starting server..." -npm run dev +# Build Next.js app +npm run build + +echo "Start app..." +npm run start diff --git a/stack-orchestrator/stacks/cosmos-multisig-ui/README.md b/stack-orchestrator/stacks/cosmos-multisig-ui/README.md index 4ddbdeb..a5055a4 100644 --- a/stack-orchestrator/stacks/cosmos-multisig-ui/README.md +++ b/stack-orchestrator/stacks/cosmos-multisig-ui/README.md @@ -7,21 +7,13 @@ Instructions for running the `cosmos-multisig-ui` using [laconic-so](https://git * Clone the stack repo: ```bash - laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull - ``` - -* Setup required repositories: - - ```bash - laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/cosmos-multisig-ui setup-repositories --git-ssh --pull - - # If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories and re-run the command + laconic-so fetch-stack git.vdb.to/cerc-io/cosmos-multisig-ui --git-ssh --pull ``` * Build the container image: ```bash - laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/cosmos-multisig-ui build-containers + laconic-so --stack ~/cerc/cosmos-multisig-ui/stack-orchestrator/stacks/cosmos-multisig-ui build-containers ``` This should create the `cerc/cosmos-multisig-ui` image locally @@ -31,13 +23,13 @@ Instructions for running the `cosmos-multisig-ui` using [laconic-so](https://git * Create a spec file for the deployment: ```bash - laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/cosmos-multisig-ui deploy init --output cosmos-multisig-ui-spec.yml + laconic-so --stack ~/cerc/cosmos-multisig-ui/stack-orchestrator/stacks/cosmos-multisig-ui deploy init --output cosmos-multisig-ui-spec.yml ``` * Create a deployment from the spec file: ```bash - laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/cosmos-multisig-ui/ deploy create --spec-file cosmos-multisig-ui-spec.yml --deployment-dir cosmos-multisig-deployment + 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 ``` ## Start the deployment @@ -61,7 +53,7 @@ Instructions for running the `cosmos-multisig-ui` using [laconic-so](https://git * Register the GraphQL schema in the Dgraph database ``` - cd ~/cerc/laconicd-stack/schema + cd ~/cerc/cosmos-multisig-ui curl -X POST localhost:8080/admin/schema -d '@db-schema.graphql' ``` diff --git a/stack-orchestrator/stacks/cosmos-multisig-ui/stack.yml b/stack-orchestrator/stacks/cosmos-multisig-ui/stack.yml index 9edfbf0..dadfca2 100644 --- a/stack-orchestrator/stacks/cosmos-multisig-ui/stack.yml +++ b/stack-orchestrator/stacks/cosmos-multisig-ui/stack.yml @@ -2,8 +2,8 @@ version: "1.0" name: cosmos-multisig-ui description: "cosmos multisig UI" repos: - - git.vdb.to/cerc-io/cosmos-multisig-ui@iv-default-laconic containers: - cerc/cosmos-multisig-ui pods: - cosmos-multisig-ui + - dgraph