Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3f5c2fc32 |
@@ -1,6 +1,6 @@
|
|||||||
# Related issues 🔗
|
# Related issues 🔗
|
||||||
|
|
||||||
Closes #[Issue number here]
|
Issue: #[Issue number here]
|
||||||
|
|
||||||
# Description ℹ️
|
# Description ℹ️
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- release/*
|
- release/*
|
||||||
- develop
|
- develop
|
||||||
- main
|
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
- ready_for_review
|
- ready_for_review
|
||||||
- reopened
|
- reopened
|
||||||
|
- edited
|
||||||
- synchronize
|
- synchronize
|
||||||
jobs:
|
jobs:
|
||||||
node-modules:
|
node-modules:
|
||||||
@@ -21,6 +21,7 @@ jobs:
|
|||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.sha || github.sha }}
|
ref: ${{ github.event.pull_request.head.sha || github.sha }}
|
||||||
|
|
||||||
- name: Cache node modules
|
- name: Cache node modules
|
||||||
id: cache
|
id: cache
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
@@ -38,15 +39,23 @@ jobs:
|
|||||||
node-version-file: '.nvmrc'
|
node-version-file: '.nvmrc'
|
||||||
# https://stackoverflow.com/questions/61010294/how-to-cache-yarn-packages-in-github-actions
|
# https://stackoverflow.com/questions/61010294/how-to-cache-yarn-packages-in-github-actions
|
||||||
cache: yarn
|
cache: yarn
|
||||||
|
|
||||||
- name: yarn install
|
- name: yarn install
|
||||||
if: steps.cache.outputs.cache-hit != 'true'
|
if: steps.cache.outputs.cache-hit != 'true'
|
||||||
run: yarn install --pure-lockfile
|
run: yarn install --pure-lockfile
|
||||||
|
|
||||||
lint-format:
|
lint-pr-title:
|
||||||
timeout-minutes: 20
|
needs: node-modules
|
||||||
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
|
name: Verify PR title
|
||||||
|
uses: ./.github/workflows/lint-pr.yml
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
|
lint-test-build:
|
||||||
|
timeout-minutes: 60
|
||||||
needs: node-modules
|
needs: node-modules
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
name: '(CI) lint + format check'
|
name: '(CI) lint + unit test + build'
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
@@ -72,76 +81,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
main-branch-name: develop
|
main-branch-name: develop
|
||||||
|
|
||||||
- name: Check formatting
|
|
||||||
run: yarn nx format:check
|
|
||||||
|
|
||||||
- name: Lint affected
|
|
||||||
run: yarn nx affected:lint --max-warnings=0
|
|
||||||
|
|
||||||
- name: Build affected spec
|
|
||||||
run: yarn nx affected --target=build-spec
|
|
||||||
|
|
||||||
test-affected:
|
|
||||||
timeout-minutes: 30
|
|
||||||
needs: build-sources
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
name: 'run unit test of affected apps'
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
ref: ${{ github.event.pull_request.head.sha || github.sha }}
|
|
||||||
|
|
||||||
- name: Setup node
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version-file: '.nvmrc'
|
|
||||||
cache: yarn
|
|
||||||
|
|
||||||
- name: Cache node modules
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: node_modules
|
|
||||||
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('yarn.lock') }}
|
|
||||||
|
|
||||||
- name: Derive appropriate SHAs for base and head for `nx affected` commands
|
|
||||||
uses: nrwl/nx-set-shas@v3
|
|
||||||
with:
|
|
||||||
main-branch-name: develop
|
|
||||||
|
|
||||||
- name: Test affected
|
|
||||||
run: yarn nx affected:test
|
|
||||||
|
|
||||||
build-sources:
|
|
||||||
timeout-minutes: 30
|
|
||||||
needs: lint-format
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
name: 'Build sources of affected apps'
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
ref: ${{ github.event.pull_request.head.sha || github.sha }}
|
|
||||||
|
|
||||||
- name: Setup node
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version-file: '.nvmrc'
|
|
||||||
cache: yarn
|
|
||||||
|
|
||||||
- name: Cache node modules
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: node_modules
|
|
||||||
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('yarn.lock') }}
|
|
||||||
|
|
||||||
- name: Derive appropriate SHAs for base and head for `nx affected` commands
|
|
||||||
uses: nrwl/nx-set-shas@v3
|
|
||||||
with:
|
|
||||||
main-branch-name: develop
|
|
||||||
|
|
||||||
# See affected apps
|
# See affected apps
|
||||||
- name: See affected apps
|
- name: See affected apps
|
||||||
run: |
|
run: |
|
||||||
@@ -158,8 +97,21 @@ jobs:
|
|||||||
echo "preview_explorer: ${{ env.PREVIEW_EXPLORER }}"
|
echo "preview_explorer: ${{ env.PREVIEW_EXPLORER }}"
|
||||||
echo "preview_tools: ${{ env.PREVIEW_TOOLS }}"
|
echo "preview_tools: ${{ env.PREVIEW_TOOLS }}"
|
||||||
|
|
||||||
|
- name: Check formatting
|
||||||
|
run: yarn nx format:check
|
||||||
|
|
||||||
|
- name: Lint affected
|
||||||
|
run: yarn nx affected:lint --max-warnings=0
|
||||||
|
|
||||||
|
- name: Build affected spec
|
||||||
|
run: yarn nx affected --target=build-spec
|
||||||
|
|
||||||
|
- name: Test affected
|
||||||
|
run: yarn nx affected:test
|
||||||
|
|
||||||
- name: Build affected
|
- name: Build affected
|
||||||
run: yarn nx affected:build || (yarn install && yarn nx affected:build)
|
run: yarn nx affected:build || (yarn install && yarn nx affected:build)
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
projects: ${{ env.PROJECTS }}
|
projects: ${{ env.PROJECTS }}
|
||||||
projects-e2e: ${{ env.PROJECTS_E2E }}
|
projects-e2e: ${{ env.PROJECTS_E2E }}
|
||||||
@@ -168,62 +120,39 @@ jobs:
|
|||||||
preview_explorer: ${{ env.PREVIEW_EXPLORER }}
|
preview_explorer: ${{ env.PREVIEW_EXPLORER }}
|
||||||
preview_tools: ${{ env.PREVIEW_TOOLS }}
|
preview_tools: ${{ env.PREVIEW_TOOLS }}
|
||||||
|
|
||||||
# console-e2e:
|
console-e2e:
|
||||||
# needs: build-sources
|
needs: lint-test-build
|
||||||
# name: '(CI) console python'
|
name: '(CI) console python'
|
||||||
# uses: ./.github/workflows/console-test-run.yml
|
uses: ./.github/workflows/console-test-run.yml
|
||||||
# secrets: inherit
|
secrets: inherit
|
||||||
# if: ${{ contains(fromJSON(needs.build-sources.outputs.projects), 'trading') && github.event_name == 'pull_request' }}
|
if: ${{ contains(fromJSON(needs.lint-test-build.outputs.projects), 'trading') && github.event_name == 'pull_request' }}
|
||||||
# with:
|
with:
|
||||||
# github-sha: ${{ github.event.pull_request.head.sha || github.sha }}
|
github-sha: ${{ github.event.pull_request.head.sha || github.sha }}
|
||||||
|
|
||||||
check-e2e-needed:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: build-sources
|
|
||||||
name: '(CI) check if e2e needed'
|
|
||||||
outputs:
|
|
||||||
run-tests: ${{ steps.check-test.outputs.e2e-needed }}
|
|
||||||
steps:
|
|
||||||
- name: Check branch
|
|
||||||
id: check-test
|
|
||||||
run: |
|
|
||||||
if [[ "${{ github.base_ref }}" == "develop" ]]; then
|
|
||||||
echo "e2e-needed=true" >> $GITHUB_OUTPUT
|
|
||||||
elif [[ "${{ github.base_ref }}" == "main" ]]; then
|
|
||||||
echo "e2e-needed=true" >> $GITHUB_OUTPUT
|
|
||||||
elif [[ "${{ github.event_name }}" == "push" && "${{ github.ref_name }}" == *"release/"* ]]; then
|
|
||||||
echo "e2e-needed=true" >> $GITHUB_OUTPUT
|
|
||||||
else
|
|
||||||
echo "e2e-needed=false" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
|
||||||
- name: Print result
|
|
||||||
run: |
|
|
||||||
echo "e2e-needed: ${{ steps.check-test.outputs.e2e-needed }}"
|
|
||||||
|
|
||||||
cypress:
|
cypress:
|
||||||
needs: [build-sources, check-e2e-needed]
|
needs: lint-test-build
|
||||||
name: '(CI) cypress'
|
name: '(CI) cypress'
|
||||||
if: ${{ needs.check-e2e-needed.outputs.run-tests == 'true' }}
|
# if: ${{ needs.lint-test-build.outputs.projects-e2e != '[]' }}
|
||||||
uses: ./.github/workflows/cypress-run.yml
|
uses: ./.github/workflows/cypress-run.yml
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
with:
|
with:
|
||||||
projects: ${{ needs.build-sources.outputs.projects-e2e }}
|
projects: ${{ needs.lint-test-build.outputs.projects-e2e }}
|
||||||
tags: '@smoke'
|
tags: '@smoke'
|
||||||
|
|
||||||
publish-dist:
|
publish-dist:
|
||||||
needs: build-sources
|
needs: lint-test-build
|
||||||
name: '(CD) publish dist'
|
name: '(CD) publish dist'
|
||||||
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'vegaprotocol/frontend-monorepo') || github.event_name == 'push' }}
|
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'vegaprotocol/frontend-monorepo') || github.event_name == 'push' }}
|
||||||
uses: ./.github/workflows/publish-dist.yml
|
uses: ./.github/workflows/publish-dist.yml
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
with:
|
with:
|
||||||
projects: ${{ needs.build-sources.outputs.projects }}
|
projects: ${{ needs.lint-test-build.outputs.projects }}
|
||||||
|
|
||||||
dist-check:
|
dist-check:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs:
|
needs:
|
||||||
- publish-dist
|
- publish-dist
|
||||||
- build-sources
|
- lint-test-build
|
||||||
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'vegaprotocol/frontend-monorepo' }}
|
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'vegaprotocol/frontend-monorepo' }}
|
||||||
timeout-minutes: 60
|
timeout-minutes: 60
|
||||||
name: '(CD) comment preview links'
|
name: '(CD) comment preview links'
|
||||||
@@ -239,27 +168,27 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
# https://stackoverflow.com/questions/3183444/check-for-valid-link-url
|
# https://stackoverflow.com/questions/3183444/check-for-valid-link-url
|
||||||
regex='(https?|ftp|file)://[-[:alnum:]\+&@#/%?=~_|!:,.;]*[-[:alnum:]\+&@#/%=~_|]'
|
regex='(https?|ftp|file)://[-[:alnum:]\+&@#/%?=~_|!:,.;]*[-[:alnum:]\+&@#/%=~_|]'
|
||||||
if [[ "${{ needs.build-sources.outputs.preview_governance }}" =~ $regex ]]; then
|
if [[ "${{ needs.lint-test-build.outputs.preview_governance }}" =~ $regex ]]; then
|
||||||
until curl --insecure --location --fail "${{ needs.build-sources.outputs.preview_governance }}"; do
|
until curl --insecure --location --fail "${{ needs.lint-test-build.outputs.preview_governance }}"; do
|
||||||
echo "waiting for governance preview: ${{ needs.build-sources.outputs.preview_governance }}"
|
echo "waiting for governance preview: ${{ needs.lint-test-build.outputs.preview_governance }}"
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
if [[ "${{ needs.build-sources.outputs.preview_explorer }}" =~ $regex ]]; then
|
if [[ "${{ needs.lint-test-build.outputs.preview_explorer }}" =~ $regex ]]; then
|
||||||
until curl --insecure --location --fail "${{ needs.build-sources.outputs.preview_explorer }}"; do
|
until curl --insecure --location --fail "${{ needs.lint-test-build.outputs.preview_explorer }}"; do
|
||||||
echo "waiting for explorer preview: ${{ needs.build-sources.outputs.preview_explorer }}"
|
echo "waiting for explorer preview: ${{ needs.lint-test-build.outputs.preview_explorer }}"
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
if [[ "${{ needs.build-sources.outputs.preview_trading }}" =~ $regex ]]; then
|
if [[ "${{ needs.lint-test-build.outputs.preview_trading }}" =~ $regex ]]; then
|
||||||
until curl --insecure --location --fail "${{ needs.build-sources.outputs.preview_trading }}"; do
|
until curl --insecure --location --fail "${{ needs.lint-test-build.outputs.preview_trading }}"; do
|
||||||
echo "waiting for trading preview: ${{ needs.build-sources.outputs.preview_trading }}"
|
echo "waiting for trading preview: ${{ needs.lint-test-build.outputs.preview_trading }}"
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
if [[ "${{ needs.build-sources.outputs.preview_tools }}" =~ $regex ]]; then
|
if [[ "${{ needs.lint-test-build.outputs.preview_tools }}" =~ $regex ]]; then
|
||||||
until curl --insecure --location --fail "${{ needs.build-sources.outputs.preview_tools }}"; do
|
until curl --insecure --location --fail "${{ needs.lint-test-build.outputs.preview_tools }}"; do
|
||||||
echo "waiting for tools preview: ${{ needs.build-sources.outputs.preview_tools }}"
|
echo "waiting for tools preview: ${{ needs.lint-test-build.outputs.preview_tools }}"
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
@@ -271,10 +200,10 @@ jobs:
|
|||||||
issue-number: ${{ github.event.pull_request.number }}
|
issue-number: ${{ github.event.pull_request.number }}
|
||||||
body: |
|
body: |
|
||||||
Previews
|
Previews
|
||||||
* governance: ${{ needs.build-sources.outputs.preview_governance }}
|
* governance: ${{ needs.lint-test-build.outputs.preview_governance }}
|
||||||
* explorer: ${{ needs.build-sources.outputs.preview_explorer }}
|
* explorer: ${{ needs.lint-test-build.outputs.preview_explorer }}
|
||||||
* trading: ${{ needs.build-sources.outputs.preview_trading }}
|
* trading: ${{ needs.lint-test-build.outputs.preview_trading }}
|
||||||
* tools: ${{ needs.build-sources.outputs.preview_tools }}
|
* tools: ${{ needs.lint-test-build.outputs.preview_tools }}
|
||||||
|
|
||||||
# Report single result at the end, to avoid mess with required checks in PR
|
# Report single result at the end, to avoid mess with required checks in PR
|
||||||
cypress-check:
|
cypress-check:
|
||||||
|
|||||||
@@ -6,14 +6,6 @@ on:
|
|||||||
github-sha:
|
github-sha:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
console-test-branch:
|
|
||||||
type: choice
|
|
||||||
description: 'main: v0.72.14, develop: v0.73.0-preview7'
|
|
||||||
options:
|
|
||||||
- main
|
|
||||||
- develop
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
run-tests:
|
run-tests:
|
||||||
@@ -24,19 +16,13 @@ jobs:
|
|||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
# check-out frontend-monorepo
|
# check-out frontend-monorepo
|
||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
- name: Checkout frontend-monorepo
|
- name: Checkout console test repo
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
ref: ${{ inputs.github-sha || github.sha }}
|
ref: ${{ inputs.github-sha }}
|
||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
# cache node modules
|
# cache node modules
|
||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
- name: setup node
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: '16'
|
|
||||||
cache: yarn
|
|
||||||
|
|
||||||
- name: Cache node modules
|
- name: Cache node modules
|
||||||
id: cache
|
id: cache
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
@@ -47,6 +33,15 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-cache-node-modules-
|
${{ runner.os }}-cache-node-modules-
|
||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
|
# setup node
|
||||||
|
#----------------------------------------------
|
||||||
|
- name: Setup node
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version-file: '.nvmrc'
|
||||||
|
# https://stackoverflow.com/questions/61010294/how-to-cache-yarn-packages-in-github-actions
|
||||||
|
cache: yarn
|
||||||
|
#----------------------------------------------
|
||||||
# install deps if cache missing
|
# install deps if cache missing
|
||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
- name: yarn install
|
- name: yarn install
|
||||||
@@ -79,42 +74,58 @@ jobs:
|
|||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
repository: vegaprotocol/console-test
|
repository: vegaprotocol/console-test
|
||||||
ref: ${{ inputs.console-test-branch }}
|
|
||||||
path: './console-test'
|
path: './console-test'
|
||||||
|
#----------------------------------------------
|
||||||
- name: Load console test envs
|
# set-up python
|
||||||
id: console-test-env
|
#----------------------------------------------
|
||||||
uses: falti/dotenv-action@v1.0.4
|
- name: Set up python
|
||||||
|
id: setup-python
|
||||||
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
path: './console-test/.env.${{ inputs.console-test-branch }}'
|
python-version: '3.10.11'
|
||||||
export-variables: true
|
#----------------------------------------------
|
||||||
keys-case: upper
|
# ----- install & configure poetry -----
|
||||||
log-variables: true
|
#----------------------------------------------
|
||||||
|
- name: Install Poetry
|
||||||
|
uses: snok/install-poetry@v1
|
||||||
|
with:
|
||||||
|
virtualenvs-create: true
|
||||||
|
virtualenvs-in-project: true
|
||||||
|
virtualenvs-path: console-test/.venv
|
||||||
|
#----------------------------------------------
|
||||||
|
# load cached venv if cache exists
|
||||||
|
#----------------------------------------------
|
||||||
|
- name: Load cached venv
|
||||||
|
id: cached-poetry-dependencies
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: console-test/.venv
|
||||||
|
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
|
||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
# install dependencies if cache does not exist
|
# install dependencies if cache does not exist
|
||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
working-directory: ./console-test
|
working-directory: ./console-test
|
||||||
|
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
|
||||||
run: poetry install --no-interaction --no-root
|
run: poetry install --no-interaction --no-root
|
||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
# install vega binaries
|
# install vega binaries
|
||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
- name: Install vega binaries
|
- name: Install vega binaries
|
||||||
working-directory: ./console-test
|
working-directory: ./console-test
|
||||||
run: poetry run python -m vega_sim.tools.load_binaries --force --version ${{ env.VEGA_VERSION }}
|
run: poetry run python -m vega_sim.tools.load_binaries --force
|
||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
# install playwright
|
# install playwright
|
||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
- name: install playwright
|
- name: install playwright
|
||||||
run: poetry run playwright install --with-deps chromium
|
run: poetry run playwright install
|
||||||
working-directory: ./console-test
|
working-directory: ./console-test
|
||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
# run tests
|
# run tests
|
||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
working-directory: ./console-test
|
working-directory: ./console-test
|
||||||
run: poetry run pytest -v -s --numprocesses 4 --dist loadfile --durations=15
|
run: poetry run pytest -v -s --numprocesses auto --dist loadfile --durations=20
|
||||||
- name: Check files
|
- name: Check files
|
||||||
run: |
|
run: |
|
||||||
ls -al .
|
ls -al .
|
||||||
@@ -129,13 +140,3 @@ jobs:
|
|||||||
name: playwright-trace
|
name: playwright-trace
|
||||||
path: ./traces/
|
path: ./traces/
|
||||||
retention-days: 15
|
retention-days: 15
|
||||||
#----------------------------------------------
|
|
||||||
# ----- upload logs -----
|
|
||||||
#----------------------------------------------
|
|
||||||
- name: Upload worker logs
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
if: always()
|
|
||||||
with:
|
|
||||||
name: worker-logs
|
|
||||||
path: ./logs/
|
|
||||||
retention-days: 15
|
|
||||||
|
|||||||
@@ -13,35 +13,13 @@ on:
|
|||||||
type: string
|
type: string
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
runner-choice:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
runner: ${{ steps.step.outputs.runner }}
|
|
||||||
steps:
|
|
||||||
- name: Check branch
|
|
||||||
id: step
|
|
||||||
run: |
|
|
||||||
if [[ "${{ github.base_ref }}" == "main" ]]; then
|
|
||||||
echo "runner=mainnet-compatible-runner" >> $GITHUB_OUTPUT
|
|
||||||
elif [[ "${{ github.base_ref }}" == "develop" && "${{ github.ref_name }}" == "main" ]]; then
|
|
||||||
echo "runner=mainnet-compatible-runner" >> $GITHUB_OUTPUT
|
|
||||||
elif [[ "${{ github.event_name }}" == "push" && "${{ github.ref_name }}" == *"release/mainnet"* ]]; then
|
|
||||||
echo "runner=mainnet-compatible-runner" >> $GITHUB_OUTPUT
|
|
||||||
else
|
|
||||||
echo "runner=self-hosted-runner" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Print runner
|
|
||||||
run: echo ${{ steps.step.outputs.runner }}
|
|
||||||
|
|
||||||
e2e:
|
e2e:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
project: ${{ fromJSON(inputs.projects) }}
|
project: ${{ fromJSON(inputs.projects) }}
|
||||||
name: ${{ matrix.project }}
|
name: ${{ matrix.project }}
|
||||||
needs: runner-choice
|
runs-on: self-hosted-runner
|
||||||
runs-on: ${{ needs.runner-choice.outputs.runner }}
|
|
||||||
timeout-minutes: 120
|
timeout-minutes: 120
|
||||||
steps:
|
steps:
|
||||||
# Checks if skip cache was requested
|
# Checks if skip cache was requested
|
||||||
@@ -59,7 +37,6 @@ jobs:
|
|||||||
|
|
||||||
# Restore node_modules from cache if possible
|
# Restore node_modules from cache if possible
|
||||||
- name: Restore node_modules from cache
|
- name: Restore node_modules from cache
|
||||||
id: cache-node-modules
|
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
@@ -69,7 +46,6 @@ jobs:
|
|||||||
|
|
||||||
# Install frontend dependencies
|
# Install frontend dependencies
|
||||||
- name: Install root dependencies
|
- name: Install root dependencies
|
||||||
if: steps.cache-node-modules.outputs.cache-hit != 'true'
|
|
||||||
run: yarn install --frozen-lockfile
|
run: yarn install --frozen-lockfile
|
||||||
working-directory: frontend-monorepo
|
working-directory: frontend-monorepo
|
||||||
|
|
||||||
@@ -85,14 +61,13 @@ jobs:
|
|||||||
- name: Run Vegacapsule network and Vega wallet
|
- name: Run Vegacapsule network and Vega wallet
|
||||||
id: setup-vega
|
id: setup-vega
|
||||||
uses: ./frontend-monorepo/.github/actions/run-vegacapsule
|
uses: ./frontend-monorepo/.github/actions/run-vegacapsule
|
||||||
timeout-minutes: 10
|
|
||||||
|
|
||||||
######
|
######
|
||||||
## Run some tests
|
## Run some tests
|
||||||
######
|
######
|
||||||
|
|
||||||
- name: Run Cypress tests
|
- name: Run Cypress tests
|
||||||
run: yarn nx run ${{ matrix.project }}:e2e ${{ env.SKIP_CACHE }} --browser chrome --env.grepTags="${{ inputs.tags }}"
|
run: yarn nx run ${{ matrix.project }}:e2e ${{ env.SKIP_CACHE }} --browser chrome --env.grepTags="${{ inputs.tags }}"
|
||||||
working-directory: frontend-monorepo
|
working-directory: frontend-monorepo
|
||||||
env:
|
env:
|
||||||
CYPRESS_SLACK_WEBHOOK: ${{ secrets.CYPRESS_SLACK_WEBHOOK }}
|
CYPRESS_SLACK_WEBHOOK: ${{ secrets.CYPRESS_SLACK_WEBHOOK }}
|
||||||
|
|||||||
@@ -2,12 +2,7 @@
|
|||||||
name: Verify PR title
|
name: Verify PR title
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
workflow_call:
|
||||||
types:
|
|
||||||
- opened
|
|
||||||
- edited
|
|
||||||
- reopened
|
|
||||||
- synchronize
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint_pr:
|
lint_pr:
|
||||||
@@ -16,16 +11,21 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.pull_request.head.sha || github.sha }}
|
||||||
|
|
||||||
- name: Setup node
|
- name: Setup node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 16
|
node-version-file: '.nvmrc'
|
||||||
|
# https://stackoverflow.com/questions/61010294/how-to-cache-yarn-packages-in-github-actions
|
||||||
|
cache: yarn
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Cache node modules
|
||||||
run: |
|
uses: actions/cache@v3
|
||||||
rm package.json
|
with:
|
||||||
npm install --no-save @commitlint/cli @commitlint/config-conventional @commitlint/config-nx-scopes nx
|
path: node_modules
|
||||||
|
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('yarn.lock') }}
|
||||||
|
|
||||||
- name: Check PR title
|
- name: Check PR title
|
||||||
run: echo "${{ github.event.pull_request.title }}" | npx commitlint --config ./commitlint.config-ci.js
|
run: echo "${{ github.event.pull_request.title }}" | npx commitlint --config ./commitlint.config-ci.js
|
||||||
|
|||||||
@@ -30,18 +30,12 @@ jobs:
|
|||||||
echo IS_IPFS_RELEASE=false >> $GITHUB_ENV
|
echo IS_IPFS_RELEASE=false >> $GITHUB_ENV
|
||||||
echo IS_S3_RELEASE=false >> $GITHUB_ENV
|
echo IS_S3_RELEASE=false >> $GITHUB_ENV
|
||||||
echo IS_DEV_IMAGE=false >> $GITHUB_ENV
|
echo IS_DEV_IMAGE=false >> $GITHUB_ENV
|
||||||
echo IS_MAIN_IMAGE=false >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Is dev image
|
- name: Is dev image
|
||||||
if: ${{ github.ref_name == 'develop' && github.event_name == 'push' && matrix.app == 'trading' }}
|
if: ${{ contains(github.ref, 'develop') && github.event_name == 'push' && matrix.app == 'trading' }}
|
||||||
run: |
|
run: |
|
||||||
echo IS_DEV_IMAGE=true >> $GITHUB_ENV
|
echo IS_DEV_IMAGE=true >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Is main image
|
|
||||||
if: ${{ github.ref_name == 'main' && github.event_name == 'push' && matrix.app == 'trading' }}
|
|
||||||
run: |
|
|
||||||
echo IS_MAIN_IMAGE=true >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Is PR
|
- name: Is PR
|
||||||
if: ${{ github.event_name == 'pull_request' }}
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
run: |
|
run: |
|
||||||
@@ -63,7 +57,7 @@ jobs:
|
|||||||
echo IS_IPFS_RELEASE=true >> $GITHUB_ENV
|
echo IS_IPFS_RELEASE=true >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Is S3 Release
|
- name: Is S3 Release
|
||||||
if: ${{ env.IS_IPFS_RELEASE == 'false' && github.event_name == 'push' && github.ref_name != 'main'}}
|
if: ${{ env.IS_IPFS_RELEASE == 'false' && github.event_name == 'push' }}
|
||||||
run: |
|
run: |
|
||||||
echo IS_S3_RELEASE=true >> $GITHUB_ENV
|
echo IS_S3_RELEASE=true >> $GITHUB_ENV
|
||||||
|
|
||||||
@@ -87,7 +81,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Log in to the Container registry (docker hub)
|
- name: Log in to the Container registry (docker hub)
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
if: ${{ env.IS_IPFS_RELEASE == 'true' || env.IS_DEV_IMAGE == 'true' || env.IS_MAIN_IMAGE == 'true' }}
|
if: ${{ env.IS_IPFS_RELEASE == 'true' || env.IS_DEV_IMAGE == 'true' }}
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
@@ -161,10 +155,10 @@ jobs:
|
|||||||
- name: Sanity check docker image
|
- name: Sanity check docker image
|
||||||
run: |
|
run: |
|
||||||
echo "Check ipfs-hash"
|
echo "Check ipfs-hash"
|
||||||
docker run --rm ghcr.io/vegaprotocol/frontend/${{ matrix.app }}:local /bin/sh -c 'cat /ipfs-hash'
|
docker run --rm ghcr.io/vegaprotocol/frontend/${{ matrix.app }}:local cat /ipfs-hash
|
||||||
docker run --rm ghcr.io/vegaprotocol/frontend/${{ matrix.app }}:local /bin/sh -c 'cat /ipfs-hash' > ${{ matrix.app }}-ipfs-hash
|
docker run --rm ghcr.io/vegaprotocol/frontend/${{ matrix.app }}:local cat /ipfs-hash > ${{ matrix.app }}-ipfs-hash
|
||||||
echo "List html directory"
|
echo "List html directory"
|
||||||
docker run --rm ghcr.io/vegaprotocol/frontend/${{ matrix.app }}:local /bin/sh -c 'apk add --update tree; tree /usr/share/nginx/html'
|
docker run --rm ghcr.io/vegaprotocol/frontend/${{ matrix.app }}:local sh -c 'apk add --update tree; tree /usr/share/nginx/html'
|
||||||
|
|
||||||
- name: Publish dist as docker image (ghcr)
|
- name: Publish dist as docker image (ghcr)
|
||||||
uses: docker/build-push-action@v3
|
uses: docker/build-push-action@v3
|
||||||
@@ -185,7 +179,7 @@ jobs:
|
|||||||
uses: docker/build-push-action@v3
|
uses: docker/build-push-action@v3
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
id: dockerhub-push
|
id: dockerhub-push
|
||||||
if: ${{ env.IS_IPFS_RELEASE == 'true' || env.IS_DEV_IMAGE == 'true' || env.IS_MAIN_IMAGE == 'true' }}
|
if: ${{ env.IS_IPFS_RELEASE == 'true' || env.IS_DEV_IMAGE == 'true' }}
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: docker/node-outside-docker.Dockerfile
|
file: docker/node-outside-docker.Dockerfile
|
||||||
@@ -195,7 +189,7 @@ jobs:
|
|||||||
ENV_NAME=${{ env.ENV_NAME }}
|
ENV_NAME=${{ env.ENV_NAME }}
|
||||||
tags: |
|
tags: |
|
||||||
vegaprotocol/${{ matrix.app }}:${{ github.sha }}
|
vegaprotocol/${{ matrix.app }}:${{ github.sha }}
|
||||||
vegaprotocol/${{ matrix.app }}:${{ env.IS_MAINNET_RELEASE == 'true' && 'mainnet' || env.IS_TESTNET_RELEASE == 'true' && 'testnet' || env.IS_DEV_IMAGE == 'true' && 'develop' || env.IS_MAIN_IMAGE == 'true' && 'main' || '' }}
|
vegaprotocol/${{ matrix.app }}:${{ env.IS_MAINNET_RELEASE == 'true' && 'mainnet' || env.IS_TESTNET_RELEASE == 'true' && 'testnet' || env.IS_DEV_IMAGE == 'true' && 'develop' || '' }}
|
||||||
|
|
||||||
- name: Publish dist as docker image (ghcr - retry)
|
- name: Publish dist as docker image (ghcr - retry)
|
||||||
uses: docker/build-push-action@v3
|
uses: docker/build-push-action@v3
|
||||||
@@ -222,7 +216,7 @@ jobs:
|
|||||||
ENV_NAME=${{ env.ENV_NAME }}
|
ENV_NAME=${{ env.ENV_NAME }}
|
||||||
tags: |
|
tags: |
|
||||||
vegaprotocol/${{ matrix.app }}:${{ github.sha }}
|
vegaprotocol/${{ matrix.app }}:${{ github.sha }}
|
||||||
vegaprotocol/${{ matrix.app }}:${{ env.IS_MAINNET_RELEASE == 'true' && 'mainnet' || env.IS_TESTNET_RELEASE == 'true' && 'testnet' || env.IS_DEV_IMAGE == 'true' && 'develop' || env.IS_MAIN_IMAGE == 'true' && 'main' || '' }}
|
vegaprotocol/${{ matrix.app }}:${{ env.IS_MAINNET_RELEASE == 'true' && 'mainnet' || env.IS_TESTNET_RELEASE == 'true' && 'testnet' || '' }}
|
||||||
|
|
||||||
# bucket creation in github.com/vegaprotocol/terraform//frontend
|
# bucket creation in github.com/vegaprotocol/terraform//frontend
|
||||||
- name: Publish dist to s3
|
- name: Publish dist to s3
|
||||||
@@ -335,9 +329,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# create commit
|
# create commit
|
||||||
if ! git diff --cached --exit-code; then
|
commit_msg="Automated hash update from ${{ github.ref }}"
|
||||||
commit_msg="Automated hash update from ${{ github.ref }}"
|
git commit -m "$commit_msg"
|
||||||
git commit -m "$commit_msg"
|
git push -u origin "main"
|
||||||
git push -u origin "main"
|
|
||||||
fi
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,3 +3,6 @@
|
|||||||
|
|
||||||
# Lint commit messages to ensure they follow conventional commit standards
|
# Lint commit messages to ensure they follow conventional commit standards
|
||||||
yarn commitlint --edit "${1}"
|
yarn commitlint --edit "${1}"
|
||||||
|
|
||||||
|
# Lint all staged files
|
||||||
|
yarn lint-staged
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
. "$(dirname "$0")/_/husky.sh"
|
|
||||||
|
|
||||||
# Lint all staged files
|
|
||||||
yarn lint-staged
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
. "$(dirname "$0")/_/husky.sh"
|
|
||||||
|
|
||||||
# Lint all staged files
|
|
||||||
yarn nx format:check
|
|
||||||
|
|
||||||
# Test all projects with changes
|
|
||||||
yarn nx affected -t test --exclude trading
|
|
||||||
@@ -1,3 +1,2 @@
|
|||||||
* @vegaprotocol/frontend
|
* @vegaprotocol/frontend
|
||||||
* @vegaprotocol/frontend-qa
|
|
||||||
*.graphql @vegaprotocol/core
|
*.graphql @vegaprotocol/core
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ recalculate-ipfs:
|
|||||||
echo "ipfs hash inside the image"
|
echo "ipfs hash inside the image"
|
||||||
docker run --rm ${TAG} cat /ipfs-hash
|
docker run --rm ${TAG} cat /ipfs-hash
|
||||||
echo "recalculating ipfs hash"
|
echo "recalculating ipfs hash"
|
||||||
docker run --rm ${TAG} ipfs add -rQ /usr/share/nginx/html
|
docker run --rm ${TAG} ipfs add -r /usr/share/nginx/html
|
||||||
|
|
||||||
.PHONY: eject-ipfs-hash
|
.PHONY: eject-ipfs-hash
|
||||||
unpack:
|
unpack:
|
||||||
|
|||||||
@@ -113,47 +113,13 @@ In order to run a container on port 3000:
|
|||||||
docker run -p 3000:80 [TAG]
|
docker run -p 3000:80 [TAG]
|
||||||
```
|
```
|
||||||
|
|
||||||
On top of that there are two possible scenarios for running docker image - using nginx server (default) of ipfs daemon.
|
|
||||||
|
|
||||||
to run ipfs on port 3000:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker run -p 3000:80 [TAG] /run-ipfs.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
to run nginx on port 3000:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker run -p 3000:80 [TAG]
|
|
||||||
```
|
|
||||||
|
|
||||||
## Build instructions
|
## Build instructions
|
||||||
|
|
||||||
The [`docker`](./docker) subfolder has some docker configurations for easily setting up your own hosted version of Console either for the web, or ready for pinning on IPFS.
|
The [`docker`](./docker) subfolder has some docker configurations for easily setting up your own hosted version of console either for the web, or ready for pinning on IPFS
|
||||||
|
|
||||||
### nx build inside the docker
|
|
||||||
|
|
||||||
Using multistage dockerfile dist is compiled using [node](https://hub.docker.com/_/node) image and later packed to nginx as in [dist build](#dist-build). The multistage builds ensures consistent CPU architecture and build toolchains are used so that the result will be identical.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker build --build-arg APP=[YOUR APP] --build-arg NODE_VERSION=16.5.1 --build-arg ENV_NAME=mainnet -t [TAG] -f docker/node-inside-docker.Dockerfile .
|
|
||||||
```
|
|
||||||
|
|
||||||
### Computing ipfs-hash of the build
|
|
||||||
|
|
||||||
At the moment this feature is important only for Console releases.
|
|
||||||
|
|
||||||
Each docker build finishes with hash calculation for ` dist`` directory. Resulting hash is added to file named as `/ipfs-hash`. Once docker image is produced you can run following commad to display ipfs-hash:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
make recalculate-ipfs TAG=vegaprotocol/trading:{YOUR_VERSION}
|
|
||||||
```
|
|
||||||
|
|
||||||
**updating hash:** recompiling dist directory (even if there are no changed to source code) results in different hash computed by ipfs command.
|
|
||||||
|
|
||||||
### nx build outside the docker
|
### nx build outside the docker
|
||||||
|
|
||||||
This Docker image packages a pre-built `dist` folder into an [`nginx`](https://hub.docker.com/_/nginx)([server configuration](./nginx/nginx.conf)) docker image. In this case, the application on docker host machine from source.
|
Packaging prepared dist into [`nginx`](https://hub.docker.com/_/nginx)([server configuration](./nginx/nginx.conf)) docker image involves building the application on docker host machine from source.
|
||||||
|
|
||||||
As a prerequisite you need to perform build of `dist` directory and move its content for specific application to `dist-result` directory. Use following script to do it with a single command:
|
As a prerequisite you need to perform build of `dist` directory and move its content for specific application to `dist-result` directory. Use following script to do it with a single command:
|
||||||
|
|
||||||
@@ -164,21 +130,41 @@ As a prerequisite you need to perform build of `dist` directory and move its con
|
|||||||
You can build any of the containers locally with the following command:
|
You can build any of the containers locally with the following command:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker build -f docker/node-outside-docker.Dockerfile . --tag=[TAG]
|
docker build --dockerfile docker/node-outside-docker.Dockerfile . --tag=[TAG]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### nx build inside the docker
|
||||||
|
|
||||||
|
Using multistage dockerfile dist is compiled using [node](https://hub.docker.com/_/node) image and later packed to nginx as in [dist build](#dist-build) example.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker build --build-arg APP=[YOUR APP] --build-arg NODE_VERSION=$(cat .nvmrc) --build-arg ENV_NAME=mainnet -t [TAG] -f docker/node-inside-docker.Dockerfile .
|
||||||
|
```
|
||||||
|
|
||||||
|
### Computing ipfs-hash of the build
|
||||||
|
|
||||||
|
At the moment this feature is important only for `trading` (console) releases.
|
||||||
|
|
||||||
|
Each docker build finishes with hash calculation for dist directory. Resulting hash is added to file named as `/ipfs-hash`. Once docker image is produced you can run following commad to display ipfs-hash:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make recalculate-ipfs TAG=vegaprotocol/trading:{YOUR_VERSION}
|
||||||
|
```
|
||||||
|
|
||||||
|
**updating hash:** recompiling dist directory (even if there are no changed to source code) results in different hash computed by ipfs command.
|
||||||
|
|
||||||
### Verifying ipfs-hash of existing current application version
|
### Verifying ipfs-hash of existing current application version
|
||||||
|
|
||||||
An IPFS CID will be attached to every [release](https://github.com/vegaprotocol/frontend-monorepo/releases). If you are intending to pin an application on IPFS, you can check that your build matches by running the following steps:
|
An IPFS CID will be attached to every [release](https://github.com/vegaprotocol/frontend-monorepo/releases). If you are intending to pin an application on IPFS, you can check that your build matches by running the following steps:
|
||||||
|
|
||||||
1. Show latest release by running: `make latest-release`. You need to configure [`gh`](https://cli.github.com/) for this step to work, otherwise please provide release manually from [github](https://github.com/vegaprotocol/frontend-monorepo/releases) or [dockerhub](https://hub.docker.com/r/vegaprotocol/trading)
|
1. Show latest release by runnning: `make latest-release`. You need to configure [`gh`](https://cli.github.com/) for this step to work, otherwise please provide release manually from [github](https://github.com/vegaprotocol/frontend-monorepo/releases) or [dockerhub](https://hub.docker.com/r/vegaprotocol/trading)
|
||||||
2. Set RELEASE environment variable to value that you want to validate: `export RELEASE=$(make latest-release)` or `export RELEASE=vXX.XX.XX`
|
2. Set RELEASE environment variable to value that you want to validate: `export RELEASE=$(make latest-release)` or `export RELEASE=vXX.XX.XX`
|
||||||
3. Set TAG environment variable to image that you want to validate: `export TAG=vegaprotocol/trading:$RELEASE`
|
3. Set TAG environment variable to image that you want to validate: `export TAG=vegaprotocol/trading:$RELEASE`
|
||||||
4. Download docker image with the desired release `docker pull $TAG`.
|
4. Download docker image with the desired release `docker pull $TAG`.
|
||||||
5. Recalculate hash: `make recalculate-ipfs`
|
5. Recalculate hash: `make recalculate-ipfs`
|
||||||
6. You should see exactly same hash produced by ipfs command as one placed with the release notes: `make show-latest-release`
|
6. You should see exactly same hash produced by ipfs command as one placed with the release notes: `make show-latest-release`
|
||||||
7. If you want to extract dist from docker image to your local filesystem you can run following command: `make unpack`
|
7. If you want to extract dist from docker image to your local filesystem you can run following command: `make unpack`
|
||||||
8. Now `dist` directory contains valid application build
|
8. Now `dist` directory contains valid application build. **it is not possible to calculate same ipfs hash on files that are result of copy operation**
|
||||||
|
|
||||||
## Config
|
## Config
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ NX_TENDERMINT_WEBSOCKET_URL=wss://n04.d.vega.xyz/tm/websocket
|
|||||||
NX_VEGA_URL=https://api.n04.d.vega.xyz/graphql
|
NX_VEGA_URL=https://api.n04.d.vega.xyz/graphql
|
||||||
NX_VEGA_ENV=DEVNET
|
NX_VEGA_ENV=DEVNET
|
||||||
NX_BLOCK_EXPLORER=https://be.devnet1.vega.xyz/rest
|
NX_BLOCK_EXPLORER=https://be.devnet1.vega.xyz/rest
|
||||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
|
||||||
|
|
||||||
|
|
||||||
# App flags
|
# App flags
|
||||||
NX_EXPLORER_ASSETS=1
|
NX_EXPLORER_ASSETS=1
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ NX_TENDERMINT_WEBSOCKET_URL=wss://mainnet-observer-proxy01.ops.vega.xyz/websocke
|
|||||||
NX_VEGA_URL=https://api.vega.community/graphql
|
NX_VEGA_URL=https://api.vega.community/graphql
|
||||||
NX_VEGA_ENV=MAINNET
|
NX_VEGA_ENV=MAINNET
|
||||||
NX_BLOCK_EXPLORER=https://be.explorer.vega.xyz/rest
|
NX_BLOCK_EXPLORER=https://be.explorer.vega.xyz/rest
|
||||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
|
||||||
|
|
||||||
# App flags
|
# App flags
|
||||||
NX_EXPLORER_ASSETS=1
|
NX_EXPLORER_ASSETS=1
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ NX_TENDERMINT_WEBSOCKET_URL=wss://lb.testnet.vega.xyz/tm/websocket
|
|||||||
NX_VEGA_URL=https://api.n07.testnet.vega.xyz/graphql
|
NX_VEGA_URL=https://api.n07.testnet.vega.xyz/graphql
|
||||||
NX_VEGA_ENV=TESTNET
|
NX_VEGA_ENV=TESTNET
|
||||||
NX_BLOCK_EXPLORER=https://be.testnet.vega.xyz/rest
|
NX_BLOCK_EXPLORER=https://be.testnet.vega.xyz/rest
|
||||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
|
||||||
|
|
||||||
# App flags
|
# App flags
|
||||||
NX_EXPLORER_ASSETS=1
|
NX_EXPLORER_ASSETS=1
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
context('Network parameters page', { tags: '@smoke' }, function () {
|
context('Network parameters page', { tags: '@smoke' }, function () {
|
||||||
before('navigate to network parameter page', function () {
|
before('navigate to network parameter page', function () {
|
||||||
cy.fixture('net_parameter_format_lookup').as('networkParameterFormat');
|
cy.fixture('net_parameter_format_lookup').as('networkParameterFormat');
|
||||||
cy.visit('/network-parameters');
|
|
||||||
});
|
});
|
||||||
describe('Verify elements on page', function () {
|
describe('Verify elements on page', function () {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('/network-parameters');
|
||||||
|
});
|
||||||
|
|
||||||
const networkParametersHeader = '[data-testid="network-param-header"]';
|
const networkParametersHeader = '[data-testid="network-param-header"]';
|
||||||
const tableRows = '[data-testid="key-value-table-row"]';
|
const tableRows = '[data-testid="key-value-table-row"]';
|
||||||
|
|
||||||
@@ -13,7 +16,6 @@ context('Network parameters page', { tags: '@smoke' }, function () {
|
|||||||
.and('be.visible');
|
.and('be.visible');
|
||||||
});
|
});
|
||||||
|
|
||||||
// 0006-NETW-021
|
|
||||||
it('should list each of the network parameters available', function () {
|
it('should list each of the network parameters available', function () {
|
||||||
cy.get_network_parameters().then((network_parameters) => {
|
cy.get_network_parameters().then((network_parameters) => {
|
||||||
const numberOfNetworkParametersInSystem =
|
const numberOfNetworkParametersInSystem =
|
||||||
@@ -196,19 +198,6 @@ context('Network parameters page', { tags: '@smoke' }, function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// 0006-NETW-022 0006-NETW-023
|
|
||||||
it('governance assets should be correctly grouped', function () {
|
|
||||||
cy.getByTestId('governance')
|
|
||||||
.should('exist')
|
|
||||||
.parent()
|
|
||||||
.should('have.attr', 'href', '/network-parameters#governance');
|
|
||||||
cy.get('[id="governance-proposal-asset"]')
|
|
||||||
.parent()
|
|
||||||
.within(() => {
|
|
||||||
cy.getByTestId('key-value-table-row').should('have.length', 8);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be able to see network parameters - on mobile', function () {
|
it('should be able to see network parameters - on mobile', function () {
|
||||||
cy.switchToMobile();
|
cy.switchToMobile();
|
||||||
cy.get_network_parameters().then((network_parameters) => {
|
cy.get_network_parameters().then((network_parameters) => {
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
context('Oracle page', { tags: '@smoke' }, () => {
|
|
||||||
describe('Verify elements on page', () => {
|
|
||||||
before('create market and navigate to oracle page', () => {
|
|
||||||
cy.createMarket();
|
|
||||||
cy.visit('/oracles');
|
|
||||||
});
|
|
||||||
it('should see oracle data', () => {
|
|
||||||
cy.getByTestId('oracle-details').should('have.length.at.least', 2);
|
|
||||||
cy.getByTestId('oracle-details')
|
|
||||||
.should('exist')
|
|
||||||
.eq(0)
|
|
||||||
.within(() => {
|
|
||||||
cy.get('tr')
|
|
||||||
.eq(0)
|
|
||||||
.within(() => {
|
|
||||||
cy.get('th').should('have.text', 'ID');
|
|
||||||
cy.get('a').invoke('text').should('have.length', 64);
|
|
||||||
cy.get('a')
|
|
||||||
.should('have.attr', 'href')
|
|
||||||
.and('contain', '/oracles/');
|
|
||||||
});
|
|
||||||
cy.get('tr')
|
|
||||||
.eq(1)
|
|
||||||
.within(() => {
|
|
||||||
cy.get('th').should('have.text', 'Type');
|
|
||||||
cy.get('td').should('have.text', 'External data');
|
|
||||||
});
|
|
||||||
cy.get('tr')
|
|
||||||
.eq(2)
|
|
||||||
.within(() => {
|
|
||||||
cy.get('th').should('have.text', 'Signer');
|
|
||||||
cy.getByTestId('keytype').should('have.text', 'Vega');
|
|
||||||
cy.get('a').invoke('text').should('have.length', 64);
|
|
||||||
cy.get('a')
|
|
||||||
.should('have.attr', 'href')
|
|
||||||
.and('contain', '/parties/');
|
|
||||||
});
|
|
||||||
cy.get('tr')
|
|
||||||
.eq(3)
|
|
||||||
.within(() => {
|
|
||||||
cy.get('th').should('have.text', 'Settlement for');
|
|
||||||
cy.get('a').invoke('text').should('have.length', 64);
|
|
||||||
cy.get('a')
|
|
||||||
.should('have.attr', 'href')
|
|
||||||
.and('contain', '/markets/');
|
|
||||||
});
|
|
||||||
cy.get('tr')
|
|
||||||
.eq(4)
|
|
||||||
.within(() => {
|
|
||||||
cy.get('th').should('have.text', 'Matched data');
|
|
||||||
cy.get('td').should('have.text', '❌');
|
|
||||||
});
|
|
||||||
cy.get('details')
|
|
||||||
.eq(0)
|
|
||||||
.within(() => {
|
|
||||||
cy.contains('Filter').click();
|
|
||||||
cy.get('.language-json').should('exist');
|
|
||||||
});
|
|
||||||
cy.get('details')
|
|
||||||
.eq(1)
|
|
||||||
.within(() => {
|
|
||||||
cy.contains('JSON').click();
|
|
||||||
cy.get('.language-json').should('exist');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -3,7 +3,6 @@ NX_VEGA_ENV=CUSTOM
|
|||||||
NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/test/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/test/announcements.json
|
||||||
NX_VEGA_EXPLORER_URL=/
|
NX_VEGA_EXPLORER_URL=/
|
||||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
|
||||||
|
|
||||||
# App flags
|
# App flags
|
||||||
NX_EXPLORER_TXS_LIST=0
|
NX_EXPLORER_TXS_LIST=0
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ NX_VEGA_URL=https://api.devnet1.vega.xyz/graphql
|
|||||||
NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks-internal/main/devnet1/vegawallet-devnet1.toml
|
NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks-internal/main/devnet1/vegawallet-devnet1.toml
|
||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
||||||
NX_VEGA_EXPLORER_URL=/
|
NX_VEGA_EXPLORER_URL=/
|
||||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
|
||||||
|
|
||||||
NX_TENDERMINT_URL=https://tm.be.devnet1.vega.xyz/
|
NX_TENDERMINT_URL=https://tm.be.devnet1.vega.xyz/
|
||||||
NX_TENDERMINT_WEBSOCKET_URL=wss://be.devnet1.vega.xyz/websocket
|
NX_TENDERMINT_WEBSOCKET_URL=wss://be.devnet1.vega.xyz/websocket
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ NX_VEGA_GOVERNANCE_URL=https://governance.vega.xyz
|
|||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/mainnet/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/mainnet/announcements.json
|
||||||
NX_VEGA_EXPLORER_URL=https://explorer.vega.xyz/
|
NX_VEGA_EXPLORER_URL=https://explorer.vega.xyz/
|
||||||
NX_VEGA_CONSOLE_URL=https://console.vega.xyz
|
NX_VEGA_CONSOLE_URL=https://console.vega.xyz
|
||||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
|
||||||
|
|
||||||
NX_TENDERMINT_URL=https://be.vega.community
|
NX_TENDERMINT_URL=https://be.vega.community
|
||||||
NX_TENDERMINT_WEBSOCKET_URL=wss://be.vega.community/websocket
|
NX_TENDERMINT_WEBSOCKET_URL=wss://be.vega.community/websocket
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ NX_VEGA_GOVERNANCE_URL=https://governance.mainnet-mirror.vega.rocks
|
|||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/mainnet/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/mainnet/announcements.json
|
||||||
NX_VEGA_EXPLORER_URL=https://explorer.mainnet-mirror.vega.rocks/
|
NX_VEGA_EXPLORER_URL=https://explorer.mainnet-mirror.vega.rocks/
|
||||||
NX_VEGA_CONSOLE_URL=https://console.mainnet-mirror.vega.rocks
|
NX_VEGA_CONSOLE_URL=https://console.mainnet-mirror.vega.rocks
|
||||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
|
||||||
|
|
||||||
NX_TENDERMINT_URL=https://be.mainnet-mirror.vega.rocks
|
NX_TENDERMINT_URL=https://be.mainnet-mirror.vega.rocks
|
||||||
NX_TENDERMINT_WEBSOCKET_URL=wss://be.mainnet-mirror.vega.rocks/websocket
|
NX_TENDERMINT_WEBSOCKET_URL=wss://be.mainnet-mirror.vega.rocks/websocket
|
||||||
|
|||||||
@@ -1,3 +1,2 @@
|
|||||||
# .env is stagnet1, so there are no overrides required
|
# .env is stagnet1, so there are no overrides required
|
||||||
NX_VEGA_NETWORKS='{"TESTNET":"https://explorer.fairground.wtf","MAINNET":"https://explorer.vega.xyz","STAGNET1":"https://stagnet1.explorer.vega.xyz"}'
|
NX_VEGA_NETWORKS='{"TESTNET":"https://explorer.fairground.wtf","MAINNET":"https://explorer.vega.xyz","STAGNET1":"https://stagnet1.explorer.vega.xyz"}'
|
||||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ NX_VEGA_GOVERNANCE_URL=https://governance.fairground.wtf
|
|||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
||||||
NX_VEGA_EXPLORER_URL=https://explorer.fairground.wtf
|
NX_VEGA_EXPLORER_URL=https://explorer.fairground.wtf
|
||||||
NX_VEGA_CONSOLE_URL=https://console.fairground.wtf
|
NX_VEGA_CONSOLE_URL=https://console.fairground.wtf
|
||||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
|
||||||
|
|
||||||
NX_TENDERMINT_URL=https://tm.be.testnet.vega.xyz
|
NX_TENDERMINT_URL=https://tm.be.testnet.vega.xyz
|
||||||
NX_TENDERMINT_WEBSOCKET_URL=wss://be.testnet.vega.xyz/websocket
|
NX_TENDERMINT_WEBSOCKET_URL=wss://be.testnet.vega.xyz/websocket
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ NX_BLOCK_EXPLORER=https://be.validators-testnet.vega.rocks/rest
|
|||||||
NX_VEGA_GOVERNANCE_URL=https://governance.validators-testnet.vega.rocks
|
NX_VEGA_GOVERNANCE_URL=https://governance.validators-testnet.vega.rocks
|
||||||
NX_VEGA_EXPLORER_URL=https://explorer.validators-testnet.vega.rocks/
|
NX_VEGA_EXPLORER_URL=https://explorer.validators-testnet.vega.rocks/
|
||||||
NX_VEGA_CONSOLE_URL=https://trading.validators-testnet.vega.rocks/
|
NX_VEGA_CONSOLE_URL=https://trading.validators-testnet.vega.rocks/
|
||||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
|
||||||
|
|
||||||
NX_TENDERMINT_URL=https://tm.be.validators-testnet.vega.rocks
|
NX_TENDERMINT_URL=https://tm.be.validators-testnet.vega.rocks
|
||||||
NX_TENDERMINT_WEBSOCKET_URL=wss://be.validators-testnet.vega.xyz/websocket
|
NX_TENDERMINT_WEBSOCKET_URL=wss://be.validators-testnet.vega.xyz/websocket
|
||||||
|
|||||||
@@ -6,4 +6,3 @@ NX_BLOCK_EXPLORER=
|
|||||||
NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/test/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/test/announcements.json
|
||||||
NX_VEGA_EXPLORER_URL=/
|
NX_VEGA_EXPLORER_URL=/
|
||||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { AssetTypeMapping, AssetStatusMapping } from '@vegaprotocol/assets';
|
|||||||
import { t } from '@vegaprotocol/i18n';
|
import { t } from '@vegaprotocol/i18n';
|
||||||
import { ButtonLink } from '@vegaprotocol/ui-toolkit';
|
import { ButtonLink } from '@vegaprotocol/ui-toolkit';
|
||||||
import type { AgGridReact } from 'ag-grid-react';
|
import type { AgGridReact } from 'ag-grid-react';
|
||||||
import { AgGrid } from '@vegaprotocol/datagrid';
|
import { AgGridLazy as AgGrid } from '@vegaprotocol/datagrid';
|
||||||
import type { VegaICellRendererParams } from '@vegaprotocol/datagrid';
|
import type { VegaICellRendererParams } from '@vegaprotocol/datagrid';
|
||||||
import { useRef, useLayoutEffect } from 'react';
|
import { useRef, useLayoutEffect } from 'react';
|
||||||
import { BREAKPOINT_MD } from '../../config/breakpoints';
|
import { BREAKPOINT_MD } from '../../config/breakpoints';
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { t } from '@vegaprotocol/i18n';
|
|||||||
import { ButtonLink } from '@vegaprotocol/ui-toolkit';
|
import { ButtonLink } from '@vegaprotocol/ui-toolkit';
|
||||||
import type { AgGridReact } from 'ag-grid-react';
|
import type { AgGridReact } from 'ag-grid-react';
|
||||||
import type { ColDef } from 'ag-grid-community';
|
import type { ColDef } from 'ag-grid-community';
|
||||||
import { AgGrid } from '@vegaprotocol/datagrid';
|
import { AgGridLazy as AgGrid } from '@vegaprotocol/datagrid';
|
||||||
import type {
|
import type {
|
||||||
VegaICellRendererParams,
|
VegaICellRendererParams,
|
||||||
VegaValueGetterParams,
|
VegaValueGetterParams,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import type { ProposalListFieldsFragment } from '@vegaprotocol/proposals';
|
|||||||
import { VoteProgress } from '@vegaprotocol/proposals';
|
import { VoteProgress } from '@vegaprotocol/proposals';
|
||||||
import type { AgGridReact } from 'ag-grid-react';
|
import type { AgGridReact } from 'ag-grid-react';
|
||||||
import { ExternalLink } from '@vegaprotocol/ui-toolkit';
|
import { ExternalLink } from '@vegaprotocol/ui-toolkit';
|
||||||
import { AgGrid } from '@vegaprotocol/datagrid';
|
import { AgGridLazy as AgGrid } from '@vegaprotocol/datagrid';
|
||||||
import type {
|
import type {
|
||||||
VegaICellRendererParams,
|
VegaICellRendererParams,
|
||||||
VegaValueFormatterParams,
|
VegaValueFormatterParams,
|
||||||
@@ -33,7 +33,7 @@ export const ProposalsTable = ({ data }: ProposalsTableProps) => {
|
|||||||
const { params } = useNetworkParams([
|
const { params } = useNetworkParams([
|
||||||
NetworkParams.governance_proposal_market_requiredMajority,
|
NetworkParams.governance_proposal_market_requiredMajority,
|
||||||
]);
|
]);
|
||||||
const tokenLink = useLinks(DApp.Governance);
|
const tokenLink = useLinks(DApp.Token);
|
||||||
const requiredMajorityPercentage = useMemo(() => {
|
const requiredMajorityPercentage = useMemo(() => {
|
||||||
const requiredMajority =
|
const requiredMajority =
|
||||||
params?.governance_proposal_market_requiredMajority ?? 1;
|
params?.governance_proposal_market_requiredMajority ?? 1;
|
||||||
@@ -105,7 +105,7 @@ export const ProposalsTable = ({ data }: ProposalsTableProps) => {
|
|||||||
? new BigNumber(0)
|
? new BigNumber(0)
|
||||||
: yesTokens.multipliedBy(100).dividedBy(totalTokensVoted);
|
: yesTokens.multipliedBy(100).dividedBy(totalTokensVoted);
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center h-full pt-2 uppercase">
|
<div className="uppercase flex h-full items-center justify-center pt-2">
|
||||||
<VoteProgress
|
<VoteProgress
|
||||||
threshold={requiredMajorityPercentage}
|
threshold={requiredMajorityPercentage}
|
||||||
progress={yesPercentage}
|
progress={yesPercentage}
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@ export const BundleSigners = ({
|
|||||||
tx,
|
tx,
|
||||||
id,
|
id,
|
||||||
}: BundleSignersProps) => {
|
}: BundleSignersProps) => {
|
||||||
const tokenLink = useLinks(DApp.Governance);
|
const tokenLink = useLinks(DApp.Token);
|
||||||
|
|
||||||
const bridgeFunction: BridgeFunction =
|
const bridgeFunction: BridgeFunction =
|
||||||
tx?.changes?.erc20 && 'contractAddress' in tx.changes.erc20
|
tx?.changes?.erc20 && 'contractAddress' in tx.changes.erc20
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
export * from './network-parameters';
|
export * from './network-parameters';
|
||||||
export * from './structure-network-params';
|
|
||||||
|
|||||||
@@ -1,105 +1,82 @@
|
|||||||
import { render, screen } from '@testing-library/react';
|
import { render, screen } from '@testing-library/react';
|
||||||
import type { NetworkParamsQuery } from '@vegaprotocol/network-parameters';
|
import type { NetworkParamsQuery } from '@vegaprotocol/network-parameters';
|
||||||
import { NetworkParametersTable } from './network-parameters';
|
import { NetworkParametersTable } from './network-parameters';
|
||||||
import { MemoryRouter } from 'react-router-dom';
|
|
||||||
|
|
||||||
const renderComponent = (data: NetworkParamsQuery | undefined) => {
|
|
||||||
return render(
|
|
||||||
<MemoryRouter>
|
|
||||||
<NetworkParametersTable data={data} loading={false} />
|
|
||||||
</MemoryRouter>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const mockData = {
|
|
||||||
networkParametersConnection: {
|
|
||||||
edges: [
|
|
||||||
{
|
|
||||||
node: {
|
|
||||||
key: 'spam.protection.delegation.min.tokens',
|
|
||||||
value: '3',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
node: {
|
|
||||||
key: 'spam.protection.voting.min.tokens',
|
|
||||||
value: '1',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
node: {
|
|
||||||
key: 'reward.staking.delegation.minimumValidatorStake',
|
|
||||||
value: '2',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
node: {
|
|
||||||
key: 'reward.asset',
|
|
||||||
value:
|
|
||||||
'fc7fd956078fb1fc9db5c19b88f0874c4299b2a7639ad05a47a28c0aef291b55',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
describe('NetworkParametersTable', () => {
|
describe('NetworkParametersTable', () => {
|
||||||
it('renders headers correctly', () => {
|
it('renders correctly when it has network params', () => {
|
||||||
renderComponent(mockData);
|
const data: NetworkParamsQuery = {
|
||||||
|
networkParametersConnection: {
|
||||||
const allHeadings = screen.getAllByRole('heading');
|
edges: [
|
||||||
expect(
|
{
|
||||||
allHeadings.map((h) => {
|
node: {
|
||||||
return {
|
__typename: 'NetworkParameter',
|
||||||
text: h.textContent,
|
key: 'market.liquidityProvision.minLpStakeQuantumMultiple',
|
||||||
level: h.tagName,
|
value: '1',
|
||||||
testId: h.getAttribute('data-testid'),
|
},
|
||||||
};
|
},
|
||||||
})
|
{
|
||||||
).toEqual([
|
node: {
|
||||||
{
|
__typename: 'NetworkParameter',
|
||||||
text: 'Network Parameters',
|
key: 'market.fee.factors.infrastructureFee',
|
||||||
level: 'H1',
|
value: '0.0005',
|
||||||
testId: 'network-param-header',
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{ text: 'Spam', level: 'H1', testId: 'spam' },
|
};
|
||||||
{ text: 'Protection', level: 'H2', testId: 'spam-protection' },
|
render(<NetworkParametersTable data={data} loading={false} />);
|
||||||
{ text: 'Delegation', level: 'H3', testId: 'spam-protection-delegation' },
|
expect(screen.getByTestId('network-param-header')).toHaveTextContent(
|
||||||
{ text: 'Min', level: 'H4', testId: 'spam-protection-delegation-min' },
|
'Network Parameters'
|
||||||
{ text: 'Voting', level: 'H3', testId: 'spam-protection-voting' },
|
);
|
||||||
{ text: 'Min', level: 'H4', testId: 'spam-protection-voting-min' },
|
const rows = screen.getAllByTestId('key-value-table-row');
|
||||||
{ text: 'Reward', level: 'H1', testId: 'reward' },
|
expect(rows[0].children[0]).toHaveTextContent(
|
||||||
{ text: 'Staking', level: 'H2', testId: 'reward-staking' },
|
'market.fee.factors.infrastructureFee'
|
||||||
{ text: 'Delegation', level: 'H3', testId: 'reward-staking-delegation' },
|
);
|
||||||
]);
|
expect(rows[1].children[0]).toHaveTextContent(
|
||||||
|
'market.liquidityProvision.minLpStakeQuantumMultiple'
|
||||||
|
);
|
||||||
|
expect(rows[0].children[1]).toHaveTextContent('0.0005');
|
||||||
|
expect(rows[1].children[1]).toHaveTextContent('1');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders network params correctly', () => {
|
it('renders the rows in ascending order', () => {
|
||||||
renderComponent(mockData);
|
const data: NetworkParamsQuery = {
|
||||||
|
networkParametersConnection: {
|
||||||
const delegationMinTokensRow = screen.getByTestId(
|
edges: [
|
||||||
'spam-protection-delegation-min-tokens'
|
{
|
||||||
|
node: {
|
||||||
|
__typename: 'NetworkParameter',
|
||||||
|
key: 'market.fee.factors.infrastructureFee',
|
||||||
|
value: '0.0005',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
node: {
|
||||||
|
__typename: 'NetworkParameter',
|
||||||
|
key: 'market.liquidityProvision.minLpStakeQuantumMultiple',
|
||||||
|
value: '1',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
render(<NetworkParametersTable data={data} loading={false} />);
|
||||||
|
expect(screen.getByTestId('network-param-header')).toHaveTextContent(
|
||||||
|
'Network Parameters'
|
||||||
);
|
);
|
||||||
expect(delegationMinTokensRow).toHaveTextContent('0.000000000000000003');
|
const rows = screen.getAllByTestId('key-value-table-row');
|
||||||
|
expect(rows[0].children[0]).toHaveTextContent(
|
||||||
const votingMinTokensRow = screen.getByTestId(
|
'market.fee.factors.infrastructureFee'
|
||||||
'spam-protection-voting-min-tokens'
|
|
||||||
);
|
);
|
||||||
expect(votingMinTokensRow).toHaveTextContent('0.000000000000000001');
|
expect(rows[1].children[0]).toHaveTextContent(
|
||||||
|
'market.liquidityProvision.minLpStakeQuantumMultiple'
|
||||||
const minimumValidatorStakeRow = screen.getByTestId(
|
|
||||||
'reward-staking-delegation-minimumValidatorStake'
|
|
||||||
);
|
|
||||||
expect(minimumValidatorStakeRow).toHaveTextContent('2');
|
|
||||||
|
|
||||||
const assetRow = screen.getByTestId('reward-asset');
|
|
||||||
expect(assetRow).toHaveTextContent(
|
|
||||||
'fc7fd956078fb1fc9db5c19b88f0874c4299b2a7639ad05a47a28c0aef291b55'
|
|
||||||
);
|
);
|
||||||
|
expect(rows[0].children[1]).toHaveTextContent('0.0005');
|
||||||
|
expect(rows[1].children[1]).toHaveTextContent('1');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not render rows when is loading', () => {
|
it('does not render rows when is loading', () => {
|
||||||
renderComponent(undefined);
|
render(<NetworkParametersTable data={undefined} loading={true} />);
|
||||||
expect(screen.getByTestId('network-param-header')).toHaveTextContent(
|
expect(screen.getByTestId('network-param-header')).toHaveTextContent(
|
||||||
'Network Parameters'
|
'Network Parameters'
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import startCase from 'lodash/startCase';
|
|
||||||
import classNames from 'classnames';
|
|
||||||
import { Link } from 'react-router-dom';
|
|
||||||
import {
|
import {
|
||||||
AsyncRenderer,
|
AsyncRenderer,
|
||||||
|
KeyValueTable,
|
||||||
KeyValueTableRow,
|
KeyValueTableRow,
|
||||||
SyntaxHighlighter,
|
SyntaxHighlighter,
|
||||||
} from '@vegaprotocol/ui-toolkit';
|
} from '@vegaprotocol/ui-toolkit';
|
||||||
@@ -14,12 +12,11 @@ import {
|
|||||||
} from '@vegaprotocol/utils';
|
} from '@vegaprotocol/utils';
|
||||||
import { t } from '@vegaprotocol/i18n';
|
import { t } from '@vegaprotocol/i18n';
|
||||||
import { RouteTitle } from '../../components/route-title';
|
import { RouteTitle } from '../../components/route-title';
|
||||||
|
import orderBy from 'lodash/orderBy';
|
||||||
import { useNetworkParamsQuery } from '@vegaprotocol/network-parameters';
|
import { useNetworkParamsQuery } from '@vegaprotocol/network-parameters';
|
||||||
|
import type { NetworkParamsQuery } from '@vegaprotocol/network-parameters';
|
||||||
import { useScrollToLocation } from '../../hooks/scroll-to-location';
|
import { useScrollToLocation } from '../../hooks/scroll-to-location';
|
||||||
import { useDocumentTitle } from '../../hooks/use-document-title';
|
import { useDocumentTitle } from '../../hooks/use-document-title';
|
||||||
import { structureNetworkParams } from './structure-network-params';
|
|
||||||
import type { NetworkParamsQuery } from '@vegaprotocol/network-parameters';
|
|
||||||
import type { GroupedParams } from './structure-network-params';
|
|
||||||
|
|
||||||
const PERCENTAGE_PARAMS = [
|
const PERCENTAGE_PARAMS = [
|
||||||
'governance.proposal.asset.requiredMajority',
|
'governance.proposal.asset.requiredMajority',
|
||||||
@@ -61,54 +58,6 @@ const BIG_NUMBER_PARAMS = [
|
|||||||
'governance.proposal.updateAsset.minVoterBalance',
|
'governance.proposal.updateAsset.minVoterBalance',
|
||||||
];
|
];
|
||||||
|
|
||||||
export const renderGroupedParams = (
|
|
||||||
group: GroupedParams,
|
|
||||||
level: number,
|
|
||||||
parentKeys: string[] = []
|
|
||||||
) => {
|
|
||||||
const Header = `h${level}` as keyof JSX.IntrinsicElements;
|
|
||||||
const headerStyles = classNames('uppercase font-semibold', {
|
|
||||||
'pt-6 text-3xl underline': level === 1,
|
|
||||||
'pt-3 text-2xl': level === 2,
|
|
||||||
'pt-2 text-lg': level === 3,
|
|
||||||
'pt-2 text-default': level === 4,
|
|
||||||
});
|
|
||||||
|
|
||||||
return Object.entries(group).map(([key, value]) => {
|
|
||||||
const fullPath = [...parentKeys, key].join('.');
|
|
||||||
const isLeafNode = typeof value !== 'object';
|
|
||||||
const id = parentKeys.concat([key]).join('-');
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div key={key}>
|
|
||||||
{!isLeafNode && (
|
|
||||||
<div id={id}>
|
|
||||||
<Link to={`#${id}`}>
|
|
||||||
<Header className={headerStyles} data-testid={id}>
|
|
||||||
{startCase(key)}
|
|
||||||
</Header>
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{isLeafNode ? (
|
|
||||||
typeof value === 'string' ? (
|
|
||||||
<div data-testid={id}>
|
|
||||||
<NetworkParameterRow
|
|
||||||
key={fullPath}
|
|
||||||
row={{ key: fullPath, value: value }}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
) : null
|
|
||||||
) : (
|
|
||||||
<div className="pb-1">
|
|
||||||
{renderGroupedParams(value, level + 1, [...parentKeys, key])}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export const NetworkParameterRow = ({
|
export const NetworkParameterRow = ({
|
||||||
row: { key, value },
|
row: { key, value },
|
||||||
}: {
|
}: {
|
||||||
@@ -128,9 +77,7 @@ export const NetworkParameterRow = ({
|
|||||||
>
|
>
|
||||||
{key}
|
{key}
|
||||||
{isSyntaxRow ? (
|
{isSyntaxRow ? (
|
||||||
<div className="pb-2">
|
<SyntaxHighlighter data={JSON.parse(value)} />
|
||||||
<SyntaxHighlighter data={JSON.parse(value)} />
|
|
||||||
</div>
|
|
||||||
) : isNaN(Number(value)) ? (
|
) : isNaN(Number(value)) ? (
|
||||||
value
|
value
|
||||||
) : BIG_NUMBER_PARAMS.includes(key) ? (
|
) : BIG_NUMBER_PARAMS.includes(key) ? (
|
||||||
@@ -166,12 +113,17 @@ export const NetworkParametersTable = ({
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
error={error}
|
error={error}
|
||||||
render={(data) => {
|
render={(data) => {
|
||||||
const flatParams = removePaginationWrapper(
|
const ascParams = orderBy(
|
||||||
data.networkParametersConnection.edges
|
removePaginationWrapper(data.networkParametersConnection.edges),
|
||||||
|
(param) => param.key,
|
||||||
|
'asc'
|
||||||
);
|
);
|
||||||
const groupedParams = structureNetworkParams(flatParams);
|
|
||||||
return (
|
return (
|
||||||
<div className="-mt-6">{renderGroupedParams(groupedParams, 1)}</div>
|
<KeyValueTable data-testid="parameters">
|
||||||
|
{(ascParams || []).map((row) => (
|
||||||
|
<NetworkParameterRow key={row.key} row={row} />
|
||||||
|
))}
|
||||||
|
</KeyValueTable>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
import type { GroupedParams } from './structure-network-params';
|
|
||||||
import {
|
|
||||||
structureParams,
|
|
||||||
sortGroupedParams,
|
|
||||||
structureNetworkParams,
|
|
||||||
} from './structure-network-params';
|
|
||||||
|
|
||||||
describe('structureParams', () => {
|
|
||||||
it('should correctly structure params', () => {
|
|
||||||
const input = [
|
|
||||||
{ key: 'spam.protection.delegation.min.tokens', value: '10' },
|
|
||||||
{ key: 'spam.protection.voting.min.tokens', value: '5' },
|
|
||||||
];
|
|
||||||
const output: GroupedParams = {
|
|
||||||
spam: {
|
|
||||||
protection: {
|
|
||||||
delegation: {
|
|
||||||
min: {
|
|
||||||
tokens: '10',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
voting: {
|
|
||||||
min: {
|
|
||||||
tokens: '5',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
expect(structureParams(input)).toEqual(output);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle top-level keys correctly', () => {
|
|
||||||
const input = [{ key: 'levelOne', value: '10' }];
|
|
||||||
const output = {
|
|
||||||
levelOne: '10',
|
|
||||||
};
|
|
||||||
expect(structureParams(input)).toEqual(output);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('sortGroupedParams', () => {
|
|
||||||
it('should correctly sort grouped params', () => {
|
|
||||||
const input: GroupedParams = {
|
|
||||||
spam: {
|
|
||||||
protection: {
|
|
||||||
delegation: {
|
|
||||||
min: {
|
|
||||||
tokens: '10',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
reward: '50',
|
|
||||||
};
|
|
||||||
const output: GroupedParams = {
|
|
||||||
reward: '50',
|
|
||||||
spam: {
|
|
||||||
protection: {
|
|
||||||
delegation: {
|
|
||||||
min: {
|
|
||||||
tokens: '10',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
expect(sortGroupedParams(input)).toEqual(output);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle already sorted keys', () => {
|
|
||||||
const input = {
|
|
||||||
a: '10',
|
|
||||||
b: {
|
|
||||||
c: '5',
|
|
||||||
d: '6',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
expect(sortGroupedParams(input)).toEqual(input);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('structureNetworkParams', () => {
|
|
||||||
it('should structure and sort network params correctly', () => {
|
|
||||||
const input = [
|
|
||||||
{ key: 'spam.protection.delegation.min.tokens', value: '10' },
|
|
||||||
{ key: 'reward.asset', value: '50' },
|
|
||||||
];
|
|
||||||
const output: GroupedParams = {
|
|
||||||
reward: {
|
|
||||||
asset: '50',
|
|
||||||
},
|
|
||||||
spam: {
|
|
||||||
protection: {
|
|
||||||
delegation: {
|
|
||||||
min: {
|
|
||||||
tokens: '10',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
expect(structureNetworkParams(input)).toEqual(output);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return an empty object if no params are provided', () => {
|
|
||||||
expect(structureNetworkParams([])).toEqual({});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
/**
|
|
||||||
* Categorizes and sorts an array of key-value pairs of network params into a nested object structure.
|
|
||||||
*
|
|
||||||
* The function takes an array of network params where keys are dot-delimited
|
|
||||||
* strings representing nested categories (e.g., 'spam.protection.delegation.min.tokens').
|
|
||||||
*
|
|
||||||
* Why this is necessary:
|
|
||||||
* A flat key-value structure wouldn't provide the hierarchical information needed.
|
|
||||||
* Organizing network parameters like this allows the rendering of nested headers
|
|
||||||
* and their corresponding network params.
|
|
||||||
*
|
|
||||||
* It also ensures that items with the minimum amount of nesting are ordered first. This
|
|
||||||
* allows us to render these items first, before more deeply nested items are rendered with
|
|
||||||
* subheaders. This creates a more intuitive UI.
|
|
||||||
*
|
|
||||||
* For example, given the input:
|
|
||||||
* [
|
|
||||||
* { key: 'spam.protection.delegation.min.tokens', value: '10' },
|
|
||||||
* { key: 'spam.protection.voting.min.tokens', value: '5' },
|
|
||||||
* { key: 'reward.staking.delegation.minimumValidatorStake', value: '2' }
|
|
||||||
* { key: 'reward.asset', value: 'fc7fd956078fb1fc9db5c19b88f0874c4299b2a7639ad05a47a28c0aef291b55' }
|
|
||||||
* ]
|
|
||||||
*
|
|
||||||
* The output will be:
|
|
||||||
* {
|
|
||||||
* spam: {
|
|
||||||
* protection: {
|
|
||||||
* delegation: {
|
|
||||||
* min: {
|
|
||||||
* tokens: '10'
|
|
||||||
* }
|
|
||||||
* },
|
|
||||||
* voting: {
|
|
||||||
* min: {
|
|
||||||
* tokens: '5'
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* },
|
|
||||||
* reward: {
|
|
||||||
* asset: 'fc7fd956078fb1fc9db5c19b88f0874c4299b2a7639ad05a47a28c0aef291b55',
|
|
||||||
* staking: {
|
|
||||||
* delegation: {
|
|
||||||
* minimumValidatorStake: '2'
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* @param {Array} params - An array of key-value pairs to categorize and sort.
|
|
||||||
* @returns {GroupedParams} - A nested object that groups the key-value pairs.
|
|
||||||
*/
|
|
||||||
|
|
||||||
export type GroupedParams = {
|
|
||||||
[key: string]: string | GroupedParams;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const structureParams = (
|
|
||||||
params: { key: string; value: string }[]
|
|
||||||
): GroupedParams => {
|
|
||||||
const grouped: GroupedParams = {};
|
|
||||||
|
|
||||||
params.forEach(({ key, value }) => {
|
|
||||||
const parts = key.split('.');
|
|
||||||
let node: GroupedParams = grouped;
|
|
||||||
|
|
||||||
parts.forEach((part, i) => {
|
|
||||||
if (typeof node[part] === 'undefined') {
|
|
||||||
node[part] = i === parts.length - 1 ? value : {};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof node[part] === 'object') {
|
|
||||||
node = node[part] as GroupedParams;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return grouped;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const sortGroupedParams = (
|
|
||||||
groupedParams: GroupedParams
|
|
||||||
): GroupedParams => {
|
|
||||||
const sorted: GroupedParams = {};
|
|
||||||
|
|
||||||
// Sort top-level keys first
|
|
||||||
Object.entries(groupedParams).forEach(([key, value]) => {
|
|
||||||
if (typeof value === 'string') {
|
|
||||||
sorted[key] = value;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Object.entries(groupedParams).forEach(([key, value]) => {
|
|
||||||
if (typeof value === 'object') {
|
|
||||||
sorted[key] = sortGroupedParams(value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return sorted;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const structureNetworkParams = (
|
|
||||||
params: { key: string; value: string }[]
|
|
||||||
) => {
|
|
||||||
const grouped = structureParams(params);
|
|
||||||
return sortGroupedParams(grouped);
|
|
||||||
};
|
|
||||||
@@ -8,9 +8,7 @@ import { useScrollToLocation } from '../../../hooks/scroll-to-location';
|
|||||||
import filter from 'recursive-key-filter';
|
import filter from 'recursive-key-filter';
|
||||||
|
|
||||||
const Oracles = () => {
|
const Oracles = () => {
|
||||||
const { data, loading, error } = useExplorerOracleSpecsQuery({
|
const { data, loading, error } = useExplorerOracleSpecsQuery();
|
||||||
errorPolicy: 'ignore',
|
|
||||||
});
|
|
||||||
|
|
||||||
useDocumentTitle(['Oracles']);
|
useDocumentTitle(['Oracles']);
|
||||||
useScrollToLocation();
|
useScrollToLocation();
|
||||||
@@ -40,12 +38,7 @@ const Oracles = () => {
|
|||||||
const dataConnection = o?.node.dataConnection;
|
const dataConnection = o?.node.dataConnection;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div id={id} key={id} className="mb-10">
|
||||||
id={id}
|
|
||||||
key={id}
|
|
||||||
className="mb-10"
|
|
||||||
data-testid="oracle-details"
|
|
||||||
>
|
|
||||||
<OracleDetails
|
<OracleDetails
|
||||||
id={id}
|
id={id}
|
||||||
dataSource={o?.node}
|
dataSource={o?.node}
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ export const ValidatorsPage = () => {
|
|||||||
const [vegaDialog, setVegaDialog] = useState<boolean>(false);
|
const [vegaDialog, setVegaDialog] = useState<boolean>(false);
|
||||||
const [tmDialog, setTmDialog] = useState<boolean>(false);
|
const [tmDialog, setTmDialog] = useState<boolean>(false);
|
||||||
|
|
||||||
const tokenLink = useLinks(DApp.Governance);
|
const tokenLink = useLinks(DApp.Token);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ NX_ETH_LOCAL_PROVIDER_URL=http://localhost:8545/
|
|||||||
NX_VEGA_WALLET_URL=http://localhost:1789
|
NX_VEGA_WALLET_URL=http://localhost:1789
|
||||||
NX_VEGA_DOCS_URL=https://docs.vega.xyz/mainnet
|
NX_VEGA_DOCS_URL=https://docs.vega.xyz/mainnet
|
||||||
NX_TRANCHES_SERVICE_URL=https://tranches-stagnet1-k8s.ops.vega.xyz
|
NX_TRANCHES_SERVICE_URL=https://tranches-stagnet1-k8s.ops.vega.xyz
|
||||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
|
||||||
|
|
||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/test/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/test/announcements.json
|
||||||
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
|
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
|
||||||
NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72
|
NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72
|
||||||
|
|||||||
@@ -3,4 +3,3 @@ NX_VEGA_ENV=DEVNET
|
|||||||
NX_VEGA_URL=https://api.n04.d.vega.xyz/graphql
|
NX_VEGA_URL=https://api.n04.d.vega.xyz/graphql
|
||||||
NX_ETHEREUM_PROVIDER_URL=https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
NX_ETHEREUM_PROVIDER_URL=https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||||
NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
||||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
|
||||||
|
|||||||
@@ -3,4 +3,3 @@ NX_VEGA_ENV=MAINNET
|
|||||||
NX_VEGA_URL=https://api.vega.community/graphql
|
NX_VEGA_URL=https://api.vega.community/graphql
|
||||||
NX_ETHEREUM_PROVIDER_URL=https://mainnet.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
NX_ETHEREUM_PROVIDER_URL=https://mainnet.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||||
NX_ETHERSCAN_URL=https://etherscan.io
|
NX_ETHERSCAN_URL=https://etherscan.io
|
||||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
|
||||||
|
|||||||
@@ -3,4 +3,3 @@ NX_VEGA_ENV=TESTNET
|
|||||||
NX_VEGA_URL=https://api.n07.testnet.vega.xyz/graphql
|
NX_VEGA_URL=https://api.n07.testnet.vega.xyz/graphql
|
||||||
NX_ETHEREUM_PROVIDER_URL=https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
NX_ETHEREUM_PROVIDER_URL=https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||||
NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
||||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
|
||||||
|
|||||||
@@ -19,22 +19,7 @@ export const upgradeProposalsData = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
node: {
|
node: {
|
||||||
upgradeBlockHeight: '10001',
|
upgradeBlockHeight: '1955065',
|
||||||
vegaReleaseTag: 'v0.71.0+dev-12156-bca1d57e',
|
|
||||||
approvers: [
|
|
||||||
'02a6531716b7a6d82779b7793c3ad2fcb47290ea2ff0912c56f61219bd9675ff',
|
|
||||||
'121934387281812a2d5e6913e5d57c0f85a8f169e2752347ee2e23b52d46623c',
|
|
||||||
'65c80e2f5f84e2109eec30810f137ba04cbbecaba8f27706c146cc6c6f90db29',
|
|
||||||
'bd6339d2428c79ac3bc9011771236d17bac92bcb1806423388d52fb440043aef',
|
|
||||||
],
|
|
||||||
status: 'PROTOCOL_UPGRADE_PROPOSAL_STATUS_APPROVED',
|
|
||||||
__typename: 'ProtocolUpgradeProposal',
|
|
||||||
},
|
|
||||||
__typename: 'ProtocolUpgradeProposalEdge',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
node: {
|
|
||||||
upgradeBlockHeight: '20',
|
|
||||||
vegaReleaseTag: 'v0.71.0+dev-12156-bca1d57e',
|
vegaReleaseTag: 'v0.71.0+dev-12156-bca1d57e',
|
||||||
approvers: [
|
approvers: [
|
||||||
'02a6531716b7a6d82779b7793c3ad2fcb47290ea2ff0912c56f61219bd9675ff',
|
'02a6531716b7a6d82779b7793c3ad2fcb47290ea2ff0912c56f61219bd9675ff',
|
||||||
|
|||||||
@@ -34,20 +34,19 @@ import { formatDateWithLocalTimezone } from '@vegaprotocol/utils';
|
|||||||
import { createSuccessorMarketProposalTxBody } from '../../support/proposal.functions';
|
import { createSuccessorMarketProposalTxBody } from '../../support/proposal.functions';
|
||||||
|
|
||||||
const proposalListItem = '[data-testid="proposals-list-item"]';
|
const proposalListItem = '[data-testid="proposals-list-item"]';
|
||||||
const participationNotMet = 'token-participation-not-met';
|
const proposalVoteProgressForPercentage =
|
||||||
const voteStatus = 'vote-status';
|
'vote-progress-indicator-percentage-for';
|
||||||
const voteMajorityNotMet = 'token-majority-not-met';
|
const proposalVoteProgressAgainstPercentage =
|
||||||
const numberOfVotesFor = 'num-votes-for';
|
'vote-progress-indicator-percentage-against';
|
||||||
const votesForPercentage = 'votes-for-percentage';
|
const proposalVoteProgressForTokens = 'vote-progress-indicator-tokens-for';
|
||||||
const numberOfVotesAgainst = 'num-votes-against';
|
const proposalVoteProgressAgainstTokens =
|
||||||
const votesAgainstPercentage = 'votes-against-percentage';
|
'vote-progress-indicator-tokens-against';
|
||||||
const totalVotedNumber = 'total-voted';
|
|
||||||
const totalVotedPercentage = 'total-voted-percentage';
|
|
||||||
const changeVoteButton = 'change-vote-button';
|
const changeVoteButton = 'change-vote-button';
|
||||||
const proposalDetailsTitle = 'proposal-title';
|
const proposalDetailsTitle = 'proposal-title';
|
||||||
const proposalDetailsDescription = 'proposal-description';
|
const proposalDetailsDescription = 'proposal-description';
|
||||||
const openProposals = 'open-proposals';
|
const openProposals = 'open-proposals';
|
||||||
const viewProposalButton = 'view-proposal-btn';
|
const viewProposalButton = 'view-proposal-btn';
|
||||||
|
const voteBreakdownToggle = 'vote-breakdown-toggle';
|
||||||
const proposalTermsToggle = 'proposal-json-toggle';
|
const proposalTermsToggle = 'proposal-json-toggle';
|
||||||
const marketDataToggle = 'proposal-market-data-toggle';
|
const marketDataToggle = 'proposal-market-data-toggle';
|
||||||
|
|
||||||
@@ -151,32 +150,29 @@ describe(
|
|||||||
// 3001-VOTE-037
|
// 3001-VOTE-037
|
||||||
// 3001-VOTE-040
|
// 3001-VOTE-040
|
||||||
// 3001-VOTE-067
|
// 3001-VOTE-067
|
||||||
// 3001-VOTE-023
|
|
||||||
createRawProposal();
|
createRawProposal();
|
||||||
cy.get<testFreeformProposal>('@rawProposal').then((rawProposal) => {
|
cy.get<testFreeformProposal>('@rawProposal').then((rawProposal) => {
|
||||||
getProposalFromTitle(rawProposal.rationale.title).within(() =>
|
getProposalFromTitle(rawProposal.rationale.title).within(() =>
|
||||||
cy.getByTestId(viewProposalButton).click()
|
cy.getByTestId(viewProposalButton).click()
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
cy.getByTestId(participationNotMet).should(
|
cy.contains('Participation: Not Met 0.00 0.00%(0.00% Required)').should(
|
||||||
'have.text',
|
'be.visible'
|
||||||
'0.000000000000000000000015% participation threshold not met'
|
|
||||||
);
|
|
||||||
cy.getByTestId(voteMajorityNotMet).should(
|
|
||||||
'have.text',
|
|
||||||
'66% majority threshold not met'
|
|
||||||
);
|
|
||||||
cy.getByTestId(voteStatus).should(
|
|
||||||
'have.text',
|
|
||||||
'Currently expected to fail'
|
|
||||||
);
|
);
|
||||||
|
cy.getByTestId(voteBreakdownToggle).click();
|
||||||
|
getProposalInformationFromTable('Expected to pass')
|
||||||
|
.contains('👎')
|
||||||
|
.should('be.visible');
|
||||||
// 3001-VOTE-062
|
// 3001-VOTE-062
|
||||||
// 3001-VOTE-040
|
// 3001-VOTE-040
|
||||||
// 3001-VOTE-070
|
// 3001-VOTE-070
|
||||||
|
getProposalInformationFromTable('Token majority met')
|
||||||
|
.contains('👎')
|
||||||
|
.should('be.visible');
|
||||||
// 3001-VOTE-068
|
// 3001-VOTE-068
|
||||||
cy.getByTestId(numberOfVotesFor).should('have.text', '0.0M');
|
getProposalInformationFromTable('Token participation met')
|
||||||
cy.getByTestId(numberOfVotesAgainst).should('have.text', '0.0M');
|
.contains('👎')
|
||||||
cy.getByTestId(totalVotedNumber).should('have.text', '0.0M');
|
.should('be.visible');
|
||||||
});
|
});
|
||||||
|
|
||||||
// 3001-VOTE-080 3001-VOTE-090 3001-VOTE-069 3001-VOTE-072 3001-VOTE-073
|
// 3001-VOTE-080 3001-VOTE-090 3001-VOTE-069 3001-VOTE-072 3001-VOTE-073
|
||||||
@@ -201,16 +197,43 @@ describe(
|
|||||||
.contains(votedDate)
|
.contains(votedDate)
|
||||||
.should('be.visible');
|
.should('be.visible');
|
||||||
});
|
});
|
||||||
cy.getByTestId(votesForPercentage) // 3001-VOTE-072
|
cy.getByTestId(proposalVoteProgressForPercentage) // 3001-VOTE-072
|
||||||
.should('have.text', '100%');
|
.contains('100.00%')
|
||||||
cy.getByTestId(votesAgainstPercentage).should('have.text', '0%');
|
.and('be.visible');
|
||||||
cy.getByTestId('token-majority-progress')
|
cy.getByTestId(proposalVoteProgressAgainstPercentage)
|
||||||
.should('have.attr', 'style')
|
.contains('0.00%')
|
||||||
.and('eq', 'width: 100%;'); // 3001-VOTE-024
|
.and('be.visible');
|
||||||
|
cy.getByTestId(proposalVoteProgressForTokens)
|
||||||
|
.contains('1.00')
|
||||||
|
.and('be.visible');
|
||||||
|
cy.getByTestId(proposalVoteProgressAgainstTokens)
|
||||||
|
.contains('0.00')
|
||||||
|
.and('be.visible');
|
||||||
|
cy.getByTestId(voteBreakdownToggle).click();
|
||||||
|
getProposalInformationFromTable('Tokens for proposal')
|
||||||
|
.should('have.text', (1).toFixed(2))
|
||||||
|
.and('be.visible');
|
||||||
|
getProposalInformationFromTable('Tokens against proposal')
|
||||||
|
.should('have.text', '0.00')
|
||||||
|
.and('be.visible');
|
||||||
|
// 3001-VOTE-061
|
||||||
|
getProposalInformationFromTable('Participation required')
|
||||||
|
.contains('0.00%')
|
||||||
|
.should('be.visible');
|
||||||
|
// 3001-VOTE-066
|
||||||
|
getProposalInformationFromTable('Majority Required') // 3001-VOTE-073
|
||||||
|
.contains(`${(66).toFixed(2)}%`)
|
||||||
|
.should('be.visible');
|
||||||
|
getProposalInformationFromTable('Number of voting parties')
|
||||||
|
.should('have.text', '1')
|
||||||
|
.and('be.visible');
|
||||||
cy.getByTestId(changeVoteButton).should('be.visible').click();
|
cy.getByTestId(changeVoteButton).should('be.visible').click();
|
||||||
voteForProposal('for');
|
voteForProposal('for');
|
||||||
// 3001-VOTE-064
|
// 3001-VOTE-064
|
||||||
cy.getByTestId('user-voted-yes').should('exist');
|
cy.getByTestId('user-voted-yes').should('exist');
|
||||||
|
getProposalInformationFromTable('Tokens for proposal')
|
||||||
|
.should('have.text', (1).toFixed(2))
|
||||||
|
.and('be.visible');
|
||||||
navigateTo(navigation.proposals);
|
navigateTo(navigation.proposals);
|
||||||
cy.get<testFreeformProposal>('@rawProposal').then((rawProposal) => {
|
cy.get<testFreeformProposal>('@rawProposal').then((rawProposal) => {
|
||||||
getProposalFromTitle(rawProposal.rationale.title).within(() => {
|
getProposalFromTitle(rawProposal.rationale.title).within(() => {
|
||||||
@@ -221,7 +244,16 @@ describe(
|
|||||||
});
|
});
|
||||||
cy.getByTestId(changeVoteButton).should('be.visible').click();
|
cy.getByTestId(changeVoteButton).should('be.visible').click();
|
||||||
voteForProposal('against');
|
voteForProposal('against');
|
||||||
cy.getByTestId(votesAgainstPercentage).should('have.text', '100%');
|
cy.getByTestId(proposalVoteProgressAgainstPercentage)
|
||||||
|
.contains('100.00%')
|
||||||
|
.and('be.visible');
|
||||||
|
cy.getByTestId(voteBreakdownToggle).click();
|
||||||
|
getProposalInformationFromTable('Tokens against proposal')
|
||||||
|
.should('have.text', (1).toFixed(2))
|
||||||
|
.and('be.visible');
|
||||||
|
getProposalInformationFromTable('Number of voting parties')
|
||||||
|
.should('have.text', '1')
|
||||||
|
.and('be.visible');
|
||||||
navigateTo(navigation.proposals);
|
navigateTo(navigation.proposals);
|
||||||
cy.get<testFreeformProposal>('@rawProposal').then((rawProposal) => {
|
cy.get<testFreeformProposal>('@rawProposal').then((rawProposal) => {
|
||||||
getProposalFromTitle(rawProposal.rationale.title).within(() => {
|
getProposalFromTitle(rawProposal.rationale.title).within(() => {
|
||||||
@@ -233,7 +265,6 @@ describe(
|
|||||||
|
|
||||||
// 3001-VOTE-042, 3001-VOTE-057, 3001-VOTE-058, 3001-VOTE-059, 3001-VOTE-060
|
// 3001-VOTE-042, 3001-VOTE-057, 3001-VOTE-058, 3001-VOTE-059, 3001-VOTE-060
|
||||||
it('Newly created proposal details - ability to increase associated tokens - by voting again after association', function () {
|
it('Newly created proposal details - ability to increase associated tokens - by voting again after association', function () {
|
||||||
ensureSpecifiedUnstakedTokensAreAssociated('1');
|
|
||||||
vegaWalletSetSpecifiedApprovalAmount('1000');
|
vegaWalletSetSpecifiedApprovalAmount('1000');
|
||||||
createRawProposal();
|
createRawProposal();
|
||||||
cy.get<testFreeformProposal>('@rawProposal').then((rawProposal) => {
|
cy.get<testFreeformProposal>('@rawProposal').then((rawProposal) => {
|
||||||
@@ -244,28 +275,69 @@ describe(
|
|||||||
voteForProposal('for');
|
voteForProposal('for');
|
||||||
// 3001-VOTE-079
|
// 3001-VOTE-079
|
||||||
cy.contains('You voted: For').should('be.visible');
|
cy.contains('You voted: For').should('be.visible');
|
||||||
cy.getByTestId(numberOfVotesFor).should('have.text', '0.0M');
|
cy.getByTestId(proposalVoteProgressForTokens)
|
||||||
cy.getByTestId(votesForPercentage).should('have.text', '100%');
|
.contains('1')
|
||||||
cy.getByTestId(totalVotedNumber).should('have.text', '0.0M');
|
.and('be.visible');
|
||||||
cy.getByTestId(totalVotedPercentage).should('have.text', '(0.00%)');
|
cy.getByTestId(voteBreakdownToggle).click();
|
||||||
ethereumWalletConnect();
|
getProposalInformationFromTable('Total Supply')
|
||||||
stakingPageAssociateTokens('1000000', { approve: true });
|
.invoke('text')
|
||||||
navigateTo(navigation.proposals);
|
.then((totalSupply) => {
|
||||||
cy.get<testFreeformProposal>('@rawProposal').then((rawProposal) => {
|
const tokensRequiredToAchieveResult = (
|
||||||
getProposalFromTitle(rawProposal.rationale.title).within(() =>
|
(Number(totalSupply.replace(/,/g, '')) * 0.001) /
|
||||||
cy.getByTestId(viewProposalButton).click()
|
100
|
||||||
);
|
).toFixed(2);
|
||||||
});
|
ethereumWalletConnect();
|
||||||
cy.getByTestId(votesForPercentage).should('have.text', '100%');
|
ensureSpecifiedUnstakedTokensAreAssociated(
|
||||||
cy.getByTestId(numberOfVotesFor).should('have.text', '0.0M');
|
tokensRequiredToAchieveResult
|
||||||
cy.getByTestId(totalVotedNumber).should('have.text', '0.0M');
|
);
|
||||||
cy.getByTestId(totalVotedPercentage).should('have.text', '(0.00%)');
|
navigateTo(navigation.proposals);
|
||||||
// 3001-VOTE-065
|
cy.get<testFreeformProposal>('@rawProposal').then((rawProposal) => {
|
||||||
cy.getByTestId(changeVoteButton).should('be.visible').click();
|
getProposalFromTitle(rawProposal.rationale.title).within(() =>
|
||||||
voteForProposal('for');
|
cy.getByTestId(viewProposalButton).click()
|
||||||
cy.getByTestId(numberOfVotesFor).should('have.text', '1.0M');
|
);
|
||||||
cy.getByTestId(totalVotedNumber).should('have.text', '1.0M');
|
});
|
||||||
cy.getByTestId(totalVotedPercentage).should('have.text', '(1.54%)');
|
cy.getByTestId(proposalVoteProgressForPercentage)
|
||||||
|
.contains('100.00%')
|
||||||
|
.and('be.visible');
|
||||||
|
cy.getByTestId(proposalVoteProgressAgainstPercentage)
|
||||||
|
.contains('0.00%')
|
||||||
|
.and('be.visible');
|
||||||
|
// 3001-VOTE-065
|
||||||
|
cy.getByTestId(changeVoteButton).should('be.visible').click();
|
||||||
|
voteForProposal('for');
|
||||||
|
cy.getByTestId(proposalVoteProgressForTokens)
|
||||||
|
.contains(tokensRequiredToAchieveResult)
|
||||||
|
.and('be.visible');
|
||||||
|
cy.getByTestId(proposalVoteProgressAgainstTokens)
|
||||||
|
.contains('0.00')
|
||||||
|
.and('be.visible');
|
||||||
|
cy.getByTestId(voteBreakdownToggle).click();
|
||||||
|
getProposalInformationFromTable('Total tokens voted percentage')
|
||||||
|
.should('have.text', '0.00%')
|
||||||
|
.and('be.visible');
|
||||||
|
getProposalInformationFromTable('Tokens for proposal')
|
||||||
|
.should('have.text', tokensRequiredToAchieveResult)
|
||||||
|
.and('be.visible');
|
||||||
|
getProposalInformationFromTable('Tokens against proposal')
|
||||||
|
.should('have.text', '0.00')
|
||||||
|
.and('be.visible');
|
||||||
|
getProposalInformationFromTable('Number of voting parties')
|
||||||
|
.should('have.text', '1')
|
||||||
|
.and('be.visible');
|
||||||
|
getProposalInformationFromTable('Expected to pass')
|
||||||
|
.contains('👍')
|
||||||
|
.should('be.visible');
|
||||||
|
// 3001-VOTE-062
|
||||||
|
getProposalInformationFromTable('Token majority met')
|
||||||
|
.contains('👍')
|
||||||
|
.should('be.visible');
|
||||||
|
getProposalInformationFromTable('Token participation met')
|
||||||
|
.contains('👍')
|
||||||
|
.should('be.visible');
|
||||||
|
getProposalInformationFromTable('Tokens for proposal')
|
||||||
|
.contains(tokensRequiredToAchieveResult)
|
||||||
|
.and('be.visible');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Able to vote for proposal twice by switching public key', function () {
|
it('Able to vote for proposal twice by switching public key', function () {
|
||||||
@@ -288,6 +360,10 @@ describe(
|
|||||||
voteForProposal('against');
|
voteForProposal('against');
|
||||||
cy.contains('You voted: Against').should('be.visible');
|
cy.contains('You voted: Against').should('be.visible');
|
||||||
switchVegaWalletPubKey();
|
switchVegaWalletPubKey();
|
||||||
|
cy.getByTestId(proposalVoteProgressForTokens).should(
|
||||||
|
'contain.text',
|
||||||
|
'1.00'
|
||||||
|
);
|
||||||
// Checking vote status for different public keys is displayed correctly
|
// Checking vote status for different public keys is displayed correctly
|
||||||
cy.contains('You voted: For').should('be.visible');
|
cy.contains('You voted: For').should('be.visible');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,10 +22,12 @@ const proposalListItem = '[data-testid="proposals-list-item"]';
|
|||||||
const closedProposals = 'closed-proposals';
|
const closedProposals = 'closed-proposals';
|
||||||
const proposalStatus = 'proposal-status';
|
const proposalStatus = 'proposal-status';
|
||||||
const viewProposalButton = 'view-proposal-btn';
|
const viewProposalButton = 'view-proposal-btn';
|
||||||
const votesTable = 'user-vote';
|
const votesTable = 'votes-table';
|
||||||
const openProposals = 'open-proposals';
|
const openProposals = 'open-proposals';
|
||||||
const majorityVoteReached = 'token-majority-met';
|
const proposalVoteProgressForPercentage =
|
||||||
const minParticipationReached = 'token-participation-met';
|
'vote-progress-indicator-percentage-for';
|
||||||
|
const majorityVoteReached = 'majority-reached';
|
||||||
|
const minParticipationReached = 'participation-reached';
|
||||||
const proposalTimeout = { timeout: 8000 };
|
const proposalTimeout = { timeout: 8000 };
|
||||||
|
|
||||||
context(
|
context(
|
||||||
@@ -68,6 +70,7 @@ context(
|
|||||||
cy.getByTestId('proposal-type').should('have.text', 'New market');
|
cy.getByTestId('proposal-type').should('have.text', 'New market');
|
||||||
cy.getByTestId(proposalStatus).should('have.text', 'Enacted');
|
cy.getByTestId(proposalStatus).should('have.text', 'Enacted');
|
||||||
cy.getByTestId(votesTable).within(() => {
|
cy.getByTestId(votesTable).within(() => {
|
||||||
|
cy.contains('Vote passed.').should('be.visible');
|
||||||
cy.contains('Voting has ended.').should('be.visible');
|
cy.contains('Voting has ended.').should('be.visible');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -89,7 +92,7 @@ context(
|
|||||||
// 3001-VOTE-019 time to vote is highlighted red
|
// 3001-VOTE-019 time to vote is highlighted red
|
||||||
cy.getByTestId('vote-details')
|
cy.getByTestId('vote-details')
|
||||||
.find('span')
|
.find('span')
|
||||||
.should('have.class', 'text-vega-orange');
|
.should('have.class', 'text-vega-pink');
|
||||||
cy.getByTestId(viewProposalButton).click();
|
cy.getByTestId(viewProposalButton).click();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -106,9 +109,12 @@ context(
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
cy.getByTestId(votesTable).within(() => {
|
cy.getByTestId(votesTable).within(() => {
|
||||||
|
cy.contains('Vote passed.').should('be.visible');
|
||||||
cy.contains('Voting has ended.').should('be.visible');
|
cy.contains('Voting has ended.').should('be.visible');
|
||||||
});
|
});
|
||||||
cy.getByTestId('votes-for-percentage').should('have.text', '100%');
|
cy.getByTestId(proposalVoteProgressForPercentage)
|
||||||
|
.contains('100.00%')
|
||||||
|
.and('be.visible');
|
||||||
navigateTo(navigation.proposals);
|
navigateTo(navigation.proposals);
|
||||||
cy.contains(proposalTitle)
|
cy.contains(proposalTitle)
|
||||||
.parentsUntil(proposalListItem)
|
.parentsUntil(proposalListItem)
|
||||||
|
|||||||
@@ -298,6 +298,9 @@ context(
|
|||||||
getProposalFromTitle(proposalTitle).within(() =>
|
getProposalFromTitle(proposalTitle).within(() =>
|
||||||
cy.getByTestId(viewProposalButton).click()
|
cy.getByTestId(viewProposalButton).click()
|
||||||
);
|
);
|
||||||
|
cy.contains('Vote breakdown').should('be.visible', {
|
||||||
|
timeout: 10000,
|
||||||
|
});
|
||||||
cy.getByTestId(voteButtons).should('not.exist');
|
cy.getByTestId(voteButtons).should('not.exist');
|
||||||
cy.getByTestId('min-proposal-requirements').should(
|
cy.getByTestId('min-proposal-requirements').should(
|
||||||
'have.text',
|
'have.text',
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ const enactmentDeadlineError = 'enactment-before-voting-deadline';
|
|||||||
const proposalDownloadBtn = 'proposal-download-json';
|
const proposalDownloadBtn = 'proposal-download-json';
|
||||||
const feedbackError = '[data-testid="Error"]';
|
const feedbackError = '[data-testid="Error"]';
|
||||||
const viewProposalBtn = 'view-proposal-btn';
|
const viewProposalBtn = 'view-proposal-btn';
|
||||||
|
const liquidityVoteStatus = 'liquidity-votes-status';
|
||||||
|
const tokenVoteStatus = 'token-votes-status';
|
||||||
const proposalJsonToggle = 'proposal-json-toggle';
|
const proposalJsonToggle = 'proposal-json-toggle';
|
||||||
const proposalJsonSection = 'proposal-json';
|
const proposalJsonSection = 'proposal-json';
|
||||||
const vegaWalletPublicKey = Cypress.env('vegaWalletPublicKey');
|
const vegaWalletPublicKey = Cypress.env('vegaWalletPublicKey');
|
||||||
@@ -419,28 +421,27 @@ context(
|
|||||||
cy.getByTestId(viewProposalBtn).click();
|
cy.getByTestId(viewProposalBtn).click();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
cy.getByTestId('lp-majority-not-met').should(
|
cy.getByTestId(liquidityVoteStatus).should(
|
||||||
'have.text',
|
'contain.text',
|
||||||
'66% majority threshold not met'
|
'Currently expected to fail'
|
||||||
);
|
);
|
||||||
|
cy.getByTestId(tokenVoteStatus).should(
|
||||||
cy.getByTestId('token-majority-not-met').should(
|
'contain.text',
|
||||||
'have.text',
|
'Currently expected to fail'
|
||||||
'66% majority threshold not met'
|
|
||||||
);
|
);
|
||||||
voteForProposal('for');
|
voteForProposal('for');
|
||||||
cy.getByTestId('lp-majority-met').should(
|
cy.getByTestId(liquidityVoteStatus).should(
|
||||||
'have.text',
|
'contain.text',
|
||||||
'66% majority threshold met'
|
'Currently expected to pass'
|
||||||
);
|
);
|
||||||
cy.getByTestId('token-majority-met').should(
|
cy.getByTestId(tokenVoteStatus).should(
|
||||||
'have.text',
|
'contain.text',
|
||||||
'66% majority threshold met'
|
'Currently expected to pass'
|
||||||
);
|
|
||||||
cy.getByTestId('vote-status').should(
|
|
||||||
'have.text',
|
|
||||||
'Currently expected to pass by token vote'
|
|
||||||
);
|
);
|
||||||
|
cy.getByTestId('vote-breakdown-toggle').click();
|
||||||
|
getProposalInformationFromTable('Expected to pass')
|
||||||
|
.contains('👍 by token vote')
|
||||||
|
.should('be.visible');
|
||||||
});
|
});
|
||||||
|
|
||||||
// 3001-VOTE-026 3001-VOTE-027 3001-VOTE-028 3001-VOTE-095 3001-VOTE-096 3005-PASN-001
|
// 3001-VOTE-026 3001-VOTE-027 3001-VOTE-028 3001-VOTE-095 3001-VOTE-096 3005-PASN-001
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
enterRawProposalBody,
|
enterRawProposalBody,
|
||||||
generateFreeFormProposalTitle,
|
generateFreeFormProposalTitle,
|
||||||
getProposalFromTitle,
|
getProposalFromTitle,
|
||||||
|
getProposalInformationFromTable,
|
||||||
goToMakeNewProposal,
|
goToMakeNewProposal,
|
||||||
governanceProposalType,
|
governanceProposalType,
|
||||||
submitUniqueRawProposal,
|
submitUniqueRawProposal,
|
||||||
@@ -29,9 +30,7 @@ const proposalType = 'proposal-type';
|
|||||||
const proposalStatus = 'proposal-status';
|
const proposalStatus = 'proposal-status';
|
||||||
const proposalClosingDate = 'vote-details';
|
const proposalClosingDate = 'vote-details';
|
||||||
const viewProposalButton = 'view-proposal-btn';
|
const viewProposalButton = 'view-proposal-btn';
|
||||||
const voteMajorityNotMet = 'token-majority-not-met';
|
const voteBreakDownToggle = 'vote-breakdown-toggle';
|
||||||
const voteMajorityMet = 'token-majority-met';
|
|
||||||
const votesForPercentage = 'votes-for-percentage';
|
|
||||||
|
|
||||||
describe('Governance flow for proposal list', { tags: '@slow' }, function () {
|
describe('Governance flow for proposal list', { tags: '@slow' }, function () {
|
||||||
before('connect wallets and set approval limit', function () {
|
before('connect wallets and set approval limit', function () {
|
||||||
@@ -122,15 +121,10 @@ describe('Governance flow for proposal list', { tags: '@slow' }, function () {
|
|||||||
submitUniqueRawProposal({ proposalTitle: proposalTitle });
|
submitUniqueRawProposal({ proposalTitle: proposalTitle });
|
||||||
getProposalFromTitle(proposalTitle).within(() => {
|
getProposalFromTitle(proposalTitle).within(() => {
|
||||||
// 3001-VOTE-039
|
// 3001-VOTE-039
|
||||||
cy.getByTestId(voteMajorityNotMet).should(
|
cy.getByTestId('participation-not-reached').should(
|
||||||
'have.text',
|
'have.text',
|
||||||
'66% majority threshold not met'
|
'Min. participation not reached'
|
||||||
);
|
);
|
||||||
cy.getByTestId('token-participation-not-met').should(
|
|
||||||
'have.text',
|
|
||||||
'0.000000000000000000000015% participation threshold not met'
|
|
||||||
);
|
|
||||||
cy.getByTestId(votesForPercentage).should('have.text', '0%');
|
|
||||||
cy.getByTestId(viewProposalButton).click();
|
cy.getByTestId(viewProposalButton).click();
|
||||||
});
|
});
|
||||||
voteForProposal('for');
|
voteForProposal('for');
|
||||||
@@ -140,15 +134,16 @@ describe('Governance flow for proposal list', { tags: '@slow' }, function () {
|
|||||||
'have.text',
|
'have.text',
|
||||||
'Currently expected to pass'
|
'Currently expected to pass'
|
||||||
);
|
);
|
||||||
cy.getByTestId(voteMajorityMet).should(
|
cy.getByTestId('user-voted-yes').should('exist');
|
||||||
|
cy.getByTestId('participation-reached').should(
|
||||||
'have.text',
|
'have.text',
|
||||||
'66% majority threshold met'
|
'Min. participation reached'
|
||||||
);
|
|
||||||
cy.getByTestId(votesForPercentage).should('have.text', '100%');
|
|
||||||
cy.getByTestId('token-participation-met').should(
|
|
||||||
'have.text',
|
|
||||||
'0.000000000000000000000015% participation threshold met'
|
|
||||||
);
|
);
|
||||||
|
cy.getByTestId(viewProposalButton).click();
|
||||||
});
|
});
|
||||||
|
cy.getByTestId(voteBreakDownToggle).click();
|
||||||
|
getProposalInformationFromTable('Token participation met')
|
||||||
|
.contains('👍')
|
||||||
|
.should('be.visible');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ context(
|
|||||||
closeStakingDialog();
|
closeStakingDialog();
|
||||||
navigateTo(navigation.validators);
|
navigateTo(navigation.validators);
|
||||||
cy.get(`[row-id="${0}"]`)
|
cy.get(`[row-id="${0}"]`)
|
||||||
.first()
|
.eq(1)
|
||||||
.within(() => {
|
.within(() => {
|
||||||
cy.getByTestId(stakeValidatorListTotalStake)
|
cy.getByTestId(stakeValidatorListTotalStake)
|
||||||
.should('have.text', '3,002.00')
|
.should('have.text', '3,002.00')
|
||||||
@@ -222,7 +222,7 @@ context(
|
|||||||
.and('be.visible');
|
.and('be.visible');
|
||||||
});
|
});
|
||||||
cy.get(`[row-id="${1}"]`)
|
cy.get(`[row-id="${1}"]`)
|
||||||
.first()
|
.eq(1)
|
||||||
.within(() => {
|
.within(() => {
|
||||||
cy.getByTestId(stakeValidatorListTotalStake)
|
cy.getByTestId(stakeValidatorListTotalStake)
|
||||||
.scrollIntoView()
|
.scrollIntoView()
|
||||||
@@ -262,10 +262,10 @@ context(
|
|||||||
'2'
|
'2'
|
||||||
);
|
);
|
||||||
waitForBeginningOfEpoch();
|
waitForBeginningOfEpoch();
|
||||||
cy.getByTestId(
|
cy.getByTestId(stakeValidatorListStakePercentage).should(
|
||||||
stakeValidatorListStakePercentage,
|
'have.text',
|
||||||
epochTimeout
|
'50.02%'
|
||||||
).should('have.text', '50.02%');
|
);
|
||||||
navigateTo(navigation.validators);
|
navigateTo(navigation.validators);
|
||||||
validateValidatorListTotalStakeAndShare('0', '3,002.00', '50.02%');
|
validateValidatorListTotalStakeAndShare('0', '3,002.00', '50.02%');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ const proposalDocumentationLink = 'proposal-documentation-link';
|
|||||||
const connectToVegaWalletButton = 'connect-to-vega-wallet-btn';
|
const connectToVegaWalletButton = 'connect-to-vega-wallet-btn';
|
||||||
const governanceDocsUrl = 'https://vega.xyz/governance';
|
const governanceDocsUrl = 'https://vega.xyz/governance';
|
||||||
const networkUpgradeProposalListItem = 'protocol-upgrade-proposals-list-item';
|
const networkUpgradeProposalListItem = 'protocol-upgrade-proposals-list-item';
|
||||||
const proposalUpgradeBlockHeight = 'protocol-upgrade-proposal-block-height';
|
|
||||||
const closedProposals = 'closed-proposals';
|
const closedProposals = 'closed-proposals';
|
||||||
const closedProposalToggle = 'closed-proposals-toggle-networkUpgrades';
|
const closedProposalToggle = 'closed-proposals-toggle-networkUpgrades';
|
||||||
const protocolUpgradeTime = 'protocol-upgrade-time';
|
const protocolUpgradeTime = 'protocol-upgrade-time';
|
||||||
@@ -38,39 +37,11 @@ context(
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 3002-PROP-023 3004-PMAC-002 3005-PASN-002 3006-PASC-002 3007-PNEC-002 3008-PFRO-003
|
// 3002-PROP-023 3004-PMAC-002 3005-PASN-002 3006-PASC-002 3007-PNEC-002 3008-PFRO-003
|
||||||
it('new proposal page should have button for link to more information on proposals', function () {
|
it('should have button for link to more information on proposals', function () {
|
||||||
cy.getByTestId('new-proposal-link').click();
|
const proposalsUrl = 'https://docs.vega.xyz/mainnet/tutorials/proposals';
|
||||||
cy.url().should('include', '/proposals/propose/raw');
|
cy.getByTestId('new-proposal-link')
|
||||||
cy.contains('To see Explorer data on proposals visit').within(() => {
|
.find('a')
|
||||||
cy.getByTestId('external-link').should(
|
.should('have.attr', 'href', proposalsUrl);
|
||||||
'have.attr',
|
|
||||||
'href',
|
|
||||||
'https://explorer.fairground.wtf/governance'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
cy.contains(
|
|
||||||
'1. Sense check your proposal with the community on the forum:'
|
|
||||||
).within(() => {
|
|
||||||
cy.getByTestId('external-link').should(
|
|
||||||
'have.attr',
|
|
||||||
'href',
|
|
||||||
'https://community.vega.xyz/c/governance/25'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
cy.contains(
|
|
||||||
'2. Use the appropriate proposal template in the docs:'
|
|
||||||
).within(() => {
|
|
||||||
cy.getByTestId('external-link').should(
|
|
||||||
'have.attr',
|
|
||||||
'href',
|
|
||||||
'https://docs.vega.xyz/mainnet/tutorials/proposals'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
cy.contains('Connect your wallet to submit a proposal').should(
|
|
||||||
'be.visible'
|
|
||||||
);
|
|
||||||
cy.getByTestId('connect-to-vega-wallet-btn').should('exist');
|
|
||||||
navigateTo(navigation.proposals);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to see a working link for - find out more about Vega governance', function () {
|
it('should be able to see a working link for - find out more about Vega governance', function () {
|
||||||
@@ -185,7 +156,7 @@ context(
|
|||||||
'have.text',
|
'have.text',
|
||||||
'Vega release tag: v1'
|
'Vega release tag: v1'
|
||||||
);
|
);
|
||||||
cy.getByTestId(proposalUpgradeBlockHeight).should(
|
cy.getByTestId('protocol-upgrade-proposal-block-height').should(
|
||||||
'have.text',
|
'have.text',
|
||||||
'Upgrade block height: 2015942'
|
'Upgrade block height: 2015942'
|
||||||
);
|
);
|
||||||
@@ -200,15 +171,7 @@ context(
|
|||||||
});
|
});
|
||||||
cy.getByTestId(closedProposalToggle).click();
|
cy.getByTestId(closedProposalToggle).click();
|
||||||
cy.getByTestId(closedProposals).within(() => {
|
cy.getByTestId(closedProposals).within(() => {
|
||||||
cy.getByTestId(networkUpgradeProposalListItem).should('have.length', 2);
|
cy.getByTestId(networkUpgradeProposalListItem).should('have.length', 1);
|
||||||
cy.getByTestId(networkUpgradeProposalListItem)
|
|
||||||
.first()
|
|
||||||
.within(() => {
|
|
||||||
cy.getByTestId(proposalUpgradeBlockHeight).should(
|
|
||||||
'contain.text',
|
|
||||||
'10001'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -220,7 +183,7 @@ context(
|
|||||||
.first()
|
.first()
|
||||||
.find('[data-testid="view-proposal-btn"]')
|
.find('[data-testid="view-proposal-btn"]')
|
||||||
.click();
|
.click();
|
||||||
cy.url().should('contain', '/protocol-upgrades/v1/2015942');
|
cy.url().should('contain', '/protocol-upgrades/v1');
|
||||||
cy.getByTestId('protocol-upgrade-proposal').within(() => {
|
cy.getByTestId('protocol-upgrade-proposal').within(() => {
|
||||||
cy.get('h1').should('have.text', 'Vega Release v1');
|
cy.get('h1').should('have.text', 'Vega Release v1');
|
||||||
cy.getByTestId('protocol-upgrade-block-height').should(
|
cy.getByTestId('protocol-upgrade-block-height').should(
|
||||||
@@ -280,7 +243,7 @@ context(
|
|||||||
);
|
);
|
||||||
cy.getByTestId('external-link')
|
cy.getByTestId('external-link')
|
||||||
.should('have.attr', 'href')
|
.should('have.attr', 'href')
|
||||||
.and('contain', '/proposals/protocol-upgrade/v1/2015942');
|
.and('contain', '/proposals/protocol-upgrade/v1');
|
||||||
});
|
});
|
||||||
|
|
||||||
// estimate does not display possibly due to mocks or Cypress unless the proposal is clicked on several times
|
// estimate does not display possibly due to mocks or Cypress unless the proposal is clicked on several times
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ export function getProposalInformationFromTable(heading: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function voteForProposal(vote: string) {
|
export function voteForProposal(vote: string) {
|
||||||
cy.get(voteButtons).should('be.visible', { timeout: 10000 });
|
cy.contains('Vote breakdown').should('be.visible', { timeout: 10000 });
|
||||||
cy.get(voteButtons).contains(vote).click();
|
cy.get(voteButtons).contains(vote).click();
|
||||||
cy.get(dialogTitle, proposalTimeout).should(
|
cy.get(dialogTitle, proposalTimeout).should(
|
||||||
'have.text',
|
'have.text',
|
||||||
|
|||||||
@@ -170,20 +170,21 @@ export function clickOnValidatorFromList(
|
|||||||
validatorName = null
|
validatorName = null
|
||||||
) {
|
) {
|
||||||
cy.contains('Loading...', epochTimeout).should('not.exist');
|
cy.contains('Loading...', epochTimeout).should('not.exist');
|
||||||
|
waitForBeginningOfEpoch();
|
||||||
// below is to ensure validator list is shown
|
// below is to ensure validator list is shown
|
||||||
cy.get(stakeValidatorListName, { timeout: 10000 }).should('exist');
|
cy.get(stakeValidatorListName, { timeout: 10000 }).should('exist');
|
||||||
cy.get(stakeValidatorListPendingStake, txTimeout).should(
|
cy.get(stakeValidatorListPendingStake, txTimeout).should(
|
||||||
'not.contain',
|
'not.contain',
|
||||||
'2,000,000,000,000,000,000.00' // number due to bug #936
|
'2,000,000,000,000,000,000.00' // number due to bug #936
|
||||||
);
|
);
|
||||||
waitForBeginningOfEpoch();
|
|
||||||
if (validatorName) {
|
if (validatorName) {
|
||||||
cy.contains(validatorName).click();
|
cy.contains(validatorName).click();
|
||||||
} else {
|
} else {
|
||||||
cy.get(`[row-id="${validatorNumber}"]`)
|
cy.get(`[row-id="${validatorNumber}"]`)
|
||||||
.should('be.visible')
|
.should('be.visible')
|
||||||
.first()
|
.first()
|
||||||
.click();
|
.as('validatorOnList');
|
||||||
|
cy.get('@validatorOnList').click();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,7 +196,7 @@ export function validateValidatorListTotalStakeAndShare(
|
|||||||
cy.contains('Loading...', epochTimeout).should('not.exist');
|
cy.contains('Loading...', epochTimeout).should('not.exist');
|
||||||
waitForBeginningOfEpoch();
|
waitForBeginningOfEpoch();
|
||||||
cy.get(`[row-id="${positionOnList}"]`)
|
cy.get(`[row-id="${positionOnList}"]`)
|
||||||
.first()
|
.eq(1)
|
||||||
.within(() => {
|
.within(() => {
|
||||||
cy.getByTestId(stakeValidatorListTotalStake, epochTimeout).should(
|
cy.getByTestId(stakeValidatorListTotalStake, epochTimeout).should(
|
||||||
'have.text',
|
'have.text',
|
||||||
@@ -218,9 +219,7 @@ export function ensureSpecifiedUnstakedTokensAreAssociated(
|
|||||||
.eq(1)
|
.eq(1)
|
||||||
.invoke('text')
|
.invoke('text')
|
||||||
.then((unstakedBalance) => {
|
.then((unstakedBalance) => {
|
||||||
const tokenFloat = parseFloat(tokenAmount);
|
if (parseFloat(unstakedBalance) != parseFloat(tokenAmount)) {
|
||||||
const unstakedFloat = parseFloat(unstakedBalance.replace(/,/g, ''));
|
|
||||||
if (tokenFloat != unstakedFloat) {
|
|
||||||
vegaWalletTeardown();
|
vegaWalletTeardown();
|
||||||
cy.get(vegaWalletAssociatedBalance, txTimeout).contains(
|
cy.get(vegaWalletAssociatedBalance, txTimeout).contains(
|
||||||
'0.00',
|
'0.00',
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ NX_FAIRGROUND=false
|
|||||||
NX_VEGA_NETWORKS='{"DEVNET":"https://dev.governance.vega.xyz","STAGNET1":"https://governance.stagnet1.vega.rocks","TESTNET":"https://governance.fairground.wtf","MAINNET":"https://governance.vega.xyz"}'
|
NX_VEGA_NETWORKS='{"DEVNET":"https://dev.governance.vega.xyz","STAGNET1":"https://governance.stagnet1.vega.rocks","TESTNET":"https://governance.fairground.wtf","MAINNET":"https://governance.vega.xyz"}'
|
||||||
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
|
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
|
||||||
NX_VEGA_WALLET_URL=http://localhost:1789
|
NX_VEGA_WALLET_URL=http://localhost:1789
|
||||||
NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72
|
|
||||||
NX_VEGA_EXPLORER_URL=https://explorer.stagnet1.vega.rocks
|
NX_VEGA_EXPLORER_URL=https://explorer.stagnet1.vega.rocks
|
||||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
||||||
|
|
||||||
@@ -24,7 +23,7 @@ NX_TENDERMINT_URL=https://tm.n01.stagnet1.vega.rocks
|
|||||||
NX_TENDERMINT_WEBSOCKET_URL=wss://tm.n01.stagnet1.vega.xyz/websocket
|
NX_TENDERMINT_WEBSOCKET_URL=wss://tm.n01.stagnet1.vega.xyz/websocket
|
||||||
|
|
||||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-fairground
|
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/pl/firefox/addon/vega-wallet
|
||||||
|
|
||||||
#Test configuration variables
|
#Test configuration variables
|
||||||
CYPRESS_FAIRGROUND=false
|
CYPRESS_FAIRGROUND=false
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ NX_TRANCHES_SERVICE_URL=https://tranches-stagnet1-k8s.ops.vega.xyz
|
|||||||
NX_VEGA_REST_URL=http://localhost:3008/api/v2/
|
NX_VEGA_REST_URL=http://localhost:3008/api/v2/
|
||||||
|
|
||||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-fairground
|
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/pl/firefox/addon/vega-wallet
|
||||||
|
|
||||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
|
||||||
|
|
||||||
NX_TENDERMINT_URL=http://localhost:26617
|
NX_TENDERMINT_URL=http://localhost:26617
|
||||||
NX_TENDERMINT_WEBSOCKET_URL=wss://localhost:26617/websocket
|
NX_TENDERMINT_WEBSOCKET_URL=wss://localhost:26617/websocket
|
||||||
|
|||||||
@@ -15,12 +15,10 @@ NX_VEGA_REST_URL=https://api.n00.devnet1.vega.xyz/api/v2/
|
|||||||
NX_SENTRY_DSN=https://4b8c8a8ba07742648aa4dfe1b8d17e40@o286262.ingest.sentry.io/5882996
|
NX_SENTRY_DSN=https://4b8c8a8ba07742648aa4dfe1b8d17e40@o286262.ingest.sentry.io/5882996
|
||||||
|
|
||||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-fairground
|
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/pl/firefox/addon/vega-wallet
|
||||||
|
|
||||||
NX_TENDERMINT_URL=https://tm.be.devnet1.vega.xyz/
|
NX_TENDERMINT_URL=https://tm.be.devnet1.vega.xyz/
|
||||||
NX_TENDERMINT_WEBSOCKET_URL=wss://be.devnet1.vega.xyz/websocket
|
NX_TENDERMINT_WEBSOCKET_URL=wss://be.devnet1.vega.xyz/websocket
|
||||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
|
||||||
|
|
||||||
|
|
||||||
# Cosmic elevator flags
|
# Cosmic elevator flags
|
||||||
NX_SUCCESSOR_MARKETS=true
|
NX_SUCCESSOR_MARKETS=true
|
||||||
|
|||||||
@@ -15,9 +15,8 @@ NX_TRANCHES_SERVICE_URL=https://tranches-mainnet-k8s.ops.vega.xyz
|
|||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/mainnet/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/mainnet/announcements.json
|
||||||
NX_VEGA_REST_URL=https://api.vega.community/api/v2/
|
NX_VEGA_REST_URL=https://api.vega.community/api/v2/
|
||||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-mainnet
|
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/pl/firefox/addon/vega-wallet
|
||||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
|
||||||
NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72
|
|
||||||
NX_TENDERMINT_URL=https://be.vega.community
|
NX_TENDERMINT_URL=https://be.vega.community
|
||||||
NX_TENDERMINT_WEBSOCKET_URL=wss://be.vega.community/websocket
|
NX_TENDERMINT_WEBSOCKET_URL=wss://be.vega.community/websocket
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ NX_TRANCHES_SERVICE_URL=https://tranches-mainnet-mirror-k8s.ops.vega.xyz
|
|||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/mainnet/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/mainnet/announcements.json
|
||||||
NX_VEGA_REST_URL=https://api.mainnet-mirror.vega.rocks/api/v2/
|
NX_VEGA_REST_URL=https://api.mainnet-mirror.vega.rocks/api/v2/
|
||||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-mainnet
|
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/pl/firefox/addon/vega-wallet
|
||||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
|
||||||
|
|
||||||
NX_TENDERMINT_URL=https://be.mainnet-mirror.vega.rocks
|
NX_TENDERMINT_URL=https://be.mainnet-mirror.vega.rocks
|
||||||
NX_TENDERMINT_WEBSOCKET_URL=wss://be.mainnet-mirror.vega.rocks/websocket
|
NX_TENDERMINT_WEBSOCKET_URL=wss://be.mainnet-mirror.vega.rocks/websocket
|
||||||
|
|||||||
@@ -9,11 +9,9 @@ NX_DELEGATIONS_PAGINATION=50
|
|||||||
NX_TRANCHES_SERVICE_URL=https://tranches-stagnet1-k8s.ops.vega.xyz
|
NX_TRANCHES_SERVICE_URL=https://tranches-stagnet1-k8s.ops.vega.xyz
|
||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
||||||
NX_VEGA_REST_URL=https://api.n00.stagnet1.vega.xyz/api/v2/
|
NX_VEGA_REST_URL=https://api.n00.stagnet1.vega.xyz/api/v2/
|
||||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
|
||||||
NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72
|
|
||||||
|
|
||||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-fairground
|
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/pl/firefox/addon/vega-wallet
|
||||||
|
|
||||||
NX_TENDERMINT_URL=https://tm.n01.stagnet1.vega.rocks
|
NX_TENDERMINT_URL=https://tm.n01.stagnet1.vega.rocks
|
||||||
NX_TENDERMINT_WEBSOCKET_URL=wss://tm.n01.stagnet1.vega.xyz/websocket
|
NX_TENDERMINT_WEBSOCKET_URL=wss://tm.n01.stagnet1.vega.xyz/websocket
|
||||||
|
|||||||
@@ -14,11 +14,9 @@ NX_TRANCHES_SERVICE_URL=https://tranches-testnet-k8s.ops.vega.xyz
|
|||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
||||||
NX_VEGA_REST_URL=https://api.n07.testnet.vega.xyz/api/v2/
|
NX_VEGA_REST_URL=https://api.n07.testnet.vega.xyz/api/v2/
|
||||||
NX_SENTRY_DSN=https://4b8c8a8ba07742648aa4dfe1b8d17e40@o286262.ingest.sentry.io/5882996
|
NX_SENTRY_DSN=https://4b8c8a8ba07742648aa4dfe1b8d17e40@o286262.ingest.sentry.io/5882996
|
||||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
|
||||||
NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72
|
|
||||||
|
|
||||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-fairground
|
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/pl/firefox/addon/vega-wallet
|
||||||
|
|
||||||
NX_TENDERMINT_URL=https://tm.be.testnet.vega.xyz
|
NX_TENDERMINT_URL=https://tm.be.testnet.vega.xyz
|
||||||
NX_TENDERMINT_WEBSOCKET_URL=wss://be.testnet.vega.xyz/websocket
|
NX_TENDERMINT_WEBSOCKET_URL=wss://be.testnet.vega.xyz/websocket
|
||||||
|
|||||||
@@ -11,10 +11,9 @@ NX_VEGA_EXPLORER_URL=https://explorer.validators-testnet.vega.rocks/
|
|||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
||||||
NX_VEGA_REST_URL=https://api-validators-testnet.vega.rocks/api/v2/
|
NX_VEGA_REST_URL=https://api-validators-testnet.vega.rocks/api/v2/
|
||||||
NX_SENTRY_DSN=https://4b8c8a8ba07742648aa4dfe1b8d17e40@o286262.ingest.sentry.io/5882996
|
NX_SENTRY_DSN=https://4b8c8a8ba07742648aa4dfe1b8d17e40@o286262.ingest.sentry.io/5882996
|
||||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
|
||||||
|
|
||||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-fairground
|
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/pl/firefox/addon/vega-wallet
|
||||||
|
|
||||||
NX_TENDERMINT_URL=https://tm.be.validators-testnet.vega.rocks
|
NX_TENDERMINT_URL=https://tm.be.validators-testnet.vega.rocks
|
||||||
NX_TENDERMINT_WEBSOCKET_URL=wss://be.validators-testnet.vega.
|
NX_TENDERMINT_WEBSOCKET_URL=wss://be.validators-testnet.vega.
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ const Web3Container = ({
|
|||||||
<TemplateSidebar sidebar={sideBar}>
|
<TemplateSidebar sidebar={sideBar}>
|
||||||
<AppRouter />
|
<AppRouter />
|
||||||
</TemplateSidebar>
|
</TemplateSidebar>
|
||||||
<footer className="p-4 border-t border-neutral-700 break-all">
|
<footer className="p-4 border-t border-neutral-700">
|
||||||
<NetworkInfo />
|
<NetworkInfo />
|
||||||
</footer>
|
</footer>
|
||||||
</AppLayout>
|
</AppLayout>
|
||||||
@@ -308,7 +308,7 @@ const AppContainer = () => {
|
|||||||
<Router>
|
<Router>
|
||||||
<ScrollToTop />
|
<ScrollToTop />
|
||||||
<AppStateProvider>
|
<AppStateProvider>
|
||||||
<div className="min-h-full text-white">
|
<div className="min-h-full text-white grid">
|
||||||
<NodeGuard
|
<NodeGuard
|
||||||
skeleton={<div>{t('Loading')}</div>}
|
skeleton={<div>{t('Loading')}</div>}
|
||||||
failure={
|
failure={
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export const WalletCardRow = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const ref = React.useRef<HTMLDivElement | null>(null);
|
const ref = React.useRef<HTMLDivElement | null>(null);
|
||||||
useAnimateValue(ref, value);
|
useAnimateValue(ref, value);
|
||||||
const [integers, decimalsPlaces, separator] = useNumberParts(value, decimals);
|
const [integers, decimalsPlaces] = useNumberParts(value, decimals);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -75,10 +75,7 @@ export const WalletCardRow = ({
|
|||||||
className="font-mono flex-1 text-right"
|
className="font-mono flex-1 text-right"
|
||||||
data-testid="associated-amount"
|
data-testid="associated-amount"
|
||||||
>
|
>
|
||||||
<span>
|
<span>{integers}.</span>
|
||||||
{integers}
|
|
||||||
{separator}
|
|
||||||
</span>
|
|
||||||
<span>{decimalsPlaces}</span>
|
<span>{decimalsPlaces}</span>
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
@@ -113,10 +110,7 @@ export const WalletCardAsset = ({
|
|||||||
border,
|
border,
|
||||||
subheading,
|
subheading,
|
||||||
}: WalletCardAssetProps) => {
|
}: WalletCardAssetProps) => {
|
||||||
const [integers, decimalsPlaces, separator] = useNumberParts(
|
const [integers, decimalsPlaces] = useNumberParts(balance, decimals);
|
||||||
balance,
|
|
||||||
decimals
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-nowrap mt-2 mb-4">
|
<div className="flex flex-nowrap mt-2 mb-4">
|
||||||
@@ -138,10 +132,7 @@ export const WalletCardAsset = ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="px-2 basis-full font-mono" data-testid="currency-value">
|
<div className="px-2 basis-full font-mono" data-testid="currency-value">
|
||||||
<span>
|
<span>{integers}.</span>
|
||||||
{integers}
|
|
||||||
{separator}
|
|
||||||
</span>
|
|
||||||
<span className="text-neutral-400">{decimalsPlaces}</span>
|
<span className="text-neutral-400">{decimalsPlaces}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -201,8 +201,6 @@
|
|||||||
"STATE_WAITING_FOR_NODE_VOTE": "Waiting for node vote",
|
"STATE_WAITING_FOR_NODE_VOTE": "Waiting for node vote",
|
||||||
"UpdateNetworkParameter": "Network parameter",
|
"UpdateNetworkParameter": "Network parameter",
|
||||||
"NewFreeform": "Freeform",
|
"NewFreeform": "Freeform",
|
||||||
"setToPass": "Set to pass",
|
|
||||||
"setToFail": "Set to fail",
|
|
||||||
"tokenVotes": "Token votes",
|
"tokenVotes": "Token votes",
|
||||||
"liquidityVotes": "Liquidity votes",
|
"liquidityVotes": "Liquidity votes",
|
||||||
"castYourVote": "Cast your vote",
|
"castYourVote": "Cast your vote",
|
||||||
@@ -211,23 +209,13 @@
|
|||||||
"against": "Against",
|
"against": "Against",
|
||||||
"majorityRequired": "Majority Required",
|
"majorityRequired": "Majority Required",
|
||||||
"participation": "Participation",
|
"participation": "Participation",
|
||||||
"majorityThreshold": "majority threshold",
|
"met": "Met",
|
||||||
"participationThreshold": "participation threshold",
|
"notMet": "Not Met",
|
||||||
"met": "met",
|
|
||||||
"notMet": "not met",
|
|
||||||
"governanceRequired": "Required",
|
"governanceRequired": "Required",
|
||||||
"daysLeft": "{{daysLeft}} left to vote.",
|
"daysLeft": "{{daysLeft}} left to vote.",
|
||||||
"toVote": "to vote",
|
"toVote": "to vote",
|
||||||
"voteFor": "Vote for",
|
"voteFor": "Vote for",
|
||||||
"voteAgainst": "Vote against",
|
"voteAgainst": "Vote against",
|
||||||
"tokenVote": "Token vote",
|
|
||||||
"tokenVotesFor": "Token votes for",
|
|
||||||
"tokenVotesAgainst": "Token votes against",
|
|
||||||
"totalTokensVoted": "Total tokens voted",
|
|
||||||
"liquidityProviderVote": "Liquidity provider vote",
|
|
||||||
"liquidityProviderVotesFor": "LP votes for",
|
|
||||||
"liquidityProviderVotesAgainst": "LP votes against",
|
|
||||||
"totalLiquidityProviderTokensVoted": "Total LP tokens voted",
|
|
||||||
"votingThresholdInfo": "If the token vote passes the participation threshold it will be the deciding vote. If not, the outcome will be determined by liquidity providers on this market.",
|
"votingThresholdInfo": "If the token vote passes the participation threshold it will be the deciding vote. If not, the outcome will be determined by liquidity providers on this market.",
|
||||||
"noGovernanceTokens": "You need some VEGA tokens to participate in governance",
|
"noGovernanceTokens": "You need some VEGA tokens to participate in governance",
|
||||||
"youVoted": "You voted",
|
"youVoted": "You voted",
|
||||||
@@ -474,7 +462,7 @@
|
|||||||
"rewardsColLiquidityProvisionHeader": "LIQUIDITY PROVISION",
|
"rewardsColLiquidityProvisionHeader": "LIQUIDITY PROVISION",
|
||||||
"rewardsColLiquidityProvisionTooltip": "Liquidity provision rewards are distributed based on how much you have earned in liquidity fees, funded by a liquidity reward pool for that market",
|
"rewardsColLiquidityProvisionTooltip": "Liquidity provision rewards are distributed based on how much you have earned in liquidity fees, funded by a liquidity reward pool for that market",
|
||||||
"rewardsColMarketCreationHeader": "MARKET CREATION",
|
"rewardsColMarketCreationHeader": "MARKET CREATION",
|
||||||
"rewardsColMarketCreationTooltip": "Market creation rewards are paid out to the creator of any market that exceeds a set threshold of cumulative volume in a given epoch, currently {{marketCreationQuantumMultiple}}",
|
"rewardsColMarketCreationTooltip": "Market creation rewards are paid out to the creator of any market that exceeds a set threshold of cumulative volume in a given epoch, currently [rewards.marketCreationQuantumMultiple]",
|
||||||
"rewardsColTotalHeader": "TOTAL",
|
"rewardsColTotalHeader": "TOTAL",
|
||||||
"ofTotalDistributed": "of total distributed",
|
"ofTotalDistributed": "of total distributed",
|
||||||
"checkBackSoon": "Check back soon",
|
"checkBackSoon": "Check back soon",
|
||||||
@@ -708,7 +696,7 @@
|
|||||||
"NewAssetProposal": "New asset proposal",
|
"NewAssetProposal": "New asset proposal",
|
||||||
"UpdateAssetProposal": "Update asset proposal",
|
"UpdateAssetProposal": "Update asset proposal",
|
||||||
"NewFreeformProposal": "New freeform proposal",
|
"NewFreeformProposal": "New freeform proposal",
|
||||||
"NewRawProposal": "New proposal",
|
"NewRawProposal": "New raw proposal",
|
||||||
"MinProposalRequirements": "You must have at least {{value}} VEGA associated to make a proposal",
|
"MinProposalRequirements": "You must have at least {{value}} VEGA associated to make a proposal",
|
||||||
"MinProposalVoteRequirements": "You must have at least {{value}} VEGA associated to vote on this proposal",
|
"MinProposalVoteRequirements": "You must have at least {{value}} VEGA associated to vote on this proposal",
|
||||||
"totalSupply": "Total Supply",
|
"totalSupply": "Total Supply",
|
||||||
@@ -870,9 +858,5 @@
|
|||||||
"Upgraded at": "Upgraded at",
|
"Upgraded at": "Upgraded at",
|
||||||
"dataIsIdentical": "Data is identical",
|
"dataIsIdentical": "Data is identical",
|
||||||
"updatesToMarket": "Updates to market",
|
"updatesToMarket": "Updates to market",
|
||||||
"viewAsParty": "View as party",
|
"viewAsParty": "View as party"
|
||||||
"HowToPropose": "How to make a proposal",
|
|
||||||
"HowToProposeRawStep1": "1. Sense check your proposal with the community on the forum:",
|
|
||||||
"HowToProposeRawStep2": "2. Use the appropriate proposal template in the docs:",
|
|
||||||
"HowToProposeRawStep3": "3. Submit on-chain below"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ import {
|
|||||||
orderByDate,
|
orderByDate,
|
||||||
orderByUpgradeBlockHeight,
|
orderByUpgradeBlockHeight,
|
||||||
} from '../proposals/components/proposals-list/proposals-list';
|
} from '../proposals/components/proposals-list/proposals-list';
|
||||||
|
import {
|
||||||
|
NetworkParams,
|
||||||
|
useNetworkParams,
|
||||||
|
} from '@vegaprotocol/network-parameters';
|
||||||
import { BigNumber } from '../../lib/bignumber';
|
import { BigNumber } from '../../lib/bignumber';
|
||||||
|
|
||||||
const nodesToShow = 6;
|
const nodesToShow = 6;
|
||||||
@@ -43,34 +47,57 @@ const HomeProposals = ({
|
|||||||
protocolUpgradeProposals: ProtocolUpgradeProposalFieldsFragment[];
|
protocolUpgradeProposals: ProtocolUpgradeProposalFieldsFragment[];
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const {
|
||||||
|
params: networkParams,
|
||||||
|
loading: networkParamsLoading,
|
||||||
|
error: networkParamsError,
|
||||||
|
} = useNetworkParams([
|
||||||
|
NetworkParams.governance_proposal_market_requiredMajority,
|
||||||
|
NetworkParams.governance_proposal_updateMarket_requiredMajority,
|
||||||
|
NetworkParams.governance_proposal_updateMarket_requiredMajorityLP,
|
||||||
|
NetworkParams.governance_proposal_asset_requiredMajority,
|
||||||
|
NetworkParams.governance_proposal_updateAsset_requiredMajority,
|
||||||
|
NetworkParams.governance_proposal_updateNetParam_requiredMajority,
|
||||||
|
NetworkParams.governance_proposal_freeform_requiredMajority,
|
||||||
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="mb-16 break-all" data-testid="home-proposals">
|
<AsyncRenderer
|
||||||
<Heading title={t('vegaGovernance')} />
|
loading={networkParamsLoading}
|
||||||
<h3 className="mb-6">{t('homeProposalsIntro')}</h3>
|
error={networkParamsError}
|
||||||
<div className="mb-8">
|
data={networkParams}
|
||||||
<ExternalLink href={ExternalLinks.GOVERNANCE_PAGE}>
|
>
|
||||||
{t(`readMoreGovernance`)}
|
<section className="mb-16" data-testid="home-proposals">
|
||||||
</ExternalLink>
|
<Heading title={t('vegaGovernance')} />
|
||||||
</div>
|
<h3 className="mb-6">{t('homeProposalsIntro')}</h3>
|
||||||
|
<div className="mb-8">
|
||||||
|
<ExternalLink href={ExternalLinks.GOVERNANCE_PAGE}>
|
||||||
|
{t(`readMoreGovernance`)}
|
||||||
|
</ExternalLink>
|
||||||
|
</div>
|
||||||
|
|
||||||
<SubHeading title={t('latestProposals')} />
|
<SubHeading title={t('latestProposals')} />
|
||||||
<ul data-testid="home-proposal-list" className="grid gap-6">
|
<ul data-testid="home-proposal-list" className="grid gap-6">
|
||||||
{protocolUpgradeProposals.map((proposal, index) => (
|
{protocolUpgradeProposals.map((proposal, index) => (
|
||||||
<ProtocolUpgradeProposalsListItem key={index} proposal={proposal} />
|
<ProtocolUpgradeProposalsListItem key={index} proposal={proposal} />
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{proposals.map((proposal) => (
|
{proposals.map((proposal) => (
|
||||||
<ProposalsListItem key={proposal.id} proposal={proposal} />
|
<ProposalsListItem
|
||||||
))}
|
key={proposal.id}
|
||||||
</ul>
|
proposal={proposal}
|
||||||
|
networkParams={networkParams}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
|
||||||
<div className="mt-6">
|
<div className="mt-6">
|
||||||
<Link to={`${Routes.PROPOSALS}`}>
|
<Link to={`${Routes.PROPOSALS}`}>
|
||||||
<Button size="md">{t('homeProposalsButtonText')}</Button>
|
<Button size="md">{t('homeProposalsButtonText')}</Button>
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
</AsyncRenderer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -279,8 +306,8 @@ const GovernanceHome = ({ name }: RouteChildProps) => {
|
|||||||
trimmedActiveNodes={trimmedActiveNodes}
|
trimmedActiveNodes={trimmedActiveNodes}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<section className="flex justify-between flex-wrap gap-12 mb-16">
|
<section className="grid grid-cols-2 gap-12 mb-16">
|
||||||
<div className="min-w-[360px] flex-1" data-testid="home-rewards">
|
<div data-testid="home-rewards">
|
||||||
<Heading title={t('Rewards')} marginTop={false} />
|
<Heading title={t('Rewards')} marginTop={false} />
|
||||||
<h3 className="mb-6">{t('homeRewardsIntro')}</h3>
|
<h3 className="mb-6">{t('homeRewardsIntro')}</h3>
|
||||||
<div className="flex items-center mb-8 gap-4">
|
<div className="flex items-center mb-8 gap-4">
|
||||||
@@ -290,7 +317,7 @@ const GovernanceHome = ({ name }: RouteChildProps) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="min-w-[360px] flex-1" data-testid="home-vega-token">
|
<div data-testid="home-vega-token">
|
||||||
<Heading title={t('vegaToken')} marginTop={false} />
|
<Heading title={t('vegaToken')} marginTop={false} />
|
||||||
<h3 className="mb-6">{t('homeVegaTokenIntro')}</h3>
|
<h3 className="mb-6">{t('homeVegaTokenIntro')}</h3>
|
||||||
<div className="flex items-center mb-8 gap-4">
|
<div className="flex items-center mb-8 gap-4">
|
||||||
|
|||||||
+2
@@ -16,6 +16,7 @@ import { ProposalHeader } from './proposal-header';
|
|||||||
import {
|
import {
|
||||||
lastWeek,
|
lastWeek,
|
||||||
nextWeek,
|
nextWeek,
|
||||||
|
mockNetworkParams,
|
||||||
mockWalletContext,
|
mockWalletContext,
|
||||||
createUserVoteQueryMock,
|
createUserVoteQueryMock,
|
||||||
} from '../../test-helpers/mocks';
|
} from '../../test-helpers/mocks';
|
||||||
@@ -47,6 +48,7 @@ const renderComponent = (
|
|||||||
<ProposalHeader
|
<ProposalHeader
|
||||||
proposal={proposal}
|
proposal={proposal}
|
||||||
isListItem={isListItem}
|
isListItem={isListItem}
|
||||||
|
networkParams={mockNetworkParams}
|
||||||
voteState={voteState}
|
voteState={voteState}
|
||||||
/>
|
/>
|
||||||
</VegaWalletContext.Provider>
|
</VegaWalletContext.Provider>
|
||||||
|
|||||||
+7
-4
@@ -8,19 +8,22 @@ import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
|||||||
import { truncateMiddle } from '../../../../lib/truncate-middle';
|
import { truncateMiddle } from '../../../../lib/truncate-middle';
|
||||||
import { CurrentProposalState } from '../current-proposal-state';
|
import { CurrentProposalState } from '../current-proposal-state';
|
||||||
import { ProposalInfoLabel } from '../proposal-info-label';
|
import { ProposalInfoLabel } from '../proposal-info-label';
|
||||||
|
import { ProposalVotingStatus } from '../proposal-voting-status';
|
||||||
|
import type { NetworkParamsResult } from '@vegaprotocol/network-parameters';
|
||||||
import { useSuccessorMarketProposalDetails } from '@vegaprotocol/proposals';
|
import { useSuccessorMarketProposalDetails } from '@vegaprotocol/proposals';
|
||||||
import { FLAGS } from '@vegaprotocol/environment';
|
import { FLAGS } from '@vegaprotocol/environment';
|
||||||
import Routes from '../../../routes';
|
import Routes from '../../../routes';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import type { VoteState } from '../vote-details/use-user-vote';
|
import type { VoteState } from '../vote-details/use-user-vote';
|
||||||
import { VoteBreakdown } from '../vote-breakdown';
|
|
||||||
|
|
||||||
export const ProposalHeader = ({
|
export const ProposalHeader = ({
|
||||||
proposal,
|
proposal,
|
||||||
|
networkParams,
|
||||||
isListItem = true,
|
isListItem = true,
|
||||||
voteState,
|
voteState,
|
||||||
}: {
|
}: {
|
||||||
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
|
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
|
||||||
|
networkParams: Partial<NetworkParamsResult>;
|
||||||
isListItem?: boolean;
|
isListItem?: boolean;
|
||||||
voteState?: VoteState | null;
|
voteState?: VoteState | null;
|
||||||
}) => {
|
}) => {
|
||||||
@@ -143,7 +146,7 @@ export const ProposalHeader = ({
|
|||||||
className="flex items-center gap-2"
|
className="flex items-center gap-2"
|
||||||
data-testid={`user-voted-${voteState.toLowerCase()}`}
|
data-testid={`user-voted-${voteState.toLowerCase()}`}
|
||||||
>
|
>
|
||||||
<div data-testid="you-voted-icon">
|
<div className="text-vega-green" data-testid="you-voted-icon">
|
||||||
<VegaIcon name={VegaIconNames.VOTE} size={24} />
|
<VegaIcon name={VegaIconNames.VOTE} size={24} />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@@ -159,7 +162,7 @@ export const ProposalHeader = ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div data-testid="proposal-title" className="break-all">
|
<div data-testid="proposal-title">
|
||||||
{isListItem ? (
|
{isListItem ? (
|
||||||
<header>
|
<header>
|
||||||
<SubHeading
|
<SubHeading
|
||||||
@@ -182,7 +185,7 @@ export const ProposalHeader = ({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<VoteBreakdown proposal={proposal} />
|
<ProposalVotingStatus proposal={proposal} networkParams={networkParams} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
export { ProposalVotesTable } from './proposal-votes-table';
|
||||||
+119
@@ -0,0 +1,119 @@
|
|||||||
|
import { render, screen, fireEvent } from '@testing-library/react';
|
||||||
|
import { MockedProvider } from '@apollo/client/testing';
|
||||||
|
import { AppStateProvider } from '../../../../contexts/app-state/app-state-provider';
|
||||||
|
import { ProposalVotesTable } from './proposal-votes-table';
|
||||||
|
import { ProposalType } from '../proposal/proposal';
|
||||||
|
import {
|
||||||
|
generateNoVotes,
|
||||||
|
generateProposal,
|
||||||
|
generateYesVotes,
|
||||||
|
} from '../../test-helpers/generate-proposals';
|
||||||
|
|
||||||
|
const defaultProposal = generateProposal();
|
||||||
|
const defaultProposalType = ProposalType.PROPOSAL_NETWORK_PARAMETER;
|
||||||
|
const updateMarketProposal = generateProposal({
|
||||||
|
terms: {
|
||||||
|
change: {
|
||||||
|
__typename: 'UpdateMarket',
|
||||||
|
marketId: '12345',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
votes: {
|
||||||
|
__typename: 'ProposalVotes',
|
||||||
|
yes: generateYesVotes(10),
|
||||||
|
no: generateNoVotes(0),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const updateMarketProposalType = ProposalType.PROPOSAL_UPDATE_MARKET;
|
||||||
|
|
||||||
|
const renderComponent = (
|
||||||
|
proposal = defaultProposal,
|
||||||
|
proposalType = defaultProposalType
|
||||||
|
) =>
|
||||||
|
render(
|
||||||
|
<MockedProvider>
|
||||||
|
<AppStateProvider>
|
||||||
|
<ProposalVotesTable proposal={proposal} proposalType={proposalType} />
|
||||||
|
</AppStateProvider>
|
||||||
|
</MockedProvider>
|
||||||
|
);
|
||||||
|
|
||||||
|
describe('Proposal Votes Table', () => {
|
||||||
|
it('should render successfully', () => {
|
||||||
|
const { baseElement } = renderComponent();
|
||||||
|
expect(baseElement).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show vote breakdown fields, excluding custom update market fields', () => {
|
||||||
|
renderComponent();
|
||||||
|
fireEvent.click(screen.getByTestId('vote-breakdown-toggle'));
|
||||||
|
expect(screen.getByText('Expected to pass')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('Token majority met')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('Token participation met')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('Tokens for proposal')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('Total Supply')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('Tokens against proposal')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('Participation required')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('Majority Required')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('Number of voting parties')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('Total tokens voted')).toBeInTheDocument();
|
||||||
|
expect(
|
||||||
|
screen.getByText('Total tokens voted percentage')
|
||||||
|
).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('Number of votes for')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('Number of votes against')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('Yes percentage')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('No percentage')).toBeInTheDocument();
|
||||||
|
expect(screen.queryByText('Liquidity majority met')).toBeNull();
|
||||||
|
expect(screen.queryByText('Liquidity participation met')).toBeNull();
|
||||||
|
expect(screen.queryByText('Liquidity shares for proposal')).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('displays different breakdown fields for update market proposal', () => {
|
||||||
|
renderComponent(updateMarketProposal, updateMarketProposalType);
|
||||||
|
fireEvent.click(screen.getByTestId('vote-breakdown-toggle'));
|
||||||
|
expect(screen.getByText('Liquidity majority met')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('Liquidity participation met')).toBeInTheDocument();
|
||||||
|
expect(
|
||||||
|
screen.getByText('Liquidity shares for proposal')
|
||||||
|
).toBeInTheDocument();
|
||||||
|
expect(screen.queryByText('Number of voting parties')).toBeNull();
|
||||||
|
expect(screen.queryByText('Total tokens voted')).toBeNull();
|
||||||
|
expect(screen.queryByText('Total tokens voted percentage')).toBeNull();
|
||||||
|
expect(screen.queryByText('Number of votes for')).toBeNull();
|
||||||
|
expect(screen.queryByText('Number of votes against')).toBeNull();
|
||||||
|
expect(screen.queryByText('Yes percentage')).toBeNull();
|
||||||
|
expect(screen.queryByText('No percentage')).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('displays if an update market proposal will pass by token vote', () => {
|
||||||
|
renderComponent(updateMarketProposal, updateMarketProposalType);
|
||||||
|
fireEvent.click(screen.getByTestId('vote-breakdown-toggle'));
|
||||||
|
expect(screen.getByText('👍 by token vote')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('displays if an update market proposal will pass by LP vote', () => {
|
||||||
|
renderComponent(
|
||||||
|
generateProposal({
|
||||||
|
terms: {
|
||||||
|
change: {
|
||||||
|
__typename: 'UpdateMarket',
|
||||||
|
marketId: '12345',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
votes: {
|
||||||
|
__typename: 'ProposalVotes',
|
||||||
|
yes: {
|
||||||
|
...generateYesVotes(0, 1, '10'),
|
||||||
|
},
|
||||||
|
no: {
|
||||||
|
...generateNoVotes(0, 1, '0'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
updateMarketProposalType
|
||||||
|
);
|
||||||
|
fireEvent.click(screen.getByTestId('vote-breakdown-toggle'));
|
||||||
|
expect(screen.getByText('👍 by liquidity vote')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
});
|
||||||
+177
@@ -0,0 +1,177 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import {
|
||||||
|
KeyValueTable,
|
||||||
|
KeyValueTableRow,
|
||||||
|
Thumbs,
|
||||||
|
RoundedWrapper,
|
||||||
|
} from '@vegaprotocol/ui-toolkit';
|
||||||
|
import { formatNumber, formatNumberPercentage } from '@vegaprotocol/utils';
|
||||||
|
import { SubHeading } from '../../../../components/heading';
|
||||||
|
import { useVoteInformation } from '../../hooks';
|
||||||
|
import { useAppState } from '../../../../contexts/app-state/app-state-context';
|
||||||
|
import { ProposalType } from '../proposal/proposal';
|
||||||
|
import { CollapsibleToggle } from '../../../../components/collapsible-toggle';
|
||||||
|
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
||||||
|
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
||||||
|
|
||||||
|
interface ProposalVotesTableProps {
|
||||||
|
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
|
||||||
|
proposalType: ProposalType | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ProposalVotesTable = ({
|
||||||
|
proposal,
|
||||||
|
proposalType,
|
||||||
|
}: ProposalVotesTableProps) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const {
|
||||||
|
appState: { totalSupply },
|
||||||
|
} = useAppState();
|
||||||
|
const [showDetails, setShowDetails] = useState(false);
|
||||||
|
const {
|
||||||
|
willPassByTokenVote,
|
||||||
|
willPassByLPVote,
|
||||||
|
totalTokensPercentage,
|
||||||
|
participationMet,
|
||||||
|
participationLPMet,
|
||||||
|
totalTokensVoted,
|
||||||
|
noPercentage,
|
||||||
|
yesPercentage,
|
||||||
|
noTokens,
|
||||||
|
yesTokens,
|
||||||
|
yesEquityLikeShareWeight,
|
||||||
|
yesVotes,
|
||||||
|
noVotes,
|
||||||
|
totalVotes,
|
||||||
|
requiredMajorityPercentage,
|
||||||
|
requiredParticipation,
|
||||||
|
majorityMet,
|
||||||
|
majorityLPMet,
|
||||||
|
} = useVoteInformation({ proposal });
|
||||||
|
|
||||||
|
const isUpdateMarket = proposalType === ProposalType.PROPOSAL_UPDATE_MARKET;
|
||||||
|
const updateMarketWillPass = willPassByTokenVote || willPassByLPVote;
|
||||||
|
const updateMarketVotePassMethod = willPassByTokenVote
|
||||||
|
? t('byTokenVote')
|
||||||
|
: t('byLiquidityVote');
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<CollapsibleToggle
|
||||||
|
toggleState={showDetails}
|
||||||
|
setToggleState={setShowDetails}
|
||||||
|
dataTestId="vote-breakdown-toggle"
|
||||||
|
>
|
||||||
|
<SubHeading title={t('voteBreakdown')} />
|
||||||
|
</CollapsibleToggle>
|
||||||
|
|
||||||
|
{showDetails && (
|
||||||
|
<RoundedWrapper marginBottomLarge={true} paddingBottom={true}>
|
||||||
|
<KeyValueTable
|
||||||
|
data-testid="proposal-votes-table"
|
||||||
|
numerical={true}
|
||||||
|
headingLevel={4}
|
||||||
|
>
|
||||||
|
<KeyValueTableRow>
|
||||||
|
{t('expectedToPass')}
|
||||||
|
{isUpdateMarket ? (
|
||||||
|
updateMarketWillPass ? (
|
||||||
|
<Thumbs up={true} text={updateMarketVotePassMethod} />
|
||||||
|
) : (
|
||||||
|
<Thumbs up={false} />
|
||||||
|
)
|
||||||
|
) : willPassByTokenVote ? (
|
||||||
|
<Thumbs up={true} />
|
||||||
|
) : (
|
||||||
|
<Thumbs up={false} />
|
||||||
|
)}
|
||||||
|
</KeyValueTableRow>
|
||||||
|
<KeyValueTableRow>
|
||||||
|
{t('majorityMet')}
|
||||||
|
{majorityMet ? <Thumbs up={true} /> : <Thumbs up={false} />}
|
||||||
|
</KeyValueTableRow>
|
||||||
|
{isUpdateMarket && (
|
||||||
|
<KeyValueTableRow>
|
||||||
|
{t('majorityLPMet')}
|
||||||
|
{majorityLPMet ? <Thumbs up={true} /> : <Thumbs up={false} />}
|
||||||
|
</KeyValueTableRow>
|
||||||
|
)}
|
||||||
|
<KeyValueTableRow>
|
||||||
|
{t('participationMet')}
|
||||||
|
{participationMet ? <Thumbs up={true} /> : <Thumbs up={false} />}
|
||||||
|
</KeyValueTableRow>
|
||||||
|
{isUpdateMarket && (
|
||||||
|
<KeyValueTableRow>
|
||||||
|
{t('participationLPMet')}
|
||||||
|
{participationLPMet ? (
|
||||||
|
<Thumbs up={true} />
|
||||||
|
) : (
|
||||||
|
<Thumbs up={false} />
|
||||||
|
)}
|
||||||
|
</KeyValueTableRow>
|
||||||
|
)}
|
||||||
|
<KeyValueTableRow>
|
||||||
|
{t('tokenForProposal')}
|
||||||
|
{formatNumber(yesTokens, 2)}
|
||||||
|
</KeyValueTableRow>
|
||||||
|
{isUpdateMarket && (
|
||||||
|
<KeyValueTableRow>
|
||||||
|
{t('tokenLPForProposal')}
|
||||||
|
{formatNumber(yesEquityLikeShareWeight, 2)}
|
||||||
|
</KeyValueTableRow>
|
||||||
|
)}
|
||||||
|
<KeyValueTableRow>
|
||||||
|
{t('totalSupply')}
|
||||||
|
{formatNumber(totalSupply, 2)}
|
||||||
|
</KeyValueTableRow>
|
||||||
|
<KeyValueTableRow>
|
||||||
|
{t('tokensAgainstProposal')}
|
||||||
|
{formatNumber(noTokens, 2)}
|
||||||
|
</KeyValueTableRow>
|
||||||
|
<KeyValueTableRow>
|
||||||
|
{t('participationRequired')}
|
||||||
|
{formatNumberPercentage(requiredParticipation)}
|
||||||
|
</KeyValueTableRow>
|
||||||
|
<KeyValueTableRow>
|
||||||
|
{t('majorityRequired')}
|
||||||
|
{formatNumberPercentage(requiredMajorityPercentage)}
|
||||||
|
</KeyValueTableRow>
|
||||||
|
{!isUpdateMarket && (
|
||||||
|
<>
|
||||||
|
<KeyValueTableRow>
|
||||||
|
{t('numberOfVotingParties')}
|
||||||
|
{formatNumber(totalVotes, 0)}
|
||||||
|
</KeyValueTableRow>
|
||||||
|
<KeyValueTableRow>
|
||||||
|
{t('totalTokensVotes')}
|
||||||
|
{formatNumber(totalTokensVoted, 2)}
|
||||||
|
</KeyValueTableRow>
|
||||||
|
<KeyValueTableRow>
|
||||||
|
{t('totalTokenVotedPercentage')}
|
||||||
|
{formatNumberPercentage(totalTokensPercentage, 2)}
|
||||||
|
</KeyValueTableRow>
|
||||||
|
<KeyValueTableRow>
|
||||||
|
{t('numberOfForVotes')}
|
||||||
|
{formatNumber(yesVotes, 0)}
|
||||||
|
</KeyValueTableRow>
|
||||||
|
<KeyValueTableRow>
|
||||||
|
{t('numberOfAgainstVotes')}
|
||||||
|
{formatNumber(noVotes, 0)}
|
||||||
|
</KeyValueTableRow>
|
||||||
|
<KeyValueTableRow>
|
||||||
|
{t('yesPercentage')}
|
||||||
|
{formatNumberPercentage(yesPercentage, 2)}
|
||||||
|
</KeyValueTableRow>
|
||||||
|
<KeyValueTableRow noBorder={true}>
|
||||||
|
{t('noPercentage')}
|
||||||
|
{formatNumberPercentage(noPercentage, 2)}
|
||||||
|
</KeyValueTableRow>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</KeyValueTable>
|
||||||
|
</RoundedWrapper>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from './proposal-voting-status';
|
||||||
+153
@@ -0,0 +1,153 @@
|
|||||||
|
import { render, screen } from '@testing-library/react';
|
||||||
|
import { BrowserRouter as Router } from 'react-router-dom';
|
||||||
|
import { MockedProvider } from '@apollo/client/testing';
|
||||||
|
import { VegaWalletContext } from '@vegaprotocol/wallet';
|
||||||
|
import {
|
||||||
|
lastWeek,
|
||||||
|
mockWalletContext,
|
||||||
|
networkParamsQueryMock,
|
||||||
|
nextWeek,
|
||||||
|
mockNetworkParams,
|
||||||
|
} from '../../test-helpers/mocks';
|
||||||
|
import { ProposalVotingStatus } from './proposal-voting-status';
|
||||||
|
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
||||||
|
import type { MockedResponse } from '@apollo/client/testing';
|
||||||
|
import {
|
||||||
|
generateNoVotes,
|
||||||
|
generateProposal,
|
||||||
|
generateYesVotes,
|
||||||
|
} from '../../test-helpers/generate-proposals';
|
||||||
|
import { ProposalState } from '@vegaprotocol/types';
|
||||||
|
import { BigNumber } from '../../../../lib/bignumber';
|
||||||
|
import type { AppState } from '../../../../contexts/app-state/app-state-context';
|
||||||
|
|
||||||
|
const mockTotalSupply = new BigNumber(100);
|
||||||
|
// Note - giving a fixedTokenValue of 1 means a ratio of 1:1 votes to tokens, making sums easier :)
|
||||||
|
const fixedTokenValue = 1000000000000000000;
|
||||||
|
|
||||||
|
const mockAppState: AppState = {
|
||||||
|
totalAssociated: new BigNumber('50063005'),
|
||||||
|
decimals: 18,
|
||||||
|
totalSupply: mockTotalSupply,
|
||||||
|
vegaWalletManageOverlay: false,
|
||||||
|
transactionOverlay: false,
|
||||||
|
bannerMessage: '',
|
||||||
|
disconnectNotice: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
jest.mock('../../../../contexts/app-state/app-state-context', () => ({
|
||||||
|
useAppState: () => ({
|
||||||
|
appState: mockAppState,
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
|
const renderComponent = (
|
||||||
|
proposal: ProposalQuery['proposal'],
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
mocks: MockedResponse<any>[] = [networkParamsQueryMock]
|
||||||
|
) =>
|
||||||
|
render(
|
||||||
|
<Router>
|
||||||
|
<MockedProvider mocks={mocks}>
|
||||||
|
<VegaWalletContext.Provider value={mockWalletContext}>
|
||||||
|
<ProposalVotingStatus
|
||||||
|
proposal={proposal}
|
||||||
|
networkParams={mockNetworkParams}
|
||||||
|
/>
|
||||||
|
</VegaWalletContext.Provider>
|
||||||
|
</MockedProvider>
|
||||||
|
</Router>
|
||||||
|
);
|
||||||
|
|
||||||
|
describe('ProposalVotingStatus', () => {
|
||||||
|
beforeAll(() => {
|
||||||
|
jest.useFakeTimers();
|
||||||
|
jest.setSystemTime(0);
|
||||||
|
});
|
||||||
|
afterAll(() => {
|
||||||
|
jest.useRealTimers();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders majority reached', () => {
|
||||||
|
const yesVotes = 100;
|
||||||
|
const noVotes = 0;
|
||||||
|
|
||||||
|
renderComponent(
|
||||||
|
generateProposal({
|
||||||
|
state: ProposalState.STATE_PASSED,
|
||||||
|
terms: {
|
||||||
|
closingDatetime: lastWeek.toString(),
|
||||||
|
enactmentDatetime: nextWeek.toString(),
|
||||||
|
},
|
||||||
|
votes: {
|
||||||
|
__typename: 'ProposalVotes',
|
||||||
|
yes: generateYesVotes(yesVotes, fixedTokenValue),
|
||||||
|
no: generateNoVotes(noVotes, fixedTokenValue),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
expect(screen.getByTestId('majority-reached')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders majority not reached', () => {
|
||||||
|
const yesVotes = 20;
|
||||||
|
const noVotes = 80;
|
||||||
|
|
||||||
|
renderComponent(
|
||||||
|
generateProposal({
|
||||||
|
state: ProposalState.STATE_PASSED,
|
||||||
|
terms: {
|
||||||
|
closingDatetime: lastWeek.toString(),
|
||||||
|
enactmentDatetime: nextWeek.toString(),
|
||||||
|
},
|
||||||
|
votes: {
|
||||||
|
__typename: 'ProposalVotes',
|
||||||
|
yes: generateYesVotes(yesVotes, fixedTokenValue),
|
||||||
|
no: generateNoVotes(noVotes, fixedTokenValue),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
expect(screen.getByTestId('majority-not-reached')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders participation reached', () => {
|
||||||
|
const yesVotes = 1000;
|
||||||
|
const noVotes = 0;
|
||||||
|
|
||||||
|
renderComponent(
|
||||||
|
generateProposal({
|
||||||
|
state: ProposalState.STATE_PASSED,
|
||||||
|
terms: {
|
||||||
|
closingDatetime: lastWeek.toString(),
|
||||||
|
enactmentDatetime: nextWeek.toString(),
|
||||||
|
},
|
||||||
|
votes: {
|
||||||
|
__typename: 'ProposalVotes',
|
||||||
|
yes: generateYesVotes(yesVotes, fixedTokenValue),
|
||||||
|
no: generateNoVotes(noVotes, fixedTokenValue),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
expect(screen.getByTestId('participation-reached')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders participation not reached', () => {
|
||||||
|
const yesVotes = 0;
|
||||||
|
const noVotes = 0;
|
||||||
|
|
||||||
|
renderComponent(
|
||||||
|
generateProposal({
|
||||||
|
terms: {
|
||||||
|
closingDatetime: lastWeek.toString(),
|
||||||
|
enactmentDatetime: nextWeek.toString(),
|
||||||
|
},
|
||||||
|
votes: {
|
||||||
|
__typename: 'ProposalVotes',
|
||||||
|
yes: generateYesVotes(yesVotes, fixedTokenValue),
|
||||||
|
no: generateNoVotes(noVotes, fixedTokenValue),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
expect(screen.getByTestId('participation-not-reached')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
});
|
||||||
+174
@@ -0,0 +1,174 @@
|
|||||||
|
import classNames from 'classnames';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { Icon } from '@vegaprotocol/ui-toolkit';
|
||||||
|
import { useVoteInformation } from '../../hooks';
|
||||||
|
import { BigNumber } from '../../../../lib/bignumber';
|
||||||
|
import type { NetworkParamsResult } from '@vegaprotocol/network-parameters';
|
||||||
|
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
||||||
|
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
||||||
|
|
||||||
|
const statusClasses = (reached: boolean) =>
|
||||||
|
classNames('flex items-center gap-2 px-4 py-2 rounded-md', {
|
||||||
|
'bg-vega-green-700': reached,
|
||||||
|
'bg-vega-red-700': !reached,
|
||||||
|
});
|
||||||
|
|
||||||
|
const MajorityStatus = ({
|
||||||
|
reached,
|
||||||
|
requiredMajority,
|
||||||
|
}: {
|
||||||
|
reached: boolean;
|
||||||
|
requiredMajority: string | null | undefined;
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={statusClasses(reached)}
|
||||||
|
data-testid="proposal-majority-status"
|
||||||
|
>
|
||||||
|
{reached ? <Icon name="tick" /> : <Icon name="cross" />}
|
||||||
|
{reached ? (
|
||||||
|
<div data-testid="majority-reached">
|
||||||
|
{requiredMajority ? (
|
||||||
|
<>
|
||||||
|
{new BigNumber(requiredMajority).times(100).toString()}%{' '}
|
||||||
|
{t('majorityVotedForProposal')}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
t('requiredMajorityVotedForProposal')
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div data-testid="majority-not-reached">
|
||||||
|
{requiredMajority ? (
|
||||||
|
<>
|
||||||
|
{new BigNumber(requiredMajority).times(100).toString()}%{' '}
|
||||||
|
{t('majorityNotVotedForProposal')}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
t('requiredMajorityNotVotedForProposal')
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const ParticipationStatus = ({ reached }: { reached: boolean }) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={statusClasses(reached)}>
|
||||||
|
{reached ? (
|
||||||
|
<>
|
||||||
|
<Icon name="tick" />
|
||||||
|
<div data-testid="participation-reached">
|
||||||
|
{t('minParticipationReached')}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Icon name="cross" />
|
||||||
|
<div data-testid="participation-not-reached">
|
||||||
|
{t('minParticipationNotReached')}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ProposalVotingStatus = ({
|
||||||
|
proposal,
|
||||||
|
networkParams,
|
||||||
|
}: {
|
||||||
|
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
|
||||||
|
networkParams: Partial<NetworkParamsResult>;
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { majorityMet, majorityLPMet, participationMet, participationLPMet } =
|
||||||
|
useVoteInformation({
|
||||||
|
proposal,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!proposal) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const isUpdateMarket = proposal?.terms.change.__typename === 'UpdateMarket';
|
||||||
|
|
||||||
|
let requiredVotingMajority = null;
|
||||||
|
let requiredVotingMajorityLP = null;
|
||||||
|
|
||||||
|
if (networkParams) {
|
||||||
|
switch (proposal.terms.change.__typename) {
|
||||||
|
case 'NewMarket':
|
||||||
|
requiredVotingMajority =
|
||||||
|
networkParams.governance_proposal_market_requiredMajority;
|
||||||
|
break;
|
||||||
|
case 'UpdateMarket':
|
||||||
|
requiredVotingMajority =
|
||||||
|
networkParams.governance_proposal_updateMarket_requiredMajority;
|
||||||
|
requiredVotingMajorityLP =
|
||||||
|
networkParams.governance_proposal_updateMarket_requiredMajorityLP;
|
||||||
|
break;
|
||||||
|
case 'NewAsset':
|
||||||
|
requiredVotingMajority =
|
||||||
|
networkParams.governance_proposal_asset_requiredMajority;
|
||||||
|
break;
|
||||||
|
case 'UpdateAsset':
|
||||||
|
requiredVotingMajority =
|
||||||
|
networkParams.governance_proposal_updateAsset_requiredMajority;
|
||||||
|
break;
|
||||||
|
case 'UpdateNetworkParameter':
|
||||||
|
requiredVotingMajority =
|
||||||
|
networkParams.governance_proposal_updateNetParam_requiredMajority;
|
||||||
|
break;
|
||||||
|
case 'NewFreeform':
|
||||||
|
requiredVotingMajority =
|
||||||
|
networkParams.governance_proposal_freeform_requiredMajority;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isUpdateMarket) {
|
||||||
|
return (
|
||||||
|
<div className="mb-6">
|
||||||
|
<p>{t('Token vote')}</p>
|
||||||
|
<div
|
||||||
|
className="grid grid-cols-2 gap-4 items-center"
|
||||||
|
data-testid="token-vote-statuses"
|
||||||
|
>
|
||||||
|
<MajorityStatus
|
||||||
|
reached={majorityMet}
|
||||||
|
requiredMajority={requiredVotingMajority}
|
||||||
|
/>{' '}
|
||||||
|
<ParticipationStatus reached={participationMet} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p className="mt-4">{t('Liquidity provider vote')}</p>
|
||||||
|
<div
|
||||||
|
className="grid grid-cols-2 gap-4 items-center"
|
||||||
|
data-testid="lp-vote-statuses"
|
||||||
|
>
|
||||||
|
<MajorityStatus
|
||||||
|
reached={majorityLPMet}
|
||||||
|
requiredMajority={requiredVotingMajorityLP}
|
||||||
|
/>{' '}
|
||||||
|
<ParticipationStatus reached={participationLPMet} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="grid grid-cols-2 gap-4 items-center mb-6">
|
||||||
|
<MajorityStatus
|
||||||
|
reached={majorityMet}
|
||||||
|
requiredMajority={requiredVotingMajority}
|
||||||
|
/>{' '}
|
||||||
|
<ParticipationStatus reached={participationMet} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -34,6 +34,12 @@ jest.mock('../proposal-change-table', () => ({
|
|||||||
jest.mock('../proposal-json', () => ({
|
jest.mock('../proposal-json', () => ({
|
||||||
ProposalJson: () => <div data-testid="proposal-json"></div>,
|
ProposalJson: () => <div data-testid="proposal-json"></div>,
|
||||||
}));
|
}));
|
||||||
|
jest.mock('../proposal-votes-table', () => ({
|
||||||
|
ProposalVotesTable: () => <div data-testid="proposal-votes-table"></div>,
|
||||||
|
}));
|
||||||
|
jest.mock('../vote-details', () => ({
|
||||||
|
VoteDetails: () => <div data-testid="proposal-vote-details"></div>,
|
||||||
|
}));
|
||||||
jest.mock('../list-asset', () => ({
|
jest.mock('../list-asset', () => ({
|
||||||
ListAsset: () => <div data-testid="proposal-list-asset"></div>,
|
ListAsset: () => <div data-testid="proposal-list-asset"></div>,
|
||||||
}));
|
}));
|
||||||
@@ -98,6 +104,8 @@ it('renders each section', async () => {
|
|||||||
expect(await screen.findByTestId('proposal-header')).toBeInTheDocument();
|
expect(await screen.findByTestId('proposal-header')).toBeInTheDocument();
|
||||||
expect(screen.getByTestId('proposal-change-table')).toBeInTheDocument();
|
expect(screen.getByTestId('proposal-change-table')).toBeInTheDocument();
|
||||||
expect(screen.getByTestId('proposal-json')).toBeInTheDocument();
|
expect(screen.getByTestId('proposal-json')).toBeInTheDocument();
|
||||||
|
expect(screen.getByTestId('proposal-votes-table')).toBeInTheDocument();
|
||||||
|
expect(screen.getByTestId('proposal-vote-details')).toBeInTheDocument();
|
||||||
expect(screen.queryByTestId('proposal-list-asset')).not.toBeInTheDocument();
|
expect(screen.queryByTestId('proposal-list-asset')).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ import { ProposalHeader } from '../proposal-detail-header/proposal-header';
|
|||||||
import { ProposalDescription } from '../proposal-description';
|
import { ProposalDescription } from '../proposal-description';
|
||||||
import { ProposalChangeTable } from '../proposal-change-table';
|
import { ProposalChangeTable } from '../proposal-change-table';
|
||||||
import { ProposalJson } from '../proposal-json';
|
import { ProposalJson } from '../proposal-json';
|
||||||
|
import { ProposalVotesTable } from '../proposal-votes-table';
|
||||||
import { ProposalAssetDetails } from '../proposal-asset-details';
|
import { ProposalAssetDetails } from '../proposal-asset-details';
|
||||||
import { UserVote } from '../vote-details';
|
import { VoteDetails } from '../vote-details';
|
||||||
import { ListAsset } from '../list-asset';
|
import { ListAsset } from '../list-asset';
|
||||||
import Routes from '../../../routes';
|
import Routes from '../../../routes';
|
||||||
import { ProposalMarketData } from '../proposal-market-data';
|
import { ProposalMarketData } from '../proposal-market-data';
|
||||||
@@ -21,6 +22,14 @@ import type { NetworkParamsResult } from '@vegaprotocol/network-parameters';
|
|||||||
import { useVoteSubmit } from '@vegaprotocol/proposals';
|
import { useVoteSubmit } from '@vegaprotocol/proposals';
|
||||||
import { useUserVote } from '../vote-details/use-user-vote';
|
import { useUserVote } from '../vote-details/use-user-vote';
|
||||||
|
|
||||||
|
export enum ProposalType {
|
||||||
|
PROPOSAL_NEW_MARKET = 'PROPOSAL_NEW_MARKET',
|
||||||
|
PROPOSAL_UPDATE_MARKET = 'PROPOSAL_UPDATE_MARKET',
|
||||||
|
PROPOSAL_NEW_ASSET = 'PROPOSAL_NEW_ASSET',
|
||||||
|
PROPOSAL_UPDATE_ASSET = 'PROPOSAL_UPDATE_ASSET',
|
||||||
|
PROPOSAL_NETWORK_PARAMETER = 'PROPOSAL_NETWORK_PARAMETER',
|
||||||
|
PROPOSAL_FREEFORM = 'PROPOSAL_FREEFORM',
|
||||||
|
}
|
||||||
export interface ProposalProps {
|
export interface ProposalProps {
|
||||||
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
|
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
|
||||||
networkParams: Partial<NetworkParamsResult>;
|
networkParams: Partial<NetworkParamsResult>;
|
||||||
@@ -71,32 +80,39 @@ export const Proposal = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
let minVoterBalance = null;
|
let minVoterBalance = null;
|
||||||
|
let proposalType = null;
|
||||||
|
|
||||||
if (networkParams) {
|
if (networkParams) {
|
||||||
switch (proposal.terms.change.__typename) {
|
switch (proposal.terms.change.__typename) {
|
||||||
case 'NewMarket':
|
case 'NewMarket':
|
||||||
minVoterBalance =
|
minVoterBalance =
|
||||||
networkParams.governance_proposal_market_minVoterBalance;
|
networkParams.governance_proposal_market_minVoterBalance;
|
||||||
|
proposalType = ProposalType.PROPOSAL_NEW_MARKET;
|
||||||
break;
|
break;
|
||||||
case 'UpdateMarket':
|
case 'UpdateMarket':
|
||||||
minVoterBalance =
|
minVoterBalance =
|
||||||
networkParams.governance_proposal_updateMarket_minVoterBalance;
|
networkParams.governance_proposal_updateMarket_minVoterBalance;
|
||||||
|
proposalType = ProposalType.PROPOSAL_UPDATE_MARKET;
|
||||||
break;
|
break;
|
||||||
case 'NewAsset':
|
case 'NewAsset':
|
||||||
minVoterBalance =
|
minVoterBalance =
|
||||||
networkParams.governance_proposal_asset_minVoterBalance;
|
networkParams.governance_proposal_asset_minVoterBalance;
|
||||||
|
proposalType = ProposalType.PROPOSAL_NEW_ASSET;
|
||||||
break;
|
break;
|
||||||
case 'UpdateAsset':
|
case 'UpdateAsset':
|
||||||
minVoterBalance =
|
minVoterBalance =
|
||||||
networkParams.governance_proposal_updateAsset_minVoterBalance;
|
networkParams.governance_proposal_updateAsset_minVoterBalance;
|
||||||
|
proposalType = ProposalType.PROPOSAL_UPDATE_ASSET;
|
||||||
break;
|
break;
|
||||||
case 'UpdateNetworkParameter':
|
case 'UpdateNetworkParameter':
|
||||||
minVoterBalance =
|
minVoterBalance =
|
||||||
networkParams.governance_proposal_updateNetParam_minVoterBalance;
|
networkParams.governance_proposal_updateNetParam_minVoterBalance;
|
||||||
|
proposalType = ProposalType.PROPOSAL_NETWORK_PARAMETER;
|
||||||
break;
|
break;
|
||||||
case 'NewFreeform':
|
case 'NewFreeform':
|
||||||
minVoterBalance =
|
minVoterBalance =
|
||||||
networkParams.governance_proposal_freeform_minVoterBalance;
|
networkParams.governance_proposal_freeform_minVoterBalance;
|
||||||
|
proposalType = ProposalType.PROPOSAL_FREEFORM;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,81 +140,91 @@ export const Proposal = ({
|
|||||||
<ProposalHeader
|
<ProposalHeader
|
||||||
proposal={proposal}
|
proposal={proposal}
|
||||||
isListItem={false}
|
isListItem={false}
|
||||||
|
networkParams={networkParams}
|
||||||
voteState={voteState}
|
voteState={voteState}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="my-10 break-all">
|
<div id="details">
|
||||||
<ProposalChangeTable proposal={proposal} />
|
<div className="my-10">
|
||||||
</div>
|
<ProposalChangeTable proposal={proposal} />
|
||||||
|
|
||||||
{proposal.terms.change.__typename === 'NewAsset' &&
|
|
||||||
proposal.terms.change.source.__typename === 'ERC20' &&
|
|
||||||
proposal.id ? (
|
|
||||||
<ListAsset
|
|
||||||
assetId={proposal.id}
|
|
||||||
withdrawalThreshold={proposal.terms.change.source.withdrawThreshold}
|
|
||||||
lifetimeLimit={proposal.terms.change.source.lifetimeLimit}
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
<div className="mb-4">
|
|
||||||
<ProposalDescription description={proposal.rationale.description} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{newMarketData && (
|
|
||||||
<div className="mb-4">
|
|
||||||
<ProposalMarketData
|
|
||||||
marketData={newMarketData}
|
|
||||||
parentMarketData={parentMarketData ? parentMarketData : undefined}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
|
|
||||||
{proposal.terms.change.__typename === 'UpdateMarket' && (
|
{proposal.terms.change.__typename === 'NewAsset' &&
|
||||||
<div className="mb-4">
|
proposal.terms.change.source.__typename === 'ERC20' &&
|
||||||
<ProposalMarketChanges
|
proposal.id ? (
|
||||||
originalProposal={
|
<ListAsset
|
||||||
originalMarketProposalRestData?.data?.proposal?.terms?.newMarket
|
assetId={proposal.id}
|
||||||
?.changes || {}
|
withdrawalThreshold={proposal.terms.change.source.withdrawThreshold}
|
||||||
}
|
lifetimeLimit={proposal.terms.change.source.lifetimeLimit}
|
||||||
latestEnactedProposal={
|
|
||||||
mostRecentlyEnactedAssociatedMarketProposal?.node?.proposal?.terms
|
|
||||||
?.updateMarket?.changes || {}
|
|
||||||
}
|
|
||||||
updatedProposal={
|
|
||||||
restData?.data?.proposal?.terms?.updateMarket?.changes || {}
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
) : null}
|
||||||
)}
|
|
||||||
|
|
||||||
{(proposal.terms.change.__typename === 'NewAsset' ||
|
<div className="mb-4">
|
||||||
proposal.terms.change.__typename === 'UpdateAsset') &&
|
<ProposalDescription description={proposal.rationale.description} />
|
||||||
asset && (
|
</div>
|
||||||
|
|
||||||
|
{newMarketData && (
|
||||||
<div className="mb-4">
|
<div className="mb-4">
|
||||||
<ProposalAssetDetails asset={asset} />
|
<ProposalMarketData
|
||||||
|
marketData={newMarketData}
|
||||||
|
parentMarketData={parentMarketData ? parentMarketData : undefined}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="mb-10">
|
{proposal.terms.change.__typename === 'UpdateMarket' && (
|
||||||
<RoundedWrapper paddingBottom={true}>
|
<div className="mb-4">
|
||||||
<UserVote
|
<ProposalMarketChanges
|
||||||
proposal={proposal}
|
originalProposal={
|
||||||
minVoterBalance={minVoterBalance}
|
originalMarketProposalRestData?.data?.proposal?.terms?.newMarket
|
||||||
spamProtectionMinTokens={
|
?.changes || {}
|
||||||
networkParams?.spam_protection_voting_min_tokens
|
}
|
||||||
}
|
latestEnactedProposal={
|
||||||
submit={submit}
|
mostRecentlyEnactedAssociatedMarketProposal?.node?.proposal
|
||||||
dialog={Dialog}
|
?.terms?.updateMarket?.changes || {}
|
||||||
transaction={transaction}
|
}
|
||||||
voteState={voteState}
|
updatedProposal={
|
||||||
voteDatetime={voteDatetime}
|
restData?.data?.proposal?.terms?.updateMarket?.changes || {}
|
||||||
/>
|
}
|
||||||
</RoundedWrapper>
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{(proposal.terms.change.__typename === 'NewAsset' ||
|
||||||
|
proposal.terms.change.__typename === 'UpdateAsset') &&
|
||||||
|
asset && (
|
||||||
|
<div className="mb-4">
|
||||||
|
<ProposalAssetDetails asset={asset} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div className="mb-6">
|
||||||
|
<ProposalJson proposal={restData?.data?.proposal} />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="mb-6">
|
<div id="voting">
|
||||||
<ProposalJson proposal={restData?.data?.proposal} />
|
<div className="mb-10">
|
||||||
|
<RoundedWrapper paddingBottom={true}>
|
||||||
|
<VoteDetails
|
||||||
|
proposal={proposal}
|
||||||
|
proposalType={proposalType}
|
||||||
|
minVoterBalance={minVoterBalance}
|
||||||
|
spamProtectionMinTokens={
|
||||||
|
networkParams?.spam_protection_voting_min_tokens
|
||||||
|
}
|
||||||
|
submit={submit}
|
||||||
|
dialog={Dialog}
|
||||||
|
transaction={transaction}
|
||||||
|
voteState={voteState}
|
||||||
|
voteDatetime={voteDatetime}
|
||||||
|
/>
|
||||||
|
</RoundedWrapper>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mb-4">
|
||||||
|
<ProposalVotesTable proposal={proposal} proposalType={proposalType} />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
+120
-1
@@ -6,7 +6,11 @@ import { MockedProvider } from '@apollo/client/testing';
|
|||||||
import { render, screen } from '@testing-library/react';
|
import { render, screen } from '@testing-library/react';
|
||||||
import { format } from 'date-fns';
|
import { format } from 'date-fns';
|
||||||
import { ProposalRejectionReason, ProposalState } from '@vegaprotocol/types';
|
import { ProposalRejectionReason, ProposalState } from '@vegaprotocol/types';
|
||||||
import { generateProposal } from '../../test-helpers/generate-proposals';
|
import {
|
||||||
|
generateNoVotes,
|
||||||
|
generateProposal,
|
||||||
|
generateYesVotes,
|
||||||
|
} from '../../test-helpers/generate-proposals';
|
||||||
import { ProposalsListItemDetails } from './proposals-list-item-details';
|
import { ProposalsListItemDetails } from './proposals-list-item-details';
|
||||||
import { DATE_FORMAT_DETAILED } from '../../../../lib/date-formats';
|
import { DATE_FORMAT_DETAILED } from '../../../../lib/date-formats';
|
||||||
import {
|
import {
|
||||||
@@ -89,6 +93,84 @@ describe('Proposals list item details', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Renders proposal state: Update market proposal - Currently expected to pass by LP vote', () => {
|
||||||
|
renderComponent(
|
||||||
|
generateProposal({
|
||||||
|
state: ProposalState.STATE_OPEN,
|
||||||
|
terms: {
|
||||||
|
change: {
|
||||||
|
__typename: 'UpdateMarket',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
votes: {
|
||||||
|
yes: {
|
||||||
|
...generateYesVotes(0),
|
||||||
|
totalEquityLikeShareWeight: '1000',
|
||||||
|
},
|
||||||
|
no: {
|
||||||
|
...generateNoVotes(0),
|
||||||
|
totalEquityLikeShareWeight: '0',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
expect(screen.getByTestId('vote-status')).toHaveTextContent(
|
||||||
|
'Currently expected to pass by LP vote'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders proposal state: Update market proposal - Currently expected to pass by token vote', () => {
|
||||||
|
renderComponent(
|
||||||
|
generateProposal({
|
||||||
|
state: ProposalState.STATE_OPEN,
|
||||||
|
terms: {
|
||||||
|
change: {
|
||||||
|
__typename: 'UpdateMarket',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
votes: {
|
||||||
|
yes: {
|
||||||
|
...generateYesVotes(1000, 1000),
|
||||||
|
totalEquityLikeShareWeight: '0',
|
||||||
|
},
|
||||||
|
no: {
|
||||||
|
...generateNoVotes(0),
|
||||||
|
totalEquityLikeShareWeight: '0',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
expect(screen.getByTestId('vote-status')).toHaveTextContent(
|
||||||
|
'Currently expected to pass by token vote'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders proposal state: Update market proposal - Currently expected to fail', () => {
|
||||||
|
renderComponent(
|
||||||
|
generateProposal({
|
||||||
|
state: ProposalState.STATE_OPEN,
|
||||||
|
terms: {
|
||||||
|
change: {
|
||||||
|
__typename: 'UpdateMarket',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
votes: {
|
||||||
|
yes: {
|
||||||
|
...generateYesVotes(0),
|
||||||
|
totalEquityLikeShareWeight: '0',
|
||||||
|
},
|
||||||
|
no: {
|
||||||
|
...generateNoVotes(0),
|
||||||
|
totalEquityLikeShareWeight: '0',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
expect(screen.getByTestId('vote-status')).toHaveTextContent(
|
||||||
|
'Currently expected to fail'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('Renders proposal state: Open - 5 minutes left to vote', () => {
|
it('Renders proposal state: Open - 5 minutes left to vote', () => {
|
||||||
renderComponent(
|
renderComponent(
|
||||||
generateProposal({
|
generateProposal({
|
||||||
@@ -131,6 +213,43 @@ describe('Proposals list item details', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Renders proposal state: Open - majority not reached', () => {
|
||||||
|
renderComponent(
|
||||||
|
generateProposal({
|
||||||
|
state: ProposalState.STATE_OPEN,
|
||||||
|
terms: {
|
||||||
|
enactmentDatetime: nextWeek.toString(),
|
||||||
|
},
|
||||||
|
votes: {
|
||||||
|
no: generateNoVotes(1, 1000000000000000000),
|
||||||
|
yes: generateYesVotes(1, 1000000000000000000),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
expect(screen.getByTestId('vote-status')).toHaveTextContent(
|
||||||
|
'Currently expected to fail'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders proposal state: Open - will pass', () => {
|
||||||
|
renderComponent(
|
||||||
|
generateProposal({
|
||||||
|
state: ProposalState.STATE_OPEN,
|
||||||
|
votes: {
|
||||||
|
__typename: 'ProposalVotes',
|
||||||
|
yes: generateYesVotes(3000, 1000000000000000000),
|
||||||
|
no: generateNoVotes(0),
|
||||||
|
},
|
||||||
|
terms: {
|
||||||
|
closingDatetime: nextWeek.toString(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
expect(screen.getByTestId('vote-status')).toHaveTextContent(
|
||||||
|
'Currently expected to pass'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('Renders proposal state: Rejected', () => {
|
it('Renders proposal state: Rejected', () => {
|
||||||
renderComponent(
|
renderComponent(
|
||||||
generateProposal({
|
generateProposal({
|
||||||
|
|||||||
+30
-1
@@ -11,6 +11,7 @@ import {
|
|||||||
import Routes from '../../../routes';
|
import Routes from '../../../routes';
|
||||||
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
||||||
|
import { useVoteInformation } from '../../hooks';
|
||||||
|
|
||||||
export const ProposalsListItemDetails = ({
|
export const ProposalsListItemDetails = ({
|
||||||
proposal,
|
proposal,
|
||||||
@@ -19,10 +20,18 @@ export const ProposalsListItemDetails = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const state = proposal?.state;
|
const state = proposal?.state;
|
||||||
|
const { willPassByTokenVote, willPassByLPVote } = useVoteInformation({
|
||||||
|
proposal,
|
||||||
|
});
|
||||||
|
const updateMarketWillPass = willPassByTokenVote || willPassByLPVote;
|
||||||
|
const updateMarketVotePassMethod = willPassByTokenVote
|
||||||
|
? t('byTokenVote')
|
||||||
|
: t('byLPVote');
|
||||||
const nowToEnactmentInHours = differenceInHours(
|
const nowToEnactmentInHours = differenceInHours(
|
||||||
new Date(proposal?.terms.closingDatetime),
|
new Date(proposal?.terms.closingDatetime),
|
||||||
new Date()
|
new Date()
|
||||||
);
|
);
|
||||||
|
const isUpdateMarket = proposal?.terms.change.__typename === 'UpdateMarket';
|
||||||
|
|
||||||
let voteDetails: ReactNode;
|
let voteDetails: ReactNode;
|
||||||
let voteStatus: ReactNode;
|
let voteStatus: ReactNode;
|
||||||
@@ -69,11 +78,31 @@ export const ProposalsListItemDetails = ({
|
|||||||
}
|
}
|
||||||
case ProposalState.STATE_OPEN: {
|
case ProposalState.STATE_OPEN: {
|
||||||
voteDetails = (
|
voteDetails = (
|
||||||
<span className={nowToEnactmentInHours < 6 ? 'text-vega-orange' : ''}>
|
<span className={nowToEnactmentInHours < 6 ? 'text-vega-pink' : ''}>
|
||||||
{formatDistanceToNowStrict(new Date(proposal?.terms.closingDatetime))}{' '}
|
{formatDistanceToNowStrict(new Date(proposal?.terms.closingDatetime))}{' '}
|
||||||
{t('left to vote')}
|
{t('left to vote')}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
voteStatus =
|
||||||
|
(isUpdateMarket &&
|
||||||
|
(updateMarketWillPass ? (
|
||||||
|
<>
|
||||||
|
{t('currentlySetTo')} {t('pass')} {updateMarketVotePassMethod}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
{t('currentlySetTo')} {t('fail')}
|
||||||
|
</>
|
||||||
|
))) ||
|
||||||
|
(willPassByTokenVote ? (
|
||||||
|
<>
|
||||||
|
{t('currentlySetTo')} {t('pass')}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
{t('currentlySetTo')} {t('fail')}
|
||||||
|
</>
|
||||||
|
));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ProposalState.STATE_REJECTED: {
|
case ProposalState.STATE_REJECTED: {
|
||||||
|
|||||||
+12
-3
@@ -4,19 +4,28 @@ import { ProposalsListItemDetails } from './proposals-list-item-details';
|
|||||||
import { useUserVote } from '../vote-details/use-user-vote';
|
import { useUserVote } from '../vote-details/use-user-vote';
|
||||||
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
||||||
|
import type { NetworkParamsResult } from '@vegaprotocol/network-parameters';
|
||||||
|
|
||||||
interface ProposalsListItemProps {
|
interface ProposalsListItemProps {
|
||||||
proposal?: ProposalFieldsFragment | ProposalQuery['proposal'] | null;
|
proposal?: ProposalFieldsFragment | ProposalQuery['proposal'] | null;
|
||||||
|
networkParams: Partial<NetworkParamsResult> | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ProposalsListItem = ({ proposal }: ProposalsListItemProps) => {
|
export const ProposalsListItem = ({
|
||||||
|
proposal,
|
||||||
|
networkParams,
|
||||||
|
}: ProposalsListItemProps) => {
|
||||||
const { voteState } = useUserVote(proposal?.id);
|
const { voteState } = useUserVote(proposal?.id);
|
||||||
if (!proposal || !proposal.id) return null;
|
if (!proposal || !proposal.id || !networkParams) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li id={proposal.id} data-testid="proposals-list-item">
|
<li id={proposal.id} data-testid="proposals-list-item">
|
||||||
<RoundedWrapper paddingBottom={true} heightFull={true}>
|
<RoundedWrapper paddingBottom={true} heightFull={true}>
|
||||||
<ProposalHeader proposal={proposal} voteState={voteState} />
|
<ProposalHeader
|
||||||
|
proposal={proposal}
|
||||||
|
networkParams={networkParams}
|
||||||
|
voteState={voteState}
|
||||||
|
/>
|
||||||
<ProposalsListItemDetails proposal={proposal} />
|
<ProposalsListItemDetails proposal={proposal} />
|
||||||
</RoundedWrapper>
|
</RoundedWrapper>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
+187
-146
@@ -7,13 +7,23 @@ import { ProposalsListItem } from '../proposals-list-item';
|
|||||||
import { ProtocolUpgradeProposalsListItem } from '../protocol-upgrade-proposals-list-item/protocol-upgrade-proposals-list-item';
|
import { ProtocolUpgradeProposalsListItem } from '../protocol-upgrade-proposals-list-item/protocol-upgrade-proposals-list-item';
|
||||||
import { ProposalsListFilter } from '../proposals-list-filter';
|
import { ProposalsListFilter } from '../proposals-list-filter';
|
||||||
import Routes from '../../../routes';
|
import Routes from '../../../routes';
|
||||||
import { Button, Toggle } from '@vegaprotocol/ui-toolkit';
|
import {
|
||||||
|
AsyncRenderer,
|
||||||
|
Button,
|
||||||
|
Toggle,
|
||||||
|
VegaIcon,
|
||||||
|
VegaIconNames,
|
||||||
|
} from '@vegaprotocol/ui-toolkit';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { ExternalLink } from '@vegaprotocol/ui-toolkit';
|
import { ExternalLink } from '@vegaprotocol/ui-toolkit';
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
||||||
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
||||||
import type { ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/proposals';
|
import type { ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/proposals';
|
||||||
import { ExternalLinks } from '@vegaprotocol/environment';
|
import { DocsLinks, ExternalLinks } from '@vegaprotocol/environment';
|
||||||
|
import {
|
||||||
|
NetworkParams,
|
||||||
|
useNetworkParams,
|
||||||
|
} from '@vegaprotocol/network-parameters';
|
||||||
|
|
||||||
interface ProposalsListProps {
|
interface ProposalsListProps {
|
||||||
proposals: Array<ProposalFieldsFragment | ProposalQuery['proposal']>;
|
proposals: Array<ProposalFieldsFragment | ProposalQuery['proposal']>;
|
||||||
@@ -50,10 +60,7 @@ export const orderByUpgradeBlockHeight = (
|
|||||||
) =>
|
) =>
|
||||||
orderBy(
|
orderBy(
|
||||||
arr,
|
arr,
|
||||||
[
|
[(p) => p?.upgradeBlockHeight, (p) => p.vegaReleaseTag],
|
||||||
(p) => (p?.upgradeBlockHeight ? parseInt(p.upgradeBlockHeight, 10) : 0),
|
|
||||||
(p) => p.vegaReleaseTag,
|
|
||||||
],
|
|
||||||
['desc', 'desc']
|
['desc', 'desc']
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -68,6 +75,20 @@ export const ProposalsList = ({
|
|||||||
lastBlockHeight,
|
lastBlockHeight,
|
||||||
}: ProposalsListProps) => {
|
}: ProposalsListProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const {
|
||||||
|
params: networkParams,
|
||||||
|
loading: networkParamsLoading,
|
||||||
|
error: networkParamsError,
|
||||||
|
} = useNetworkParams([
|
||||||
|
NetworkParams.governance_proposal_market_requiredMajority,
|
||||||
|
NetworkParams.governance_proposal_updateMarket_requiredMajority,
|
||||||
|
NetworkParams.governance_proposal_updateMarket_requiredMajorityLP,
|
||||||
|
NetworkParams.governance_proposal_asset_requiredMajority,
|
||||||
|
NetworkParams.governance_proposal_updateAsset_requiredMajority,
|
||||||
|
NetworkParams.governance_proposal_updateNetParam_requiredMajority,
|
||||||
|
NetworkParams.governance_proposal_freeform_requiredMajority,
|
||||||
|
]);
|
||||||
|
|
||||||
const [filterString, setFilterString] = useState('');
|
const [filterString, setFilterString] = useState('');
|
||||||
const [closedProposalsView, setClosedProposalsView] =
|
const [closedProposalsView, setClosedProposalsView] =
|
||||||
useState<ClosedProposalsViewOptions>(
|
useState<ClosedProposalsViewOptions>(
|
||||||
@@ -132,161 +153,181 @@ export const ProposalsList = ({
|
|||||||
p?.party?.id?.toString().includes(filterString);
|
p?.party?.id?.toString().includes(filterString);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div data-testid="proposals-list">
|
<AsyncRenderer
|
||||||
<div className="grid xs:grid-cols-2 items-center">
|
loading={networkParamsLoading}
|
||||||
<Heading
|
error={networkParamsError}
|
||||||
centerContent={false}
|
data={networkParams}
|
||||||
marginBottom={false}
|
>
|
||||||
title={t('pageTitleProposals')}
|
<div data-testid="proposals-list">
|
||||||
/>
|
<div className="grid xs:grid-cols-2 items-center">
|
||||||
|
<Heading
|
||||||
|
centerContent={false}
|
||||||
|
marginBottom={false}
|
||||||
|
title={t('pageTitleProposals')}
|
||||||
|
/>
|
||||||
|
|
||||||
<div className="xs:justify-self-end" data-testid="new-proposal-link">
|
{DocsLinks && (
|
||||||
<Link to={`${Routes.PROPOSALS}/propose/raw`}>
|
<div
|
||||||
<Button variant="primary" size="sm">
|
className="xs:justify-self-end"
|
||||||
<div className="flex items-center gap-1">{t('NewProposal')}</div>
|
data-testid="new-proposal-link"
|
||||||
</Button>
|
>
|
||||||
</Link>
|
<ExternalLink href={DocsLinks.PROPOSALS_GUIDE}>
|
||||||
|
<Button variant="primary" size="sm">
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
{t('NewProposal')}
|
||||||
|
<VegaIcon name={VegaIconNames.OPEN_EXTERNAL} size={13} />
|
||||||
|
</div>
|
||||||
|
</Button>
|
||||||
|
</ExternalLink>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p className="mb-8">
|
<p className="mb-8">
|
||||||
{t(
|
{t(
|
||||||
`The Vega network is governed by the community. View active proposals, vote on them or propose changes to the network. Network upgrades are proposed and approved by validators.`
|
`The Vega network is governed by the community. View active proposals, vote on them or propose changes to the network. Network upgrades are proposed and approved by validators.`
|
||||||
)}{' '}
|
)}{' '}
|
||||||
<ExternalLink
|
<ExternalLink
|
||||||
data-testid="proposal-documentation-link"
|
data-testid="proposal-documentation-link"
|
||||||
href={ExternalLinks.GOVERNANCE_PAGE}
|
href={ExternalLinks.GOVERNANCE_PAGE}
|
||||||
className="text-white"
|
className="text-white"
|
||||||
>
|
>
|
||||||
{t(`Find out more about Vega governance`)}
|
{t(`Find out more about Vega governance`)}
|
||||||
</ExternalLink>
|
</ExternalLink>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{proposals.length > 0 && (
|
{proposals.length > 0 && (
|
||||||
<ProposalsListFilter
|
<ProposalsListFilter
|
||||||
filterString={filterString}
|
filterString={filterString}
|
||||||
setFilterString={(value) => {
|
setFilterString={(value) => {
|
||||||
setFilterString(value);
|
setFilterString(value);
|
||||||
if (value.length > 0) {
|
if (value.length > 0) {
|
||||||
// If the filter is engaged, ensure the user is viewing governance proposals,
|
// If the filter is engaged, ensure the user is viewing governance proposals,
|
||||||
// as network upgrades do not have IDs to filter by and will be excluded.
|
// as network upgrades do not have IDs to filter by and will be excluded.
|
||||||
setClosedProposalsView(
|
setClosedProposalsView(
|
||||||
ClosedProposalsViewOptions.NetworkGovernance
|
ClosedProposalsViewOptions.NetworkGovernance
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<section className="-mx-4 p-4 mb-8 bg-vega-dark-100">
|
<section className="-mx-4 p-4 mb-8 bg-vega-dark-100">
|
||||||
<SubHeading title={t('openProposals')} />
|
<SubHeading title={t('openProposals')} />
|
||||||
|
|
||||||
{sortedProposals.open.length > 0 ||
|
{sortedProposals.open.length > 0 ||
|
||||||
sortedProtocolUpgradeProposals.open.length > 0 ? (
|
sortedProtocolUpgradeProposals.open.length > 0 ? (
|
||||||
<ul data-testid="open-proposals">
|
<ul data-testid="open-proposals">
|
||||||
{filterString.length < 1 &&
|
{filterString.length < 1 &&
|
||||||
sortedProtocolUpgradeProposals.open.map((proposal) => (
|
sortedProtocolUpgradeProposals.open.map((proposal) => (
|
||||||
<ProtocolUpgradeProposalsListItem
|
<ProtocolUpgradeProposalsListItem
|
||||||
key={proposal.upgradeBlockHeight}
|
key={proposal.upgradeBlockHeight}
|
||||||
|
proposal={proposal}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
|
||||||
|
{sortedProposals.open.filter(filterPredicate).map((proposal) => (
|
||||||
|
<ProposalsListItem
|
||||||
|
key={proposal?.id}
|
||||||
proposal={proposal}
|
proposal={proposal}
|
||||||
|
networkParams={networkParams}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
</ul>
|
||||||
|
) : (
|
||||||
|
<p className="mb-0" data-testid="no-open-proposals">
|
||||||
|
{t('noOpenProposals')}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
|
|
||||||
{sortedProposals.open.filter(filterPredicate).map((proposal) => (
|
<section className="relative">
|
||||||
<ProposalsListItem key={proposal?.id} proposal={proposal} />
|
<SubHeading title={t('closedProposals')} />
|
||||||
))}
|
{sortedProposals.closed.length > 0 ||
|
||||||
</ul>
|
sortedProtocolUpgradeProposals.closed.length > 0 ? (
|
||||||
) : (
|
<>
|
||||||
<p className="mb-0" data-testid="no-open-proposals">
|
{
|
||||||
{t('noOpenProposals')}
|
// We need both the closed proposals and closed protocol upgrade
|
||||||
</p>
|
// proposals to be present for there to be a toggle. It also gets
|
||||||
)}
|
// hidden if the user has filtered the list, as the upgrade proposals
|
||||||
</section>
|
// do not have the necessary fields for filtering.
|
||||||
|
sortedProposals.closed.length > 0 &&
|
||||||
<section className="relative">
|
sortedProtocolUpgradeProposals.closed.length > 0 &&
|
||||||
<SubHeading title={t('closedProposals')} />
|
filterString.length < 1 && (
|
||||||
{sortedProposals.closed.length > 0 ||
|
<div
|
||||||
sortedProtocolUpgradeProposals.closed.length > 0 ? (
|
className="grid w-full justify-end xl:-mt-12 pb-6"
|
||||||
<>
|
data-testid="toggle-closed-proposals"
|
||||||
{
|
>
|
||||||
// We need both the closed proposals and closed protocol upgrade
|
<div className="w-[440px]">
|
||||||
// proposals to be present for there to be a toggle. It also gets
|
<Toggle
|
||||||
// hidden if the user has filtered the list, as the upgrade proposals
|
name="closed-proposals-toggle"
|
||||||
// do not have the necessary fields for filtering.
|
toggles={[
|
||||||
sortedProposals.closed.length > 0 &&
|
{
|
||||||
sortedProtocolUpgradeProposals.closed.length > 0 &&
|
label: t(
|
||||||
filterString.length < 1 && (
|
ClosedProposalsViewOptions.NetworkGovernance
|
||||||
<div
|
),
|
||||||
className="flex justify-end xl:-mt-12 pb-6"
|
value:
|
||||||
data-testid="toggle-closed-proposals"
|
ClosedProposalsViewOptions.NetworkGovernance,
|
||||||
>
|
},
|
||||||
<div className="w-full max-w-[420px]">
|
{
|
||||||
<Toggle
|
label: t(
|
||||||
name="closed-proposals-toggle"
|
ClosedProposalsViewOptions.NetworkUpgrades
|
||||||
toggles={[
|
),
|
||||||
{
|
value: ClosedProposalsViewOptions.NetworkUpgrades,
|
||||||
label: t(
|
},
|
||||||
ClosedProposalsViewOptions.NetworkGovernance
|
]}
|
||||||
),
|
checkedValue={closedProposalsView}
|
||||||
value: ClosedProposalsViewOptions.NetworkGovernance,
|
onChange={(e) =>
|
||||||
},
|
setClosedProposalsView(
|
||||||
{
|
e.target.value as ClosedProposalsViewOptions
|
||||||
label: t(
|
)
|
||||||
ClosedProposalsViewOptions.NetworkUpgrades
|
}
|
||||||
),
|
/>
|
||||||
value: ClosedProposalsViewOptions.NetworkUpgrades,
|
</div>
|
||||||
},
|
|
||||||
]}
|
|
||||||
checkedValue={closedProposalsView}
|
|
||||||
onChange={(e) =>
|
|
||||||
setClosedProposalsView(
|
|
||||||
e.target.value as ClosedProposalsViewOptions
|
|
||||||
)
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
)
|
||||||
)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
<ul data-testid="closed-proposals">
|
<ul data-testid="closed-proposals">
|
||||||
{closedProposalsView ===
|
{closedProposalsView ===
|
||||||
ClosedProposalsViewOptions.NetworkUpgrades && (
|
ClosedProposalsViewOptions.NetworkUpgrades && (
|
||||||
<div data-testid="closed-upgrade-proposals">
|
<div data-testid="closed-upgrade-proposals">
|
||||||
{sortedProtocolUpgradeProposals.closed.map((proposal) => (
|
{sortedProtocolUpgradeProposals.closed.map((proposal) => (
|
||||||
<ProtocolUpgradeProposalsListItem
|
<ProtocolUpgradeProposalsListItem
|
||||||
key={proposal.upgradeBlockHeight}
|
key={proposal.upgradeBlockHeight}
|
||||||
proposal={proposal}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{closedProposalsView ===
|
|
||||||
ClosedProposalsViewOptions.NetworkGovernance && (
|
|
||||||
<div data-testid="closed-governance-proposals">
|
|
||||||
{sortedProposals.closed
|
|
||||||
.filter(filterPredicate)
|
|
||||||
.map((proposal) => (
|
|
||||||
<ProposalsListItem
|
|
||||||
key={proposal?.id}
|
|
||||||
proposal={proposal}
|
proposal={proposal}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</ul>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<p className="mb-0" data-testid="no-closed-proposals">
|
|
||||||
{t('noClosedProposals')}
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<Link className="underline" to={Routes.PROPOSALS_REJECTED}>
|
{closedProposalsView ===
|
||||||
{t('seeRejectedProposals')}
|
ClosedProposalsViewOptions.NetworkGovernance && (
|
||||||
</Link>
|
<div data-testid="closed-governance-proposals">
|
||||||
</div>
|
{sortedProposals.closed
|
||||||
|
.filter(filterPredicate)
|
||||||
|
.map((proposal) => (
|
||||||
|
<ProposalsListItem
|
||||||
|
key={proposal?.id}
|
||||||
|
proposal={proposal}
|
||||||
|
networkParams={networkParams}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</ul>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<p className="mb-0" data-testid="no-closed-proposals">
|
||||||
|
{t('noClosedProposals')}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<Link className="underline" to={Routes.PROPOSALS_REJECTED}>
|
||||||
|
{t('seeRejectedProposals')}
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</AsyncRenderer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
+29
-3
@@ -1,10 +1,15 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
|
||||||
import { Heading } from '../../../../components/heading';
|
import { Heading } from '../../../../components/heading';
|
||||||
import { ProposalsListItem } from '../proposals-list-item';
|
import { ProposalsListItem } from '../proposals-list-item';
|
||||||
import { ProposalsListFilter } from '../proposals-list-filter';
|
import { ProposalsListFilter } from '../proposals-list-filter';
|
||||||
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
||||||
|
import {
|
||||||
|
NetworkParams,
|
||||||
|
useNetworkParams,
|
||||||
|
} from '@vegaprotocol/network-parameters';
|
||||||
|
|
||||||
interface ProposalsListProps {
|
interface ProposalsListProps {
|
||||||
proposals: Array<ProposalQuery['proposal'] | ProposalFieldsFragment>;
|
proposals: Array<ProposalQuery['proposal'] | ProposalFieldsFragment>;
|
||||||
@@ -12,6 +17,19 @@ interface ProposalsListProps {
|
|||||||
|
|
||||||
export const RejectedProposalsList = ({ proposals }: ProposalsListProps) => {
|
export const RejectedProposalsList = ({ proposals }: ProposalsListProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const {
|
||||||
|
params: networkParams,
|
||||||
|
loading: networkParamsLoading,
|
||||||
|
error: networkParamsError,
|
||||||
|
} = useNetworkParams([
|
||||||
|
NetworkParams.governance_proposal_market_requiredMajority,
|
||||||
|
NetworkParams.governance_proposal_updateMarket_requiredMajority,
|
||||||
|
NetworkParams.governance_proposal_updateMarket_requiredMajorityLP,
|
||||||
|
NetworkParams.governance_proposal_asset_requiredMajority,
|
||||||
|
NetworkParams.governance_proposal_updateAsset_requiredMajority,
|
||||||
|
NetworkParams.governance_proposal_updateNetParam_requiredMajority,
|
||||||
|
NetworkParams.governance_proposal_freeform_requiredMajority,
|
||||||
|
]);
|
||||||
const [filterString, setFilterString] = useState('');
|
const [filterString, setFilterString] = useState('');
|
||||||
|
|
||||||
const filterPredicate = (
|
const filterPredicate = (
|
||||||
@@ -21,7 +39,11 @@ export const RejectedProposalsList = ({ proposals }: ProposalsListProps) => {
|
|||||||
p?.party?.id?.toString().includes(filterString);
|
p?.party?.id?.toString().includes(filterString);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<AsyncRenderer
|
||||||
|
loading={networkParamsLoading}
|
||||||
|
error={networkParamsError}
|
||||||
|
data={networkParams}
|
||||||
|
>
|
||||||
<Heading title={t('pageTitleRejectedProposals')} />
|
<Heading title={t('pageTitleRejectedProposals')} />
|
||||||
<ProposalsListFilter
|
<ProposalsListFilter
|
||||||
filterString={filterString}
|
filterString={filterString}
|
||||||
@@ -31,7 +53,11 @@ export const RejectedProposalsList = ({ proposals }: ProposalsListProps) => {
|
|||||||
{proposals.length > 0 ? (
|
{proposals.length > 0 ? (
|
||||||
<ul data-testid="rejected-proposals">
|
<ul data-testid="rejected-proposals">
|
||||||
{proposals.filter(filterPredicate).map((proposal) => (
|
{proposals.filter(filterPredicate).map((proposal) => (
|
||||||
<ProposalsListItem key={proposal?.id} proposal={proposal} />
|
<ProposalsListItem
|
||||||
|
key={proposal?.id}
|
||||||
|
proposal={proposal}
|
||||||
|
networkParams={networkParams}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
) : (
|
) : (
|
||||||
@@ -40,6 +66,6 @@ export const RejectedProposalsList = ({ proposals }: ProposalsListProps) => {
|
|||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
</section>
|
</section>
|
||||||
</>
|
</AsyncRenderer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
@@ -67,7 +67,7 @@ export const ProtocolUpgradeProposalsListItem = ({
|
|||||||
<Link
|
<Link
|
||||||
to={`${Routes.PROTOCOL_UPGRADES}/${stripFullStops(
|
to={`${Routes.PROTOCOL_UPGRADES}/${stripFullStops(
|
||||||
proposal.vegaReleaseTag
|
proposal.vegaReleaseTag
|
||||||
)}/${proposal.upgradeBlockHeight}`}
|
)}`}
|
||||||
>
|
>
|
||||||
<Button data-testid="view-proposal-btn">{t('viewDetails')}</Button>
|
<Button data-testid="view-proposal-btn">{t('viewDetails')}</Button>
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
export * from './vote-breakdown';
|
|
||||||
-348
@@ -1,348 +0,0 @@
|
|||||||
import { render, screen } from '@testing-library/react';
|
|
||||||
import { BrowserRouter as Router } from 'react-router-dom';
|
|
||||||
import { MockedProvider } from '@apollo/client/testing';
|
|
||||||
import { VegaWalletContext } from '@vegaprotocol/wallet';
|
|
||||||
import {
|
|
||||||
lastWeek,
|
|
||||||
mockWalletContext,
|
|
||||||
networkParamsQueryMock,
|
|
||||||
nextWeek,
|
|
||||||
} from '../../test-helpers/mocks';
|
|
||||||
import { VoteBreakdown } from './vote-breakdown';
|
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
|
||||||
import type { MockedResponse } from '@apollo/client/testing';
|
|
||||||
import {
|
|
||||||
generateNoVotes,
|
|
||||||
generateProposal,
|
|
||||||
generateYesVotes,
|
|
||||||
} from '../../test-helpers/generate-proposals';
|
|
||||||
import { ProposalState } from '@vegaprotocol/types';
|
|
||||||
import { BigNumber } from '../../../../lib/bignumber';
|
|
||||||
import type { AppState } from '../../../../contexts/app-state/app-state-context';
|
|
||||||
|
|
||||||
const mockTotalSupply = new BigNumber(100);
|
|
||||||
// Note - giving a fixedTokenValue of 1 means a ratio of 1:1 votes to tokens, making sums easier :)
|
|
||||||
const fixedTokenValue = 1000000000000000000;
|
|
||||||
|
|
||||||
const mockAppState: AppState = {
|
|
||||||
totalAssociated: new BigNumber('50063005'),
|
|
||||||
decimals: 18,
|
|
||||||
totalSupply: mockTotalSupply,
|
|
||||||
vegaWalletManageOverlay: false,
|
|
||||||
transactionOverlay: false,
|
|
||||||
bannerMessage: '',
|
|
||||||
disconnectNotice: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
jest.mock('../../../../contexts/app-state/app-state-context', () => ({
|
|
||||||
useAppState: () => ({
|
|
||||||
appState: mockAppState,
|
|
||||||
}),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const renderComponent = (
|
|
||||||
proposal: ProposalQuery['proposal'],
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
mocks: MockedResponse<any>[] = [networkParamsQueryMock]
|
|
||||||
) =>
|
|
||||||
render(
|
|
||||||
<Router>
|
|
||||||
<MockedProvider mocks={mocks}>
|
|
||||||
<VegaWalletContext.Provider value={mockWalletContext}>
|
|
||||||
<VoteBreakdown proposal={proposal} />
|
|
||||||
</VegaWalletContext.Provider>
|
|
||||||
</MockedProvider>
|
|
||||||
</Router>
|
|
||||||
);
|
|
||||||
|
|
||||||
describe('VoteBreakdown', () => {
|
|
||||||
beforeAll(() => {
|
|
||||||
jest.useFakeTimers();
|
|
||||||
jest.setSystemTime(0);
|
|
||||||
});
|
|
||||||
afterAll(() => {
|
|
||||||
jest.useRealTimers();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Renders majority reached', () => {
|
|
||||||
const yesVotes = 100;
|
|
||||||
const noVotes = 0;
|
|
||||||
|
|
||||||
renderComponent(
|
|
||||||
generateProposal({
|
|
||||||
state: ProposalState.STATE_PASSED,
|
|
||||||
terms: {
|
|
||||||
closingDatetime: lastWeek.toString(),
|
|
||||||
enactmentDatetime: nextWeek.toString(),
|
|
||||||
},
|
|
||||||
votes: {
|
|
||||||
__typename: 'ProposalVotes',
|
|
||||||
yes: generateYesVotes(yesVotes, fixedTokenValue),
|
|
||||||
no: generateNoVotes(noVotes, fixedTokenValue),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
expect(screen.getByTestId('token-majority-met')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Renders majority not reached', () => {
|
|
||||||
const yesVotes = 20;
|
|
||||||
const noVotes = 80;
|
|
||||||
|
|
||||||
renderComponent(
|
|
||||||
generateProposal({
|
|
||||||
state: ProposalState.STATE_PASSED,
|
|
||||||
terms: {
|
|
||||||
closingDatetime: lastWeek.toString(),
|
|
||||||
enactmentDatetime: nextWeek.toString(),
|
|
||||||
},
|
|
||||||
votes: {
|
|
||||||
__typename: 'ProposalVotes',
|
|
||||||
yes: generateYesVotes(yesVotes, fixedTokenValue),
|
|
||||||
no: generateNoVotes(noVotes, fixedTokenValue),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
expect(screen.getByTestId('token-majority-not-met')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Renders participation reached', () => {
|
|
||||||
const yesVotes = 1000;
|
|
||||||
const noVotes = 0;
|
|
||||||
|
|
||||||
renderComponent(
|
|
||||||
generateProposal({
|
|
||||||
state: ProposalState.STATE_PASSED,
|
|
||||||
terms: {
|
|
||||||
closingDatetime: lastWeek.toString(),
|
|
||||||
enactmentDatetime: nextWeek.toString(),
|
|
||||||
},
|
|
||||||
votes: {
|
|
||||||
__typename: 'ProposalVotes',
|
|
||||||
yes: generateYesVotes(yesVotes, fixedTokenValue),
|
|
||||||
no: generateNoVotes(noVotes, fixedTokenValue),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
expect(screen.getByTestId('token-participation-met')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Renders participation not reached', () => {
|
|
||||||
const yesVotes = 0;
|
|
||||||
const noVotes = 0;
|
|
||||||
|
|
||||||
renderComponent(
|
|
||||||
generateProposal({
|
|
||||||
terms: {
|
|
||||||
closingDatetime: lastWeek.toString(),
|
|
||||||
enactmentDatetime: nextWeek.toString(),
|
|
||||||
},
|
|
||||||
votes: {
|
|
||||||
__typename: 'ProposalVotes',
|
|
||||||
yes: generateYesVotes(yesVotes, fixedTokenValue),
|
|
||||||
no: generateNoVotes(noVotes, fixedTokenValue),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
expect(
|
|
||||||
screen.getByTestId('token-participation-not-met')
|
|
||||||
).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Renders proposal state: Update market proposal - Currently expected to pass by LP vote', () => {
|
|
||||||
renderComponent(
|
|
||||||
generateProposal({
|
|
||||||
state: ProposalState.STATE_OPEN,
|
|
||||||
terms: {
|
|
||||||
change: {
|
|
||||||
__typename: 'UpdateMarket',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
votes: {
|
|
||||||
yes: {
|
|
||||||
...generateYesVotes(0),
|
|
||||||
totalEquityLikeShareWeight: '1000',
|
|
||||||
},
|
|
||||||
no: {
|
|
||||||
...generateNoVotes(0),
|
|
||||||
totalEquityLikeShareWeight: '0',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
expect(screen.getByTestId('vote-status')).toHaveTextContent(
|
|
||||||
'Currently expected to pass by liquidity vote'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Renders proposal state: Update market proposal - Currently expected to pass by token vote', () => {
|
|
||||||
renderComponent(
|
|
||||||
generateProposal({
|
|
||||||
state: ProposalState.STATE_OPEN,
|
|
||||||
terms: {
|
|
||||||
change: {
|
|
||||||
__typename: 'UpdateMarket',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
votes: {
|
|
||||||
yes: {
|
|
||||||
...generateYesVotes(1000, fixedTokenValue),
|
|
||||||
totalEquityLikeShareWeight: '0',
|
|
||||||
},
|
|
||||||
no: {
|
|
||||||
...generateNoVotes(0, fixedTokenValue),
|
|
||||||
totalEquityLikeShareWeight: '0',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
expect(screen.getByTestId('vote-status')).toHaveTextContent(
|
|
||||||
'Currently expected to pass by token vote'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Renders proposal state: Update market proposal - Currently expected to fail', () => {
|
|
||||||
renderComponent(
|
|
||||||
generateProposal({
|
|
||||||
state: ProposalState.STATE_OPEN,
|
|
||||||
terms: {
|
|
||||||
change: {
|
|
||||||
__typename: 'UpdateMarket',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
votes: {
|
|
||||||
yes: {
|
|
||||||
...generateYesVotes(0),
|
|
||||||
totalEquityLikeShareWeight: '0',
|
|
||||||
},
|
|
||||||
no: {
|
|
||||||
...generateNoVotes(0),
|
|
||||||
totalEquityLikeShareWeight: '0',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
expect(screen.getByTestId('vote-status')).toHaveTextContent(
|
|
||||||
'Currently expected to fail'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Progress bar displays status - token majority', () => {
|
|
||||||
const yesVotes = 80;
|
|
||||||
const noVotes = 20;
|
|
||||||
|
|
||||||
renderComponent(
|
|
||||||
generateProposal({
|
|
||||||
state: ProposalState.STATE_PASSED,
|
|
||||||
terms: {
|
|
||||||
closingDatetime: lastWeek.toString(),
|
|
||||||
enactmentDatetime: nextWeek.toString(),
|
|
||||||
},
|
|
||||||
votes: {
|
|
||||||
__typename: 'ProposalVotes',
|
|
||||||
yes: generateYesVotes(yesVotes, fixedTokenValue),
|
|
||||||
no: generateNoVotes(noVotes, fixedTokenValue),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
const element = screen.getByTestId('token-majority-progress');
|
|
||||||
const style = window.getComputedStyle(element);
|
|
||||||
|
|
||||||
expect(style.width).toBe(`${yesVotes}%`);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Progress bar displays status - token participation', () => {
|
|
||||||
const yesVotes = 40;
|
|
||||||
const noVotes = 20;
|
|
||||||
const totalVotes = yesVotes + noVotes;
|
|
||||||
const totalSupplyValue = mockTotalSupply.toNumber();
|
|
||||||
const expectedProgress = (totalVotes / totalSupplyValue) * 100; // Here it should be 60%
|
|
||||||
|
|
||||||
renderComponent(
|
|
||||||
generateProposal({
|
|
||||||
state: ProposalState.STATE_PASSED,
|
|
||||||
terms: {
|
|
||||||
closingDatetime: lastWeek.toString(),
|
|
||||||
enactmentDatetime: nextWeek.toString(),
|
|
||||||
},
|
|
||||||
votes: {
|
|
||||||
__typename: 'ProposalVotes',
|
|
||||||
yes: generateYesVotes(yesVotes, fixedTokenValue),
|
|
||||||
no: generateNoVotes(noVotes, fixedTokenValue),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
const element = screen.getByTestId('token-participation-progress');
|
|
||||||
const style = window.getComputedStyle(element);
|
|
||||||
|
|
||||||
expect(style.width).toBe(`${expectedProgress}%`);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Progress bar displays status - LP majority', () => {
|
|
||||||
const yesVotesLP = 800;
|
|
||||||
const noVotesLP = 200;
|
|
||||||
const expectedProgress = (yesVotesLP / (yesVotesLP + noVotesLP)) * 100; // 80%
|
|
||||||
|
|
||||||
renderComponent(
|
|
||||||
generateProposal({
|
|
||||||
state: ProposalState.STATE_PASSED,
|
|
||||||
terms: {
|
|
||||||
change: {
|
|
||||||
__typename: 'UpdateMarket',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
votes: {
|
|
||||||
__typename: 'ProposalVotes',
|
|
||||||
yes: {
|
|
||||||
...generateYesVotes(0),
|
|
||||||
totalEquityLikeShareWeight: `${yesVotesLP}`,
|
|
||||||
},
|
|
||||||
no: {
|
|
||||||
...generateNoVotes(0),
|
|
||||||
totalEquityLikeShareWeight: `${noVotesLP}`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
const element = screen.getByTestId('lp-majority-progress');
|
|
||||||
const style = window.getComputedStyle(element);
|
|
||||||
expect(style.width).toBe(`${expectedProgress}%`);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Progress bar displays status - LP participation', () => {
|
|
||||||
const yesVotesLP = 400;
|
|
||||||
const noVotesLP = 600;
|
|
||||||
const totalVotesLP = yesVotesLP + noVotesLP;
|
|
||||||
const totalLPSupply = 1000;
|
|
||||||
const expectedProgress = (totalVotesLP / totalLPSupply) * 100; // 100%
|
|
||||||
|
|
||||||
renderComponent(
|
|
||||||
generateProposal({
|
|
||||||
state: ProposalState.STATE_PASSED,
|
|
||||||
terms: {
|
|
||||||
change: {
|
|
||||||
__typename: 'UpdateMarket',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
votes: {
|
|
||||||
__typename: 'ProposalVotes',
|
|
||||||
yes: {
|
|
||||||
...generateYesVotes(0),
|
|
||||||
totalEquityLikeShareWeight: `${yesVotesLP}`,
|
|
||||||
},
|
|
||||||
no: {
|
|
||||||
...generateNoVotes(0),
|
|
||||||
totalEquityLikeShareWeight: `${noVotesLP}`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
const element = screen.getByTestId('lp-participation-progress');
|
|
||||||
const style = window.getComputedStyle(element);
|
|
||||||
expect(style.width).toBe(`${expectedProgress}%`);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,399 +0,0 @@
|
|||||||
import classNames from 'classnames';
|
|
||||||
import BigNumber from 'bignumber.js';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
import { useVoteInformation } from '../../hooks';
|
|
||||||
import { Icon, Tooltip } from '@vegaprotocol/ui-toolkit';
|
|
||||||
import { formatNumber, toBigNum } from '@vegaprotocol/utils';
|
|
||||||
import { ProposalState } from '@vegaprotocol/types';
|
|
||||||
import type { ReactNode } from 'react';
|
|
||||||
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
|
||||||
|
|
||||||
interface VoteBreakdownProps {
|
|
||||||
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface VoteProgressProps {
|
|
||||||
percentageFor: BigNumber;
|
|
||||||
colourfulBg?: boolean;
|
|
||||||
testId?: string;
|
|
||||||
children?: ReactNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
const VoteProgress = ({
|
|
||||||
percentageFor,
|
|
||||||
colourfulBg,
|
|
||||||
testId,
|
|
||||||
children,
|
|
||||||
}: VoteProgressProps) => {
|
|
||||||
const containerClasses = classNames(
|
|
||||||
'relative h-10 rounded-md border border-vega-dark-300 overflow-hidden',
|
|
||||||
colourfulBg ? 'bg-vega-pink' : 'bg-vega-dark-400'
|
|
||||||
);
|
|
||||||
|
|
||||||
const progressClasses = classNames(
|
|
||||||
'absolute h-full top-0 left-0',
|
|
||||||
colourfulBg ? 'bg-vega-green' : 'bg-white'
|
|
||||||
);
|
|
||||||
|
|
||||||
const textClasses = classNames(
|
|
||||||
'absolute top-0 left-0 w-full h-full flex items-center justify-start px-3 text-black'
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={containerClasses}>
|
|
||||||
<div
|
|
||||||
className={progressClasses}
|
|
||||||
style={{ width: `${percentageFor}%` }}
|
|
||||||
data-testid={testId}
|
|
||||||
></div>
|
|
||||||
<div className={textClasses}>{children}</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
interface StatusProps {
|
|
||||||
reached: boolean;
|
|
||||||
threshold: BigNumber;
|
|
||||||
text: string;
|
|
||||||
testId?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Status = ({ reached, threshold, text, testId }: StatusProps) => {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div data-testid={testId}>
|
|
||||||
{reached ? (
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<Icon name="tick" size={4} />
|
|
||||||
<span>
|
|
||||||
{threshold.toString()}% {text} {t('met')}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<Icon name="cross" size={4} />
|
|
||||||
<span>
|
|
||||||
{threshold.toString()}% {text} {t('not met')}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const VoteBreakdown = ({ proposal }: VoteBreakdownProps) => {
|
|
||||||
const {
|
|
||||||
totalTokensPercentage,
|
|
||||||
participationMet,
|
|
||||||
totalTokensVoted,
|
|
||||||
totalLPTokensPercentage,
|
|
||||||
noPercentage,
|
|
||||||
noLPPercentage,
|
|
||||||
yesPercentage,
|
|
||||||
yesLPPercentage,
|
|
||||||
yesTokens,
|
|
||||||
noTokens,
|
|
||||||
yesEquityLikeShareWeight,
|
|
||||||
noEquityLikeShareWeight,
|
|
||||||
totalEquityLikeShareWeight,
|
|
||||||
requiredMajorityPercentage,
|
|
||||||
requiredMajorityLPPercentage,
|
|
||||||
requiredParticipation,
|
|
||||||
requiredParticipationLP,
|
|
||||||
participationLPMet,
|
|
||||||
majorityMet,
|
|
||||||
majorityLPMet,
|
|
||||||
willPassByTokenVote,
|
|
||||||
willPassByLPVote,
|
|
||||||
} = useVoteInformation({ proposal });
|
|
||||||
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const defaultDP = 2;
|
|
||||||
const isProposalOpen = proposal?.state === ProposalState.STATE_OPEN;
|
|
||||||
const isUpdateMarket = proposal?.terms?.change?.__typename === 'UpdateMarket';
|
|
||||||
const participationThresholdProgress = BigNumber.min(
|
|
||||||
totalTokensPercentage.dividedBy(requiredParticipation).multipliedBy(100),
|
|
||||||
new BigNumber(100)
|
|
||||||
);
|
|
||||||
const lpParticipationThresholdProgress =
|
|
||||||
requiredParticipationLP &&
|
|
||||||
BigNumber.min(
|
|
||||||
totalLPTokensPercentage
|
|
||||||
.dividedBy(requiredParticipationLP)
|
|
||||||
.multipliedBy(100),
|
|
||||||
new BigNumber(100)
|
|
||||||
);
|
|
||||||
const willPass = willPassByTokenVote || willPassByLPVote;
|
|
||||||
const updateMarketVotePassMethod = willPassByTokenVote
|
|
||||||
? t('byTokenVote')
|
|
||||||
: t('byLiquidityVote');
|
|
||||||
|
|
||||||
const sectionWrapperClasses = classNames(
|
|
||||||
'flex justify-between flex-wrap gap-6'
|
|
||||||
);
|
|
||||||
const sectionClasses = classNames('min-w-[300px] flex-1 flex-grow');
|
|
||||||
const headingClasses = classNames('mb-2 text-vega-dark-400');
|
|
||||||
const progressDetailsClasses = classNames(
|
|
||||||
'flex justify-between flex-wrap mt-2 text-sm'
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="mb-6">
|
|
||||||
{isProposalOpen && (
|
|
||||||
<div
|
|
||||||
data-testid="vote-status"
|
|
||||||
className="flex items-center gap-1 mb-2 text-bold"
|
|
||||||
>
|
|
||||||
<span>
|
|
||||||
{willPass ? (
|
|
||||||
<Icon name="tick" size={5} className="text-vega-green" />
|
|
||||||
) : (
|
|
||||||
<Icon name="cross" size={5} className="text-vega-pink" />
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
<span>{t('currentlySetTo')} </span>
|
|
||||||
{willPass ? (
|
|
||||||
<span>
|
|
||||||
<span className="text-vega-green">{t('pass')}</span>
|
|
||||||
{isUpdateMarket && <span> {updateMarketVotePassMethod}</span>}
|
|
||||||
</span>
|
|
||||||
) : (
|
|
||||||
<span className="text-vega-pink">{t('fail')}</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{isUpdateMarket && (
|
|
||||||
<div className="mb-4">
|
|
||||||
<h3 className={headingClasses}>{t('liquidityProviderVote')}</h3>
|
|
||||||
<div className={sectionWrapperClasses}>
|
|
||||||
<section
|
|
||||||
className={sectionClasses}
|
|
||||||
data-testid="lp-majority-breakdown"
|
|
||||||
>
|
|
||||||
<VoteProgress
|
|
||||||
percentageFor={yesLPPercentage}
|
|
||||||
colourfulBg={true}
|
|
||||||
testId="lp-majority-progress"
|
|
||||||
>
|
|
||||||
<Status
|
|
||||||
reached={majorityLPMet}
|
|
||||||
threshold={requiredMajorityLPPercentage}
|
|
||||||
text={t('majorityThreshold')}
|
|
||||||
testId={
|
|
||||||
majorityLPMet ? 'lp-majority-met' : 'lp-majority-not-met'
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</VoteProgress>
|
|
||||||
|
|
||||||
<div className={progressDetailsClasses}>
|
|
||||||
<div className="flex items-center gap-1">
|
|
||||||
<span>{t('liquidityProviderVotesFor')}:</span>
|
|
||||||
<Tooltip
|
|
||||||
description={formatNumber(
|
|
||||||
yesEquityLikeShareWeight,
|
|
||||||
defaultDP
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<button>
|
|
||||||
{yesEquityLikeShareWeight
|
|
||||||
.dividedBy(toBigNum(10 ** 6, 0))
|
|
||||||
.toFixed(1)}
|
|
||||||
M
|
|
||||||
</button>
|
|
||||||
</Tooltip>
|
|
||||||
<span>
|
|
||||||
(
|
|
||||||
<Tooltip
|
|
||||||
description={
|
|
||||||
<span>{yesLPPercentage.toFixed(defaultDP)}%</span>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<button>{yesLPPercentage.toFixed(0)}%</button>
|
|
||||||
</Tooltip>
|
|
||||||
)
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex items-center gap-1">
|
|
||||||
<span>{t('liquidityProviderVotesAgainst')}:</span>
|
|
||||||
<Tooltip
|
|
||||||
description={formatNumber(
|
|
||||||
noEquityLikeShareWeight,
|
|
||||||
defaultDP
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<button>
|
|
||||||
{noEquityLikeShareWeight
|
|
||||||
.dividedBy(toBigNum(10 ** 6, 0))
|
|
||||||
.toFixed(1)}
|
|
||||||
M
|
|
||||||
</button>
|
|
||||||
</Tooltip>
|
|
||||||
<span>
|
|
||||||
(
|
|
||||||
<Tooltip
|
|
||||||
description={
|
|
||||||
<span>{noLPPercentage.toFixed(defaultDP)}%</span>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<button>{noLPPercentage.toFixed(0)}%</button>
|
|
||||||
</Tooltip>
|
|
||||||
)
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section
|
|
||||||
className={sectionClasses}
|
|
||||||
data-testid="lp-participation-breakdown"
|
|
||||||
>
|
|
||||||
<VoteProgress
|
|
||||||
percentageFor={
|
|
||||||
lpParticipationThresholdProgress || new BigNumber(0)
|
|
||||||
}
|
|
||||||
testId="lp-participation-progress"
|
|
||||||
>
|
|
||||||
<Status
|
|
||||||
reached={participationLPMet}
|
|
||||||
threshold={requiredParticipationLP || new BigNumber(1)}
|
|
||||||
text={t('participationThreshold')}
|
|
||||||
testId={
|
|
||||||
participationLPMet
|
|
||||||
? 'lp-participation-met'
|
|
||||||
: 'lp-participation-not-met'
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</VoteProgress>
|
|
||||||
|
|
||||||
<div className="flex mt-2 text-sm">
|
|
||||||
<div className="flex items-center gap-1">
|
|
||||||
<span>{t('totalLiquidityProviderTokensVoted')}:</span>
|
|
||||||
<Tooltip
|
|
||||||
description={formatNumber(
|
|
||||||
totalEquityLikeShareWeight,
|
|
||||||
defaultDP
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<button>
|
|
||||||
{totalEquityLikeShareWeight
|
|
||||||
.dividedBy(toBigNum(10 ** 6, 0))
|
|
||||||
.toFixed(1)}
|
|
||||||
M
|
|
||||||
</button>
|
|
||||||
</Tooltip>
|
|
||||||
<span>
|
|
||||||
({totalEquityLikeShareWeight.toFixed(defaultDP)}%)
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{isUpdateMarket && <h3 className={headingClasses}>{t('tokenVote')}</h3>}
|
|
||||||
<div className={sectionWrapperClasses}>
|
|
||||||
<section
|
|
||||||
className={sectionClasses}
|
|
||||||
data-testid="token-majority-breakdown"
|
|
||||||
>
|
|
||||||
<VoteProgress
|
|
||||||
percentageFor={yesPercentage}
|
|
||||||
colourfulBg={true}
|
|
||||||
testId="token-majority-progress"
|
|
||||||
>
|
|
||||||
<Status
|
|
||||||
reached={majorityMet}
|
|
||||||
threshold={requiredMajorityPercentage}
|
|
||||||
text={t('majorityThreshold')}
|
|
||||||
testId={
|
|
||||||
majorityMet ? 'token-majority-met' : 'token-majority-not-met'
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</VoteProgress>
|
|
||||||
|
|
||||||
<div className={progressDetailsClasses}>
|
|
||||||
<div className="flex items-center gap-1">
|
|
||||||
<span>{t('tokenVotesFor')}:</span>
|
|
||||||
<Tooltip description={formatNumber(yesTokens, defaultDP)}>
|
|
||||||
<button data-testid="num-votes-for">
|
|
||||||
{yesTokens.dividedBy(toBigNum(10 ** 6, 0)).toFixed(1)}M
|
|
||||||
</button>
|
|
||||||
</Tooltip>
|
|
||||||
<span>
|
|
||||||
(
|
|
||||||
<Tooltip
|
|
||||||
description={<span>{yesPercentage.toFixed(defaultDP)}%</span>}
|
|
||||||
>
|
|
||||||
<button data-testid="votes-for-percentage">
|
|
||||||
{yesPercentage.toFixed(0)}%
|
|
||||||
</button>
|
|
||||||
</Tooltip>
|
|
||||||
)
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex items-center gap-1">
|
|
||||||
<span>{t('tokenVotesAgainst')}:</span>
|
|
||||||
<Tooltip description={formatNumber(noTokens, defaultDP)}>
|
|
||||||
<button data-testid="num-votes-against">
|
|
||||||
{noTokens.dividedBy(toBigNum(10 ** 6, 0)).toFixed(1)}M
|
|
||||||
</button>
|
|
||||||
</Tooltip>
|
|
||||||
<span>
|
|
||||||
(
|
|
||||||
<Tooltip
|
|
||||||
description={<span>{noPercentage.toFixed(defaultDP)}%</span>}
|
|
||||||
>
|
|
||||||
<button data-testid="votes-against-percentage">
|
|
||||||
{noPercentage.toFixed(0)}%
|
|
||||||
</button>
|
|
||||||
</Tooltip>
|
|
||||||
)
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section
|
|
||||||
className={sectionClasses}
|
|
||||||
data-testid="token-participation-breakdown"
|
|
||||||
>
|
|
||||||
<VoteProgress
|
|
||||||
percentageFor={participationThresholdProgress}
|
|
||||||
testId="token-participation-progress"
|
|
||||||
>
|
|
||||||
<Status
|
|
||||||
reached={participationMet}
|
|
||||||
threshold={requiredParticipation}
|
|
||||||
text={t('participationThreshold')}
|
|
||||||
testId={
|
|
||||||
participationMet
|
|
||||||
? 'token-participation-met'
|
|
||||||
: 'token-participation-not-met'
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</VoteProgress>
|
|
||||||
|
|
||||||
<div className="flex mt-2 text-sm">
|
|
||||||
<div className="flex items-center gap-1">
|
|
||||||
<span>{t('totalTokensVoted')}:</span>
|
|
||||||
<Tooltip description={formatNumber(totalTokensVoted, defaultDP)}>
|
|
||||||
<button data-testid="total-voted">
|
|
||||||
{totalTokensVoted.dividedBy(toBigNum(10 ** 6, 0)).toFixed(1)}M
|
|
||||||
</button>
|
|
||||||
</Tooltip>
|
|
||||||
<span data-testid="total-voted-percentage">
|
|
||||||
({totalTokensPercentage.toFixed(defaultDP)}%)
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1 +1 @@
|
|||||||
export { UserVote } from './user-vote';
|
export { VoteDetails } from './vote-details';
|
||||||
|
|||||||
@@ -1,78 +0,0 @@
|
|||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
import { Icon, ExternalLink } from '@vegaprotocol/ui-toolkit';
|
|
||||||
import { useVegaWallet } from '@vegaprotocol/wallet';
|
|
||||||
import { ProposalState } from '@vegaprotocol/types';
|
|
||||||
import { ConnectToVega } from '../../../../components/connect-to-vega';
|
|
||||||
import { VoteButtonsContainer } from './vote-buttons';
|
|
||||||
import { SubHeading } from '../../../../components/heading';
|
|
||||||
import type { VoteValue } from '@vegaprotocol/types';
|
|
||||||
import type { DialogProps, VegaTxState } from '@vegaprotocol/wallet';
|
|
||||||
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
|
||||||
import type { VoteState } from './use-user-vote';
|
|
||||||
|
|
||||||
interface UserVoteProps {
|
|
||||||
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
|
|
||||||
minVoterBalance: string | null | undefined;
|
|
||||||
spamProtectionMinTokens: string | null | undefined;
|
|
||||||
transaction: VegaTxState | null;
|
|
||||||
submit: (voteValue: VoteValue, proposalId: string | null) => Promise<void>;
|
|
||||||
dialog: (props: DialogProps) => JSX.Element;
|
|
||||||
voteState: VoteState | null;
|
|
||||||
voteDatetime: Date | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const UserVote = ({
|
|
||||||
proposal,
|
|
||||||
minVoterBalance,
|
|
||||||
spamProtectionMinTokens,
|
|
||||||
submit,
|
|
||||||
transaction,
|
|
||||||
dialog,
|
|
||||||
voteState,
|
|
||||||
voteDatetime,
|
|
||||||
}: UserVoteProps) => {
|
|
||||||
const { pubKey } = useVegaWallet();
|
|
||||||
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section data-testid="user-vote">
|
|
||||||
{proposal?.state === ProposalState.STATE_OPEN ? (
|
|
||||||
<SubHeading title={t('castYourVote')} />
|
|
||||||
) : (
|
|
||||||
<SubHeading title={t('yourVote')} />
|
|
||||||
)}
|
|
||||||
|
|
||||||
{pubKey ? (
|
|
||||||
proposal && (
|
|
||||||
<VoteButtonsContainer
|
|
||||||
voteState={voteState}
|
|
||||||
voteDatetime={voteDatetime}
|
|
||||||
proposalState={proposal.state}
|
|
||||||
proposalId={proposal.id ?? ''}
|
|
||||||
minVoterBalance={minVoterBalance}
|
|
||||||
spamProtectionMinTokens={spamProtectionMinTokens}
|
|
||||||
className="flex"
|
|
||||||
submit={submit}
|
|
||||||
transaction={transaction}
|
|
||||||
dialog={dialog}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
) : (
|
|
||||||
<div className="pb-2">
|
|
||||||
<div className="mb-4">
|
|
||||||
<div className="flex items-center gap-2 mb-2">
|
|
||||||
<Icon name={'info-sign'} />
|
|
||||||
<div>{t('connectAVegaWalletToVote')}</div>
|
|
||||||
</div>
|
|
||||||
<ExternalLink href="https://blog.vega.xyz/how-to-vote-on-vega-2195d1e52ec5">
|
|
||||||
{t('findOutMoreAboutHowToVote')}
|
|
||||||
</ExternalLink>
|
|
||||||
</div>
|
|
||||||
<ConnectToVega />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -190,15 +190,14 @@ export const VoteButtons = ({
|
|||||||
(voteState === VoteState.Yes || voteState === VoteState.No) && (
|
(voteState === VoteState.Yes || voteState === VoteState.No) && (
|
||||||
<p data-testid="you-voted">
|
<p data-testid="you-voted">
|
||||||
<span>{t('youVoted')}:</span>{' '}
|
<span>{t('youVoted')}:</span>{' '}
|
||||||
<span className="mx-1 text-white font-bold uppercase">
|
<span className="text-white font-bold">
|
||||||
{t(`voteState_${voteState}`)}
|
{t(`voteState_${voteState}`)}
|
||||||
</span>{' '}
|
</span>{' '}
|
||||||
{voteDatetime ? (
|
{voteDatetime ? (
|
||||||
<span>on {format(voteDatetime, DATE_FORMAT_LONG)}. </span>
|
<span>{format(voteDatetime, DATE_FORMAT_LONG)}. </span>
|
||||||
) : null}
|
) : null}
|
||||||
{proposalVotable ? (
|
{proposalVotable ? (
|
||||||
<ButtonLink
|
<ButtonLink
|
||||||
className="text-white"
|
|
||||||
data-testid="change-vote-button"
|
data-testid="change-vote-button"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setChangeVote(true);
|
setChangeVote(true);
|
||||||
|
|||||||
@@ -0,0 +1,255 @@
|
|||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { formatDistanceToNow } from 'date-fns';
|
||||||
|
import { RoundedWrapper, Icon, ExternalLink } from '@vegaprotocol/ui-toolkit';
|
||||||
|
import { useVegaWallet } from '@vegaprotocol/wallet';
|
||||||
|
import { ProposalState } from '@vegaprotocol/types';
|
||||||
|
import { VoteProgress } from '@vegaprotocol/proposals';
|
||||||
|
import { formatNumber } from '../../../../lib/format-number';
|
||||||
|
import { ConnectToVega } from '../../../../components/connect-to-vega';
|
||||||
|
import { useVoteInformation } from '../../hooks';
|
||||||
|
import { CurrentProposalStatus } from '../current-proposal-status';
|
||||||
|
import { VoteButtonsContainer } from './vote-buttons';
|
||||||
|
import { SubHeading } from '../../../../components/heading';
|
||||||
|
import { ProposalType } from '../proposal/proposal';
|
||||||
|
import type { VoteValue } from '@vegaprotocol/types';
|
||||||
|
import type { DialogProps, VegaTxState } from '@vegaprotocol/wallet';
|
||||||
|
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
||||||
|
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
||||||
|
import type { VoteState } from './use-user-vote';
|
||||||
|
|
||||||
|
interface VoteDetailsProps {
|
||||||
|
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
|
||||||
|
minVoterBalance: string | null | undefined;
|
||||||
|
spamProtectionMinTokens: string | null | undefined;
|
||||||
|
proposalType: ProposalType | null;
|
||||||
|
transaction: VegaTxState | null;
|
||||||
|
submit: (voteValue: VoteValue, proposalId: string | null) => Promise<void>;
|
||||||
|
dialog: (props: DialogProps) => JSX.Element;
|
||||||
|
voteState: VoteState | null;
|
||||||
|
voteDatetime: Date | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const VoteDetails = ({
|
||||||
|
proposal,
|
||||||
|
minVoterBalance,
|
||||||
|
spamProtectionMinTokens,
|
||||||
|
proposalType,
|
||||||
|
submit,
|
||||||
|
transaction,
|
||||||
|
dialog,
|
||||||
|
voteState,
|
||||||
|
voteDatetime,
|
||||||
|
}: VoteDetailsProps) => {
|
||||||
|
const { pubKey } = useVegaWallet();
|
||||||
|
const {
|
||||||
|
totalTokensPercentage,
|
||||||
|
participationMet,
|
||||||
|
totalTokensVoted,
|
||||||
|
totalLPTokensPercentage,
|
||||||
|
noPercentage,
|
||||||
|
noLPPercentage,
|
||||||
|
yesPercentage,
|
||||||
|
yesLPPercentage,
|
||||||
|
yesTokens,
|
||||||
|
noTokens,
|
||||||
|
requiredMajorityPercentage,
|
||||||
|
requiredMajorityLPPercentage,
|
||||||
|
requiredParticipation,
|
||||||
|
requiredParticipationLP,
|
||||||
|
participationLPMet,
|
||||||
|
} = useVoteInformation({ proposal });
|
||||||
|
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const defaultDecimals = 2;
|
||||||
|
const daysLeft = t('daysLeft', {
|
||||||
|
daysLeft: formatDistanceToNow(new Date(proposal?.terms.closingDatetime)),
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{proposalType === ProposalType.PROPOSAL_UPDATE_MARKET && (
|
||||||
|
<section>
|
||||||
|
<SubHeading title={t('liquidityVotes')} />
|
||||||
|
<p data-testid="liquidity-votes-status">
|
||||||
|
<span>
|
||||||
|
<CurrentProposalStatus proposal={proposal} />
|
||||||
|
</span>
|
||||||
|
{'. '}
|
||||||
|
{proposal?.state === ProposalState.STATE_OPEN ? daysLeft : null}
|
||||||
|
</p>
|
||||||
|
<table className="w-full mb-8">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th className="text-vega-green w-[18%] text-left">
|
||||||
|
{t('for')}
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<VoteProgress
|
||||||
|
threshold={requiredMajorityLPPercentage}
|
||||||
|
progress={yesLPPercentage}
|
||||||
|
/>
|
||||||
|
</th>
|
||||||
|
<th className="text-danger w-[18%] text-right">
|
||||||
|
{t('against')}
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td
|
||||||
|
className="text-left"
|
||||||
|
data-testid="vote-progress-indicator-percentage-for"
|
||||||
|
>
|
||||||
|
{yesLPPercentage.toFixed(defaultDecimals)}%
|
||||||
|
</td>
|
||||||
|
<td className="text-center text-white">
|
||||||
|
{t('majorityRequired')}{' '}
|
||||||
|
{requiredMajorityLPPercentage.toFixed(defaultDecimals)}%
|
||||||
|
</td>
|
||||||
|
<td
|
||||||
|
className="text-right"
|
||||||
|
data-testid="vote-progress-indicator-percentage-against"
|
||||||
|
>
|
||||||
|
{noLPPercentage.toFixed(defaultDecimals)}%
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<p className="mb-6">
|
||||||
|
{t('participation')}
|
||||||
|
{': '}
|
||||||
|
{participationLPMet ? (
|
||||||
|
<span className="text-vega-green mx-4">{t('met')}</span>
|
||||||
|
) : (
|
||||||
|
<span className="text-danger mx-4">{t('notMet')}</span>
|
||||||
|
)}{' '}
|
||||||
|
{formatNumber(totalLPTokensPercentage, defaultDecimals)}%
|
||||||
|
<span className="ml-4">
|
||||||
|
{requiredParticipationLP && (
|
||||||
|
<>
|
||||||
|
({formatNumber(requiredParticipationLP, defaultDecimals)}%{' '}
|
||||||
|
{t('governanceRequired')})
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
)}
|
||||||
|
<section data-testid="votes-table">
|
||||||
|
<SubHeading title={t('tokenVotes')} />
|
||||||
|
<p data-testid="token-votes-status">
|
||||||
|
<span>
|
||||||
|
<CurrentProposalStatus proposal={proposal} />
|
||||||
|
</span>
|
||||||
|
{'. '}
|
||||||
|
{proposal?.state === ProposalState.STATE_OPEN ? daysLeft : null}
|
||||||
|
</p>
|
||||||
|
<table className="w-full mb-4">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th className="text-vega-green w-[18%] text-left">{t('for')}</th>
|
||||||
|
<th>
|
||||||
|
<VoteProgress
|
||||||
|
threshold={requiredMajorityPercentage}
|
||||||
|
progress={yesPercentage}
|
||||||
|
/>
|
||||||
|
</th>
|
||||||
|
<th className="text-danger w-[18%] text-right">{t('against')}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td
|
||||||
|
className="text-left"
|
||||||
|
data-testid="vote-progress-indicator-percentage-for"
|
||||||
|
>
|
||||||
|
{yesPercentage.toFixed(defaultDecimals)}%
|
||||||
|
</td>
|
||||||
|
<td className="text-center text-white">
|
||||||
|
{t('majorityRequired')}{' '}
|
||||||
|
{requiredMajorityPercentage.toFixed(defaultDecimals)}%
|
||||||
|
</td>
|
||||||
|
<td
|
||||||
|
className="text-right"
|
||||||
|
data-testid="vote-progress-indicator-percentage-against"
|
||||||
|
>
|
||||||
|
{noPercentage.toFixed(defaultDecimals)}%
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td data-testid="vote-progress-indicator-tokens-for">
|
||||||
|
{' '}
|
||||||
|
{formatNumber(yesTokens, defaultDecimals)}{' '}
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
<td
|
||||||
|
data-testid="vote-progress-indicator-tokens-against"
|
||||||
|
className="text-right"
|
||||||
|
>
|
||||||
|
{formatNumber(noTokens, defaultDecimals)}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<p className="mb-6">
|
||||||
|
{t('participation')}
|
||||||
|
{': '}
|
||||||
|
{participationMet ? (
|
||||||
|
<span className="text-vega-green mx-4">{t('met')}</span>
|
||||||
|
) : (
|
||||||
|
<span className="text-danger mx-4">{t('notMet')}</span>
|
||||||
|
)}{' '}
|
||||||
|
{formatNumber(totalTokensVoted, defaultDecimals)}{' '}
|
||||||
|
{formatNumber(totalTokensPercentage, defaultDecimals)}%
|
||||||
|
<span className="ml-4">
|
||||||
|
({formatNumber(requiredParticipation, defaultDecimals)}%{' '}
|
||||||
|
{t('governanceRequired')})
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
{proposalType === ProposalType.PROPOSAL_UPDATE_MARKET && (
|
||||||
|
<p>{t('votingThresholdInfo')}</p>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<section className="mt-10">
|
||||||
|
{proposal?.state === ProposalState.STATE_OPEN ? (
|
||||||
|
<SubHeading title={t('castYourVote')} />
|
||||||
|
) : (
|
||||||
|
<SubHeading title={t('yourVote')} />
|
||||||
|
)}
|
||||||
|
|
||||||
|
{pubKey ? (
|
||||||
|
proposal && (
|
||||||
|
<VoteButtonsContainer
|
||||||
|
voteState={voteState}
|
||||||
|
voteDatetime={voteDatetime}
|
||||||
|
proposalState={proposal.state}
|
||||||
|
proposalId={proposal.id ?? ''}
|
||||||
|
minVoterBalance={minVoterBalance}
|
||||||
|
spamProtectionMinTokens={spamProtectionMinTokens}
|
||||||
|
className="flex"
|
||||||
|
submit={submit}
|
||||||
|
transaction={transaction}
|
||||||
|
dialog={dialog}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
) : (
|
||||||
|
<RoundedWrapper paddingBottom={true}>
|
||||||
|
<div className="mb-4">
|
||||||
|
<div className="flex items-center gap-2 mb-2">
|
||||||
|
<Icon name={'info-sign'} />
|
||||||
|
<div>{t('connectAVegaWalletToVote')}</div>
|
||||||
|
</div>
|
||||||
|
<ExternalLink href="https://blog.vega.xyz/how-to-vote-on-vega-2195d1e52ec5">
|
||||||
|
{t('findOutMoreAboutHowToVote')}
|
||||||
|
</ExternalLink>
|
||||||
|
</div>
|
||||||
|
<ConnectToVega />
|
||||||
|
</RoundedWrapper>
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -6,11 +6,6 @@ import { MockedProvider } from '@apollo/client/testing';
|
|||||||
import { MemoryRouter, Route, Routes } from 'react-router-dom';
|
import { MemoryRouter, Route, Routes } from 'react-router-dom';
|
||||||
import { ProposalDocument } from './__generated__/Proposal';
|
import { ProposalDocument } from './__generated__/Proposal';
|
||||||
|
|
||||||
jest.mock('@vegaprotocol/data-provider', () => ({
|
|
||||||
...jest.requireActual('@vegaprotocol/data-provider'),
|
|
||||||
useDataProvider: jest.fn(() => ({ data: [], loading: false })),
|
|
||||||
}));
|
|
||||||
|
|
||||||
jest.mock('../components/proposal', () => ({
|
jest.mock('../components/proposal', () => ({
|
||||||
Proposal: () => <div data-testid="proposal" />,
|
Proposal: () => <div data-testid="proposal" />,
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -1,17 +1,12 @@
|
|||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import {
|
import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
|
||||||
useEnvironment,
|
import { Heading } from '../../../../components/heading';
|
||||||
DocsLinks,
|
|
||||||
ExternalLinks,
|
|
||||||
} from '@vegaprotocol/environment';
|
|
||||||
import { Heading, SubHeading } from '../../../../components/heading';
|
|
||||||
import {
|
import {
|
||||||
AsyncRenderer,
|
AsyncRenderer,
|
||||||
ExternalLink,
|
ExternalLink,
|
||||||
FormGroup,
|
FormGroup,
|
||||||
InputError,
|
InputError,
|
||||||
RoundedWrapper,
|
|
||||||
TextArea,
|
TextArea,
|
||||||
} from '@vegaprotocol/ui-toolkit';
|
} from '@vegaprotocol/ui-toolkit';
|
||||||
import { validateJson } from '@vegaprotocol/utils';
|
import { validateJson } from '@vegaprotocol/utils';
|
||||||
@@ -84,6 +79,15 @@ export const ProposeRaw = () => {
|
|||||||
spamProtectionMin={params.spam_protection_proposal_min_tokens}
|
spamProtectionMin={params.spam_protection_proposal_min_tokens}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{DocsLinks && (
|
||||||
|
<p className="text-sm" data-testid="proposal-docs-link">
|
||||||
|
<span className="mr-1">{t('ProposalTermsText')}</span>
|
||||||
|
<ExternalLink href={DocsLinks.PROPOSALS_GUIDE} target="_blank">
|
||||||
|
{DocsLinks.PROPOSALS_GUIDE}
|
||||||
|
</ExternalLink>
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
|
||||||
{VEGA_EXPLORER_URL && (
|
{VEGA_EXPLORER_URL && (
|
||||||
<p className="text-sm">
|
<p className="text-sm">
|
||||||
{t('MoreProposalsInfo')}{' '}
|
{t('MoreProposalsInfo')}{' '}
|
||||||
@@ -94,44 +98,12 @@ export const ProposeRaw = () => {
|
|||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<section data-testid="how-to" className="my-10">
|
|
||||||
<RoundedWrapper paddingBottom={true}>
|
|
||||||
<SubHeading title={t('HowToPropose')} />
|
|
||||||
<ul>
|
|
||||||
<li className="p-1">
|
|
||||||
{t('HowToProposeRawStep1')}{' '}
|
|
||||||
{ExternalLinks && (
|
|
||||||
<span data-testid="proposal-docs-link">
|
|
||||||
<ExternalLink
|
|
||||||
href={ExternalLinks.PROPOSALS_FORUM}
|
|
||||||
target="_blank"
|
|
||||||
>
|
|
||||||
{ExternalLinks.PROPOSALS_FORUM}
|
|
||||||
</ExternalLink>
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</li>
|
|
||||||
<li className="p-1">
|
|
||||||
{t('HowToProposeRawStep2')}{' '}
|
|
||||||
{DocsLinks && (
|
|
||||||
<span data-testid="proposal-docs-link">
|
|
||||||
<ExternalLink
|
|
||||||
href={DocsLinks.PROPOSALS_GUIDE}
|
|
||||||
target="_blank"
|
|
||||||
>
|
|
||||||
{DocsLinks.PROPOSALS_GUIDE}
|
|
||||||
</ExternalLink>
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</li>
|
|
||||||
<li className="p-1">{t('HowToProposeRawStep3')}</li>
|
|
||||||
</ul>
|
|
||||||
</RoundedWrapper>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<div data-testid="raw-proposal-form">
|
<div data-testid="raw-proposal-form">
|
||||||
<form onSubmit={handleSubmit(onSubmit)}>
|
<form onSubmit={handleSubmit(onSubmit)}>
|
||||||
<FormGroup label="Valid JSON required" labelFor="proposal-data">
|
<FormGroup
|
||||||
|
label="Make a proposal by submitting JSON"
|
||||||
|
labelFor="proposal-data"
|
||||||
|
>
|
||||||
<TextArea
|
<TextArea
|
||||||
id="proposal-data"
|
id="proposal-data"
|
||||||
className="min-h-[200px]"
|
className="min-h-[200px]"
|
||||||
|
|||||||
+1
-4
@@ -43,10 +43,7 @@ describe('EpochIndividualRewardsTable', () => {
|
|||||||
it('should render correctly', () => {
|
it('should render correctly', () => {
|
||||||
const { getByTestId } = render(
|
const { getByTestId } = render(
|
||||||
<AppStateProvider>
|
<AppStateProvider>
|
||||||
<EpochIndividualRewardsTable
|
<EpochIndividualRewardsTable data={mockData} />
|
||||||
data={mockData}
|
|
||||||
marketCreationQuantumMultiple={'1000'}
|
|
||||||
/>
|
|
||||||
</AppStateProvider>
|
</AppStateProvider>
|
||||||
);
|
);
|
||||||
expect(getByTestId('epoch-individual-rewards-table')).toBeInTheDocument();
|
expect(getByTestId('epoch-individual-rewards-table')).toBeInTheDocument();
|
||||||
|
|||||||
-3
@@ -8,7 +8,6 @@ import type { EpochIndividualReward } from './generate-epoch-individual-rewards-
|
|||||||
|
|
||||||
interface EpochIndividualRewardsGridProps {
|
interface EpochIndividualRewardsGridProps {
|
||||||
data: EpochIndividualReward;
|
data: EpochIndividualReward;
|
||||||
marketCreationQuantumMultiple: string | null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RewardItemProps {
|
interface RewardItemProps {
|
||||||
@@ -70,11 +69,9 @@ const RewardItem = ({
|
|||||||
|
|
||||||
export const EpochIndividualRewardsTable = ({
|
export const EpochIndividualRewardsTable = ({
|
||||||
data,
|
data,
|
||||||
marketCreationQuantumMultiple,
|
|
||||||
}: EpochIndividualRewardsGridProps) => {
|
}: EpochIndividualRewardsGridProps) => {
|
||||||
return (
|
return (
|
||||||
<RewardsTable
|
<RewardsTable
|
||||||
marketCreationQuantumMultiple={marketCreationQuantumMultiple}
|
|
||||||
dataTestId="epoch-individual-rewards-table"
|
dataTestId="epoch-individual-rewards-table"
|
||||||
epoch={Number(data.epoch)}
|
epoch={Number(data.epoch)}
|
||||||
>
|
>
|
||||||
|
|||||||
+4
-15
@@ -1,4 +1,4 @@
|
|||||||
import { useMemo, useEffect, useState, useCallback, useRef } from 'react';
|
import { useMemo, useEffect, useState, useCallback } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { AsyncRenderer, Pagination } from '@vegaprotocol/ui-toolkit';
|
import { AsyncRenderer, Pagination } from '@vegaprotocol/ui-toolkit';
|
||||||
import { removePaginationWrapper } from '@vegaprotocol/utils';
|
import { removePaginationWrapper } from '@vegaprotocol/utils';
|
||||||
@@ -9,7 +9,6 @@ import { useVegaWallet } from '@vegaprotocol/wallet';
|
|||||||
import { EpochIndividualRewardsTable } from './epoch-individual-rewards-table';
|
import { EpochIndividualRewardsTable } from './epoch-individual-rewards-table';
|
||||||
import { generateEpochIndividualRewardsList } from './generate-epoch-individual-rewards-list';
|
import { generateEpochIndividualRewardsList } from './generate-epoch-individual-rewards-list';
|
||||||
import { calculateEpochOffset } from '../../../lib/epoch-pagination';
|
import { calculateEpochOffset } from '../../../lib/epoch-pagination';
|
||||||
import { useNetworkParam } from '@vegaprotocol/network-parameters';
|
|
||||||
|
|
||||||
const EPOCHS_PAGE_SIZE = 10;
|
const EPOCHS_PAGE_SIZE = 10;
|
||||||
|
|
||||||
@@ -27,9 +26,6 @@ export const EpochIndividualRewards = ({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { pubKey } = useVegaWallet();
|
const { pubKey } = useVegaWallet();
|
||||||
const { delegationsPagination } = ENV;
|
const { delegationsPagination } = ENV;
|
||||||
const { param: marketCreationQuantumMultiple } = useNetworkParam(
|
|
||||||
'rewards_marketCreationQuantumMultiple'
|
|
||||||
);
|
|
||||||
|
|
||||||
const { data, loading, error, refetch } = useRewardsQuery({
|
const { data, loading, error, refetch } = useRewardsQuery({
|
||||||
notifyOnNetworkStatusChange: true,
|
notifyOnNetworkStatusChange: true,
|
||||||
@@ -86,18 +82,12 @@ export const EpochIndividualRewards = ({
|
|||||||
[epochId, page, refetch, delegationsPagination, pubKey]
|
[epochId, page, refetch, delegationsPagination, pubKey]
|
||||||
);
|
);
|
||||||
|
|
||||||
const prevEpochIdRef = useRef<number | null>(null);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (prevEpochIdRef.current === null) {
|
// when the epoch changes, we want to refetch the data to update the current page
|
||||||
prevEpochIdRef.current = epochId;
|
if (data) {
|
||||||
} else if (epochId !== prevEpochIdRef.current) {
|
|
||||||
// When the epoch changes, we want to refetch the data to update the current page
|
|
||||||
refetchData();
|
refetchData();
|
||||||
}
|
}
|
||||||
|
}, [epochId, data, refetchData]);
|
||||||
prevEpochIdRef.current = epochId;
|
|
||||||
}, [epochId, refetchData]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AsyncRenderer
|
<AsyncRenderer
|
||||||
@@ -113,7 +103,6 @@ export const EpochIndividualRewards = ({
|
|||||||
{epochIndividualRewardSummaries.map(
|
{epochIndividualRewardSummaries.map(
|
||||||
(epochIndividualRewardSummary) => (
|
(epochIndividualRewardSummary) => (
|
||||||
<EpochIndividualRewardsTable
|
<EpochIndividualRewardsTable
|
||||||
marketCreationQuantumMultiple={marketCreationQuantumMultiple}
|
|
||||||
data={epochIndividualRewardSummary}
|
data={epochIndividualRewardSummary}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-4
@@ -66,10 +66,7 @@ describe('EpochTotalRewardsTable', () => {
|
|||||||
it('should render correctly', () => {
|
it('should render correctly', () => {
|
||||||
const { getByTestId } = render(
|
const { getByTestId } = render(
|
||||||
<AppStateProvider>
|
<AppStateProvider>
|
||||||
<EpochTotalRewardsTable
|
<EpochTotalRewardsTable data={mockData} />
|
||||||
data={mockData}
|
|
||||||
marketCreationQuantumMultiple={'1000'}
|
|
||||||
/>
|
|
||||||
</AppStateProvider>
|
</AppStateProvider>
|
||||||
);
|
);
|
||||||
expect(getByTestId('epoch-total-rewards-table')).toBeInTheDocument();
|
expect(getByTestId('epoch-total-rewards-table')).toBeInTheDocument();
|
||||||
|
|||||||
+1
-7
@@ -8,7 +8,6 @@ import type { EpochTotalSummary } from './generate-epoch-total-rewards-list';
|
|||||||
|
|
||||||
interface EpochTotalRewardsGridProps {
|
interface EpochTotalRewardsGridProps {
|
||||||
data: EpochTotalSummary;
|
data: EpochTotalSummary;
|
||||||
marketCreationQuantumMultiple: string | null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RewardItemProps {
|
interface RewardItemProps {
|
||||||
@@ -53,14 +52,9 @@ const RewardItem = ({
|
|||||||
|
|
||||||
export const EpochTotalRewardsTable = ({
|
export const EpochTotalRewardsTable = ({
|
||||||
data,
|
data,
|
||||||
marketCreationQuantumMultiple,
|
|
||||||
}: EpochTotalRewardsGridProps) => {
|
}: EpochTotalRewardsGridProps) => {
|
||||||
return (
|
return (
|
||||||
<RewardsTable
|
<RewardsTable dataTestId="epoch-total-rewards-table" epoch={data.epoch}>
|
||||||
marketCreationQuantumMultiple={marketCreationQuantumMultiple}
|
|
||||||
dataTestId="epoch-total-rewards-table"
|
|
||||||
epoch={data.epoch}
|
|
||||||
>
|
|
||||||
{Array.from(data.assetRewards.values()).map(
|
{Array.from(data.assetRewards.values()).map(
|
||||||
({ name, rewards, totalAmount, decimals }, i) => (
|
({ name, rewards, totalAmount, decimals }, i) => (
|
||||||
<div className="contents" key={i}>
|
<div className="contents" key={i}>
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { useEpochAssetsRewardsQuery } from '../home/__generated__/Rewards';
|
|||||||
import { generateEpochTotalRewardsList } from './generate-epoch-total-rewards-list';
|
import { generateEpochTotalRewardsList } from './generate-epoch-total-rewards-list';
|
||||||
import { EpochTotalRewardsTable } from './epoch-total-rewards-table';
|
import { EpochTotalRewardsTable } from './epoch-total-rewards-table';
|
||||||
import { calculateEpochOffset } from '../../../lib/epoch-pagination';
|
import { calculateEpochOffset } from '../../../lib/epoch-pagination';
|
||||||
import { useNetworkParam } from '@vegaprotocol/network-parameters';
|
|
||||||
|
|
||||||
const EPOCHS_PAGE_SIZE = 10;
|
const EPOCHS_PAGE_SIZE = 10;
|
||||||
|
|
||||||
@@ -19,9 +18,6 @@ export const EpochTotalRewards = ({ currentEpoch }: EpochTotalRewardsProps) => {
|
|||||||
const epochId = Number(currentEpoch.id) - 1;
|
const epochId = Number(currentEpoch.id) - 1;
|
||||||
const totalPages = Math.ceil(epochId / EPOCHS_PAGE_SIZE);
|
const totalPages = Math.ceil(epochId / EPOCHS_PAGE_SIZE);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { param: marketCreationQuantumMultiple } = useNetworkParam(
|
|
||||||
'rewards_marketCreationQuantumMultiple'
|
|
||||||
);
|
|
||||||
const [page, setPage] = useState(1);
|
const [page, setPage] = useState(1);
|
||||||
const { data, loading, error, refetch } = useEpochAssetsRewardsQuery({
|
const { data, loading, error, refetch } = useEpochAssetsRewardsQuery({
|
||||||
notifyOnNetworkStatusChange: true,
|
notifyOnNetworkStatusChange: true,
|
||||||
@@ -74,11 +70,7 @@ export const EpochTotalRewards = ({ currentEpoch }: EpochTotalRewardsProps) => {
|
|||||||
>
|
>
|
||||||
{Array.from(epochTotalRewardSummaries.values()).map(
|
{Array.from(epochTotalRewardSummaries.values()).map(
|
||||||
(epochTotalSummary, index) => (
|
(epochTotalSummary, index) => (
|
||||||
<EpochTotalRewardsTable
|
<EpochTotalRewardsTable data={epochTotalSummary} key={index} />
|
||||||
marketCreationQuantumMultiple={marketCreationQuantumMultiple}
|
|
||||||
data={epochTotalSummary}
|
|
||||||
key={index}
|
|
||||||
/>
|
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
<Pagination
|
<Pagination
|
||||||
|
|||||||
@@ -133,26 +133,24 @@ export const RewardsPage = () => {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex justify-end">
|
<div className="w-[360px]">
|
||||||
<div className="w-full max-w-[360px]">
|
<Toggle
|
||||||
<Toggle
|
name="epoch-reward-view-toggle"
|
||||||
name="epoch-reward-view-toggle"
|
toggles={[
|
||||||
toggles={[
|
{
|
||||||
{
|
label: t('totalDistributed'),
|
||||||
label: t('totalDistributed'),
|
value: 'total',
|
||||||
value: 'total',
|
},
|
||||||
},
|
{
|
||||||
{
|
label: t('earnedByMe'),
|
||||||
label: t('earnedByMe'),
|
value: 'individual',
|
||||||
value: 'individual',
|
},
|
||||||
},
|
]}
|
||||||
]}
|
checkedValue={toggleRewardsView}
|
||||||
checkedValue={toggleRewardsView}
|
onChange={(e) =>
|
||||||
onChange={(e) =>
|
setToggleRewardsView(e.target.value as RewardsView)
|
||||||
setToggleRewardsView(e.target.value as RewardsView)
|
}
|
||||||
}
|
/>
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|||||||
+3
-13
@@ -77,11 +77,7 @@ const ColumnHeader = ({
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
const ColumnHeaders = ({
|
const ColumnHeaders = () => {
|
||||||
marketCreationQuantumMultiple,
|
|
||||||
}: {
|
|
||||||
marketCreationQuantumMultiple: string | null;
|
|
||||||
}) => {
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<div className="contents">
|
<div className="contents">
|
||||||
@@ -93,9 +89,7 @@ const ColumnHeaders = ({
|
|||||||
<ColumnHeader
|
<ColumnHeader
|
||||||
key={columnTitle}
|
key={columnTitle}
|
||||||
title={t(columnTitle)}
|
title={t(columnTitle)}
|
||||||
tooltipContent={t(description, {
|
tooltipContent={t(description)}
|
||||||
marketCreationQuantumMultiple,
|
|
||||||
})}
|
|
||||||
className={headerGridItemStyles()}
|
className={headerGridItemStyles()}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
@@ -111,7 +105,6 @@ export interface RewardTableProps {
|
|||||||
dataTestId: string;
|
dataTestId: string;
|
||||||
epoch: number;
|
epoch: number;
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
marketCreationQuantumMultiple: string | null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rewards table children will be the row items. Make sure they contain
|
// Rewards table children will be the row items. Make sure they contain
|
||||||
@@ -120,15 +113,12 @@ export const RewardsTable = ({
|
|||||||
dataTestId,
|
dataTestId,
|
||||||
epoch,
|
epoch,
|
||||||
children,
|
children,
|
||||||
marketCreationQuantumMultiple,
|
|
||||||
}: RewardTableProps) => (
|
}: RewardTableProps) => (
|
||||||
<div data-testid={dataTestId} className="mb-12">
|
<div data-testid={dataTestId} className="mb-12">
|
||||||
<SubHeading title={`EPOCH ${epoch}`} />
|
<SubHeading title={`EPOCH ${epoch}`} />
|
||||||
|
|
||||||
<div className={gridStyles}>
|
<div className={gridStyles}>
|
||||||
<ColumnHeaders
|
<ColumnHeaders />
|
||||||
marketCreationQuantumMultiple={marketCreationQuantumMultiple}
|
|
||||||
/>
|
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -279,7 +279,7 @@ const routerConfig = [
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: `${Routes.PROTOCOL_UPGRADES}/:proposalReleaseTag/:proposalBlockHeight`,
|
path: `${Routes.PROTOCOL_UPGRADES}/:proposalReleaseTag`,
|
||||||
element: <LazyProtocolUpgradeProposal />,
|
element: <LazyProtocolUpgradeProposal />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
+7
-5
@@ -3,7 +3,7 @@ import { forwardRef, useMemo, useRef, useState } from 'react';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { Button, Icon } from '@vegaprotocol/ui-toolkit';
|
import { Button, Icon } from '@vegaprotocol/ui-toolkit';
|
||||||
import { AgGrid } from '@vegaprotocol/datagrid';
|
import { AgGridLazy as AgGrid } from '@vegaprotocol/datagrid';
|
||||||
import { useAppState } from '../../../../contexts/app-state/app-state-context';
|
import { useAppState } from '../../../../contexts/app-state/app-state-context';
|
||||||
import { BigNumber } from '../../../../lib/bignumber';
|
import { BigNumber } from '../../../../lib/bignumber';
|
||||||
import {
|
import {
|
||||||
@@ -85,17 +85,17 @@ const TopThirdCellRenderer = (
|
|||||||
}}
|
}}
|
||||||
className="grid grid-cols-[60px_1fr] w-full h-full py-4 px-0 text-sm text-white text-center overflow-scroll"
|
className="grid grid-cols-[60px_1fr] w-full h-full py-4 px-0 text-sm text-white text-center overflow-scroll"
|
||||||
>
|
>
|
||||||
<div className="px-3 text-xs text-left">
|
<div className="text-xs text-left px-3">
|
||||||
{params?.data?.rankingDisplay}
|
{params?.data?.rankingDisplay}
|
||||||
</div>
|
</div>
|
||||||
<div className="px-3 whitespace-normal">
|
<div className="whitespace-normal px-3">
|
||||||
<div className="mb-4">
|
<div className="mb-4">
|
||||||
<Button
|
<Button
|
||||||
data-testid="show-all-validators"
|
data-testid="show-all-validators"
|
||||||
rightIcon={
|
rightIcon={
|
||||||
<Icon
|
<Icon
|
||||||
name="arrow-right"
|
name="arrow-right"
|
||||||
className="mr-2 align-text-top fill-current"
|
className="fill-current mr-2 align-text-top"
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
className="inline-flex items-center"
|
className="inline-flex items-center"
|
||||||
@@ -103,7 +103,7 @@ const TopThirdCellRenderer = (
|
|||||||
{t('Reveal top validators')}
|
{t('Reveal top validators')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<p className="mb-0 font-semibold text-white">
|
<p className="font-semibold text-white mb-0">
|
||||||
{t(
|
{t(
|
||||||
'Validators with too great a stake share will have the staking rewards for their delegators penalised.'
|
'Validators with too great a stake share will have the staking rewards for their delegators penalised.'
|
||||||
)}
|
)}
|
||||||
@@ -352,6 +352,7 @@ export const ConsensusValidatorsTable = ({
|
|||||||
field: ValidatorFields.RANKING_INDEX,
|
field: ValidatorFields.RANKING_INDEX,
|
||||||
headerName: '#',
|
headerName: '#',
|
||||||
width: 60,
|
width: 60,
|
||||||
|
pinned: 'left',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: ValidatorFields.VALIDATOR,
|
field: ValidatorFields.VALIDATOR,
|
||||||
@@ -361,6 +362,7 @@ export const ConsensusValidatorsTable = ({
|
|||||||
if (a === b) return 0;
|
if (a === b) return 0;
|
||||||
return a > b ? 1 : -1;
|
return a > b ? 1 : -1;
|
||||||
},
|
},
|
||||||
|
pinned: 'left',
|
||||||
width: 260,
|
width: 260,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
+3
-1
@@ -1,7 +1,7 @@
|
|||||||
import { forwardRef, useMemo, useRef } from 'react';
|
import { forwardRef, useMemo, useRef } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { AgGrid } from '@vegaprotocol/datagrid';
|
import { AgGridLazy as AgGrid } from '@vegaprotocol/datagrid';
|
||||||
import { useAppState } from '../../../../contexts/app-state/app-state-context';
|
import { useAppState } from '../../../../contexts/app-state/app-state-context';
|
||||||
import { BigNumber } from '../../../../lib/bignumber';
|
import { BigNumber } from '../../../../lib/bignumber';
|
||||||
import {
|
import {
|
||||||
@@ -195,12 +195,14 @@ export const StandbyPendingValidatorsTable = ({
|
|||||||
field: ValidatorFields.RANKING_INDEX,
|
field: ValidatorFields.RANKING_INDEX,
|
||||||
headerName: '#',
|
headerName: '#',
|
||||||
width: 60,
|
width: 60,
|
||||||
|
pinned: 'left',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: ValidatorFields.VALIDATOR,
|
field: ValidatorFields.VALIDATOR,
|
||||||
headerName: t(ValidatorFields.VALIDATOR).toString(),
|
headerName: t(ValidatorFields.VALIDATOR).toString(),
|
||||||
cellRenderer: ValidatorRenderer,
|
cellRenderer: ValidatorRenderer,
|
||||||
comparator: ({ name: a }, { name: b }) => Math.sign(a - b),
|
comparator: ({ name: a }, { name: b }) => Math.sign(a - b),
|
||||||
|
pinned: 'left',
|
||||||
width: 260,
|
width: 260,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -122,43 +122,38 @@ export const ValidatorTable = ({
|
|||||||
|
|
||||||
<div className="my-12" data-testid="validator-table">
|
<div className="my-12" data-testid="validator-table">
|
||||||
<SubHeading title={t('profile')} />
|
<SubHeading title={t('profile')} />
|
||||||
<div className="break-all">
|
<RoundedWrapper paddingBottom={true}>
|
||||||
<RoundedWrapper paddingBottom={true}>
|
<KeyValueTable data-testid="validator-table-profile">
|
||||||
<KeyValueTable data-testid="validator-table-profile">
|
<KeyValueTableRow>
|
||||||
<KeyValueTableRow>
|
<span>{t('id')}</span>
|
||||||
<span>{t('id')}</span>
|
<ValidatorTableCell dataTestId="validator-id">
|
||||||
<ValidatorTableCell dataTestId="validator-id">
|
{node.id}
|
||||||
{node.id}
|
</ValidatorTableCell>
|
||||||
</ValidatorTableCell>
|
</KeyValueTableRow>
|
||||||
</KeyValueTableRow>
|
<KeyValueTableRow>
|
||||||
<KeyValueTableRow>
|
<span>{t('ABOUT THIS VALIDATOR')}</span>
|
||||||
<span>{t('ABOUT THIS VALIDATOR')}</span>
|
|
||||||
|
|
||||||
<Tooltip description={t('AboutThisValidatorDescription')}>
|
<Tooltip description={t('AboutThisValidatorDescription')}>
|
||||||
<a
|
<a data-testid="validator-description-url" href={node.infoUrl}>
|
||||||
data-testid="validator-description-url"
|
{node.infoUrl}
|
||||||
href={node.infoUrl}
|
</a>
|
||||||
>
|
</Tooltip>
|
||||||
{node.infoUrl}
|
</KeyValueTableRow>
|
||||||
</a>
|
<KeyValueTableRow noBorder={true}>
|
||||||
</Tooltip>
|
<span>
|
||||||
</KeyValueTableRow>
|
<strong>{t('STATUS')}</strong>
|
||||||
<KeyValueTableRow noBorder={true}>
|
</span>
|
||||||
<span>
|
|
||||||
<strong>{t('STATUS')}</strong>
|
<Tooltip description={t('ValidatorStatusDescription')}>
|
||||||
|
<span data-testid="validator-status">
|
||||||
|
<strong>
|
||||||
|
{t(statusTranslationKey(node.rankingScore.status))}
|
||||||
|
</strong>
|
||||||
</span>
|
</span>
|
||||||
|
</Tooltip>
|
||||||
<Tooltip description={t('ValidatorStatusDescription')}>
|
</KeyValueTableRow>
|
||||||
<span data-testid="validator-status">
|
</KeyValueTable>
|
||||||
<strong>
|
</RoundedWrapper>
|
||||||
{t(statusTranslationKey(node.rankingScore.status))}
|
|
||||||
</strong>
|
|
||||||
</span>
|
|
||||||
</Tooltip>
|
|
||||||
</KeyValueTableRow>
|
|
||||||
</KeyValueTable>
|
|
||||||
</RoundedWrapper>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mb-10">
|
<div className="mb-10">
|
||||||
{t('validatorTableIntro')}{' '}
|
{t('validatorTableIntro')}{' '}
|
||||||
@@ -172,154 +167,144 @@ export const ValidatorTable = ({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<SubHeading title={t('ADDRESS')} />
|
<SubHeading title={t('ADDRESS')} />
|
||||||
<div className="break-all">
|
<RoundedWrapper marginBottomLarge={true} paddingBottom={true}>
|
||||||
<RoundedWrapper marginBottomLarge={true} paddingBottom={true}>
|
<KeyValueTable data-testid="validator-table-address">
|
||||||
<KeyValueTable data-testid="validator-table-address">
|
<KeyValueTableRow>
|
||||||
<KeyValueTableRow>
|
<span>{t('VEGA ADDRESS / PUBLIC KEY')}</span>
|
||||||
<span>{t('VEGA ADDRESS / PUBLIC KEY')}</span>
|
<ValidatorTableCell dataTestId="validator-public-key">
|
||||||
<ValidatorTableCell dataTestId="validator-public-key">
|
{node.pubkey}
|
||||||
{node.pubkey}
|
</ValidatorTableCell>
|
||||||
</ValidatorTableCell>
|
</KeyValueTableRow>
|
||||||
</KeyValueTableRow>
|
<KeyValueTableRow>
|
||||||
<KeyValueTableRow>
|
<span>{t('SERVER LOCATION')}</span>
|
||||||
<span>{t('SERVER LOCATION')}</span>
|
<ValidatorTableCell dataTestId="validator-server-location">
|
||||||
<ValidatorTableCell dataTestId="validator-server-location">
|
{countryData.find((c) => c.code === node.location)?.name ||
|
||||||
{countryData.find((c) => c.code === node.location)?.name ||
|
t('not available')}
|
||||||
t('not available')}
|
</ValidatorTableCell>
|
||||||
</ValidatorTableCell>
|
</KeyValueTableRow>
|
||||||
</KeyValueTableRow>
|
<KeyValueTableRow noBorder={true}>
|
||||||
<KeyValueTableRow noBorder={true}>
|
<span>{t('ETHEREUM ADDRESS')}</span>
|
||||||
<span>{t('ETHEREUM ADDRESS')}</span>
|
<span data-testid="validator-eth-address">
|
||||||
<span data-testid="validator-eth-address">
|
<Link
|
||||||
<Link
|
title={t('View on Etherscan (opens in a new tab)')}
|
||||||
title={t('View on Etherscan (opens in a new tab)')}
|
href={`${ETHERSCAN_URL}/address/${node.ethereumAddress}`}
|
||||||
href={`${ETHERSCAN_URL}/address/${node.ethereumAddress}`}
|
target="_blank"
|
||||||
target="_blank"
|
>
|
||||||
>
|
{node.ethereumAddress}
|
||||||
{node.ethereumAddress}
|
</Link>
|
||||||
</Link>
|
</span>
|
||||||
</span>
|
</KeyValueTableRow>
|
||||||
</KeyValueTableRow>
|
</KeyValueTable>
|
||||||
</KeyValueTable>
|
</RoundedWrapper>
|
||||||
</RoundedWrapper>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<SubHeading title={t('STAKE')} />
|
<SubHeading title={t('STAKE')} />
|
||||||
<div className="break-all">
|
<RoundedWrapper marginBottomLarge={true} paddingBottom={true}>
|
||||||
<RoundedWrapper marginBottomLarge={true} paddingBottom={true}>
|
<KeyValueTable data-testid="validator-table-stake">
|
||||||
<KeyValueTable data-testid="validator-table-stake">
|
<KeyValueTableRow>
|
||||||
<KeyValueTableRow>
|
<span>{t('STAKED BY OPERATOR')}</span>
|
||||||
<span>{t('STAKED BY OPERATOR')}</span>
|
|
||||||
|
|
||||||
<Tooltip description={t('StakedByOperatorDescription')}>
|
<Tooltip description={t('StakedByOperatorDescription')}>
|
||||||
<span data-testid="staked-by-operator">
|
<span data-testid="staked-by-operator">
|
||||||
{formatNumber(toBigNum(node.stakedByOperator, decimals))}
|
{formatNumber(toBigNum(node.stakedByOperator, decimals))}
|
||||||
</span>
|
|
||||||
</Tooltip>
|
|
||||||
</KeyValueTableRow>
|
|
||||||
<KeyValueTableRow>
|
|
||||||
<span>{t('STAKED BY DELEGATES')}</span>
|
|
||||||
|
|
||||||
<Tooltip description={t('StakedByDelegatesDescription')}>
|
|
||||||
<span data-testid="staked-by-delegates">
|
|
||||||
{formatNumber(toBigNum(node.stakedByDelegates, decimals))}
|
|
||||||
</span>
|
|
||||||
</Tooltip>
|
|
||||||
</KeyValueTableRow>
|
|
||||||
<KeyValueTableRow>
|
|
||||||
<span>
|
|
||||||
<strong>{t('TOTAL STAKE')}</strong>
|
|
||||||
</span>
|
</span>
|
||||||
|
</Tooltip>
|
||||||
|
</KeyValueTableRow>
|
||||||
|
<KeyValueTableRow>
|
||||||
|
<span>{t('STAKED BY DELEGATES')}</span>
|
||||||
|
|
||||||
<span data-testid="total-stake">
|
<Tooltip description={t('StakedByDelegatesDescription')}>
|
||||||
<strong>
|
<span data-testid="staked-by-delegates">
|
||||||
{formatNumber(toBigNum(node.stakedTotal, decimals))}
|
{formatNumber(toBigNum(node.stakedByDelegates, decimals))}
|
||||||
</strong>
|
|
||||||
</span>
|
</span>
|
||||||
</KeyValueTableRow>
|
</Tooltip>
|
||||||
<KeyValueTableRow>
|
</KeyValueTableRow>
|
||||||
<span>{t('PENDING STAKE')}</span>
|
<KeyValueTableRow>
|
||||||
|
<span>
|
||||||
|
<strong>{t('TOTAL STAKE')}</strong>
|
||||||
|
</span>
|
||||||
|
|
||||||
<Tooltip description={t('PendingStakeDescription')}>
|
<span data-testid="total-stake">
|
||||||
<span data-testid="pending-stake">
|
<strong>
|
||||||
{formatNumber(toBigNum(node.pendingStake, decimals))}
|
{formatNumber(toBigNum(node.stakedTotal, decimals))}
|
||||||
</span>
|
</strong>
|
||||||
</Tooltip>
|
</span>
|
||||||
</KeyValueTableRow>
|
</KeyValueTableRow>
|
||||||
<KeyValueTableRow noBorder={true}>
|
<KeyValueTableRow>
|
||||||
<span>{t('STAKE SHARE')}</span>
|
<span>{t('PENDING STAKE')}</span>
|
||||||
|
|
||||||
<Tooltip description={t('StakeShareDescription')}>
|
<Tooltip description={t('PendingStakeDescription')}>
|
||||||
<span data-testid="stake-percentage">{stakePercentage}</span>
|
<span data-testid="pending-stake">
|
||||||
</Tooltip>
|
{formatNumber(toBigNum(node.pendingStake, decimals))}
|
||||||
</KeyValueTableRow>
|
</span>
|
||||||
</KeyValueTable>
|
</Tooltip>
|
||||||
</RoundedWrapper>
|
</KeyValueTableRow>
|
||||||
</div>
|
<KeyValueTableRow noBorder={true}>
|
||||||
|
<span>{t('STAKE SHARE')}</span>
|
||||||
|
|
||||||
|
<Tooltip description={t('StakeShareDescription')}>
|
||||||
|
<span data-testid="stake-percentage">{stakePercentage}</span>
|
||||||
|
</Tooltip>
|
||||||
|
</KeyValueTableRow>
|
||||||
|
</KeyValueTable>
|
||||||
|
</RoundedWrapper>
|
||||||
|
|
||||||
<SubHeading title={t('PENALTIES')} />
|
<SubHeading title={t('PENALTIES')} />
|
||||||
<div className="break-all">
|
<RoundedWrapper marginBottomLarge={true} paddingBottom={true}>
|
||||||
<RoundedWrapper marginBottomLarge={true} paddingBottom={true}>
|
<KeyValueTable data-testid="validator-table-penalties">
|
||||||
<KeyValueTable data-testid="validator-table-penalties">
|
<KeyValueTableRow>
|
||||||
<KeyValueTableRow>
|
<span>{t('OVERSTAKED PENALTY')}</span>
|
||||||
<span>{t('OVERSTAKED PENALTY')}</span>
|
|
||||||
|
|
||||||
<Tooltip description={t('OverstakedPenaltyDescription')}>
|
<Tooltip description={t('OverstakedPenaltyDescription')}>
|
||||||
<span data-testid="overstaking-penalty">
|
<span data-testid="overstaking-penalty">
|
||||||
{formatNumberPercentage(penalties.overstaked, 2)}
|
{formatNumberPercentage(penalties.overstaked, 2)}
|
||||||
</span>
|
</span>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</KeyValueTableRow>
|
</KeyValueTableRow>
|
||||||
<KeyValueTableRow>
|
<KeyValueTableRow>
|
||||||
<span>{t('PERFORMANCE PENALTY')}</span>
|
<span>{t('PERFORMANCE PENALTY')}</span>
|
||||||
|
|
||||||
<Tooltip description={t('PerformancePenaltyDescription')}>
|
<Tooltip description={t('PerformancePenaltyDescription')}>
|
||||||
<span data-testid="performance-penalty">
|
<span data-testid="performance-penalty">
|
||||||
{formatNumberPercentage(penalties.performance, 2)}
|
{formatNumberPercentage(penalties.performance, 2)}
|
||||||
</span>
|
|
||||||
</Tooltip>
|
|
||||||
</KeyValueTableRow>
|
|
||||||
<KeyValueTableRow noBorder={true}>
|
|
||||||
<span>
|
|
||||||
<strong>{t('TOTAL PENALTIES')}</strong>
|
|
||||||
</span>
|
</span>
|
||||||
<span data-testid="total-penalties">
|
</Tooltip>
|
||||||
<strong>
|
</KeyValueTableRow>
|
||||||
{formatNumberPercentage(penalties.overall, 2)}
|
<KeyValueTableRow noBorder={true}>
|
||||||
</strong>
|
<span>
|
||||||
</span>
|
<strong>{t('TOTAL PENALTIES')}</strong>
|
||||||
</KeyValueTableRow>
|
</span>
|
||||||
</KeyValueTable>
|
<span data-testid="total-penalties">
|
||||||
</RoundedWrapper>
|
<strong>{formatNumberPercentage(penalties.overall, 2)}</strong>
|
||||||
</div>
|
</span>
|
||||||
|
</KeyValueTableRow>
|
||||||
|
</KeyValueTable>
|
||||||
|
</RoundedWrapper>
|
||||||
|
|
||||||
<SubHeading title={t('VOTING POWER')} />
|
<SubHeading title={t('VOTING POWER')} />
|
||||||
<div className="break-all">
|
<RoundedWrapper marginBottomLarge={true} paddingBottom={true}>
|
||||||
<RoundedWrapper marginBottomLarge={true} paddingBottom={true}>
|
<KeyValueTable data-testid="validator-table-voting-power">
|
||||||
<KeyValueTable data-testid="validator-table-voting-power">
|
<KeyValueTableRow>
|
||||||
<KeyValueTableRow>
|
<span>{t('UNNORMALISED VOTING POWER')}</span>
|
||||||
<span>{t('UNNORMALISED VOTING POWER')}</span>
|
|
||||||
|
|
||||||
<Tooltip description={t('UnnormalisedVotingPowerDescription')}>
|
<Tooltip description={t('UnnormalisedVotingPowerDescription')}>
|
||||||
<span data-testid="unnormalised-voting-power">
|
<span data-testid="unnormalised-voting-power">
|
||||||
{getUnnormalisedVotingPower(rawValidatorScore)}
|
{getUnnormalisedVotingPower(rawValidatorScore)}
|
||||||
</span>
|
|
||||||
</Tooltip>
|
|
||||||
</KeyValueTableRow>
|
|
||||||
<KeyValueTableRow noBorder={true}>
|
|
||||||
<span>
|
|
||||||
<strong>{t('NORMALISED VOTING POWER')}</strong>
|
|
||||||
</span>
|
</span>
|
||||||
|
</Tooltip>
|
||||||
|
</KeyValueTableRow>
|
||||||
|
<KeyValueTableRow noBorder={true}>
|
||||||
|
<span>
|
||||||
|
<strong>{t('NORMALISED VOTING POWER')}</strong>
|
||||||
|
</span>
|
||||||
|
|
||||||
<Tooltip description={t('NormalisedVotingPowerDescription')}>
|
<Tooltip description={t('NormalisedVotingPowerDescription')}>
|
||||||
<strong data-testid="normalised-voting-power">
|
<strong data-testid="normalised-voting-power">
|
||||||
{getNormalisedVotingPower(node.rankingScore.votingPower)}
|
{getNormalisedVotingPower(node.rankingScore.votingPower)}
|
||||||
</strong>
|
</strong>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</KeyValueTableRow>
|
</KeyValueTableRow>
|
||||||
</KeyValueTable>
|
</KeyValueTable>
|
||||||
</RoundedWrapper>
|
</RoundedWrapper>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user