Feat/dockerize frontends (#388)
* feat: unhardcode contract addresses * fix: linting and tests * feat: switch contract usage in token app to use unhardcoded addresses * chore: remove other usage of hard coded contract addresses * feat: convert contracts to classes, update claim contract to fix circular dependency * feat: add hard coded contract addresses to contracts page * fix: misc tidy up * chore: rename ethers big num conversion func * fix: remove pending transactions modal * chore: add single toBigNum function that can accept number string or EthersBignNumber * chore: delete unused tranche helpers and decimals functions from smart contracts lib * feat: add faucetable token class * fix: reset tx state after early exit from approve tx * feat: re add transaction modal using zustand store * fix: loader colors for eth wallet * fix: pass ethereum config to gurantee existence before tx execution * add docker image for building explorer * add arg * env file changes * add docker file to build env file * add requirement for env file in explorer * fix env file syntax * containers functional * default to testnet * make env flag logic consistent in all places * pre populate env file * ensure working for all projects * address PR comment * generalising env for token * invert config dependency from ui toolkit * fix: merge issues * docs: running containers documentation * style: lint * fix: env varibales not being added properly * chore: fix merge issues * chore: fix docker file to support new exectutors * chore: set address on all contracts as a property * feat: pull token from contract rather than relying on env var * chore: fix typing * chore: remove duplicated prop * chore: don't use chainId * style: lint * style: lint * Merge branch 'master' into feat/dockerize-frontends * Merge remote-tracking branch 'origin/master' into feat/dockerize-frontends * test: revert changes to explorer e2e file * fix: creating client without base causing token to error * test: fix tests erroring in before hook due to file not being found * chore: remove node env from configurable flags Co-authored-by: Matthew Russell <mattrussell36@gmail.com>
This commit is contained in:
parent
5f8061d5ce
commit
bcaab22891
5
.dockerignore
Normal file
5
.dockerignore
Normal file
@ -0,0 +1,5 @@
|
||||
dist/*
|
||||
node_modules/*
|
||||
tmp/*
|
||||
.dockerignore
|
||||
Dockerfile
|
29
Dockerfile
Normal file
29
Dockerfile
Normal file
@ -0,0 +1,29 @@
|
||||
# Build container
|
||||
FROM node:16.14.0-alpine as build
|
||||
WORKDIR /app
|
||||
# Argument to allow building of different apps
|
||||
ARG APP
|
||||
ENV PATH /app/node_modules/.bin:$PATH
|
||||
COPY package.json ./
|
||||
COPY yarn.lock ./
|
||||
COPY . ./
|
||||
RUN yarn
|
||||
RUN yarn nx build $APP
|
||||
|
||||
# Production environment
|
||||
FROM nginx:stable-alpine
|
||||
ARG APP
|
||||
COPY --from=build /app/dist/apps/$APP /usr/share/nginx/html
|
||||
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
WORKDIR /usr/share/nginx/html
|
||||
COPY ./env.sh .
|
||||
COPY ./apps/$APP/.env .env
|
||||
|
||||
# Add bash
|
||||
RUN apk add --no-cache bash
|
||||
|
||||
RUN chmod +x ./env.sh
|
||||
CMD ["/bin/bash", "-c", "/usr/share/nginx/html/env.sh && nginx -g \"daemon off;\""]
|
40
README.md
40
README.md
@ -103,24 +103,42 @@ In CI linting, formatting and also run. These checks can be seen in the [CI work
|
||||
|
||||
Visit the [Nx Documentation](https://nx.dev/getting-started/intro) to learn more.
|
||||
|
||||
# Vegacapsule
|
||||
# Docker & Vegacapsule
|
||||
|
||||
## Explorer
|
||||
## Docker
|
||||
|
||||
Follow the following steps to start using a local network with the Vega Explorer:
|
||||
The [Dockerfile](./Dockerfile) for running the frontends is pretty basic, merely building the application with the APP arg that is passed in and serving the application from [nginx](./nginx/nginx.conf). The only complexity that exists is that there is a script which allows the passing of run time environement variabels to the containers. See configuration below for how to do this.
|
||||
|
||||
1. Prepare vegacapsule. Follow the [Vegacapsule instructions](https://github.com/vegaprotocol/vegacapsule#quick-start)
|
||||
2. Build the explorer frontend application
|
||||
3. Start the explorer frontend application with the `.env.vegacapsule` env file
|
||||
4. Go to [http://localhost:3000](http://localhost:3000) in your browser
|
||||
|
||||
If you simply want to run Explorer locally, without using a local network:
|
||||
You can build any of the containers locally with the following command:
|
||||
|
||||
```bash
|
||||
cd apps/explorer && cp .env.testnet .env.local
|
||||
yarn nx run explorer:serve
|
||||
docker build . --build-arg APP=[YOUR APP] --tag=[TAG]
|
||||
```
|
||||
|
||||
In order to run a container:
|
||||
|
||||
```bash
|
||||
docker run -p 3000:80 [TAG]
|
||||
```
|
||||
|
||||
## Config
|
||||
|
||||
As envrionment variabels are build time and not run time in frontend applications. We have built a system which allows for passing run time environment variables, this generates a JSON file that will override the default environement vairbales that the container was built with (which is always testnet, using the default .env files).
|
||||
|
||||
In order to override specific environment variables you can pass these to the container like this:
|
||||
|
||||
```bash
|
||||
docker run -e NX_VEGA_URL=https://n04.d.vega.xyz/query -p 3000:80 [TAG]
|
||||
```
|
||||
|
||||
Which will now point the app to use a devnet data node. To see a list of all possible config properties see the readme.md for each app in the app directory.
|
||||
|
||||
## Vega capsule
|
||||
|
||||
Coming soon! You will be able to run the containers within Vega Capsule.
|
||||
|
||||
You can run against a local intance of Vega Cpasule today by using the .env.capsule present in the apps.
|
||||
|
||||
# 📑 License
|
||||
|
||||
[MIT](./LICENSE)
|
||||
|
@ -1,11 +1,11 @@
|
||||
NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-explorer-api"
|
||||
NX_TENDERMINT_URL = 'http://localhost:26617'
|
||||
NX_TENDERMINT_WEBSOCKET_URL = 'wss://localhost:26617/websocket'
|
||||
NX_VEGA_URL = "http://localhost:3028/query"
|
||||
NX_VEGA_ENV = 'LOCAL'
|
||||
NX_VEGA_REST = 'http://localhost:3029'
|
||||
NX_CHAIN_EXPLORER_URL=https://explorer.vega.trading/.netlify/functions/chain-explorer-api
|
||||
NX_TENDERMINT_URL=http://localhost:26617
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://localhost:26617/websocket
|
||||
NX_VEGA_URL=http://localhost:3028/query
|
||||
NX_VEGA_ENV=LOCAL
|
||||
NX_VEGA_REST=http://localhost:3029
|
||||
|
||||
CYPRESS_VEGA_TENDERMINT_URL='http://localhost:26617'
|
||||
CYPRESS_VEGA_TENDERMINT_URL=http://localhost:26617
|
||||
|
||||
NX_EXPLORER_ASSETS=1
|
||||
NX_EXPLORER_GENESIS=1
|
||||
|
@ -1,10 +1,10 @@
|
||||
# App configuration variables
|
||||
NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-explorer-api"
|
||||
NX_TENDERMINT_URL = "https://n04.d.vega.xyz/tm"
|
||||
NX_TENDERMINT_WEBSOCKET_URL = "wss://n04.d.vega.xyz/tm/websocket"
|
||||
NX_VEGA_URL = "https://n04.d.vega.xyz/query"
|
||||
NX_VEGA_ENV = 'DEVNET'
|
||||
NX_VEGA_REST = 'https://n04.d.vega.xyz/datanode/rest'
|
||||
NX_CHAIN_EXPLORER_URL=https://explorer.vega.trading/.netlify/functions/chain-explorer-api
|
||||
NX_TENDERMINT_URL=https://n04.d.vega.xyz/tm
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://n04.d.vega.xyz/tm/websocket
|
||||
NX_VEGA_URL=https://n04.d.vega.xyz/query
|
||||
NX_VEGA_ENV=DEVNET
|
||||
NX_VEGA_REST=https://n04.d.vega.xyz/datanode/rest
|
||||
|
||||
# App flags
|
||||
NX_EXPLORER_ASSETS=1
|
||||
|
@ -1,10 +1,10 @@
|
||||
# App configuration variables
|
||||
NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-explorer-api"
|
||||
NX_TENDERMINT_URL = "https://mainnet-observer-proxy01.ops.vega.xyz/"
|
||||
NX_TENDERMINT_WEBSOCKET_URL = "wss://mainnet-observer-proxy01.ops.vega.xyz/websocket"
|
||||
NX_VEGA_URL = "https://api.token.vega.xyz/query"
|
||||
NX_VEGA_ENV = 'MAINNET'
|
||||
NX_VEGA_REST = 'https://api.token.vega.xyz/'
|
||||
NX_CHAIN_EXPLORER_URL=https://explorer.vega.trading/.netlify/functions/chain-explorer-api
|
||||
NX_TENDERMINT_URL=https://mainnet-observer-proxy01.ops.vega.xyz/
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://mainnet-observer-proxy01.ops.vega.xyz/websocket
|
||||
NX_VEGA_URL=https://api.token.vega.xyz/query
|
||||
NX_VEGA_ENV=MAINNET
|
||||
NX_VEGA_REST=https://api.token.vega.xyz/
|
||||
|
||||
# App flags
|
||||
NX_EXPLORER_ASSETS=1
|
||||
|
@ -1,10 +1,10 @@
|
||||
# App configuration variables
|
||||
NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-explorer-api"
|
||||
NX_TENDERMINT_URL = "https://n03.s.vega.xyz/tm"
|
||||
NX_TENDERMINT_WEBSOCKET_URL = "wss://n03.s.vega.xyz/tm/websocket"
|
||||
NX_VEGA_URL = "https://n03.s.vega.xyz/query"
|
||||
NX_VEGA_ENV = 'STAGNET'
|
||||
NX_VEGA_REST = 'https://n03.s.vega.xyz/datanode/rest'
|
||||
NX_CHAIN_EXPLORER_URL=https://explorer.vega.trading/.netlify/functions/chain-explorer-api
|
||||
NX_TENDERMINT_URL=https://n03.s.vega.xyz/tm
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://n03.s.vega.xyz/tm/websocket
|
||||
NX_VEGA_URL=https://n03.s.vega.xyz/query
|
||||
NX_VEGA_ENV=STAGNET
|
||||
NX_VEGA_REST=https://n03.s.vega.xyz/datanode/rest
|
||||
|
||||
# App flags
|
||||
NX_EXPLORER_ASSETS=1
|
||||
|
@ -1,10 +1,10 @@
|
||||
# App configuration variables
|
||||
NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-explorer-api"
|
||||
NX_TENDERMINT_URL = "https://n03.stagnet2.vega.xyz/tm"
|
||||
NX_TENDERMINT_WEBSOCKET_URL = "wss://n03.stagnet2.vega.xyz/tm/websocket"
|
||||
NX_VEGA_URL = "https://n03.stagnet2.vega.xyz/query"
|
||||
NX_VEGA_ENV = 'STAGNET2'
|
||||
NX_VEGA_REST = 'https://n01.stagnet2.vega.xyz/datanode/rest'
|
||||
NX_CHAIN_EXPLORER_URL=https://explorer.vega.trading/.netlify/functions/chain-explorer-api
|
||||
NX_TENDERMINT_URL=https://n03.stagnet2.vega.xyz/tm
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://n03.stagnet2.vega.xyz/tm/websocket
|
||||
NX_VEGA_URL=https://n03.stagnet2.vega.xyz/query
|
||||
NX_VEGA_ENV=STAGNET2
|
||||
NX_VEGA_REST=https://n01.stagnet2.vega.xyz/datanode/rest
|
||||
|
||||
# App flags
|
||||
NX_EXPLORER_ASSETS=1
|
||||
|
@ -1,10 +1,10 @@
|
||||
# App configuration variables
|
||||
NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-explorer-api"
|
||||
NX_TENDERMINT_URL = "https://lb.testnet.vega.xyz/tm"
|
||||
NX_TENDERMINT_WEBSOCKET_URL = "wss://lb.testnet.vega.xyz/tm/websocket"
|
||||
NX_VEGA_URL = "https://lb.testnet.vega.xyz/query"
|
||||
NX_VEGA_ENV = 'TESTNET'
|
||||
NX_VEGA_REST = 'https://lb.testnet.vega.xyz/datanode/rest'
|
||||
NX_CHAIN_EXPLORER_URL=https://explorer.vega.trading/.netlify/functions/chain-explorer-api
|
||||
NX_TENDERMINT_URL=https://lb.testnet.vega.xyz/tm
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://lb.testnet.vega.xyz/tm/websocket
|
||||
NX_VEGA_URL=https://lb.testnet.vega.xyz/query
|
||||
NX_VEGA_ENV=TESTNET
|
||||
NX_VEGA_REST=https://lb.testnet.vega.xyz/datanode/rest
|
||||
|
||||
# App flags
|
||||
NX_EXPLORER_ASSETS=1
|
||||
|
@ -1,31 +1,18 @@
|
||||
# React Environment Variables
|
||||
# https://facebook.github.io/create-react-app/docs/adding-custom-environment-variables#expanding-environment-variables-in-env
|
||||
NX_CHAIN_EXPLORER_URL=https://explorer.vega.trading/.netlify/functions/chain-explorer-api
|
||||
NX_TENDERMINT_URL=http://localhost:26617
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://localhost:26617/websocket
|
||||
NX_VEGA_URL=http://localhost:3028/query
|
||||
NX_VEGA_ENV=LOCAL
|
||||
NX_VEGA_REST=http://localhost:3029
|
||||
|
||||
# Netlify Environment Variables
|
||||
# https://www.netlify.com/docs/continuous-deployment/#environment-variables
|
||||
NX_VERSION=$npm_package_version
|
||||
NX_REPOSITORY_URL=$REPOSITORY_URL
|
||||
NX_BRANCH=$BRANCH
|
||||
NX_PULL_REQUEST=$PULL_REQUEST
|
||||
NX_HEAD=$HEAD
|
||||
NX_COMMIT_REF=$COMMIT_REF
|
||||
NX_CONTEXT=$CONTEXT
|
||||
NX_REVIEW_ID=$REVIEW_ID
|
||||
NX_INCOMING_HOOK_TITLE=$INCOMING_HOOK_TITLE
|
||||
NX_INCOMING_HOOK_URL=$INCOMING_HOOK_URL
|
||||
NX_INCOMING_HOOK_BODY=$INCOMING_HOOK_BODY
|
||||
NX_URL=$URL
|
||||
NX_DEPLOY_URL=$DEPLOY_URL
|
||||
NX_DEPLOY_PRIME_URL=$DEPLOY_PRIME_URL
|
||||
|
||||
NX_CHAIN_EXPLORER_URL = 'https://explorer.vega.trading/.netlify/functions/chain-explorer-api'
|
||||
NX_TENDERMINT_URL = 'https://lb.testnet.vega.xyz/tm'
|
||||
NX_TENDERMINT_WEBSOCKET_URL = 'wss://lb.testnet.vega.xyz/tm/websocket'
|
||||
NX_VEGA_URL = 'https://lb.testnet.vega.xyz/query'
|
||||
NX_VEGA_ENV = 'TESTNET'
|
||||
NX_VEGA_REST = 'https://lb.testnet.vega.xyz/datanode/rest'
|
||||
NX_CHAIN_EXPLORER_URL=https://explorer.vega.trading/.netlify/functions/chain-explorer-api
|
||||
NX_TENDERMINT_URL=https://lb.testnet.vega.xyz/tm
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://lb.testnet.vega.xyz/tm/websocket
|
||||
NX_VEGA_URL=https://lb.testnet.vega.xyz/query
|
||||
NX_VEGA_ENV=TESTNET
|
||||
NX_VEGA_REST=https://lb.testnet.vega.xyz/datanode/rest
|
||||
NX_VEGA_NETWORKS='{"TESTNET":"https://explorer.fairground.wtf","MAINNET":"https://explorer.vega.xyz"}'
|
||||
CYPRESS_VEGA_TENDERMINT_URL='https://lb.testnet.vega.xyz/tm'
|
||||
CYPRESS_VEGA_TENDERMINT_URL=https://lb.testnet.vega.xyz/tm
|
||||
|
||||
# App flags
|
||||
NX_EXPLORER_ASSETS=1
|
||||
@ -34,3 +21,4 @@ NX_EXPLORER_GOVERNANCE = 1
|
||||
NX_EXPLORER_NETWORK_PARAMETERS=1
|
||||
NX_EXPLORER_PARTIES=1
|
||||
NX_EXPLORER_VALIDATORS=1
|
||||
NX_EXPLORER_MARKETS=1
|
||||
|
@ -1,11 +1,11 @@
|
||||
# App configuration variables
|
||||
NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-explorer-api"
|
||||
NX_TENDERMINT_URL = "http://localhost:26617"
|
||||
NX_TENDERMINT_WEBSOCKET_URL = "wss://localhost:26617/websocket"
|
||||
NX_VEGA_URL = "http://localhost:3028/query"
|
||||
NX_CHAIN_EXPLORER_URL=https://explorer.vega.trading/.netlify/functions/chain-explorer-api
|
||||
NX_TENDERMINT_URL=http://localhost:26617
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://localhost:26617/websocket
|
||||
NX_VEGA_URL=http://localhost:3028/query
|
||||
NX_VEGA_NETWORKS='{"TESTNET":"https://explorer.fairground.wtf","MAINNET":"https://explorer.vega.xyz"}'
|
||||
NX_VEGA_ENV = 'LOCAL'
|
||||
NX_VEGA_REST = 'http://localhost:3029'
|
||||
NX_VEGA_ENV=LOCAL
|
||||
NX_VEGA_REST=http://localhost:3029
|
||||
|
||||
# App flags
|
||||
NX_EXPLORER_ASSETS=1
|
||||
|
@ -1,8 +1,8 @@
|
||||
# App configuration variables
|
||||
NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-explorer-api"
|
||||
NX_TENDERMINT_URL = "https://n04.d.vega.xyz/tm"
|
||||
NX_TENDERMINT_WEBSOCKET_URL = "wss://n04.d.vega.xyz/tm/websocket"
|
||||
NX_VEGA_URL = "https://n04.d.vega.xyz/query"
|
||||
NX_CHAIN_EXPLORER_URL=https://explorer.vega.trading/.netlify/functions/chain-explorer-api
|
||||
NX_TENDERMINT_URL=https://n04.d.vega.xyz/tm
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://n04.d.vega.xyz/tm/websocket
|
||||
NX_VEGA_URL=https://n04.d.vega.xyz/query
|
||||
NX_VEGA_NETWORKS='{"TESTNET":"https://explorer.fairground.wtf","MAINNET":"https://explorer.vega.xyz"}'
|
||||
NX_VEGA_ENV = 'DEVNET'
|
||||
NX_VEGA_REST = 'https://n04.d.vega.xyz/datanode/rest'
|
||||
NX_VEGA_ENV=DEVNET
|
||||
NX_VEGA_REST=https://n04.d.vega.xyz/datanode/rest
|
||||
|
@ -1,8 +1,8 @@
|
||||
# App configuration variables
|
||||
NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-explorer-api"
|
||||
NX_TENDERMINT_URL = "https://mainnet-observer-proxy01.ops.vega.xyz/"
|
||||
NX_TENDERMINT_WEBSOCKET_URL = "wss://mainnet-observer-proxy01.ops.vega.xyz/websocket"
|
||||
NX_VEGA_URL = "https://api.token.vega.xyz/query"
|
||||
NX_CHAIN_EXPLORER_URL=https://explorer.vega.trading/.netlify/functions/chain-explorer-api
|
||||
NX_TENDERMINT_URL=https://mainnet-observer-proxy01.ops.vega.xyz/
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://mainnet-observer-proxy01.ops.vega.xyz/websocket
|
||||
NX_VEGA_URL=https://api.token.vega.xyz/query
|
||||
NX_VEGA_NETWORKS='{"TESTNET":"https://explorer.fairground.wtf","MAINNET":"https://explorer.vega.xyz"}'
|
||||
NX_VEGA_ENV = 'MAINNET'
|
||||
NX_VEGA_REST = 'https://api.token.vega.xyz/'
|
||||
NX_VEGA_ENV=MAINNET
|
||||
NX_VEGA_REST=https://api.token.vega.xyz/
|
||||
|
@ -1,8 +1,8 @@
|
||||
# App configuration variables
|
||||
NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-explorer-api"
|
||||
NX_TENDERMINT_URL = "https://n03.s.vega.xyz/tm"
|
||||
NX_TENDERMINT_WEBSOCKET_URL = "wss://n03.s.vega.xyz/tm/websocket"
|
||||
NX_VEGA_URL = "https://n03.s.vega.xyz/query"
|
||||
NX_CHAIN_EXPLORER_URL=https://explorer.vega.trading/.netlify/functions/chain-explorer-api
|
||||
NX_TENDERMINT_URL=https://n03.s.vega.xyz/tm
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://n03.s.vega.xyz/tm/websocket
|
||||
NX_VEGA_URL=https://n03.s.vega.xyz/query
|
||||
NX_VEGA_NETWORKS='{"TESTNET":"https://explorer.fairground.wtf","MAINNET":"https://explorer.vega.xyz"}'
|
||||
NX_VEGA_ENV = 'STAGNET'
|
||||
NX_VEGA_REST = 'https://n03.s.vega.xyz/datanode/rest'
|
||||
NX_VEGA_ENV=STAGNET
|
||||
NX_VEGA_REST=https://n03.s.vega.xyz/datanode/rest
|
||||
|
@ -1,8 +1,8 @@
|
||||
# App configuration variables
|
||||
NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-explorer-api"
|
||||
NX_TENDERMINT_URL = "https://n03.stagnet2.vega.xyz/tm"
|
||||
NX_TENDERMINT_WEBSOCKET_URL = "wss://n03.stagnet2.vega.xyz/tm/websocket"
|
||||
NX_VEGA_URL = "https://n03.stagnet2.vega.xyz/query"
|
||||
NX_CHAIN_EXPLORER_URL=https://explorer.vega.trading/.netlify/functions/chain-explorer-api
|
||||
NX_TENDERMINT_URL=https://n03.stagnet2.vega.xyz/tm
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://n03.stagnet2.vega.xyz/tm/websocket
|
||||
NX_VEGA_URL=https://n03.stagnet2.vega.xyz/query
|
||||
NX_VEGA_NETWORKS='{"TESTNET":"https://explorer.fairground.wtf","MAINNET":"https://explorer.vega.xyz"}'
|
||||
NX_VEGA_ENV = 'STAGNET2'
|
||||
NX_VEGA_REST = 'https://n01.stagnet2.vega.xyz/datanode/rest'
|
||||
NX_VEGA_ENV=STAGNET2
|
||||
NX_VEGA_REST=https://n01.stagnet2.vega.xyz/datanode/rest
|
||||
|
@ -1,8 +1,8 @@
|
||||
# App configuration variables
|
||||
NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-explorer-api"
|
||||
NX_TENDERMINT_URL = "https://lb.testnet.vega.xyz/tm"
|
||||
NX_TENDERMINT_WEBSOCKET_URL = "wss://lb.testnet.vega.xyz/tm/websocket"
|
||||
NX_VEGA_URL = "https://lb.testnet.vega.xyz/query"
|
||||
NX_CHAIN_EXPLORER_URL=https://explorer.vega.trading/.netlify/functions/chain-explorer-api
|
||||
NX_TENDERMINT_URL=https://lb.testnet.vega.xyz/tm
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://lb.testnet.vega.xyz/tm/websocket
|
||||
NX_VEGA_URL=https://lb.testnet.vega.xyz/query
|
||||
NX_VEGA_NETWORKS='{"TESTNET":"https://explorer.fairground.wtf","MAINNET":"https://explorer.vega.xyz"}'
|
||||
NX_VEGA_ENV = 'TESTNET'
|
||||
NX_VEGA_REST = 'https://lb.testnet.vega.xyz/datanode/rest'
|
||||
NX_VEGA_ENV=TESTNET
|
||||
NX_VEGA_REST=https://lb.testnet.vega.xyz/datanode/rest
|
||||
|
7
apps/explorer/.env.vegacapsule
Normal file
7
apps/explorer/.env.vegacapsule
Normal file
@ -0,0 +1,7 @@
|
||||
# App configuration variables
|
||||
NX_CHAIN_EXPLORER_URL=https://explorer.vega.trading/.netlify/functions/chain-explorer-api
|
||||
NX_TENDERMINT_URL=http://localhost:26607/
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://localhost:26607/websocket
|
||||
NX_VEGA_URL=http://localhost:3003/query
|
||||
NX_VEGA_ENV=CUSTOM
|
||||
NX_VEGA_REST=http://localhost:3029/rest
|
5
apps/explorer/index.d.ts
vendored
Normal file
5
apps/explorer/index.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
/// <reference types="react-scripts" />
|
||||
|
||||
interface Window {
|
||||
_env_?: Record<string, string>;
|
||||
}
|
33
apps/explorer/src/app/config/env.ts
Normal file
33
apps/explorer/src/app/config/env.ts
Normal file
@ -0,0 +1,33 @@
|
||||
const windowOrDefault = (key: string) => {
|
||||
if (window._env_ && window._env_[key]) {
|
||||
return window._env_[key] as string;
|
||||
}
|
||||
return (process.env[key] as string) || '';
|
||||
};
|
||||
|
||||
const truthy = ['1', 'true'];
|
||||
|
||||
export const ENV = {
|
||||
// Data sources
|
||||
// Environment
|
||||
dsn: windowOrDefault('NX_EXPLORER_SENTRY_DSN'),
|
||||
envName: windowOrDefault('NX_VEGA_ENV'),
|
||||
dataSources: {
|
||||
chainExplorerUrl: windowOrDefault('NX_CHAIN_EXPLORER_URL'),
|
||||
tendermintUrl: windowOrDefault('NX_TENDERMINT_URL'),
|
||||
tendermintWebsocketUrl: windowOrDefault('NX_TENDERMINT_WEBSOCKET_URL'),
|
||||
dataNodeUrl: windowOrDefault('NX_VEGA_URL'),
|
||||
restEndpoint: windowOrDefault('NX_VEGA_REST'),
|
||||
},
|
||||
flags: {
|
||||
assets: truthy.includes(windowOrDefault('NX_EXPLORER_ASSETS')),
|
||||
genesis: truthy.includes(windowOrDefault('NX_EXPLORER_GENESIS')),
|
||||
governance: truthy.includes(windowOrDefault('NX_EXPLORER_GOVERNANCE')),
|
||||
markets: truthy.includes(windowOrDefault('NX_EXPLORER_MARKETS')),
|
||||
networkParameters: truthy.includes(
|
||||
windowOrDefault('NX_EXPLORER_NETWORK_PARAMETERS')
|
||||
),
|
||||
parties: truthy.includes(windowOrDefault('NX_EXPLORER_PARTIES')),
|
||||
validators: truthy.includes(windowOrDefault('NX_EXPLORER_VALIDATORS')),
|
||||
},
|
||||
};
|
5
apps/explorer/src/app/config/flags.ts
Normal file
5
apps/explorer/src/app/config/flags.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import { ENV } from './env';
|
||||
|
||||
export default {
|
||||
...ENV.flags,
|
||||
};
|
@ -1,8 +1,5 @@
|
||||
import { ENV } from './env';
|
||||
|
||||
export const DATA_SOURCES = {
|
||||
chainExplorerUrl: process.env['NX_CHAIN_EXPLORER_URL'] as string,
|
||||
tendermintUrl: process.env['NX_TENDERMINT_URL'] as string,
|
||||
tendermintWebsocketUrl: process.env['NX_TENDERMINT_WEBSOCKET_URL'] as string,
|
||||
dataNodeUrl: process.env['NX_VEGA_URL'] as string,
|
||||
envName: process.env['NX_VEGA_ENV'] as string,
|
||||
restEndpoint: process.env['NX_VEGA_REST'] as string,
|
||||
...ENV.dataSources,
|
||||
};
|
||||
|
@ -1,13 +0,0 @@
|
||||
const truthy = ['1', 'true'];
|
||||
|
||||
export default {
|
||||
assets: truthy.includes(process.env['NX_EXPLORER_ASSETS'] || ''),
|
||||
genesis: truthy.includes(process.env['NX_EXPLORER_GENESIS'] || ''),
|
||||
governance: truthy.includes(process.env['NX_EXPLORER_GOVERNANCE'] || ''),
|
||||
markets: truthy.includes(process.env['NX_EXPLORER_MARKETS'] || ''),
|
||||
networkParameters: truthy.includes(
|
||||
process.env['NX_EXPLORER_NETWORK_PARAMETERS'] || ''
|
||||
),
|
||||
parties: truthy.includes(process.env['NX_EXPLORER_PARTIES'] || ''),
|
||||
validators: truthy.includes(process.env['NX_EXPLORER_VALIDATORS'] || ''),
|
||||
};
|
@ -1,7 +1,8 @@
|
||||
import { DATA_SOURCES } from '../../config';
|
||||
import { StatsManager } from '@vegaprotocol/network-stats';
|
||||
import { ENV } from '../../config/env';
|
||||
|
||||
const envName = DATA_SOURCES.envName;
|
||||
const envName = ENV.envName;
|
||||
const restEndpoint = DATA_SOURCES.restEndpoint;
|
||||
const statsEndpoint = `${restEndpoint}/statistics`;
|
||||
const nodesEndpoint = `${restEndpoint}/nodes-data`;
|
||||
|
@ -14,7 +14,7 @@ import { Blocks } from './blocks/home';
|
||||
import { Tx } from './txs/id';
|
||||
import { Txs as TxHome } from './txs/home';
|
||||
import { PendingTxs } from './pending';
|
||||
import flags from '../lib/flags';
|
||||
import flags from '../config/flags';
|
||||
import { t } from '@vegaprotocol/react-helpers';
|
||||
import { Routes } from './route-names';
|
||||
import { NetworkParameters } from './network-parameters';
|
||||
|
1
apps/explorer/src/assets/env-config.js
Normal file
1
apps/explorer/src/assets/env-config.js
Normal file
@ -0,0 +1 @@
|
||||
window._env_ = {};
|
@ -18,6 +18,7 @@
|
||||
href="https://static.vega.xyz/favicon.ico"
|
||||
/>
|
||||
<link rel="stylesheet" href="https://static.vega.xyz/fonts.css" />
|
||||
<script src="./assets/env-config.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
@ -6,8 +6,9 @@ import { BrowserRouter } from 'react-router-dom';
|
||||
import './styles.css';
|
||||
|
||||
import App from './app/app';
|
||||
import { ENV } from './app/config/env';
|
||||
|
||||
const dsn = process.env['NX_EXPLORER_SENTRY_DSN'];
|
||||
const { dsn } = ENV;
|
||||
|
||||
/* istanbul ignore next */
|
||||
if (dsn) {
|
||||
@ -15,7 +16,7 @@ if (dsn) {
|
||||
dsn,
|
||||
integrations: [new BrowserTracing()],
|
||||
tracesSampleRate: 1,
|
||||
environment: process.env['NX_VEGA_ENV'],
|
||||
environment: ENV.envName,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,6 @@ NX_URL=$URL
|
||||
NX_DEPLOY_URL=$DEPLOY_URL
|
||||
NX_DEPLOY_PRIME_URL=$DEPLOY_PRIME_URL
|
||||
|
||||
NX_VEGA_URL = "https://lb.testnet.vega.xyz/query"
|
||||
NX_VEGA_ENV = 'TESTNET'
|
||||
NX_VEGA_REST = 'https://lb.testnet.vega.xyz/datanode/rest'
|
||||
NX_VEGA_URL=https://lb.testnet.vega.xyz/query
|
||||
NX_VEGA_ENV=TESTNET
|
||||
NX_VEGA_REST=https://lb.testnet.vega.xyz/datanode/rest
|
||||
|
@ -1,4 +1,4 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_URL = "http://localhost:3028/query"
|
||||
NX_VEGA_ENV = 'LOCAL'
|
||||
NX_VEGA_REST = 'http://localhost:3029'
|
||||
NX_VEGA_URL=http://localhost:3028/query
|
||||
NX_VEGA_ENV=LOCAL
|
||||
NX_VEGA_REST=http://localhost:3029
|
||||
|
@ -1,4 +1,4 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_URL = "https://n04.d.vega.xyz/query"
|
||||
NX_VEGA_ENV = 'DEVNET'
|
||||
NX_VEGA_REST = 'https://n04.d.vega.xyz/datanode/rest'
|
||||
NX_VEGA_URL=https://n04.d.vega.xyz/query
|
||||
NX_VEGA_ENV=DEVNET
|
||||
NX_VEGA_REST=https://n04.d.vega.xyz/datanode/rest
|
||||
|
@ -1,4 +1,4 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_URL = "https://api.token.vega.xyz/query"
|
||||
NX_VEGA_ENV = 'MAINNET'
|
||||
NX_VEGA_REST = 'https://api.token.vega.xyz/'
|
||||
NX_VEGA_URL=https://api.token.vega.xyz/query
|
||||
NX_VEGA_ENV=MAINNET
|
||||
NX_VEGA_REST=https://api.token.vega.xyz/
|
||||
|
@ -1,4 +1,4 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_URL = "https://n03.s.vega.xyz/query"
|
||||
NX_VEGA_ENV = 'STAGNET'
|
||||
NX_VEGA_REST = 'https://n03.s.vega.xyz/datanode/rest'
|
||||
NX_VEGA_URL=https://n03.s.vega.xyz/query
|
||||
NX_VEGA_ENV=STAGNET
|
||||
NX_VEGA_REST=https://n03.s.vega.xyz/datanode/rest
|
||||
|
@ -1,4 +1,4 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_URL = "https://n03.stagnet2.vega.xyz/query"
|
||||
NX_VEGA_ENV = 'STAGNET2'
|
||||
NX_VEGA_REST = 'https://n01.stagnet2.vega.xyz/datanode/rest'
|
||||
NX_VEGA_URL=https://n03.stagnet2.vega.xyz/query
|
||||
NX_VEGA_ENV=STAGNET2
|
||||
NX_VEGA_REST=https://n01.stagnet2.vega.xyz/datanode/rest
|
||||
|
@ -1,4 +1,4 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_URL = "https://lb.testnet.vega.xyz/query"
|
||||
NX_VEGA_ENV = 'TESTNET'
|
||||
NX_VEGA_REST = 'https://lb.testnet.vega.xyz/datanode/rest'
|
||||
NX_VEGA_URL=https://lb.testnet.vega.xyz/query
|
||||
NX_VEGA_ENV=TESTNET
|
||||
NX_VEGA_REST=https://lb.testnet.vega.xyz/datanode/rest
|
||||
|
@ -1,4 +1,4 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = 'TESTNET'
|
||||
CYPRESS_VEGA_ENV = 'TESTNET'
|
||||
NX_VEGA_REST = 'https://lb.testnet.vega.xyz/datanode/rest'
|
||||
NX_VEGA_ENV=TESTNET
|
||||
CYPRESS_VEGA_ENV=TESTNET
|
||||
NX_VEGA_REST=https://lb.testnet.vega.xyz/datanode/rest
|
||||
|
@ -1,4 +1,4 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = 'DEVNET'
|
||||
CYPRESS_VEGA_ENV = 'DEVNET'
|
||||
NX_VEGA_REST = 'https://n04.d.vega.xyz/datanode/rest'
|
||||
NX_VEGA_ENV=DEVNET
|
||||
CYPRESS_VEGA_ENV=DEVNET
|
||||
NX_VEGA_REST=https://n04.d.vega.xyz/datanode/rest
|
||||
|
@ -1,4 +1,4 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = 'MAINNET'
|
||||
CYPRESS_VEGA_ENV = 'MAINNET'
|
||||
NX_VEGA_REST = 'https://api.token.vega.xyz/'
|
||||
NX_VEGA_ENV=MAINNET
|
||||
CYPRESS_VEGA_ENV=MAINNET
|
||||
NX_VEGA_REST=https://api.token.vega.xyz/
|
||||
|
@ -1,4 +1,4 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = 'STAGNET 1'
|
||||
CYPRESS_VEGA_ENV = 'STAGNET 1'
|
||||
NX_VEGA_REST = 'https://n03.s.vega.xyz/datanode/rest'
|
||||
NX_VEGA_ENV=STAGNET 1
|
||||
CYPRESS_VEGA_ENV=STAGNET 1
|
||||
NX_VEGA_REST=https://n03.s.vega.xyz/datanode/rest
|
||||
|
@ -1,4 +1,4 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = 'STAGNET 2'
|
||||
CYPRESS_VEGA_ENV = 'STAGNET 2'
|
||||
NX_VEGA_REST = 'https://n01.stagnet2.vega.xyz/datanode/rest'
|
||||
NX_VEGA_ENV=STAGNET 2
|
||||
CYPRESS_VEGA_ENV=STAGNET 2
|
||||
NX_VEGA_REST=https://n01.stagnet2.vega.xyz/datanode/rest
|
||||
|
@ -1,4 +1,4 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = 'TESTNET'
|
||||
CYPRESS_VEGA_ENV = 'TESTNET'
|
||||
NX_VEGA_REST = 'https://lb.testnet.vega.xyz/datanode/rest'
|
||||
NX_VEGA_ENV=TESTNET
|
||||
CYPRESS_VEGA_ENV=TESTNET
|
||||
NX_VEGA_REST=https://lb.testnet.vega.xyz/datanode/rest
|
||||
|
@ -1,3 +1,3 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = 'MAINNET'
|
||||
NX_VEGA_REST = 'https://api.token.vega.xyz/'
|
||||
NX_VEGA_ENV=MAINNET
|
||||
NX_VEGA_REST=https://api.token.vega.xyz/
|
||||
|
@ -1,3 +1,3 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = 'DEVNET'
|
||||
NX_VEGA_REST = 'https://n04.d.vega.xyz/datanode/rest'
|
||||
NX_VEGA_ENV=DEVNET
|
||||
NX_VEGA_REST=https://n04.d.vega.xyz/datanode/rest
|
||||
|
@ -1,3 +1,3 @@
|
||||
# App configuration variables. No overrides for default urls
|
||||
NX_VEGA_ENV = 'MAINNET'
|
||||
NX_VEGA_REST = 'https://api.token.vega.xyz/'
|
||||
NX_VEGA_ENV=MAINNET
|
||||
NX_VEGA_REST=https://api.token.vega.xyz/
|
||||
|
@ -1,3 +1,3 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = 'STAGNET1'
|
||||
NX_VEGA_REST = 'https://n03.s.vega.xyz/datanode/rest'
|
||||
NX_VEGA_ENV=STAGNET1;
|
||||
NX_VEGA_REST=https://n03.s.vega.xyz/datanode/rest;
|
||||
|
@ -1,3 +1,3 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = 'STAGNET2'
|
||||
NX_VEGA_REST = 'https://n03.stagnet2.vega.xyz/datanode/rest'
|
||||
NX_VEGA_REST=https://n01.stagnet2.vega.xyz/datanode/rest;
|
||||
NX_VEGA_ENV=STAGNET2;
|
||||
|
@ -1,3 +1,3 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = 'TESTNET'
|
||||
NX_VEGA_REST = 'https://lb.testnet.vega.xyz/datanode/rest'
|
||||
NX_VEGA_ENV=TESTNET
|
||||
NX_VEGA_REST=https://lb.testnet.vega.xyz/datanode/rest
|
||||
|
@ -19,11 +19,11 @@ REACT_APP_DEPLOY_URL=$DEPLOY_URL
|
||||
REACT_APP_DEPLOY_PRIME_URL=$DEPLOY_PRIME_URL
|
||||
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = "TESTNET"
|
||||
NX_VEGA_URL = "https://lb.testnet.vega.xyz/query"
|
||||
NX_VEGA_ENV=TESTNET
|
||||
NX_VEGA_URL=https://lb.testnet.vega.xyz/query
|
||||
NX_ETHEREUM_CHAIN_ID=3
|
||||
NX_ETHEREUM_PROVIDER_URL = "https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8"
|
||||
NX_ETHERSCAN_URL = "https://ropsten.etherscan.io"
|
||||
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
||||
NX_FAIRGROUND=false
|
||||
|
||||
#Test configuration variables
|
||||
|
@ -1,6 +1,6 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = "DEVNET"
|
||||
NX_VEGA_URL = "https://n04.d.vega.xyz/query"
|
||||
NX_VEGA_ENV=DEVNET
|
||||
NX_VEGA_URL=https://n04.d.vega.xyz/query
|
||||
NX_ETHEREUM_CHAIN_ID=3
|
||||
NX_ETHEREUM_PROVIDER_URL = "https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8"
|
||||
NX_ETHERSCAN_URL = "https://ropsten.etherscan.io"
|
||||
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
||||
|
@ -1,6 +1,6 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = "MAINNET"
|
||||
NX_VEGA_URL = "https://api.token.vega.xyz/query"
|
||||
NX_VEGA_ENV=MAINNET
|
||||
NX_VEGA_URL=https://api.token.vega.xyz/query
|
||||
NX_ETHEREUM_CHAIN_ID=1
|
||||
NX_ETHEREUM_PROVIDER_URL = "https://mainnet.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8"
|
||||
NX_ETHERSCAN_URL = "https://etherscan.io"
|
||||
NX_ETHEREUM_PROVIDER_URL=https://mainnet.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||
NX_ETHERSCAN_URL=https://etherscan.io
|
||||
|
@ -1,6 +1,6 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = "STAGNET"
|
||||
NX_VEGA_URL = "https://n03.s.vega.xyz/query"
|
||||
NX_VEGA_ENV=STAGNET
|
||||
NX_VEGA_URL=https://n03.s.vega.xyz/query
|
||||
NX_ETHEREUM_CHAIN_ID=3
|
||||
NX_ETHEREUM_PROVIDER_URL = "https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8"
|
||||
NX_ETHERSCAN_URL = "https://ropsten.etherscan.io"
|
||||
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
||||
|
@ -1,6 +1,6 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = "STAGNET2"
|
||||
NX_VEGA_URL = "https://n03.stagnet2.vega.xyz/query"
|
||||
NX_VEGA_ENV=STAGNET2
|
||||
NX_VEGA_URL=https://n03.stagnet2.vega.xyz/query
|
||||
NX_ETHEREUM_CHAIN_ID=3
|
||||
NX_ETHEREUM_PROVIDER_URL = "https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8"
|
||||
NX_ETHERSCAN_URL = "https://ropsten.etherscan.io"
|
||||
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
||||
|
@ -1,6 +1,6 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = "TESTNET"
|
||||
NX_VEGA_URL = "https://lb.testnet.vega.xyz/query"
|
||||
NX_VEGA_ENV=TESTNET
|
||||
NX_VEGA_URL=https://lb.testnet.vega.xyz/query
|
||||
NX_ETHEREUM_CHAIN_ID=3
|
||||
NX_ETHEREUM_PROVIDER_URL = "https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8"
|
||||
NX_ETHERSCAN_URL = "https://ropsten.etherscan.io"
|
||||
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
||||
|
@ -19,11 +19,11 @@ REACT_APP_DEPLOY_URL=$DEPLOY_URL
|
||||
REACT_APP_DEPLOY_PRIME_URL=$DEPLOY_PRIME_URL
|
||||
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = "TESTNET"
|
||||
NX_VEGA_URL = "https://lb.testnet.vega.xyz/query"
|
||||
NX_VEGA_ENV=TESTNET
|
||||
NX_VEGA_URL=https://lb.testnet.vega.xyz/query
|
||||
NX_ETHEREUM_CHAIN_ID=3
|
||||
NX_ETHEREUM_PROVIDER_URL = "https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8"
|
||||
NX_ETHERSCAN_URL = "https://ropsten.etherscan.io"
|
||||
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
||||
NX_FAIRGROUND=false
|
||||
NX_IS_NEW_BRIDGE_CONTRACT=true
|
||||
NX_VEGA_NETWORKS='{"DEVNET":"https://dev.token.vega.xyz","STAGNET":"https://dev.token.vega.xyz","STAGNET2":"staging2.token.vega.xyz","TESTNET":"token.fairground.wtf","MAINNET":"token.vega.xyz"}'
|
||||
|
@ -1,7 +1,7 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = "DEVNET"
|
||||
NX_VEGA_URL = "https://n04.d.vega.xyz/query"
|
||||
NX_VEGA_ENV=DEVNET
|
||||
NX_VEGA_URL=https://n04.d.vega.xyz/query
|
||||
NX_VEGA_NETWORKS='{"DEVNET":"https://dev.token.vega.xyz","STAGNET":"https://dev.token.vega.xyz","STAGNET2":"staging2.token.vega.xyz","TESTNET":"token.fairground.wtf","MAINNET":"token.vega.xyz"}'
|
||||
NX_ETHEREUM_CHAIN_ID=3
|
||||
NX_ETHEREUM_PROVIDER_URL = "https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8"
|
||||
NX_ETHERSCAN_URL = "https://ropsten.etherscan.io"
|
||||
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
||||
|
@ -1,7 +1,7 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = "MAINNET"
|
||||
NX_VEGA_URL = "https://api.token.vega.xyz/query"
|
||||
NX_VEGA_ENV=MAINNET
|
||||
NX_VEGA_URL=https://api.token.vega.xyz/query
|
||||
NX_VEGA_NETWORKS='{"DEVNET":"https://dev.token.vega.xyz","STAGNET":"https://dev.token.vega.xyz","STAGNET2":"staging2.token.vega.xyz","TESTNET":"token.fairground.wtf","MAINNET":"token.vega.xyz"}'
|
||||
NX_ETHEREUM_CHAIN_ID=1
|
||||
NX_ETHEREUM_PROVIDER_URL = "https://mainnet.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8"
|
||||
NX_ETHERSCAN_URL = "https://etherscan.io"
|
||||
NX_ETHEREUM_PROVIDER_URL=https://mainnet.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||
NX_ETHERSCAN_URL=https://etherscan.io
|
||||
|
@ -1,7 +1,7 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = "STAGNET"
|
||||
NX_VEGA_URL = "https://n03.s.vega.xyz/query"
|
||||
NX_VEGA_ENV=STAGNET
|
||||
NX_VEGA_URL=https://n03.s.vega.xyz/query
|
||||
NX_VEGA_NETWORKS='{"DEVNET":"https://dev.token.vega.xyz","STAGNET":"https://dev.token.vega.xyz","STAGNET2":"staging2.token.vega.xyz","TESTNET":"token.fairground.wtf","MAINNET":"token.vega.xyz"}'
|
||||
NX_ETHEREUM_CHAIN_ID=3
|
||||
NX_ETHEREUM_PROVIDER_URL = "https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8"
|
||||
NX_ETHERSCAN_URL = "https://ropsten.etherscan.io"
|
||||
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
||||
|
@ -1,7 +1,7 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = "STAGNET2"
|
||||
NX_VEGA_URL = "https://n03.stagnet2.vega.xyz/query"
|
||||
NX_VEGA_ENV=STAGNET2
|
||||
NX_VEGA_URL=https://n03.stagnet2.vega.xyz/query
|
||||
NX_VEGA_NETWORKS='{"DEVNET":"https://dev.token.vega.xyz","STAGNET":"https://dev.token.vega.xyz","STAGNET2":"staging2.token.vega.xyz","TESTNET":"token.fairground.wtf","MAINNET":"token.vega.xyz"}'
|
||||
NX_ETHEREUM_CHAIN_ID=3
|
||||
NX_ETHEREUM_PROVIDER_URL = "https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8"
|
||||
NX_ETHERSCAN_URL = "https://ropsten.etherscan.io"
|
||||
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
||||
|
@ -1,7 +1,7 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = "TESTNET"
|
||||
NX_VEGA_URL = "https://lb.testnet.vega.xyz/query"
|
||||
NX_VEGA_ENV=TESTNET
|
||||
NX_VEGA_URL=https://lb.testnet.vega.xyz/query
|
||||
NX_VEGA_NETWORKS='{"DEVNET":"https://dev.token.vega.xyz","STAGNET":"https://dev.token.vega.xyz","STAGNET2":"staging2.token.vega.xyz","TESTNET":"token.fairground.wtf","MAINNET":"token.vega.xyz"}'
|
||||
NX_ETHEREUM_CHAIN_ID=3
|
||||
NX_ETHEREUM_PROVIDER_URL = "https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8"
|
||||
NX_ETHERSCAN_URL = "https://ropsten.etherscan.io"
|
||||
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
||||
|
5
apps/token/index.d.ts
vendored
Normal file
5
apps/token/index.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
/// <reference types="react-scripts" />
|
||||
|
||||
interface Window {
|
||||
_env_?: Record<string, string>;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import './i18n';
|
||||
import React from 'react';
|
||||
import { ApolloProvider } from '@apollo/client';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import { BrowserRouter as Router } from 'react-router-dom';
|
||||
import { AppLoader } from './app-loader';
|
||||
import { AppBanner } from './components/app-banner';
|
||||
@ -15,18 +15,28 @@ import { AppStateProvider } from './contexts/app-state/app-state-provider';
|
||||
import { ContractsProvider } from './contexts/contracts/contracts-provider';
|
||||
import { AppRouter } from './routes';
|
||||
import { Web3Provider } from '@vegaprotocol/web3';
|
||||
import { Connectors } from './lib/web3-connectors';
|
||||
import { VegaWalletDialogs } from './components/vega-wallet-dialogs';
|
||||
import { VegaWalletProvider } from '@vegaprotocol/wallet';
|
||||
import { EnvironmentProvider } from '@vegaprotocol/network-switcher';
|
||||
import { client } from './lib/apollo-client';
|
||||
import { createConnectors } from './lib/web3-connectors';
|
||||
import { ApolloProvider } from '@apollo/client';
|
||||
import { createClient } from './lib/apollo-client';
|
||||
import {
|
||||
EnvironmentProvider,
|
||||
useEnvironment,
|
||||
} from '@vegaprotocol/network-switcher';
|
||||
|
||||
function App() {
|
||||
const AppContainer = () => {
|
||||
const sideBar = React.useMemo(() => [<EthWallet />, <VegaWallet />], []);
|
||||
const { ETHEREUM_PROVIDER_URL, ETHEREUM_CHAIN_ID, VEGA_URL } =
|
||||
useEnvironment();
|
||||
const Connectors = useMemo(
|
||||
() => createConnectors(ETHEREUM_PROVIDER_URL, ETHEREUM_CHAIN_ID),
|
||||
[ETHEREUM_CHAIN_ID, ETHEREUM_PROVIDER_URL]
|
||||
);
|
||||
const client = useMemo(() => createClient(VEGA_URL), [VEGA_URL]);
|
||||
return (
|
||||
<ApolloProvider client={client}>
|
||||
<Router>
|
||||
<EnvironmentProvider>
|
||||
<AppStateProvider>
|
||||
<Web3Provider connectors={Connectors}>
|
||||
<Web3Connector>
|
||||
@ -52,10 +62,17 @@ function App() {
|
||||
</Web3Connector>
|
||||
</Web3Provider>
|
||||
</AppStateProvider>
|
||||
</EnvironmentProvider>
|
||||
</Router>
|
||||
</ApolloProvider>
|
||||
);
|
||||
};
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<EnvironmentProvider>
|
||||
<AppContainer />
|
||||
</EnvironmentProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
|
1
apps/token/src/assets/env-config.js
Normal file
1
apps/token/src/assets/env-config.js
Normal file
@ -0,0 +1 @@
|
||||
window._env_ = {};
|
@ -2,13 +2,12 @@ import { Link } from '@vegaprotocol/ui-toolkit';
|
||||
import { Trans } from 'react-i18next';
|
||||
|
||||
import { Links } from '../../config';
|
||||
import { ENV } from '../../config/env';
|
||||
|
||||
export const AppFooter = () => {
|
||||
return (
|
||||
<footer className="p-12 text-ui">
|
||||
<p className="mb-8">
|
||||
Version: {process.env['NX_COMMIT_REF'] || 'development'}
|
||||
</p>
|
||||
<p className="mb-8">Version: {ENV.commit || 'development'}</p>
|
||||
<p>
|
||||
<Trans
|
||||
i18nKey="footerLinksText"
|
||||
|
@ -17,7 +17,7 @@ import type {
|
||||
DelegationsVariables,
|
||||
} from './__generated__/Delegations';
|
||||
import { useVegaWallet } from '@vegaprotocol/wallet';
|
||||
import { useEnvironment } from '@vegaprotocol/network-switcher';
|
||||
import { useContracts } from '../../contexts/contracts/contracts-context';
|
||||
|
||||
const DELEGATIONS_QUERY = gql`
|
||||
query Delegations($partyId: ID!) {
|
||||
@ -60,7 +60,7 @@ const DELEGATIONS_QUERY = gql`
|
||||
`;
|
||||
|
||||
export const usePollForDelegations = () => {
|
||||
const { ADDRESSES } = useEnvironment();
|
||||
const { token: vegaToken } = useContracts();
|
||||
const { t } = useTranslation();
|
||||
const { keypair } = useVegaWallet();
|
||||
const client = useApolloClient();
|
||||
@ -118,8 +118,7 @@ export const usePollForDelegations = () => {
|
||||
.map((a) => {
|
||||
const isVega =
|
||||
a.asset.source.__typename === 'ERC20' &&
|
||||
a.asset.source.contractAddress ===
|
||||
ADDRESSES.vegaTokenAddress;
|
||||
a.asset.source.contractAddress === vegaToken.address;
|
||||
|
||||
return {
|
||||
isVega,
|
||||
@ -228,7 +227,7 @@ export const usePollForDelegations = () => {
|
||||
clearInterval(interval);
|
||||
mounted = false;
|
||||
};
|
||||
}, [client, keypair?.pub, t, ADDRESSES.vegaTokenAddress]);
|
||||
}, [client, keypair?.pub, t, vegaToken.address]);
|
||||
|
||||
return { delegations, currentStakeAvailable, delegatedNodes, accounts };
|
||||
};
|
||||
|
@ -1,13 +1,14 @@
|
||||
import { useEnvironment } from '@vegaprotocol/network-switcher';
|
||||
import { Button, Splash } from '@vegaprotocol/ui-toolkit';
|
||||
import { Web3ConnectDialog } from '@vegaprotocol/web3';
|
||||
import { useWeb3React } from '@web3-react/core';
|
||||
import type { ReactElement } from 'react';
|
||||
import { useCallback, useEffect } from 'react';
|
||||
import { useCallback, useEffect, useMemo } from 'react';
|
||||
import {
|
||||
AppStateActionType,
|
||||
useAppState,
|
||||
} from '../../contexts/app-state/app-state-context';
|
||||
import { Connectors } from '../../lib/web3-connectors';
|
||||
import { createConnectors } from '../../lib/web3-connectors';
|
||||
|
||||
interface Web3ConnectorProps {
|
||||
children: ReactElement;
|
||||
@ -15,13 +16,18 @@ interface Web3ConnectorProps {
|
||||
|
||||
export function Web3Connector({ children }: Web3ConnectorProps) {
|
||||
const { appState, appDispatch } = useAppState();
|
||||
const { ETHEREUM_PROVIDER_URL, ETHEREUM_CHAIN_ID } = useEnvironment();
|
||||
const Connectors = useMemo(
|
||||
() => createConnectors(ETHEREUM_PROVIDER_URL, ETHEREUM_CHAIN_ID),
|
||||
[ETHEREUM_CHAIN_ID, ETHEREUM_PROVIDER_URL]
|
||||
);
|
||||
const setDialogOpen = useCallback(
|
||||
(isOpen: boolean) => {
|
||||
appDispatch({ type: AppStateActionType.SET_ETH_WALLET_OVERLAY, isOpen });
|
||||
},
|
||||
[appDispatch]
|
||||
);
|
||||
const appChainId = Number(process.env['NX_ETHEREUM_CHAIN_ID']);
|
||||
const appChainId = Number(ETHEREUM_CHAIN_ID);
|
||||
return (
|
||||
<>
|
||||
<Web3Content appChainId={appChainId} setDialogOpen={setDialogOpen}>
|
||||
|
29
apps/token/src/config/env.ts
Normal file
29
apps/token/src/config/env.ts
Normal file
@ -0,0 +1,29 @@
|
||||
const windowOrDefault = (key: string) => {
|
||||
if (window._env_ && window._env_[key]) {
|
||||
return window._env_[key];
|
||||
}
|
||||
return process.env[key] || '';
|
||||
};
|
||||
|
||||
const TRUTHY = ['1', 'true'];
|
||||
|
||||
export const ENV = {
|
||||
// Environment
|
||||
dsn: windowOrDefault('NX_SENTRY_DSN'),
|
||||
envName: windowOrDefault('NX_VEGA_ENV'),
|
||||
commit: windowOrDefault('NX_COMMIT_REF'),
|
||||
branch: windowOrDefault('NX_BRANCH'),
|
||||
vegaUrl: windowOrDefault('NX_VEGA_URL'),
|
||||
flags: {
|
||||
NETWORK_DOWN: TRUTHY.includes(windowOrDefault('NX_NETWORK_DOWN')),
|
||||
HOSTED_WALLET_ENABLED: TRUTHY.includes(
|
||||
windowOrDefault('NX_HOSTED_WALLET_ENABLED')
|
||||
),
|
||||
MOCK: TRUTHY.includes(windowOrDefault('NX_MOCKED')),
|
||||
FAIRGROUND: TRUTHY.includes(windowOrDefault('NX_FAIRGROUND')),
|
||||
NETWORK_LIMITS: TRUTHY.includes(windowOrDefault('NX_NETWORK_LIMITS')),
|
||||
USE_NEW_BRIDGE_CONTRACT: TRUTHY.includes(
|
||||
process.env['NX_IS_NEW_BRIDGE_CONTRACT'] as string
|
||||
),
|
||||
},
|
||||
};
|
@ -1,14 +1,5 @@
|
||||
const TRUTHY = ['1', 'true'];
|
||||
import { ENV } from './env';
|
||||
|
||||
export const Flags = {
|
||||
NETWORK_DOWN: TRUTHY.includes(process.env['NX_NETWORK_DOWN'] as string),
|
||||
HOSTED_WALLET_ENABLED: TRUTHY.includes(
|
||||
process.env['NX_HOSTED_WALLET_ENABLED'] as string
|
||||
),
|
||||
MOCK: TRUTHY.includes(process.env['NX_MOCKED'] as string),
|
||||
FAIRGROUND: TRUTHY.includes(process.env['NX_FAIRGROUND'] as string),
|
||||
NETWORK_LIMITS: TRUTHY.includes(process.env['NX_NETWORK_LIMITS'] as string),
|
||||
USE_NEW_BRIDGE_CONTRACT: TRUTHY.includes(
|
||||
process.env['NX_IS_NEW_BRIDGE_CONTRACT'] as string
|
||||
),
|
||||
...ENV.flags,
|
||||
};
|
||||
|
@ -17,31 +17,6 @@ export type NetworkConfig = {
|
||||
[N in Networks]: string[];
|
||||
};
|
||||
|
||||
const splitFilter = (a: string) => a.split(',').filter((a) => a.length > 0);
|
||||
const getCustomNodesFromOptionalEnvironmentVariables = () => {
|
||||
const validatorUrls = process.env['CUSTOM_URLS'] || '';
|
||||
const validatorUrlsWithGraphQL =
|
||||
process.env['CUSTOM_URLS_WITH_GRAPHQL'] || '';
|
||||
|
||||
const validatorUrlsList: string[] = splitFilter(validatorUrls);
|
||||
const validatorUrlsWithGraphQLList: string[] = splitFilter(
|
||||
validatorUrlsWithGraphQL
|
||||
);
|
||||
|
||||
const customNodes: VegaNode[] = validatorUrlsList
|
||||
.map((a) => ({ url: a, api: { GraphQL: false } }))
|
||||
.concat(
|
||||
validatorUrlsWithGraphQLList.map((a) => ({
|
||||
url: a,
|
||||
api: { GraphQL: true },
|
||||
}))
|
||||
);
|
||||
|
||||
return customNodes;
|
||||
};
|
||||
|
||||
const customNodes = getCustomNodesFromOptionalEnvironmentVariables();
|
||||
|
||||
export const VegaNetworks: VegaNets = {
|
||||
[Networks.DEVNET]: {
|
||||
nodes: [
|
||||
@ -179,9 +154,6 @@ export const VegaNetworks: VegaNets = {
|
||||
},
|
||||
],
|
||||
},
|
||||
[Networks.CUSTOM]: {
|
||||
nodes: customNodes,
|
||||
},
|
||||
[Networks.MAINNET]: {
|
||||
nodes: [],
|
||||
},
|
||||
|
@ -11,7 +11,7 @@ import React from 'react';
|
||||
import { SplashLoader } from '../../components/splash-loader';
|
||||
import type { ContractsContextShape } from './contracts-context';
|
||||
import { ContractsContext } from './contracts-context';
|
||||
import { defaultProvider } from '../../lib/web3-connectors';
|
||||
import { createDefaultProvider } from '../../lib/web3-connectors';
|
||||
import { useEthereumConfig } from '@vegaprotocol/web3';
|
||||
import { useEnvironment } from '@vegaprotocol/network-switcher';
|
||||
|
||||
@ -21,14 +21,20 @@ import { useEnvironment } from '@vegaprotocol/network-switcher';
|
||||
export const ContractsProvider = ({ children }: { children: JSX.Element }) => {
|
||||
const { provider: activeProvider, account } = useWeb3React();
|
||||
const { config } = useEthereumConfig();
|
||||
const { VEGA_ENV, ADDRESSES } = useEnvironment();
|
||||
const { VEGA_ENV, ADDRESSES, ETHEREUM_PROVIDER_URL, ETHEREUM_CHAIN_ID } =
|
||||
useEnvironment();
|
||||
const [contracts, setContracts] =
|
||||
React.useState<ContractsContextShape | null>(null);
|
||||
const defaultProvider = createDefaultProvider(
|
||||
ETHEREUM_PROVIDER_URL,
|
||||
ETHEREUM_CHAIN_ID
|
||||
);
|
||||
|
||||
// Create instances of contract classes. If we have an account use a signer for the
|
||||
// contracts so that we can sign transactions, otherwise use the provider for just
|
||||
// reading data
|
||||
React.useEffect(() => {
|
||||
const run = async () => {
|
||||
let signer = null;
|
||||
|
||||
const provider = activeProvider ? activeProvider : defaultProvider;
|
||||
@ -42,8 +48,14 @@ export const ContractsProvider = ({ children }: { children: JSX.Element }) => {
|
||||
}
|
||||
|
||||
if (provider && config) {
|
||||
const staking = new StakingBridge(
|
||||
config.staking_bridge_contract.address,
|
||||
signer || provider
|
||||
);
|
||||
const vegaAddress = await staking.stakingToken();
|
||||
|
||||
setContracts({
|
||||
token: new Token(ADDRESSES.vegaTokenAddress, signer || provider),
|
||||
token: new Token(vegaAddress, signer || provider),
|
||||
staking: new StakingBridge(
|
||||
config.staking_bridge_contract.address,
|
||||
signer || provider
|
||||
@ -55,7 +67,9 @@ export const ContractsProvider = ({ children }: { children: JSX.Element }) => {
|
||||
claim: new Claim(ADDRESSES.claimAddress, signer || provider),
|
||||
});
|
||||
}
|
||||
}, [activeProvider, account, config, ADDRESSES, VEGA_ENV]);
|
||||
};
|
||||
run();
|
||||
}, [activeProvider, account, config, ADDRESSES, VEGA_ENV, defaultProvider]);
|
||||
|
||||
if (!contracts) {
|
||||
return (
|
||||
|
@ -12,7 +12,6 @@ const TRANCHES_URLS: { [N in Networks]: string } = {
|
||||
STAGNET: 'https://static.vega.xyz/assets/stagnet1-tranches.json',
|
||||
STAGNET2: 'https://static.vega.xyz/assets/stagnet2-tranches.json',
|
||||
DEVNET: 'https://static.vega.xyz/assets/devnet-tranches.json',
|
||||
CUSTOM: '',
|
||||
};
|
||||
|
||||
export function useTranches() {
|
||||
|
@ -25,6 +25,7 @@
|
||||
crossorigin="anonymous"
|
||||
/>
|
||||
<title>Vega Token dApp</title>
|
||||
<script src="./assets/env-config.js"></script>
|
||||
</head>
|
||||
<body class="h-full">
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
|
@ -8,7 +8,6 @@ import uniqBy from 'lodash/uniqBy';
|
||||
import { BigNumber } from './bignumber';
|
||||
import { addDecimal } from './decimals';
|
||||
import { deterministicShuffle } from './deterministic-shuffle';
|
||||
import { getDataNodeUrl } from './get-data-node-url';
|
||||
|
||||
// Create seed in memory. Validator list order will remain the same
|
||||
// until the page is refreshed.
|
||||
@ -16,9 +15,10 @@ const VALIDATOR_RANDOMISER_SEED = (
|
||||
Math.floor(Math.random() * 1000) + 1
|
||||
).toString();
|
||||
|
||||
export function createClient() {
|
||||
const { graphql } = getDataNodeUrl();
|
||||
|
||||
export function createClient(base?: string) {
|
||||
if (!base) {
|
||||
throw new Error('Base must be passed into createClient!');
|
||||
}
|
||||
const formatUintToNumber = (amount: string, decimals = 18) =>
|
||||
addDecimal(new BigNumber(amount), decimals).toString();
|
||||
|
||||
@ -155,7 +155,7 @@ export function createClient() {
|
||||
});
|
||||
|
||||
const httpLink = new HttpLink({
|
||||
uri: graphql,
|
||||
uri: base,
|
||||
credentials: 'same-origin',
|
||||
});
|
||||
|
||||
@ -172,5 +172,3 @@ export function createClient() {
|
||||
cache,
|
||||
});
|
||||
}
|
||||
|
||||
export const client = createClient();
|
||||
|
@ -1,5 +1,7 @@
|
||||
import { ENV } from '../config/env';
|
||||
|
||||
export function getDataNodeUrl() {
|
||||
const base = process.env['NX_VEGA_URL'];
|
||||
const base = ENV.vegaUrl;
|
||||
if (!base) {
|
||||
throw new Error('Environment variable NX_VEGA_URL must be set');
|
||||
}
|
||||
|
@ -4,34 +4,30 @@ import { initializeConnector } from '@web3-react/core';
|
||||
import { MetaMask } from '@web3-react/metamask';
|
||||
import { WalletConnect } from '@web3-react/walletconnect';
|
||||
|
||||
export const [metamask, metamaskHooks] = initializeConnector<MetaMask>(
|
||||
const [metamask, metamaskHooks] = initializeConnector<MetaMask>(
|
||||
(actions) => new MetaMask(actions)
|
||||
);
|
||||
|
||||
const CHAIN_ID = Number(process.env['NX_ETHEREUM_CHAIN_ID']);
|
||||
const PROVIDER_URL = process.env['NX_ETHEREUM_PROVIDER_URL'] as string;
|
||||
export const createDefaultProvider = (providerUrl: string, chainId: number) => {
|
||||
return new ethers.providers.JsonRpcProvider(providerUrl, chainId);
|
||||
};
|
||||
|
||||
if (isNaN(CHAIN_ID)) {
|
||||
export const createConnectors = (providerUrl: string, chainId: number) => {
|
||||
if (isNaN(chainId)) {
|
||||
throw new Error('Invalid Ethereum chain ID for environment');
|
||||
}
|
||||
|
||||
export const [walletconnect, walletconnectHooks] =
|
||||
const [walletconnect, walletconnectHooks] =
|
||||
initializeConnector<WalletConnect>(
|
||||
(actions) =>
|
||||
new WalletConnect(actions, {
|
||||
rpc: {
|
||||
[CHAIN_ID]: PROVIDER_URL,
|
||||
[chainId]: providerUrl,
|
||||
},
|
||||
}),
|
||||
[CHAIN_ID]
|
||||
[chainId]
|
||||
);
|
||||
|
||||
export const defaultProvider = new ethers.providers.JsonRpcProvider(
|
||||
PROVIDER_URL,
|
||||
CHAIN_ID
|
||||
);
|
||||
|
||||
export const Connectors: [MetaMask | WalletConnect, Web3ReactHooks][] = [
|
||||
return [
|
||||
[metamask, metamaskHooks],
|
||||
[walletconnect, walletconnectHooks],
|
||||
];
|
||||
] as [MetaMask | WalletConnect, Web3ReactHooks][];
|
||||
};
|
||||
|
@ -7,11 +7,12 @@ import ReactDOM from 'react-dom';
|
||||
|
||||
import App from './app';
|
||||
import reportWebVitals from './report-web-vitals';
|
||||
import { ENV } from './config/env';
|
||||
|
||||
const dsn = process.env['NX_SENTRY_DSN'] || false;
|
||||
const environment = process.env['NX_VEGA_ENV'] || 'local';
|
||||
const commit = process.env['NX_COMMIT_REF'] || 'local';
|
||||
const branch = process.env['NX_BRANCH'] || 'unknown';
|
||||
const dsn = ENV.dsn || false;
|
||||
const environment = ENV.envName || 'local';
|
||||
const commit = ENV.commit || 'local';
|
||||
const branch = ENV.branch || 'unknown';
|
||||
|
||||
/* istanbul ignore next */
|
||||
if (dsn) {
|
||||
|
@ -9,6 +9,7 @@ import { formatNumber } from '../../../lib/format-number';
|
||||
import { TokenDetailsCirculating } from './token-details-circulating';
|
||||
import { SplashLoader } from '../../../components/splash-loader';
|
||||
import { useEthereumConfig } from '@vegaprotocol/web3';
|
||||
import { useContracts } from '../../../contexts/contracts/contracts-context';
|
||||
|
||||
export const TokenDetails = ({
|
||||
totalSupply,
|
||||
@ -17,11 +18,12 @@ export const TokenDetails = ({
|
||||
totalSupply: BigNumber;
|
||||
totalStaked: BigNumber;
|
||||
}) => {
|
||||
const { ADDRESSES, ETHERSCAN_URL } = useEnvironment();
|
||||
const { ETHERSCAN_URL } = useEnvironment();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { tranches, loading, error } = useTranches();
|
||||
const { config } = useEthereumConfig();
|
||||
const { token } = useContracts();
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
@ -47,10 +49,9 @@ export const TokenDetails = ({
|
||||
data-testid="token-address"
|
||||
title={t('View on Etherscan (opens in a new tab)')}
|
||||
className="font-mono"
|
||||
href={`${ETHERSCAN_URL}/address/${ADDRESSES.vegaTokenAddress}`}
|
||||
target="_blank"
|
||||
href={`${ETHERSCAN_URL}/address/${token.address}`}
|
||||
>
|
||||
{ADDRESSES.vegaTokenAddress}
|
||||
{token.address}
|
||||
</Link>
|
||||
</KeyValueTableRow>
|
||||
<KeyValueTableRow>
|
||||
|
@ -3,7 +3,6 @@ import { Trans, useTranslation } from 'react-i18next';
|
||||
import { Link, useParams, useOutletContext } from 'react-router-dom';
|
||||
|
||||
import { TransactionCallout } from '../../../components/transaction-callout';
|
||||
import { useEnvironment } from '@vegaprotocol/network-switcher';
|
||||
import { useAppState } from '../../../contexts/app-state/app-state-context';
|
||||
import { useContracts } from '../../../contexts/contracts/contracts-context';
|
||||
import {
|
||||
@ -25,7 +24,6 @@ export const RedeemFromTranche = () => {
|
||||
address: string;
|
||||
}>();
|
||||
const { vesting } = useContracts();
|
||||
const { ADDRESSES } = useEnvironment();
|
||||
const { t } = useTranslation();
|
||||
const {
|
||||
appState: { lien, totalVestedBalance, trancheBalances, totalLockedBalance },
|
||||
@ -44,6 +42,8 @@ export const RedeemFromTranche = () => {
|
||||
perform,
|
||||
dispatch: txDispatch,
|
||||
} = useTransaction(() => vesting.withdrawFromTranche(numberId));
|
||||
const { token } = useContracts();
|
||||
|
||||
const redeemedAmount = React.useMemo(() => {
|
||||
return (
|
||||
trancheBalances.find(({ id: bId }) => bId.toString() === id?.toString())
|
||||
@ -111,7 +111,7 @@ export const RedeemFromTranche = () => {
|
||||
{t(
|
||||
'The VEGA token address is {{address}}, make sure you add this to your wallet to see your tokens',
|
||||
{
|
||||
address: ADDRESSES.vegaTokenAddress,
|
||||
address: token.address,
|
||||
}
|
||||
)}
|
||||
</p>
|
||||
|
1
apps/trading-e2e/.env
Normal file
1
apps/trading-e2e/.env
Normal file
@ -0,0 +1 @@
|
||||
NX_USE_ENV_OVERRIDES=0
|
@ -14,7 +14,6 @@
|
||||
"chromeWebSecurity": false,
|
||||
"projectId": "et4snf",
|
||||
"defaultCommandTimeout": 10000,
|
||||
|
||||
"env": {
|
||||
"TRADING_TEST_VEGA_WALLET_NAME": "UI_Trading_Test",
|
||||
"ETHEREUM_PROVIDER_URL": "https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8",
|
||||
@ -26,6 +25,8 @@
|
||||
"ETHEREUM_WALLET_ADDRESS": "0x265Cc6d39a1B53d0d92068443009eE7410807158",
|
||||
"ETHERSCAN_URL": "https://ropsten.etherscan.io",
|
||||
"tsConfig": "tsconfig.json",
|
||||
"TAGS": "not @todo and not @ignore and not @manual"
|
||||
"TAGS": "not @todo and not @ignore and not @manual",
|
||||
"TRADING_TEST_VEGA_WALLET_PASSPHRASE": "123",
|
||||
"ETH_WALLET_MNEMONIC": "ugly gallery notice network true range brave clarify flat logic someone chunk"
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +1,8 @@
|
||||
# React Environment Variables
|
||||
# https://facebook.github.io/create-react-app/docs/adding-custom-environment-variables#expanding-environment-variables-in-env
|
||||
|
||||
# Netlify Environment Variables
|
||||
# https://www.netlify.com/docs/continuous-deployment/#environment-variables
|
||||
NX_VERSION=$npm_package_version
|
||||
NX_REPOSITORY_URL=$REPOSITORY_URL
|
||||
NX_BRANCH=$BRANCH
|
||||
NX_PULL_REQUEST=$PULL_REQUEST
|
||||
NX_HEAD=$HEAD
|
||||
NX_COMMIT_REF=$COMMIT_REF
|
||||
NX_CONTEXT=$CONTEXT
|
||||
NX_REVIEW_ID=$REVIEW_ID
|
||||
NX_INCOMING_HOOK_TITLE=$INCOMING_HOOK_TITLE
|
||||
NX_INCOMING_HOOK_URL=$INCOMING_HOOK_URL
|
||||
NX_INCOMING_HOOK_BODY=$INCOMING_HOOK_BODY
|
||||
NX_URL=$URL
|
||||
NX_DEPLOY_URL=$DEPLOY_URL
|
||||
NX_DEPLOY_PRIME_URL=$DEPLOY_PRIME_URL
|
||||
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = "TESTNET"
|
||||
NX_VEGA_URL = "https://lb.testnet.vega.xyz/query"
|
||||
NX_VEGA_ENV=TESTNET
|
||||
NX_VEGA_URL=https://lb.testnet.vega.xyz/query
|
||||
NX_ETHEREUM_CHAIN_ID=3
|
||||
NX_ETHEREUM_PROVIDER_URL = "https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8"
|
||||
NX_ETHERSCAN_URL = "https://ropsten.etherscan.io"
|
||||
NX_VEGA_NETWORKS='{\"MAINNET\":\"https://alpha.console.vega.xyz\"}'
|
||||
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
||||
NX_VEGA_NETWORKS={\"MAINNET\":\"https://alpha.console.vega.xyz\"}
|
||||
NX_USE_ENV_OVERRIDES=1
|
||||
|
@ -1,7 +1,7 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = "DEVNET"
|
||||
NX_VEGA_URL = "https://n04.d.vega.xyz/query"
|
||||
NX_VEGA_NETWORKS='{\"MAINNET\":\"https://alpha.console.vega.xyz\"}'
|
||||
NX_VEGA_ENV=DEVNET
|
||||
NX_VEGA_URL=https://n04.d.vega.xyz/query
|
||||
NX_VEGA_NETWORKS={\"MAINNET\":\"https://alpha.console.vega.xyz\"}
|
||||
NX_ETHEREUM_CHAIN_ID=3
|
||||
NX_ETHEREUM_PROVIDER_URL = "https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8"
|
||||
NX_ETHERSCAN_URL = "https://ropsten.etherscan.io"
|
||||
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
||||
|
@ -1,7 +1,7 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = "MAINNET"
|
||||
NX_VEGA_URL = "https://api.token.vega.xyz/query"
|
||||
NX_VEGA_ENV=MAINNET
|
||||
NX_VEGA_URL=https://api.token.vega.xyz/query
|
||||
NX_VEGA_NETWORKS='{\"MAINNET\":\"https://alpha.console.vega.xyz\"}'
|
||||
NX_ETHEREUM_CHAIN_ID=1
|
||||
NX_ETHEREUM_PROVIDER_URL = "https://mainnet.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8"
|
||||
NX_ETHERSCAN_URL = "https://etherscan.io"
|
||||
NX_ETHEREUM_PROVIDER_URL=https://mainnet.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||
NX_ETHERSCAN_URL=https://etherscan.io
|
||||
|
@ -1,7 +1,7 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = "STAGNET"
|
||||
NX_VEGA_URL = "https://n03.s.vega.xyz/query"
|
||||
NX_VEGA_ENV=STAGNET
|
||||
NX_VEGA_URL=https://n03.s.vega.xyz/query
|
||||
NX_VEGA_NETWORKS='{\"MAINNET\":\"https://alpha.console.vega.xyz\"}'
|
||||
NX_ETHEREUM_CHAIN_ID=3
|
||||
NX_ETHEREUM_PROVIDER_URL = "https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8"
|
||||
NX_ETHERSCAN_URL = "https://ropsten.etherscan.io"
|
||||
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
||||
|
@ -1,7 +1,7 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = "STAGNET2"
|
||||
NX_VEGA_URL = "https://n03.stagnet2.vega.xyz/query"
|
||||
NX_VEGA_ENV=STAGNET2
|
||||
NX_VEGA_URL=https://n03.stagnet2.vega.xyz/query
|
||||
NX_VEGA_NETWORKS='{\"MAINNET\":\"https://alpha.console.vega.xyz\"}'
|
||||
NX_ETHEREUM_CHAIN_ID=3
|
||||
NX_ETHEREUM_PROVIDER_URL = "https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8"
|
||||
NX_ETHERSCAN_URL = "https://ropsten.etherscan.io"
|
||||
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
||||
|
@ -1,7 +1,7 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = "TESTNET"
|
||||
NX_VEGA_URL = "https://lb.testnet.vega.xyz/query"
|
||||
NX_VEGA_ENV=TESTNET
|
||||
NX_VEGA_URL=https://lb.testnet.vega.xyz/query
|
||||
NX_VEGA_NETWORKS='{\"MAINNET\":\"https://alpha.console.vega.xyz\"}'
|
||||
NX_ETHEREUM_CHAIN_ID=3
|
||||
NX_ETHEREUM_PROVIDER_URL = "https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8"
|
||||
NX_ETHERSCAN_URL = "https://ropsten.etherscan.io"
|
||||
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
||||
|
0
apps/trading/assets/.gitkeep
Normal file
0
apps/trading/assets/.gitkeep
Normal file
1
apps/trading/assets/env-config.js
Normal file
1
apps/trading/assets/env-config.js
Normal file
@ -0,0 +1 @@
|
||||
window._env_ = {};
|
@ -5,6 +5,7 @@ import { Web3Container } from './web3-container';
|
||||
import type { useWeb3React } from '@web3-react/core';
|
||||
import type { NetworkParamsQuery } from '@vegaprotocol/web3';
|
||||
import { NETWORK_PARAMS_QUERY } from '@vegaprotocol/web3';
|
||||
import { EnvironmentProvider } from '@vegaprotocol/network-switcher';
|
||||
|
||||
const defaultHookValue = {
|
||||
isActive: false,
|
||||
@ -50,6 +51,7 @@ jest.mock('@web3-react/core', () => {
|
||||
|
||||
function setup(mock = networkParamsQueryMock) {
|
||||
return render(
|
||||
<EnvironmentProvider>
|
||||
<MockedProvider mocks={[mock]}>
|
||||
<Web3Container>
|
||||
<div>
|
||||
@ -58,6 +60,7 @@ function setup(mock = networkParamsQueryMock) {
|
||||
</div>
|
||||
</Web3Container>
|
||||
</MockedProvider>
|
||||
</EnvironmentProvider>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -6,9 +6,10 @@ import {
|
||||
} from '@vegaprotocol/web3';
|
||||
import { useWeb3React } from '@web3-react/core';
|
||||
import type { ReactNode } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Connectors } from '../../lib/web3-connectors';
|
||||
import { useEffect, useState, useMemo } from 'react';
|
||||
import { t } from '@vegaprotocol/react-helpers';
|
||||
import { useEnvironment } from '@vegaprotocol/network-switcher';
|
||||
import { createConnectors } from '../../lib/web3-connectors';
|
||||
|
||||
interface Web3ContainerProps {
|
||||
children: ReactNode;
|
||||
@ -17,7 +18,11 @@ interface Web3ContainerProps {
|
||||
export const Web3Container = ({ children }: Web3ContainerProps) => {
|
||||
const [dialogOpen, setDialogOpen] = useState(false);
|
||||
const { config, loading, error } = useEthereumConfig();
|
||||
|
||||
const { ETHEREUM_PROVIDER_URL, ETHEREUM_CHAIN_ID } = useEnvironment();
|
||||
const Connectors = useMemo(
|
||||
() => createConnectors(ETHEREUM_PROVIDER_URL, ETHEREUM_CHAIN_ID),
|
||||
[ETHEREUM_CHAIN_ID, ETHEREUM_PROVIDER_URL]
|
||||
);
|
||||
return (
|
||||
<AsyncRenderer data={config} loading={loading} error={error}>
|
||||
{config ? (
|
||||
|
4
apps/trading/index.d.ts
vendored
4
apps/trading/index.d.ts
vendored
@ -4,3 +4,7 @@ declare module '*.svg' {
|
||||
export const ReactComponent: any;
|
||||
export default content;
|
||||
}
|
||||
|
||||
interface Window {
|
||||
_env_?: Record<string, string>;
|
||||
}
|
||||
|
21
apps/trading/lib/config/env.ts
Normal file
21
apps/trading/lib/config/env.ts
Normal file
@ -0,0 +1,21 @@
|
||||
const windowOrDefault = (key: string, defaultValue?: string) => {
|
||||
if (typeof window !== 'undefined') {
|
||||
if (window._env_ && window._env_[key]) {
|
||||
return window._env_[key];
|
||||
}
|
||||
}
|
||||
return defaultValue || '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Need to have default value as next in-lines environment variables. Cannot figure out dynamic keys.
|
||||
* So must provide the default with the key so that next can figure it out.
|
||||
*/
|
||||
export const ENV = {
|
||||
dsn: windowOrDefault(
|
||||
'NX_TRADING_SENTRY_DSN',
|
||||
process.env['NX_TRADING_SENTRY_DSN']
|
||||
),
|
||||
envName: windowOrDefault('NX_VEGA_ENV', process.env['NX_VEGA_ENV']),
|
||||
vegaUrl: windowOrDefault('NX_VEGA_URL', process.env['NX_VEGA_URL']),
|
||||
};
|
1
apps/trading/lib/config/index.ts
Normal file
1
apps/trading/lib/config/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './env';
|
@ -7,24 +7,22 @@ const [metamask, metamaskHooks] = initializeConnector<MetaMask>(
|
||||
(actions) => new MetaMask(actions)
|
||||
);
|
||||
|
||||
const CHAIN_ID = Number(process.env['NX_ETHEREUM_CHAIN_ID']);
|
||||
const PROVIDER_URL = process.env['NX_ETHEREUM_PROVIDER_URL'] as string;
|
||||
|
||||
if (isNaN(CHAIN_ID)) {
|
||||
export const createConnectors = (providerUrl: string, chainId: number) => {
|
||||
if (isNaN(chainId)) {
|
||||
throw new Error('Invalid Ethereum chain ID for environment');
|
||||
}
|
||||
|
||||
const [walletconnect, walletconnectHooks] = initializeConnector<WalletConnect>(
|
||||
const [walletconnect, walletconnectHooks] =
|
||||
initializeConnector<WalletConnect>(
|
||||
(actions) =>
|
||||
new WalletConnect(actions, {
|
||||
rpc: {
|
||||
[CHAIN_ID]: PROVIDER_URL,
|
||||
[chainId]: providerUrl,
|
||||
},
|
||||
}),
|
||||
[CHAIN_ID]
|
||||
[chainId]
|
||||
);
|
||||
|
||||
export const Connectors: [MetaMask | WalletConnect, Web3ReactHooks][] = [
|
||||
return [
|
||||
[metamask, metamaskHooks],
|
||||
[walletconnect, walletconnectHooks],
|
||||
];
|
||||
] as [MetaMask | WalletConnect, Web3ReactHooks][];
|
||||
};
|
||||
|
@ -7,11 +7,7 @@ import {
|
||||
VegaManageDialog,
|
||||
VegaWalletProvider,
|
||||
} from '@vegaprotocol/wallet';
|
||||
import {
|
||||
useEnvironment,
|
||||
EnvironmentProvider,
|
||||
NetworkSwitcherDialog,
|
||||
} from '@vegaprotocol/network-switcher';
|
||||
import { NetworkSwitcherDialog } from '@vegaprotocol/network-switcher';
|
||||
import { Connectors } from '../lib/vega-connectors';
|
||||
import { useMemo } from 'react';
|
||||
import { createClient } from '../lib/apollo-client';
|
||||
@ -21,6 +17,9 @@ import { AppLoader } from '../components/app-loader';
|
||||
import { VegaWalletConnectButton } from '../components/vega-wallet-connect-button';
|
||||
import './styles.css';
|
||||
import { useGlobalStore } from '../stores';
|
||||
import { ENV } from '../lib/config/env';
|
||||
import { EnvironmentProvider } from '@vegaprotocol/network-switcher';
|
||||
import { useEnvironment } from '@vegaprotocol/network-switcher';
|
||||
|
||||
function AppBody({ Component, pageProps }: AppProps) {
|
||||
const store = useGlobalStore();
|
||||
@ -72,7 +71,7 @@ function AppBody({ Component, pageProps }: AppProps) {
|
||||
|
||||
function VegaTradingApp(props: AppProps) {
|
||||
const [theme] = useThemeSwitcher();
|
||||
const client = useMemo(() => createClient(process.env['NX_VEGA_URL']), []);
|
||||
const client = useMemo(() => createClient(ENV.vegaUrl), []);
|
||||
|
||||
return (
|
||||
<EnvironmentProvider>
|
||||
@ -98,6 +97,12 @@ function VegaTradingApp(props: AppProps) {
|
||||
rel="stylesheet"
|
||||
href="https://static.vega.xyz/fonts.css"
|
||||
/>
|
||||
{['1', 'true'].includes(
|
||||
process.env['NX_USE_ENV_OVERRIDES'] || ''
|
||||
) ? (
|
||||
/* eslint-disable-next-line @next/next/no-sync-scripts */
|
||||
<script src="./env-config.js" type="text/javascript" />
|
||||
) : null}
|
||||
</Head>
|
||||
<AppBody {...props} />
|
||||
</AppLoader>
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { useRouter } from 'next/router';
|
||||
import { useMemo } from 'react';
|
||||
import { WithdrawPageContainer } from './withdraw-page-container';
|
||||
import { t } from '@vegaprotocol/react-helpers';
|
||||
import { VegaWalletContainer } from '../../../components/vega-wallet-container';
|
||||
import { Web3Container } from '../../../components/web3-container';
|
||||
import { t } from '@vegaprotocol/react-helpers';
|
||||
|
||||
const Withdraw = () => {
|
||||
const { query } = useRouter();
|
||||
|
@ -1,13 +1,14 @@
|
||||
import * as Sentry from '@sentry/nextjs';
|
||||
import { BrowserTracing } from '@sentry/tracing';
|
||||
import { ENV } from './lib/config/env';
|
||||
|
||||
const dsn = process.env['NX_TRADING_SENTRY_DSN'];
|
||||
const { dsn } = ENV;
|
||||
|
||||
if (dsn) {
|
||||
Sentry.init({
|
||||
dsn,
|
||||
integrations: [new BrowserTracing()],
|
||||
tracesSampleRate: 1,
|
||||
environment: process.env['NX_VEGA_ENV'],
|
||||
environment: ENV.envName,
|
||||
});
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
import * as Sentry from '@sentry/nextjs';
|
||||
import { BrowserTracing } from '@sentry/tracing';
|
||||
import { ENV } from './lib/config/env';
|
||||
|
||||
const dsn = process.env['NX_TRADING_SENTRY_DSN'];
|
||||
const { dsn } = ENV;
|
||||
|
||||
if (dsn) {
|
||||
Sentry.init({
|
||||
dsn,
|
||||
integrations: [new BrowserTracing()],
|
||||
tracesSampleRate: 1,
|
||||
environment: process.env['NX_VEGA_ENV'],
|
||||
environment: ENV.envName,
|
||||
});
|
||||
}
|
||||
|
18
env-config.js
Normal file
18
env-config.js
Normal file
@ -0,0 +1,18 @@
|
||||
window._env_ = {
|
||||
NX_CHAIN_EXPLORER_URL:
|
||||
'https://explorer.vega.trading/.netlify/functions/chain-explorer-api;',
|
||||
NX_TENDERMINT_URL: 'http://localhost:26617;',
|
||||
NX_TENDERMINT_WEBSOCKET_URL: 'wss://localhost:26617/websocket;',
|
||||
NX_VEGA_URL: 'http://localhost:3028/query;',
|
||||
NX_VEGA_ENV: 'LOCAL;',
|
||||
NX_VEGA_REST: 'http://localhost:3029;',
|
||||
NX_VEGA_REST: 'http://localhost:3029;',
|
||||
NX_VEGA_REST: 'http://localhost:3029;',
|
||||
NX_EXPLORER_ASSETS: '1;',
|
||||
NX_EXPLORER_GENESIS: '1;',
|
||||
NX_EXPLORER_GOVERNANCE: '1;',
|
||||
NX_EXPLORER_MARKETS: '1;',
|
||||
NX_EXPLORER_NETWORK_PARAMETERS: '1;',
|
||||
NX_EXPLORER_PARTIES: '1;',
|
||||
NX_EXPLORER_VALIDATORS: '1;',
|
||||
};
|
32
env.sh
Executable file
32
env.sh
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Recreate config file
|
||||
mkdir assets
|
||||
rm -rf ./assets/env-config.js
|
||||
touch ./assets/env-config.js
|
||||
|
||||
# Add assignment
|
||||
echo "window._env_ = {" >> ./assets/env-config.js
|
||||
|
||||
# Read each line in .env file
|
||||
# Each line represents key=value pairs
|
||||
while read -r line || [[ -n "$line" ]];
|
||||
do
|
||||
# Split env variables by character `=`
|
||||
if printf '%s\n' "$line" | grep -q -e '='; then
|
||||
varname=$(printf '%s\n' "$line" | sed -e 's/=.*//')
|
||||
varvalue=$(printf '%s\n' "$line" | sed -e 's/^[^=]*=//')
|
||||
fi
|
||||
|
||||
# Read value of current variable if exists as Environment variable
|
||||
value=$(printf '%s\n' "${!varname}")
|
||||
# Otherwise use value from .env file
|
||||
[[ -z $value ]] && value=${varvalue}
|
||||
|
||||
# Append configuration property to JS file if non-empty
|
||||
if [ ! -z "$varname" ]; then
|
||||
echo " $varname: \"$value\"," >> ./assets/env-config.js
|
||||
fi
|
||||
done < .env
|
||||
|
||||
echo "}" >> ./assets/env-config.js
|
@ -1,52 +1,38 @@
|
||||
import { useState } from 'react';
|
||||
import type { ReactNode } from 'react';
|
||||
import { createContext, useContext } from 'react';
|
||||
import type { Networks } from '@vegaprotocol/react-helpers';
|
||||
import type { ReactNode } from 'react';
|
||||
import { useState } from 'react';
|
||||
import { createContext, useContext } from 'react';
|
||||
|
||||
const isBrowser = typeof window !== 'undefined';
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
_ENV?: RawEnvironment;
|
||||
_env_?: Record<string, string>;
|
||||
}
|
||||
}
|
||||
const customVegaTokenAddress = process.env['CUSTOM_TOKEN_ADDRESS'] as string;
|
||||
const customClaimAddress = process.env['CUSTOM_CLAIM_ADDRESS'] as string;
|
||||
const customLockedAddress = process.env['CUSTOM_LOCKED_ADDRESS'] as string;
|
||||
interface VegaContracts {
|
||||
vegaTokenAddress: string;
|
||||
claimAddress: string;
|
||||
lockedAddress: string;
|
||||
}
|
||||
|
||||
export const ContractAddresses: { [key in Networks]: VegaContracts } = {
|
||||
CUSTOM: {
|
||||
vegaTokenAddress: customVegaTokenAddress,
|
||||
claimAddress: customClaimAddress,
|
||||
lockedAddress: customLockedAddress,
|
||||
},
|
||||
DEVNET: {
|
||||
vegaTokenAddress: '0xc93137f9F4B820Ca85FfA3C7e84cCa6Ebc7bB517',
|
||||
claimAddress: '0x8Cef746ab7C83B61F6461cC92882bD61AB65a994',
|
||||
lockedAddress: '0x0',
|
||||
},
|
||||
STAGNET: {
|
||||
vegaTokenAddress: '0x547cbA83a7eb82b546ee5C7ff0527F258Ba4546D',
|
||||
claimAddress: '0x8Cef746ab7C83B61F6461cC92882bD61AB65a994', // TODO not deployed to this env, but random address so app doesn't error
|
||||
lockedAddress: '0x0', // TODO not deployed to this env
|
||||
},
|
||||
STAGNET2: {
|
||||
vegaTokenAddress: '0xd8fa193B93a179DdCf51FFFDe5320E0872cdcf44',
|
||||
claimAddress: '0x8Cef746ab7C83B61F6461cC92882bD61AB65a994', // TODO not deployed to this env, but random address so app doesn't error
|
||||
lockedAddress: '0x0', // TODO not deployed to this env
|
||||
},
|
||||
TESTNET: {
|
||||
vegaTokenAddress: '0xDc335304979D378255015c33AbFf09B60c31EBAb',
|
||||
claimAddress: '0x8Cef746ab7C83B61F6461cC92882bD61AB65a994', // TODO not deployed to this env, but random address so app doesn't error
|
||||
lockedAddress: '0x0', // TODO not deployed to this env
|
||||
},
|
||||
MAINNET: {
|
||||
vegaTokenAddress: '0xcB84d72e61e383767C4DFEb2d8ff7f4FB89abc6e',
|
||||
claimAddress: '0x0ee1fb382caf98e86e97e51f9f42f8b4654020f3',
|
||||
lockedAddress: '0x78344c7305d73a7a0ac3c94cd9960f4449a1814e',
|
||||
},
|
||||
@ -133,7 +119,7 @@ const getValue = (key: EnvKey, definitions: Partial<RawEnvironment> = {}) => {
|
||||
}
|
||||
return transformValue(
|
||||
key,
|
||||
window._ENV?.[key] ?? definitions[key] ?? getBundledEnvironmentValue(key)
|
||||
window._env_?.[key] ?? definitions[key] ?? getBundledEnvironmentValue(key)
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
export enum Networks {
|
||||
CUSTOM = 'CUSTOM',
|
||||
TESTNET = 'TESTNET',
|
||||
STAGNET = 'STAGNET',
|
||||
STAGNET2 = 'STAGNET2',
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user