Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf6d6e70bc | ||
|
|
9e2dc19426 | ||
|
|
344971d5a9 |
@@ -3,7 +3,3 @@ apps/**/node_modules/*
|
|||||||
tmp/*
|
tmp/*
|
||||||
.dockerignore
|
.dockerignore
|
||||||
dockerfiles
|
dockerfiles
|
||||||
node_modules
|
|
||||||
.git
|
|
||||||
.github
|
|
||||||
.vscode
|
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
---
|
|
||||||
name: Release
|
|
||||||
about: A template to outline the steps needed to for a successful release of our frontend apps
|
|
||||||
title: 'Release [add dapp version]-core-[add core version]'
|
|
||||||
labels:
|
|
||||||
assignees: ''
|
|
||||||
---
|
|
||||||
|
|
||||||
### Tasks
|
|
||||||
|
|
||||||
- [ ] Review [link to core release](xxx)
|
|
||||||
- [ ] Tag frontend-monorepo
|
|
||||||
- [ ] Create release and generate release notes
|
|
||||||
- [ ] Run `@smoke` tests
|
|
||||||
- [ ] Run `@regression` tests
|
|
||||||
- [ ] Run `@slow` tests
|
|
||||||
- [ ] Explorative testing of key flows
|
|
||||||
- [ ] Set `release/[network]` to tagged commit
|
|
||||||
- [ ] Verify builds (on Netlify and Fleek) are successful
|
|
||||||
- [ ] Verify build has been deployed
|
|
||||||
- [ ] Smoke testing on deployed app
|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
inputs:
|
||||||
|
all:
|
||||||
|
description: 'Install all binaries'
|
||||||
|
default: false
|
||||||
|
version:
|
||||||
|
description: 'Vega version'
|
||||||
|
gobin:
|
||||||
|
description: 'GOBIN path'
|
||||||
|
default: '/home/runner/go/bin'
|
||||||
|
runs:
|
||||||
|
using: 'composite'
|
||||||
|
steps:
|
||||||
|
- name: Install Vega binaries
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
wget 'https://github.com/vegaprotocol/vega/releases/download/${{ inputs.version }}/vega-linux-amd64.zip' -q
|
||||||
|
unzip vega-linux-amd64.zip -d ${{ inputs.gobin }}
|
||||||
|
|
||||||
|
- name: Checkout vegawallet-dummy
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
repository: 'vegaprotocol/vegawallet-dummy'
|
||||||
|
path: './dummy'
|
||||||
|
|
||||||
|
- name: Install vegawallet-dummy binaries
|
||||||
|
shell: bash
|
||||||
|
run: go install
|
||||||
|
working-directory: ./dummy
|
||||||
@@ -1,17 +1,25 @@
|
|||||||
outputs:
|
inputs:
|
||||||
token:
|
github-token:
|
||||||
description: 'api-token of wallet'
|
description: 'github token'
|
||||||
value: ${{ steps.generate-api-token.outputs.api-token }}
|
|
||||||
runs:
|
runs:
|
||||||
using: 'composite'
|
using: 'composite'
|
||||||
steps:
|
steps:
|
||||||
- name: Vegacapsule version
|
- name: Checkout capsule
|
||||||
shell: bash
|
uses: actions/checkout@v2
|
||||||
run: vegacapsule version
|
with:
|
||||||
|
repository: vegaprotocol/vegacapsule
|
||||||
|
ref: main
|
||||||
|
token: ${{ inputs.github-token }}
|
||||||
|
path: './capsule'
|
||||||
|
|
||||||
- name: Vega wallet version
|
- name: Build capsule
|
||||||
|
run: go install
|
||||||
shell: bash
|
shell: bash
|
||||||
run: vega wallet software version
|
working-directory: capsule
|
||||||
|
|
||||||
|
- name: Login to docker
|
||||||
|
shell: bash
|
||||||
|
run: echo -n ${{ inputs.github-token }} | docker login https://ghcr.io -u vega-ci-bot --password-stdin
|
||||||
|
|
||||||
- name: Start nomad
|
- name: Start nomad
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -20,32 +28,3 @@ runs:
|
|||||||
- name: Bootstrap network
|
- name: Bootstrap network
|
||||||
shell: bash
|
shell: bash
|
||||||
run: vegacapsule network bootstrap --config-path=./frontend-monorepo/vegacapsule/config.hcl --force
|
run: vegacapsule network bootstrap --config-path=./frontend-monorepo/vegacapsule/config.hcl --force
|
||||||
|
|
||||||
- name: Initialize wallet
|
|
||||||
shell: bash
|
|
||||||
run: vega wallet init -f --home ~/.vegacapsule/testnet/wallet
|
|
||||||
|
|
||||||
- name: Import wallet
|
|
||||||
shell: bash
|
|
||||||
run: vega wallet import -w capsule_wallet --recovery-phrase-file ./frontend-monorepo/vegacapsule/recovery -p ./frontend-monorepo/vegacapsule/passphrase --home ~/.vegacapsule/testnet/wallet
|
|
||||||
|
|
||||||
- name: Generate second public key
|
|
||||||
shell: bash
|
|
||||||
run: vega wallet key generate -w capsule_wallet -p ./frontend-monorepo/vegacapsule/passphrase --home ~/.vegacapsule/testnet/wallet
|
|
||||||
|
|
||||||
- name: Import network
|
|
||||||
shell: bash
|
|
||||||
run: vega wallet network import --force --from-file ./frontend-monorepo/vegacapsule/wallet-config.toml --home ~/.vegacapsule/testnet/wallet
|
|
||||||
|
|
||||||
- name: Init api-token
|
|
||||||
shell: bash
|
|
||||||
run: vega wallet api-token init --home ~/.vegacapsule/testnet/wallet --passphrase-file ./frontend-monorepo/vegacapsule/passphrase
|
|
||||||
|
|
||||||
- name: Generate api-token
|
|
||||||
id: generate-api-token
|
|
||||||
shell: bash
|
|
||||||
run: echo api-token=$(vega wallet api-token generate --wallet-name capsule_wallet --tokens-passphrase-file ./frontend-monorepo/vegacapsule/passphrase --wallet-passphrase-file ./frontend-monorepo/vegacapsule/passphrase --home ~/.vegacapsule/testnet/wallet | grep -Eo '[a-zA-Z0-9]{64}') >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Start service using capsule network
|
|
||||||
shell: bash
|
|
||||||
run: vega wallet service run -n DV --load-tokens --tokens-passphrase-file ./frontend-monorepo/vegacapsule/passphrase --no-version-check --automatic-consent --home ~/.vegacapsule/testnet/wallet &
|
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
inputs:
|
||||||
|
passphrase:
|
||||||
|
description: 'Wallet password'
|
||||||
|
runs:
|
||||||
|
using: 'composite'
|
||||||
|
steps:
|
||||||
|
- name: Create passphrase
|
||||||
|
shell: bash
|
||||||
|
run: echo "${{ inputs.passphrase }}" > ./passphrase
|
||||||
|
|
||||||
|
- name: Initialize wallet
|
||||||
|
shell: bash
|
||||||
|
run: vega wallet init -f --home ~/.vegacapsule/testnet/wallet
|
||||||
|
|
||||||
|
- name: Import wallet
|
||||||
|
shell: bash
|
||||||
|
run: vega wallet import -w capsule_wallet --recovery-phrase-file ./frontend-monorepo/vegacapsule/recovery -p ./passphrase --home ~/.vegacapsule/testnet/wallet
|
||||||
|
|
||||||
|
- name: Import network
|
||||||
|
shell: bash
|
||||||
|
run: vega wallet network import --force --from-file ./frontend-monorepo/vegacapsule/wallet-config.toml --home ~/.vegacapsule/testnet/wallet
|
||||||
|
|
||||||
|
- name: Start service using capsule network
|
||||||
|
shell: bash
|
||||||
|
run: vegawallet-dummy service run --network DV --wallet capsule_wallet --passphrase-file ./passphrase --home ~/.vegacapsule/testnet/wallet &
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
inputs:
|
||||||
|
recovery:
|
||||||
|
description: 'Recovery phrase'
|
||||||
|
passphrase:
|
||||||
|
description: 'Wallet password'
|
||||||
|
runs:
|
||||||
|
using: 'composite'
|
||||||
|
steps:
|
||||||
|
- name: Create passphrase
|
||||||
|
shell: bash
|
||||||
|
run: echo "${{ inputs.passphrase }}" > ./passphrase
|
||||||
|
|
||||||
|
- name: Create recovery
|
||||||
|
shell: bash
|
||||||
|
run: echo "${{ inputs.recovery }}" > ./recovery
|
||||||
|
|
||||||
|
- name: Initialize wallet
|
||||||
|
shell: bash
|
||||||
|
run: vega wallet init -f --home ~/.vegacapsule/testnet/wallet
|
||||||
|
|
||||||
|
- name: Import wallet
|
||||||
|
shell: bash
|
||||||
|
run: vega wallet import -w UI_Trading_Test --recovery-phrase-file ./recovery -p ./passphrase --home ~/.vegacapsule/testnet/wallet
|
||||||
|
|
||||||
|
- name: Create public key 2
|
||||||
|
shell: bash
|
||||||
|
run: vega wallet key generate -w UI_Trading_Test -p ./passphrase --home ~/.vegacapsule/testnet/wallet
|
||||||
|
|
||||||
|
- name: Import network
|
||||||
|
shell: bash
|
||||||
|
run: vega wallet network import --from-url="https://raw.githubusercontent.com/vegaprotocol/networks-internal/main/stagnet3/vegawallet-stagnet3.toml" --force --home ~/.vegacapsule/testnet/wallet
|
||||||
|
|
||||||
|
- name: Start service using stagnet3 network
|
||||||
|
shell: bash
|
||||||
|
run: vegawallet-dummy service run --network stagnet3 --wallet UI_Trading_Test --passphrase-file ./passphrase --home ~/.vegacapsule/testnet/wallet &
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
name: After Release
|
|
||||||
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types: [published]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
after-release:
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
timeout-minutes: 30
|
|
||||||
steps:
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v2
|
|
||||||
|
|
||||||
- name: Log in to the Container registry (ghcr)
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Log in to the Container registry (docker hub)
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: resolve ipfs hashes for release
|
|
||||||
run: |
|
|
||||||
echo "Tag name: ${{ github.event.release.tag_name }}"
|
|
||||||
echo "Name: ${{ github.event.release.name }}"
|
|
||||||
echo "Description: ${{ github.event.release.body }}"
|
|
||||||
until docker pull vegaprotocol/trading:${{ github.event.release.tag_name }}; do
|
|
||||||
echo "Image not pushed yet, waiting 60 seconds"
|
|
||||||
sleep 60
|
|
||||||
done
|
|
||||||
docker run --rm vegaprotocol/trading:${{ github.event.release.tag_name }} cat /ipfs-hash > ipfs-hash
|
|
||||||
curl -L https://dist.ipfs.tech/kubo/v0.20.0/kubo_v0.20.0_linux-amd64.tar.gz -o kubo.tgz
|
|
||||||
tar -xzf kubo.tgz
|
|
||||||
export PATH="$PATH:$PWD/kubo"
|
|
||||||
which ipfs
|
|
||||||
echo IPFS_V0=$(cat ipfs-hash) >> $GITHUB_ENV
|
|
||||||
echo IPFS_V1=$(ipfs cid format -v 1 -b base32 $(cat ipfs-hash)) >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Edit Release
|
|
||||||
uses: irongut/EditRelease@v1.2.0
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
id: ${{ github.event.release.id }}
|
|
||||||
body: |
|
|
||||||
---
|
|
||||||
|
|
||||||
# Deployments
|
|
||||||
* https://explorer.vega.xyz
|
|
||||||
* https://governance.vega.xyz
|
|
||||||
|
|
||||||
# IPFS releases
|
|
||||||
Tye IPFS hash of this release of the Trading app is:
|
|
||||||
|
|
||||||
CIDv0: ${{ env.IPFS_V0 }}
|
|
||||||
CIDv1: ${{ env.IPFS_V1 }}
|
|
||||||
|
|
||||||
You can always access the latest IPFS release by visiting [vega.trading](https://vega.trading).
|
|
||||||
|
|
||||||
You can also access Trading directly from an IPFS gateway.
|
|
||||||
BEWARE: The Trading interface uses [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) to remember your settings, such as which tokens you have imported. You should always use an IPFS gateway that enforces [origin separation](https://ipfs.github.io/public-gateway-checker/).
|
|
||||||
|
|
||||||
Your settings are not remembered across different URLs.
|
|
||||||
|
|
||||||
IPFS gateways:
|
|
||||||
|
|
||||||
https://${{ env.IPFS_V1 }}.ipfs.dweb.link/
|
|
||||||
https://${{ env.IPFS_V1 }}.ipfs.cf-ipfs.com/
|
|
||||||
ipfs://${{ env.IPFS_V0 }}/
|
|
||||||
@@ -13,7 +13,7 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
add_issue:
|
add_issue:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: 'Add issue to project board'
|
- name: 'Add issue to project board'
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
name: 'Check if branch is shorter than 52 chars'
|
|
||||||
on: pull_request
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
branch-naming-rules:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
# echo "branches that are longer than 51 chars can't be parsed by kubernetes to create previews. Each app has prefix of it's name like: 'governance-' (12 chars), what leaves 51 max branch length"
|
|
||||||
# current parsable length: $( git rev-parse --abbrev-ref HEAD | sed -r s/[^a-zA-Z0-9]+/-/g | sed -r s/^-+\|-+$//g | wc -c)
|
|
||||||
- uses: deepakputhraya/action-branch-name@master
|
|
||||||
with:
|
|
||||||
# regex: '([a-z])+\/([a-z])+' # Regex the branch should match. This example enforces grouping
|
|
||||||
# allowed_prefixes: 'feature,stable,fix' # All branches should start with the given prefix
|
|
||||||
# ignore: master,develop # Ignore exactly matching branch names from convention
|
|
||||||
min_length: 1 # Min length of the branch name
|
|
||||||
max_length: 51 # Max length of the branch name
|
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
name: Cypress tests -- manual trigger
|
||||||
|
|
||||||
|
# This workflow runs the frontend tests against chosen branch
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
project:
|
||||||
|
description: 'Project'
|
||||||
|
required: true
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- console-lite-e2e
|
||||||
|
- explorer-e2e
|
||||||
|
- liquidity-provision-dashboard-e2e
|
||||||
|
- stats-e2e
|
||||||
|
- token-e2e
|
||||||
|
- trading-e2e
|
||||||
|
tags:
|
||||||
|
description: 'Test tags to run'
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
default: '@smoke, @regression, @slow'
|
||||||
|
skip-nx-cache:
|
||||||
|
description: 'Add --skip-nx-cache to cypress test'
|
||||||
|
required: false
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
env:
|
||||||
|
GOBIN: /home/runner/go/bin
|
||||||
|
VEGA_VERSION: 'v0.62.1'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
manual:
|
||||||
|
name: Run Cypress tests -- manual trigger
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Set tags
|
||||||
|
run: echo TAGS="--env.grepTags '[ ${{ github.event.inputs.tags }} ]'" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Set --skip-nx-cache flag
|
||||||
|
if: ${{ github.event.inputs.skip-nx-cache == 'true' }}
|
||||||
|
run: echo SKIP_NX_CACHE="--skip-nx-cache" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
vega-version: ${{env.VEGA_VERSION}}
|
||||||
|
gobin: ${{env.GOBIN}}
|
||||||
|
skip-cache: ${{env.SKIP_NX_CACHE}}
|
||||||
|
tags: ${{env.TAGS}}
|
||||||
|
|
||||||
|
dispatch:
|
||||||
|
needs: manual
|
||||||
|
uses: ./.github/workflows/tests-dispatcher.yml
|
||||||
|
secrets: inherit
|
||||||
|
with:
|
||||||
|
project: ${{ inputs.project }}
|
||||||
|
vega-version: ${{needs.manual.outputs.vega-version}}
|
||||||
|
gobin: ${{needs.manual.outputs.gobin}}
|
||||||
|
skip-cache: ${{needs.manual.outputs.skip-cache}}
|
||||||
|
tags: ${{needs.manual.outputs.tags}}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
name: Cypress tests -- night run
|
||||||
|
|
||||||
|
# This workflow runs the frontend tests against latest develop of the core to preempt breaking changes
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 4 * * *'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
nightly:
|
||||||
|
uses: ./.github/workflows/tests-dispatcher.yml
|
||||||
|
secrets: inherit
|
||||||
|
with:
|
||||||
|
project: '[console-lite-e2e, explorer-e2e, liquidity-provision-dashboard-e2e, stats-e2e, token-e2e, trading-e2e]'
|
||||||
|
vega-version: 'v0.62.1'
|
||||||
|
gobin: /home/runner/go/bin
|
||||||
|
tags: --env.grepTags '[ @smoke, @regression, @slow ]'
|
||||||
|
night-run: true
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
name: Cypress tests - PR
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- develop
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- reopened
|
||||||
|
- synchronize
|
||||||
|
- ready_for_review
|
||||||
|
|
||||||
|
env:
|
||||||
|
GOBIN: /home/runner/go/bin
|
||||||
|
VEGA_VERSION: 'v0.62.1'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pr:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
# Checkout front ends
|
||||||
|
- name: Checkout frontend mono repo
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
path: './frontend-monorepo'
|
||||||
|
|
||||||
|
# Restore node_modules from cache if possible
|
||||||
|
- name: Restore node_modules from cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
frontend-monorepo/node_modules
|
||||||
|
/home/runner/.cache/Cypress
|
||||||
|
key: node_modules_cypress-${{ hashFiles('frontend-monorepo/yarn.lock') }}
|
||||||
|
|
||||||
|
# Install frontend dependencies
|
||||||
|
- name: Install root dependencies
|
||||||
|
run: yarn install --frozen-lockfile
|
||||||
|
working-directory: frontend-monorepo
|
||||||
|
|
||||||
|
# Check SHAs
|
||||||
|
- name: Derive appropriate SHAs for base and head for `nx affected` commands
|
||||||
|
uses: nrwl/nx-set-shas@v2
|
||||||
|
with:
|
||||||
|
working-directory: frontend-monorepo
|
||||||
|
main-branch-name: ${{ github.base_ref || github.ref_name }}
|
||||||
|
set-environment-variables-for-job: true
|
||||||
|
|
||||||
|
# See affected projects
|
||||||
|
- name: See affected apps
|
||||||
|
run: echo AFFECTED=$(yarn nx print-affected --base=${{ env.NX_BASE }} --head=${{ env.NX_HEAD }} --select=projects) >> $GITHUB_ENV
|
||||||
|
working-directory: frontend-monorepo
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
projects: ${{ env.AFFECTED }}
|
||||||
|
vega-version: ${{ env.VEGA_VERSION }}
|
||||||
|
gobin: ${{ env.GOBIN }}
|
||||||
|
|
||||||
|
dispatch:
|
||||||
|
needs: pr
|
||||||
|
uses: ./.github/workflows/tests-dispatcher.yml
|
||||||
|
secrets: inherit
|
||||||
|
with:
|
||||||
|
project: ${{ needs.pr.outputs.projects }}
|
||||||
|
vega-version: ${{needs.pr.outputs.vega-version}}
|
||||||
|
gobin: ${{needs.pr.outputs.gobin}}
|
||||||
|
tags: "--env.grepTags='@smoke'"
|
||||||
@@ -1,211 +0,0 @@
|
|||||||
name: CI/CD
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- release/*
|
|
||||||
- develop
|
|
||||||
tags:
|
|
||||||
- v*
|
|
||||||
pull_request:
|
|
||||||
types:
|
|
||||||
- opened
|
|
||||||
- ready_for_review
|
|
||||||
- reopened
|
|
||||||
- edited
|
|
||||||
- synchronize
|
|
||||||
jobs:
|
|
||||||
node-modules:
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
name: 'Cache yarn modules'
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Cache node modules
|
|
||||||
id: cache
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: node_modules
|
|
||||||
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('yarn.lock') }}
|
|
||||||
# comment out "restore-keys" if you need to rebuild yarn from 0
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-cache-node-modules-
|
|
||||||
|
|
||||||
- name: Setup node
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
if: steps.cache.outputs.cache-hit != 'true'
|
|
||||||
with:
|
|
||||||
node-version-file: '.nvmrc'
|
|
||||||
# https://stackoverflow.com/questions/61010294/how-to-cache-yarn-packages-in-github-actions
|
|
||||||
cache: yarn
|
|
||||||
|
|
||||||
- name: yarn install
|
|
||||||
if: steps.cache.outputs.cache-hit != 'true'
|
|
||||||
run: yarn install --pure-lockfile
|
|
||||||
|
|
||||||
lint-pr-title:
|
|
||||||
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
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
name: '(CI) lint + unit test + build'
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
||||||
- 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: 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
|
|
||||||
run: yarn nx affected:build || (yarn install && yarn nx affected:build)
|
|
||||||
|
|
||||||
# See affected apps
|
|
||||||
- name: See affected apps
|
|
||||||
run: |
|
|
||||||
echo ">>>> debug"
|
|
||||||
echo "NX_BASE: ${{ env.NX_BASE }}"
|
|
||||||
echo "NX_HEAD: ${{ env.NX_HEAD }}"
|
|
||||||
echo ">>>> eof debug"
|
|
||||||
|
|
||||||
affected="$(yarn nx print-affected --base=${{ env.NX_BASE }} --head=${{ env.NX_HEAD }} --select=projects)"
|
|
||||||
|
|
||||||
branch_slug="$(echo '${{ github.head_ref || github.ref_name }}' | sed -r s/[^a-zA-Z0-9]+/-/g | sed -r s/^-+\|-+$//g | cut -c 1-50 )"
|
|
||||||
projects_e2e=""
|
|
||||||
preview_governance="not deployed"
|
|
||||||
preview_trading="not deployed"
|
|
||||||
preview_explorer="not deployed"
|
|
||||||
if [[ -z "$projects_e2e" ]]; then
|
|
||||||
projects_e2e+='"governance-e2e" "trading-e2e" "explorer-e2e" '
|
|
||||||
preview_governance=$(printf "https://%s.%s.vega.rocks" "governance" "$branch_slug")
|
|
||||||
preview_trading=$(printf "https://%s.%s.vega.rocks" "trading" "$branch_slug")
|
|
||||||
preview_explorer=$(printf "https://%s.%s.vega.rocks" "explorer" "$branch_slug")
|
|
||||||
else
|
|
||||||
if [[ $affected == *"governance"* ]]; then
|
|
||||||
projects_e2e+='"governance-e2e" '
|
|
||||||
preview_governance=$(printf "https://%s.%s.vega.rocks" "governance" "$branch_slug")
|
|
||||||
fi
|
|
||||||
if [[ $affected == *"trading"* ]]; then
|
|
||||||
projects_e2e+='"trading-e2e" '
|
|
||||||
preview_trading=$(printf "https://%s.%s.vega.rocks" "trading" "$branch_slug")
|
|
||||||
fi
|
|
||||||
if [[ $affected == *"explorer"* ]]; then
|
|
||||||
projects_e2e+='"explorer-e2e" '
|
|
||||||
preview_explorer=$(printf "https://%s.%s.vega.rocks" "explorer" "$branch_slug")
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
projects_e2e=${projects_e2e%?}
|
|
||||||
projects_e2e=[${projects_e2e// /,}]
|
|
||||||
echo PROJECTS_E2E=$projects_e2e >> $GITHUB_ENV
|
|
||||||
echo PROJECTS=$(echo $projects_e2e | sed 's|-e2e||g') >> $GITHUB_ENV
|
|
||||||
echo PREVIEW_GOVERNANCE=$preview_governance >> $GITHUB_ENV
|
|
||||||
echo PREVIEW_TRADING=$preview_trading >> $GITHUB_ENV
|
|
||||||
echo PREVIEW_EXPLORER=$preview_explorer >> $GITHUB_ENV
|
|
||||||
|
|
||||||
outputs:
|
|
||||||
projects: ${{ env.PROJECTS }}
|
|
||||||
projects-e2e: ${{ env.PROJECTS_E2E }}
|
|
||||||
preview_governance: ${{ env.PREVIEW_GOVERNANCE }}
|
|
||||||
preview_trading: ${{ env.PREVIEW_TRADING }}
|
|
||||||
preview_explorer: ${{ env.PREVIEW_EXPLORER }}
|
|
||||||
|
|
||||||
cypress:
|
|
||||||
needs: lint-test-build
|
|
||||||
name: '(CI) cypress'
|
|
||||||
if: ${{ needs.lint-test-build.outputs.projects != '[]' }}
|
|
||||||
uses: ./.github/workflows/cypress-run.yml
|
|
||||||
secrets: inherit
|
|
||||||
with:
|
|
||||||
projects: ${{ needs.lint-test-build.outputs.projects-e2e }}
|
|
||||||
tags: '@smoke @regression'
|
|
||||||
|
|
||||||
publish-dist:
|
|
||||||
needs: lint-test-build
|
|
||||||
name: '(CD) publish dist'
|
|
||||||
if: ${{ needs.lint-test-build.outputs.projects != '[]' }}
|
|
||||||
uses: ./.github/workflows/publish-dist.yml
|
|
||||||
secrets: inherit
|
|
||||||
with:
|
|
||||||
projects: ${{ needs.lint-test-build.outputs.projects }}
|
|
||||||
|
|
||||||
dist-check:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs:
|
|
||||||
- publish-dist
|
|
||||||
- lint-test-build
|
|
||||||
if: ${{ github.event_name == 'pull_request' }}
|
|
||||||
name: '(CD) comment preview links'
|
|
||||||
steps:
|
|
||||||
- name: Find Comment
|
|
||||||
uses: peter-evans/find-comment@v2
|
|
||||||
id: fc
|
|
||||||
with:
|
|
||||||
issue-number: ${{ github.event.pull_request.number }}
|
|
||||||
body-includes: Previews
|
|
||||||
|
|
||||||
- name: Create comment
|
|
||||||
uses: peter-evans/create-or-update-comment@v3
|
|
||||||
if: ${{ steps.fc.outputs.comment-id == 0 }}
|
|
||||||
with:
|
|
||||||
issue-number: ${{ github.event.pull_request.number }}
|
|
||||||
body: |
|
|
||||||
Previews:
|
|
||||||
* governance: ${{ needs.lint-test-build.outputs.preview_governance }}
|
|
||||||
* explorer: ${{ needs.lint-test-build.outputs.preview_explorer }}
|
|
||||||
* trading: ${{ needs.lint-test-build.outputs.preview_trading }}
|
|
||||||
|
|
||||||
cypress-check:
|
|
||||||
name: '(CI) cypress - check'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: cypress
|
|
||||||
steps:
|
|
||||||
- run: echo Done!
|
|
||||||
|
|
||||||
# Report single result at the end, to avoid mess with required checks in PR
|
|
||||||
cypress-result:
|
|
||||||
if: ${{ always() }}
|
|
||||||
needs: cypress
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
steps:
|
|
||||||
- run: |
|
|
||||||
result="${{ needs.cypress.result }}"
|
|
||||||
if [[ $result == "success" || $result == "skipped" ]]; then
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
name: Cypress - console-lite
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
trigger:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
default: 'false'
|
||||||
|
vega-version:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
gobin:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
default: /home/runner/go/bin
|
||||||
|
skip-cache:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
tags:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
console-lite-e2e:
|
||||||
|
if: ${{ inputs.trigger == 'true' }}
|
||||||
|
runs-on: self-hosted
|
||||||
|
steps:
|
||||||
|
# Add GOBIN to PATH
|
||||||
|
- name: Add GOBIN to PATH
|
||||||
|
run: echo ${{ inputs.gobin }} >> $GITHUB_PATH
|
||||||
|
|
||||||
|
# Checkout front ends
|
||||||
|
- name: Checkout frontend mono repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
path: './frontend-monorepo'
|
||||||
|
|
||||||
|
# Restore node_modules from cache if possible
|
||||||
|
- name: Restore node_modules from cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
frontend-monorepo/node_modules
|
||||||
|
/home/runner/.cache/Cypress
|
||||||
|
key: node_modules_cypress-${{ hashFiles('frontend-monorepo/yarn.lock') }}
|
||||||
|
|
||||||
|
# Install frontend dependencies
|
||||||
|
- name: Install root dependencies
|
||||||
|
run: yarn install --frozen-lockfile
|
||||||
|
working-directory: frontend-monorepo
|
||||||
|
|
||||||
|
#######
|
||||||
|
## Build and run Vegacapsule network
|
||||||
|
#######
|
||||||
|
|
||||||
|
- name: Install Vega binaries
|
||||||
|
uses: ./frontend-monorepo/.github/actions/install-vega-binaries
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.vega-version }}
|
||||||
|
gobin: ${{ inputs.gobin }}
|
||||||
|
|
||||||
|
######
|
||||||
|
## Setup a Vega wallet for our user
|
||||||
|
######
|
||||||
|
|
||||||
|
- name: Set up Vegawallet
|
||||||
|
uses: ./frontend-monorepo/.github/actions/setup-vegawallet
|
||||||
|
with:
|
||||||
|
recovery: ${{ secrets.TRADING_TEST_VEGA_WALLET_RECOVERY }}
|
||||||
|
passphrase: ${{ secrets.CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE }}
|
||||||
|
|
||||||
|
# To make sure that all Cypress binaries are installed properly
|
||||||
|
- name: Install cypress bins
|
||||||
|
run: yarn cypress install
|
||||||
|
working-directory: frontend-monorepo
|
||||||
|
|
||||||
|
- name: Run Cypress tests
|
||||||
|
run: npx nx run console-lite-e2e:e2e ${{ inputs.skip-cache }} --record --key ${{ secrets.CYPRESS_RECORD_KEY }} --browser chrome ${{ inputs.tags }}
|
||||||
|
working-directory: frontend-monorepo
|
||||||
|
env:
|
||||||
|
CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE: ${{ secrets.CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE }}
|
||||||
|
CYPRESS_SLACK_WEBHOOK: ${{ secrets.CYPRESS_SLACK_WEBHOOK }}
|
||||||
|
CYPRESS_ETH_WALLET_MNEMONIC: ${{ secrets.CYPRESS_ETH_WALLET_MNEMONIC }}
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
name: Cypress - explorer
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
trigger:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
default: 'false'
|
||||||
|
vega-version:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
gobin:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
default: /home/runner/go/bin
|
||||||
|
skip-cache:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
tags:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
night-run:
|
||||||
|
required: false
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
explorer-e2e:
|
||||||
|
if: ${{ inputs.trigger == 'true' }}
|
||||||
|
runs-on: self-hosted
|
||||||
|
timeout-minutes: 30
|
||||||
|
steps:
|
||||||
|
# Add GOBIN to PATH
|
||||||
|
- name: Add GOBIN to PATH
|
||||||
|
run: echo ${{ inputs.gobin }} >> $GITHUB_PATH
|
||||||
|
|
||||||
|
# Checkout front ends
|
||||||
|
- name: Checkout frontend mono repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
path: './frontend-monorepo'
|
||||||
|
|
||||||
|
# Restore node_modules from cache if possible
|
||||||
|
- name: Restore node_modules from cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
frontend-monorepo/node_modules
|
||||||
|
/home/runner/.cache/Cypress
|
||||||
|
key: node_modules_cypress-${{ hashFiles('frontend-monorepo/yarn.lock') }}
|
||||||
|
|
||||||
|
# Install frontend dependencies
|
||||||
|
- name: Install root dependencies
|
||||||
|
run: yarn install --frozen-lockfile
|
||||||
|
working-directory: frontend-monorepo
|
||||||
|
|
||||||
|
#######
|
||||||
|
## Build and run Vegacapsule network
|
||||||
|
#######
|
||||||
|
|
||||||
|
- name: Install Vega binaries
|
||||||
|
uses: ./frontend-monorepo/.github/actions/install-vega-binaries
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.vega-version }}
|
||||||
|
gobin: ${{ inputs.gobin }}
|
||||||
|
|
||||||
|
- name: Build and run Vegacapsule network
|
||||||
|
uses: ./frontend-monorepo/.github/actions/run-vegacapsule
|
||||||
|
with:
|
||||||
|
github-token: ${{ secrets.VEGA_CI_BOT_GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
######
|
||||||
|
## Setup a Vega wallet for our user
|
||||||
|
######
|
||||||
|
|
||||||
|
- name: Set up Vegawallet for docker
|
||||||
|
uses: ./frontend-monorepo/.github/actions/setup-vegawallet-docker
|
||||||
|
with:
|
||||||
|
passphrase: ${{ secrets.CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE }}
|
||||||
|
|
||||||
|
######
|
||||||
|
## Run some tests
|
||||||
|
######
|
||||||
|
|
||||||
|
# To make sure that all Cypress binaries are installed properly
|
||||||
|
- name: Install cypress bins
|
||||||
|
run: yarn cypress install
|
||||||
|
working-directory: frontend-monorepo
|
||||||
|
|
||||||
|
- name: Run Cypress tests
|
||||||
|
run: npx nx run explorer-e2e:e2e ${{ inputs.skip-cache }} --record --key ${{ secrets.CYPRESS_RECORD_KEY }} --browser chrome ${{ inputs.tags }}
|
||||||
|
working-directory: frontend-monorepo
|
||||||
|
env:
|
||||||
|
CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE: ${{ secrets.CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE }}
|
||||||
|
CYPRESS_SLACK_WEBHOOK: ${{ secrets.CYPRESS_SLACK_WEBHOOK }}
|
||||||
|
CYPRESS_ETH_WALLET_MNEMONIC: ${{ secrets.CYPRESS_ETH_WALLET_MNEMONIC }}
|
||||||
|
CYPRESS_NIGHTLY_RUN: ${{ inputs.night-run }}
|
||||||
|
|
||||||
|
######
|
||||||
|
## Upload logs
|
||||||
|
######
|
||||||
|
|
||||||
|
- name: Logs
|
||||||
|
run: vegacapsule network logs > vega-capsule-logs.txt
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: logs
|
||||||
|
path: ./vega-capsule-logs.txt
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
name: Cypress - liquidity provision dashboard
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
trigger:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
default: 'false'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
liquidity-provision-dashboard-e2e:
|
||||||
|
timeout-minutes: 10
|
||||||
|
if: ${{ inputs.trigger == 'true' }}
|
||||||
|
runs-on: self-hosted
|
||||||
|
steps:
|
||||||
|
# Checkout front ends
|
||||||
|
- name: Checkout frontend mono repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
path: './frontend-monorepo'
|
||||||
|
|
||||||
|
# Restore node_modules from cache if possible
|
||||||
|
- name: Restore node_modules from cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
frontend-monorepo/node_modules
|
||||||
|
/home/runner/.cache/Cypress
|
||||||
|
key: node_modules_cypress-${{ hashFiles('frontend-monorepo/yarn.lock') }}
|
||||||
|
|
||||||
|
# Install frontend dependencies
|
||||||
|
- name: Install root dependencies
|
||||||
|
run: yarn install --frozen-lockfile
|
||||||
|
working-directory: frontend-monorepo
|
||||||
|
|
||||||
|
# To make sure that all Cypress binaries are installed properly
|
||||||
|
- name: Install cypress bins
|
||||||
|
run: yarn cypress install
|
||||||
|
working-directory: frontend-monorepo
|
||||||
|
|
||||||
|
- name: Run Cypress tests
|
||||||
|
run: npx nx run liquidity-provision-dashboard-e2e:e2e --record --key ${{ secrets.CYPRESS_RECORD_KEY }} --browser chrome
|
||||||
|
working-directory: frontend-monorepo
|
||||||
|
env:
|
||||||
|
CYPRESS_SLACK_WEBHOOK: ${{ secrets.CYPRESS_SLACK_WEBHOOK }}
|
||||||
@@ -13,17 +13,11 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
cypress-run:
|
cypress-run:
|
||||||
name: Run Cypress Trading tests -- live environment
|
name: Run Cypress Trading tests -- live environment
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Use Node.js 16
|
|
||||||
id: Node
|
|
||||||
uses: actions/setup-node@v2
|
|
||||||
with:
|
|
||||||
node-version: 16.15.1
|
|
||||||
|
|
||||||
- name: Run Cypress tests
|
- name: Run Cypress tests
|
||||||
uses: cypress-io/github-action@v4
|
uses: cypress-io/github-action@v4
|
||||||
with:
|
with:
|
||||||
@@ -33,4 +27,5 @@ jobs:
|
|||||||
config: baseUrl=${{ github.event.inputs.url }}
|
config: baseUrl=${{ github.event.inputs.url }}
|
||||||
env: grepTags=@live
|
env: grepTags=@live
|
||||||
env:
|
env:
|
||||||
|
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
name: Cypress tests -- manual trigger
|
|
||||||
|
|
||||||
# This workflow runs the frontend tests against chosen branch
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
project:
|
|
||||||
description: 'Project'
|
|
||||||
required: true
|
|
||||||
type: choice
|
|
||||||
options:
|
|
||||||
- explorer-e2e
|
|
||||||
- governance-e2e
|
|
||||||
- trading-e2e
|
|
||||||
tags:
|
|
||||||
description: 'Test tags to run'
|
|
||||||
required: true
|
|
||||||
type: string
|
|
||||||
default: '@smoke @regression @slow'
|
|
||||||
skip-nx-cache:
|
|
||||||
description: 'Skip NX cache'
|
|
||||||
required: false
|
|
||||||
type: boolean
|
|
||||||
default: false
|
|
||||||
jobs:
|
|
||||||
manual:
|
|
||||||
uses: ./.github/workflows/cypress-run.yml
|
|
||||||
secrets: inherit
|
|
||||||
with:
|
|
||||||
projects: '["${{inputs.project}}"]'
|
|
||||||
skip-cache: ${{inputs.skip-nx-cache}}
|
|
||||||
tags: ${{inputs.tags}}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
name: Cypress tests -- night run
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: '0 4 * * *'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
nightly:
|
|
||||||
uses: ./.github/workflows/cypress-run.yml
|
|
||||||
secrets: inherit
|
|
||||||
with:
|
|
||||||
projects: '["explorer-e2e","governance-e2e","trading-e2e"]'
|
|
||||||
tags: '@smoke @regression @slow'
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
name: (CI) Cypress Run
|
|
||||||
on:
|
|
||||||
workflow_call:
|
|
||||||
inputs:
|
|
||||||
projects:
|
|
||||||
required: true
|
|
||||||
type: string
|
|
||||||
skip-cache:
|
|
||||||
required: false
|
|
||||||
type: boolean
|
|
||||||
tags:
|
|
||||||
required: false
|
|
||||||
type: string
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
e2e:
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
project: ${{ fromJSON(inputs.projects) }}
|
|
||||||
name: ${{ matrix.project }}
|
|
||||||
runs-on: self-hosted-runner
|
|
||||||
timeout-minutes: 60
|
|
||||||
steps:
|
|
||||||
# Checks if skip cache was requested
|
|
||||||
- name: Set skip-nx-cache flag
|
|
||||||
if: ${{ inputs.skip-cache == true }}
|
|
||||||
run: echo "SKIP_CACHE=--skip-nx-cache" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
# Checkout front ends
|
|
||||||
- name: Checkout frontend mono repo
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
path: './frontend-monorepo'
|
|
||||||
|
|
||||||
# Restore node_modules from cache if possible
|
|
||||||
- name: Restore node_modules from cache
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
frontend-monorepo/node_modules
|
|
||||||
/home/runner/.cache/Cypress
|
|
||||||
key: node_modules_cypress-${{ hashFiles('frontend-monorepo/yarn.lock', 'frontend-monorepo/package.json') }}
|
|
||||||
|
|
||||||
# Install frontend dependencies
|
|
||||||
- name: Install root dependencies
|
|
||||||
run: yarn install --frozen-lockfile
|
|
||||||
working-directory: frontend-monorepo
|
|
||||||
|
|
||||||
# Make sure that all Cypress binaries are installed properly
|
|
||||||
- name: Install cypress bins
|
|
||||||
run: yarn cypress install
|
|
||||||
working-directory: frontend-monorepo
|
|
||||||
|
|
||||||
######
|
|
||||||
## Setup Vegacapsule and Vega wallet
|
|
||||||
######
|
|
||||||
|
|
||||||
- name: Run Vegacapsule network and Vega wallet
|
|
||||||
id: setup-vega
|
|
||||||
uses: ./frontend-monorepo/.github/actions/run-vegacapsule
|
|
||||||
|
|
||||||
######
|
|
||||||
## Run some tests
|
|
||||||
######
|
|
||||||
|
|
||||||
- name: Run Cypress tests
|
|
||||||
run: yarn nx run ${{ matrix.project }}:e2e ${{ env.SKIP_CACHE }} --browser chrome --env.grepTags="${{ inputs.tags }}"
|
|
||||||
working-directory: frontend-monorepo
|
|
||||||
env:
|
|
||||||
CYPRESS_SLACK_WEBHOOK: ${{ secrets.CYPRESS_SLACK_WEBHOOK }}
|
|
||||||
CYPRESS_VEGA_WALLET_API_TOKEN: ${{ steps.setup-vega.outputs.token }}
|
|
||||||
|
|
||||||
######
|
|
||||||
## Upload logs
|
|
||||||
######
|
|
||||||
|
|
||||||
# Artifact path is not valid: /ganache-1/capsule-logscolletor.stderr-2022-12-22T10:20:30Z.log. Contains the following character: Colon :
|
|
||||||
- name: Rename files to allow archive
|
|
||||||
if: ${{ always() }}
|
|
||||||
run: |
|
|
||||||
while read -r file; do
|
|
||||||
mv "${file}" "$(echo ${file} | sed 's|:|-|g')"
|
|
||||||
done< <(find /home/runner/.vegacapsule/testnet/logs -type f)
|
|
||||||
|
|
||||||
- name: Print logs files
|
|
||||||
if: ${{ always() }}
|
|
||||||
run: ls -alsh /home/runner/.vegacapsule/testnet/logs/
|
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
|
||||||
if: ${{ failure() }}
|
|
||||||
with:
|
|
||||||
name: logs-${{ matrix.project }}
|
|
||||||
path: /home/runner/.vegacapsule/testnet/logs
|
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
|
||||||
if: ${{ failure() }}
|
|
||||||
with:
|
|
||||||
name: test-report-${{ matrix.project }}
|
|
||||||
path: frontend-monorepo/apps/${{ matrix.project }}/cypress/reports
|
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
name: Cypress - stats
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
trigger:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
default: 'false'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
stats-e2e:
|
||||||
|
runs-on: self-hosted
|
||||||
|
if: ${{ inputs.trigger == 'true' }}
|
||||||
|
timeout-minutes: 10
|
||||||
|
steps:
|
||||||
|
# Checkout front ends
|
||||||
|
- name: Checkout frontend mono repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
path: './frontend-monorepo'
|
||||||
|
|
||||||
|
# Restore node_modules from cache if possible
|
||||||
|
- name: Restore node_modules from cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
frontend-monorepo/node_modules
|
||||||
|
/home/runner/.cache/Cypress
|
||||||
|
key: node_modules_cypress-${{ hashFiles('frontend-monorepo/yarn.lock') }}
|
||||||
|
|
||||||
|
# Install frontend dependencies
|
||||||
|
- name: Install root dependencies
|
||||||
|
run: yarn install --frozen-lockfile
|
||||||
|
working-directory: frontend-monorepo
|
||||||
|
|
||||||
|
# To make sure that all Cypress binaries are installed properly
|
||||||
|
- name: Install cypress bins
|
||||||
|
run: yarn cypress install
|
||||||
|
working-directory: frontend-monorepo
|
||||||
|
|
||||||
|
- name: Run Cypress tests
|
||||||
|
run: npx nx run stats-e2e:e2e --record --key ${{ secrets.CYPRESS_RECORD_KEY }} --browser chrome
|
||||||
|
working-directory: frontend-monorepo
|
||||||
|
env:
|
||||||
|
CYPRESS_SLACK_WEBHOOK: ${{ secrets.CYPRESS_SLACK_WEBHOOK }}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
name: Cypress - token
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
trigger:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
default: 'false'
|
||||||
|
vega-version:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
gobin:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
default: /home/runner/go/bin
|
||||||
|
skip-cache:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
tags:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
token-e2e:
|
||||||
|
if: ${{ inputs.trigger == 'true' }}
|
||||||
|
runs-on: self-hosted
|
||||||
|
timeout-minutes: 60
|
||||||
|
steps:
|
||||||
|
# Add GOBIN to PATH
|
||||||
|
- name: Add GOBIN to PATH
|
||||||
|
run: echo ${{ inputs.gobin }} >> $GITHUB_PATH
|
||||||
|
|
||||||
|
# Checkout front ends
|
||||||
|
- name: Checkout frontend mono repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
path: './frontend-monorepo'
|
||||||
|
|
||||||
|
# Restore node_modules from cache if possible
|
||||||
|
- name: Restore node_modules from cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
frontend-monorepo/node_modules
|
||||||
|
/home/runner/.cache/Cypress
|
||||||
|
key: node_modules_cypress-${{ hashFiles('frontend-monorepo/yarn.lock') }}
|
||||||
|
|
||||||
|
# Install frontend dependencies
|
||||||
|
- name: Install root dependencies
|
||||||
|
run: yarn install --frozen-lockfile
|
||||||
|
working-directory: frontend-monorepo
|
||||||
|
|
||||||
|
#######
|
||||||
|
## Build and run Vegacapsule network
|
||||||
|
#######
|
||||||
|
|
||||||
|
- name: Install Vega binaries
|
||||||
|
uses: ./frontend-monorepo/.github/actions/install-vega-binaries
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.vega-version }}
|
||||||
|
gobin: ${{ inputs.gobin }}
|
||||||
|
|
||||||
|
- name: Build and run Vegacapsule network
|
||||||
|
uses: ./frontend-monorepo/.github/actions/run-vegacapsule
|
||||||
|
with:
|
||||||
|
github-token: ${{ secrets.VEGA_CI_BOT_GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
######
|
||||||
|
## Setup a Vega wallet for our user
|
||||||
|
######
|
||||||
|
|
||||||
|
- name: Set up Vegawallet for docker
|
||||||
|
uses: ./frontend-monorepo/.github/actions/setup-vegawallet-docker
|
||||||
|
with:
|
||||||
|
passphrase: ${{ secrets.CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE }}
|
||||||
|
|
||||||
|
######
|
||||||
|
## Run some tests
|
||||||
|
######
|
||||||
|
|
||||||
|
# To make sure that all Cypress binaries are installed properly
|
||||||
|
- name: Install cypress bins
|
||||||
|
run: yarn cypress install
|
||||||
|
working-directory: frontend-monorepo
|
||||||
|
|
||||||
|
- name: Run Cypress tests
|
||||||
|
run: npx nx run token-e2e:e2e ${{ inputs.skip-cache }} --record --key ${{ secrets.CYPRESS_RECORD_KEY }} --browser chrome ${{ inputs.tags }}
|
||||||
|
working-directory: frontend-monorepo
|
||||||
|
env:
|
||||||
|
CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE: ${{ secrets.CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE }}
|
||||||
|
CYPRESS_SLACK_WEBHOOK: ${{ secrets.CYPRESS_SLACK_WEBHOOK }}
|
||||||
|
CYPRESS_ETH_WALLET_MNEMONIC: ${{ secrets.CYPRESS_ETH_WALLET_MNEMONIC }}
|
||||||
|
|
||||||
|
######
|
||||||
|
## Upload logs
|
||||||
|
######
|
||||||
|
|
||||||
|
- name: Logs
|
||||||
|
run: vegacapsule network logs > vega-capsule-logs.txt
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: logs
|
||||||
|
path: ./vega-capsule-logs.txt
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
name: Cypress - trading
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
trigger:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
default: 'false'
|
||||||
|
vega-version:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
gobin:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
default: /home/runner/go/bin
|
||||||
|
skip-cache:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
tags:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
trading-e2e:
|
||||||
|
if: ${{ inputs.trigger == 'true' }}
|
||||||
|
timeout-minutes: 30
|
||||||
|
runs-on: self-hosted
|
||||||
|
steps:
|
||||||
|
# Add GOBIN to PATH
|
||||||
|
- name: Add GOBIN to PATH
|
||||||
|
run: echo ${{ inputs.gobin }} >> $GITHUB_PATH
|
||||||
|
|
||||||
|
# Checkout front ends
|
||||||
|
- name: Checkout frontend mono repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
path: './frontend-monorepo'
|
||||||
|
|
||||||
|
# Restore node_modules from cache if possible
|
||||||
|
- name: Restore node_modules from cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
frontend-monorepo/node_modules
|
||||||
|
/home/runner/.cache/Cypress
|
||||||
|
key: node_modules_cypress-${{ hashFiles('frontend-monorepo/yarn.lock') }}
|
||||||
|
|
||||||
|
# Install frontend dependencies
|
||||||
|
- name: Install root dependencies
|
||||||
|
run: yarn install --frozen-lockfile
|
||||||
|
working-directory: frontend-monorepo
|
||||||
|
|
||||||
|
#######
|
||||||
|
## Build and run Vegacapsule network
|
||||||
|
#######
|
||||||
|
|
||||||
|
- name: Install Vega binaries
|
||||||
|
uses: ./frontend-monorepo/.github/actions/install-vega-binaries
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.vega-version }}
|
||||||
|
gobin: ${{ inputs.gobin }}
|
||||||
|
|
||||||
|
######
|
||||||
|
## Setup a Vega wallet for our user
|
||||||
|
######
|
||||||
|
|
||||||
|
- name: Set up Vegawallet
|
||||||
|
uses: ./frontend-monorepo/.github/actions/setup-vegawallet
|
||||||
|
with:
|
||||||
|
recovery: ${{ secrets.TRADING_TEST_VEGA_WALLET_RECOVERY }}
|
||||||
|
passphrase: ${{ secrets.CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE }}
|
||||||
|
|
||||||
|
# To make sure that all Cypress binaries are installed properly
|
||||||
|
- name: Install cypress bins
|
||||||
|
run: yarn cypress install
|
||||||
|
working-directory: frontend-monorepo
|
||||||
|
|
||||||
|
- name: Run Cypress tests
|
||||||
|
run: npx nx run trading-e2e:e2e ${{ inputs.skip-cache }} --record --key ${{ secrets.CYPRESS_RECORD_KEY }} --browser chrome ${{ inputs.tags }}
|
||||||
|
working-directory: frontend-monorepo
|
||||||
|
env:
|
||||||
|
CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE: ${{ secrets.CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE }}
|
||||||
|
CYPRESS_SLACK_WEBHOOK: ${{ secrets.CYPRESS_SLACK_WEBHOOK }}
|
||||||
|
CYPRESS_ETH_WALLET_MNEMONIC: ${{ secrets.CYPRESS_ETH_WALLET_MNEMONIC }}
|
||||||
@@ -8,25 +8,22 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
master:
|
master:
|
||||||
name: Generate Queries
|
name: Generate Queries
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Setup node
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
with:
|
||||||
node-version-file: '.nvmrc'
|
fetch-depth: 0
|
||||||
# https://stackoverflow.com/questions/61010294/how-to-cache-yarn-packages-in-github-actions
|
- name: Use Node.js 16
|
||||||
cache: yarn
|
id: Node
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: 16.14.0
|
||||||
- name: Install root dependencies
|
- name: Install root dependencies
|
||||||
run: yarn install --frozen-lockfile
|
run: yarn install
|
||||||
|
|
||||||
- name: Generate queries
|
- name: Generate queries
|
||||||
run: node ./scripts/get-queries.js
|
run: node ./scripts/get-queries.js
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: queries
|
name: queries
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
---
|
|
||||||
name: Verify PR title
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_call:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
lint_pr:
|
|
||||||
timeout-minutes: 10
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
||||||
- name: Cache node modules
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: node_modules
|
|
||||||
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('yarn.lock') }}
|
|
||||||
|
|
||||||
- name: Check PR title
|
|
||||||
run: echo "${{ github.event.pull_request.title }}" | npx commitlint --config ./commitlint.config-ci.js
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
name: Verify PR title
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, ready_for_review, reopened, edited, synchronize]
|
||||||
|
jobs:
|
||||||
|
lint_pr:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Use Node.js 16
|
||||||
|
id: Node
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: 16.14.0
|
||||||
|
- name: Install commitlint cli and config
|
||||||
|
run: npm install @commitlint/cli @commitlint/config-conventional
|
||||||
|
- name: Create config
|
||||||
|
run: echo "module.exports = {extends:['@commitlint/config-conventional']};" > commitlint.config.js
|
||||||
|
- name: Check PR title
|
||||||
|
run: echo "${{ github.event.pull_request.title }}" | npx commitlint
|
||||||
@@ -7,7 +7,7 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
master:
|
master:
|
||||||
name: Generate Queries
|
name: Generate Queries
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@@ -19,7 +19,7 @@ jobs:
|
|||||||
id: Node
|
id: Node
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: 16.15.1
|
node-version: 16.14.0
|
||||||
- name: Install root dependencies
|
- name: Install root dependencies
|
||||||
run: yarn install
|
run: yarn install
|
||||||
- name: Generate queries
|
- name: Generate queries
|
||||||
|
|||||||
@@ -1,222 +0,0 @@
|
|||||||
name: (CD) Publish docker + s3
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_call:
|
|
||||||
inputs:
|
|
||||||
projects:
|
|
||||||
required: true
|
|
||||||
type: string
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
publish-dist:
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
app: ${{ fromJSON(inputs.projects) }}
|
|
||||||
name: ${{ matrix.app }}
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
timeout-minutes: 25
|
|
||||||
steps:
|
|
||||||
- name: Check out code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Set up QEMU
|
|
||||||
id: quemu
|
|
||||||
uses: docker/setup-qemu-action@v2
|
|
||||||
|
|
||||||
- name: Available platforms
|
|
||||||
run: echo ${{ steps.qemu.outputs.platforms }}
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v2
|
|
||||||
|
|
||||||
- name: Log in to the Container registry (ghcr)
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Log in to the Container registry (docker hub)
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
|
||||||
with:
|
|
||||||
# registry: registry.hub.docker.com
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
||||||
- name: Cache node modules
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: node_modules
|
|
||||||
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('yarn.lock') }}
|
|
||||||
|
|
||||||
# https://docs.github.com/en/actions/learn-github-actions/contexts
|
|
||||||
- name: Define variables
|
|
||||||
run: |
|
|
||||||
envName=''
|
|
||||||
domain="vega.rocks"
|
|
||||||
if [[ "${{ github.event_name }}" = "push" ]]; then
|
|
||||||
if [[ "${{ github.ref }}" =~ .*release/.* ]]; then
|
|
||||||
envName="$(echo ${{ github.ref }} | rev | cut -d '/' -f 1 | rev)"
|
|
||||||
elif [[ "${{ github.ref }}" =~ .*develop$ ]]; then
|
|
||||||
envName="stagnet1"
|
|
||||||
elif [[ "${{ matrix.app}}" = "trading" ]] && [[ ${{ startsWith(github.ref, 'refs/tags/v') && 'true' || 'false' }} = "true" ]]; then
|
|
||||||
envName="mainnet"
|
|
||||||
elif [[ "${{ github.ref }}" =~ .*main$ ]]; then
|
|
||||||
envName="mainnet"
|
|
||||||
fi
|
|
||||||
if [[ "${envName}" = "mainnet" ]]; then
|
|
||||||
domain="vega.xyz"
|
|
||||||
fi
|
|
||||||
bucketName="${{ matrix.app }}.${envName}.${domain}"
|
|
||||||
echo BUCKET_NAME=${bucketName} >> $GITHUB_ENV
|
|
||||||
fi
|
|
||||||
echo ENV_NAME=${envName} >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Build local dist
|
|
||||||
run: |
|
|
||||||
flags=""
|
|
||||||
if [[ ! -z "${{ env.ENV_NAME }}" ]]; then
|
|
||||||
if [[ "${{ env.ENV_NAME }}" != "ops-vega" ]]; then
|
|
||||||
flags="--env=${{ env.ENV_NAME }}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${{ matrix.app }}" = "trading" ]; then
|
|
||||||
yarn nx export trading $flags || (yarn install && yarn nx export trading $flags)
|
|
||||||
DIST_LOCATION=dist/apps/trading/exported
|
|
||||||
else
|
|
||||||
yarn nx build ${{ matrix.app }} $flags || (yarn install && yarn nx build ${{ matrix.app }} $flags)
|
|
||||||
DIST_LOCATION=dist/apps/${{ matrix.app }}
|
|
||||||
fi
|
|
||||||
mv $DIST_LOCATION dist-result
|
|
||||||
tree dist-result
|
|
||||||
|
|
||||||
- name: Build and export to local Docker
|
|
||||||
id: docker_build
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: docker/node-outside-docker.Dockerfile
|
|
||||||
load: true
|
|
||||||
build-args: |
|
|
||||||
APP=${{ matrix.app }}
|
|
||||||
ENV_NAME=${{ env.ENV_NAME }}
|
|
||||||
tags: |
|
|
||||||
ghcr.io/vegaprotocol/frontend/${{ matrix.app }}:local
|
|
||||||
|
|
||||||
- name: Image digest
|
|
||||||
if: ${{ github.event_name == 'pull_request' }}
|
|
||||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
||||||
|
|
||||||
- name: Sanity check docker image
|
|
||||||
run: |
|
|
||||||
echo "Check 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 cat /ipfs-hash > ${{ matrix.app }}-ipfs-hash
|
|
||||||
echo "List html directory"
|
|
||||||
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)
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
if: ${{ github.event_name == 'pull_request' || (matrix.app == 'trading' && github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/v') ) }}
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: docker/node-outside-docker.Dockerfile
|
|
||||||
push: true
|
|
||||||
build-args: |
|
|
||||||
APP=${{ matrix.app }}
|
|
||||||
ENV_NAME=${{ env.ENV_NAME }}
|
|
||||||
tags: |
|
|
||||||
ghcr.io/vegaprotocol/frontend/${{ matrix.app }}:${{ github.event.pull_request.head.sha || github.sha }}
|
|
||||||
|
|
||||||
- name: Publish dist as docker image (docker hub)
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
if: ${{ matrix.app == 'trading' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: docker/node-outside-docker.Dockerfile
|
|
||||||
push: true
|
|
||||||
build-args: |
|
|
||||||
APP=${{ matrix.app }}
|
|
||||||
ENV_NAME=${{ env.ENV_NAME }}
|
|
||||||
tags: |
|
|
||||||
vegaprotocol/${{ matrix.app }}:${{ github.ref_name }}
|
|
||||||
vegaprotocol/${{ matrix.app }}:mainnet
|
|
||||||
|
|
||||||
# bucket creation in github.com/vegaprotocol/terraform//frontend
|
|
||||||
- name: Publish dist to s3
|
|
||||||
uses: jakejarvis/s3-sync-action@master
|
|
||||||
if: ${{ github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/v') }}
|
|
||||||
with:
|
|
||||||
args: --acl private --follow-symlinks --delete
|
|
||||||
env:
|
|
||||||
AWS_S3_BUCKET: ${{ env.BUCKET_NAME }}
|
|
||||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
||||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
||||||
AWS_REGION: 'eu-west-1'
|
|
||||||
SOURCE_DIR: 'dist-result'
|
|
||||||
|
|
||||||
- name: Add preview label
|
|
||||||
uses: actions-ecosystem/action-add-labels@v1
|
|
||||||
if: ${{ github.event_name == 'pull_request' }}
|
|
||||||
with:
|
|
||||||
labels: ${{ matrix.app }}-preview
|
|
||||||
number: ${{ github.event.number }}
|
|
||||||
|
|
||||||
- name: Trigger fleek deployment
|
|
||||||
if: ${{ matrix.app == 'trading' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
|
|
||||||
run: |
|
|
||||||
# display info about app
|
|
||||||
curl -H "Authorization: ${{ secrets.FLEEK_API_KEY }}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{"query": "query{getSiteById(siteId:\"f8f2e051-f18e-49e6-b876-0a39369dc0d8\"){id latestDeploy{id status}}}"}' \
|
|
||||||
https://api.fleek.co/graphql
|
|
||||||
|
|
||||||
# trigger new deployment as base image is always set to vegaprotocol/trading:mainnet
|
|
||||||
curl -H "Authorization: ${{ secrets.FLEEK_API_KEY }}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{"query": "mutation{triggerDeploy(siteId:\"f8f2e051-f18e-49e6-b876-0a39369dc0d8\"){id status}}"}' \
|
|
||||||
https://api.fleek.co/graphql
|
|
||||||
|
|
||||||
- name: Update vega.trading DNS to redirect to the new console
|
|
||||||
if: ${{ matrix.app == 'trading' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
|
|
||||||
run: |
|
|
||||||
curl -L https://dist.ipfs.tech/kubo/v0.20.0/kubo_v0.20.0_linux-amd64.tar.gz -o kubo.tgz
|
|
||||||
tar -xzf kubo.tgz
|
|
||||||
export PATH="$PATH:$PWD/kubo"
|
|
||||||
which ipfs
|
|
||||||
new_hash=$(cat ${{ matrix.app }}-ipfs-hash)
|
|
||||||
new_cid=$(ipfs cid format -v 1 -b base32 $new_hash)
|
|
||||||
|
|
||||||
# Generate console URL
|
|
||||||
new_console_url_type=ipfs
|
|
||||||
# new_console_url_type=ipns
|
|
||||||
new_console_url_domain=cf-ipfs.com
|
|
||||||
# new_console_url_domain=dweb.link
|
|
||||||
new_console_url="https://${new_cid}.${new_console_url_type}.${new_console_url_domain}/"
|
|
||||||
echo "new_console_url=${new_console_url}"
|
|
||||||
|
|
||||||
# Update record in DNSimple
|
|
||||||
# docs: https://developer.dnsimple.com/v2/zones/records/#updateZoneRecord
|
|
||||||
dnsimple_account_id=84895
|
|
||||||
dnsimple_zone_name=vega.trading
|
|
||||||
dnsimple_record_id=44409591
|
|
||||||
# see: https://dnsimple.com/a/84895/domains/vega.trading/records/44409591/edit
|
|
||||||
|
|
||||||
curl -H 'Authorization: Bearer ${{ secrets.DNSIMPLE_API_TOKEN }}' \
|
|
||||||
-H 'Accept: application/json' \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-X PATCH \
|
|
||||||
-d "{
|
|
||||||
\"content\": \"${new_console_url}\"
|
|
||||||
}" \
|
|
||||||
https://api.dnsimple.com/v2/${dnsimple_account_id}/zones/${dnsimple_zone_name}/records/${dnsimple_record_id}
|
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
name: Publish docker containers
|
||||||
|
|
||||||
|
'on':
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v[0-9]+.[0-9]+.[0-9]+'
|
||||||
|
- 'v[0-9]+.[0-9]+.[0-9]+-pre[0-9]+'
|
||||||
|
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
publish:
|
||||||
|
description: 'Publish tag to Docker Hub & GitHub Registry'
|
||||||
|
required: false
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
tag:
|
||||||
|
description: 'Git Tag to build and publish'
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
default: ''
|
||||||
|
apps:
|
||||||
|
description: 'Applications to build and publish'
|
||||||
|
required: false
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- '["explorer", "token", "trading"]'
|
||||||
|
- '["explorer"]'
|
||||||
|
- '["token"]'
|
||||||
|
- '["trading"]'
|
||||||
|
archs:
|
||||||
|
description: 'Architecture to build and publish'
|
||||||
|
required: false
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- linux/amd64, linux/arm64
|
||||||
|
- linux/amd64
|
||||||
|
- linux/arm64
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
master:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
app: ${{ fromJson(inputs.apps || '["explorer", "token", "trading"]') }}
|
||||||
|
name: Build the ${{ matrix.app }} image
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: ${{ inputs.tag }}
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
id: quemu
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
|
||||||
|
- name: Available platforms
|
||||||
|
run: echo ${{ steps.qemu.outputs.platforms }}
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
- name: Login to DockerHub
|
||||||
|
if: ${{ inputs.publish || startsWith(github.ref, 'refs/tags/') }}
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Determine Docker Image tag
|
||||||
|
id: tags
|
||||||
|
run: |
|
||||||
|
hash=$(git rev-parse HEAD|cut -b1-8)
|
||||||
|
versionTag=${{ inputs.tag || startsWith(github.ref, 'refs/tags/') && github.ref_name || '${hash}' }}
|
||||||
|
echo ::set-output name=version::${versionTag}
|
||||||
|
echo ::set-output name=npmVersion::$(cat dockerfiles/${{ matrix.app =='trading' && 'Dockerfile.next' || 'Dockerfile.cra' }} | grep FROM | head -n 1 | awk '{print $2}' | cut -d ':' -f 2 | cut -d '-' -f 1 )
|
||||||
|
|
||||||
|
- name: Print config
|
||||||
|
run: |
|
||||||
|
git rev-parse --verify HEAD
|
||||||
|
git status
|
||||||
|
echo "inputs.tag=${{ inputs.tag }}"
|
||||||
|
echo "inputs.publish=${{ inputs.publish }}"
|
||||||
|
echo "inputs.apps=${{ inputs.apps }}"
|
||||||
|
echo "inputs.archs=${{ inputs.archs }}"
|
||||||
|
echo "steps.tags.outputs.version=${{ steps.tags.outputs.version }}"
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: ${{ steps.tags.outputs.npmVersion }}
|
||||||
|
|
||||||
|
- name: Build frontend dists
|
||||||
|
run: |
|
||||||
|
yarn --verbose --pure-lockfile
|
||||||
|
yarn nx ${{ matrix.app =='trading' && 'export' || 'build' }} ${{ matrix.app }} --pure-lockfile
|
||||||
|
|
||||||
|
- name: Build and export to local Docker
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: false
|
||||||
|
file: dockerfiles/${{ matrix.app =='trading' && 'Dockerfile.next' || 'Dockerfile.cra' }}.dist
|
||||||
|
build-args: APP=${{ matrix.app }}
|
||||||
|
load: true
|
||||||
|
tags: vegaprotocol/${{ matrix.app }}:local
|
||||||
|
|
||||||
|
- name: Sanity check docker image
|
||||||
|
run: |
|
||||||
|
docker run --rm vegaprotocol/${{ matrix.app }}:local cat .env
|
||||||
|
docker run --rm vegaprotocol/${{ matrix.app }}:local ls -lah
|
||||||
|
|
||||||
|
- name: Build and push to DockerHub
|
||||||
|
id: docker_build
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: ${{ inputs.publish || startsWith(github.ref, 'refs/tags/') }}
|
||||||
|
file: dockerfiles/${{ matrix.app =='trading' && 'Dockerfile.next' || 'Dockerfile.cra' }}.dist
|
||||||
|
build-args: APP=${{ matrix.app }}
|
||||||
|
platforms: ${{ inputs.archs || 'linux/amd64, linux/arm64' }}
|
||||||
|
tags: |
|
||||||
|
vegaprotocol/${{ matrix.app }}:latest
|
||||||
|
vegaprotocol/${{ matrix.app }}:${{ steps.tags.outputs.version }}
|
||||||
|
|
||||||
|
- name: Image digest
|
||||||
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
name: Publish libs to npm
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
project:
|
|
||||||
description: 'Monorepo project to publish'
|
|
||||||
required: true
|
|
||||||
type: choice
|
|
||||||
options:
|
|
||||||
- announcements
|
|
||||||
- ui-toolkit
|
|
||||||
- react-helpers
|
|
||||||
- tailwindcss-config
|
|
||||||
- types
|
|
||||||
- utils
|
|
||||||
- i18n
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
publish:
|
|
||||||
name: Build & Publish - Tag
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
permissions:
|
|
||||||
contents: 'read'
|
|
||||||
actions: 'read'
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
||||||
- name: Install root dependencies
|
|
||||||
run: yarn install --frozen-lockfile
|
|
||||||
|
|
||||||
- name: Build project
|
|
||||||
run: yarn nx build ${{inputs.project}}
|
|
||||||
|
|
||||||
- name: Publish project to @vegaprotocol
|
|
||||||
uses: JS-DevTools/npm-publish@v1
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.NPM_TOKEN }}
|
|
||||||
package: dist/libs/${{inputs.project}}/package.json
|
|
||||||
access: public
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
name: 'Rollback console'
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
version:
|
|
||||||
description: 'Version that should be set on rollback'
|
|
||||||
required: true
|
|
||||||
type: string
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
rollback:
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
timeout-minutes: 10
|
|
||||||
steps:
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v2
|
|
||||||
|
|
||||||
- name: Log in to the Container registry (docker hub)
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Retag mainnet
|
|
||||||
run: |
|
|
||||||
docker pull vegaprotocol/trading:${{ inputs.version }}
|
|
||||||
docker tag vegaprotocol/trading:${{ inputs.version }} vegaprotocol/trading:mainnet
|
|
||||||
docker push vegaprotocol/trading:mainnet
|
|
||||||
docker run --rm vegaprotocol/trading:mainnet cat /ipfs-hash > ipfs-hash
|
|
||||||
|
|
||||||
- name: Trigger fleek deployment
|
|
||||||
run: |
|
|
||||||
# display info about app
|
|
||||||
curl -H "Authorization: ${{ secrets.FLEEK_API_KEY }}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{"query": "query{getSiteById(siteId:\"f8f2e051-f18e-49e6-b876-0a39369dc0d8\"){id latestDeploy{id status}}}"}' \
|
|
||||||
https://api.fleek.co/graphql
|
|
||||||
|
|
||||||
# trigger new deployment as base image is always set to vegaprotocol/trading:mainnet
|
|
||||||
curl -H "Authorization: ${{ secrets.FLEEK_API_KEY }}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{"query": "mutation{triggerDeploy(siteId:\"f8f2e051-f18e-49e6-b876-0a39369dc0d8\"){id status}}"}' \
|
|
||||||
https://api.fleek.co/graphql
|
|
||||||
|
|
||||||
- name: Update vega.trading DNS to redirect to the new console
|
|
||||||
run: |
|
|
||||||
curl -L https://dist.ipfs.tech/kubo/v0.20.0/kubo_v0.20.0_linux-amd64.tar.gz -o kubo.tgz
|
|
||||||
tar -xzf kubo.tgz
|
|
||||||
export PATH="$PATH:$PWD/kubo"
|
|
||||||
which ipfs
|
|
||||||
new_hash=$(cat ipfs-hash)
|
|
||||||
new_cid=$(ipfs cid format -v 1 -b base32 $new_hash)
|
|
||||||
|
|
||||||
# Generate console URL
|
|
||||||
new_console_url_type=ipfs
|
|
||||||
# new_console_url_type=ipns
|
|
||||||
new_console_url_domain=cf-ipfs.com
|
|
||||||
# new_console_url_domain=dweb.link
|
|
||||||
new_console_url="https://${new_cid}.${new_console_url_type}.${new_console_url_domain}/"
|
|
||||||
echo "new_console_url=${new_console_url}"
|
|
||||||
|
|
||||||
# Update record in DNSimple
|
|
||||||
# docs: https://developer.dnsimple.com/v2/zones/records/#updateZoneRecord
|
|
||||||
dnsimple_account_id=84895
|
|
||||||
dnsimple_zone_name=vega.trading
|
|
||||||
dnsimple_record_id=44409591
|
|
||||||
# see: https://dnsimple.com/a/84895/domains/vega.trading/records/44409591/edit
|
|
||||||
|
|
||||||
curl -H 'Authorization: Bearer ${{ secrets.DNSIMPLE_API_TOKEN }}' \
|
|
||||||
-H 'Accept: application/json' \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-X PATCH \
|
|
||||||
-d "{
|
|
||||||
\"content\": \"${new_console_url}\"
|
|
||||||
}" \
|
|
||||||
https://api.dnsimple.com/v2/${dnsimple_account_id}/zones/${dnsimple_zone_name}/records/${dnsimple_record_id}
|
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
name: Unit tests & build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- develop
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
jobs:
|
||||||
|
pr:
|
||||||
|
name: Test and lint - PR
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: 'read'
|
||||||
|
actions: 'read'
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Derive appropriate SHAs for base and head for `nx affected` commands
|
||||||
|
uses: nrwl/nx-set-shas@v2
|
||||||
|
with:
|
||||||
|
main-branch-name: ${{ github.base_ref }}
|
||||||
|
- name: Use Node.js 16
|
||||||
|
id: Node
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 16.14.0
|
||||||
|
- name: Restore node_modules from cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: '**/node_modules'
|
||||||
|
key: node_modules-${{ hashFiles('**/yarn.lock') }}
|
||||||
|
- name: Install root dependencies
|
||||||
|
run: yarn install --frozen-lockfile
|
||||||
|
- name: Check formatting
|
||||||
|
run: yarn nx format:check
|
||||||
|
- name: Lint affected
|
||||||
|
run: yarn nx affected:lint --max-warnings=0
|
||||||
|
- name: Test affected
|
||||||
|
run: yarn nx affected:test
|
||||||
|
- name: Build affected
|
||||||
|
run: yarn nx affected:build
|
||||||
|
- name: Build affected spec
|
||||||
|
run: yarn nx affected --target=build-spec
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
project:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
vega-version:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
gobin:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
default: /home/runner/go/bin
|
||||||
|
skip-cache:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
tags:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
night-run:
|
||||||
|
required: false
|
||||||
|
type: boolean
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run-console-lite-e2e:
|
||||||
|
uses: ./.github/workflows/cypress-console-lite-e2e.yml
|
||||||
|
secrets: inherit
|
||||||
|
with:
|
||||||
|
trigger: ${{ contains(inputs.project, 'console-lite-e2e') || contains(inputs.project, 'console-lite') }}
|
||||||
|
vega-version: ${{ inputs.vega-version }}
|
||||||
|
gobin: ${{ inputs.gobin }}
|
||||||
|
skip-cache: ${{ inputs.skip-cache }}
|
||||||
|
tags: ${{ inputs.tags }}
|
||||||
|
|
||||||
|
run-explorer-e2e:
|
||||||
|
uses: ./.github/workflows/cypress-explorer-e2e.yml
|
||||||
|
secrets: inherit
|
||||||
|
with:
|
||||||
|
trigger: ${{ contains(inputs.project, 'explorer-e2e') || contains(inputs.project, 'explorer') }}
|
||||||
|
vega-version: ${{ inputs.vega-version }}
|
||||||
|
gobin: ${{ inputs.gobin }}
|
||||||
|
skip-cache: ${{ inputs.skip-cache }}
|
||||||
|
tags: ${{ inputs.tags }}
|
||||||
|
night-run: ${{ inputs.night-run }}
|
||||||
|
|
||||||
|
run-liquidity-e2e:
|
||||||
|
uses: ./.github/workflows/cypress-liquidity-provision-dashboard-e2e.yml
|
||||||
|
secrets: inherit
|
||||||
|
with:
|
||||||
|
trigger: ${{ contains(inputs.project, 'liquidity-provision-dashboard-e2e') || contains(inputs.project, 'liquidity-provision-dashboard') }}
|
||||||
|
|
||||||
|
run-stats-e2e:
|
||||||
|
uses: ./.github/workflows/cypress-stats-e2e.yml
|
||||||
|
secrets: inherit
|
||||||
|
with:
|
||||||
|
trigger: ${{ contains(inputs.project, 'stats-e2e') || contains(inputs.project, 'stats') }}
|
||||||
|
|
||||||
|
run-token-e2e:
|
||||||
|
uses: ./.github/workflows/cypress-token-e2e.yml
|
||||||
|
secrets: inherit
|
||||||
|
with:
|
||||||
|
trigger: ${{ contains(inputs.project, 'token-e2e') || contains(inputs.project, 'token') }}
|
||||||
|
vega-version: ${{ inputs.vega-version }}
|
||||||
|
gobin: ${{ inputs.gobin }}
|
||||||
|
skip-cache: ${{ inputs.skip-cache }}
|
||||||
|
tags: ${{ inputs.tags }}
|
||||||
|
|
||||||
|
run-trading-e2e:
|
||||||
|
uses: ./.github/workflows/cypress-trading-e2e.yml
|
||||||
|
secrets: inherit
|
||||||
|
with:
|
||||||
|
trigger: ${{ contains(inputs.project, 'trading-e2e') || contains(inputs.project, 'trading') }}
|
||||||
|
vega-version: ${{ inputs.vega-version }}
|
||||||
|
gobin: ${{ inputs.gobin }}
|
||||||
|
skip-cache: ${{ inputs.skip-cache }}
|
||||||
|
tags: ${{ inputs.tags }}
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
# compiled output
|
# compiled output
|
||||||
/dist
|
/dist
|
||||||
/dist-result
|
|
||||||
/tmp
|
/tmp
|
||||||
/out-tsc
|
/out-tsc
|
||||||
/tools/executors/**/*.js
|
/tools/executors/**/*.js
|
||||||
@@ -47,6 +46,3 @@ cypress.env.json
|
|||||||
|
|
||||||
# Next.js
|
# Next.js
|
||||||
.next
|
.next
|
||||||
|
|
||||||
#cypress
|
|
||||||
/apps/**/cypress/reports/
|
|
||||||
|
|||||||
@@ -7,4 +7,5 @@ __generated___
|
|||||||
|
|
||||||
apps/static/src/assets/devnet-tranches.json
|
apps/static/src/assets/devnet-tranches.json
|
||||||
apps/static/src/assets/mainnet-tranches.json
|
apps/static/src/assets/mainnet-tranches.json
|
||||||
|
apps/static/src/assets/stagnet3-tranches.json
|
||||||
apps/static/src/assets/testnet-tranches.json
|
apps/static/src/assets/testnet-tranches.json
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
* @vegaprotocol/frontend
|
* @vegaprotocol/frontend
|
||||||
*.graphql @vegaprotocol/core
|
|
||||||
|
|||||||
Vendored
+19
-1
@@ -1,2 +1,20 @@
|
|||||||
@Library('vega-shared-library') _
|
@Library('vega-shared-library') _
|
||||||
runApprobation ignoreFailure: false, frontendBranch: env.BRANCH_NAME, type: 'frontend'
|
|
||||||
|
def commitHash = 'UNKNOWN'
|
||||||
|
|
||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
options {
|
||||||
|
skipDefaultCheckout true
|
||||||
|
parallelsAlwaysFailFast()
|
||||||
|
}
|
||||||
|
stages {
|
||||||
|
stage('approbation') {
|
||||||
|
steps {
|
||||||
|
sh 'printenv'
|
||||||
|
checkout scm
|
||||||
|
runApprobation ignoreFailure: false, frontendBranch: env.BRANCH_NAME, type: 'frontend'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
.PHONY: latest-release
|
|
||||||
latest-release:
|
|
||||||
gh release list | head -n 1 | awk '{print $1}'
|
|
||||||
|
|
||||||
.PHONY: show-latest-release
|
|
||||||
show-latest-release:
|
|
||||||
gh release view `gh release list | head -n 1 | awk '{print $1}'`
|
|
||||||
|
|
||||||
.PHONY: recalculate-ipfs
|
|
||||||
recalculate-ipfs:
|
|
||||||
echo "ipfs hash inside the image"
|
|
||||||
docker run --rm ${TAG} cat /ipfs-hash
|
|
||||||
echo "recalculating ipfs hash"
|
|
||||||
docker run --rm ${TAG} ipfs add -r /usr/share/nginx/html
|
|
||||||
|
|
||||||
.PHONY: eject-ipfs-hash
|
|
||||||
unpack:
|
|
||||||
docker create --name=dist ${TAG}
|
|
||||||
docker cp dist:/usr/share/nginx/html dist
|
|
||||||
docker rm dist
|
|
||||||
@@ -22,6 +22,10 @@ The utility dApp for interacting with the Vega token and using its' utility. Thi
|
|||||||
|
|
||||||
The block explorer for the Vega network, showing details of raw chain states and the state of markets on the Vega network.
|
The block explorer for the Vega network, showing details of raw chain states and the state of markets on the Vega network.
|
||||||
|
|
||||||
|
### [Stats](./apps/stats)
|
||||||
|
|
||||||
|
An application for the status of the Vega network. Showing block height and other network activity.
|
||||||
|
|
||||||
### [Static](./apps/static)
|
### [Static](./apps/static)
|
||||||
|
|
||||||
Hosting for static content being shared across apps, for example fonts.
|
Hosting for static content being shared across apps, for example fonts.
|
||||||
@@ -72,7 +76,7 @@ Run `nx serve my-app` for a dev server. Navigate to the port specified in `app/<
|
|||||||
In order to generate the schemas for your GraphQL queries, you can run `GRAPHQL_SCHEMA_PATH=[YOUR SCHEMA FILE / API URL HERE] nx run types:generate`.
|
In order to generate the schemas for your GraphQL queries, you can run `GRAPHQL_SCHEMA_PATH=[YOUR SCHEMA FILE / API URL HERE] nx run types:generate`.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export GRAPHQL_SCHEMA_PATH=https://api.n07.testnet.vega.xyz/graphql
|
export GRAPHQL_SCHEMA_PATH=https://api.n11.testnet.vega.xyz/graphql
|
||||||
yarn nx run types:generate
|
yarn nx run types:generate
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -84,12 +88,12 @@ Run `nx test my-app` to execute the unit tests with [Jest](https://jestjs.io), o
|
|||||||
|
|
||||||
### Using wallet
|
### Using wallet
|
||||||
|
|
||||||
To run tests locally using your own wallets make sure you have generated at least two public keys and update the following environment variables in `cypress.config.js` to match your wallet.
|
To run tests locally using your own wallets you can add the following environment variables to `cypress.json`
|
||||||
|
|
||||||
1. Set `VEGA_PUBLIC_KEY` and `TRUNCATED_VEGA_PUBLIC_KEY` to your first public key.
|
1. Change `TRADING_TEST_VEGA_WALLET_NAME` to your Vega wallet name
|
||||||
2. Set `VEGA_PUBLIC_KEY2` and `TRUNCATED_VEGA_PUBLIC_KEY2` to your second public key.
|
2. Add `TRADING_TEST_VEGA_WALLET_PASSPHRASE` as your wallet passphrase
|
||||||
3. Set `TRADING_TEST_VEGA_WALLET_PASSPHRASE` as your wallet passphrase
|
3. Add `ETH_WALLET_MNEMONIC` as your Ethereum wallet mnemonic
|
||||||
4. Add `ETH_WALLET_MNEMONIC` as your Ethereum wallet mnemonic
|
4. Use [vegawallet-dummy](https://github.com/vegaprotocol/vegawallet-dummy) to avoid being prompted in CLI during test execution.
|
||||||
|
|
||||||
### Formatting
|
### Formatting
|
||||||
|
|
||||||
@@ -103,68 +107,25 @@ In CI linting, formatting and also run. These checks can be seen in the [CI work
|
|||||||
|
|
||||||
Visit the [Nx Documentation](https://nx.dev/getting-started/intro) to learn more.
|
Visit the [Nx Documentation](https://nx.dev/getting-started/intro) to learn more.
|
||||||
|
|
||||||
# 🐋 Hosting a console
|
# Docker & Vegacapsule
|
||||||
|
|
||||||
To host a console there are two possible build scenarios for running the frontends: nx performed **outside** or **inside** docker build. For specific build instructions follow [build instructions](#build-instructions).
|
## Docker
|
||||||
|
|
||||||
In order to run a container on port 3000:
|
The [Dockerfile](./dockerfiles) for running the frontends is pretty basic, merely building the application with the APP arg that is passed in and serving the application from [nginx](./nginx/nginx.conf). The only complexity that exists is that there is a script which allows the passing of run time environment variables to the containers. See configuration below for how to do this.
|
||||||
|
|
||||||
|
You can build any of the containers locally with the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker build --dockerfile dockerfiles/Dockerfile.cra . --build-arg APP=[YOUR APP] --tag=[TAG]
|
||||||
|
```
|
||||||
|
|
||||||
|
In order to run a container:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run -p 3000:80 [TAG]
|
docker run -p 3000:80 [TAG]
|
||||||
```
|
```
|
||||||
|
|
||||||
## Build instructions
|
Images ending with `.dist` are to pack locally created transpiled HTML files into nginx container for non-compatible with yarn architectures like M1 Mac
|
||||||
|
|
||||||
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 outside the docker
|
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
./docker/prepare-dist.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
You can build any of the containers locally with the following command:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
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
|
|
||||||
|
|
||||||
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 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`
|
|
||||||
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`.
|
|
||||||
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`
|
|
||||||
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. **it is not possible to calculate same ipfs hash on files that are result of copy operation**
|
|
||||||
|
|
||||||
## Config
|
## Config
|
||||||
|
|
||||||
@@ -195,23 +156,6 @@ In order to run the bootstrap command to generate and start a new network, we mu
|
|||||||
vegacapsule network bootstrap --config-path=../frontend-monorepo/vegacapsule/config.hcl
|
vegacapsule network bootstrap --config-path=../frontend-monorepo/vegacapsule/config.hcl
|
||||||
```
|
```
|
||||||
|
|
||||||
In order to setup and run vegawallet for e2e capsule tests, in a separate terminal window:
|
|
||||||
|
|
||||||
1. cd into `./vegacapsule`
|
|
||||||
2. run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
bash setup-vegawallet.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
3. copy generated `api-token` and paste the token into `CYPRESS_VEGA_WALLET_API_TOKEN` environment variable in either `apps/governance-e2e/.env` or `apps/explorer-e2e/.env` depending on which project needs testing.
|
|
||||||
|
|
||||||
Note: The script is only needed if capsule was built for first time or fresh. To run existing wallet service for capsule:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
vega wallet service run -n DV --load-tokens --tokens-passphrase-file passphrase --no-version-check --automatic-consent --home ~/.vegacapsule/testnet/wallet
|
|
||||||
```
|
|
||||||
|
|
||||||
# 📑 License
|
# 📑 License
|
||||||
|
|
||||||
[MIT](./LICENSE)
|
[MIT](./LICENSE)
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# App configuration variables
|
||||||
|
NX_VEGA_CONFIG_URL=https://static.vega.xyz/assets/stagnet3-network.json
|
||||||
|
NX_VEGA_URL=https://api.stagnet3.vega.xyz/graphql
|
||||||
|
NX_VEGA_ENV=STAGNET3
|
||||||
|
NX_ETHEREUM_PROVIDER_URL=https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||||
|
NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
||||||
|
NX_VEGA_EXPLORER_URL=https://stagnet3.explorer.vega.xyz
|
||||||
|
NX_VEGA_WALLET_URL=http://localhost:1789
|
||||||
|
CYPRESS_VEGA_ENV=STAGNET3
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
const { defineConfig } = require('cypress');
|
||||||
|
module.exports = defineConfig({
|
||||||
|
projectId: 'et4snf',
|
||||||
|
|
||||||
|
e2e: {
|
||||||
|
setupNodeEvents(on, config) {
|
||||||
|
require('cypress-grep/src/plugin')(config);
|
||||||
|
return config;
|
||||||
|
},
|
||||||
|
baseUrl: 'http://localhost:4200',
|
||||||
|
fileServerFolder: '.',
|
||||||
|
fixturesFolder: false,
|
||||||
|
specPattern: './src/integration/*.ts',
|
||||||
|
excludeSpecPattern: '**/*.js',
|
||||||
|
modifyObstructiveCode: false,
|
||||||
|
supportFile: './src/support/index.js',
|
||||||
|
video: false,
|
||||||
|
videoUploadOnPasses: false,
|
||||||
|
videosFolder: '../../dist/cypress/apps/console-lite-e2e/videos',
|
||||||
|
screenshotsFolder: '../../dist/cypress/apps/console-lite-e2e/screenshots',
|
||||||
|
chromeWebSecurity: false,
|
||||||
|
viewportWidth: 1440,
|
||||||
|
viewportHeight: 900,
|
||||||
|
},
|
||||||
|
env: {
|
||||||
|
TRADING_TEST_VEGA_WALLET_NAME: 'UI_Trading_Test',
|
||||||
|
ETHEREUM_PROVIDER_URL:
|
||||||
|
'https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8',
|
||||||
|
VEGA_PUBLIC_KEY:
|
||||||
|
'47836c253520d2661bf5bed6339c0de08fd02cf5d4db0efee3b4373f20c7d278',
|
||||||
|
VEGA_PUBLIC_KEY2:
|
||||||
|
'1a18cdcaaa4f44a57b35a4e9b77e0701c17a476f2b407620f8c17371740cf2e4',
|
||||||
|
TRUNCATED_VEGA_PUBLIC_KEY: '47836c…c7d278',
|
||||||
|
TRUNCATED_VEGA_PUBLIC_KEY2: '1a18cd…0cf2e4',
|
||||||
|
ETHEREUM_WALLET_ADDRESS: '0x265Cc6d39a1B53d0d92068443009eE7410807158',
|
||||||
|
ETHERSCAN_URL: 'https://sepolia.etherscan.io',
|
||||||
|
tsConfig: 'tsconfig.json',
|
||||||
|
TAGS: 'not @todo and not @ignore and not @manual',
|
||||||
|
TRADING_TEST_VEGA_WALLET_PASSPHRASE: '123',
|
||||||
|
ETH_WALLET_MNEMONIC:
|
||||||
|
'ugly gallery notice network true range brave clarify flat logic someone chunk',
|
||||||
|
grepTags: '@regression @smoke @slow',
|
||||||
|
grepFilterSpecs: true,
|
||||||
|
grepOmitFiltered: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
declare module '*.scss';
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||||
|
"sourceRoot": "apps/console-lite-e2e/src",
|
||||||
|
"projectType": "application",
|
||||||
|
"targets": {
|
||||||
|
"e2e": {
|
||||||
|
"executor": "@nrwl/cypress:cypress",
|
||||||
|
"options": {
|
||||||
|
"cypressConfig": "apps/console-lite-e2e/cypress.config.js",
|
||||||
|
"devServerTarget": "console-lite:serve"
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"production": {
|
||||||
|
"devServerTarget": "console-lite:serve:production"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lint": {
|
||||||
|
"executor": "@nrwl/linter:eslint",
|
||||||
|
"outputs": ["{options.outputFile}"],
|
||||||
|
"options": {
|
||||||
|
"lintFilePatterns": ["apps/console-lite-e2e/**/*.{js,ts}"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"build": {
|
||||||
|
"executor": "@nrwl/workspace:run-commands",
|
||||||
|
"outputs": [],
|
||||||
|
"options": {
|
||||||
|
"command": "yarn tsc --project ./apps/console-lite-e2e/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tags": [],
|
||||||
|
"implicitDependencies": ["console-lite"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import { aliasQuery } from '@vegaprotocol/cypress';
|
||||||
|
import {
|
||||||
|
generateSimpleMarkets,
|
||||||
|
generateMarketsCandles,
|
||||||
|
} from '../support/mocks/generate-markets';
|
||||||
|
|
||||||
|
describe('simple trading app', { tags: '@smoke' }, () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.mockGQL((req) => {
|
||||||
|
aliasQuery(req, 'Markets', generateSimpleMarkets());
|
||||||
|
aliasQuery(req, 'MarketsCandles', generateMarketsCandles());
|
||||||
|
});
|
||||||
|
cy.visit('/');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('render', () => {
|
||||||
|
cy.get('#root').should('exist');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
describe('console lite header', { tags: '@smoke' }, () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
window.localStorage.setItem('theme', 'dark');
|
||||||
|
cy.visit('/');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('logo should linked home', () => {
|
||||||
|
cy.get('span').contains('Markets').click();
|
||||||
|
cy.location('pathname').should('eq', '/markets');
|
||||||
|
cy.getByTestId('header').find('a').click();
|
||||||
|
cy.location('pathname').should('eq', '/');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('theme switcher should switch theme', () => {
|
||||||
|
cy.get('#root').children().eq(0).as('Container');
|
||||||
|
cy.get('@Container').should('have.css', 'background-color', 'rgb(8, 8, 8)');
|
||||||
|
cy.getByTestId('theme-switcher').click();
|
||||||
|
cy.get('@Container').should(
|
||||||
|
'have.css',
|
||||||
|
'background-color',
|
||||||
|
'rgb(255, 255, 255)'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('wallet connector should open a dialog', () => {
|
||||||
|
cy.get('[role="dialog"]').should('not.exist');
|
||||||
|
cy.getByTestId('connect-vega-wallet').click();
|
||||||
|
cy.get('[role="dialog"]').should('be.visible');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,137 @@
|
|||||||
|
import { aliasQuery } from '@vegaprotocol/cypress';
|
||||||
|
import type { MarketsQuery } from '@vegaprotocol/market-list';
|
||||||
|
import {
|
||||||
|
generateLongListMarkets,
|
||||||
|
generateSimpleMarkets,
|
||||||
|
generateMarketsCandles,
|
||||||
|
} from '../support/mocks/generate-markets';
|
||||||
|
|
||||||
|
describe('market list', { tags: '@smoke' }, () => {
|
||||||
|
describe('simple url', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.mockGQL((req) => {
|
||||||
|
aliasQuery(req, 'Markets', generateSimpleMarkets());
|
||||||
|
aliasQuery(req, 'MarketsCandles', generateMarketsCandles());
|
||||||
|
});
|
||||||
|
cy.visit('/markets');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('selects menus', () => {
|
||||||
|
cy.get('[aria-label="Sidebar Navigation Menu"] [aria-current]').should(
|
||||||
|
'have.text',
|
||||||
|
'Markets'
|
||||||
|
);
|
||||||
|
cy.getByTestId('state-trigger').should('have.text', 'Active');
|
||||||
|
cy.get('[aria-label="Future"]').click();
|
||||||
|
cy.get('[data-testid="market-assets-menu"] a.active').should(
|
||||||
|
'have.text',
|
||||||
|
'All'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('navigation should make possibly shortest url', () => {
|
||||||
|
cy.location('pathname').should('equal', '/markets');
|
||||||
|
|
||||||
|
cy.getByTestId('state-trigger').click();
|
||||||
|
cy.get('[role=menuitemcheckbox]').contains('All').click();
|
||||||
|
cy.location('pathname').should('equal', '/markets/all');
|
||||||
|
|
||||||
|
cy.get('[aria-label="Future"]').click();
|
||||||
|
cy.location('pathname').should('eq', '/markets/all/Future');
|
||||||
|
let asset = '';
|
||||||
|
cy.getByTestId('market-assets-menu')
|
||||||
|
.children()
|
||||||
|
.then((children) => {
|
||||||
|
if (children.length > 1) {
|
||||||
|
asset = children[1].innerText;
|
||||||
|
if (asset) {
|
||||||
|
cy.wrap(children[1]).click();
|
||||||
|
cy.location('pathname').should(
|
||||||
|
'match',
|
||||||
|
new RegExp(`/markets/all/Future/${asset}`, 'i')
|
||||||
|
);
|
||||||
|
cy.get('a').contains('All Markets').click();
|
||||||
|
cy.location('pathname').should('eq', '/markets/all');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
cy.getByTestId('state-trigger').click();
|
||||||
|
cy.get('[role=menuitemcheckbox]').contains('Active').click();
|
||||||
|
cy.location('pathname').should('equal', '/markets');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('url params should select filters', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.mockGQL((req) => {
|
||||||
|
aliasQuery(req, 'Markets', generateSimpleMarkets());
|
||||||
|
aliasQuery(req, 'MarketsCandles', generateMarketsCandles());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('suspended status', () => {
|
||||||
|
cy.visit('/markets/Suspended');
|
||||||
|
cy.getByTestId('state-trigger').should('have.text', 'Suspended');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('last asset (if exists)', () => {
|
||||||
|
cy.visit('/markets');
|
||||||
|
cy.wait('@Markets').then((filters) => {
|
||||||
|
const data: MarketsQuery | undefined = filters?.response?.body?.data;
|
||||||
|
if (data?.marketsConnection?.edges.length) {
|
||||||
|
const asset =
|
||||||
|
data?.marketsConnection?.edges[0].node.tradableInstrument.instrument
|
||||||
|
.product.settlementAsset.symbol;
|
||||||
|
cy.visit(`/markets/Suspended/Future/${asset}`);
|
||||||
|
cy.getByTestId('market-assets-menu')
|
||||||
|
.find('a.active')
|
||||||
|
.should('have.text', asset);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Future product', () => {
|
||||||
|
cy.visit('/markets/Suspended/Future');
|
||||||
|
cy.getByTestId('market-products-menu')
|
||||||
|
.find('a.active')
|
||||||
|
.should('have.text', 'Future');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('long list of results should be handled properly', () => {
|
||||||
|
it('handles 1000 markets', () => {
|
||||||
|
cy.viewport(1440, 900);
|
||||||
|
cy.mockGQL((req) => {
|
||||||
|
aliasQuery(req, 'Markets', generateLongListMarkets(1000));
|
||||||
|
aliasQuery(req, 'MarketsCandles', generateMarketsCandles());
|
||||||
|
});
|
||||||
|
performance.mark('start-1k');
|
||||||
|
cy.visit('/markets');
|
||||||
|
cy.get('.ag-center-cols-container', { timeout: 50000 }).then(() => {
|
||||||
|
performance.mark('end-1k');
|
||||||
|
performance.measure('load-1k', 'start-1k', 'end-1k');
|
||||||
|
const measure = performance.getEntriesByName('load-1k')[0];
|
||||||
|
expect(measure.duration).lte(20000);
|
||||||
|
cy.log(`Ag-grid 1k load took ${measure.duration} milliseconds.`);
|
||||||
|
|
||||||
|
cy.get('.ag-root').should('have.attr', 'aria-rowcount', '1001');
|
||||||
|
cy.get('.ag-center-cols-container')
|
||||||
|
.find('[role="row"]')
|
||||||
|
.its('length')
|
||||||
|
.then((length) => expect(length).to.be.closeTo(20, 3));
|
||||||
|
cy.get('.ag-cell-label-container').eq(4).click();
|
||||||
|
cy.get('body').then(($body) => {
|
||||||
|
for (let i = 0; i < 15; i++) {
|
||||||
|
cy.wrap($body).realPress('Tab', { pressDelay: 100 });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cy.focused().parent('.ag-row').should('have.attr', 'row-index', '14');
|
||||||
|
cy.get('.ag-center-cols-container')
|
||||||
|
.find('[role="row"]')
|
||||||
|
.its('length')
|
||||||
|
.then((length) => expect(length).to.be.closeTo(26, 2));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
import { connectVegaWallet } from '../support/vega-wallet';
|
||||||
|
import { aliasQuery } from '@vegaprotocol/cypress';
|
||||||
|
import {
|
||||||
|
generateMarket,
|
||||||
|
generateMarketData,
|
||||||
|
generateMarketsCandles,
|
||||||
|
generateMarketsData,
|
||||||
|
generateSimpleMarkets,
|
||||||
|
} from '../support/mocks/generate-markets';
|
||||||
|
import { generateMarketTags } from '../support/mocks/generate-market-tags';
|
||||||
|
import { generateMarketPositions } from '../support/mocks/generate-market-positions';
|
||||||
|
import { generateEstimateOrder } from '../support/mocks/generate-estimate-order';
|
||||||
|
import { generatePartyBalance } from '../support/mocks/generate-party-balance';
|
||||||
|
import { generatePartyMarketData } from '../support/mocks/generate-party-market-data';
|
||||||
|
import { generateMarketMarkPrice } from '../support/mocks/generate-market-mark-price';
|
||||||
|
import { generateMarketNames } from '../support/mocks/generate-market-names';
|
||||||
|
import { generateMarketDepth } from '../support/mocks/generate-market-depth';
|
||||||
|
import type { Market, MarketsQuery } from '@vegaprotocol/market-list';
|
||||||
|
import { generateChainId } from '../support/mocks/generate-chain-id';
|
||||||
|
import { generateStatistics } from '../support/mocks/generate-statistics';
|
||||||
|
|
||||||
|
describe('market selector', { tags: '@smoke' }, () => {
|
||||||
|
let markets: Market[];
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.mockGQL((req) => {
|
||||||
|
aliasQuery(req, 'ChainId', generateChainId());
|
||||||
|
aliasQuery(req, 'Statistics', generateStatistics());
|
||||||
|
aliasQuery(req, 'Markets', generateSimpleMarkets());
|
||||||
|
aliasQuery(req, 'MarketsCandles', generateMarketsCandles());
|
||||||
|
aliasQuery(req, 'MarketsData', generateMarketsData());
|
||||||
|
aliasQuery(req, 'MarketData', generateMarketData());
|
||||||
|
aliasQuery(req, 'Market', generateMarket());
|
||||||
|
aliasQuery(req, 'MarketTags', generateMarketTags());
|
||||||
|
aliasQuery(req, 'MarketPositions', generateMarketPositions());
|
||||||
|
aliasQuery(req, 'EstimateOrder', generateEstimateOrder());
|
||||||
|
aliasQuery(req, 'PartyBalance', generatePartyBalance());
|
||||||
|
aliasQuery(req, 'PartyMarketData', generatePartyMarketData());
|
||||||
|
aliasQuery(req, 'MarketMarkPrice', generateMarketMarkPrice());
|
||||||
|
aliasQuery(req, 'MarketNames', generateMarketNames());
|
||||||
|
aliasQuery(req, 'MarketDepth', generateMarketDepth());
|
||||||
|
});
|
||||||
|
|
||||||
|
cy.visit('/markets');
|
||||||
|
cy.wait('@Markets').then((response) => {
|
||||||
|
const data: MarketsQuery | undefined = response?.response?.body?.data;
|
||||||
|
if (data?.marketsConnection?.edges.length) {
|
||||||
|
markets = data?.marketsConnection?.edges.map((edge) => edge.node);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be properly rendered', () => {
|
||||||
|
if (markets?.length) {
|
||||||
|
cy.visit(`/trading/${markets[0].id}`);
|
||||||
|
connectVegaWallet();
|
||||||
|
cy.get('input[placeholder="Search"]').should(
|
||||||
|
'have.value',
|
||||||
|
markets[0].tradableInstrument.instrument.name
|
||||||
|
);
|
||||||
|
cy.getByTestId('arrow-button').click();
|
||||||
|
cy.getByTestId('market-pane').should('be.visible');
|
||||||
|
cy.getByTestId('market-pane')
|
||||||
|
.children()
|
||||||
|
.find('[role="button"]')
|
||||||
|
.first()
|
||||||
|
.should('contain.text', markets[0].tradableInstrument.instrument.name);
|
||||||
|
cy.getByTestId('market-pane')
|
||||||
|
.children()
|
||||||
|
.find('[role="button"]')
|
||||||
|
.first()
|
||||||
|
.click();
|
||||||
|
cy.getByTestId('market-pane').should('not.be.visible');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('typing should change list', () => {
|
||||||
|
if (markets?.length) {
|
||||||
|
cy.visit(`/trading/${markets[0].id}`);
|
||||||
|
connectVegaWallet();
|
||||||
|
cy.get('input[placeholder="Search"]').type('{backspace}');
|
||||||
|
cy.getByTestId('market-pane')
|
||||||
|
.children()
|
||||||
|
.find('[role="button"]')
|
||||||
|
.should('have.length.at.least', 1);
|
||||||
|
cy.get('input[placeholder="Search"]').clear();
|
||||||
|
cy.get('input[placeholder="Search"]').type('aa');
|
||||||
|
const filtered = markets.filter(
|
||||||
|
(market) =>
|
||||||
|
market.state === 'STATE_ACTIVE' &&
|
||||||
|
market.tradableInstrument.instrument.name.match(/aa/i)
|
||||||
|
);
|
||||||
|
cy.getByTestId('market-pane')
|
||||||
|
.children()
|
||||||
|
.find('[role="button"]')
|
||||||
|
.should('have.length', filtered.length);
|
||||||
|
cy.getByTestId('market-pane')
|
||||||
|
.children()
|
||||||
|
.find('[role="button"]')
|
||||||
|
.last()
|
||||||
|
.click();
|
||||||
|
cy.location('pathname').should(
|
||||||
|
'eq',
|
||||||
|
`/trading/${filtered[filtered.length - 1].id}`
|
||||||
|
);
|
||||||
|
cy.get('input[placeholder="Search"]').should(
|
||||||
|
'have.value',
|
||||||
|
filtered[filtered.length - 1].tradableInstrument.instrument.name
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// constantly failing on ci
|
||||||
|
it.skip('keyboard navigation should work well', () => {
|
||||||
|
if (markets?.length) {
|
||||||
|
cy.visit(`/trading/${markets[0].id}`);
|
||||||
|
connectVegaWallet();
|
||||||
|
cy.get('input[placeholder="Search"]').type('{backspace}');
|
||||||
|
cy.get('input[placeholder="Search"]').clear();
|
||||||
|
cy.focused().realPress('ArrowDown');
|
||||||
|
cy.focused().should('contain.text', 'AAVEDAI Monthly');
|
||||||
|
cy.focused().realPress('ArrowDown');
|
||||||
|
cy.focused().should('contain.text', 'ETHBTC').realPress('Enter');
|
||||||
|
cy.location('pathname').should('eq', '/trading/ethbtc-quaterly');
|
||||||
|
|
||||||
|
cy.get('input[placeholder="Search"]').type('{backspace}');
|
||||||
|
cy.get('input[placeholder="Search"]').clear();
|
||||||
|
cy.getByTestId('market-pane').should('be.visible');
|
||||||
|
cy.get('body').realPress('ArrowDown');
|
||||||
|
cy.get('body').realPress('Tab');
|
||||||
|
cy.getByTestId('market-pane').should('not.be.visible');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('mobile view', () => {
|
||||||
|
if (markets?.length) {
|
||||||
|
cy.viewport('iphone-xr');
|
||||||
|
cy.visit(`/trading/${markets[0].id}`);
|
||||||
|
connectVegaWallet();
|
||||||
|
cy.get('[role="dialog"]').should('not.exist');
|
||||||
|
cy.getByTestId('arrow-button').click();
|
||||||
|
cy.get('[role="dialog"]').should('be.visible');
|
||||||
|
cy.get('input[placeholder="Search"]').then((search) => {
|
||||||
|
cy.wrap(search).clear();
|
||||||
|
});
|
||||||
|
cy.getByTestId('market-pane')
|
||||||
|
.children()
|
||||||
|
.find('[role="button"]')
|
||||||
|
.should('have.length', 9);
|
||||||
|
cy.get('div[role="dialog"]').should('have.class', 'w-screen');
|
||||||
|
cy.getByTestId('dialog-close').click();
|
||||||
|
cy.get('input[placeholder="Search"]').should(
|
||||||
|
'have.value',
|
||||||
|
markets[0].tradableInstrument.instrument.name
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,331 @@
|
|||||||
|
import { connectVegaWallet } from '../support/vega-wallet';
|
||||||
|
import { aliasQuery } from '@vegaprotocol/cypress';
|
||||||
|
import {
|
||||||
|
generateSimpleMarkets,
|
||||||
|
generateMarketsCandles,
|
||||||
|
generateMarketsData,
|
||||||
|
generateMarket,
|
||||||
|
generateMarketData,
|
||||||
|
} from '../support/mocks/generate-markets';
|
||||||
|
import { generateMarketTags } from '../support/mocks/generate-market-tags';
|
||||||
|
import { generateMarketPositions } from '../support/mocks/generate-market-positions';
|
||||||
|
import { generateEstimateOrder } from '../support/mocks/generate-estimate-order';
|
||||||
|
import { generatePartyBalance } from '../support/mocks/generate-party-balance';
|
||||||
|
import { generatePartyMarketData } from '../support/mocks/generate-party-market-data';
|
||||||
|
import { generateMarketMarkPrice } from '../support/mocks/generate-market-mark-price';
|
||||||
|
import { generateMarketDepth } from '../support/mocks/generate-market-depth';
|
||||||
|
import type { MarketsQuery, Market } from '@vegaprotocol/market-list';
|
||||||
|
import { generateChainId } from '../support/mocks/generate-chain-id';
|
||||||
|
import { generateStatistics } from '../support/mocks/generate-statistics';
|
||||||
|
|
||||||
|
describe('Market trade', { tags: '@smoke' }, () => {
|
||||||
|
let markets: Market[];
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.mockGQL((req) => {
|
||||||
|
aliasQuery(req, 'ChainId', generateChainId());
|
||||||
|
aliasQuery(req, 'Statistics', generateStatistics());
|
||||||
|
aliasQuery(req, 'Markets', generateSimpleMarkets());
|
||||||
|
aliasQuery(req, 'MarketsCandles', generateMarketsCandles());
|
||||||
|
aliasQuery(req, 'MarketsData', generateMarketsData());
|
||||||
|
aliasQuery(req, 'SimpleMarkets', generateSimpleMarkets());
|
||||||
|
aliasQuery(req, 'MarketTags', generateMarketTags());
|
||||||
|
aliasQuery(req, 'MarketPositions', generateMarketPositions());
|
||||||
|
aliasQuery(req, 'EstimateOrder', generateEstimateOrder());
|
||||||
|
aliasQuery(req, 'PartyBalance', generatePartyBalance());
|
||||||
|
aliasQuery(req, 'PartyMarketData', generatePartyMarketData());
|
||||||
|
aliasQuery(req, 'MarketMarkPrice', generateMarketMarkPrice());
|
||||||
|
aliasQuery(req, 'MarketDepth', generateMarketDepth());
|
||||||
|
aliasQuery(req, 'Market', generateMarket());
|
||||||
|
aliasQuery(req, 'MarketData', generateMarketData());
|
||||||
|
});
|
||||||
|
cy.visit('/markets');
|
||||||
|
cy.wait('@Markets').then((response) => {
|
||||||
|
const data: MarketsQuery | undefined = response?.response?.body?.data;
|
||||||
|
if (data?.marketsConnection?.edges.length) {
|
||||||
|
markets = data?.marketsConnection?.edges.map((edge) => edge.node);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not display steps if wallet is disconnected', () => {
|
||||||
|
cy.visit(`/trading/${markets[0].id}`);
|
||||||
|
cy.getByTestId('trading-connect-wallet')
|
||||||
|
.find('h3')
|
||||||
|
.should('have.text', 'Please connect your Vega wallet to make a trade');
|
||||||
|
cy.getByTestId('trading-connect-wallet')
|
||||||
|
.find('button')
|
||||||
|
.should('have.text', 'Connect Vega wallet');
|
||||||
|
cy.getByTestId('trading-connect-wallet')
|
||||||
|
.find('a')
|
||||||
|
.should('have.text', 'https://vega.xyz/wallet');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('side selector should work well', () => {
|
||||||
|
if (markets?.length) {
|
||||||
|
cy.visit(`/trading/${markets[0].id}`);
|
||||||
|
connectVegaWallet();
|
||||||
|
cy.get('#step-1-control [aria-label^="Selected value"]').should(
|
||||||
|
'have.text',
|
||||||
|
'Long'
|
||||||
|
);
|
||||||
|
cy.get('#step-1-control [aria-label^="Selected value"]').click();
|
||||||
|
cy.get('button[aria-label="Open short position"]').click();
|
||||||
|
cy.get('#step-2-control').click();
|
||||||
|
cy.get('#step-1-control [aria-label^="Selected value"]').should(
|
||||||
|
'have.text',
|
||||||
|
'Short'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('side selector mobile view should work well', () => {
|
||||||
|
if (markets?.length) {
|
||||||
|
cy.viewport('iphone-xr');
|
||||||
|
cy.visit(`/trading/${markets[0].id}`);
|
||||||
|
connectVegaWallet();
|
||||||
|
cy.getByTestId('next-button').scrollIntoView().click();
|
||||||
|
|
||||||
|
cy.get('button[aria-label="Open long position"]').should(
|
||||||
|
'have.class',
|
||||||
|
'selected'
|
||||||
|
);
|
||||||
|
cy.get('button[aria-label="Open short position"]').should(
|
||||||
|
'not.have.class',
|
||||||
|
'selected'
|
||||||
|
);
|
||||||
|
|
||||||
|
cy.get('button[aria-label="Open short position"]').click();
|
||||||
|
cy.get('button[aria-label="Open long position"]').should(
|
||||||
|
'not.have.class',
|
||||||
|
'selected'
|
||||||
|
);
|
||||||
|
cy.get('button[aria-label="Open short position"]').should(
|
||||||
|
'have.class',
|
||||||
|
'selected'
|
||||||
|
);
|
||||||
|
cy.getByTestId('next-button').scrollIntoView().click();
|
||||||
|
cy.get('#step-1-control').should(
|
||||||
|
'contain.html',
|
||||||
|
'aria-label="Selected value Short"'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('size slider should work well', () => {
|
||||||
|
if (markets?.length) {
|
||||||
|
cy.visit(`/trading/${markets[1].id}`);
|
||||||
|
connectVegaWallet();
|
||||||
|
cy.get('#step-1-control [aria-label^="Selected value"]').click();
|
||||||
|
cy.get('button[aria-label="Open short position"]').click();
|
||||||
|
cy.get('#step-2-control').click();
|
||||||
|
cy.get('#step-2-panel')
|
||||||
|
.find('dd')
|
||||||
|
.eq(0)
|
||||||
|
.find('button')
|
||||||
|
.should('have.text', '1');
|
||||||
|
cy.get('#step-2-panel').find('[role="slider"]').type('{rightarrow}');
|
||||||
|
|
||||||
|
cy.get('#step-2-panel')
|
||||||
|
.find('dd')
|
||||||
|
.eq(0)
|
||||||
|
.find('button')
|
||||||
|
.should('have.text', '2');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('percentage selection should work well', () => {
|
||||||
|
if (markets?.length) {
|
||||||
|
cy.visit(`/trading/${markets[1].id}`);
|
||||||
|
connectVegaWallet();
|
||||||
|
cy.get('#step-1-control [aria-label^="Selected value"]').click();
|
||||||
|
cy.get('button[aria-label="Open short position"]').click();
|
||||||
|
cy.get('#step-2-control').click();
|
||||||
|
cy.get('#step-2-panel')
|
||||||
|
.find('dd')
|
||||||
|
.eq(0)
|
||||||
|
.find('button')
|
||||||
|
.should('have.text', '1');
|
||||||
|
|
||||||
|
cy.getByTestId('max-label').should('have.text', '21');
|
||||||
|
|
||||||
|
cy.getByTestId('percentage-selector')
|
||||||
|
.find('button')
|
||||||
|
.contains('Max')
|
||||||
|
.click();
|
||||||
|
cy.get('#step-2-panel')
|
||||||
|
.find('dd')
|
||||||
|
.eq(0)
|
||||||
|
.find('button')
|
||||||
|
.should('have.text', '21');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('size input should work well', () => {
|
||||||
|
if (markets?.length) {
|
||||||
|
cy.visit(`/trading/${markets[1].id}`);
|
||||||
|
connectVegaWallet();
|
||||||
|
cy.get('#step-1-control [aria-label^="Selected value"]').click();
|
||||||
|
cy.get('button[aria-label="Open short position"]').click();
|
||||||
|
cy.get('#step-2-control').click();
|
||||||
|
cy.get('#step-2-panel')
|
||||||
|
.find('dd')
|
||||||
|
.eq(0)
|
||||||
|
.find('button')
|
||||||
|
.should('have.text', '1');
|
||||||
|
cy.get('#step-2-panel').find('dd').eq(0).find('button').click();
|
||||||
|
cy.get('#step-2-panel')
|
||||||
|
.find('dd')
|
||||||
|
.eq(0)
|
||||||
|
.find('input')
|
||||||
|
.type('{backspace}2');
|
||||||
|
cy.get('#step-2-panel').find('dd').eq(0).find('button').click();
|
||||||
|
cy.get('#step-2-panel')
|
||||||
|
.find('dd')
|
||||||
|
.eq(0)
|
||||||
|
.find('button')
|
||||||
|
.should('have.text', '2');
|
||||||
|
cy.get('button').contains('Max').click();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('slippage value should be displayed', () => {
|
||||||
|
if (markets?.length) {
|
||||||
|
cy.visit(`/trading/${markets[1].id}`);
|
||||||
|
connectVegaWallet();
|
||||||
|
cy.get('#step-1-control [aria-label^="Selected value"]').click();
|
||||||
|
cy.get('button[aria-label="Open short position"]').click();
|
||||||
|
cy.get('#step-2-control').click();
|
||||||
|
cy.get('button').contains('Max').click();
|
||||||
|
cy.get('#step-2-panel')
|
||||||
|
.find('dl')
|
||||||
|
.eq(2)
|
||||||
|
.find('dd')
|
||||||
|
.should('have.text', '0.02%');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('allow slippage value to be adjusted', () => {
|
||||||
|
if (markets?.length) {
|
||||||
|
cy.visit(`/trading/${markets[1].id}`);
|
||||||
|
connectVegaWallet();
|
||||||
|
cy.get('#step-1-control [aria-label^="Selected value"]').click();
|
||||||
|
cy.get('button[aria-label="Open short position"]').click();
|
||||||
|
cy.get('#step-2-control').click();
|
||||||
|
cy.get('button').contains('Max').click();
|
||||||
|
cy.get('#step-2-panel')
|
||||||
|
.find('dl')
|
||||||
|
.eq(2)
|
||||||
|
.find('dd')
|
||||||
|
.should('have.text', '0.02%');
|
||||||
|
cy.get('#step-2-panel').find('dl').eq(2).find('button').click();
|
||||||
|
cy.get('#input-order-slippage')
|
||||||
|
.focus()
|
||||||
|
.type('{backspace}{backspace}{backspace}1');
|
||||||
|
|
||||||
|
cy.getByTestId('slippage-dialog').find('button').click();
|
||||||
|
|
||||||
|
cy.get('#step-2-panel')
|
||||||
|
.find('dl')
|
||||||
|
.eq(2)
|
||||||
|
.find('dd')
|
||||||
|
.should('have.text', '1%');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('notional position size should be present', () => {
|
||||||
|
if (markets?.length) {
|
||||||
|
cy.visit(`/trading/${markets[1].id}`);
|
||||||
|
connectVegaWallet();
|
||||||
|
cy.get('#step-1-control [aria-label^="Selected value"]').click();
|
||||||
|
cy.get('button[aria-label="Open short position"]').click();
|
||||||
|
cy.get('#step-2-control').click();
|
||||||
|
cy.get('#step-2-panel')
|
||||||
|
.find('dd')
|
||||||
|
.eq(0)
|
||||||
|
.find('button')
|
||||||
|
.should('have.text', '1');
|
||||||
|
cy.get('#step-2-panel').find('dd').eq(0).find('button').click();
|
||||||
|
cy.get('#step-2-panel')
|
||||||
|
.find('dd')
|
||||||
|
.eq(0)
|
||||||
|
.find('input')
|
||||||
|
.type('{backspace}2');
|
||||||
|
cy.get('#step-2-panel').find('dd').eq(0).find('button').click();
|
||||||
|
cy.get('#step-2-panel')
|
||||||
|
.find('dt')
|
||||||
|
.eq(2)
|
||||||
|
.should('have.text', 'Est. Position Size (tDAI)');
|
||||||
|
cy.get('#step-2-panel').find('dd').eq(2).should('have.text', '197.86012');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('total fees should be displayed', () => {
|
||||||
|
if (markets?.length) {
|
||||||
|
cy.visit(`/trading/${markets[1].id}`);
|
||||||
|
connectVegaWallet();
|
||||||
|
cy.get('#step-1-control [aria-label^="Selected value"]').click();
|
||||||
|
cy.get('button[aria-label="Open short position"]').click();
|
||||||
|
cy.get('#step-2-control').click();
|
||||||
|
cy.get('#step-2-panel')
|
||||||
|
.find('dt')
|
||||||
|
.eq(3)
|
||||||
|
.should('have.text', 'Est. Fees (tDAI)');
|
||||||
|
cy.get('#step-2-panel')
|
||||||
|
.find('dd')
|
||||||
|
.eq(3)
|
||||||
|
.should('have.text', '3.00 (3.03%)');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('order review should display proper calculations', () => {
|
||||||
|
if (markets?.length) {
|
||||||
|
cy.visit(`/trading/${markets[0].id}`);
|
||||||
|
connectVegaWallet();
|
||||||
|
cy.get('#step-3-control').click();
|
||||||
|
|
||||||
|
cy.getByTestId('review-trade')
|
||||||
|
.get('#contracts_tooltip_trigger')
|
||||||
|
.trigger('click')
|
||||||
|
.realTouch();
|
||||||
|
|
||||||
|
cy.get('[data-radix-popper-content-wrapper]').contains(
|
||||||
|
'The number of contracts determines'
|
||||||
|
);
|
||||||
|
cy.get('#step-3-panel').find('dd').eq(1).should('have.text', '1');
|
||||||
|
|
||||||
|
cy.get('#step-3-panel').find('dd').eq(2).should('have.text', '98.93006');
|
||||||
|
|
||||||
|
cy.get('#step-3-panel')
|
||||||
|
.find('dd')
|
||||||
|
.eq(3)
|
||||||
|
.should('have.text', '3.00 (3.03%)');
|
||||||
|
|
||||||
|
cy.get('#step-3-panel').find('dd').eq(4).should('have.text', ' - ');
|
||||||
|
|
||||||
|
cy.getByTestId('place-order').should('be.enabled').click();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('info tooltip on mobile view should work well', () => {
|
||||||
|
if (markets?.length) {
|
||||||
|
cy.viewport('iphone-xr');
|
||||||
|
cy.visit(`/trading/${markets[0].id}`);
|
||||||
|
connectVegaWallet();
|
||||||
|
cy.get('#step-3-control').click();
|
||||||
|
|
||||||
|
// Start from the bottom tooltip to ensure the tooltip above
|
||||||
|
// can be interacted with
|
||||||
|
cy.getByTestId('review-trade').get('div.cursor-help').eq(1).realTouch();
|
||||||
|
cy.get('[data-radix-popper-content-wrapper]').contains(
|
||||||
|
'The notional size represents the position size'
|
||||||
|
);
|
||||||
|
|
||||||
|
cy.getByTestId('review-trade')
|
||||||
|
.get('#contracts_tooltip_trigger')
|
||||||
|
.realTouch();
|
||||||
|
cy.get('[data-radix-popper-content-wrapper]').contains(
|
||||||
|
'The number of contracts determines'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,198 @@
|
|||||||
|
import { connectVegaWallet } from '../support/vega-wallet';
|
||||||
|
import { aliasQuery } from '@vegaprotocol/cypress';
|
||||||
|
import {
|
||||||
|
generatePositions,
|
||||||
|
emptyPositions,
|
||||||
|
generateMargins,
|
||||||
|
} from '../support/mocks/generate-positions';
|
||||||
|
import { generateAccounts } from '../support/mocks/generate-accounts';
|
||||||
|
import { generateAssets } from '../support/mocks/generate-assets';
|
||||||
|
import { generateOrders } from '../support/mocks/generate-orders';
|
||||||
|
import { generateFills } from '../support/mocks/generate-fills';
|
||||||
|
import {
|
||||||
|
generateFillsMarkets,
|
||||||
|
generateMarketsData,
|
||||||
|
generatePositionsMarkets,
|
||||||
|
} from '../support/mocks/generate-markets';
|
||||||
|
import { generateChainId } from '../support/mocks/generate-chain-id';
|
||||||
|
import { generateStatistics } from '../support/mocks/generate-statistics';
|
||||||
|
|
||||||
|
describe('Portfolio page - wallet', { tags: '@smoke' }, () => {
|
||||||
|
it('button for wallet connect should work', () => {
|
||||||
|
cy.visit('/');
|
||||||
|
cy.get('[href="/portfolio"]').eq(0).click();
|
||||||
|
cy.getByTestId('trading-connect-wallet').should('be.visible');
|
||||||
|
connectVegaWallet();
|
||||||
|
cy.getByTestId('trading-connect-wallet').should('not.exist');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Portfolio page tabs', { tags: '@smoke' }, () => {
|
||||||
|
before(() => {
|
||||||
|
cy.mockGQL((req) => {
|
||||||
|
aliasQuery(req, 'ChainId', generateChainId());
|
||||||
|
aliasQuery(req, 'Statistics', generateStatistics());
|
||||||
|
aliasQuery(req, 'Positions', generatePositions());
|
||||||
|
aliasQuery(req, 'Margins', generateMargins());
|
||||||
|
aliasQuery(req, 'Markets', generatePositionsMarkets());
|
||||||
|
aliasQuery(req, 'MarketsData', generateMarketsData());
|
||||||
|
aliasQuery(req, 'Accounts', generateAccounts());
|
||||||
|
aliasQuery(req, 'Assets', generateAssets());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('certain tabs should exist', () => {
|
||||||
|
cy.visit('/portfolio');
|
||||||
|
connectVegaWallet();
|
||||||
|
|
||||||
|
cy.getByTestId('assets').click();
|
||||||
|
cy.location('pathname').should('eq', '/portfolio/assets');
|
||||||
|
|
||||||
|
cy.getByTestId('positions').click();
|
||||||
|
cy.location('pathname').should('eq', '/portfolio/positions');
|
||||||
|
|
||||||
|
cy.getByTestId('orders').click();
|
||||||
|
cy.location('pathname').should('eq', '/portfolio/orders');
|
||||||
|
|
||||||
|
cy.getByTestId('fills').click();
|
||||||
|
cy.location('pathname').should('eq', '/portfolio/fills');
|
||||||
|
|
||||||
|
cy.getByTestId('deposits').click();
|
||||||
|
cy.location('pathname').should('eq', '/portfolio/deposits');
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Assets view', () => {
|
||||||
|
before(() => {
|
||||||
|
cy.mockGQL((req) => {
|
||||||
|
aliasQuery(req, 'ChainId', generateChainId());
|
||||||
|
aliasQuery(req, 'Statistics', generateStatistics());
|
||||||
|
aliasQuery(req, 'Positions', generatePositions());
|
||||||
|
aliasQuery(req, 'Margins', generateMargins());
|
||||||
|
aliasQuery(req, 'Markets', generatePositionsMarkets());
|
||||||
|
aliasQuery(req, 'MarketsData', generateMarketsData());
|
||||||
|
aliasQuery(req, 'Accounts', generateAccounts());
|
||||||
|
aliasQuery(req, 'Assets', generateAssets());
|
||||||
|
});
|
||||||
|
cy.visit('/portfolio/assets');
|
||||||
|
connectVegaWallet();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('data should be properly rendered', () => {
|
||||||
|
cy.get('.ag-center-cols-container .ag-row').should('have.length', 3);
|
||||||
|
cy.get(
|
||||||
|
'.ag-center-cols-container [row-id="ACCOUNT_TYPE_GENERAL-asset-id-null"]'
|
||||||
|
)
|
||||||
|
.find('button')
|
||||||
|
.click();
|
||||||
|
cy.getByTestId('dialog-title').should(
|
||||||
|
'have.text',
|
||||||
|
'Asset details - tEURO'
|
||||||
|
);
|
||||||
|
cy.getByTestId('dialog-close').click();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Positions view', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.mockGQL((req) => {
|
||||||
|
aliasQuery(req, 'ChainId', generateChainId());
|
||||||
|
aliasQuery(req, 'Statistics', generateStatistics());
|
||||||
|
aliasQuery(req, 'Positions', generatePositions());
|
||||||
|
aliasQuery(req, 'Accounts', generateAccounts());
|
||||||
|
aliasQuery(req, 'Margins', generateMargins());
|
||||||
|
aliasQuery(req, 'Markets', generatePositionsMarkets());
|
||||||
|
aliasQuery(req, 'MarketsData', generateMarketsData());
|
||||||
|
aliasQuery(req, 'Assets', generateAssets());
|
||||||
|
});
|
||||||
|
cy.visit('/portfolio/positions');
|
||||||
|
connectVegaWallet();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('data should be properly rendered', () => {
|
||||||
|
cy.get('.ag-center-cols-container .ag-row').should('have.length', 2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Orders view', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.mockGQL((req) => {
|
||||||
|
aliasQuery(req, 'ChainId', generateChainId());
|
||||||
|
aliasQuery(req, 'Statistics', generateStatistics());
|
||||||
|
aliasQuery(req, 'Orders', generateOrders());
|
||||||
|
aliasQuery(req, 'Markets', generateFillsMarkets());
|
||||||
|
});
|
||||||
|
cy.visit('/portfolio/orders');
|
||||||
|
connectVegaWallet();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('data should be properly rendered', () => {
|
||||||
|
cy.get('.ag-center-cols-container .ag-row').should('have.length', 5);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Fills view', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.mockGQL((req) => {
|
||||||
|
aliasQuery(req, 'ChainId', generateChainId());
|
||||||
|
aliasQuery(req, 'Statistics', generateStatistics());
|
||||||
|
aliasQuery(req, 'Fills', generateFills());
|
||||||
|
aliasQuery(req, 'Markets', generateFillsMarkets());
|
||||||
|
});
|
||||||
|
cy.visit('/portfolio/fills');
|
||||||
|
connectVegaWallet();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('data should be properly rendered', () => {
|
||||||
|
cy.get('.ag-center-cols-container .ag-row').should('have.length', 4);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Empty views', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.mockGQL((req) => {
|
||||||
|
aliasQuery(req, 'ChainId', generateChainId());
|
||||||
|
aliasQuery(req, 'Statistics', generateStatistics());
|
||||||
|
aliasQuery(req, 'Positions', emptyPositions());
|
||||||
|
aliasQuery(req, 'Accounts', { party: null });
|
||||||
|
aliasQuery(req, 'Orders', { party: null });
|
||||||
|
aliasQuery(req, 'Fills', { party: null });
|
||||||
|
aliasQuery(req, 'Markets', {
|
||||||
|
marketsConnection: { edges: [], __typename: 'MarketConnection' },
|
||||||
|
});
|
||||||
|
aliasQuery(req, 'Assets', {
|
||||||
|
assetsConnection: { edges: null, __typename: 'AssetsConnection' },
|
||||||
|
});
|
||||||
|
aliasQuery(req, 'Margins', generateMargins());
|
||||||
|
aliasQuery(req, 'MarketsData', generateMarketsData());
|
||||||
|
});
|
||||||
|
cy.visit('/portfolio');
|
||||||
|
connectVegaWallet();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('"No data to display" should be always displayed', () => {
|
||||||
|
cy.getByTestId('assets').click();
|
||||||
|
cy.get('div.flex.items-center.justify-center').should(
|
||||||
|
'contain.text',
|
||||||
|
'No data to display'
|
||||||
|
);
|
||||||
|
|
||||||
|
cy.getByTestId('positions').click();
|
||||||
|
cy.get('div.flex.items-center.justify-center').should(
|
||||||
|
'contain.text',
|
||||||
|
'No data to display'
|
||||||
|
);
|
||||||
|
|
||||||
|
cy.getByTestId('orders').click();
|
||||||
|
cy.get('div.flex.items-center.justify-center').should(
|
||||||
|
'contain.text',
|
||||||
|
'No data to display'
|
||||||
|
);
|
||||||
|
|
||||||
|
cy.getByTestId('fills').click();
|
||||||
|
cy.get('div.flex.items-center.justify-center').should(
|
||||||
|
'contain.text',
|
||||||
|
'No data to display'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// ***********************************************
|
||||||
|
// This example commands.js shows you how to
|
||||||
|
// create various custom commands and overwrite
|
||||||
|
// existing commands.
|
||||||
|
//
|
||||||
|
// For more comprehensive examples of custom
|
||||||
|
// commands please read more here:
|
||||||
|
// https://on.cypress.io/custom-commands
|
||||||
|
// ***********************************************
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
// ***********************************************************
|
||||||
|
// This example support/index.js is processed and
|
||||||
|
// loaded automatically before your test files.
|
||||||
|
//
|
||||||
|
// This is a great place to put global configuration and
|
||||||
|
// behavior that modifies Cypress.
|
||||||
|
//
|
||||||
|
// You can change the location of this file or turn off
|
||||||
|
// automatically serving support files with the
|
||||||
|
// 'supportFile' configuration option.
|
||||||
|
//
|
||||||
|
// You can read more here:
|
||||||
|
// https://on.cypress.io/configuration
|
||||||
|
// ***********************************************************
|
||||||
|
|
||||||
|
import '@vegaprotocol/cypress';
|
||||||
|
import 'cypress-real-events/support';
|
||||||
|
// Import commands.js using ES2015 syntax:
|
||||||
|
import './commands';
|
||||||
|
import registerCypressGrep from 'cypress-grep';
|
||||||
|
import { aliasQuery } from '@vegaprotocol/cypress';
|
||||||
|
registerCypressGrep();
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
// Mock chainId fetch which happens on every page for wallet connection
|
||||||
|
cy.mockGQL((req) => {
|
||||||
|
aliasQuery(req, 'ChainId', {
|
||||||
|
statistics: {
|
||||||
|
__typename: 'Statistics',
|
||||||
|
chainId:
|
||||||
|
Cypress.env('VEGA_ENV').toLowerCase() ||
|
||||||
|
'vega-fairground-202210041151',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
import type { Market } from '@vegaprotocol/market-list';
|
||||||
|
import { Schema } from '@vegaprotocol/types';
|
||||||
|
import type { SingleMarketFieldsFragment } from '@vegaprotocol/market-list';
|
||||||
|
|
||||||
|
export const protoCandles = [
|
||||||
|
{ open: '9556163', close: '9587028', __typename: 'Candle' },
|
||||||
|
{
|
||||||
|
open: '9587028',
|
||||||
|
close: '9769899',
|
||||||
|
__typename: 'Candle',
|
||||||
|
},
|
||||||
|
{ open: '9769899', close: '9586292', __typename: 'Candle' },
|
||||||
|
{
|
||||||
|
open: '9586292',
|
||||||
|
close: '9261774',
|
||||||
|
__typename: 'Candle',
|
||||||
|
},
|
||||||
|
{ open: '9261773', close: '9236369', __typename: 'Candle' },
|
||||||
|
{
|
||||||
|
open: '9236369',
|
||||||
|
close: '9226070',
|
||||||
|
__typename: 'Candle',
|
||||||
|
},
|
||||||
|
{ open: '9226077', close: '9233252', __typename: 'Candle' },
|
||||||
|
{
|
||||||
|
open: '9249854',
|
||||||
|
close: '9333038',
|
||||||
|
__typename: 'Candle',
|
||||||
|
},
|
||||||
|
{ open: '9333038', close: '9410371', __typename: 'Candle' },
|
||||||
|
{
|
||||||
|
open: '9410371',
|
||||||
|
close: '9626249',
|
||||||
|
__typename: 'Candle',
|
||||||
|
},
|
||||||
|
{ open: '9626247', close: '9493253', __typename: 'Candle' },
|
||||||
|
{
|
||||||
|
open: '9493253',
|
||||||
|
close: '9309054',
|
||||||
|
__typename: 'Candle',
|
||||||
|
},
|
||||||
|
{ open: '9309054', close: '9378428', __typename: 'Candle' },
|
||||||
|
{
|
||||||
|
open: '9378428',
|
||||||
|
close: '9352996',
|
||||||
|
__typename: 'Candle',
|
||||||
|
},
|
||||||
|
{ open: '9352996', close: '9451142', __typename: 'Candle' },
|
||||||
|
{
|
||||||
|
open: '9451142',
|
||||||
|
close: '9691070',
|
||||||
|
__typename: 'Candle',
|
||||||
|
},
|
||||||
|
{ open: '9691071', close: '9622031', __typename: 'Candle' },
|
||||||
|
{
|
||||||
|
open: '9622034',
|
||||||
|
close: '9519285',
|
||||||
|
__typename: 'Candle',
|
||||||
|
},
|
||||||
|
{ open: '9528904', close: '9671275', __typename: 'Candle' },
|
||||||
|
{
|
||||||
|
open: '9671275',
|
||||||
|
close: '9988454',
|
||||||
|
__typename: 'Candle',
|
||||||
|
},
|
||||||
|
{ open: '9982457', close: '10085537', __typename: 'Candle' },
|
||||||
|
{
|
||||||
|
open: '10085537',
|
||||||
|
close: '9967390',
|
||||||
|
__typename: 'Candle',
|
||||||
|
},
|
||||||
|
{ open: '9967390', close: '9974844', __typename: 'Candle' },
|
||||||
|
{
|
||||||
|
open: '9974844',
|
||||||
|
close: '9940706',
|
||||||
|
__typename: 'Candle',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const protoMarket: Market = {
|
||||||
|
id: 'ca7768f6de84bf86a21bbb6b0109d9659c81917b0e0339b2c262566c9b581a15',
|
||||||
|
tradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
|
||||||
|
state: Schema.MarketState.STATE_ACTIVE,
|
||||||
|
decimalPlaces: 5,
|
||||||
|
positionDecimalPlaces: 0,
|
||||||
|
marketTimestamps: {
|
||||||
|
__typename: 'MarketTimestamps',
|
||||||
|
close: '',
|
||||||
|
open: '',
|
||||||
|
},
|
||||||
|
fees: {
|
||||||
|
__typename: 'Fees',
|
||||||
|
factors: {
|
||||||
|
__typename: 'FeeFactors',
|
||||||
|
makerFee: '',
|
||||||
|
infrastructureFee: '',
|
||||||
|
liquidityFee: '',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
tradableInstrument: {
|
||||||
|
instrument: {
|
||||||
|
id: '',
|
||||||
|
code: 'AAVEDAI.MF21',
|
||||||
|
name: 'AAVEDAI Monthly (30 Jun 2022)',
|
||||||
|
metadata: {
|
||||||
|
tags: [
|
||||||
|
'formerly:2839D9B2329C9E70',
|
||||||
|
'base:AAVE',
|
||||||
|
'quote:DAI',
|
||||||
|
'class:fx/crypto',
|
||||||
|
'monthly',
|
||||||
|
'sector:defi',
|
||||||
|
],
|
||||||
|
__typename: 'InstrumentMetadata',
|
||||||
|
},
|
||||||
|
product: {
|
||||||
|
__typename: 'Future',
|
||||||
|
quoteName: 'DAI',
|
||||||
|
settlementAsset: {
|
||||||
|
__typename: 'Asset',
|
||||||
|
id: 'asset-id',
|
||||||
|
symbol: 'tDAI',
|
||||||
|
decimals: 5,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
__typename: 'Instrument',
|
||||||
|
},
|
||||||
|
__typename: 'TradableInstrument',
|
||||||
|
},
|
||||||
|
__typename: 'Market',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const singleMarket: SingleMarketFieldsFragment = {
|
||||||
|
...protoMarket,
|
||||||
|
tradableInstrument: {
|
||||||
|
...protoMarket.tradableInstrument,
|
||||||
|
instrument: {
|
||||||
|
...protoMarket.tradableInstrument.instrument,
|
||||||
|
product: {
|
||||||
|
...protoMarket.tradableInstrument.instrument.product,
|
||||||
|
settlementAsset: {
|
||||||
|
...protoMarket.tradableInstrument.instrument.product.settlementAsset,
|
||||||
|
id: 'dai-id',
|
||||||
|
name: 'DAI Name',
|
||||||
|
},
|
||||||
|
dataSourceSpecForTradingTermination: {
|
||||||
|
id: 'oid',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
depth: {
|
||||||
|
__typename: 'MarketDepth',
|
||||||
|
lastTrade: { price: '9893006', __typename: 'Trade' },
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
import merge from 'lodash/merge';
|
||||||
|
import type { AccountsQuery } from '@vegaprotocol/accounts';
|
||||||
|
import { Schema as Types } from '@vegaprotocol/types';
|
||||||
|
import type { PartialDeep } from 'type-fest';
|
||||||
|
|
||||||
|
export const generateAccounts = (
|
||||||
|
override?: PartialDeep<AccountsQuery>
|
||||||
|
): AccountsQuery => {
|
||||||
|
const defaultAccounts: AccountsQuery = {
|
||||||
|
party: {
|
||||||
|
__typename: 'Party',
|
||||||
|
id: Cypress.env('VEGA_PUBLIC_KEY'),
|
||||||
|
accountsConnection: {
|
||||||
|
__typename: 'AccountsConnection',
|
||||||
|
edges: [
|
||||||
|
{
|
||||||
|
__typename: 'AccountEdge',
|
||||||
|
node: {
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
type: Types.AccountType.ACCOUNT_TYPE_GENERAL,
|
||||||
|
balance: '100000000',
|
||||||
|
market: null,
|
||||||
|
asset: {
|
||||||
|
__typename: 'Asset',
|
||||||
|
id: 'asset-id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
__typename: 'AccountEdge',
|
||||||
|
node: {
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
type: Types.AccountType.ACCOUNT_TYPE_GENERAL,
|
||||||
|
balance: '100000000',
|
||||||
|
market: {
|
||||||
|
id: '0604e8c918655474525e1a95367902266ade70d318c2c908f0cca6e3d11dcb13',
|
||||||
|
__typename: 'Market',
|
||||||
|
},
|
||||||
|
asset: {
|
||||||
|
__typename: 'Asset',
|
||||||
|
id: 'asset-id-2',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
__typename: 'AccountEdge',
|
||||||
|
node: {
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
type: Types.AccountType.ACCOUNT_TYPE_MARGIN,
|
||||||
|
balance: '1000',
|
||||||
|
market: {
|
||||||
|
__typename: 'Market',
|
||||||
|
id: '5a4b0b9e9c0629f0315ec56fcb7bd444b0c6e4da5ec7677719d502626658a376',
|
||||||
|
},
|
||||||
|
asset: {
|
||||||
|
__typename: 'Asset',
|
||||||
|
id: 'asset-id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
__typename: 'AccountEdge',
|
||||||
|
node: {
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
type: Types.AccountType.ACCOUNT_TYPE_MARGIN,
|
||||||
|
balance: '1000',
|
||||||
|
market: {
|
||||||
|
__typename: 'Market',
|
||||||
|
id: 'c9f5acd348796011c075077e4d58d9b7f1689b7c1c8e030a5e886b83aa96923d',
|
||||||
|
},
|
||||||
|
asset: {
|
||||||
|
__typename: 'Asset',
|
||||||
|
id: 'asset-id-2',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
__typename: 'AccountEdge',
|
||||||
|
node: {
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
type: Types.AccountType.ACCOUNT_TYPE_GENERAL,
|
||||||
|
balance: '100000000',
|
||||||
|
market: null,
|
||||||
|
asset: {
|
||||||
|
__typename: 'Asset',
|
||||||
|
id: 'asset-0',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return merge(defaultAccounts, override);
|
||||||
|
};
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
import merge from 'lodash/merge';
|
||||||
|
import type { AssetsQuery } from '@vegaprotocol/assets';
|
||||||
|
import { Schema as Types } from '@vegaprotocol/types';
|
||||||
|
import type { PartialDeep } from 'type-fest';
|
||||||
|
|
||||||
|
export const generateAssets = (override?: PartialDeep<AssetsQuery>) => {
|
||||||
|
const defaultAssets: AssetsQuery = {
|
||||||
|
assetsConnection: {
|
||||||
|
edges: [
|
||||||
|
{
|
||||||
|
node: {
|
||||||
|
id: 'asset-id',
|
||||||
|
symbol: 'tEURO',
|
||||||
|
decimals: 5,
|
||||||
|
name: 'Euro',
|
||||||
|
source: {
|
||||||
|
__typename: 'ERC20',
|
||||||
|
contractAddress: '0x0158031158Bb4dF2AD02eAA31e8963E84EA978a4',
|
||||||
|
lifetimeLimit: '1',
|
||||||
|
withdrawThreshold: '2',
|
||||||
|
},
|
||||||
|
quantum: '',
|
||||||
|
status: Types.AssetStatus.STATUS_ENABLED,
|
||||||
|
infrastructureFeeAccount: {
|
||||||
|
balance: '1',
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
},
|
||||||
|
globalRewardPoolAccount: {
|
||||||
|
balance: '2',
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
},
|
||||||
|
takerFeeRewardAccount: {
|
||||||
|
balance: '3',
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
},
|
||||||
|
makerFeeRewardAccount: {
|
||||||
|
balance: '4',
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
},
|
||||||
|
lpFeeRewardAccount: {
|
||||||
|
balance: '5',
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
},
|
||||||
|
marketProposerRewardAccount: {
|
||||||
|
balance: '6',
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
},
|
||||||
|
__typename: 'Asset',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
node: {
|
||||||
|
id: 'asset-id-2',
|
||||||
|
symbol: 'tDAI',
|
||||||
|
decimals: 5,
|
||||||
|
name: 'DAI',
|
||||||
|
source: {
|
||||||
|
__typename: 'ERC20',
|
||||||
|
contractAddress: '0x0158031158Bb4dF2AD02eAA31e8963E84EA978a4',
|
||||||
|
lifetimeLimit: '1',
|
||||||
|
withdrawThreshold: '2',
|
||||||
|
},
|
||||||
|
quantum: '',
|
||||||
|
status: Types.AssetStatus.STATUS_ENABLED,
|
||||||
|
infrastructureFeeAccount: {
|
||||||
|
balance: '1',
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
},
|
||||||
|
globalRewardPoolAccount: {
|
||||||
|
balance: '2',
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
},
|
||||||
|
takerFeeRewardAccount: {
|
||||||
|
balance: '3',
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
},
|
||||||
|
makerFeeRewardAccount: {
|
||||||
|
balance: '4',
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
},
|
||||||
|
lpFeeRewardAccount: {
|
||||||
|
balance: '5',
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
},
|
||||||
|
marketProposerRewardAccount: {
|
||||||
|
balance: '6',
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
},
|
||||||
|
__typename: 'Asset',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
node: {
|
||||||
|
id: 'asset-0',
|
||||||
|
symbol: 'AST0',
|
||||||
|
decimals: 5,
|
||||||
|
name: 'Asto',
|
||||||
|
source: {
|
||||||
|
__typename: 'BuiltinAsset',
|
||||||
|
maxFaucetAmountMint: '3',
|
||||||
|
},
|
||||||
|
quantum: '',
|
||||||
|
status: Types.AssetStatus.STATUS_ENABLED,
|
||||||
|
infrastructureFeeAccount: {
|
||||||
|
balance: '0',
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
},
|
||||||
|
globalRewardPoolAccount: null,
|
||||||
|
takerFeeRewardAccount: null,
|
||||||
|
makerFeeRewardAccount: null,
|
||||||
|
lpFeeRewardAccount: null,
|
||||||
|
marketProposerRewardAccount: null,
|
||||||
|
__typename: 'Asset',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return merge(defaultAssets, override);
|
||||||
|
};
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import type { ChainIdQuery } from '@vegaprotocol/react-helpers';
|
||||||
|
import merge from 'lodash/merge';
|
||||||
|
import type { PartialDeep } from 'type-fest';
|
||||||
|
|
||||||
|
export const generateChainId = (
|
||||||
|
override?: PartialDeep<ChainIdQuery>
|
||||||
|
): ChainIdQuery => {
|
||||||
|
const defaultResult = {
|
||||||
|
statistics: {
|
||||||
|
__typename: 'Statistics',
|
||||||
|
chainId: Cypress.env('VEGA_ENV').toLowerCase() || 'test-chain-id',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return merge(defaultResult, override);
|
||||||
|
};
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
export const generateEstimateOrder = () => {
|
||||||
|
return {
|
||||||
|
estimateOrder: {
|
||||||
|
fee: {
|
||||||
|
__typename: 'TradeFee',
|
||||||
|
makerFee: '100000',
|
||||||
|
liquidityFee: '100000',
|
||||||
|
infrastructureFee: '100000',
|
||||||
|
},
|
||||||
|
marginLevels: {
|
||||||
|
initialLevel: '2844054.80937741220203',
|
||||||
|
__typename: 'MarginLevels',
|
||||||
|
},
|
||||||
|
__typename: 'OrderEstimate',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
import type { FillsQuery, FillFieldsFragment } from '@vegaprotocol/fills';
|
||||||
|
import { Schema } from '@vegaprotocol/types';
|
||||||
|
import merge from 'lodash/merge';
|
||||||
|
import type { PartialDeep } from 'type-fest';
|
||||||
|
|
||||||
|
export const generateFills = (
|
||||||
|
override?: PartialDeep<FillsQuery>
|
||||||
|
): FillsQuery => {
|
||||||
|
const fills: FillFieldsFragment[] = [
|
||||||
|
generateFill({
|
||||||
|
buyer: {
|
||||||
|
id: Cypress.env('VEGA_PUBLIC_KEY'),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
generateFill({
|
||||||
|
id: '1',
|
||||||
|
seller: {
|
||||||
|
id: Cypress.env('VEGA_PUBLIC_KEY'),
|
||||||
|
},
|
||||||
|
aggressor: Schema.Side.SIDE_SELL,
|
||||||
|
buyerFee: {
|
||||||
|
infrastructureFee: '5000',
|
||||||
|
},
|
||||||
|
market: {
|
||||||
|
id: 'market-1',
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
generateFill({
|
||||||
|
id: '2',
|
||||||
|
seller: {
|
||||||
|
id: Cypress.env('VEGA_PUBLIC_KEY'),
|
||||||
|
},
|
||||||
|
aggressor: Schema.Side.SIDE_BUY,
|
||||||
|
}),
|
||||||
|
generateFill({
|
||||||
|
id: '3',
|
||||||
|
aggressor: Schema.Side.SIDE_SELL,
|
||||||
|
market: {
|
||||||
|
id: 'market-2',
|
||||||
|
},
|
||||||
|
buyer: {
|
||||||
|
id: Cypress.env('VEGA_PUBLIC_KEY'),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
|
||||||
|
const defaultResult: FillsQuery = {
|
||||||
|
party: {
|
||||||
|
id: 'buyer-id',
|
||||||
|
tradesConnection: {
|
||||||
|
__typename: 'TradeConnection',
|
||||||
|
edges: fills.map((f) => {
|
||||||
|
return {
|
||||||
|
__typename: 'TradeEdge',
|
||||||
|
node: f,
|
||||||
|
cursor: '3',
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
pageInfo: {
|
||||||
|
__typename: 'PageInfo',
|
||||||
|
startCursor: '1',
|
||||||
|
endCursor: '2',
|
||||||
|
hasNextPage: false,
|
||||||
|
hasPreviousPage: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
__typename: 'Party',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return merge(defaultResult, override);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const generateFill = (override?: PartialDeep<FillFieldsFragment>) => {
|
||||||
|
const defaultFill: FillFieldsFragment = {
|
||||||
|
__typename: 'Trade',
|
||||||
|
id: '0',
|
||||||
|
createdAt: new Date().toISOString(),
|
||||||
|
price: '10000000',
|
||||||
|
size: '50000',
|
||||||
|
buyOrder: 'buy-order',
|
||||||
|
sellOrder: 'sell-order',
|
||||||
|
aggressor: Schema.Side.SIDE_BUY,
|
||||||
|
buyer: {
|
||||||
|
__typename: 'Party',
|
||||||
|
id: 'buyer-id',
|
||||||
|
},
|
||||||
|
seller: {
|
||||||
|
__typename: 'Party',
|
||||||
|
id: 'seller-id',
|
||||||
|
},
|
||||||
|
buyerFee: {
|
||||||
|
__typename: 'TradeFee',
|
||||||
|
makerFee: '100',
|
||||||
|
infrastructureFee: '100',
|
||||||
|
liquidityFee: '100',
|
||||||
|
},
|
||||||
|
sellerFee: {
|
||||||
|
__typename: 'TradeFee',
|
||||||
|
makerFee: '200',
|
||||||
|
infrastructureFee: '200',
|
||||||
|
liquidityFee: '200',
|
||||||
|
},
|
||||||
|
market: {
|
||||||
|
__typename: 'Market',
|
||||||
|
id: 'market-0',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return merge(defaultFill, override);
|
||||||
|
};
|
||||||
@@ -0,0 +1,210 @@
|
|||||||
|
import merge from 'lodash/merge';
|
||||||
|
import type { PartialDeep } from 'type-fest';
|
||||||
|
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
|
||||||
|
import type { MarketDepthQuery } from '../../../../../libs/market-depth/src/lib/__generated___/MarketDepth';
|
||||||
|
|
||||||
|
export const generateMarketDepth = (
|
||||||
|
override?: PartialDeep<MarketDepthQuery>
|
||||||
|
): MarketDepthQuery => {
|
||||||
|
const defaultResult: MarketDepthQuery = {
|
||||||
|
market: {
|
||||||
|
id: 'a46bd7e5277087723b7ab835844dec3cef8b4445738101269624bf5537d5d423',
|
||||||
|
depth: {
|
||||||
|
sell: [
|
||||||
|
{
|
||||||
|
price: '9893007',
|
||||||
|
volume: '3',
|
||||||
|
numberOfOrders: '3',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9893010',
|
||||||
|
volume: '4',
|
||||||
|
numberOfOrders: '4',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9893012',
|
||||||
|
volume: '1',
|
||||||
|
numberOfOrders: '1',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9893015',
|
||||||
|
volume: '1',
|
||||||
|
numberOfOrders: '1',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9893017',
|
||||||
|
volume: '2',
|
||||||
|
numberOfOrders: '2',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9893021',
|
||||||
|
volume: '4',
|
||||||
|
numberOfOrders: '1',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9893025',
|
||||||
|
volume: '5',
|
||||||
|
numberOfOrders: '1',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9893125',
|
||||||
|
volume: '4',
|
||||||
|
numberOfOrders: '1',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9893135',
|
||||||
|
volume: '2',
|
||||||
|
numberOfOrders: '1',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9893165',
|
||||||
|
volume: '5',
|
||||||
|
numberOfOrders: '1',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9893175',
|
||||||
|
volume: '3',
|
||||||
|
numberOfOrders: '1',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9893185',
|
||||||
|
volume: '3',
|
||||||
|
numberOfOrders: '3',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9894185',
|
||||||
|
volume: '1',
|
||||||
|
numberOfOrders: '1',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9894585',
|
||||||
|
volume: '1',
|
||||||
|
numberOfOrders: '1',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9895585',
|
||||||
|
volume: '4',
|
||||||
|
numberOfOrders: '1',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9896585',
|
||||||
|
volume: '2',
|
||||||
|
numberOfOrders: '2',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
buy: [
|
||||||
|
{
|
||||||
|
price: '9893005',
|
||||||
|
volume: '4',
|
||||||
|
numberOfOrders: '3',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9893003',
|
||||||
|
volume: '2',
|
||||||
|
numberOfOrders: '1',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9893001',
|
||||||
|
volume: '1',
|
||||||
|
numberOfOrders: '1',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9892006',
|
||||||
|
volume: '3',
|
||||||
|
numberOfOrders: '2',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9891006',
|
||||||
|
volume: '2',
|
||||||
|
numberOfOrders: '1',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9891001',
|
||||||
|
volume: '1',
|
||||||
|
numberOfOrders: '1',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9890101',
|
||||||
|
volume: '2',
|
||||||
|
numberOfOrders: '1',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9890091',
|
||||||
|
volume: '5',
|
||||||
|
numberOfOrders: '1',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9890081',
|
||||||
|
volume: '4',
|
||||||
|
numberOfOrders: '1',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9890050',
|
||||||
|
volume: '2',
|
||||||
|
numberOfOrders: '1',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9890040',
|
||||||
|
volume: '6',
|
||||||
|
numberOfOrders: '3',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9890030',
|
||||||
|
volume: '6',
|
||||||
|
numberOfOrders: '2',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9890021',
|
||||||
|
volume: '3',
|
||||||
|
numberOfOrders: '1',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9890011',
|
||||||
|
volume: '1',
|
||||||
|
numberOfOrders: '1',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
price: '9890001',
|
||||||
|
volume: '11',
|
||||||
|
numberOfOrders: '1',
|
||||||
|
__typename: 'PriceLevel',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
sequenceNumber: '1661773865550746910',
|
||||||
|
__typename: 'MarketDepth',
|
||||||
|
},
|
||||||
|
__typename: 'Market',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return merge(defaultResult, override);
|
||||||
|
};
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
export const generateMarketMarkPrice = () => {
|
||||||
|
return {
|
||||||
|
market: {
|
||||||
|
decimalPlaces: 5,
|
||||||
|
data: { markPrice: '692748', __typename: 'MarketData' },
|
||||||
|
__typename: 'Market',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
import { protoMarket } from './commons';
|
||||||
|
|
||||||
|
export const generateMarketNames = () => {
|
||||||
|
return {
|
||||||
|
markets: [
|
||||||
|
{ ...protoMarket },
|
||||||
|
{
|
||||||
|
id: '1d7ddf67dac4924db03f5bf58571a7bcb1908d70c66580467717aabc5345b68a',
|
||||||
|
state: 'STATE_SUSPENDED',
|
||||||
|
tradableInstrument: {
|
||||||
|
instrument: {
|
||||||
|
code: 'AAPL.MF21',
|
||||||
|
name: 'Apple Monthly (30 Jun 2022)',
|
||||||
|
metadata: {
|
||||||
|
tags: [
|
||||||
|
'formerly:4899E01009F1A721',
|
||||||
|
'quote:USD',
|
||||||
|
'ticker:AAPL',
|
||||||
|
'class:equities/single-stock-futures',
|
||||||
|
'sector:tech',
|
||||||
|
'listing_venue:NASDAQ',
|
||||||
|
'country:US',
|
||||||
|
],
|
||||||
|
__typename: 'InstrumentMetadata',
|
||||||
|
},
|
||||||
|
product: { quoteName: 'USD', __typename: 'Future' },
|
||||||
|
__typename: 'Instrument',
|
||||||
|
},
|
||||||
|
__typename: 'TradableInstrument',
|
||||||
|
},
|
||||||
|
__typename: 'Market',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '87ae87cd3244fc1fab4b0e2dad2437879864192bb969f3109b69293421644c8b',
|
||||||
|
state: 'STATE_SUSPENDED',
|
||||||
|
tradableInstrument: {
|
||||||
|
instrument: {
|
||||||
|
code: 'TSLA.QM21',
|
||||||
|
name: 'Tesla Quarterly (30 Jun 2022)',
|
||||||
|
metadata: {
|
||||||
|
tags: [
|
||||||
|
'formerly:5A86B190C384997F',
|
||||||
|
'quote:EURO',
|
||||||
|
'ticker:TSLA',
|
||||||
|
'class:equities/single-stock-futures',
|
||||||
|
'sector:tech',
|
||||||
|
'listing_venue:NASDAQ',
|
||||||
|
'country:US',
|
||||||
|
],
|
||||||
|
__typename: 'InstrumentMetadata',
|
||||||
|
},
|
||||||
|
product: { quoteName: 'EURO', __typename: 'Future' },
|
||||||
|
__typename: 'Instrument',
|
||||||
|
},
|
||||||
|
__typename: 'TradableInstrument',
|
||||||
|
},
|
||||||
|
__typename: 'Market',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '69205712a854f1bbfb69fa3d11b60e01a1e249bafb5ece88115e7451e8ef07b3',
|
||||||
|
state: 'STATE_SUSPENDED',
|
||||||
|
tradableInstrument: {
|
||||||
|
instrument: {
|
||||||
|
code: 'BTCUSD.MF21',
|
||||||
|
name: 'BTCUSD Monthly (30 Jun 2022)',
|
||||||
|
metadata: {
|
||||||
|
tags: [
|
||||||
|
'formerly:076BB86A5AA41E3E',
|
||||||
|
'base:BTC',
|
||||||
|
'quote:USD',
|
||||||
|
'class:fx/crypto',
|
||||||
|
'monthly',
|
||||||
|
'sector:crypto',
|
||||||
|
],
|
||||||
|
__typename: 'InstrumentMetadata',
|
||||||
|
},
|
||||||
|
product: { quoteName: 'USD', __typename: 'Future' },
|
||||||
|
__typename: 'Instrument',
|
||||||
|
},
|
||||||
|
__typename: 'TradableInstrument',
|
||||||
|
},
|
||||||
|
__typename: 'Market',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'ethbtc-quaterly',
|
||||||
|
state: 'STATE_ACTIVE',
|
||||||
|
tradableInstrument: {
|
||||||
|
instrument: {
|
||||||
|
code: 'ETHBTC.QM21',
|
||||||
|
name: 'ETHBTC Quarterly (30 Jun 2022)',
|
||||||
|
metadata: {
|
||||||
|
tags: [
|
||||||
|
'formerly:1F0BB6EB5703B099',
|
||||||
|
'base:ETH',
|
||||||
|
'quote:BTC',
|
||||||
|
'class:fx/crypto',
|
||||||
|
'quarterly',
|
||||||
|
'sector:crypto',
|
||||||
|
],
|
||||||
|
__typename: 'InstrumentMetadata',
|
||||||
|
},
|
||||||
|
product: { quoteName: 'BTC', __typename: 'Future' },
|
||||||
|
__typename: 'Instrument',
|
||||||
|
},
|
||||||
|
__typename: 'TradableInstrument',
|
||||||
|
},
|
||||||
|
__typename: 'Market',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '3c62b2714c4332d1a689a5352bff090e6aabccfd6bd87ce018936b38372530c9',
|
||||||
|
state: 'STATE_ACTIVE',
|
||||||
|
tradableInstrument: {
|
||||||
|
instrument: {
|
||||||
|
code: 'UNIDAI.MF21',
|
||||||
|
name: 'UNIDAI Monthly (30 Jun 2022)',
|
||||||
|
metadata: {
|
||||||
|
tags: [
|
||||||
|
'formerly:3C58ED2A4A6C5D7E',
|
||||||
|
'base:UNI',
|
||||||
|
'quote:DAI',
|
||||||
|
'class:fx/crypto',
|
||||||
|
'monthly',
|
||||||
|
'sector:defi',
|
||||||
|
],
|
||||||
|
__typename: 'InstrumentMetadata',
|
||||||
|
},
|
||||||
|
product: { quoteName: 'DAI', __typename: 'Future' },
|
||||||
|
__typename: 'Instrument',
|
||||||
|
},
|
||||||
|
__typename: 'TradableInstrument',
|
||||||
|
},
|
||||||
|
__typename: 'Market',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
import type { MarketPositionsQuery } from '@vegaprotocol/deal-ticket';
|
||||||
|
import { Schema } from '@vegaprotocol/types';
|
||||||
|
|
||||||
|
export const generateMarketPositions = (): MarketPositionsQuery => {
|
||||||
|
return {
|
||||||
|
party: {
|
||||||
|
id: '2e1ef32e5804e14232406aebaad719087d326afa5c648b7824d0823d8a46c8d1',
|
||||||
|
accountsConnection: {
|
||||||
|
__typename: 'AccountsConnection',
|
||||||
|
edges: [
|
||||||
|
{
|
||||||
|
__typename: 'AccountEdge',
|
||||||
|
node: {
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
type: Schema.AccountType.ACCOUNT_TYPE_GENERAL,
|
||||||
|
asset: {
|
||||||
|
decimals: 5,
|
||||||
|
},
|
||||||
|
balance: '400000000000000000000',
|
||||||
|
market: {
|
||||||
|
id: '2751c508f9759761f912890f37fb3f97a00300bf7685c02a56a86e05facfe221',
|
||||||
|
__typename: 'Market',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
__typename: 'AccountEdge',
|
||||||
|
node: {
|
||||||
|
type: Schema.AccountType.ACCOUNT_TYPE_MARGIN,
|
||||||
|
asset: {
|
||||||
|
decimals: 5,
|
||||||
|
},
|
||||||
|
balance: '265329',
|
||||||
|
market: {
|
||||||
|
id: 'ca7768f6de84bf86a21bbb6b0109d9659c81917b0e0339b2c262566c9b581a15',
|
||||||
|
__typename: 'Market',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
positionsConnection: {
|
||||||
|
edges: [
|
||||||
|
{
|
||||||
|
node: {
|
||||||
|
openVolume: '3',
|
||||||
|
market: {
|
||||||
|
id: '2751c508f9759761f912890f37fb3f97a00300bf7685c02a56a86e05facfe221',
|
||||||
|
__typename: 'Market',
|
||||||
|
},
|
||||||
|
__typename: 'Position',
|
||||||
|
},
|
||||||
|
__typename: 'PositionEdge',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
node: {
|
||||||
|
openVolume: '12',
|
||||||
|
market: {
|
||||||
|
id: 'ca7768f6de84bf86a21bbb6b0109d9659c81917b0e0339b2c262566c9b581a15',
|
||||||
|
__typename: 'Market',
|
||||||
|
},
|
||||||
|
__typename: 'Position',
|
||||||
|
},
|
||||||
|
__typename: 'PositionEdge',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
__typename: 'PositionConnection',
|
||||||
|
},
|
||||||
|
__typename: 'Party',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
export const generateMarketTags = () => {
|
||||||
|
return {
|
||||||
|
market: {
|
||||||
|
tradableInstrument: {
|
||||||
|
instrument: {
|
||||||
|
metadata: {
|
||||||
|
tags: [
|
||||||
|
'formerly:2839D9B2329C9E70',
|
||||||
|
'base:AAVE',
|
||||||
|
'quote:DAI',
|
||||||
|
'class:fx/crypto',
|
||||||
|
'monthly',
|
||||||
|
'sector:defi',
|
||||||
|
'settlement:2022-08-01',
|
||||||
|
],
|
||||||
|
__typename: 'InstrumentMetadata',
|
||||||
|
},
|
||||||
|
__typename: 'Instrument',
|
||||||
|
},
|
||||||
|
__typename: 'TradableInstrument',
|
||||||
|
},
|
||||||
|
__typename: 'Market',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,143 @@
|
|||||||
|
import merge from 'lodash/merge';
|
||||||
|
import type { PartialDeep } from 'type-fest';
|
||||||
|
import type { OrdersQuery, OrderFieldsFragment } from '@vegaprotocol/orders';
|
||||||
|
import { Schema } from '@vegaprotocol/types';
|
||||||
|
|
||||||
|
export const generateOrders = (
|
||||||
|
override?: PartialDeep<OrdersQuery>
|
||||||
|
): OrdersQuery => {
|
||||||
|
const orders: OrderFieldsFragment[] = [
|
||||||
|
{
|
||||||
|
__typename: 'Order',
|
||||||
|
id: '066468C06549101DAF7BC51099E1412A0067DC08C246B7D8013C9D0CBF1E8EE7',
|
||||||
|
market: {
|
||||||
|
__typename: 'Market',
|
||||||
|
id: 'market-0',
|
||||||
|
},
|
||||||
|
size: '10',
|
||||||
|
type: Schema.OrderType.TYPE_LIMIT,
|
||||||
|
status: Schema.OrderStatus.STATUS_FILLED,
|
||||||
|
side: Schema.Side.SIDE_BUY,
|
||||||
|
remaining: '0',
|
||||||
|
price: '20000000',
|
||||||
|
timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC,
|
||||||
|
createdAt: new Date(2020, 1, 30).toISOString(),
|
||||||
|
updatedAt: null,
|
||||||
|
expiresAt: null,
|
||||||
|
rejectionReason: null,
|
||||||
|
liquidityProvision: null,
|
||||||
|
peggedOrder: null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
__typename: 'Order',
|
||||||
|
id: '48DB6767E4E4E0F649C5A13ABFADE39F8451C27DA828DAF14B7A1E8E5EBDAD99',
|
||||||
|
market: {
|
||||||
|
__typename: 'Market',
|
||||||
|
id: 'market-1',
|
||||||
|
},
|
||||||
|
size: '1',
|
||||||
|
type: Schema.OrderType.TYPE_LIMIT,
|
||||||
|
status: Schema.OrderStatus.STATUS_FILLED,
|
||||||
|
side: Schema.Side.SIDE_BUY,
|
||||||
|
remaining: '0',
|
||||||
|
price: '100',
|
||||||
|
timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC,
|
||||||
|
createdAt: new Date(2020, 1, 29).toISOString(),
|
||||||
|
updatedAt: null,
|
||||||
|
expiresAt: null,
|
||||||
|
rejectionReason: null,
|
||||||
|
liquidityProvision: null,
|
||||||
|
peggedOrder: null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
__typename: 'Order',
|
||||||
|
id: '4e93702990712c41f6995fcbbd94f60bb372ad12d64dfa7d96d205c49f790336',
|
||||||
|
market: {
|
||||||
|
__typename: 'Market',
|
||||||
|
id: 'market-2',
|
||||||
|
},
|
||||||
|
size: '1',
|
||||||
|
type: Schema.OrderType.TYPE_LIMIT,
|
||||||
|
status: Schema.OrderStatus.STATUS_FILLED,
|
||||||
|
side: Schema.Side.SIDE_BUY,
|
||||||
|
remaining: '0',
|
||||||
|
price: '20000',
|
||||||
|
timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC,
|
||||||
|
createdAt: new Date(2020, 1, 28).toISOString(),
|
||||||
|
updatedAt: null,
|
||||||
|
expiresAt: null,
|
||||||
|
rejectionReason: null,
|
||||||
|
liquidityProvision: null,
|
||||||
|
peggedOrder: null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
__typename: 'Order',
|
||||||
|
id: '94737d2bafafa4bc3b80a56ef084ae52a983b91aa067c31e243c61a0f962a836',
|
||||||
|
market: {
|
||||||
|
__typename: 'Market',
|
||||||
|
id: 'market-3',
|
||||||
|
},
|
||||||
|
size: '1',
|
||||||
|
type: Schema.OrderType.TYPE_LIMIT,
|
||||||
|
status: Schema.OrderStatus.STATUS_ACTIVE,
|
||||||
|
side: Schema.Side.SIDE_BUY,
|
||||||
|
remaining: '0',
|
||||||
|
price: '100000',
|
||||||
|
timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC,
|
||||||
|
createdAt: new Date(2020, 1, 27).toISOString(),
|
||||||
|
updatedAt: null,
|
||||||
|
expiresAt: null,
|
||||||
|
rejectionReason: null,
|
||||||
|
liquidityProvision: null,
|
||||||
|
peggedOrder: null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
__typename: 'Order',
|
||||||
|
id: '94aead3ca92dc932efcb503631b03a410e2a5d4606cae6083e2406dc38e52f78',
|
||||||
|
market: {
|
||||||
|
__typename: 'Market',
|
||||||
|
id: 'market-3',
|
||||||
|
},
|
||||||
|
size: '10',
|
||||||
|
type: Schema.OrderType.TYPE_LIMIT,
|
||||||
|
status: Schema.OrderStatus.STATUS_PARTIALLY_FILLED,
|
||||||
|
side: Schema.Side.SIDE_SELL,
|
||||||
|
remaining: '3',
|
||||||
|
price: '100000',
|
||||||
|
timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC,
|
||||||
|
createdAt: new Date(2020, 1, 27).toISOString(),
|
||||||
|
updatedAt: null,
|
||||||
|
expiresAt: null,
|
||||||
|
liquidityProvision: null,
|
||||||
|
peggedOrder: null,
|
||||||
|
rejectionReason: null,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const defaultResult: OrdersQuery = {
|
||||||
|
party: {
|
||||||
|
id: Cypress.env('VEGA_PUBLIC_KEY'),
|
||||||
|
ordersConnection: {
|
||||||
|
__typename: 'OrderConnection',
|
||||||
|
edges: orders.map((f) => {
|
||||||
|
return {
|
||||||
|
__typename: 'OrderEdge',
|
||||||
|
node: f,
|
||||||
|
cursor: f.id,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
pageInfo: {
|
||||||
|
__typename: 'PageInfo',
|
||||||
|
startCursor:
|
||||||
|
'066468C06549101DAF7BC51099E1412A0067DC08C246B7D8013C9D0CBF1E8EE7',
|
||||||
|
endCursor:
|
||||||
|
'94737d2bafafa4bc3b80a56ef084ae52a983b91aa067c31e243c61a0f962a836',
|
||||||
|
hasNextPage: false,
|
||||||
|
hasPreviousPage: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
__typename: 'Party',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return merge(defaultResult, override);
|
||||||
|
};
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
import merge from 'lodash/merge';
|
||||||
|
import type { PartyBalanceQuery } from '@vegaprotocol/deal-ticket';
|
||||||
|
import type { PartialDeep } from 'type-fest';
|
||||||
|
import { Schema as Types } from '@vegaprotocol/types';
|
||||||
|
|
||||||
|
export const generatePartyBalance = (
|
||||||
|
override?: PartialDeep<PartyBalanceQuery>
|
||||||
|
): PartyBalanceQuery => {
|
||||||
|
const defaultResult: PartyBalanceQuery = {
|
||||||
|
party: {
|
||||||
|
accountsConnection: {
|
||||||
|
__typename: 'AccountsConnection',
|
||||||
|
edges: [
|
||||||
|
{
|
||||||
|
__typename: 'AccountEdge',
|
||||||
|
node: {
|
||||||
|
balance: '88474051',
|
||||||
|
type: Types.AccountType.ACCOUNT_TYPE_GENERAL,
|
||||||
|
asset: {
|
||||||
|
id: 'dai-id',
|
||||||
|
symbol: 'tDAI',
|
||||||
|
name: 'tDAI TEST',
|
||||||
|
decimals: 5,
|
||||||
|
__typename: 'Asset',
|
||||||
|
},
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
__typename: 'AccountEdge',
|
||||||
|
node: {
|
||||||
|
balance: '100000000',
|
||||||
|
type: Types.AccountType.ACCOUNT_TYPE_GENERAL,
|
||||||
|
asset: {
|
||||||
|
id: '8b52d4a3a4b0ffe733cddbc2b67be273816cfeb6ca4c8b339bac03ffba08e4e4',
|
||||||
|
symbol: 'tEURO',
|
||||||
|
name: 'tEURO TEST',
|
||||||
|
decimals: 5,
|
||||||
|
__typename: 'Asset',
|
||||||
|
},
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
__typename: 'AccountEdge',
|
||||||
|
node: {
|
||||||
|
balance: '3412867',
|
||||||
|
type: Types.AccountType.ACCOUNT_TYPE_GENERAL,
|
||||||
|
asset: {
|
||||||
|
id: 'dai-id',
|
||||||
|
symbol: 'tDAI',
|
||||||
|
name: 'tDAI TEST',
|
||||||
|
decimals: 5,
|
||||||
|
__typename: 'Asset',
|
||||||
|
},
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
__typename: 'AccountEdge',
|
||||||
|
node: {
|
||||||
|
balance: '70007',
|
||||||
|
type: Types.AccountType.ACCOUNT_TYPE_GENERAL,
|
||||||
|
asset: {
|
||||||
|
id: 'dai-id',
|
||||||
|
symbol: 'tDAI',
|
||||||
|
name: 'tDAI TEST',
|
||||||
|
decimals: 5,
|
||||||
|
__typename: 'Asset',
|
||||||
|
},
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
__typename: 'Party',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return merge(defaultResult, override);
|
||||||
|
};
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import type { PartyMarketDataQuery } from '@vegaprotocol/deal-ticket';
|
||||||
|
import { Schema as Types } from '@vegaprotocol/types';
|
||||||
|
|
||||||
|
export const generatePartyMarketData = (): PartyMarketDataQuery => {
|
||||||
|
return {
|
||||||
|
party: {
|
||||||
|
id: '2e1ef32e5804e14232406aebaad719087d326afa5c648b7824d0823d8a46c8d1',
|
||||||
|
accountsConnection: {
|
||||||
|
__typename: 'AccountsConnection',
|
||||||
|
edges: [
|
||||||
|
{
|
||||||
|
__typename: 'AccountEdge',
|
||||||
|
node: {
|
||||||
|
type: Types.AccountType.ACCOUNT_TYPE_GENERAL,
|
||||||
|
balance: '1200000',
|
||||||
|
asset: { id: 'fBTC', decimals: 5, __typename: 'Asset' },
|
||||||
|
market: null,
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
__typename: 'AccountEdge',
|
||||||
|
node: {
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
type: Types.AccountType.ACCOUNT_TYPE_GENERAL,
|
||||||
|
balance: '0.000000001',
|
||||||
|
asset: {
|
||||||
|
__typename: 'Asset',
|
||||||
|
id: '5cfa87844724df6069b94e4c8a6f03af21907d7bc251593d08e4251043ee9f7c',
|
||||||
|
decimals: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
marginsConnection: { edges: null, __typename: 'MarginConnection' },
|
||||||
|
__typename: 'Party',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
import merge from 'lodash/merge';
|
||||||
|
import type { PartialDeep } from 'type-fest';
|
||||||
|
import type {
|
||||||
|
PositionsQuery,
|
||||||
|
PositionFieldsFragment,
|
||||||
|
MarginsQuery,
|
||||||
|
} from '@vegaprotocol/positions';
|
||||||
|
|
||||||
|
export const generatePositions = (
|
||||||
|
override?: PartialDeep<PositionsQuery>
|
||||||
|
): PositionsQuery => {
|
||||||
|
const nodes: PositionFieldsFragment[] = [
|
||||||
|
{
|
||||||
|
__typename: 'Position',
|
||||||
|
realisedPNL: '0',
|
||||||
|
openVolume: '6',
|
||||||
|
unrealisedPNL: '895000',
|
||||||
|
averageEntryPrice: '1129935',
|
||||||
|
updatedAt: '2022-07-28T15:09:34.441143Z',
|
||||||
|
market: {
|
||||||
|
id: 'c9f5acd348796011c075077e4d58d9b7f1689b7c1c8e030a5e886b83aa96923d',
|
||||||
|
__typename: 'Market',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
__typename: 'Position',
|
||||||
|
realisedPNL: '100',
|
||||||
|
openVolume: '20',
|
||||||
|
unrealisedPNL: '895000',
|
||||||
|
averageEntryPrice: '8509338',
|
||||||
|
updatedAt: '2022-07-28T15:09:34.441143Z',
|
||||||
|
market: {
|
||||||
|
id: '0604e8c918655474525e1a95367902266ade70d318c2c908f0cca6e3d11dcb13',
|
||||||
|
__typename: 'Market',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
realisedPNL: '0',
|
||||||
|
openVolume: '1',
|
||||||
|
unrealisedPNL: '-22519',
|
||||||
|
averageEntryPrice: '84400088',
|
||||||
|
updatedAt: '2022-07-28T14:53:54.725477Z',
|
||||||
|
market: {
|
||||||
|
id: '5a4b0b9e9c0629f0315ec56fcb7bd444b0c6e4da5ec7677719d502626658a376',
|
||||||
|
__typename: 'Market',
|
||||||
|
},
|
||||||
|
__typename: 'Position',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const defaultResult: PositionsQuery = {
|
||||||
|
party: {
|
||||||
|
__typename: 'Party',
|
||||||
|
id: Cypress.env('VEGA_PUBLIC_KEY'),
|
||||||
|
positionsConnection: {
|
||||||
|
__typename: 'PositionConnection',
|
||||||
|
edges: nodes.map((node) => {
|
||||||
|
return {
|
||||||
|
__typename: 'PositionEdge',
|
||||||
|
node,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return merge(defaultResult, override);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const emptyPositions = (): PositionsQuery => {
|
||||||
|
return {
|
||||||
|
party: {
|
||||||
|
id: Cypress.env('VEGA_PUBLIC_KEY'),
|
||||||
|
positionsConnection: { edges: null, __typename: 'PositionConnection' },
|
||||||
|
__typename: 'Party',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const generateMargins = (): MarginsQuery => {
|
||||||
|
return {
|
||||||
|
party: {
|
||||||
|
id: Cypress.env('VEGA_PUBLIC_KEY'),
|
||||||
|
marginsConnection: {
|
||||||
|
edges: [
|
||||||
|
{
|
||||||
|
node: {
|
||||||
|
__typename: 'MarginLevels',
|
||||||
|
maintenanceLevel: '0',
|
||||||
|
searchLevel: '0',
|
||||||
|
initialLevel: '0',
|
||||||
|
collateralReleaseLevel: '0',
|
||||||
|
market: {
|
||||||
|
__typename: 'Market',
|
||||||
|
id: 'c9f5acd348796011c075077e4d58d9b7f1689b7c1c8e030a5e886b83aa96923d',
|
||||||
|
},
|
||||||
|
asset: {
|
||||||
|
__typename: 'Asset',
|
||||||
|
id: 'tDAI-id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
node: {
|
||||||
|
__typename: 'MarginLevels',
|
||||||
|
maintenanceLevel: '0',
|
||||||
|
searchLevel: '0',
|
||||||
|
initialLevel: '0',
|
||||||
|
collateralReleaseLevel: '0',
|
||||||
|
market: {
|
||||||
|
__typename: 'Market',
|
||||||
|
id: '0604e8c918655474525e1a95367902266ade70d318c2c908f0cca6e3d11dcb13',
|
||||||
|
},
|
||||||
|
asset: {
|
||||||
|
__typename: 'Asset',
|
||||||
|
id: 'tDAI-id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
__typename: 'MarginEdge',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
node: {
|
||||||
|
__typename: 'MarginLevels',
|
||||||
|
maintenanceLevel: '0',
|
||||||
|
searchLevel: '0',
|
||||||
|
initialLevel: '0',
|
||||||
|
collateralReleaseLevel: '0',
|
||||||
|
market: {
|
||||||
|
__typename: 'Market',
|
||||||
|
id: '5a4b0b9e9c0629f0315ec56fcb7bd444b0c6e4da5ec7677719d502626658a376',
|
||||||
|
},
|
||||||
|
asset: {
|
||||||
|
__typename: 'Asset',
|
||||||
|
id: 'tEURO-id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
__typename: 'MarginEdge',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
__typename: 'MarginConnection',
|
||||||
|
},
|
||||||
|
__typename: 'Party',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import type { StatisticsQuery } from '@vegaprotocol/environment';
|
||||||
|
import merge from 'lodash/merge';
|
||||||
|
import type { PartialDeep } from 'type-fest';
|
||||||
|
|
||||||
|
export const generateStatistics = (
|
||||||
|
override?: PartialDeep<StatisticsQuery>
|
||||||
|
): StatisticsQuery => {
|
||||||
|
const defaultResult = {
|
||||||
|
statistics: {
|
||||||
|
__typename: 'Statistics',
|
||||||
|
chainId: Cypress.env('VEGA_ENV').toLowerCase() || 'test-chain-id',
|
||||||
|
blockHeight: '11',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return merge(defaultResult, override);
|
||||||
|
};
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
export const connectVegaWallet = () => {
|
||||||
|
const form = 'rest-connector-form';
|
||||||
|
const walletName = Cypress.env('TRADING_TEST_VEGA_WALLET_NAME');
|
||||||
|
const walletPassphrase = Cypress.env('TRADING_TEST_VEGA_WALLET_PASSPHRASE');
|
||||||
|
cy.getByTestId('connect-vega-wallet').click();
|
||||||
|
cy.getByTestId('connectors-list')
|
||||||
|
.find('[data-testid="connector-gui"]')
|
||||||
|
.click();
|
||||||
|
cy.getByTestId(form).find('#wallet').click().type(walletName);
|
||||||
|
cy.getByTestId(form).find('#passphrase').click().type(walletPassphrase);
|
||||||
|
cy.getByTestId('rest-connector-form').find('button[type=submit]').click();
|
||||||
|
};
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"strict": true,
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"sourceMap": false,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"outDir": "../../dist/out-tsc",
|
||||||
|
"allowJs": true,
|
||||||
|
"types": ["cypress", "node", "cypress-real-events", "cypress-grep"]
|
||||||
|
},
|
||||||
|
"include": ["src/**/*.ts", "src/**/*.js", "./declaration.d.ts"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
# React Environment Variables
|
||||||
|
# https://facebook.github.io/create-react-app/docs/adding-custom-environment-variables#expanding-environment-variables-in-env
|
||||||
|
|
||||||
|
# Netlify Environment Variables
|
||||||
|
# https://www.netlify.com/docs/continuous-deployment/#environment-variables
|
||||||
|
NX_VERSION=$npm_package_version
|
||||||
|
NX_REPOSITORY_URL=$REPOSITORY_URL
|
||||||
|
NX_BRANCH=$BRANCH
|
||||||
|
NX_PULL_REQUEST=$PULL_REQUEST
|
||||||
|
NX_HEAD=$HEAD
|
||||||
|
NX_COMMIT_REF=$COMMIT_REF
|
||||||
|
NX_CONTEXT=$CONTEXT
|
||||||
|
NX_REVIEW_ID=$REVIEW_ID
|
||||||
|
NX_INCOMING_HOOK_TITLE=$INCOMING_HOOK_TITLE
|
||||||
|
NX_INCOMING_HOOK_URL=$INCOMING_HOOK_URL
|
||||||
|
NX_INCOMING_HOOK_BODY=$INCOMING_HOOK_BODY
|
||||||
|
NX_URL=$URL
|
||||||
|
NX_DEPLOY_URL=$DEPLOY_URL
|
||||||
|
NX_DEPLOY_PRIME_URL=$DEPLOY_PRIME_URL
|
||||||
|
NX_VEGA_CONFIG_URL="https://static.vega.xyz/assets/stagnet3-network.json"
|
||||||
|
NX_VEGA_ENV=STAGNET3
|
||||||
|
NX_VEGA_URL="https://api.stagnet3.vega.xyz/graphql"
|
||||||
|
NX_VEGA_WALLET_URL=http://localhost:1789
|
||||||
|
NX_ETHEREUM_PROVIDER_URL=https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||||
|
NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
||||||
|
NX_VEGA_NETWORKS={"MAINNET":"https://alpha.console.vega.xyz"}
|
||||||
|
NX_VEGA_EXPLORER_URL=https://explorer.fairground.wtf
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# App configuration variables
|
||||||
|
NX_VEGA_URL=http://localhost:3028/query
|
||||||
|
NX_VEGA_ENV=LOCAL
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# App configuration variables
|
||||||
|
NX_VEGA_CONFIG_URL=https://static.vega.xyz/assets/devnet-network.json
|
||||||
|
NX_VEGA_URL=https://api.n04.d.vega.xyz/graphql
|
||||||
|
NX_VEGA_ENV=DEVNET
|
||||||
|
NX_VEGA_NETWORKS={\"MAINNET\":\"https://alpha.console.vega.xyz\"}
|
||||||
|
NX_ETHEREUM_PROVIDER_URL=https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||||
|
NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
||||||
|
NX_VEGA_EXPLORER_URL=https://dev.explorer.vega.xyz
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# App configuration variables
|
||||||
|
NX_VEGA_CONFIG_URL=https://static.vega.xyz/assets/mainnet-network.json
|
||||||
|
NX_VEGA_URL=https://api.vega.xyz/query
|
||||||
|
NX_VEGA_ENV=MAINNET
|
||||||
|
NX_VEGA_NETWORKS='{\"MAINNET\":\"https://alpha.console.vega.xyz\"}'
|
||||||
|
NX_ETHEREUM_PROVIDER_URL=https://mainnet.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||||
|
NX_ETHERSCAN_URL=https://etherscan.io
|
||||||
|
NX_VEGA_EXPLORER_URL=https://explorer.vega.xyz
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
NX_VEGA_CONFIG_URL=https://static.vega.xyz/assets/sandbox-network.json
|
||||||
|
NX_VEGA_URL=https://api.sandbox.vega.xyz/graphql
|
||||||
|
NX_VEGA_ENV=SANDBOX
|
||||||
|
NX_VEGA_NETWORKS='{"DEVNET":"https://dev.token.vega.xyz","STAGNET3":"https://stagnet3.token.vega.xyz","STAGNET1":"https://stagnet1.token.vega.xyz","TESTNET":"https://token.fairground.wtf","MAINNET":"https://token.vega.xyz"}'
|
||||||
|
NX_VEGA_CONFIG_URL=https://static.vega.xyz/assets/sandbox-network.json
|
||||||
|
NX_VEGA_EXPLORER_URL=https://sandbox.explorer.vega.xyz
|
||||||
|
NX_VEGA_DOCS_URL=https://docs.vega.xyz/testnet
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
NX_ETHEREUM_PROVIDER_URL=https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||||
|
NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
||||||
|
NX_HOSTED_WALLET_URL=https://wallet.testnet.vega.xyz
|
||||||
|
NX_VEGA_CONFIG_URL=https://static.vega.xyz/assets/stagnet1-network.json
|
||||||
|
NX_VEGA_ENV=STAGNET1
|
||||||
|
NX_VEGA_EXPLORER_URL=https://stagnet1.explorer.vega.xyz
|
||||||
|
NX_VEGA_NETWORKS={\"TESTNET\":\"https://console.fairground.wtf\",\"STAGNET1\":\"https://stagnet1.console.vega.xyz\",\"STAGNET3\":\"https://stagnet3.console.vega.xyz\"}
|
||||||
|
NX_VEGA_TOKEN_URL=https://stagnet1.token.vega.xyz
|
||||||
|
NX_VEGA_URL=https://api.n00.stagnet1.vega.xyz/graphql
|
||||||
|
NX_VEGA_WALLET_URL=http://localhost:1789
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# App configuration variables
|
||||||
|
NX_VEGA_CONFIG_URL=https://static.vega.xyz/assets/stagnet3-network.json
|
||||||
|
NX_VEGA_URL=https://api.stagnet3.vega.xyz/graphql
|
||||||
|
NX_VEGA_ENV=STAGNET3
|
||||||
|
NX_ETHEREUM_PROVIDER_URL=https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||||
|
NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
||||||
|
NX_VEGA_EXPLORER_URL=https://stagnet3.explorer.vega.xyz
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# App configuration variables
|
||||||
|
NX_VEGA_CONFIG_URL=https://static.vega.xyz/assets/testnet-network.json
|
||||||
|
NX_VEGA_URL=https://api.n12.testnet.vega.xyz/graphql
|
||||||
|
NX_VEGA_ENV=TESTNET
|
||||||
|
NX_VEGA_NETWORKS='{\"MAINNET\":\"https://alpha.console.vega.xyz\"}'
|
||||||
|
NX_ETHEREUM_PROVIDER_URL=https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||||
|
NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
||||||
|
NX_VEGA_EXPLORER_URL=https://explorer.fairground.wtf
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
export default {
|
||||||
|
displayName: 'console-lite',
|
||||||
|
preset: '../../jest.preset.js',
|
||||||
|
transform: {
|
||||||
|
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nrwl/react/plugins/jest',
|
||||||
|
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nrwl/next/babel'] }],
|
||||||
|
},
|
||||||
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
|
||||||
|
coverageDirectory: '../../coverage/apps/console-lite',
|
||||||
|
setupFilesAfterEnv: ['./setup-tests.ts'],
|
||||||
|
};
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
{
|
||||||
|
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||||
|
"sourceRoot": "apps/console-lite/src",
|
||||||
|
"projectType": "application",
|
||||||
|
"targets": {
|
||||||
|
"build": {
|
||||||
|
"executor": "./tools/executors/webpack:build",
|
||||||
|
"outputs": ["{options.outputPath}"],
|
||||||
|
"defaultConfiguration": "production",
|
||||||
|
"options": {
|
||||||
|
"compiler": "babel",
|
||||||
|
"outputPath": "dist/apps/console-lite",
|
||||||
|
"index": "apps/console-lite/src/index.html",
|
||||||
|
"baseHref": "/",
|
||||||
|
"main": "apps/console-lite/src/main.tsx",
|
||||||
|
"polyfills": "apps/console-lite/src/polyfills.ts",
|
||||||
|
"tsConfig": "apps/console-lite/tsconfig.app.json",
|
||||||
|
"assets": [
|
||||||
|
"apps/console-lite/src/favicon.ico",
|
||||||
|
"apps/console-lite/src/assets"
|
||||||
|
],
|
||||||
|
"styles": ["apps/console-lite/src/styles.scss"],
|
||||||
|
"scripts": [],
|
||||||
|
"webpackConfig": "@nrwl/react/plugins/webpack"
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"production": {
|
||||||
|
"fileReplacements": [
|
||||||
|
{
|
||||||
|
"replace": "apps/console-lite/src/environments/environment.ts",
|
||||||
|
"with": "apps/console-lite/src/environments/environment.prod.ts"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"optimization": true,
|
||||||
|
"outputHashing": "all",
|
||||||
|
"sourceMap": false,
|
||||||
|
"namedChunks": false,
|
||||||
|
"extractLicenses": true,
|
||||||
|
"vendorChunk": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"serve": {
|
||||||
|
"executor": "./tools/executors/webpack:serve",
|
||||||
|
"options": {
|
||||||
|
"buildTarget": "console-lite:build:development",
|
||||||
|
"hmr": true,
|
||||||
|
"port": 4001
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"production": {
|
||||||
|
"buildTarget": "console-lite:build:production",
|
||||||
|
"hmr": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lint": {
|
||||||
|
"executor": "@nrwl/linter:eslint",
|
||||||
|
"outputs": ["{options.outputFile}"],
|
||||||
|
"options": {
|
||||||
|
"lintFilePatterns": ["apps/console-lite/**/*.{ts,tsx,js,jsx}"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"test": {
|
||||||
|
"executor": "@nrwl/jest:jest",
|
||||||
|
"outputs": ["coverage/apps/console-lite"],
|
||||||
|
"options": {
|
||||||
|
"jestConfig": "apps/console-lite/jest.config.ts",
|
||||||
|
"passWithNoTests": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"build-netlify": {
|
||||||
|
"executor": "@nrwl/workspace:run-commands",
|
||||||
|
"options": {
|
||||||
|
"commands": [
|
||||||
|
"cp apps/console-lite/netlify.toml netlify.toml",
|
||||||
|
"nx build console-lite"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"build-spec": {
|
||||||
|
"executor": "@nrwl/workspace:run-commands",
|
||||||
|
"outputs": [],
|
||||||
|
"options": {
|
||||||
|
"command": "yarn tsc --project ./apps/console-lite/tsconfig.spec.json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tags": []
|
||||||
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
import '@testing-library/jest-dom';
|
import '@testing-library/jest-dom';
|
||||||
import 'jest-canvas-mock';
|
import 'jest-canvas-mock';
|
||||||
|
import { defaultFallbackInView } from 'react-intersection-observer';
|
||||||
import ResizeObserver from 'resize-observer-polyfill';
|
import ResizeObserver from 'resize-observer-polyfill';
|
||||||
|
|
||||||
|
defaultFallbackInView(true);
|
||||||
global.ResizeObserver = ResizeObserver;
|
global.ResizeObserver = ResizeObserver;
|
||||||
|
|
||||||
global.DOMRect = class DOMRect {
|
global.DOMRect = class DOMRect {
|
||||||
@@ -23,3 +25,19 @@ global.DOMRect = class DOMRect {
|
|||||||
return JSON.stringify(this);
|
return JSON.stringify(this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Object.defineProperty(window, 'matchMedia', {
|
||||||
|
writable: true,
|
||||||
|
value: jest.fn().mockImplementation((query) => ({
|
||||||
|
matches: false,
|
||||||
|
media: query,
|
||||||
|
onchange: null,
|
||||||
|
addListener: jest.fn(), // Deprecated
|
||||||
|
removeListener: jest.fn(), // Deprecated
|
||||||
|
addEventListener: jest.fn(),
|
||||||
|
removeEventListener: jest.fn(),
|
||||||
|
dispatchEvent: jest.fn(),
|
||||||
|
})),
|
||||||
|
});
|
||||||
|
|
||||||
|
jest.setTimeout(30000);
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
import { useEffect } from 'react';
|
||||||
|
import { useLocation } from 'react-router-dom';
|
||||||
|
import { ThemeContext } from '@vegaprotocol/react-helpers';
|
||||||
|
import { useThemeSwitcher } from '@vegaprotocol/react-helpers';
|
||||||
|
import { EnvironmentProvider, NetworkLoader } from '@vegaprotocol/environment';
|
||||||
|
import {
|
||||||
|
VegaConnectDialog,
|
||||||
|
VegaManageDialog,
|
||||||
|
VegaWalletProvider,
|
||||||
|
} from '@vegaprotocol/wallet';
|
||||||
|
import { Connectors } from './lib/vega-connectors';
|
||||||
|
import '../styles.scss';
|
||||||
|
import { AppLoader } from './components/app-loader';
|
||||||
|
import Header from './components/header';
|
||||||
|
import { Main } from './components/main';
|
||||||
|
import LocalContext from './context/local-context';
|
||||||
|
import useLocalValues from './hooks/use-local-values';
|
||||||
|
import type { InMemoryCacheConfig } from '@apollo/client';
|
||||||
|
|
||||||
|
function App() {
|
||||||
|
const [theme, toggleTheme] = useThemeSwitcher();
|
||||||
|
const localValues = useLocalValues(theme, toggleTheme);
|
||||||
|
const {
|
||||||
|
vegaWalletDialog,
|
||||||
|
menu: { setMenuOpen },
|
||||||
|
} = localValues;
|
||||||
|
const location = useLocation();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setMenuOpen(false);
|
||||||
|
}, [location, setMenuOpen]);
|
||||||
|
|
||||||
|
const cacheConfig: InMemoryCacheConfig = {
|
||||||
|
typePolicies: {
|
||||||
|
Market: {
|
||||||
|
merge: true,
|
||||||
|
},
|
||||||
|
Party: {
|
||||||
|
merge: true,
|
||||||
|
},
|
||||||
|
Query: {},
|
||||||
|
Account: {
|
||||||
|
keyFields: false,
|
||||||
|
fields: {
|
||||||
|
balanceFormatted: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Node: {
|
||||||
|
keyFields: false,
|
||||||
|
},
|
||||||
|
Instrument: {
|
||||||
|
keyFields: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<EnvironmentProvider>
|
||||||
|
<ThemeContext.Provider value={theme}>
|
||||||
|
<NetworkLoader cache={cacheConfig}>
|
||||||
|
<VegaWalletProvider>
|
||||||
|
<LocalContext.Provider value={localValues}>
|
||||||
|
<AppLoader>
|
||||||
|
<div className="max-h-full min-h-full dark:bg-lite-black dark:text-neutral-200 bg-white text-neutral-800 grid grid-rows-[min-content,1fr]">
|
||||||
|
<Header />
|
||||||
|
<Main />
|
||||||
|
<VegaConnectDialog connectors={Connectors} />
|
||||||
|
<VegaManageDialog
|
||||||
|
dialogOpen={vegaWalletDialog.manage}
|
||||||
|
setDialogOpen={vegaWalletDialog.setManage}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</AppLoader>
|
||||||
|
</LocalContext.Provider>
|
||||||
|
</VegaWalletProvider>
|
||||||
|
</NetworkLoader>
|
||||||
|
</ThemeContext.Provider>
|
||||||
|
</EnvironmentProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default App;
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import { useEagerConnect } from '@vegaprotocol/wallet';
|
||||||
|
import type { ReactNode } from 'react';
|
||||||
|
import { Connectors } from '../../lib/vega-connectors';
|
||||||
|
|
||||||
|
interface AppLoaderProps {
|
||||||
|
children: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Component to handle any app initialization, startup querys and other things
|
||||||
|
* that must happen for it can be used
|
||||||
|
*/
|
||||||
|
export function AppLoader({ children }: AppLoaderProps) {
|
||||||
|
// Get keys from vega wallet immediately
|
||||||
|
useEagerConnect(Connectors);
|
||||||
|
|
||||||
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
||||||
|
return <>{children}</>;
|
||||||
|
}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
import React, {
|
||||||
|
forwardRef,
|
||||||
|
useCallback,
|
||||||
|
useContext,
|
||||||
|
useMemo,
|
||||||
|
useRef,
|
||||||
|
} from 'react';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import type { AgGridReact } from 'ag-grid-react';
|
||||||
|
import { AgGridDynamic as AgGrid } from '@vegaprotocol/ui-toolkit';
|
||||||
|
import { ThemeContext, useScreenDimensions } from '@vegaprotocol/react-helpers';
|
||||||
|
import type {
|
||||||
|
GridOptions,
|
||||||
|
GetRowIdParams,
|
||||||
|
TabToNextCellParams,
|
||||||
|
CellKeyDownEvent,
|
||||||
|
FullWidthCellKeyDownEvent,
|
||||||
|
IGetRowsParams,
|
||||||
|
IDatasource,
|
||||||
|
} from 'ag-grid-community';
|
||||||
|
import { NO_DATA_MESSAGE } from '../../constants';
|
||||||
|
import * as constants from '../simple-market-list/constants';
|
||||||
|
|
||||||
|
export interface GetRowsParams<T>
|
||||||
|
extends Omit<IGetRowsParams, 'successCallback'> {
|
||||||
|
successCallback(rowsThisBlock: T[], lastRow?: number): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Datasource<T> extends IDatasource {
|
||||||
|
getRows(params: GetRowsParams<T>): void;
|
||||||
|
}
|
||||||
|
interface Props<T> extends GridOptions {
|
||||||
|
rowData?: T[];
|
||||||
|
datasource?: Datasource<T>;
|
||||||
|
handleRowClicked?: (event: { data: T }) => void;
|
||||||
|
components?: Record<string, unknown>;
|
||||||
|
classNamesParam?: string | string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const ConsoleLiteGrid = <T extends { id?: string }>(
|
||||||
|
{ handleRowClicked, getRowId, classNamesParam, ...props }: Props<T>,
|
||||||
|
ref?: React.Ref<AgGridReact>
|
||||||
|
) => {
|
||||||
|
const { isMobile, screenSize } = useScreenDimensions();
|
||||||
|
const gridRef = useRef<AgGridReact | null>(null);
|
||||||
|
const theme = useContext(ThemeContext);
|
||||||
|
const handleOnGridReady = useCallback(() => {
|
||||||
|
(
|
||||||
|
(ref as React.RefObject<AgGridReact>) || gridRef
|
||||||
|
).current?.api?.sizeColumnsToFit();
|
||||||
|
}, [gridRef, ref]);
|
||||||
|
const onTabToNextCell = useCallback((params: TabToNextCellParams) => {
|
||||||
|
const {
|
||||||
|
api,
|
||||||
|
previousCellPosition: { rowIndex },
|
||||||
|
} = params;
|
||||||
|
const rowCount = api.getDisplayedRowCount();
|
||||||
|
if (rowCount <= rowIndex + 1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return { ...params.previousCellPosition, rowIndex: rowIndex + 1 };
|
||||||
|
}, []);
|
||||||
|
const getRowIdLocal = useCallback(({ data }: GetRowIdParams) => data.id, []);
|
||||||
|
const onCellKeyDown = useCallback(
|
||||||
|
(
|
||||||
|
params: (CellKeyDownEvent | FullWidthCellKeyDownEvent) & {
|
||||||
|
event: KeyboardEvent;
|
||||||
|
}
|
||||||
|
) => {
|
||||||
|
const { event: { key = '' } = {}, data } = params;
|
||||||
|
if (key === 'Enter') {
|
||||||
|
handleRowClicked?.({ data });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[handleRowClicked]
|
||||||
|
);
|
||||||
|
const shouldSuppressHorizontalScroll = useMemo(() => {
|
||||||
|
return !isMobile && constants.LARGE_SCREENS.includes(screenSize);
|
||||||
|
}, [isMobile, screenSize]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AgGrid
|
||||||
|
className={classNames(classNamesParam)}
|
||||||
|
rowHeight={60}
|
||||||
|
customThemeParams={
|
||||||
|
theme === 'dark'
|
||||||
|
? constants.agGridDarkVariables
|
||||||
|
: constants.agGridLightVariables
|
||||||
|
}
|
||||||
|
onGridReady={handleOnGridReady}
|
||||||
|
onRowClicked={handleRowClicked}
|
||||||
|
rowClass={isMobile ? 'mobile' : ''}
|
||||||
|
rowClassRules={constants.ROW_CLASS_RULES}
|
||||||
|
ref={ref || gridRef}
|
||||||
|
overlayNoRowsTemplate={NO_DATA_MESSAGE}
|
||||||
|
suppressContextMenu
|
||||||
|
getRowId={getRowId || getRowIdLocal}
|
||||||
|
suppressMovableColumns
|
||||||
|
suppressRowTransform
|
||||||
|
onCellKeyDown={onCellKeyDown}
|
||||||
|
tabToNextCell={onTabToNextCell}
|
||||||
|
suppressHorizontalScroll={shouldSuppressHorizontalScroll}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const ConsoleLiteGridForwarder = forwardRef(ConsoleLiteGrid) as <T>(
|
||||||
|
p: Props<T> & { ref?: React.Ref<AgGridReact> }
|
||||||
|
) => React.ReactElement;
|
||||||
|
|
||||||
|
export default ConsoleLiteGridForwarder;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export { default as ConsoleLiteGrid } from './console-lite-grid';
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
query MarketTags($marketId: ID!) {
|
||||||
|
market(id: $marketId) {
|
||||||
|
tradableInstrument {
|
||||||
|
instrument {
|
||||||
|
metadata {
|
||||||
|
tags
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
query PartyBalanceQuery($partyId: ID!) {
|
||||||
|
party(id: $partyId) {
|
||||||
|
accountsConnection {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
type
|
||||||
|
balance
|
||||||
|
asset {
|
||||||
|
id
|
||||||
|
symbol
|
||||||
|
name
|
||||||
|
decimals
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+51
@@ -0,0 +1,51 @@
|
|||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @generated
|
||||||
|
// This file was automatically generated and should not be edited.
|
||||||
|
|
||||||
|
// ====================================================
|
||||||
|
// GraphQL query operation: MarketTags
|
||||||
|
// ====================================================
|
||||||
|
|
||||||
|
export interface MarketTags_market_tradableInstrument_instrument_metadata {
|
||||||
|
__typename: "InstrumentMetadata";
|
||||||
|
/**
|
||||||
|
* An arbitrary list of tags to associated to associate to the Instrument (string list)
|
||||||
|
*/
|
||||||
|
tags: string[] | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MarketTags_market_tradableInstrument_instrument {
|
||||||
|
__typename: "Instrument";
|
||||||
|
/**
|
||||||
|
* Metadata for this instrument
|
||||||
|
*/
|
||||||
|
metadata: MarketTags_market_tradableInstrument_instrument_metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MarketTags_market_tradableInstrument {
|
||||||
|
__typename: "TradableInstrument";
|
||||||
|
/**
|
||||||
|
* An instance of, or reference to, a fully specified instrument.
|
||||||
|
*/
|
||||||
|
instrument: MarketTags_market_tradableInstrument_instrument;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MarketTags_market {
|
||||||
|
__typename: "Market";
|
||||||
|
/**
|
||||||
|
* An instance of, or reference to, a tradable instrument.
|
||||||
|
*/
|
||||||
|
tradableInstrument: MarketTags_market_tradableInstrument;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MarketTags {
|
||||||
|
/**
|
||||||
|
* An instrument that is trading on the Vega network
|
||||||
|
*/
|
||||||
|
market: MarketTags_market | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MarketTagsVariables {
|
||||||
|
marketId: string;
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import { Schema as Types } from '@vegaprotocol/types';
|
||||||
|
|
||||||
|
import { gql } from '@apollo/client';
|
||||||
|
import * as Apollo from '@apollo/client';
|
||||||
|
const defaultOptions = {} as const;
|
||||||
|
export type MarketTagsQueryVariables = Types.Exact<{
|
||||||
|
marketId: Types.Scalars['ID'];
|
||||||
|
}>;
|
||||||
|
|
||||||
|
|
||||||
|
export type MarketTagsQuery = { __typename?: 'Query', market?: { __typename?: 'Market', tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null } } } } | null };
|
||||||
|
|
||||||
|
|
||||||
|
export const MarketTagsDocument = gql`
|
||||||
|
query MarketTags($marketId: ID!) {
|
||||||
|
market(id: $marketId) {
|
||||||
|
tradableInstrument {
|
||||||
|
instrument {
|
||||||
|
metadata {
|
||||||
|
tags
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* __useMarketTagsQuery__
|
||||||
|
*
|
||||||
|
* To run a query within a React component, call `useMarketTagsQuery` and pass it any options that fit your needs.
|
||||||
|
* When your component renders, `useMarketTagsQuery` returns an object from Apollo Client that contains loading, error, and data properties
|
||||||
|
* you can use to render your UI.
|
||||||
|
*
|
||||||
|
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const { data, loading, error } = useMarketTagsQuery({
|
||||||
|
* variables: {
|
||||||
|
* marketId: // value for 'marketId'
|
||||||
|
* },
|
||||||
|
* });
|
||||||
|
*/
|
||||||
|
export function useMarketTagsQuery(baseOptions: Apollo.QueryHookOptions<MarketTagsQuery, MarketTagsQueryVariables>) {
|
||||||
|
const options = {...defaultOptions, ...baseOptions}
|
||||||
|
return Apollo.useQuery<MarketTagsQuery, MarketTagsQueryVariables>(MarketTagsDocument, options);
|
||||||
|
}
|
||||||
|
export function useMarketTagsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<MarketTagsQuery, MarketTagsQueryVariables>) {
|
||||||
|
const options = {...defaultOptions, ...baseOptions}
|
||||||
|
return Apollo.useLazyQuery<MarketTagsQuery, MarketTagsQueryVariables>(MarketTagsDocument, options);
|
||||||
|
}
|
||||||
|
export type MarketTagsQueryHookResult = ReturnType<typeof useMarketTagsQuery>;
|
||||||
|
export type MarketTagsLazyQueryHookResult = ReturnType<typeof useMarketTagsLazyQuery>;
|
||||||
|
export type MarketTagsQueryResult = Apollo.QueryResult<MarketTagsQuery, MarketTagsQueryVariables>;
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
import { Schema as Types } from '@vegaprotocol/types';
|
||||||
|
|
||||||
|
import { gql } from '@apollo/client';
|
||||||
|
import * as Apollo from '@apollo/client';
|
||||||
|
const defaultOptions = {} as const;
|
||||||
|
export type PartyBalanceQueryQueryVariables = Types.Exact<{
|
||||||
|
partyId: Types.Scalars['ID'];
|
||||||
|
}>;
|
||||||
|
|
||||||
|
|
||||||
|
export type PartyBalanceQueryQuery = { __typename?: 'Query', party?: { __typename?: 'Party', accountsConnection?: { __typename?: 'AccountsConnection', edges?: Array<{ __typename?: 'AccountEdge', node: { __typename?: 'AccountBalance', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number } } } | null> | null } | null } | null };
|
||||||
|
|
||||||
|
|
||||||
|
export const PartyBalanceQueryDocument = gql`
|
||||||
|
query PartyBalanceQuery($partyId: ID!) {
|
||||||
|
party(id: $partyId) {
|
||||||
|
accountsConnection {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
type
|
||||||
|
balance
|
||||||
|
asset {
|
||||||
|
id
|
||||||
|
symbol
|
||||||
|
name
|
||||||
|
decimals
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* __usePartyBalanceQueryQuery__
|
||||||
|
*
|
||||||
|
* To run a query within a React component, call `usePartyBalanceQueryQuery` and pass it any options that fit your needs.
|
||||||
|
* When your component renders, `usePartyBalanceQueryQuery` returns an object from Apollo Client that contains loading, error, and data properties
|
||||||
|
* you can use to render your UI.
|
||||||
|
*
|
||||||
|
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const { data, loading, error } = usePartyBalanceQueryQuery({
|
||||||
|
* variables: {
|
||||||
|
* partyId: // value for 'partyId'
|
||||||
|
* },
|
||||||
|
* });
|
||||||
|
*/
|
||||||
|
export function usePartyBalanceQueryQuery(baseOptions: Apollo.QueryHookOptions<PartyBalanceQueryQuery, PartyBalanceQueryQueryVariables>) {
|
||||||
|
const options = {...defaultOptions, ...baseOptions}
|
||||||
|
return Apollo.useQuery<PartyBalanceQueryQuery, PartyBalanceQueryQueryVariables>(PartyBalanceQueryDocument, options);
|
||||||
|
}
|
||||||
|
export function usePartyBalanceQueryLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<PartyBalanceQueryQuery, PartyBalanceQueryQueryVariables>) {
|
||||||
|
const options = {...defaultOptions, ...baseOptions}
|
||||||
|
return Apollo.useLazyQuery<PartyBalanceQueryQuery, PartyBalanceQueryQueryVariables>(PartyBalanceQueryDocument, options);
|
||||||
|
}
|
||||||
|
export type PartyBalanceQueryQueryHookResult = ReturnType<typeof usePartyBalanceQueryQuery>;
|
||||||
|
export type PartyBalanceQueryLazyQueryHookResult = ReturnType<typeof usePartyBalanceQueryLazyQuery>;
|
||||||
|
export type PartyBalanceQueryQueryResult = Apollo.QueryResult<PartyBalanceQueryQuery, PartyBalanceQueryQueryVariables>;
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import Video from '../header/video';
|
||||||
|
import Comet from '../header/comet';
|
||||||
|
import Star from '../icons/star';
|
||||||
|
|
||||||
|
const Baubles = () => {
|
||||||
|
return (
|
||||||
|
<aside className="relative right-0 top-0 h-[700px] hidden md:block md:w-1/2 overflow-hidden">
|
||||||
|
<div className="absolute top-[100px] w-[393px] left-[19%] h-[517px]">
|
||||||
|
<div className="absolute top-[82px] right-[34px] w-[100px] h-[100px] clip-path-rounded">
|
||||||
|
<Video />
|
||||||
|
</div>
|
||||||
|
<div className="absolute bottom-[100px] left-[59px] w-[200px] h-[200px] clip-path-rounded">
|
||||||
|
<Video />
|
||||||
|
</div>
|
||||||
|
<div className="absolute w-[118px] h-[85px] right-0 bottom-[178px]">
|
||||||
|
<Comet />
|
||||||
|
</div>
|
||||||
|
<div className="absolute w-[118px] h-[82px] left-0 bottom-[120px]">
|
||||||
|
<Comet />
|
||||||
|
</div>
|
||||||
|
<div className="absolute w-[20px] h-[20px] top-0 left-[49px]">
|
||||||
|
<Star />
|
||||||
|
</div>
|
||||||
|
<div className="absolute w-[20px] h-[20px] top-[89px] left-[184px]">
|
||||||
|
<Star />
|
||||||
|
</div>
|
||||||
|
<div className="absolute w-[10px] h-[10px] bottom-0 right-[137px]">
|
||||||
|
<Star />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Baubles;
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { render } from '@testing-library/react';
|
||||||
|
import type { AccountFragment } from '@vegaprotocol/deal-ticket';
|
||||||
|
import { DealTicketBalance } from './deal-ticket-balance';
|
||||||
|
import { Schema } from '@vegaprotocol/types';
|
||||||
|
import type { MarketDealTicketAsset } from '@vegaprotocol/market-list';
|
||||||
|
|
||||||
|
const tDAI: MarketDealTicketAsset = {
|
||||||
|
__typename: 'Asset',
|
||||||
|
id: '1',
|
||||||
|
symbol: 'tDAI',
|
||||||
|
name: 'TDAI',
|
||||||
|
decimals: 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
const accounts: AccountFragment[] = [
|
||||||
|
{
|
||||||
|
__typename: 'AccountBalance',
|
||||||
|
type: Schema.AccountType.ACCOUNT_TYPE_GENERAL,
|
||||||
|
balance: '1000000',
|
||||||
|
asset: tDAI,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
describe('DealTicketBalance', function () {
|
||||||
|
it('should render the balance', () => {
|
||||||
|
const { getByText, getByRole } = render(
|
||||||
|
<DealTicketBalance
|
||||||
|
settlementAsset={tDAI}
|
||||||
|
accounts={accounts}
|
||||||
|
isWalletConnected
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(getByRole('complementary')).toHaveAccessibleName('tDAI Balance');
|
||||||
|
expect(getByText('10,000.00')).toBeInTheDocument();
|
||||||
|
expect(getByText('tDAI')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should prompt to connect wallet', () => {
|
||||||
|
const { getByText } = render(
|
||||||
|
<DealTicketBalance
|
||||||
|
settlementAsset={tDAI}
|
||||||
|
accounts={accounts}
|
||||||
|
isWalletConnected={false}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
getByText('Please connect your Vega wallet to see your balance')
|
||||||
|
).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should display zero balance', () => {
|
||||||
|
const { getByText } = render(
|
||||||
|
<DealTicketBalance
|
||||||
|
settlementAsset={tDAI}
|
||||||
|
accounts={[]}
|
||||||
|
isWalletConnected={true}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(getByText('No tDAI left to trade')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
import classNames from 'classnames';
|
||||||
|
import { addDecimalsFormatNumber, t } from '@vegaprotocol/react-helpers';
|
||||||
|
import { Schema } from '@vegaprotocol/types';
|
||||||
|
import type { AccountFragment } from '@vegaprotocol/deal-ticket';
|
||||||
|
import type { MarketDealTicket } from '@vegaprotocol/market-list';
|
||||||
|
import { useSettlementAccount } from '@vegaprotocol/deal-ticket';
|
||||||
|
|
||||||
|
interface DealTicketBalanceProps {
|
||||||
|
settlementAsset: MarketDealTicket['tradableInstrument']['instrument']['product']['settlementAsset'];
|
||||||
|
accounts: AccountFragment[];
|
||||||
|
isWalletConnected: boolean;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DealTicketBalance = ({
|
||||||
|
settlementAsset,
|
||||||
|
accounts,
|
||||||
|
isWalletConnected,
|
||||||
|
className = '',
|
||||||
|
}: DealTicketBalanceProps) => {
|
||||||
|
const settlementAssetId = settlementAsset?.id;
|
||||||
|
const settlementAssetSymbol = settlementAsset?.symbol;
|
||||||
|
const settlementAccount = useSettlementAccount(
|
||||||
|
settlementAssetId,
|
||||||
|
accounts,
|
||||||
|
Schema.AccountType.ACCOUNT_TYPE_GENERAL
|
||||||
|
);
|
||||||
|
const formattedNumber =
|
||||||
|
settlementAccount?.balance &&
|
||||||
|
settlementAccount.asset.decimals &&
|
||||||
|
addDecimalsFormatNumber(
|
||||||
|
settlementAccount.balance,
|
||||||
|
settlementAccount.asset.decimals
|
||||||
|
);
|
||||||
|
|
||||||
|
const balance = (
|
||||||
|
<p className="text-blue text-lg font-semibold">
|
||||||
|
{settlementAccount
|
||||||
|
? t(`${formattedNumber}`)
|
||||||
|
: `No ${settlementAssetSymbol} left to trade`}
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
|
||||||
|
const connectWallet = (
|
||||||
|
<p>{t('Please connect your Vega wallet to see your balance')}</p>
|
||||||
|
);
|
||||||
|
|
||||||
|
const ariaLabel = t(`${settlementAssetSymbol} Balance`);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<aside
|
||||||
|
aria-label={ariaLabel}
|
||||||
|
className={classNames('text-right', className)}
|
||||||
|
>
|
||||||
|
<div className="inline-block">
|
||||||
|
<span className="text-blue">{settlementAssetSymbol}</span>
|
||||||
|
{isWalletConnected ? balance : connectWallet}
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
);
|
||||||
|
};
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user