threefoldtecharchive / tfgrid_dashboard

unified portal + explorer
1 stars 3 forks source link

Unable to configure network url’s at runtime #484

Closed coesensbert closed 1 year ago

coesensbert commented 1 year ago

Description

To be able to setup multiple isolated backends we need to be able to set where an instance of the dashboard connects to get it's data. In the future there will be multiple full stack backends running, with their own dashboard that needs to connect to it's own graphql .. etc.

Found this config file where the URLs seem to be hard-coded: /usr/share/nginx/html/config.js

window.configs = { APP_API_URL: 'wss://tfchain.dev.grid.tf/ws', APP_STELLAR_HORIZON_URL: 'https://horizon-testnet.stellar.org', APP_TFT_ASSET_ISSUER: 'GA47YZA3PKFUZMPLQ3B5F2E3CJIB57TGGU7SPCQT2WAEYKN766P
WIMB3', APP_BRIDGE_TFT_ADDRESS: 'GDHJP6TF3UXYXTNEZ2P36J5FH7W4BJJQ4AYYAXC66I2Q2AH5B6O6BCFG', APP_ACTIVATION_SERVICE_URL: 'https://activation.dev.grid.tf', APP_EXPLORER_URL: 'https://explorer.dev.grid.tf/
', APP_GRAPHQL_URL: 'https://graphql.dev.grid.tf/graphql', APP_GRIDPROXY_URL: 'https://gridproxy.dev.grid.tf', APP_NETWORK: 'dev', APP_VERSION: 'v1.3.0', APP_GRAVITY_CONTRACT_ADDRESS: '0xBF8C35Ad93366E1
59C0F0B75F1a4f4ad6Ff80811', APP_TFT_TOKEN_CONTRACT_ADDRESS: '0xDC5a9199e2604A6BF4A99A583034506AE53F4B34', APP_BRIDGE_FEES: '3', APP_TFT_DECIMALS: 7, APP_TFT_DENOM: 'TFT', APP_PROPOSAL_DENOM: 'TFT', APP_
COSMOS_REST: 'https://tfhub.test.grid.tf:1317/', APP_TENDERMINT_RPC: 'https://tfhub.test.grid.tf:26657/', APP_GAS_PRICE: '80TFT', APP_CHAIN_ID: 'threefold-hub-testnet', PLAYGROUND_URL: 'https://play.dev
.grid.tf', };

Implementation

We need at least these URLs to be set as environment variables, so we can change them for each instance of the dashboard.

This one could be handy to set the stellar config's? Like the horizon url .. If we hard code them for each net, and then define the net here? Open for suggestions ..

Mahmoud-Emad commented 1 year ago

@coesensbert Seems logical to set all required env vars based on the current network instead because you gonna use all its partners e.g.

export APP_NETWORK=`dev`
window.configs = {
    GQL_URL="https://graphql.dev.grid.tf/graphql"
    PROXY_URL="https://gridproxy.dev.grid.tf"
}

in case we will use this approach, the server won't run without the APP_NETWORK otherwise will raise an error.

robvanmieghem commented 1 year ago

@Mahmoud-Emad There is more than dev, qa, test and main. We are working on setting up private grid stacks for development and testing. People should also be able to create grid instances for local internets. This does not have to be configurable through environment variables, it can be through a configfile too.

Mahmoud-Emad commented 1 year ago

@robvanmieghem @coesensbert the build script was changed with the requested changes. one more mode was added called custom, if you want to add the links by yourself you just have to set the TFCHAIN_NETWORK=custom otherwise dev will be selected, also if you missed setting any env var the script will raise an error to you to tell you what you missed.

So what are the required env vars now you have to set before starting the server

optional env vars.

in case you choose one of the tf-chain that is mentioned above, the script will generate all required env vars for you. in case you choose a custom network, you have to set all of those env vars.

TFCHAIN_NETWORK -> Must be custom to set all env vars below.

Note: Wating for approval from you to merge the changes.

xmonader commented 1 year ago

@robvanmieghem please close once verified

A-Harby commented 1 year ago

Verified on devnet. Was able to use default dev config and custom and serve successfully. image