diff --git a/.github/workflows/ci-cd-trigger.yml b/.github/workflows/ci-cd-trigger.yml index 23450bda5..fd11dc4de 100644 --- a/.github/workflows/ci-cd-trigger.yml +++ b/.github/workflows/ci-cd-trigger.yml @@ -105,19 +105,44 @@ jobs: affected="$(yarn nx print-affected --base=${{ env.NX_BASE }} --head=${{ env.NX_HEAD }} --select=projects)" echo -n "Affected projects: $affected" + branch_slug="$(echo ${{ github.head_ref || github.ref_name }} | sed -r s/[^a-zA-Z0-9]+/-/g | sed -r s/^-+\|-+$//g )" projects_e2e="" - if [[ $affected == *"governance"* ]]; then projects_e2e+='"governance-e2e" '; fi - if [[ $affected == *"trading"* ]]; then projects_e2e+='"trading-e2e" '; fi - if [[ $affected == *"explorer"* ]]; then projects_e2e+='"explorer-e2e" '; fi - if [[ -z "$projects_e2e" ]]; then projects_e2e+='"governance-e2e" "trading-e2e" "explorer-e2e" '; fi + 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 @@ -140,7 +165,9 @@ jobs: dist-check: runs-on: ubuntu-latest - needs: publish-dist + needs: + - publish-dist + - lint-test-build if: ${{ github.event_name == 'pull_request' }} name: '(CD) comment preview links' steps: @@ -151,22 +178,16 @@ jobs: issue-number: ${{ github.event.pull_request.number }} body-includes: Previews - - name: Inject slug/short variables - if: ${{ steps.fc.outputs.comment-id == 0 }} - uses: rlespinasse/github-slug-action@v4 - with: - prefix: CI_ - - name: Create comment - if: ${{ steps.fc.outputs.comment-id == 0 }} 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 - - explorer https://explorer.${{ env.CI_GITHUB_REF_NAME }}.vega.rocks - - trading https://trading.${{ env.CI_GITHUB_REF_NAME }}.vega.rocks - - governance https://governance.${{ env.CI_GITHUB_REF_NAME }}.vega.rocks + 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' diff --git a/Jenkinsfile b/Jenkinsfile index f1aebe8fd..c3b9be865 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,20 +1,2 @@ @Library('vega-shared-library') _ - -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' - } - } - } -} +runApprobation ignoreFailure: false, frontendBranch: env.BRANCH_NAME, type: 'frontend' diff --git a/README.md b/README.md index 93abf6294..7704343ad 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,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`. ```bash -export GRAPHQL_SCHEMA_PATH=https://api.n11.testnet.vega.xyz/graphql +export GRAPHQL_SCHEMA_PATH=https://api.n07.testnet.vega.xyz/graphql yarn nx run types:generate ``` diff --git a/apps/explorer-e2e/.env b/apps/explorer-e2e/.env index ec072e6c6..594c765fb 100644 --- a/apps/explorer-e2e/.env +++ b/apps/explorer-e2e/.env @@ -1,7 +1,7 @@ NX_CHAIN_EXPLORER_URL=https://explorer.vega.trading/.netlify/functions/chain-explorer-api NX_TENDERMINT_URL=http://localhost:26617 NX_TENDERMINT_WEBSOCKET_URL=wss://localhost:26617/websocket -NX_VEGA_URL=http://localhost:3028/query +NX_VEGA_URL=http://localhost:3008/graphql NX_VEGA_ENV=CUSTOM NX_VEGA_CONFIG_URL= @@ -18,4 +18,4 @@ NX_EXPLORER_PARTIES=1 NX_EXPLORER_VALIDATORS=1 CYPRESS_VEGA_WALLET_API_TOKEN= -CYPRESS_VEGA_URL=http://localhost:3028/query +CYPRESS_VEGA_URL=http://localhost:3008/graphql diff --git a/apps/explorer-e2e/.env.testnet b/apps/explorer-e2e/.env.testnet index 67801ebd5..c4bc9adf3 100644 --- a/apps/explorer-e2e/.env.testnet +++ b/apps/explorer-e2e/.env.testnet @@ -2,7 +2,7 @@ NX_CHAIN_EXPLORER_URL=https://explorer.vega.trading/.netlify/functions/chain-explorer-api NX_TENDERMINT_URL=https://tm.n07.testnet.vega.xyz/tm NX_TENDERMINT_WEBSOCKET_URL=wss://lb.testnet.vega.xyz/tm/websocket -NX_VEGA_URL=https://api.n11.testnet.vega.xyz/graphql +NX_VEGA_URL=https://api.n07.testnet.vega.xyz/graphql NX_VEGA_ENV=TESTNET NX_BLOCK_EXPLORER=https://be.testnet.vega.xyz/rest diff --git a/apps/explorer-e2e/cypress.config.js b/apps/explorer-e2e/cypress.config.js index 9b91a7946..1d936740e 100644 --- a/apps/explorer-e2e/cypress.config.js +++ b/apps/explorer-e2e/cypress.config.js @@ -25,7 +25,7 @@ module.exports = defineConfig({ }, env: { environment: 'CUSTOM', - networkQueryUrl: 'http://localhost:3028/query', + networkQueryUrl: 'http://localhost:3008/graphql', ethUrl: 'https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8', commitHash: 'dev', tsConfig: 'tsconfig.json', diff --git a/apps/explorer-e2e/src/integration/home.cy.js b/apps/explorer-e2e/src/integration/home.cy.js index 5f9342727..bc8f058dd 100644 --- a/apps/explorer-e2e/src/integration/home.cy.js +++ b/apps/explorer-e2e/src/integration/home.cy.js @@ -9,21 +9,22 @@ context('Home Page', function () { it('should show connected environment stats', function () { const statTitles = { 0: 'Status', - 1: 'Block height', - 2: 'Uptime', - 3: 'Total nodes', - 4: 'Total staked', - 5: 'Backlog', - 6: 'Trades / second', - 7: 'Orders / block', - 8: 'Orders / second', - 9: 'Transactions / block', - 10: 'Block time', - 11: 'Time', - 12: 'App', - 13: 'Tendermint', - 14: 'Up since', - 15: 'Chain ID', + 1: 'Epoch', + 2: 'Block height', + 3: 'Uptime', + 4: 'Total nodes', + 5: 'Total staked', + 6: 'Backlog', + 7: 'Trades / second', + 8: 'Orders / block', + 9: 'Orders / second', + 10: 'Transactions / block', + 11: 'Block time', + 12: 'Time', + 13: 'App', + 14: 'Tendermint', + 15: 'Up since', + 16: 'Chain ID', }; cy.get('[data-testid="stats-title"]') @@ -31,42 +32,13 @@ context('Home Page', function () { cy.wrap($list).should('contain.text', statTitles[index]); }) .then(($list) => { - cy.wrap($list).should('have.length', 16); + cy.wrap($list).should('have.length', 17); }); - - cy.get(statsValue).eq(0).should('contain.text', 'CONNECTED'); - cy.get(statsValue).eq(1).should('not.be.empty'); - cy.get(statsValue) - .eq(2) - .invoke('text') - .should('match', /\d+d \d+h \d+m \d+s/i); - cy.get(statsValue).eq(3).should('contain.text', '2'); - cy.get(statsValue) - .eq(4) - .invoke('text') - .should('match', /\d+\.\d\d(?!\d)/i); - cy.get(statsValue).eq(5).should('contain.text', '0'); - cy.get(statsValue).eq(6).should('contain.text', '0'); - cy.get(statsValue).eq(7).should('contain.text', '0'); - cy.get(statsValue).eq(8).should('contain.text', '0'); - cy.get(statsValue).eq(9).should('not.be.empty'); - cy.get(statsValue).eq(10).should('not.be.empty'); - cy.get(statsValue).eq(11).should('not.be.empty'); - cy.get(statsValue) - .eq(12) - .invoke('text') - .should('match', /v\d+\.\d+\.\d+/i); - cy.get(statsValue) - .eq(13) - .invoke('text') - .should('match', /\d+\.\d+\.\d+/i); - cy.get(statsValue).eq(14).should('not.be.empty'); - cy.get(statsValue).eq(15).should('not.be.empty'); }); it('Block height should be updating', function () { cy.get(statsValue) - .eq(1) + .eq(2) .invoke('text') .then((blockHeightTxt) => { cy.get(statsValue) diff --git a/apps/explorer-e2e/src/integration/node-switcher.cy.js b/apps/explorer-e2e/src/integration/node-switcher.cy.js index 965d5fce5..c61601ddf 100644 --- a/apps/explorer-e2e/src/integration/node-switcher.cy.js +++ b/apps/explorer-e2e/src/integration/node-switcher.cy.js @@ -6,7 +6,7 @@ const customNodeBtn = 'custom-node'; context.skip('Node switcher', { tags: '@regression' }, function () { beforeEach('visit home page', function () { cy.intercept('GET', 'https://static.vega.xyz/assets/capsule-network.json', { - hosts: ['http://localhost:3028/query'], + hosts: ['http://localhost:3008/graphql'], }).as('nodeData'); cy.visit('/'); cy.wait('@nodeData'); diff --git a/apps/explorer-e2e/src/integration/parties.cy.js b/apps/explorer-e2e/src/integration/parties.cy.js index db63026cd..7ff8b5a57 100644 --- a/apps/explorer-e2e/src/integration/parties.cy.js +++ b/apps/explorer-e2e/src/integration/parties.cy.js @@ -219,7 +219,7 @@ context.skip('Parties page', { tags: '@regression' }, function () { balance type asset {id symbol decimals}}}}}}}}'; cy.request({ method: 'POST', - url: `http://localhost:3028/query`, + url: `http://localhost:3008/graphql`, body: { query: mutation, }, diff --git a/apps/explorer/src/app/components/links/asset-link/asset-link.tsx b/apps/explorer/src/app/components/links/asset-link/asset-link.tsx index 232296b2d..bfaf87def 100644 --- a/apps/explorer/src/app/components/links/asset-link/asset-link.tsx +++ b/apps/explorer/src/app/components/links/asset-link/asset-link.tsx @@ -43,7 +43,7 @@ export const AssetLink = ({ if (asDialog) { open(assetId, e.target as HTMLElement); } else { - navigate(`${Routes.ASSETS}/${asset?.id}`); + navigate(`/${Routes.ASSETS}/${asset?.id}`); } }} {...props} diff --git a/apps/explorer/src/app/components/order-details/deterministic-order-details.tsx b/apps/explorer/src/app/components/order-details/deterministic-order-details.tsx index 7c0dce1f3..2e3b51458 100644 --- a/apps/explorer/src/app/components/order-details/deterministic-order-details.tsx +++ b/apps/explorer/src/app/components/order-details/deterministic-order-details.tsx @@ -9,7 +9,7 @@ import SizeInMarket from '../size-in-market/size-in-market'; export interface DeterministicOrderDetailsProps { id: string; // Version to fetch, with 0 being 'latest' and 1 being 'first'. Defaults to 0 - version?: number; + version?: number | null; } export const wrapperClasses = @@ -28,7 +28,7 @@ export const wrapperClasses = */ const DeterministicOrderDetails = ({ id, - version = 0, + version = null, }: DeterministicOrderDetailsProps) => { const { data, error } = useExplorerDeterministicOrderQuery({ variables: { orderId: id, version }, diff --git a/apps/explorer/src/app/routes/parties/id/components/party-accounts.tsx b/apps/explorer/src/app/routes/parties/id/components/party-accounts.tsx index 5259a7410..1b2c6dc32 100644 --- a/apps/explorer/src/app/routes/parties/id/components/party-accounts.tsx +++ b/apps/explorer/src/app/routes/parties/id/components/party-accounts.tsx @@ -71,7 +71,7 @@ export const PartyAccounts = ({ accounts }: PartyAccountsProps) => { /> - + ); diff --git a/apps/governance-e2e/.env b/apps/governance-e2e/.env index 847bb5bb4..4187dafaa 100644 --- a/apps/governance-e2e/.env +++ b/apps/governance-e2e/.env @@ -5,7 +5,7 @@ NX_ETHERSCAN_URL=https://sepolia.etherscan.io NX_FAIRGROUND=false NX_VEGA_NETWORKS={} -NX_VEGA_URL=http://localhost:3028/query +NX_VEGA_URL=http://localhost:3008/graphql NX_ETHEREUM_CHAIN_ID=1440 NX_ETH_URL_CONNECT=1 NX_ETH_WALLET_MNEMONIC=ozone access unlock valid olympic save include omit supply green clown session @@ -20,7 +20,7 @@ NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72 #Test configuration variables CYPRESS_FAIRGROUND=false -CYPRESS_VEGA_URL=http://localhost:3028/query +CYPRESS_VEGA_URL=http://localhost:3008/graphql CYPRESS_ETH_WALLET_MNEMONIC=ozone access unlock valid olympic save include omit supply green clown session CYPRESS_ETHEREUM_PROVIDER_URL=http://localhost:8545 CYPRESS_EXPLORER_URL=https://explorer.fairground.wtf @@ -31,6 +31,5 @@ CYPRESS_VEGA_ENV=CUSTOM CYPRESS_VEGA_PUBLIC_KEY=02eceaba4df2bef76ea10caf728d8a099a2aa846cced25737cccaa9812342f65 CYPRESS_VEGA_PUBLIC_KEY2=7f9cf07d3a9905b1a61a1069f7a758855da428bc0f4a97de87f48644bfc25535 CYPRESS_VEGA_TOKEN_URL=https://token.fairground.wtf -CYPRESS_VEGA_URL=http://localhost:3028/query CYPRESS_VEGA_WALLET_URL=http://localhost:1789 CYPRESS_VEGA_WALLET_API_TOKEN= diff --git a/apps/governance-e2e/.env.testnet b/apps/governance-e2e/.env.testnet index 631ab9296..218bc4e94 100644 --- a/apps/governance-e2e/.env.testnet +++ b/apps/governance-e2e/.env.testnet @@ -1,5 +1,5 @@ # App configuration variables NX_VEGA_ENV=TESTNET -NX_VEGA_URL=https://api.n11.testnet.vega.xyz/graphql +NX_VEGA_URL=https://api.n07.testnet.vega.xyz/graphql NX_ETHEREUM_PROVIDER_URL=https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8 NX_ETHERSCAN_URL=https://sepolia.etherscan.io diff --git a/apps/governance-e2e/src/integration/flow/proposal-forms.cy.ts b/apps/governance-e2e/src/integration/flow/proposal-forms.cy.ts index 8edb77c66..557f6c31e 100644 --- a/apps/governance-e2e/src/integration/flow/proposal-forms.cy.ts +++ b/apps/governance-e2e/src/integration/flow/proposal-forms.cy.ts @@ -50,6 +50,8 @@ const liquidityVoteStatus = 'liquidity-votes-status'; const tokenVoteStatus = 'token-votes-status'; const proposalTermsSection = 'proposal'; const vegaWalletPublicKey = Cypress.env('vegaWalletPublicKey'); +const fUSDCId = + '816af99af60d684502a40824758f6b5377e6af48e50a9ee8ef478ecb879ea8bc'; const epochTimeout = Cypress.env('epochTimeout'); const proposalTimeout = { timeout: 14000 }; @@ -264,7 +266,7 @@ context( it('Unable to submit update market proposal without minimum amount of tokens', function () { vegaWalletTeardown(); vegaWalletFaucetAssetsWithoutCheck( - 'fUSDC', + fUSDCId, '1000000', vegaWalletPublicKey ); @@ -290,7 +292,7 @@ context( // 3001-VOTE-092 3004-PMAC-001 it('Able to submit update market proposal and vote for proposal', function () { vegaWalletFaucetAssetsWithoutCheck( - 'fUSDC', + fUSDCId, '1000000', vegaWalletPublicKey ); diff --git a/apps/governance-e2e/src/integration/flow/staking-flow.cy.ts b/apps/governance-e2e/src/integration/flow/staking-flow.cy.ts index f811276fc..7722c6c8d 100644 --- a/apps/governance-e2e/src/integration/flow/staking-flow.cy.ts +++ b/apps/governance-e2e/src/integration/flow/staking-flow.cy.ts @@ -55,7 +55,6 @@ context( function () { // 2001-STKE-002, 2001-STKE-032 before('visit staking tab and connect vega wallet', function () { - cy.clearAllLocalStorage(); cy.visit('/'); ethereumWalletConnect(); // this is a workaround for #2422 which can be removed once issue is resolved @@ -67,6 +66,7 @@ context( beforeEach( 'teardown wallet & drill into a specific validator', function () { + cy.clearAllLocalStorage(); cy.reload(); waitForSpinner(); cy.connectVegaWallet(); diff --git a/apps/governance-e2e/src/integration/view/home.cy.ts b/apps/governance-e2e/src/integration/view/home.cy.ts index 2890c7f23..8c99a9313 100644 --- a/apps/governance-e2e/src/integration/view/home.cy.ts +++ b/apps/governance-e2e/src/integration/view/home.cy.ts @@ -131,7 +131,7 @@ context('Home Page - verify elements on page', { tags: '@smoke' }, function () { .within(() => { cy.get('span') .first() - .should('have.text', 'http://localhost:3028/query'); + .should('have.text', 'http://localhost:3008/graphql'); cy.getByTestId('link').should('exist'); }); }); diff --git a/apps/governance-e2e/src/integration/view/pubkey-view.cy.ts b/apps/governance-e2e/src/integration/view/pubkey-view.cy.ts index 8727ab164..b4cf0056d 100644 --- a/apps/governance-e2e/src/integration/view/pubkey-view.cy.ts +++ b/apps/governance-e2e/src/integration/view/pubkey-view.cy.ts @@ -17,10 +17,15 @@ const banner = 'view-banner'; context('View functionality with public key', { tags: '@smoke' }, function () { before('send asset to wallet', function () { - vegaWalletFaucetAssetsWithoutCheck('fUSDC', '1000000', vegaWalletPubKey); + vegaWalletFaucetAssetsWithoutCheck( + '816af99af60d684502a40824758f6b5377e6af48e50a9ee8ef478ecb879ea8bc', + '1000000', + vegaWalletPubKey + ); }); beforeEach('visit home page', function () { + cy.clearLocalStorage(); cy.visit('/'); waitForSpinner(); cy.connectPublicKey(vegaWalletPubKey); diff --git a/apps/governance-e2e/src/integration/view/rewards.cy.ts b/apps/governance-e2e/src/integration/view/rewards.cy.ts index 856caeae3..f5e4fb194 100644 --- a/apps/governance-e2e/src/integration/view/rewards.cy.ts +++ b/apps/governance-e2e/src/integration/view/rewards.cy.ts @@ -13,6 +13,7 @@ context( { tags: '@regression' }, function () { before('navigate to rewards page', function () { + cy.clearLocalStorage(); cy.visit('/'); navigateTo(navigation.rewards); }); diff --git a/apps/governance-e2e/src/integration/view/wallet-vega.cy.ts b/apps/governance-e2e/src/integration/view/wallet-vega.cy.ts index 782a194a2..f43b77d33 100644 --- a/apps/governance-e2e/src/integration/view/wallet-vega.cy.ts +++ b/apps/governance-e2e/src/integration/view/wallet-vega.cy.ts @@ -282,26 +282,30 @@ context( describe('Vega wallet with assets', function () { const assets = [ { - id: 'fUSDC', + id: '816af99af60d684502a40824758f6b5377e6af48e50a9ee8ef478ecb879ea8bc', name: 'USDC (fake)', + symbol: 'fUSDC', amount: '1000000', expectedAmount: '10.00', }, { - id: 'fDAI', + id: '8566db7257222b5b7ef2886394ad28b938b28680a54a169bbc795027b89d6665', name: 'DAI (fake)', + symbol: 'fDAI', amount: '200000', expectedAmount: '2.00', }, { - id: 'fBTC', + id: '73174a6fb1d5802ba0ac7bd7ab79e0a3a4837b262de0a4e80815a55442692bd0', name: 'BTC (fake)', + symbol: 'fBTC', amount: '600000', expectedAmount: '6.00', }, { - id: 'fEURO', + id: 'e02d4c15d790d1d2dffaf2dcd1cf06a1fe656656cf4ed18c8ce99f9e83643567', name: 'EURO (fake)', + symbol: 'fEURO', amount: '800000', expectedAmount: '8.00', }, @@ -322,15 +326,15 @@ context( }); }); - for (const { id, name, expectedAmount } of assets) { - it(`should see ${id} within vega wallet`, () => { + for (const { name, symbol, expectedAmount } of assets) { + it(`should see ${name} within vega wallet`, () => { cy.get(walletContainer).within(() => { cy.get(vegaWalletCurrencyTitle) - .contains(id, txTimeout) + .contains(name, txTimeout) .should('be.visible'); cy.get(vegaWalletCurrencyTitle) - .contains(id) + .contains(name) .parent() .siblings() .invoke('text') @@ -338,9 +342,9 @@ context( .should('be.gte', parseFloat(expectedAmount)); cy.get(vegaWalletCurrencyTitle) - .contains(id) + .contains(name) .parent() - .contains(name); + .contains(symbol); }); }); } diff --git a/apps/governance-e2e/src/support/staking.functions.ts b/apps/governance-e2e/src/support/staking.functions.ts index bb85b57b4..15a427126 100644 --- a/apps/governance-e2e/src/support/staking.functions.ts +++ b/apps/governance-e2e/src/support/staking.functions.ts @@ -54,7 +54,7 @@ export function stakingValidatorPageRemoveStake(stake: string) { .and('contain', `Remove ${stake} $VEGA tokens at the end of epoch`) .and('be.visible') .click(); - cy.contains('been removed from validator').should('be.visible'); + cy.contains('been removed from validator', txTimeout).should('be.visible'); closeDialog(); } @@ -185,7 +185,7 @@ export function validateValidatorListTotalStakeAndShare( ) { cy.contains('Loading...', epochTimeout).should('not.exist'); waitForBeginningOfEpoch(); - cy.get(`[row-id="${positionOnList}"]:visible`) + cy.get(`[row-id="${positionOnList}"]`) .eq(1) .within(() => { cy.getByTestId(stakeValidatorListTotalStake, epochTimeout).should( @@ -221,12 +221,12 @@ export function ensureSpecifiedUnstakedTokensAreAssociated( } export function closeStakingDialog() { - cy.get('[data-testid="dialog-title"]:visible').should( + cy.getByTestId('dialog-title').should( 'contain.text', 'At the beginning of the next epoch' ); - cy.get('[data-testid="dialog-content"]:visible') - .first() + cy.getByTestId('dialog-content') + .last() .within(() => { cy.get('a').should('have.text', 'Back to Staking').click(); }); diff --git a/apps/governance-e2e/src/support/wallet-teardown.functions.ts b/apps/governance-e2e/src/support/wallet-teardown.functions.ts index 7d1366e83..1560c2233 100644 --- a/apps/governance-e2e/src/support/wallet-teardown.functions.ts +++ b/apps/governance-e2e/src/support/wallet-teardown.functions.ts @@ -9,7 +9,7 @@ import { import { ethers, Wallet } from 'ethers'; const associatedAmountInWallet = '[data-testid="associated-amount"]:visible'; -const vegaWalletContainer = 'aside [data-testid="vega-wallet"]:visible'; +const vegaWalletContainer = 'aside [data-testid="vega-wallet"]'; const vegaWalletMnemonic = Cypress.env('vegaWalletMnemonic'); const vegaWalletPubKey = Cypress.env('vegaWalletPublicKey'); const vegaTokenContractAddress = Cypress.env('vegaTokenContractAddress'); @@ -105,25 +105,24 @@ async function vegaWalletTeardownStaking(stakingBridgeContract: StakingBridge) { { timeout: transactionTimeout, log: false } ).then((stakeBalance) => { if (Number(stakeBalance) != 0) { - cy.get(vegaWalletContainer).within(() => { - cy.getByTestId('currency-value') - .invoke('text') - .then(($associatedAmount) => { - cy.wrap( - stakingBridgeContract.remove_stake( - String(stakeBalance), - vegaWalletPubKey - ), - { timeout: transactionTimeout, log: false } - ); - cy.get("[data-testid='currency-value']") - .first() - .invoke('text', { + cy.get('[data-testid="vega-wallet-balance-unstaked"]:visible').within( + () => { + cy.get(associatedAmountInWallet) + .invoke('text') + .then(($walletAmount) => { + cy.wrap( + stakingBridgeContract.remove_stake( + String(stakeBalance), + vegaWalletPubKey + ), + { timeout: transactionTimeout, log: false } + ); + cy.get(associatedAmountInWallet, { timeout: transactionTimeout, - }) - .should('not.eq', $associatedAmount); - }); - }); + }).should('not.have.text', $walletAmount); + }); + } + ); } }); } diff --git a/apps/governance/.env.capsule b/apps/governance/.env.capsule index d5c67898a..446dabc96 100644 --- a/apps/governance/.env.capsule +++ b/apps/governance/.env.capsule @@ -8,7 +8,7 @@ NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/test/announcements.json NX_VEGA_CONFIG_URL='' -NX_VEGA_URL=http://localhost:3028/query +NX_VEGA_URL=http://localhost:3008/graphql NX_ETHEREUM_CHAIN_ID=1440 NX_ETH_URL_CONNECT=1 NX_ETH_WALLET_MNEMONIC=ozone access unlock valid olympic save include omit supply green clown session diff --git a/apps/governance/.env.testnet b/apps/governance/.env.testnet index d3215abfd..4e7d865c5 100644 --- a/apps/governance/.env.testnet +++ b/apps/governance/.env.testnet @@ -1,7 +1,7 @@ # App configuration variables NX_VEGA_ENV=TESTNET NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks-internal/main/fairground/vegawallet-fairground.toml -NX_VEGA_URL=https://api.n08.testnet.vega.xyz/graphql +NX_VEGA_URL=https://api.n07.testnet.vega.xyz/graphql NX_VEGA_NETWORKS='{"DEVNET":"https://dev.token.vega.xyz","STAGNET3":"https://stagnet3.token.vega.xyz","TESTNET":"https://token.fairground.wtf","MAINNET":"https://token.vega.xyz"}' NX_ETHEREUM_PROVIDER_URL=https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8 NX_ETHERSCAN_URL=https://sepolia.etherscan.io diff --git a/apps/governance/src/contexts/contracts/contracts-provider.tsx b/apps/governance/src/contexts/contracts/contracts-provider.tsx index 7737a4248..f4a4c470f 100644 --- a/apps/governance/src/contexts/contracts/contracts-provider.tsx +++ b/apps/governance/src/contexts/contracts/contracts-provider.tsx @@ -14,13 +14,17 @@ import { ContractsContext } from './contracts-context'; import { createDefaultProvider } from '../../lib/web3-connectors'; import { useEthereumConfig } from '@vegaprotocol/web3'; import { useEnvironment } from '@vegaprotocol/environment'; -import { ENV } from '../../config/env'; +import { ENV } from '../../config'; /** * Provides Vega Ethereum contract instances to its children. */ export const ContractsProvider = ({ children }: { children: JSX.Element }) => { - const { provider: activeProvider, account } = useWeb3React(); + const { + provider: activeProvider, + account, + chainId: activeChainId, + } = useWeb3React(); const { config } = useEthereumConfig(); const { VEGA_ENV, ETHEREUM_PROVIDER_URL } = useEnvironment(); const [contracts, setContracts] = @@ -39,7 +43,11 @@ export const ContractsProvider = ({ children }: { children: JSX.Element }) => { ETHEREUM_PROVIDER_URL, Number(config.chain_id) ); - const provider = activeProvider ? activeProvider : defaultProvider; + + const provider = + activeProvider && activeChainId === Number(config.chain_id) + ? activeProvider + : defaultProvider; if ( account && @@ -84,7 +92,14 @@ export const ContractsProvider = ({ children }: { children: JSX.Element }) => { // TODO: hacky quick fix for release to prevent race condition, find a better fix for this. cancelled = true; }; - }, [activeProvider, account, config, VEGA_ENV, ETHEREUM_PROVIDER_URL]); + }, [ + activeProvider, + activeChainId, + account, + config, + VEGA_ENV, + ETHEREUM_PROVIDER_URL, + ]); if (!contracts) { return ( diff --git a/apps/liquidity-provision-dashboard/.env b/apps/liquidity-provision-dashboard/.env index 6573e8bbc..fa7e64896 100644 --- a/apps/liquidity-provision-dashboard/.env +++ b/apps/liquidity-provision-dashboard/.env @@ -19,7 +19,7 @@ NX_DEPLOY_URL=$DEPLOY_URL NX_DEPLOY_PRIME_URL=$DEPLOY_PRIME_URL NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks-internal/main/fairground/vegawallet-fairground.toml NX_VEGA_ENV = 'TESTNET' -NX_VEGA_URL="https://api.n11.testnet.vega.xyz/graphql" +NX_VEGA_URL="https://api.n07.testnet.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 diff --git a/apps/liquidity-provision-dashboard/.env.capsule b/apps/liquidity-provision-dashboard/.env.capsule index 03bcc702c..6bc5b34a1 100644 --- a/apps/liquidity-provision-dashboard/.env.capsule +++ b/apps/liquidity-provision-dashboard/.env.capsule @@ -1,3 +1,3 @@ # App configuration variables -NX_VEGA_URL=http://localhost:3028/query +NX_VEGA_URL=http://localhost:3008/graphql NX_VEGA_ENV=LOCAL diff --git a/apps/liquidity-provision-dashboard/.env.testnet b/apps/liquidity-provision-dashboard/.env.testnet index fded68ffa..49e8eec13 100644 --- a/apps/liquidity-provision-dashboard/.env.testnet +++ b/apps/liquidity-provision-dashboard/.env.testnet @@ -1,6 +1,6 @@ # App configuration variables NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks-internal/main/fairground/vegawallet-fairground.toml -NX_VEGA_URL=https://api.n11.testnet.vega.xyz/graphql +NX_VEGA_URL=https://api.n07.testnet.vega.xyz/graphql NX_VEGA_ENV=TESTNET NX_VEGA_NETWORKS={\"MAINNET\":\"https://alpha.console.vega.xyz\",\"TESTNET\":\"https://console.fairground.wtf\"} NX_ETHEREUM_PROVIDER_URL=https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8 diff --git a/apps/multisig-signer/.env.testnet b/apps/multisig-signer/.env.testnet index de6b3a29f..34b22daf8 100644 --- a/apps/multisig-signer/.env.testnet +++ b/apps/multisig-signer/.env.testnet @@ -1,5 +1,5 @@ # App configuration variables NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks-internal/main/fairground/vegawallet-fairground.toml -NX_VEGA_URL=https://api.n09.testnet.vega.xyz/graphql +NX_VEGA_URL=https://api.n07.testnet.vega.xyz/graphql NX_VEGA_NETWORKS='{"TESTNET":"https://multisig-signer.fairground.wtf","MAINNET":"https://multisig-signer.vega.xyz"}' NX_VEGA_ENV=TESTNET diff --git a/apps/static/src/assets/mainnet-network.json b/apps/static/src/assets/mainnet-network.json index edc8eb86b..a804553f4 100644 --- a/apps/static/src/assets/mainnet-network.json +++ b/apps/static/src/assets/mainnet-network.json @@ -1,17 +1,3 @@ { - "hosts": [ - "https://vega-data-graphql.chorus.one/query", - "https://vega.xprv.io/datanode/query", - "http://nala.mainnet.vega.community:3008/query", - "http://commodum.mainnet.vega.community:3008/query", - "http://lovali.mainnet.vega.community:3008/query", - "http://b-harvest.mainnet.vega.community:3008/query", - "http://staking-facilities.mainnet.vega.community:3008/query", - "http://figment.mainnet.vega.community:3008/query", - "http://nodes-guru.mainnet.vega.community:3008/query", - "http://p2p.mainnet.vega.community:3008/query", - "http://rockaway.mainnet.vega.community:3008/query", - "http://greenfield-one.mainnet.vega.community:3008/query", - "http://ryabina.mainnet.vega.community:3008/query" - ] + "hosts": ["https://vega.xprv.io/datanode/query"] } diff --git a/apps/static/src/assets/mainnet-tranches.json b/apps/static/src/assets/mainnet-tranches.json index bbb3a2584..dc114cbf7 100644 --- a/apps/static/src/assets/mainnet-tranches.json +++ b/apps/static/src/assets/mainnet-tranches.json @@ -36,9 +36,9 @@ "tranche_id": 56, "tranche_start": "2023-04-20T00:00:00.000Z", "tranche_end": "2023-05-20T00:00:00.000Z", - "total_added": "17896.625", - "total_removed": "202.093666077975", - "locked_amount": "14463.5524347029308835625", + "total_added": "19242.125", + "total_removed": "537.22112238579", + "locked_amount": "13786.0174867862645531375", "deposits": [ { "amount": "188", @@ -60,6 +60,16 @@ "user": "0x33Ce1D9E53AFb7367E34749517C086405a651a95", "tx": "0xa717d720df95537c07c8f24591d49fb35d2b2d935ec25da4b23a0819a78b499d" }, + { + "amount": "914.25", + "user": "0xDd7a98557586ce21f770662319C2047C5a3bD605", + "tx": "0xa4b11dd967e1726d3f10d1a8330d3cac2338a93b3f8ea5db2f58a6c653ff8a1f" + }, + { + "amount": "431.25", + "user": "0x9573BDF7FfC5519912d293e4D1f750eab2E471E7", + "tx": "0xcad28318a71f2c8c6f4d505b8c2029c44aa83a249c5428e97110d9c0071ab9e3" + }, { "amount": "241.5", "user": "0xBf1AaB792D729fA125e6D7122D4b916a1E1C44B1", @@ -206,6 +216,21 @@ "amount": "202.093666077975", "user": "0x1447Efc62d5077d7AbB20492dF831Dd6c9Eb1756", "tx": "0x300c18b4220d3bc357f054792cb65f05d4005912bf8e5d9580b5b830cc3c0845" + }, + { + "amount": "195.89040769089", + "user": "0xDd7a98557586ce21f770662319C2047C5a3bD605", + "tx": "0x338ca1f2a725add8aa5328efa43ac7cb1e91c35bf01a2312431c0dbb57137387" + }, + { + "amount": "96.6447222258", + "user": "0x1447Efc62d5077d7AbB20492dF831Dd6c9Eb1756", + "tx": "0x13b160a21d48eab98cc304bbb46cd675da08afbf6e0ad261c67c10ba34dc4d74" + }, + { + "amount": "42.592326391125", + "user": "0x1447Efc62d5077d7AbB20492dF831Dd6c9Eb1756", + "tx": "0x5f544a659ae728cc7b1a29dcda14740425cadf1f47aa74bae92bf2ade3c8093d" } ], "users": [ @@ -255,11 +280,23 @@ "user": "0x1447Efc62d5077d7AbB20492dF831Dd6c9Eb1756", "tranche_id": 56, "tx": "0x300c18b4220d3bc357f054792cb65f05d4005912bf8e5d9580b5b830cc3c0845" + }, + { + "amount": "96.6447222258", + "user": "0x1447Efc62d5077d7AbB20492dF831Dd6c9Eb1756", + "tranche_id": 56, + "tx": "0x13b160a21d48eab98cc304bbb46cd675da08afbf6e0ad261c67c10ba34dc4d74" + }, + { + "amount": "42.592326391125", + "user": "0x1447Efc62d5077d7AbB20492dF831Dd6c9Eb1756", + "tranche_id": 56, + "tx": "0x5f544a659ae728cc7b1a29dcda14740425cadf1f47aa74bae92bf2ade3c8093d" } ], "total_tokens": "1207.5", - "withdrawn_tokens": "202.093666077975", - "remaining_tokens": "1005.406333922025" + "withdrawn_tokens": "341.3307146949", + "remaining_tokens": "866.1692853051" }, { "address": "0x33Ce1D9E53AFb7367E34749517C086405a651a95", @@ -276,6 +313,43 @@ "withdrawn_tokens": "0", "remaining_tokens": "690" }, + { + "address": "0xDd7a98557586ce21f770662319C2047C5a3bD605", + "deposits": [ + { + "amount": "914.25", + "user": "0xDd7a98557586ce21f770662319C2047C5a3bD605", + "tranche_id": 56, + "tx": "0xa4b11dd967e1726d3f10d1a8330d3cac2338a93b3f8ea5db2f58a6c653ff8a1f" + } + ], + "withdrawals": [ + { + "amount": "195.89040769089", + "user": "0xDd7a98557586ce21f770662319C2047C5a3bD605", + "tranche_id": 56, + "tx": "0x338ca1f2a725add8aa5328efa43ac7cb1e91c35bf01a2312431c0dbb57137387" + } + ], + "total_tokens": "914.25", + "withdrawn_tokens": "195.89040769089", + "remaining_tokens": "718.35959230911" + }, + { + "address": "0x9573BDF7FfC5519912d293e4D1f750eab2E471E7", + "deposits": [ + { + "amount": "431.25", + "user": "0x9573BDF7FfC5519912d293e4D1f750eab2E471E7", + "tranche_id": 56, + "tx": "0xcad28318a71f2c8c6f4d505b8c2029c44aa83a249c5428e97110d9c0071ab9e3" + } + ], + "withdrawals": [], + "total_tokens": "431.25", + "withdrawn_tokens": "0", + "remaining_tokens": "431.25" + }, { "address": "0xBf1AaB792D729fA125e6D7122D4b916a1E1C44B1", "deposits": [ @@ -759,7 +833,7 @@ "tranche_end": "2023-05-06T00:00:00.000Z", "total_added": "8976", "total_removed": "596.64743517951", - "locked_amount": "3065.3524814814810216", + "locked_amount": "2242.0538148148150032", "deposits": [ { "amount": "111", @@ -1531,7 +1605,7 @@ "tranche_start": "2023-03-06T00:00:00.000Z", "tranche_end": "2023-04-06T00:00:00.000Z", "total_added": "14099", - "total_removed": "3112.49002352036", + "total_removed": "3142.49002352036", "locked_amount": "0", "deposits": [ { @@ -2296,6 +2370,11 @@ } ], "withdrawals": [ + { + "amount": "30", + "user": "0xBe9F912Ad481C61B653463E8F1D2b2b310D49861", + "tx": "0x191a1901917ada560c9c30efd3d24c0ec116b9dc131a6966cc67ad7e3701df3b" + }, { "amount": "30", "user": "0x8499411Bff99ddE9A02903008F917EEa0E27B42A", @@ -2530,10 +2609,17 @@ "tx": "0x20d505a766d3d8e376509ed8003a5b9f35fd0524f0979a5a57c7d3714d01d3e5" } ], - "withdrawals": [], + "withdrawals": [ + { + "amount": "30", + "user": "0xBe9F912Ad481C61B653463E8F1D2b2b310D49861", + "tranche_id": 53, + "tx": "0x191a1901917ada560c9c30efd3d24c0ec116b9dc131a6966cc67ad7e3701df3b" + } + ], "total_tokens": "30", - "withdrawn_tokens": "0", - "remaining_tokens": "30" + "withdrawn_tokens": "30", + "remaining_tokens": "0" }, { "address": "0xA9821681fEF27Ed817DF77E476DDDAf0aDac4443", @@ -4542,7 +4628,7 @@ "tranche_end": "2023-12-05T00:00:00.000Z", "total_added": "86666.297", "total_removed": "0", - "locked_amount": "53007.7575805889739871627", + "locked_amount": "52354.396592703131652297", "deposits": [ { "amount": "86666.297", @@ -4608,7 +4694,7 @@ "tranche_end": "2023-06-01T00:00:00.000Z", "total_added": "2500", "total_removed": "0", - "locked_amount": "497.873104904355", + "locked_amount": "460.07548585673575", "deposits": [ { "amount": "2500", @@ -4729,7 +4815,7 @@ "tranche_end": "2023-09-01T00:00:00.000Z", "total_added": "17500", "total_removed": "0", - "locked_amount": "12197.23008504428225", + "locked_amount": "11935.52265750805275", "deposits": [ { "amount": "12500", @@ -4995,8 +5081,8 @@ "tranche_start": "2023-02-01T00:00:00.000Z", "tranche_end": "2023-08-01T00:00:00.000Z", "total_added": "37500", - "total_removed": "12704.026146825", - "locked_amount": "20147.47832259054375", + "total_removed": "17678.335539225", + "locked_amount": "19577.381637507675", "deposits": [ { "amount": "7500", @@ -5015,6 +5101,11 @@ "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", "tx": "0x4dc6eefb43f5b1704894582aa926f0c6ecd94550ac354b7d5b5f49b0f17261fd" }, + { + "amount": "4974.3093924", + "user": "0x0B4e6fcE839B01ef43DA6F890FAC7B1Afb004600", + "tx": "0xfce75d8b6bf0d20cbdb1ef29cfabcae4f4504c30b30ca166b4e66d37f7f04339" + }, { "amount": "126.30064455", "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", @@ -5357,6 +5448,12 @@ } ], "withdrawals": [ + { + "amount": "4974.3093924", + "user": "0x0B4e6fcE839B01ef43DA6F890FAC7B1Afb004600", + "tranche_id": 34, + "tx": "0xfce75d8b6bf0d20cbdb1ef29cfabcae4f4504c30b30ca166b4e66d37f7f04339" + }, { "amount": "6960.3360957", "user": "0x0B4e6fcE839B01ef43DA6F890FAC7B1Afb004600", @@ -5371,8 +5468,8 @@ } ], "total_tokens": "30000", - "withdrawn_tokens": "9235.4492784", - "remaining_tokens": "20764.5507216" + "withdrawn_tokens": "14209.7586708", + "remaining_tokens": "15790.2413292" } ] }, @@ -5382,7 +5479,7 @@ "tranche_end": "2023-12-05T00:00:00.000Z", "total_added": "129999.45", "total_removed": "0", - "locked_amount": "52959.394671488498864265", + "locked_amount": "52306.629793295059806393", "deposits": [ { "amount": "129999.45", @@ -5415,7 +5512,7 @@ "tranche_end": "2024-04-01T00:00:00.000Z", "total_added": "54144.7663", "total_removed": "0", - "locked_amount": "50482.6217199480944905281", + "locked_amount": "50075.54972923179337511559", "deposits": [ { "amount": "54144.7663", @@ -5448,7 +5545,7 @@ "tranche_end": "2023-09-03T00:00:00.000Z", "total_added": "62600", "total_removed": "0", - "locked_amount": "22337.93737950278814", + "locked_amount": "21866.007699137490576", "deposits": [ { "amount": "10000", @@ -5641,7 +5738,7 @@ "tranche_end": "2023-09-17T00:00:00.000Z", "total_added": "5000", "total_removed": "0", - "locked_amount": "1975.961123795028", + "locked_amount": "1938.26705986808735", "deposits": [ { "amount": "5000", @@ -6182,7 +6279,7 @@ "tranche_end": "2023-05-01T00:00:00.000Z", "total_added": "22500", "total_removed": "7280.725809525", - "locked_amount": "652.02290515653876", + "locked_amount": "309.9648941068150575", "deposits": [ { "amount": "7500", @@ -6687,8 +6784,8 @@ "tranche_start": "2022-06-02T00:00:00.000Z", "tranche_end": "2023-06-02T00:00:00.000Z", "total_added": "1939928.38", - "total_removed": "928642.9598472029154", - "locked_amount": "197953.279050265129539525", + "total_removed": "1709370.7872515768348", + "locked_amount": "183328.522176383808038828", "deposits": [ { "amount": "1852091.69", @@ -6702,6 +6799,11 @@ } ], "withdrawals": [ + { + "amount": "780727.8274043739194", + "user": "0xEbaeCD22304445A471630600708A197A311daB7F", + "tx": "0x10c3995baad1a053d37e0b84a56df717948b38bc10000676c296f22d1528754c" + }, { "amount": "15557.429251822391", "user": "0xEbaeCD22304445A471630600708A197A311daB7F", @@ -6780,6 +6882,12 @@ } ], "withdrawals": [ + { + "amount": "780727.8274043739194", + "user": "0xEbaeCD22304445A471630600708A197A311daB7F", + "tranche_id": 15, + "tx": "0x10c3995baad1a053d37e0b84a56df717948b38bc10000676c296f22d1528754c" + }, { "amount": "15557.429251822391", "user": "0xEbaeCD22304445A471630600708A197A311daB7F", @@ -6836,8 +6944,8 @@ } ], "total_tokens": "1852091.69", - "withdrawn_tokens": "886846.7025967940149", - "remaining_tokens": "965244.9874032059851" + "withdrawn_tokens": "1667574.5300011679343", + "remaining_tokens": "184517.1599988320657" }, { "address": "0x3469bbE61Ef6d5F31FE75a3f93C8835Aa2A62359", @@ -12177,7 +12285,7 @@ "tranche_start": "2021-09-03T00:00:00.000Z", "tranche_end": "2022-09-03T00:00:00.000Z", "total_added": "57278.000000000000000003", - "total_removed": "48182.21518131551", + "total_removed": "50196.35141572991", "locked_amount": "0", "deposits": [ { @@ -22762,6 +22870,16 @@ } ], "withdrawals": [ + { + "amount": "725", + "user": "0x52Dd36AB8e8eec8f6bE968E93679838dc73b19D3", + "tx": "0xbc67aa993d42656a84c7da90e6abcc0a3c00e7e9e21da4013251b0f8582567ca" + }, + { + "amount": "1289.1362344144", + "user": "0xab6dE081Af6C78433AFDaC5B756804bcE17e9eC1", + "tx": "0x9e6077e2dc83701a70b2a04028ab533e89cd7f1bb757ea4fe45e1388cfee600d" + }, { "amount": "25", "user": "0x363D3d06d70761c34D6EfEB25E409A9549E6970D", @@ -32271,10 +32389,17 @@ "tx": "0x1a0e42b837a8f3908bc4e36e9b024f48c371b98f066a0db36fd98793cd178f57" } ], - "withdrawals": [], + "withdrawals": [ + { + "amount": "725", + "user": "0x52Dd36AB8e8eec8f6bE968E93679838dc73b19D3", + "tranche_id": 11, + "tx": "0xbc67aa993d42656a84c7da90e6abcc0a3c00e7e9e21da4013251b0f8582567ca" + } + ], "total_tokens": "725", - "withdrawn_tokens": "0", - "remaining_tokens": "725" + "withdrawn_tokens": "725", + "remaining_tokens": "0" }, { "address": "0xab6dE081Af6C78433AFDaC5B756804bcE17e9eC1", @@ -32977,6 +33102,12 @@ } ], "withdrawals": [ + { + "amount": "1289.1362344144", + "user": "0xab6dE081Af6C78433AFDaC5B756804bcE17e9eC1", + "tranche_id": 11, + "tx": "0x9e6077e2dc83701a70b2a04028ab533e89cd7f1bb757ea4fe45e1388cfee600d" + }, { "amount": "842.29689345648", "user": "0xab6dE081Af6C78433AFDaC5B756804bcE17e9eC1", @@ -33021,8 +33152,8 @@ } ], "total_tokens": "3439", - "withdrawn_tokens": "2149.8637655856", - "remaining_tokens": "1289.1362344144" + "withdrawn_tokens": "3439", + "remaining_tokens": "0" }, { "address": "0x23E18CBa049393DFebC5a17e3b5ec9aF584CAE04", @@ -40504,7 +40635,7 @@ "tranche_end": "2023-06-05T00:00:00.000Z", "total_added": "3732368.4671", "total_removed": "715655.108029600523393", - "locked_amount": "328686.594617871114289061124", + "locked_amount": "306213.435102254068923605253", "deposits": [ { "amount": "1998.95815", @@ -41896,8 +42027,8 @@ "tranche_start": "2022-06-05T00:00:00.000Z", "tranche_end": "2023-12-05T00:00:00.000Z", "total_added": "15870102.715470999700000001", - "total_removed": "861351.90789501781835852", - "locked_amount": "6465189.1464593890044880891992803725493377", + "total_removed": "864782.86597041115934852", + "locked_amount": "6385500.76573176443723552685141297101162474", "deposits": [ { "amount": "16249.93", @@ -42416,6 +42547,26 @@ "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", "tx": "0x715201656de8957c81817e491e18394abf8bc419d96c86c5106ef3f30d7625e9" }, + { + "amount": "1784.722222", + "user": "0xF4c75FdbAe821C6B5DBB9f001bB23cBA58D1bA37", + "tx": "0x0b45b329eb6c3793425d9169b07ed6a7db7db303e4930ffaed75e3a1772a6a9c" + }, + { + "amount": "819.57170977716749", + "user": "0xe3eB4CF43C072658401996b71D43eE26E573562D", + "tx": "0x9d12dadb940c59a796a405a4971e73f24d7ad284528ec7ce676ae361a4ac1f51" + }, + { + "amount": "444.73147185430975", + "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", + "tx": "0x28d2b3f088965906ac3da878c491309729680c302fb98e2a435d07f88d6b962a" + }, + { + "amount": "381.93267176186375", + "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", + "tx": "0x6d5ce55a076149d5f66e5e84720d3bd46f31e5c79c54632927c1a00d1fdbce37" + }, { "amount": "981.387731774910625", "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", @@ -44536,6 +44687,18 @@ "tranche_id": 2, "tx": "0x715201656de8957c81817e491e18394abf8bc419d96c86c5106ef3f30d7625e9" }, + { + "amount": "444.73147185430975", + "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", + "tranche_id": 2, + "tx": "0x28d2b3f088965906ac3da878c491309729680c302fb98e2a435d07f88d6b962a" + }, + { + "amount": "381.93267176186375", + "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", + "tranche_id": 2, + "tx": "0x6d5ce55a076149d5f66e5e84720d3bd46f31e5c79c54632927c1a00d1fdbce37" + }, { "amount": "981.387731774910625", "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", @@ -46044,8 +46207,8 @@ } ], "total_tokens": "259998.8875", - "withdrawn_tokens": "154058.03361015483075", - "remaining_tokens": "105940.85388984516925" + "withdrawn_tokens": "154884.69775377100425", + "remaining_tokens": "105114.18974622899575" }, { "address": "0x89051CAb67Bc7F8CC44F7e270c6EDaf1EC57676c", @@ -46278,6 +46441,12 @@ "tranche_id": 2, "tx": "0x2ee57ee8a712525955ad807f4d45eeaa5f6388bf0b4fceabc7de6871899f736e" }, + { + "amount": "819.57170977716749", + "user": "0xe3eB4CF43C072658401996b71D43eE26E573562D", + "tranche_id": 2, + "tx": "0x9d12dadb940c59a796a405a4971e73f24d7ad284528ec7ce676ae361a4ac1f51" + }, { "amount": "2873.74755113623213", "user": "0xe3eB4CF43C072658401996b71D43eE26E573562D", @@ -46550,8 +46719,8 @@ } ], "total_tokens": "150551.801", - "withdrawn_tokens": "88566.24522601405589", - "remaining_tokens": "61985.55577398594411" + "withdrawn_tokens": "89385.81693579122338", + "remaining_tokens": "61165.98406420877662" }, { "address": "0x4d982Ab0823fD2f48e934a7be2bb0a5374a26148", @@ -46771,6 +46940,12 @@ } ], "withdrawals": [ + { + "amount": "1784.722222", + "user": "0xF4c75FdbAe821C6B5DBB9f001bB23cBA58D1bA37", + "tranche_id": 2, + "tx": "0x0b45b329eb6c3793425d9169b07ed6a7db7db303e4930ffaed75e3a1772a6a9c" + }, { "amount": "12786.192214", "user": "0xF4c75FdbAe821C6B5DBB9f001bB23cBA58D1bA37", @@ -47025,8 +47200,8 @@ } ], "total_tokens": "200000", - "withdrawn_tokens": "116957.518078", - "remaining_tokens": "83042.481922" + "withdrawn_tokens": "118742.2403", + "remaining_tokens": "81257.7597" }, { "address": "0x1b956E6c00E238194B331eddEFF72Cb5f28A8d01", @@ -48408,8 +48583,8 @@ "tranche_start": "2021-11-05T00:00:00.000Z", "tranche_end": "2023-05-05T00:00:00.000Z", "total_added": "14597706.0446472999", - "total_removed": "5849351.477870348891944626", - "locked_amount": "247176.1130985340899653821137083424", + "total_removed": "6130217.967403708954663132", + "locked_amount": "173608.308825906440421784938704799", "deposits": [ { "amount": "129284.449", @@ -48628,6 +48803,21 @@ "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", "tx": "0x4aef9b3e2f51d9ed88eb15f4553ae6f8388122b113571035da8ccb9f25ba68aa" }, + { + "amount": "613.7949227556821805", + "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", + "tx": "0xc37374c867eb2543ba3de47bf14990096f3371a93609cfd557a1eeaa3fb3e774" + }, + { + "amount": "279723.309055727147688756", + "user": "0xDdc5F6484349B242A9B23382Aa21f49B5Dc9a089", + "tx": "0xba1fdde929e0e2d4fe79de4dbac92cb5d20bb8b1dd7e5ff9bab961b728e7dae2" + }, + { + "amount": "529.38555487723284925", + "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", + "tx": "0x0c555d0f3b2b4b3fb50f208d9155b5886c83511a552518af11cadd5d5a06acec" + }, { "amount": "1360.32447632896938825", "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", @@ -51940,6 +52130,18 @@ "tranche_id": 3, "tx": "0x4aef9b3e2f51d9ed88eb15f4553ae6f8388122b113571035da8ccb9f25ba68aa" }, + { + "amount": "613.7949227556821805", + "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", + "tranche_id": 3, + "tx": "0xc37374c867eb2543ba3de47bf14990096f3371a93609cfd557a1eeaa3fb3e774" + }, + { + "amount": "529.38555487723284925", + "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", + "tranche_id": 3, + "tx": "0x0c555d0f3b2b4b3fb50f208d9155b5886c83511a552518af11cadd5d5a06acec" + }, { "amount": "1360.32447632896938825", "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", @@ -54762,8 +54964,8 @@ } ], "total_tokens": "359123.469575", - "withdrawn_tokens": "353014.654080898123457", - "remaining_tokens": "6108.815494101876543" + "withdrawn_tokens": "354157.83455853103848675", + "remaining_tokens": "4965.63501646896151325" }, { "address": "0xBdd412797c1B78535Afc5F71503b91fAbD0160fB", @@ -55443,6 +55645,12 @@ } ], "withdrawals": [ + { + "amount": "279723.309055727147688756", + "user": "0xDdc5F6484349B242A9B23382Aa21f49B5Dc9a089", + "tranche_id": 3, + "tx": "0xba1fdde929e0e2d4fe79de4dbac92cb5d20bb8b1dd7e5ff9bab961b728e7dae2" + }, { "amount": "204596.435472093839665575", "user": "0xDdc5F6484349B242A9B23382Aa21f49B5Dc9a089", @@ -55469,8 +55677,8 @@ } ], "total_tokens": "805741.847535494", - "withdrawn_tokens": "514496.445771975315053377", - "remaining_tokens": "291245.401763518684946623" + "withdrawn_tokens": "794219.754827702462742133", + "remaining_tokens": "11522.092707791537257867" }, { "address": "0x47FbE34Fd93416c63d35544dEE6c6f442Db8513d", @@ -58408,8 +58616,8 @@ "tranche_start": "2022-06-05T00:00:00.000Z", "tranche_end": "2023-06-05T00:00:00.000Z", "total_added": "472355.6199999996", - "total_removed": "43365.4083448891849", - "locked_amount": "52082.2697698769160313228361238", + "total_removed": "43997.0543192803416", + "locked_amount": "48521.26918257097251294495027906", "deposits": [ { "amount": "3000", @@ -65038,6 +65246,26 @@ "user": "0x7345AaA0D0e4C4A46d921fA9323973956F2b7392", "tx": "0xb13444d5ef684a442be6c285a6c38dcbc9959ff2eacc31474531826efe28c20a" }, + { + "amount": "177.4550903267567", + "user": "0x1ee93BF13d1D1d876330B011B28c507e392bc5E1", + "tx": "0xe4864b2d0f69c08809883553089d90b5a2318c4bc3c95ab5433db46cbd797bae" + }, + { + "amount": "35.7043670724", + "user": "0x5934b08F2548207149f90AC776867e4527Cf61E8", + "tx": "0x95a888c071664f817003e5e8410f8f7d9559fcfd93818961d6e656bf72b1dcde" + }, + { + "amount": "357.305466768", + "user": "0x0a6A5e1da768709A2bF17b2E58B2B73120051D03", + "tx": "0x097e43cb4f64f1cb502f321eceb8b91e6378cac0b3b6fe558fc1d543aec597e2" + }, + { + "amount": "61.181050224", + "user": "0xe7770271d882C54C46B9f00137e96a3BbfFD4d94", + "tx": "0x3c7d0394e431000fa5c733213116dc39b0f87a9a32a40e75cec3c2fce7795b0b" + }, { "amount": "168.502276762", "user": "0x38A292CB98Dc602ECAFF94E8E5fADD9800e4bA13", @@ -75573,10 +75801,17 @@ "tx": "0x96a22c369645e8945b4047374a05332f4054b50a492c43092e8bb8e974a006b9" } ], - "withdrawals": [], + "withdrawals": [ + { + "amount": "35.7043670724", + "user": "0x5934b08F2548207149f90AC776867e4527Cf61E8", + "tranche_id": 5, + "tx": "0x95a888c071664f817003e5e8410f8f7d9559fcfd93818961d6e656bf72b1dcde" + } + ], "total_tokens": "40", - "withdrawn_tokens": "0", - "remaining_tokens": "40" + "withdrawn_tokens": "35.7043670724", + "remaining_tokens": "4.2956329276" }, { "address": "0x2DFE1e54a1c9b6Ff874da1A4390326115e6f9eF9", @@ -78036,6 +78271,12 @@ } ], "withdrawals": [ + { + "amount": "61.181050224", + "user": "0xe7770271d882C54C46B9f00137e96a3BbfFD4d94", + "tranche_id": 5, + "tx": "0x3c7d0394e431000fa5c733213116dc39b0f87a9a32a40e75cec3c2fce7795b0b" + }, { "amount": "101.521461192", "user": "0xe7770271d882C54C46B9f00137e96a3BbfFD4d94", @@ -78074,8 +78315,8 @@ } ], "total_tokens": "600", - "withdrawn_tokens": "476.48491248", - "remaining_tokens": "123.51508752" + "withdrawn_tokens": "537.665962704", + "remaining_tokens": "62.334037296" }, { "address": "0x79D8ff1699911f065fD97a95a6B47216925C4B0e", @@ -78835,10 +79076,17 @@ "tx": "0x716a7be06da5a7a3d8038907974887a31805ea8eeab5d130cba528e4d2094d9f" } ], - "withdrawals": [], + "withdrawals": [ + { + "amount": "357.305466768", + "user": "0x0a6A5e1da768709A2bF17b2E58B2B73120051D03", + "tranche_id": 5, + "tx": "0x097e43cb4f64f1cb502f321eceb8b91e6378cac0b3b6fe558fc1d543aec597e2" + } + ], "total_tokens": "400", - "withdrawn_tokens": "0", - "remaining_tokens": "400" + "withdrawn_tokens": "357.305466768", + "remaining_tokens": "42.694533232" }, { "address": "0x7Bca13F09dA191AAc54cb76C815c8055C02a4D59", @@ -85688,10 +85936,17 @@ "tx": "0xc8541da6a57f410b6faba47a5e5184bae700193b7bd042914fffc562114d92f5" } ], - "withdrawals": [], + "withdrawals": [ + { + "amount": "177.4550903267567", + "user": "0x1ee93BF13d1D1d876330B011B28c507e392bc5E1", + "tranche_id": 5, + "tx": "0xe4864b2d0f69c08809883553089d90b5a2318c4bc3c95ab5433db46cbd797bae" + } + ], "total_tokens": "199.19", - "withdrawn_tokens": "0", - "remaining_tokens": "199.19" + "withdrawn_tokens": "177.4550903267567", + "remaining_tokens": "21.7349096732433" }, { "address": "0xEeE68cBdc1cB918087ebf3ea7bce8D326766985B", diff --git a/apps/static/src/assets/testnet-network.json b/apps/static/src/assets/testnet-network.json index 7017b9acd..ab52271c7 100644 --- a/apps/static/src/assets/testnet-network.json +++ b/apps/static/src/assets/testnet-network.json @@ -1,11 +1,7 @@ { "hosts": [ + "https://api-n00.testnet.vega.rocks/graphql", "https://api-n06.testnet.vega.rocks/graphql", - "https://api-n07.testnet.vega.rocks/graphql", - "https://api-n08.testnet.vega.rocks/graphql", - "https://api-n09.testnet.vega.rocks/graphql", - "https://api-n10.testnet.vega.rocks/graphql", - "https://api-n11.testnet.vega.rocks/graphql", - "https://api-n12.testnet.vega.rocks/graphql" + "https://api-n07.testnet.vega.rocks/graphql" ] } diff --git a/apps/trading-e2e/.env b/apps/trading-e2e/.env index d71f10490..d9fd22b0b 100644 --- a/apps/trading-e2e/.env +++ b/apps/trading-e2e/.env @@ -8,7 +8,7 @@ NX_VEGA_ENV=CUSTOM NX_VEGA_EXPLORER_URL=https://explorer.fairground.wtf 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://token.fairground.wtf -NX_VEGA_URL=http://localhost:3028/query +NX_VEGA_URL=http://localhost:3008/graphql NX_VEGA_WALLET_URL=http://localhost:1789 NX_ETH_LOCAL_PROVIDER_URL=http://localhost:8545/ NX_ETH_WALLET_MNEMONIC="ozone access unlock valid olympic save include omit supply green clown session" @@ -27,6 +27,6 @@ CYPRESS_VEGA_ENV=CUSTOM CYPRESS_VEGA_PUBLIC_KEY=02eceaba4df2bef76ea10caf728d8a099a2aa846cced25737cccaa9812342f65 CYPRESS_VEGA_PUBLIC_KEY2=7f9cf07d3a9905b1a61a1069f7a758855da428bc0f4a97de87f48644bfc25535 CYPRESS_VEGA_TOKEN_URL=https://token.fairground.wtf -CYPRESS_VEGA_URL=http://localhost:3028/query +CYPRESS_VEGA_URL=http://localhost:3008/graphql CYPRESS_VEGA_WALLET_URL=http://localhost:1789 CYPRESS_VEGA_WALLET_API_TOKEN= diff --git a/apps/trading-e2e/.env.capsule b/apps/trading-e2e/.env.capsule index 67273ea3f..5e9bf73bf 100644 --- a/apps/trading-e2e/.env.capsule +++ b/apps/trading-e2e/.env.capsule @@ -7,7 +7,7 @@ NX_VEGA_ENV=CUSTOM NX_VEGA_EXPLORER_URL=https://explorer.fairground.wtf 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://token.fairground.wtf -NX_VEGA_URL=http://localhost:3028/query +NX_VEGA_URL=http://localhost:3008/graphql NX_VEGA_WALLET_URL=http://localhost:1789 NX_ETH_LOCAL_PROVIDER_URL=http://localhost:8545/ NX_ETH_WALLET_MNEMONIC="ozone access unlock valid olympic save include omit supply green clown session" @@ -24,6 +24,6 @@ CYPRESS_VEGA_ENV=CUSTOM CYPRESS_VEGA_PUBLIC_KEY=02eceaba4df2bef76ea10caf728d8a099a2aa846cced25737cccaa9812342f65 CYPRESS_VEGA_PUBLIC_KEY2=7f9cf07d3a9905b1a61a1069f7a758855da428bc0f4a97de87f48644bfc25535 CYPRESS_VEGA_TOKEN_URL=https://token.fairground.wtf -CYPRESS_VEGA_URL=http://localhost:3028/query +CYPRESS_VEGA_URL=http://localhost:3008/graphql CYPRESS_VEGA_WALLET_URL=http://localhost:1789 CYPRESS_VEGA_WALLET_API_TOKEN= diff --git a/apps/trading-e2e/src/integration/market-info.cy.ts b/apps/trading-e2e/src/integration/market-info.cy.ts index 9ebd9445d..ea34519d1 100644 --- a/apps/trading-e2e/src/integration/market-info.cy.ts +++ b/apps/trading-e2e/src/integration/market-info.cy.ts @@ -1,4 +1,5 @@ import { MarketTradingModeMapping } from '@vegaprotocol/types'; +import { MarketState } from '@vegaprotocol/types'; const marketInfoBtn = 'Info'; const row = 'key-value-table-row'; @@ -12,7 +13,12 @@ describe('market info is displayed', { tags: '@smoke' }, () => { }); before(() => { - cy.mockTradingPage(); + cy.mockTradingPage( + MarketState.STATE_ACTIVE, + undefined, + undefined, + 'COMPROMISED' + ); cy.mockSubscription(); cy.visit('/#/markets/market-0'); cy.wait('@Markets'); @@ -20,6 +26,11 @@ describe('market info is displayed', { tags: '@smoke' }, () => { cy.wait('@MarketInfo'); }); + it('show oracle banner', () => { + cy.getByTestId(marketTitle).contains('Oracle').click(); + cy.getByTestId('oracle-status').should('contain.text', 'COMPROMISED'); + }); + it('current fees displayed', () => { cy.getByTestId(marketTitle).contains('Current fees').click(); validateMarketDataRow(0, 'Maker Fee', '0.02%'); diff --git a/apps/trading-e2e/src/integration/navbar.cy.ts b/apps/trading-e2e/src/integration/navbar.cy.ts index 6b04eecac..205c77f3a 100644 --- a/apps/trading-e2e/src/integration/navbar.cy.ts +++ b/apps/trading-e2e/src/integration/navbar.cy.ts @@ -32,7 +32,7 @@ describe('Navbar', { tags: '@smoke' }, () => { }); it('Resources dropdown should be correctly rendered', () => { - const resourceSelector = 'ul li:last-child'; + const resourceSelector = 'ul li:contains(Resources)'; ['Docs', 'Give Feedback'].forEach((text, index) => { cy.get('nav').find(resourceSelector).contains('Resources').click(); cy.get('nav') @@ -91,7 +91,7 @@ describe('Navbar', { tags: '@smoke' }, () => { cy.getByTestId('button-menu-drawer').click(); cy.getByTestId('menu-drawer').should('be.visible'); cy.getByTestId('menu-drawer') - .find('[data-testid="theme-switcher"]') + .find('[data-testid="Settings"]') .should('be.visible'); cy.getByTestId('button-menu-drawer').click(); cy.getByTestId('menu-drawer').should('not.be.visible'); diff --git a/apps/trading-e2e/src/integration/settings.cy.ts b/apps/trading-e2e/src/integration/settings.cy.ts new file mode 100644 index 000000000..c4ed19e46 --- /dev/null +++ b/apps/trading-e2e/src/integration/settings.cy.ts @@ -0,0 +1,45 @@ +import { closeWelcomeDialog } from '../support/helpers'; + +describe('Settings page', { tags: '@smoke' }, () => { + beforeEach(() => { + cy.clearLocalStorage().then(() => { + cy.mockTradingPage(); + cy.mockSubscription(); + cy.visit('/'); + closeWelcomeDialog(); + cy.get('[aria-label="cog icon"]').click(); + }); + }); + it('telemetry checkbox should work well', () => { + cy.location('hash').should('equal', '#/settings'); + cy.getByTestId('telemetry-approval').should( + 'have.attr', + 'data-state', + 'unchecked' + ); + cy.get('[for="telemetry-approval"]').click(); + cy.getByTestId('telemetry-approval').should( + 'have.attr', + 'data-state', + 'checked' + ); + cy.reload(); + cy.getByTestId('telemetry-approval').should( + 'have.attr', + 'data-state', + 'checked' + ); + cy.get('[for="telemetry-approval"]').click(); + cy.getByTestId('telemetry-approval').should( + 'have.attr', + 'data-state', + 'unchecked' + ); + cy.reload(); + cy.getByTestId('telemetry-approval').should( + 'have.attr', + 'data-state', + 'unchecked' + ); + }); +}); diff --git a/apps/trading-e2e/src/integration/trading-accounts.cy.ts b/apps/trading-e2e/src/integration/trading-accounts.cy.ts index 0a4ecdc54..8b337fa8c 100644 --- a/apps/trading-e2e/src/integration/trading-accounts.cy.ts +++ b/apps/trading-e2e/src/integration/trading-accounts.cy.ts @@ -1,17 +1,23 @@ import { checkSorting } from '@vegaprotocol/cypress'; describe('accounts', { tags: '@smoke' }, () => { - before(() => { - cy.clearAllLocalStorage(); + beforeEach(() => { cy.mockTradingPage(); cy.mockWeb3Provider(); cy.mockSubscription(); cy.setVegaWallet(); cy.visit('/#/markets/market-0'); - cy.wait('@Assets'); }); it('renders accounts', () => { + // 7001-COLL-001 + // 7001-COLL-002 + // 7001-COLL-003 + // 7001-COLL-004 + // 7001-COLL-005 + // 7001-COLL-006 + // 7001-COLL-007 + const tradingAccountRowId = '[row-id="t-0"]'; cy.getByTestId('Collateral').click(); @@ -24,29 +30,85 @@ describe('accounts', { tags: '@smoke' }, () => { cy.getByTestId('tab-accounts') .get(tradingAccountRowId) - .find('[col-id="accounts-actions"]') - .should('have.text', 'DepositWithdraw'); + .find('[col-id="used"]') + .should('have.text', '1.010.00%'); cy.getByTestId('tab-accounts') .get(tradingAccountRowId) - .find('[data-testid="deposit"]') - .should('have.text', 'Deposit'); - - cy.getByTestId('tab-accounts') - .get(tradingAccountRowId) - .find('[col-id="accounts-actions"] [data-testid="withdraw"]') - .should('have.text', 'Withdraw'); + .find('[col-id="available"]') + .should('have.text', '100,000.00'); cy.getByTestId('tab-accounts') .get(tradingAccountRowId) .find('[col-id="total"]') .should('have.text', '100,001.01'); + + cy.getByTestId('tab-accounts') + .get(tradingAccountRowId) + .find('[col-id="accounts-actions"]') + .should('have.text', ' '); + + cy.getByTestId('tab-accounts') + .get(tradingAccountRowId) + .find('[col-id="total"]') + .should('have.text', '100,001.01'); + + cy.getByTestId('tab-accounts') + .get('[col-id="accounts-actions"]') + .find('[data-testid="dropdown-menu"]') + .eq(1) + .click(); + cy.getByTestId('deposit').should('be.visible'); + cy.getByTestId('withdraw').should('be.visible'); + cy.getByTestId('breakdown').should('be.visible'); + cy.getByTestId('Collateral').click({ force: true }); }); it('should open asset details dialog when clicked on symbol', () => { + // 7001-COLL-008 cy.getByTestId('asset').contains('tEURO').click(); - cy.get('[data-testid="dialog-content"]:visible').should('exist'); - cy.get('[data-testid="dialog-close"]:visible').click(); + cy.get('[data-testid$="_label"]').should('have.length', 16); + cy.get('[data-testid="dialog-close"]').click(); + }); + + it('should open asset details dialog when clicked on symbol', () => { + // 7001-COLL-008 + cy.getByTestId('asset').contains('tEURO').click(); + cy.get('[data-testid$="_label"]').should('have.length', 16); + cy.get('[data-testid="dialog-close"]').click(); + }); + + it('should open usage breakdown dialog when clicked on used', () => { + // 7001-COLL-009 + cy.getByTestId('breakdown').contains('1.01').click(); + const headers = ['Market', 'Account type', 'Balance']; + cy.getByTestId('usage-breakdown').within(($headers) => { + cy.wrap($headers) + .get('.ag-header-cell-text') + .each(($header, i) => { + cy.wrap($header).should('have.text', headers[i]); + }); + }); + cy.get('[data-testid="dialog-close"]').click(); + }); + + it('sorting usage breakdown columns should work well', () => { + // 7001-COLL-010 + cy.getByTestId('breakdown').contains('1.01').click(); + cy.getByTestId('usage-breakdown') + .find('[col-id="type"]') + .eq(1) + .should('have.text', 'Margin'); + cy.getByTestId('usage-breakdown') + .find('[col-id="type"]') + .eq(2) + .should('have.text', 'Margin'); + cy.getByTestId('usage-breakdown') + .find('[col-id="type"]') + .eq(3) + .should('have.text', 'General'); + + cy.get('[data-testid="dialog-close"]').click(); }); describe('sorting by ag-grid columns should work well', () => { diff --git a/apps/trading-e2e/src/integration/trading-deal-ticket-order.cy.ts b/apps/trading-e2e/src/integration/trading-deal-ticket-order.cy.ts index 1c74e5415..418d1c290 100644 --- a/apps/trading-e2e/src/integration/trading-deal-ticket-order.cy.ts +++ b/apps/trading-e2e/src/integration/trading-deal-ticket-order.cy.ts @@ -88,5 +88,18 @@ describe('deal ticker order validation', { tags: '@smoke' }, () => { 'Size cannot be lower than 1' ); }); + it('must have total margin available', () => { + // 7001-COLL-011 + cy.getByTestId('tab-ticket') + .find('.text-xs') + .eq(5) + .within(() => { + cy.get('[data-state="closed"]').should( + 'have.text', + 'Total margin available' + ); + cy.get('.text-neutral-500').should('have.text', '~100,000.01 tDAI'); + }); + }); }); }); diff --git a/apps/trading-e2e/src/integration/trading-orders.cy.ts b/apps/trading-e2e/src/integration/trading-orders.cy.ts index f3a459f7a..8d8524f8b 100644 --- a/apps/trading-e2e/src/integration/trading-orders.cy.ts +++ b/apps/trading-e2e/src/integration/trading-orders.cy.ts @@ -455,7 +455,7 @@ describe('amend and cancel order', { tags: '@smoke' }, () => { }); }); it('must be warned (pre-submit) if the input price has too many digits after the decimal place for the market', () => { - // 7003-MORD-016 + // 7003-MORD-013 updateOrder({ id: orderId, status: Schema.OrderStatus.STATUS_ACTIVE, diff --git a/apps/trading-e2e/src/support/helpers.ts b/apps/trading-e2e/src/support/helpers.ts index 85fa22a68..19af30e7e 100644 --- a/apps/trading-e2e/src/support/helpers.ts +++ b/apps/trading-e2e/src/support/helpers.ts @@ -9,3 +9,8 @@ export const selectAsset = (assetIndex: number) => { // eslint-disable-next-line cy.wait(100); }; + +export const closeWelcomeDialog = () => { + cy.getByTestId('select-market-list').should('exist'); + cy.getByTestId('dialog-close').click(); +}; diff --git a/apps/trading-e2e/src/support/trading.ts b/apps/trading-e2e/src/support/trading.ts index ccf1d9b63..8d8202d6d 100644 --- a/apps/trading-e2e/src/support/trading.ts +++ b/apps/trading-e2e/src/support/trading.ts @@ -1,6 +1,7 @@ import { aliasGQLQuery } from '@vegaprotocol/cypress'; import * as Schema from '@vegaprotocol/types'; import type { CyHttpMessages } from 'cypress/types/net-stubbing'; +import type { Provider, Status } from '@vegaprotocol/oracles'; import { accountsQuery, assetQuery, @@ -155,7 +156,6 @@ const mockTradingPage = ( aliasGQLQuery(req, 'ProposalsList', proposalListQuery()); aliasGQLQuery(req, 'Deposits', depositsQuery()); }; - declare global { // eslint-disable-next-line @typescript-eslint/no-namespace namespace Cypress { @@ -164,50 +164,56 @@ declare global { mockTradingPage( state?: Schema.MarketState, tradingMode?: Schema.MarketTradingMode, - trigger?: Schema.AuctionTrigger + trigger?: Schema.AuctionTrigger, + oracleStatus?: Status ): void; } } } + export const addMockTradingPage = () => { Cypress.Commands.add( 'mockTradingPage', - (state = Schema.MarketState.STATE_ACTIVE, tradingMode, trigger) => { + ( + state = Schema.MarketState.STATE_ACTIVE, + tradingMode, + trigger, + oracleStatus + ) => { cy.mockGQL((req) => { mockTradingPage(req, state, tradingMode, trigger); }); + const oracle: Provider = { + name: 'Another oracle', + url: 'https://zombo.com', + description_markdown: + 'Some markdown describing the oracle provider.\n\nTwitter: @FacesPics2\n', + oracle: { + status: oracleStatus || 'GOOD', + status_reason: '', + first_verified: '2022-01-01T00:00:00.000Z', + last_verified: '2022-12-31T00:00:00.000Z', + type: 'public_key', + public_key: ORACLE_PUBKEY, + }, + proofs: [ + { + format: 'signed_message', + available: true, + type: 'public_key', + public_key: ORACLE_PUBKEY, + message: 'SOMEHEX', + }, + ], + github_link: `https://github.com/vegaprotocol/well-known/blob/main/oracle-providers/public_key-${ORACLE_PUBKEY}.toml`, + }; // Prevent request to github, return some dummy content cy.intercept( 'GET', /^https:\/\/raw.githubusercontent.com\/vegaprotocol\/well-known/, { - body: [ - { - name: 'Another oracle', - url: 'https://zombo.com', - description_markdown: - 'Some markdown describing the oracle provider.\n\nTwitter: @FacesPics2\n', - oracle: { - status: 'GOOD', - status_reason: '', - first_verified: '2022-01-01T00:00:00.000Z', - last_verified: '2022-12-31T00:00:00.000Z', - type: 'public_key', - public_key: ORACLE_PUBKEY, - }, - proofs: [ - { - format: 'signed_message', - available: true, - type: 'public_key', - public_key: ORACLE_PUBKEY, - message: 'SOMEHEX', - }, - ], - github_link: `https://github.com/vegaprotocol/well-known/blob/main/oracle-providers/public_key-${ORACLE_PUBKEY}.toml`, - }, - ], + body: [oracle], } ); } diff --git a/apps/trading/.env.capsule b/apps/trading/.env.capsule index f02546319..0a657ab2a 100644 --- a/apps/trading/.env.capsule +++ b/apps/trading/.env.capsule @@ -7,7 +7,7 @@ NX_VEGA_ENV=CUSTOM NX_VEGA_EXPLORER_URL=https://stagnet3.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://token.fairground.wtf -NX_VEGA_URL=http://localhost:3028/query +NX_VEGA_URL=http://localhost:3008/graphql NX_VEGA_WALLET_URL=http://localhost:1789 NX_VEGA_DOCS_URL=https://docs.vega.xyz/testnet NX_VEGA_REPO_URL=https://github.com/vegaprotocol/vega/releases diff --git a/apps/trading/.env.testnet b/apps/trading/.env.testnet index 64e584a9c..c4f8bc481 100644 --- a/apps/trading/.env.testnet +++ b/apps/trading/.env.testnet @@ -11,4 +11,4 @@ NX_VEGA_WALLET_URL=http://localhost:1789 NX_VEGA_DOCS_URL=https://docs.vega.xyz/testnet NX_VEGA_REPO_URL=https://github.com/vegaprotocol/vega/releases NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json -NX_VEGA_INCIDENT_URL=https://blog.vega.xyz/tagged/vega-incident-reports \ No newline at end of file +NX_VEGA_INCIDENT_URL=https://blog.vega.xyz/tagged/vega-incident-reports diff --git a/apps/trading/client-pages/market/trade-grid.tsx b/apps/trading/client-pages/market/trade-grid.tsx index b6f326a8d..ef31ef630 100644 --- a/apps/trading/client-pages/market/trade-grid.tsx +++ b/apps/trading/client-pages/market/trade-grid.tsx @@ -350,7 +350,10 @@ export const TradePanels = ({ return (
- +
+ + +
{({ width, height }) => ( diff --git a/apps/trading/client-pages/settings/index.ts b/apps/trading/client-pages/settings/index.ts new file mode 100644 index 000000000..9b97e60b3 --- /dev/null +++ b/apps/trading/client-pages/settings/index.ts @@ -0,0 +1,2 @@ +export { Settings as default } from './settings'; +export { SettingsButton } from './settings-button'; diff --git a/apps/trading/client-pages/settings/settings-button.tsx b/apps/trading/client-pages/settings/settings-button.tsx new file mode 100644 index 000000000..4f17c2601 --- /dev/null +++ b/apps/trading/client-pages/settings/settings-button.tsx @@ -0,0 +1,16 @@ +import { Icon, NavigationLink } from '@vegaprotocol/ui-toolkit'; +import { t } from '@vegaprotocol/i18n'; +import { Links, Routes } from '../../pages/client-router'; +import { COG } from '@blueprintjs/icons/src/generated/iconNames'; + +export const SettingsButton = ({ withMobile }: { withMobile?: boolean }) => { + return ( + + {withMobile ? ( + t('Settings') + ) : ( + + )} + + ); +}; diff --git a/apps/trading/client-pages/settings/settings.tsx b/apps/trading/client-pages/settings/settings.tsx new file mode 100644 index 000000000..cb14ffde2 --- /dev/null +++ b/apps/trading/client-pages/settings/settings.tsx @@ -0,0 +1,45 @@ +import { t } from '@vegaprotocol/i18n'; +import { TelemetryApproval } from '../../components/welcome-dialog/telemetry-approval'; +import { + Divider, + RoundedWrapper, + Switch, + ThemeSwitcher, +} from '@vegaprotocol/ui-toolkit'; +import { useThemeSwitcher } from '@vegaprotocol/react-helpers'; + +export const Settings = () => { + const { theme, setTheme } = useThemeSwitcher(); + const text = t(theme === 'dark' ? 'Light mode' : 'Dark mode'); + return ( +
+
+

+ {t('Settings')} +

+
+ {t('Changes are applied automatically.')} +
+
+ +
+
+ + +
+ setTheme()} + checked={theme === 'dark'} + /> +
+ + +
+
+
+
+ ); +}; diff --git a/apps/trading/components/banner/oracle-banner.tsx b/apps/trading/components/banner/oracle-banner.tsx index 08a27e9ed..894651fec 100644 --- a/apps/trading/components/banner/oracle-banner.tsx +++ b/apps/trading/components/banner/oracle-banner.tsx @@ -26,7 +26,8 @@ export const OracleBanner = ({ marketId }: { marketId: string }) => { return (
- Oracle status for this market is {oracle.status}.{' '} + Oracle status for this market is{' '} + {oracle.status}.{' '} {oracleStatuses[oracle.status]}
{oracle.status_reason ? ( diff --git a/apps/trading/components/navbar/navbar.tsx b/apps/trading/components/navbar/navbar.tsx index f4a36e2af..ccbd32b91 100644 --- a/apps/trading/components/navbar/navbar.tsx +++ b/apps/trading/components/navbar/navbar.tsx @@ -10,7 +10,6 @@ import { t } from '@vegaprotocol/i18n'; import { useGlobalStore } from '../../stores'; import { VegaWalletConnectButton } from '../vega-wallet-connect-button'; import { - ThemeSwitcher, Navigation, NavigationList, NavigationItem, @@ -24,6 +23,7 @@ import { import { Links, Routes } from '../../pages/client-router'; import { createDocsLinks } from '@vegaprotocol/utils'; +import { SettingsButton } from '../../client-pages/settings'; export const Navbar = ({ theme = 'system', @@ -45,7 +45,7 @@ export const Navbar = ({ theme={theme} actions={ <> - + } @@ -108,15 +108,15 @@ export const Navbar = ({ )} - - + + diff --git a/apps/trading/components/welcome-dialog/risk-notice-dialog.spec.tsx b/apps/trading/components/welcome-dialog/risk-notice-dialog.spec.tsx index bf29c411a..9b476130b 100644 --- a/apps/trading/components/welcome-dialog/risk-notice-dialog.spec.tsx +++ b/apps/trading/components/welcome-dialog/risk-notice-dialog.spec.tsx @@ -21,12 +21,12 @@ describe('Risk notice dialog', () => { }); it.each` - assertion | network - ${'displays'} | ${Networks.MAINNET} - ${'does not display'} | ${Networks.CUSTOM} - ${'does not display'} | ${Networks.DEVNET} - ${'does not display'} | ${Networks.STAGNET3} - ${'does not display'} | ${Networks.TESTNET} + assertion | network + ${'displays'} | ${Networks.MAINNET} + ${'displays'} | ${Networks.CUSTOM} + ${'displays'} | ${Networks.DEVNET} + ${'displays'} | ${Networks.STAGNET3} + ${'displays'} | ${Networks.TESTNET} `( '$assertion the risk notice on $network', async ({ assertion, network }) => { @@ -43,13 +43,7 @@ describe('Risk notice dialog', () => { { wrapper: BrowserRouter } ); - if (assertion === 'displays') { - // eslint-disable-next-line jest/no-conditional-expect - expect(screen.queryByText(introText)).toBeInTheDocument(); - } else { - // eslint-disable-next-line jest/no-conditional-expect - expect(screen.queryByText(introText)).not.toBeInTheDocument(); - } + expect(screen.queryByText(introText)).toBeInTheDocument(); } ); diff --git a/apps/trading/components/welcome-dialog/risk-notice-dialog.tsx b/apps/trading/components/welcome-dialog/risk-notice-dialog.tsx index 650d59da7..6c5531b2b 100644 --- a/apps/trading/components/welcome-dialog/risk-notice-dialog.tsx +++ b/apps/trading/components/welcome-dialog/risk-notice-dialog.tsx @@ -3,6 +3,7 @@ import { t } from '@vegaprotocol/i18n'; import { Button } from '@vegaprotocol/ui-toolkit'; import { LocalStorage } from '@vegaprotocol/utils'; import { RISK_ACCEPTED_KEY } from '../constants'; +import { TelemetryApproval } from './telemetry-approval'; interface Props { onClose: () => void; @@ -32,6 +33,9 @@ export const RiskNoticeDialog = ({ onClose }: Props) => { )}

+
+ +
); }; diff --git a/apps/trading/components/welcome-dialog/telemetry-approval.spec.tsx b/apps/trading/components/welcome-dialog/telemetry-approval.spec.tsx new file mode 100644 index 000000000..dc5ff93a9 --- /dev/null +++ b/apps/trading/components/welcome-dialog/telemetry-approval.spec.tsx @@ -0,0 +1,19 @@ +import { render, screen, act } from '@testing-library/react'; +import { TelemetryApproval } from './telemetry-approval'; + +describe('TelemetryApproval', () => { + it('click on checkbox should be properly handled', () => { + render(); + expect(screen.getByRole('checkbox')).toHaveAttribute( + 'data-state', + 'unchecked' + ); + act(() => { + screen.getByRole('checkbox').click(); + }); + expect(screen.getByRole('checkbox')).toHaveAttribute( + 'data-state', + 'checked' + ); + }); +}); diff --git a/apps/trading/components/welcome-dialog/telemetry-approval.tsx b/apps/trading/components/welcome-dialog/telemetry-approval.tsx new file mode 100644 index 000000000..e4464418e --- /dev/null +++ b/apps/trading/components/welcome-dialog/telemetry-approval.tsx @@ -0,0 +1,32 @@ +import { Checkbox } from '@vegaprotocol/ui-toolkit'; +import { t } from '@vegaprotocol/i18n'; +import { useTelemetryApproval } from '../../lib/hooks/use-telemetry-approval'; + +export const TelemetryApproval = ({ + isSettingsPage, +}: { + isSettingsPage?: boolean; +}) => { + const [isApproved, setIsApproved] = useTelemetryApproval(); + return ( +
+
+ {t('Share usage data')}} + checked={isApproved} + name="telemetry-approval" + onCheckedChange={() => setIsApproved(!isApproved)} + /> +
+
+ + {t( + 'Help identify bugs and improve the service by sharing anonymous usage data.' + )} + {!isSettingsPage && + ' ' + t('You can change this in your settings at any time.')} + +
+
+ ); +}; diff --git a/apps/trading/components/welcome-dialog/welcome-dialog.tsx b/apps/trading/components/welcome-dialog/welcome-dialog.tsx index c3faf3dc6..722f02c1a 100644 --- a/apps/trading/components/welcome-dialog/welcome-dialog.tsx +++ b/apps/trading/components/welcome-dialog/welcome-dialog.tsx @@ -4,7 +4,6 @@ import { Dialog } from '@vegaprotocol/ui-toolkit'; import { t } from '@vegaprotocol/i18n'; import { useDataProvider, useLocalStorage } from '@vegaprotocol/react-helpers'; import { activeMarketsProvider } from '@vegaprotocol/market-list'; -import { useEnvironment, Networks } from '@vegaprotocol/environment'; import * as constants from '../constants'; import { RiskNoticeDialog } from './risk-notice-dialog'; import { WelcomeNoticeDialog } from './welcome-notice-dialog'; @@ -13,37 +12,38 @@ import { useGlobalStore } from '../../stores'; export const WelcomeDialog = () => { const { pathname } = useLocation(); - const { VEGA_ENV } = useEnvironment(); - let dialogContent: React.ReactNode = null; + let dialogContent: React.ReactNode; let title = ''; let size: 'small' | 'medium' = 'small'; + let onClose: ((open: boolean) => void) | undefined = undefined; const [riskAccepted] = useLocalStorage(constants.RISK_ACCEPTED_KEY); const { data } = useDataProvider({ dataProvider: activeMarketsProvider, variables: undefined, }); - const { update, shouldDisplayWelcomeDialog } = useGlobalStore((store) => ({ - update: store.update, - shouldDisplayWelcomeDialog: store.shouldDisplayWelcomeDialog, - })); - const isRiskDialogNeeded = - riskAccepted !== 'true' && VEGA_ENV === Networks.MAINNET; + const update = useGlobalStore((store) => store.update); + const shouldDisplayWelcomeDialog = useGlobalStore( + (store) => store.shouldDisplayWelcomeDialog + ); + const isRiskDialogNeeded = riskAccepted !== 'true' && !('Cypress' in window); const isWelcomeDialogNeeded = pathname === '/' || shouldDisplayWelcomeDialog; - const onClose = useCallback(() => { + const onCloseDialog = useCallback(() => { update({ shouldDisplayWelcomeDialog: isRiskDialogNeeded }); - // eslint-disable-next-line react-hooks/exhaustive-deps - dialogContent = null; }, [update, isRiskDialogNeeded]); if (isRiskDialogNeeded) { - dialogContent = ; + dialogContent = ; title = t('WARNING'); size = 'medium'; } else if (isWelcomeDialogNeeded && data?.length === 0) { dialogContent = ; + onClose = onCloseDialog; } else if (isWelcomeDialogNeeded && (data?.length || 0) > 0) { - dialogContent = ; + dialogContent = ; + onClose = onCloseDialog; + } else { + dialogContent = null as React.ReactNode; } return ( diff --git a/apps/trading/lib/hooks/use-telemetry-approval.spec.ts b/apps/trading/lib/hooks/use-telemetry-approval.spec.ts new file mode 100644 index 000000000..6a4c9f00d --- /dev/null +++ b/apps/trading/lib/hooks/use-telemetry-approval.spec.ts @@ -0,0 +1,48 @@ +import { renderHook, act, waitFor } from '@testing-library/react'; +import { useLocalStorage } from '@vegaprotocol/react-helpers'; +import { SentryInit, SentryClose } from '@vegaprotocol/utils'; +import { STORAGE_KEY, useTelemetryApproval } from './use-telemetry-approval'; + +const mockSetValue = jest.fn(); +const mockRemoveValue = jest.fn(); +jest.mock('@vegaprotocol/utils'); +jest.mock('@vegaprotocol/react-helpers', () => ({ + ...jest.requireActual('@vegaprotocol/react-helpers'), + useLocalStorage: jest + .fn() + .mockImplementation(() => [false, mockSetValue, mockRemoveValue]), +})); + +describe('useTelemetryApproval', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + it('hook should return proper array', () => { + const res = renderHook(() => useTelemetryApproval()); + expect(res.result.current[0]).toEqual(false); + expect(res.result.current[1]).toEqual(expect.any(Function)); + expect(useLocalStorage).toHaveBeenCalledWith(STORAGE_KEY); + }); + + it('hook should init stuff properly', async () => { + const res = renderHook(() => useTelemetryApproval()); + await act(() => { + res.result.current[1](true); + }); + await waitFor(() => { + expect(SentryInit).toHaveBeenCalled(); + expect(mockSetValue).toHaveBeenCalledWith('1'); + }); + }); + + it('hook should close stuff properly', async () => { + const res = renderHook(() => useTelemetryApproval()); + await act(() => { + res.result.current[1](false); + }); + await waitFor(() => { + expect(SentryClose).toHaveBeenCalled(); + expect(mockRemoveValue).toHaveBeenCalledWith(); + }); + }); +}); diff --git a/apps/trading/lib/hooks/use-telemetry-approval.ts b/apps/trading/lib/hooks/use-telemetry-approval.ts new file mode 100644 index 000000000..21e6a2469 --- /dev/null +++ b/apps/trading/lib/hooks/use-telemetry-approval.ts @@ -0,0 +1,24 @@ +import { useLocalStorage } from '@vegaprotocol/react-helpers'; +import { useCallback } from 'react'; +import { SentryInit, SentryClose } from '@vegaprotocol/utils'; +import { ENV } from '../config'; +export const STORAGE_KEY = 'vega_telemetry_approval'; + +export const useTelemetryApproval = (): [ + value: boolean, + setValue: (value: boolean) => void +] => { + const [value, setValue, removeValue] = useLocalStorage(STORAGE_KEY); + const setApprove = useCallback( + (value: boolean) => { + if (value) { + SentryInit(ENV.dsn, ENV.envName); + return setValue('1'); + } + SentryClose(); + removeValue(); + }, + [setValue, removeValue] + ); + return [Boolean(value), setApprove]; +}; diff --git a/apps/trading/pages/_app.page.tsx b/apps/trading/pages/_app.page.tsx index cfd815d31..3996631d3 100644 --- a/apps/trading/pages/_app.page.tsx +++ b/apps/trading/pages/_app.page.tsx @@ -36,6 +36,7 @@ import { Navbar } from '../components/navbar'; import { ENV } from '../lib/config'; import { useDataProvider } from '@vegaprotocol/react-helpers'; import { activeOrdersProvider } from '@vegaprotocol/orders'; +import { useTelemetryApproval } from '../lib/hooks/use-telemetry-approval'; const DEFAULT_TITLE = t('Welcome to Vega trading!'); @@ -145,7 +146,10 @@ const PartyData = () => { const MaybeConnectEagerly = () => { useVegaEagerConnect(Connectors); - useEthereumEagerConnect(ENV.dsn); + const [isTelemetryApproved] = useTelemetryApproval(); + useEthereumEagerConnect( + isTelemetryApproved ? { dsn: ENV.dsn, env: ENV.envName } : {} + ); const { pubKey, connect } = useVegaWallet(); const [searchParams] = useSearchParams(); diff --git a/apps/trading/pages/client-router.tsx b/apps/trading/pages/client-router.tsx index e5a4659b6..4180df127 100644 --- a/apps/trading/pages/client-router.tsx +++ b/apps/trading/pages/client-router.tsx @@ -26,12 +26,17 @@ const LazyPortfolio = dynamic(() => import('../client-pages/portfolio'), { ssr: false, }); +const LazySettings = dynamic(() => import('../client-pages/settings'), { + ssr: false, +}); + export enum Routes { HOME = '/', MARKET = '/markets', MARKETS = '/markets/all', PORTFOLIO = '/portfolio', - LIQUIDITY = '/liquidity', + LIQUIDITY = 'liquidity/:marketId', + SETTINGS = 'settings', } type ConsoleLinks = { [r in Routes]: (...args: string[]) => string }; @@ -45,6 +50,7 @@ export const Links: ConsoleLinks = { marketId ? trimEnd(`${Routes.LIQUIDITY}/${marketId}`, '/') : Routes.LIQUIDITY, + [Routes.SETTINGS]: () => Routes.SETTINGS, }; const routerConfig: RouteObject[] = [ @@ -87,6 +93,10 @@ const routerConfig: RouteObject[] = [ path: Routes.PORTFOLIO, element: , }, + { + path: Routes.SETTINGS, + element: , + }, { path: '*', element: ( diff --git a/apps/trading/sentry.client.config.js b/apps/trading/sentry.client.config.js index 6724c2dd4..7b5a79bb5 100644 --- a/apps/trading/sentry.client.config.js +++ b/apps/trading/sentry.client.config.js @@ -1,14 +1,9 @@ -import * as Sentry from '@sentry/nextjs'; -import { BrowserTracing } from '@sentry/tracing'; import { ENV } from './lib/config/env'; +import { LocalStorage, SentryInit } from '@vegaprotocol/utils'; +import { STORAGE_KEY } from './lib/hooks/use-telemetry-approval'; -const { dsn } = ENV; - -if (dsn) { - Sentry.init({ - dsn, - integrations: [new BrowserTracing()], - tracesSampleRate: 1, - environment: ENV.envName, - }); +const { dsn, envName } = ENV; +const isTelemetryApproved = !!LocalStorage.getItem(STORAGE_KEY); +if (dsn && isTelemetryApproved) { + SentryInit(dsn, envName); } diff --git a/libs/accounts/src/lib/accounts-table.spec.tsx b/libs/accounts/src/lib/accounts-table.spec.tsx index 7539a5303..cf3538a1b 100644 --- a/libs/accounts/src/lib/accounts-table.spec.tsx +++ b/libs/accounts/src/lib/accounts-table.spec.tsx @@ -61,14 +61,7 @@ describe('AccountsTable', () => { ); }); const cells = await screen.findAllByRole('gridcell'); - const expectedValues = [ - 'tBTC', - '1,256.00', - '1,256.00', - '2,512.00', - 'Deposit', - 'Withdraw', - ]; + const expectedValues = ['tBTC', '1,256.00', '1,256.00', '2,512.00', '']; cells.forEach((cell, i) => { expect(cell).toHaveTextContent(expectedValues[i]); }); diff --git a/libs/accounts/src/lib/accounts-table.tsx b/libs/accounts/src/lib/accounts-table.tsx index dfd80d8a3..170abbc17 100644 --- a/libs/accounts/src/lib/accounts-table.tsx +++ b/libs/accounts/src/lib/accounts-table.tsx @@ -9,7 +9,17 @@ import type { VegaICellRendererParams, VegaValueFormatterParams, } from '@vegaprotocol/datagrid'; -import { Button, ButtonLink, Dialog } from '@vegaprotocol/ui-toolkit'; +import { + Button, + ButtonLink, + Dialog, + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, + VegaIcon, + VegaIconNames, +} from '@vegaprotocol/ui-toolkit'; import { TooltipCellComponent } from '@vegaprotocol/ui-toolkit'; import { AgGridDynamic as AgGrid, @@ -122,7 +132,7 @@ export const AccountTable = forwardRef( params.data.asset.id === pinnedAssetId && new BigNumber(params.data.total).isLessThanOrEqualTo(0) ? 32 - : 22, + : 24, [pinnedAssetId] ); @@ -256,7 +266,7 @@ export const AccountTable = forwardRef( colId="accounts-actions" headerName="" sortable={false} - minWidth={200} + maxWidth={200} type="rightAligned" cellRenderer={({ data, @@ -283,30 +293,66 @@ export const AccountTable = forwardRef( ); } return ( - <> - - {!props.isReadOnly && ( - { - onClickDeposit && onClickDeposit(data.asset.id); - }} - > - {t('Deposit')} - - )} - - {!props.isReadOnly && ( - - onClickWithdraw && onClickWithdraw(data.asset.id) - } - > - {t('Withdraw')} - - )} - + !props.isReadOnly && ( + + } + > + + { + onClickDeposit && onClickDeposit(data.asset.id); + }} + > + + + {t('Deposit')} + + + + onClickWithdraw && onClickWithdraw(data.asset.id) + } + > + + + {t('Withdraw')} + + + { + setOpenBreakdown(!openBreakdown); + setRow(data); + }} + > + + + {t('Breakdown')} + + + + + ) ); } }} @@ -314,7 +360,10 @@ export const AccountTable = forwardRef( } -
+

{row?.asset?.symbol} {t('usage breakdown')}

diff --git a/libs/cypress/src/lib/capsule/contants.ts b/libs/cypress/src/lib/capsule/contants.ts index 224bcadf4..449e18253 100644 --- a/libs/cypress/src/lib/capsule/contants.ts +++ b/libs/cypress/src/lib/capsule/contants.ts @@ -1 +1,4 @@ -export const ASSET_ID_FOR_MARKET = 'fUSDC'; +export const ASSET_ID_FOR_MARKET = + '816af99af60d684502a40824758f6b5377e6af48e50a9ee8ef478ecb879ea8bc'; + +export const ASSET_SYMBOL = 'fUSDC'; diff --git a/libs/cypress/src/lib/capsule/propose-market.ts b/libs/cypress/src/lib/capsule/propose-market.ts index 095379bcf..1ad7c0c9f 100644 --- a/libs/cypress/src/lib/capsule/propose-market.ts +++ b/libs/cypress/src/lib/capsule/propose-market.ts @@ -4,7 +4,7 @@ import { createLog } from './logging'; import type { ProposalSubmissionBody } from '@vegaprotocol/wallet'; import { getProposal } from './get-proposal'; import { sendVegaTx } from './wallet-client'; -import { ASSET_ID_FOR_MARKET } from './contants'; +import { ASSET_ID_FOR_MARKET, ASSET_SYMBOL } from './contants'; const log = createLog('propose-market'); @@ -43,7 +43,7 @@ function createNewMarketProposal(): ProposalSubmissionBody { code: 'TEST.24h', future: { settlementAsset: ASSET_ID_FOR_MARKET, - quoteName: ASSET_ID_FOR_MARKET, + quoteName: ASSET_SYMBOL, dataSourceSpecForSettlementData: { external: { oracle: { diff --git a/libs/cypress/src/lib/commands/get-assets.ts b/libs/cypress/src/lib/commands/get-assets.ts index 6d4f9d152..c2ea51845 100644 --- a/libs/cypress/src/lib/commands/get-assets.ts +++ b/libs/cypress/src/lib/commands/get-assets.ts @@ -66,7 +66,7 @@ export function addGetAssets() { cy.request({ method: 'POST', - url: 'http://localhost:3028/query', + url: 'http://localhost:3008/graphql', body: { query: print(query), }, diff --git a/libs/cypress/src/lib/commands/get-network-parameters.ts b/libs/cypress/src/lib/commands/get-network-parameters.ts index 9fa5e8871..1f12d67d6 100644 --- a/libs/cypress/src/lib/commands/get-network-parameters.ts +++ b/libs/cypress/src/lib/commands/get-network-parameters.ts @@ -24,7 +24,7 @@ export function addGetNetworkParameters() { }`; cy.request({ method: 'POST', - url: `http://localhost:3028/query`, + url: `http://localhost:3008/graphql`, body: { query: mutation, }, diff --git a/libs/cypress/src/lib/commands/get-nodes.ts b/libs/cypress/src/lib/commands/get-nodes.ts index d7206df7b..454ad1aba 100644 --- a/libs/cypress/src/lib/commands/get-nodes.ts +++ b/libs/cypress/src/lib/commands/get-nodes.ts @@ -43,7 +43,7 @@ export function addGetNodes() { cy.request({ method: 'POST', - url: `http://localhost:3028/query`, + url: `http://localhost:3008/graphql`, body: { query: print(query), }, diff --git a/libs/environment/src/components/network-switcher/network-switcher.tsx b/libs/environment/src/components/network-switcher/network-switcher.tsx index 8302a384b..4f7392342 100644 --- a/libs/environment/src/components/network-switcher/network-switcher.tsx +++ b/libs/environment/src/components/network-switcher/network-switcher.tsx @@ -70,7 +70,7 @@ const NetworkLabel = ({ isCurrent = false, isAvailable = false, }: NetworkLabelProps) => ( - + {getLabelText({ isCurrent, isAvailable })} ); @@ -111,9 +111,12 @@ export const NetworkSwitcher = ({ trigger={ - {envTriggerMapping[current]} + {envTriggerMapping[current]} } > diff --git a/libs/fills/src/lib/fills-table.spec.tsx b/libs/fills/src/lib/fills-table.spec.tsx index f1ee45630..797dc2391 100644 --- a/libs/fills/src/lib/fills-table.spec.tsx +++ b/libs/fills/src/lib/fills-table.spec.tsx @@ -120,6 +120,40 @@ describe('FillsTable', () => { expect(amountCell).toHaveClass('text-vega-pink'); }); + it('should format cells correctly for side unspecified', async () => { + const partyId = 'party-id'; + const buyerFill = generateFill({ + ...defaultFill, + seller: { + id: partyId, + }, + aggressor: Schema.Side.SIDE_UNSPECIFIED, + sellerFee: { + makerFee: '1', + infrastructureFee: '1', + liquidityFee: '1', + }, + }); + render(); + + const cells = screen.getAllByRole('gridcell'); + const expectedValues = [ + buyerFill.market?.tradableInstrument.instrument.name || '', + '-3.00', + '1.00 BTC', + '3.00 BTC', + '-', + '0.03 BTC', + getDateTimeFormat().format(new Date(buyerFill.createdAt)), + ]; + cells.forEach((cell, i) => { + expect(cell).toHaveTextContent(expectedValues[i]); + }); + + const amountCell = cells.find((c) => c.getAttribute('col-id') === 'size'); + expect(amountCell).toHaveClass('text-vega-pink'); + }); + it('should render correct maker or taker role', async () => { const partyId = 'party-id'; const takerFill = generateFill({ @@ -190,7 +224,7 @@ describe('FillsTable', () => { makerFee: '1000', totalFee: '6000', }; - expect(getFeesBreakdown('TAKER', fees)).toEqual(expectedBreakdown); + expect(getFeesBreakdown('Taker', fees)).toEqual(expectedBreakdown); }); it('should return correct fees breakdown for a maker', () => { @@ -205,7 +239,7 @@ describe('FillsTable', () => { makerFee: '-1000', totalFee: '4000', }; - expect(getFeesBreakdown('MAKER', fees)).toEqual(expectedBreakdown); + expect(getFeesBreakdown('Maker', fees)).toEqual(expectedBreakdown); }); }); }); diff --git a/libs/fills/src/lib/fills-table.tsx b/libs/fills/src/lib/fills-table.tsx index eb3090225..9f0e7167b 100644 --- a/libs/fills/src/lib/fills-table.tsx +++ b/libs/fills/src/lib/fills-table.tsx @@ -26,8 +26,10 @@ import BigNumber from 'bignumber.js'; import type { Trade } from './fills-data-provider'; import type { FillFieldsFragment } from './__generated__/Fills'; -const TAKER = 'TAKER'; -const MAKER = 'MAKER'; +const TAKER = 'Taker'; +const MAKER = 'Maker'; + +export type Role = typeof TAKER | typeof MAKER | '-'; export type Props = (AgGridReactProps | AgReactUiProps) & { partyId: string; @@ -180,24 +182,10 @@ const formatTotal = ({ }; const formatRole = (partyId: string) => { - return ({ value, data }: VegaValueFormatterParams) => { - const taker = t('Taker'); - const maker = t('Maker'); - if (data?.buyer.id === partyId) { - if (value === Schema.Side.SIDE_BUY) { - return taker; - } else { - return maker; - } - } else if (data?.seller.id === partyId) { - if (value === Schema.Side.SIDE_SELL) { - return taker; - } else { - return maker; - } - } else { - return '-'; - } + return ({ data }: VegaValueFormatterParams) => { + if (!data) return '-'; + const { role } = getRoleAndFees({ data, partyId }); + return role; }; }; @@ -222,6 +210,15 @@ const formatFee = (partyId: string) => { }; }; +export const isEmptyFeeObj = (feeObj: Schema.TradeFee) => { + if (!feeObj) return true; + return ( + feeObj.liquidityFee === '0' && + feeObj.makerFee === '0' && + feeObj.infrastructureFee === '0' + ); +}; + export const getRoleAndFees = ({ data, partyId, @@ -232,14 +229,30 @@ export const getRoleAndFees = ({ >; partyId?: string; }) => { - let role; + let role: Role; let feesObj; if (data?.buyer.id === partyId) { - role = data.aggressor === Schema.Side.SIDE_BUY ? TAKER : MAKER; - feesObj = role === TAKER ? data?.buyerFee : data.sellerFee; + if (data.aggressor === Schema.Side.SIDE_BUY) { + role = TAKER; + feesObj = data?.buyerFee; + } else if (data.aggressor === Schema.Side.SIDE_SELL) { + role = MAKER; + feesObj = data?.sellerFee; + } else { + role = '-'; + feesObj = !isEmptyFeeObj(data?.buyerFee) ? data.buyerFee : data.sellerFee; + } } else if (data?.seller.id === partyId) { - role = data.aggressor === Schema.Side.SIDE_SELL ? TAKER : MAKER; - feesObj = role === TAKER ? data?.sellerFee : data.buyerFee; + if (data.aggressor === Schema.Side.SIDE_SELL) { + role = TAKER; + feesObj = data?.sellerFee; + } else if (data.aggressor === Schema.Side.SIDE_BUY) { + role = MAKER; + feesObj = data?.buyerFee; + } else { + role = '-'; + feesObj = !isEmptyFeeObj(data.sellerFee) ? data.sellerFee : data.buyerFee; + } } else { return { role: '-', feesObj: '-' }; } @@ -270,11 +283,6 @@ const FeesBreakdownTooltip = ({ {role === MAKER && ( <>

{t('The maker will receive the maker fee.')}

-

- {t( - 'If the market is in monitoring auction the maker will pay half of the infrastructure and liquidity fees.' - )} -

{t( 'If the market is active the maker will pay zero infrastructure and liquidity fees.' @@ -283,14 +291,14 @@ const FeesBreakdownTooltip = ({ )} {role === TAKER && ( - <> -

{t('Fees to be paid by the taker.')}

-

- {t( - 'If the market is in monitoring auction the taker will pay half of the infrastructure and liquidity fees.' - )} -

- +

{t('Fees to be paid by the taker.')}

+ )} + {role === '-' && ( +

+ {t( + 'If the market is in monitoring auction, half of the infrastructure and liquidity fees will be paid.' + )} +

)}
{t('Infrastructure fee')}
@@ -316,7 +324,7 @@ const FeesBreakdownTooltip = ({ }; export const getFeesBreakdown = ( - role: string, + role: Role, feesObj: { __typename?: 'TradeFee' | undefined; makerFee: string; @@ -328,6 +336,7 @@ export const getFeesBreakdown = ( role === MAKER ? new BigNumber(feesObj.makerFee).times(-1).toString() : feesObj.makerFee; + const infrastructureFee = feesObj.infrastructureFee; const liquidityFee = feesObj.liquidityFee; diff --git a/libs/ledger/jest.config.ts b/libs/ledger/jest.config.ts index deafd8379..3c3e0b5cd 100644 --- a/libs/ledger/jest.config.ts +++ b/libs/ledger/jest.config.ts @@ -12,4 +12,5 @@ export default { }, moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], coverageDirectory: '../../coverage/libs/ledger', + setupFilesAfterEnv: ['./src/setup-tests.ts'], }; diff --git a/libs/ledger/src/lib/ledger-entries-data-provider.ts b/libs/ledger/src/lib/ledger-entries-data-provider.ts index 0f8a31f69..893214335 100644 --- a/libs/ledger/src/lib/ledger-entries-data-provider.ts +++ b/libs/ledger/src/lib/ledger-entries-data-provider.ts @@ -30,7 +30,10 @@ export type LedgerEntry = LedgerEntryFragment & { }; export type AggregatedLedgerEntriesEdge = Schema.AggregatedLedgerEntriesEdge; -export type AggregatedLedgerEntriesNode = AggregatedLedgerEntriesEdge & { +export type AggregatedLedgerEntriesNode = Omit< + AggregatedLedgerEntriesEdge, + 'node' +> & { node: LedgerEntry; }; diff --git a/libs/ledger/src/lib/ledger-entries.mock.ts b/libs/ledger/src/lib/ledger-entries.mock.ts index 8e31a31e9..1033a8c0c 100644 --- a/libs/ledger/src/lib/ledger-entries.mock.ts +++ b/libs/ledger/src/lib/ledger-entries.mock.ts @@ -32,7 +32,7 @@ export const ledgerEntriesQuery = ( return merge(defaultResult, override); }; -const ledgerEntries: LedgerEntryFragment[] = [ +export const ledgerEntries: LedgerEntryFragment[] = [ { vegaTime: '1669224476734364000', quantity: '0', @@ -180,7 +180,6 @@ const ledgerEntries: LedgerEntryFragment[] = [ toAccountBalance: '0', fromAccountBalance: '0', }, - { vegaTime: '2022-11-24T12:41:22.054428Z', quantity: '1000000000', diff --git a/libs/ledger/src/lib/ledger-export-link.spec.tsx b/libs/ledger/src/lib/ledger-export-link.spec.tsx new file mode 100644 index 000000000..8c623ccfa --- /dev/null +++ b/libs/ledger/src/lib/ledger-export-link.spec.tsx @@ -0,0 +1,85 @@ +import { act, render, screen, waitFor } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; +import { LedgerExportLink } from './ledger-export-link'; +import * as Types from '@vegaprotocol/types'; +import { ledgerEntries } from './ledger-entries.mock'; +import type { LedgerEntry } from './ledger-entries-data-provider'; + +const VEGA_URL = 'https://vega-url.co.uk/querystuff'; +const mockEnvironment = jest.fn(() => VEGA_URL); +jest.mock('@vegaprotocol/environment', () => ({ + useEnvironment: jest.fn(() => mockEnvironment()), +})); + +const asset = { + id: 'assetID', + name: 'assetName', + symbol: 'assetSymbol', + decimals: 1, + quantum: '1', + status: Types.AssetStatus, + source: { + __typename: 'ERC20', + contractAddress: 'contractAddres', + lifetimeLimit: 'lifetimeLimit', + withdrawThreshold: 'withdraw', + }, +}; + +describe('LedgerExportLink', () => { + const partyId = 'partyId'; + const entries = ledgerEntries.map((entry) => { + return { + ...entry, + asset: entry.assetId + ? { + ...asset, + id: entry.assetId, + name: `name ${entry.assetId}`, + symbol: `symbol ${entry.assetId}`, + } + : null, + marketSender: null, + marketReceiver: null, + } as LedgerEntry; + }); + + it('should be properly rendered', async () => { + render(); + await waitFor(() => { + expect(screen.getByRole('link')).toBeInTheDocument(); + expect(screen.getByRole('link')).toHaveAttribute( + 'href', + `https://vega-url.co.uk/api/v2/ledgerentry/export?partyId=${partyId}&assetId=asset-id` + ); + expect( + screen.getByRole('button', { name: /^symbol asset-id/ }) + ).toBeInTheDocument(); + }); + }); + it('should be properly change link url', async () => { + render(); + await waitFor(() => { + expect( + screen.getByRole('button', { name: /^symbol asset-id/ }) + ).toBeInTheDocument(); + }); + act(() => { + userEvent.click(screen.getByRole('button', { name: /^symbol asset-id/ })); + }); + await waitFor(() => { + expect(screen.getByRole('menu')).toBeInTheDocument(); + }); + act(() => { + userEvent.click( + screen.getByRole('menuitem', { name: /^symbol asset-id-2/ }) + ); + }); + await waitFor(() => { + expect(screen.getByRole('link')).toHaveAttribute( + 'href', + `https://vega-url.co.uk/api/v2/ledgerentry/export?partyId=${partyId}&assetId=asset-id-2` + ); + }); + }); +}); diff --git a/libs/ledger/src/lib/ledger-export-link.tsx b/libs/ledger/src/lib/ledger-export-link.tsx new file mode 100644 index 000000000..9de96bbc9 --- /dev/null +++ b/libs/ledger/src/lib/ledger-export-link.tsx @@ -0,0 +1,71 @@ +import type { LedgerEntry } from './ledger-entries-data-provider'; +import { useMemo, useState } from 'react'; +import { useEnvironment } from '@vegaprotocol/environment'; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, + Link, + Button, +} from '@vegaprotocol/ui-toolkit'; +import { t } from '@vegaprotocol/i18n'; + +const getProtoHost = (vegaurl: string) => { + const loc = new URL(vegaurl); + return `${loc.protocol}//${loc.host}`; +}; + +export const LedgerExportLink = ({ + partyId, + entries, +}: { + partyId: string; + entries: LedgerEntry[]; +}) => { + const assets = entries.reduce((aggr, item) => { + if (item.asset && !(item.asset.id in aggr)) { + aggr[item.asset.id] = item.asset.symbol; + } + return aggr; + }, {} as Record); + const [assetId, setAssetId] = useState(Object.keys(assets)[0]); + const VEGA_URL = useEnvironment((store) => store.VEGA_URL); + const protohost = VEGA_URL ? getProtoHost(VEGA_URL) : ''; + + const assetDropDown = useMemo(() => { + return ( + {assets[assetId]}} + > + + {Object.keys(assets).map((assetKey) => ( + setAssetId(assetKey)} + > + {assets[assetKey]} + + ))} + + + ); + }, [assetId, assets]); + + if (!protohost) { + return null; + } + return ( +
+
Export all
+ {assetDropDown} + + + +
+ ); +}; diff --git a/libs/ledger/src/lib/ledger-manager.tsx b/libs/ledger/src/lib/ledger-manager.tsx index a6771d2e1..a4ca28c2f 100644 --- a/libs/ledger/src/lib/ledger-manager.tsx +++ b/libs/ledger/src/lib/ledger-manager.tsx @@ -3,12 +3,13 @@ import type * as Schema from '@vegaprotocol/types'; import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import type { FilterChangedEvent } from 'ag-grid-community'; import type { AgGridReact } from 'ag-grid-react'; -import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; +import { useCallback, useEffect, useRef, useState } from 'react'; import { subDays, formatRFC3339 } from 'date-fns'; import type { AggregatedLedgerEntriesNode } from './ledger-entries-data-provider'; import { useLedgerEntriesDataProvider } from './ledger-entries-data-provider'; import { LedgerTable } from './ledger-table'; import type * as Types from '@vegaprotocol/types'; +import { LedgerExportLink } from './ledger-export-link'; export interface Filter { vegaTime?: { @@ -22,6 +23,7 @@ const defaultFilter = { value: { start: formatRFC3339(subDays(Date.now(), 7)) }, }, }; + export const LedgerManager = ({ partyId }: { partyId: string }) => { const gridRef = useRef(null); const [filter, setFilter] = useState(defaultFilter); @@ -55,6 +57,9 @@ export const LedgerManager = ({ partyId }: { partyId: string }) => { rowData={extractedData} onFilterChanged={onFilterChanged} /> + {extractedData && ( + + )}
( (props, ref) => { return ( { marketInfo.tradableInstrument.instrument.product .dataSourceSpecForSettlementData.data; return data.find((provider) => - provider.proofs.some( - (proof) => - (proof.type === 'eth_address' && - dataSource.sourceType.__typename === - 'DataSourceDefinitionExternal' && - dataSource.sourceType.sourceType.signers?.some( - (signer) => - signer.signer.__typename === 'ETHAddress' && - signer.signer.address === proof.eth_address - )) || - (proof.type === 'public_key' && - dataSource.sourceType.__typename === - 'DataSourceDefinitionExternal' && - dataSource.sourceType.sourceType.signers?.some( - (signer) => - signer.signer.__typename === 'PubKey' && - signer.signer.key === proof.public_key - )) - ) + provider.proofs.some((proof) => { + if ( + proof.type === 'eth_address' && + dataSource.sourceType.__typename === 'DataSourceDefinitionExternal' + ) { + return dataSource.sourceType.sourceType.signers?.some( + (signer) => + signer.signer.__typename === 'ETHAddress' && + signer.signer.address === proof.eth_address + ); + } + if ( + proof.type === 'public_key' && + dataSource.sourceType.__typename === 'DataSourceDefinitionExternal' + ) { + return dataSource.sourceType.sourceType.signers?.some( + (signer) => + signer.signer.__typename === 'PubKey' && + signer.signer.key === proof.public_key + ); + } + return false; + }) )?.oracle; }, [data, marketInfo]); }; diff --git a/libs/network-stats/src/components/stats-manager/Stats.graphql b/libs/network-stats/src/components/stats-manager/Stats.graphql index 348d64156..3be3c5840 100644 --- a/libs/network-stats/src/components/stats-manager/Stats.graphql +++ b/libs/network-stats/src/components/stats-manager/Stats.graphql @@ -1,4 +1,7 @@ query Stats { + epoch { + id + } nodeData { stakedTotal totalNodes diff --git a/libs/network-stats/src/components/stats-manager/__generated__/Stats.ts b/libs/network-stats/src/components/stats-manager/__generated__/Stats.ts index 6c2275fa7..d253da9c7 100644 --- a/libs/network-stats/src/components/stats-manager/__generated__/Stats.ts +++ b/libs/network-stats/src/components/stats-manager/__generated__/Stats.ts @@ -6,11 +6,14 @@ const defaultOptions = {} as const; export type StatsQueryVariables = Types.Exact<{ [key: string]: never; }>; -export type StatsQuery = { __typename?: 'Query', nodeData?: { __typename?: 'NodeData', stakedTotal: string, totalNodes: number, inactiveNodes: number } | null, statistics: { __typename?: 'Statistics', status: string, blockHeight: string, blockDuration: string, backlogLength: string, txPerBlock: string, tradesPerSecond: string, ordersPerSecond: string, averageOrdersPerBlock: string, vegaTime: any, appVersion: string, chainVersion: string, chainId: string, genesisTime: any } }; +export type StatsQuery = { __typename?: 'Query', epoch: { __typename?: 'Epoch', id: string }, nodeData?: { __typename?: 'NodeData', stakedTotal: string, totalNodes: number, inactiveNodes: number } | null, statistics: { __typename?: 'Statistics', status: string, blockHeight: string, blockDuration: string, backlogLength: string, txPerBlock: string, tradesPerSecond: string, ordersPerSecond: string, averageOrdersPerBlock: string, vegaTime: any, appVersion: string, chainVersion: string, chainId: string, genesisTime: any } }; export const StatsDocument = gql` query Stats { + epoch { + id + } nodeData { stakedTotal totalNodes diff --git a/libs/network-stats/src/components/stats-manager/stats-manager.tsx b/libs/network-stats/src/components/stats-manager/stats-manager.tsx index 2a88d56be..b1de0ff6e 100644 --- a/libs/network-stats/src/components/stats-manager/stats-manager.tsx +++ b/libs/network-stats/src/components/stats-manager/stats-manager.tsx @@ -19,10 +19,14 @@ export const StatsManager = ({ className }: StatsManagerProps) => { return () => stopPolling(); }, [startPolling, stopPolling]); - const getValue = (field: keyof NodeData | keyof Statistics) => - ['stakedTotal', 'totalNodes', 'inactiveNodes'].includes(field) - ? data?.nodeData?.[field as keyof NodeData] - : data?.statistics?.[field as keyof Statistics]; + const getValue = (field: keyof NodeData | keyof Statistics | 'epoch') => { + if (['stakedTotal', 'totalNodes', 'inactiveNodes'].includes(field)) { + return data?.nodeData?.[field as keyof NodeData]; + } else if (field === 'epoch') { + return data?.epoch.id; + } + return data?.statistics?.[field as keyof Statistics]; + }; const panels = fieldsDefinition.map( ({ field, title, description, formatter, goodThreshold }) => ({ @@ -50,7 +54,7 @@ export const StatsManager = ({ className }: StatsManagerProps) => { className={classNames( 'border rounded p-2 relative border-vega-light-200 dark:border-vega-dark-200', { - 'col-span-2': field === 'chainId' || field === 'status', + 'col-span-2': field === 'chainId', }, { 'bg-transparent border-vega-light-200 dark:border-vega-dark-200': diff --git a/libs/network-stats/src/config/stats-fields.ts b/libs/network-stats/src/config/stats-fields.ts index 96f8be4e5..f6b315d84 100644 --- a/libs/network-stats/src/config/stats-fields.ts +++ b/libs/network-stats/src/config/stats-fields.ts @@ -20,7 +20,7 @@ export type FieldValue = any; export type GoodThreshold = (...args: FieldValue[]) => boolean; export interface Stats { - field: keyof NodeData | keyof Statistics; + field: keyof NodeData | keyof Statistics | 'epoch'; title: string; goodThreshold?: GoodThreshold; // eslint-disable-next-line @@ -161,6 +161,11 @@ const VEGA_TIME: Stats = { description: t('The time on the blockchain'), }; +const EPOCH: Stats = { + field: 'epoch', + title: 'Epoch', +}; + const APP_VERSION: Stats = { field: 'appVersion', title: t('App'), @@ -217,6 +222,7 @@ const CHAIN_ID: Stats = { export const fieldsDefinition: Stats[] = [ STATUS, + EPOCH, BLOCK_HEIGHT, UPTIME, TOTAL_NODES, diff --git a/libs/react-helpers/src/hooks/use-logger.ts b/libs/react-helpers/src/hooks/use-logger.ts index cf62cf218..759d3f3b8 100644 --- a/libs/react-helpers/src/hooks/use-logger.ts +++ b/libs/react-helpers/src/hooks/use-logger.ts @@ -1,24 +1,18 @@ import { useRef } from 'react'; -import { BrowserTracing } from '@sentry/tracing'; -import * as Sentry from '@sentry/browser'; import type { LocalLogger, LoggerConf } from '@vegaprotocol/utils'; -import { localLoggerFactory } from '@vegaprotocol/utils'; +import { localLoggerFactory, SentryInit } from '@vegaprotocol/utils'; -interface Props extends LoggerConf { +export interface LoggerProps extends LoggerConf { dsn?: string; + env?: string; } -export const useLogger = ({ dsn, ...props }: Props) => { +export const useLogger = ({ dsn, env, ...props }: LoggerProps) => { const logger = useRef(null); if (!logger.current) { logger.current = localLoggerFactory(props); if (dsn) { - Sentry.init({ - dsn, - integrations: [new BrowserTracing()], - tracesSampleRate: 1, - defaultIntegrations: false, - }); + SentryInit(dsn, env); } } return logger.current; diff --git a/libs/types/src/__generated__/types.ts b/libs/types/src/__generated__/types.ts index aa926b374..cc785d575 100644 --- a/libs/types/src/__generated__/types.ts +++ b/libs/types/src/__generated__/types.ts @@ -796,6 +796,67 @@ export type ETHAddress = { address?: Maybe; }; +/** List of all entities created by transaction hash */ +export type Entities = { + __typename?: 'Entities'; + /** List of accounts created by the transaction hash */ + accounts?: Maybe>>; + /** List of assets created by the transaction hash */ + assets?: Maybe>>; + /** List of balance changes created by the transaction hash */ + balanceChanges?: Maybe>>; + /** List of delegations created by the transaction hash */ + delegations?: Maybe>>; + /** List of deposits created by the transaction hash */ + deposits?: Maybe>>; + /** List of ERC-20 multisig signer added bundles created by the transaction hash */ + erc20MultiSigSignerAddedBundles?: Maybe>>; + /** List of ERC-20 multisig signer removed bundles created by the transaction hash */ + erc20MultiSigSignerRemovedBundles?: Maybe>>; + /** List of ethereum key rotations created by the transaction hash */ + ethereumKeyRotations?: Maybe>>; + /** List of key rotations created by the transaction hash */ + keyRotations?: Maybe>>; + /** List of ledger entries created by the transaction hash */ + ledgerEntries?: Maybe>>; + /** List of liquidity provisions created by the transaction hash */ + liquidityProvisions?: Maybe>>; + /** List of margin levels created by the transaction hash */ + marginLevels?: Maybe>>; + /** List of markets created by the transaction hash */ + markets?: Maybe>>; + /** List of network parameters created by the transaction hash */ + networkParameters?: Maybe>>; + /** List of node signatures created by the transaction hash */ + nodeSignatures?: Maybe>>; + /** List of nodes created by the transaction hash */ + nodes?: Maybe>>; + /** List of oracle data created by the transaction hash */ + oracleData?: Maybe>>; + /** List of oracle specs created by the transaction hash */ + oracleSpecs?: Maybe>>; + /** List of orders created by the transaction hash */ + orders?: Maybe>>; + /** List of parties created by the transaction hash */ + parties?: Maybe>>; + /** List of positions created by the transaction hash */ + positions?: Maybe>>; + /** List of proposals created by the transaction hash */ + proposals?: Maybe>>; + /** List of protocol upgrade proposals created by the transaction hash */ + protocolUpgradeProposals?: Maybe>>; + /** List of rewards created by the transaction hash */ + rewards?: Maybe>>; + /** List of trades created by the transaction hash */ + trades?: Maybe>>; + /** List of transfers created by the transaction hash */ + transfers?: Maybe>>; + /** List of votes created by the transaction hash */ + votes?: Maybe>>; + /** List of withdrawals created by the transaction hash */ + withdrawals?: Maybe>>; +}; + /** Epoch describes a specific period of time in the Vega network */ export type Epoch = { __typename?: 'Epoch'; @@ -988,6 +1049,15 @@ export type ExternalDataSourceSpec = { spec: DataSourceSpec; }; +/** An estimate of the fee to be paid for the order */ +export type FeeEstimate = { + __typename?: 'FeeEstimate'; + /** The estimated fees if the order was to trade */ + fees: TradeFee; + /** The total estimated amount of fees if the order was to trade */ + totalFeeAmount: Scalars['String']; +}; + /** The factors applied to calculate the fees */ export type FeeFactors = { __typename?: 'FeeFactors'; @@ -1178,6 +1248,26 @@ export type LedgerEntryFilter = { TransferTypes?: InputMaybe>>; }; +/** Liquidation estimate for both worst and best case possible */ +export type LiquidationEstimate = { + __typename?: 'LiquidationEstimate'; + /** Liquidation price estimate assuming no slippage */ + bestCase: LiquidationPrice; + /** Liquidation price estimate assuming slippage cap is applied */ + worstCase: LiquidationPrice; +}; + +/** Liquidation price estimate for either only the current open volume and position given some or all buy orders get filled, or position given some or all sell orders get filled */ +export type LiquidationPrice = { + __typename?: 'LiquidationPrice'; + /** Liquidation price assuming buy orders start getting filled */ + including_buy_orders: Scalars['String']; + /** Liquidation price assuming sell orders start getting filled */ + including_sell_orders: Scalars['String']; + /** Liquidation price for current open volume ignoring any active orders */ + open_volume_only: Scalars['String']; +}; + /** Configuration of a market liquidity monitoring parameters */ export type LiquidityMonitoringParameters = { __typename?: 'LiquidityMonitoringParameters'; @@ -1367,6 +1457,15 @@ export type MarginEdge = { node: MarginLevels; }; +/** Margin level estimate for both worst and best case possible */ +export type MarginEstimate = { + __typename?: 'MarginEstimate'; + /** Margin level estimate assuming no slippage */ + bestCase: MarginLevels; + /** Margin level estimate assuming slippage cap is applied */ + worstCase: MarginLevels; +}; + /** Margins for a given a party */ export type MarginLevels = { __typename?: 'MarginLevels'; @@ -1377,7 +1476,7 @@ export type MarginLevels = { * the general account of the party for the given asset. */ collateralReleaseLevel: Scalars['String']; - /** This is the minimum margin required for a party to place a new order on the network (unsigned integer) */ + /** This is the minimum margin required for a party to place a new order on the network, expressed as unsigned integer */ initialLevel: Scalars['String']; /** Minimal margin for the position to be maintained in the network (unsigned integer) */ maintenanceLevel: Scalars['String']; @@ -1385,7 +1484,7 @@ export type MarginLevels = { market: Market; /** The party for this margin */ party: Party; - /** If the margin is between maintenance and search, the network will initiate a collateral search (unsigned integer) */ + /** If the margin is between maintenance and search, the network will initiate a collateral search, expressed as unsigned integer */ searchLevel: Scalars['String']; /** RFC3339Nano time from at which this margin level was relevant */ timestamp: Scalars['Timestamp']; @@ -1483,6 +1582,7 @@ export type Market = { state: MarketState; /** An instance of, or reference to, a tradable instrument. */ tradableInstrument: TradableInstrument; + /** @deprecated Simplify and consolidate trades query and remove nesting. Use trades query instead */ tradesConnection?: Maybe; /** Current mode of execution of the market */ tradingMode: MarketTradingMode; @@ -1894,6 +1994,28 @@ export type NodedelegationsConnectionArgs = { partyId?: InputMaybe; }; +export type NodeBasic = { + __typename?: 'NodeBasic'; + /** The URL of an avatar */ + avatarUrl?: Maybe; + /** Ethereum public key of the node */ + ethereumAddress: Scalars['String']; + /** The node URL, for example n01.vega.xyz */ + id: Scalars['ID']; + /** URL that provides more information about the node */ + infoUrl: Scalars['String']; + /** Country code for the location of the node */ + location: Scalars['String']; + /** The name of the node operator */ + name: Scalars['String']; + /** Public key of the node operator */ + pubkey: Scalars['String']; + /** Validator status of the node */ + status: NodeStatus; + /** Tendermint public key of the node */ + tmPubkey: Scalars['String']; +}; + /** Summary of data across all nodes */ export type NodeData = { __typename?: 'NodeData'; @@ -2107,18 +2229,6 @@ export type ObservableMarketDepthUpdate = { sequenceNumber: Scalars['String']; }; -export type OffsetPagination = { - /** - * Descending reverses the order of the records returned - * default is true, if false the results will be returned in ascending order - */ - descending: Scalars['Boolean']; - /** Limit the number of returned records to the value specified, default is 50 */ - limit: Scalars['Int']; - /** Skip the number of records specified, default is 0 */ - skip: Scalars['Int']; -}; - /** The specific details for a one-off transfer */ export type OneOffTransfer = { __typename?: 'OneOffTransfer'; @@ -2213,7 +2323,10 @@ export type Order = { status: OrderStatus; /** The timeInForce of order (determines how and if it executes, and whether it persists on the book) */ timeInForce: OrderTimeInForce; - /** Trades relating to this order */ + /** + * Trades relating to this order + * @deprecated Simplify and consolidate trades query and remove nesting. Use trades query instead + */ tradesConnection?: Maybe; /** The order type */ type?: Maybe; @@ -2279,11 +2392,28 @@ export type OrderFilter = { /** Date range to retrieve orders from/to. Start and end time should be expressed as an integer value of nano-seconds past the Unix epoch */ dateRange?: InputMaybe; excludeLiquidity?: InputMaybe; + /** + * If true, only orders that are live will be returned. Orders are live if they have STATUS_ACTIVE or STATUS_PARKED + * as per https://github.com/vegaprotocol/specs-internal/blob/master/protocol/0024-OSTA-order_status.md + */ + liveOnly?: InputMaybe; status?: InputMaybe>; timeInForce?: InputMaybe>; types?: InputMaybe>; }; +/** Basic description of an order */ +export type OrderInfo = { + /** Boolean indicating a market order */ + isMarketOrder: Scalars['Boolean']; + /** Price for the order */ + price: Scalars['String']; + /** Number of units remaining of the total that have not yet been bought or sold (uint64) */ + remaining: Scalars['String']; + /** Whether the order is to buy or sell */ + side: Side; +}; + /** Why the order was rejected by the core node */ export enum OrderRejectionReason { /** Amending the order failed */ @@ -2304,6 +2434,8 @@ export enum OrderRejectionReason { ORDER_ERROR_CANNOT_HAVE_GTC_AND_EXPIRYAT = 'ORDER_ERROR_CANNOT_HAVE_GTC_AND_EXPIRYAT', /** Cannot send FOK orders during an auction */ ORDER_ERROR_CANNOT_SEND_FOK_ORDER_DURING_AUCTION = 'ORDER_ERROR_CANNOT_SEND_FOK_ORDER_DURING_AUCTION', + /** Good for Auction order received during continuous trading */ + ORDER_ERROR_CANNOT_SEND_GFA_ORDER_DURING_CONTINUOUS_TRADING = 'ORDER_ERROR_CANNOT_SEND_GFA_ORDER_DURING_CONTINUOUS_TRADING', /** Good for Normal order received during an auction */ ORDER_ERROR_CANNOT_SEND_GFN_ORDER_DURING_AN_AUCTION = 'ORDER_ERROR_CANNOT_SEND_GFN_ORDER_DURING_AN_AUCTION', /** Cannot send IOC orders during an auction */ @@ -2312,8 +2444,8 @@ export enum OrderRejectionReason { ORDER_ERROR_EDIT_NOT_ALLOWED = 'ORDER_ERROR_EDIT_NOT_ALLOWED', /** Attempt to amend expiry time to a value before time order was created */ ORDER_ERROR_EXPIRYAT_BEFORE_CREATEDAT = 'ORDER_ERROR_EXPIRYAT_BEFORE_CREATEDAT', - /** Good for Auction order received during continuous trading */ - ORDER_ERROR_GFA_CANNOT_SEND_ORDER_DURING_CONTINUOUS_TRADING = 'ORDER_ERROR_GFA_CANNOT_SEND_ORDER_DURING_CONTINUOUS_TRADING', + /** Order was submitted with an incorrect or invalid market type */ + ORDER_ERROR_INCORRECT_MARKET_TYPE = 'ORDER_ERROR_INCORRECT_MARKET_TYPE', /** Insufficient balance to submit the order (no deposit made) */ ORDER_ERROR_INSUFFICIENT_ASSET_BALANCE = 'ORDER_ERROR_INSUFFICIENT_ASSET_BALANCE', /** Insufficient funds to pay fees */ @@ -2360,6 +2492,10 @@ export enum OrderRejectionReason { ORDER_ERROR_OFFSET_MUST_BE_GREATER_THAN_ZERO = 'ORDER_ERROR_OFFSET_MUST_BE_GREATER_THAN_ZERO', /** Order is out of sequence */ ORDER_ERROR_OUT_OF_SEQUENCE = 'ORDER_ERROR_OUT_OF_SEQUENCE', + /** A post-only order would produce an aggressive trade and thus it has been rejected */ + ORDER_ERROR_POST_ONLY_ORDER_WOULD_TRADE = 'ORDER_ERROR_POST_ONLY_ORDER_WOULD_TRADE', + /** A reduce-ony order would not reduce the party's position and thus it has been rejected */ + ORDER_ERROR_REDUCE_ONLY_ORDER_WOULD_NOT_REDUCE = 'ORDER_ERROR_REDUCE_ONLY_ORDER_WOULD_NOT_REDUCE', /** Unable to remove the order */ ORDER_ERROR_REMOVAL_FAILURE = 'ORDER_ERROR_REMOVAL_FAILURE', /** Order cannot be filled because it would require self trading */ @@ -2368,6 +2504,8 @@ export enum OrderRejectionReason { ORDER_ERROR_SELL_CANNOT_REFERENCE_BEST_BID_PRICE = 'ORDER_ERROR_SELL_CANNOT_REFERENCE_BEST_BID_PRICE', /** Time has failed us */ ORDER_ERROR_TIME_FAILURE = 'ORDER_ERROR_TIME_FAILURE', + /** Unable to submit pegged order, temporarily too many pegged orders across all markets */ + ORDER_ERROR_TOO_MANY_PEGGED_ORDERS = 'ORDER_ERROR_TOO_MANY_PEGGED_ORDERS', /** Unable to amend pegged order price */ ORDER_ERROR_UNABLE_TO_AMEND_PRICE_ON_PEGGED_ORDER = 'ORDER_ERROR_UNABLE_TO_AMEND_PRICE_ON_PEGGED_ORDER', /** Unable to reprice a pegged order */ @@ -2526,6 +2664,7 @@ export type Party = { rewardsConnection?: Maybe; /** The staking information for this Party */ stakingSummary: StakingSummary; + /** @deprecated Simplify and consolidate trades query and remove nesting. Use trades query instead */ tradesConnection?: Maybe; /** All transfers for a public key */ transfersConnection?: Maybe; @@ -2754,6 +2893,15 @@ export type PositionEdge = { node: Position; }; +/** Response for the estimate of the margin level and, if available, collateral was provided in the request, liqudation price for the specified position */ +export type PositionEstimate = { + __typename?: 'PositionEstimate'; + /** Liquidation price range estimate for the specified position. Only populated if available collateral was specified in the request */ + liquidation?: Maybe; + /** Margin level range estimate for the specified position */ + margin: MarginEstimate; +}; + export type PositionResolution = { __typename?: 'PositionResolution'; /** Number of parties closed out */ @@ -2770,6 +2918,8 @@ export type PositionResolution = { export enum PositionStatus { /** The position was distressed, and had to be closed out entirely - orders were removed from the book, and the open volume was closed out by the network */ POSITION_STATUS_CLOSED_OUT = 'POSITION_STATUS_CLOSED_OUT', + /** The position was distressed, but could not be closed out - orders were removed from the book, and the open volume will be closed out once there is sufficient volume on the book */ + POSITION_STATUS_DISTRESSED = 'POSITION_STATUS_DISTRESSED', /** The position was distressed, but removing open orders from the book brought the margin level back to a point where the open position could be maintained */ POSITION_STATUS_ORDERS_CLOSED = 'POSITION_STATUS_ORDERS_CLOSED', /** The position is either healthy, or if closed out, was closed out normally */ @@ -2923,9 +3073,9 @@ export type Proposal = { reference: Scalars['String']; /** Why the proposal was rejected by the core */ rejectionReason?: Maybe; - /** Required liquidity provider equity like share majority for this proposal to succeed */ + /** Equity-like share required for a market amendment proposal to be enacted (if not met, the proposal will not be enacted), represented as a fraction that can be converted to a percentage */ requiredLpMajority?: Maybe; - /** Required liquidity provider equity like share participation for this proposal to succeed */ + /** The market share of LPs' equity-like share that must take part in the market amendment vote for the proposal to pass. This means the votes of LPs that have submitted more liquidity to that market, or have been LPs from the start carry more weight. If it requires 50% of a market's equity-like share for a majority, and the proposal receives only YES votes but only LPs with 49% of the equity-like share voted, the proposal will not pass */ requiredLpParticipation?: Maybe; /** Required majority for this proposal to succeed */ requiredMajority: Scalars['String']; @@ -2941,6 +3091,36 @@ export type Proposal = { export type ProposalChange = NewAsset | NewFreeform | NewMarket | UpdateAsset | UpdateMarket | UpdateNetworkParameter; +export type ProposalDetail = { + __typename?: 'ProposalDetail'; + /** RFC3339Nano time and date when the proposal reached the Vega network */ + datetime: Scalars['Timestamp']; + /** Error details of the rejectionReason */ + errorDetails?: Maybe; + /** Proposal ID that is provided by Vega once proposal reaches the network */ + id?: Maybe; + /** Party that prepared the proposal */ + party: Party; + /** Rationale behind the proposal */ + rationale: ProposalRationale; + /** A UUID reference to aid tracking proposals on Vega */ + reference: Scalars['String']; + /** Why the proposal was rejected by the core */ + rejectionReason?: Maybe; + /** Equity-like share required for a market amendment proposal to be enacted (if not met, the proposal will not be enacted), represented as a fraction that can be converted to a percentage */ + requiredLpMajority?: Maybe; + /** The market share of LPs' equity-like share that must take part in the market amendment vote for the proposal to pass. This means the votes of LPs that have submitted more liquidity to that market, or have been LPs from the start carry more weight. If it requires 50% of a market's equity-like share for a majority, and the proposal receives only YES votes but only LPs with 49% of the equity-like share voted, the proposal will not pass */ + requiredLpParticipation?: Maybe; + /** Required majority for this proposal to succeed */ + requiredMajority: Scalars['String']; + /** Required participation for this proposal to succeed */ + requiredParticipation: Scalars['String']; + /** State of the proposal */ + state: ProposalState; + /** Terms of the proposal */ + terms: ProposalTerms; +}; + /** Edge type containing the proposals and cursor information returned by a ProposalsConnection */ export type ProposalEdge = { __typename?: 'ProposalEdge'; @@ -3234,6 +3414,8 @@ export type Query = { deposit?: Maybe; /** Fetch all deposits */ deposits?: Maybe; + /** Fetch all entities for a given transaction hash */ + entities: Entities; /** Get data for a specific epoch, if ID omitted it gets the current epoch. If the string is 'next', fetch the next epoch */ epoch: Epoch; /** List reward summary per epoch by asset, market, reward type */ @@ -3249,15 +3431,17 @@ export type Query = { /** Find an erc20 withdrawal approval using its withdrawal ID */ erc20WithdrawalApproval?: Maybe; /** Return an estimation of the potential cost for a new order */ + estimateFees: FeeEstimate; + /** + * Return an estimation of the potential cost for a new order + * @deprecated Use estimateFees and estimatePosition instead + */ estimateOrder: OrderEstimate; + /** Return a margin range for the specified position and liquidation price range if available collateral is supplied */ + estimatePosition?: Maybe; /** Query for historic ethereum key rotations */ ethereumKeyRotations: EthereumKeyRotationsConnection; - /** - * Get market data history for a specific market. If no dates are given, the latest snapshot will be returned. If only the start date is provided, all history from the given date will be provided, and if only the end date is provided, all history from the start up to and including the end date will be provided. - * @deprecated Use getMarketDataHistoryConnectionByID instead - */ - getMarketDataHistoryByID?: Maybe>>; - /** Get market data history for a specific market. If no dates are given, the latest snapshot will be returned. If only the start date is provided all history from the given date will be provided, and if only the end date is provided, all history from the start up to and including the end date will be provided. Pagination is provided using a cursor based pagination model */ + /** Get market data history for a specific market. If no dates are given, the latest snapshot will be returned. If only the start date is provided all history from the given date will be provided, and if only the end date is provided, all history from the start up to and including the end date will be provided. */ getMarketDataHistoryConnectionByID?: Maybe; /** Query for historic key rotations */ keyRotationsConnection: KeyRotationConnection; @@ -3315,6 +3499,8 @@ export type Query = { protocolUpgradeStatus?: Maybe; /** Get statistics about the Vega node */ statistics: Statistics; + /** Get a list of all trades and apply any given filters to the results */ + trades?: Maybe; /** Get a list of all transfers for a public key */ transfersConnection?: Maybe; /** Find a withdrawal using its ID */ @@ -3364,6 +3550,12 @@ export type QuerydepositsArgs = { }; +/** Queries allow a caller to read data and filter data via GraphQL. */ +export type QueryentitiesArgs = { + txHash: Scalars['String']; +}; + + /** Queries allow a caller to read data and filter data via GraphQL. */ export type QueryepochArgs = { id?: InputMaybe; @@ -3413,6 +3605,19 @@ export type Queryerc20WithdrawalApprovalArgs = { }; +/** Queries allow a caller to read data and filter data via GraphQL. */ +export type QueryestimateFeesArgs = { + expiration?: InputMaybe; + marketId: Scalars['ID']; + partyId: Scalars['ID']; + price?: InputMaybe; + side: Side; + size: Scalars['String']; + timeInForce: OrderTimeInForce; + type: OrderType; +}; + + /** Queries allow a caller to read data and filter data via GraphQL. */ export type QueryestimateOrderArgs = { expiration?: InputMaybe; @@ -3427,19 +3632,17 @@ export type QueryestimateOrderArgs = { /** Queries allow a caller to read data and filter data via GraphQL. */ -export type QueryethereumKeyRotationsArgs = { - nodeId?: InputMaybe; +export type QueryestimatePositionArgs = { + collateralAvailable?: InputMaybe; + marketId: Scalars['ID']; + openVolume: Scalars['String']; + orders?: InputMaybe>; }; /** Queries allow a caller to read data and filter data via GraphQL. */ -export type QuerygetMarketDataHistoryByIDArgs = { - end?: InputMaybe; - first?: InputMaybe; - id: Scalars['ID']; - last?: InputMaybe; - skip?: InputMaybe; - start?: InputMaybe; +export type QueryethereumKeyRotationsArgs = { + nodeId?: InputMaybe; }; @@ -3600,6 +3803,14 @@ export type QueryprotocolUpgradeProposalsArgs = { }; +/** Queries allow a caller to read data and filter data via GraphQL. */ +export type QuerytradesArgs = { + dateRange?: InputMaybe; + filter?: InputMaybe; + pagination?: InputMaybe; +}; + + /** Queries allow a caller to read data and filter data via GraphQL. */ export type QuerytransfersConnectionArgs = { direction?: InputMaybe; @@ -3798,7 +4009,9 @@ export enum Side { /** The placer of the order is aiming to buy */ SIDE_BUY = 'SIDE_BUY', /** The placer of the order is aiming to sell */ - SIDE_SELL = 'SIDE_SELL' + SIDE_SELL = 'SIDE_SELL', + /** Unspecified is only used for trades at the end of an auction, where neither party acts as the aggressor. */ + SIDE_UNSPECIFIED = 'SIDE_UNSPECIFIED' } /** Signer is the authorized signature used for the data. */ @@ -3978,8 +4191,6 @@ export type Subscription = { busEvents?: Maybe>; /** Subscribe to the candles updates */ candles: Candle; - /** Subscribe to delegation data */ - delegations: Delegation; /** Subscribe to liquidity provisioning data */ liquidityProvisions?: Maybe>; /** Subscribe to the margin changes */ @@ -3996,10 +4207,13 @@ export type Subscription = { positions: Array; /** Subscribe to proposals. Leave out all arguments to receive all proposals */ proposals: Proposal; - /** Subscribe to reward details data */ - rewards: Reward; - /** Subscribe to the trades updates */ + /** + * Subscribe to the trades updates + * @deprecated Use tradesStream instead as it allows for filtering multiple markets and/or parties at once + */ trades?: Maybe>; + /** Subscribe to the trades updates */ + tradesStream?: Maybe>; /** Subscribe to votes, either by proposal ID or party ID */ votes: ProposalVote; }; @@ -4030,13 +4244,6 @@ export type SubscriptioncandlesArgs = { }; -/** Subscriptions allow a caller to receive new information as it is available from the Vega network. */ -export type SubscriptiondelegationsArgs = { - nodeId?: InputMaybe; - partyId?: InputMaybe; -}; - - /** Subscriptions allow a caller to receive new information as it is available from the Vega network. */ export type SubscriptionliquidityProvisionsArgs = { marketId?: InputMaybe; @@ -4089,16 +4296,15 @@ export type SubscriptionproposalsArgs = { /** Subscriptions allow a caller to receive new information as it is available from the Vega network. */ -export type SubscriptionrewardsArgs = { - assetId?: InputMaybe; +export type SubscriptiontradesArgs = { + marketId?: InputMaybe; partyId?: InputMaybe; }; /** Subscriptions allow a caller to receive new information as it is available from the Vega network. */ -export type SubscriptiontradesArgs = { - marketId?: InputMaybe; - partyId?: InputMaybe; +export type SubscriptiontradesStreamArgs = { + filter: TradesSubscriptionFilter; }; @@ -4251,6 +4457,19 @@ export type TradeUpdate = { type: TradeType; }; +/** Filter to apply to the trade connection query */ +export type TradesFilter = { + marketIds?: InputMaybe>; + orderIds?: InputMaybe>; + partyIds?: InputMaybe>; +}; + +/** Filter to apply to the trade subscription request */ +export type TradesSubscriptionFilter = { + marketIds?: InputMaybe>; + partyIds?: InputMaybe>; +}; + /** The result from processing a transaction */ export type TransactionResult = { __typename?: 'TransactionResult'; diff --git a/libs/types/src/global-types-mappings.ts b/libs/types/src/global-types-mappings.ts index eaf84b1e0..9eb11448e 100644 --- a/libs/types/src/global-types-mappings.ts +++ b/libs/types/src/global-types-mappings.ts @@ -172,7 +172,7 @@ export const OrderRejectionReasonMapping: { 'Cannot send IOC order during auction', ORDER_ERROR_EDIT_NOT_ALLOWED: 'Edit not allowed', ORDER_ERROR_EXPIRYAT_BEFORE_CREATEDAT: 'Expiry time before creation time', - ORDER_ERROR_GFA_CANNOT_SEND_ORDER_DURING_CONTINUOUS_TRADING: + ORDER_ERROR_CANNOT_SEND_GFA_ORDER_DURING_CONTINUOUS_TRADING: 'Cannot send GFA order during continuous trading', ORDER_ERROR_INSUFFICIENT_ASSET_BALANCE: 'Insufficient asset balance', ORDER_ERROR_INSUFFICIENT_FUNDS_TO_PAY_FEES: 'Insufficient funds to pay fees', @@ -209,6 +209,11 @@ export const OrderRejectionReasonMapping: { 'Unable to amend price on pegged order', ORDER_ERROR_UNABLE_TO_REPRICE_PEGGED_ORDER: 'Unable to reprice pegged order', ORDER_ERROR_WITHOUT_REFERENCE_PRICE: 'Without reference price', + ORDER_ERROR_INCORRECT_MARKET_TYPE: 'Incorrect market type', + ORDER_ERROR_POST_ONLY_ORDER_WOULD_TRADE: 'Post only order would trade', + ORDER_ERROR_REDUCE_ONLY_ORDER_WOULD_NOT_REDUCE: + 'Reduce only order would not reduce', + ORDER_ERROR_TOO_MANY_PEGGED_ORDERS: 'Too many pegged orders', }; /** @@ -345,6 +350,7 @@ export const SideMapping: { } = { SIDE_BUY: 'Long', SIDE_SELL: 'Short', + SIDE_UNSPECIFIED: 'Unspecified', }; /** @@ -458,6 +464,7 @@ export const PositionStatusMapping: { POSITION_STATUS_CLOSED_OUT: 'Closed by network', POSITION_STATUS_ORDERS_CLOSED: 'Maintained by network', POSITION_STATUS_UNSPECIFIED: 'Normal', + POSITION_STATUS_DISTRESSED: 'Distressed', }; export const ConditionOperatorMapping: { [C in ConditionOperator]: string } = { diff --git a/libs/ui-toolkit/src/components/dialog/dialog.tsx b/libs/ui-toolkit/src/components/dialog/dialog.tsx index 2b886b42a..21918b352 100644 --- a/libs/ui-toolkit/src/components/dialog/dialog.tsx +++ b/libs/ui-toolkit/src/components/dialog/dialog.tsx @@ -62,7 +62,7 @@ export function Dialog({ onChange?.(x)}> ; + +const Template: ComponentStory = (args) => { + return ( +
+
+ +
+
+ ); +}; + +export const Default = Template.bind({}); +Default.args = {}; + +export const Vertical = Template.bind({}); +Vertical.args = { + orientation: 'vertical', +}; diff --git a/libs/ui-toolkit/src/components/divider/divider.tsx b/libs/ui-toolkit/src/components/divider/divider.tsx new file mode 100644 index 000000000..136cc3d46 --- /dev/null +++ b/libs/ui-toolkit/src/components/divider/divider.tsx @@ -0,0 +1,19 @@ +import { forwardRef } from 'react'; +import * as Separator from '@radix-ui/react-separator'; + +interface DividerProps { + orientation?: 'horizontal' | 'vertical'; + decorative?: boolean; +} + +export const Divider = forwardRef( + ({ orientation = 'horizontal', decorative }, ref) => { + return ( + + ); + } +); diff --git a/libs/ui-toolkit/src/components/divider/index.ts b/libs/ui-toolkit/src/components/divider/index.ts new file mode 100644 index 000000000..0dd50b568 --- /dev/null +++ b/libs/ui-toolkit/src/components/divider/index.ts @@ -0,0 +1 @@ +export { Divider } from './divider'; diff --git a/libs/ui-toolkit/src/components/dropdown-menu/dropdown-menu.tsx b/libs/ui-toolkit/src/components/dropdown-menu/dropdown-menu.tsx index 5f0885541..70d48778e 100644 --- a/libs/ui-toolkit/src/components/dropdown-menu/dropdown-menu.tsx +++ b/libs/ui-toolkit/src/components/dropdown-menu/dropdown-menu.tsx @@ -2,13 +2,14 @@ import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu'; import classNames from 'classnames'; import type { ReactNode } from 'react'; import { forwardRef } from 'react'; +import type { IconName } from '../icon'; import { Icon } from '../icon'; const itemClass = classNames( 'relative flex items-center justify-between rounded-sm p-2 text-sm', 'cursor-default hover:cursor-pointer', - 'hover:bg-white dark:hover:bg-neutral-200', - 'focus:bg-white dark:focus:bg-neutral-200', + 'hover:bg-white dark:hover:bg-vega-dark-200', + 'focus:bg-white dark:focus:bg-vega-dark-200', 'select-none', 'whitespace-nowrap' ); @@ -16,6 +17,11 @@ const itemClass = classNames( type DropdownMenuProps = DropdownMenuPrimitive.DropdownMenuProps & { trigger: ReactNode; }; + +type DropdownTriggerProps = DropdownMenuPrimitive.DropdownMenuTriggerProps & { + iconName?: IconName; +}; + /** * Contains all the parts of a dropdown menu. */ @@ -37,22 +43,20 @@ export const DropdownMenu = ({ */ export const DropdownMenuTrigger = forwardRef< React.ElementRef, - React.ComponentProps ->(({ className, children, ...props }, forwardedRef) => { - const triggerClasses = classNames( - className, - 'text-sm py-1 px-2 rounded bg-transparent border border-neutral-500 whitespace-nowrap', - 'hover:bg-neutral-500/20 dark:hover:bg-neutral-500/40' - ); + DropdownTriggerProps +>(({ className, children, iconName, ...props }, forwardedRef) => { + const defaultClasses = + 'text-sm py-1 px-2 rounded bg-transparent border border-vega-dark-200 whitespace-nowrap dark:hover:bg-vega-dark-500/20 hover:bg-vega-light-500/40'; + return ( ); @@ -73,7 +77,7 @@ export const DropdownMenuContent = forwardRef< @@ -115,9 +119,9 @@ export const DropdownMenuRadioItem = forwardRef< React.ComponentProps & { inset?: boolean; } ->(({ className, inset = false, ...radioItemprops }, forwardedRef) => ( +>(({ className, inset = false, ...radioItemProps }, forwardedRef) => ( @@ -151,7 +155,7 @@ export const DropdownMenuSeparator = forwardRef< {...separatorProps} ref={forwardedRef} className={classNames( - 'h-px my-1 mx-2 bg-neutral-400 dark:bg-neutral-300', + 'h-px my-1 mx-2 bg-vega-dark-400 dark:bg-vega-dark-300', className )} /> diff --git a/libs/ui-toolkit/src/components/icon/icon.spec.tsx b/libs/ui-toolkit/src/components/icon/blueprint-icons/icon.spec.tsx similarity index 100% rename from libs/ui-toolkit/src/components/icon/icon.spec.tsx rename to libs/ui-toolkit/src/components/icon/blueprint-icons/icon.spec.tsx diff --git a/libs/ui-toolkit/src/components/icon/icon.stories.tsx b/libs/ui-toolkit/src/components/icon/blueprint-icons/icon.stories.tsx similarity index 100% rename from libs/ui-toolkit/src/components/icon/icon.stories.tsx rename to libs/ui-toolkit/src/components/icon/blueprint-icons/icon.stories.tsx diff --git a/libs/ui-toolkit/src/components/icon/icon.tsx b/libs/ui-toolkit/src/components/icon/blueprint-icons/icon.tsx similarity index 100% rename from libs/ui-toolkit/src/components/icon/icon.tsx rename to libs/ui-toolkit/src/components/icon/blueprint-icons/icon.tsx diff --git a/libs/ui-toolkit/src/components/icon/blueprint-icons/index.ts b/libs/ui-toolkit/src/components/icon/blueprint-icons/index.ts new file mode 100644 index 000000000..af77d84ef --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/blueprint-icons/index.ts @@ -0,0 +1 @@ +export * from './icon'; diff --git a/libs/ui-toolkit/src/components/icon/index.ts b/libs/ui-toolkit/src/components/icon/index.ts index af77d84ef..f02899246 100644 --- a/libs/ui-toolkit/src/components/icon/index.ts +++ b/libs/ui-toolkit/src/components/icon/index.ts @@ -1 +1,2 @@ -export * from './icon'; +export * from './blueprint-icons'; +export * from './vega-icons'; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/index.ts b/libs/ui-toolkit/src/components/icon/vega-icons/index.ts new file mode 100644 index 000000000..a84f70849 --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/index.ts @@ -0,0 +1,3 @@ +export * from './vega-icon'; +export * from './vega-icon.stories'; +export * from './vega-icon-record'; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-breakdown.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-breakdown.tsx new file mode 100644 index 000000000..43c910f86 --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-breakdown.tsx @@ -0,0 +1,29 @@ +export const IconBreakdown = ({ size = 16 }: { size: number }) => { + return ( + + + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-copy.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-copy.tsx new file mode 100644 index 000000000..8873fa553 --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-copy.tsx @@ -0,0 +1,18 @@ +export const IconCopy = ({ size = 16 }: { size: number }) => { + return ( + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-deposit.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-deposit.tsx new file mode 100644 index 000000000..c0d15dc2d --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-deposit.tsx @@ -0,0 +1,17 @@ +export const IconDeposit = ({ size = 16 }: { size: number }) => { + return ( + + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-edit.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-edit.tsx new file mode 100644 index 000000000..fadb9a59f --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-edit.tsx @@ -0,0 +1,18 @@ +export const IconEdit = ({ size = 16 }: { size: number }) => { + return ( + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-forum.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-forum.tsx new file mode 100644 index 000000000..6874233e5 --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-forum.tsx @@ -0,0 +1,18 @@ +export const IconForum = ({ size = 24 }: { size: number }) => { + return ( + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-globe.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-globe.tsx new file mode 100644 index 000000000..64137f532 --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-globe.tsx @@ -0,0 +1,18 @@ +export const IconGlobe = ({ size = 24 }: { size: number }) => { + return ( + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-linkedin.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-linkedin.tsx new file mode 100644 index 000000000..589b59a45 --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-linkedin.tsx @@ -0,0 +1,16 @@ +export const IconLinkedIn = ({ size = 24 }: { size: number }) => { + return ( + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-moon.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-moon.tsx new file mode 100644 index 000000000..038695aa6 --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-moon.tsx @@ -0,0 +1,23 @@ +export const IconMoon = ({ size = 16 }: { size: number }) => { + return ( + + + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-open-external.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-open-external.tsx new file mode 100644 index 000000000..70ce980ec --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-open-external.tsx @@ -0,0 +1,16 @@ +export const IconOpenExternal = ({ size = 24 }: { size: number }) => { + return ( + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-question-mark.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-question-mark.tsx new file mode 100644 index 000000000..f329f012c --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-question-mark.tsx @@ -0,0 +1,18 @@ +export const IconQuestionMark = ({ size = 16 }: { size: number }) => { + return ( + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-transfer.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-transfer.tsx new file mode 100644 index 000000000..1542a9633 --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-transfer.tsx @@ -0,0 +1,20 @@ +export const IconTransfer = ({ size = 16 }: { size: number }) => { + return ( + + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-twitter.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-twitter.tsx new file mode 100644 index 000000000..893025e51 --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-twitter.tsx @@ -0,0 +1,16 @@ +export const IconTwitter = ({ size = 24 }: { size: number }) => { + return ( + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-withdraw.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-withdraw.tsx new file mode 100644 index 000000000..e2d89b1ae --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/svg-icons/icon-withdraw.tsx @@ -0,0 +1,17 @@ +export const IconWithdraw = ({ size = 16 }: { size: number }) => { + return ( + + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/vega-icon-record.ts b/libs/ui-toolkit/src/components/icon/vega-icons/vega-icon-record.ts new file mode 100644 index 000000000..2b4723cbb --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/vega-icon-record.ts @@ -0,0 +1,48 @@ +import { IconBreakdown } from './svg-icons/icon-breakdown'; +import { IconCopy } from './svg-icons/icon-copy'; +import { IconDeposit } from './svg-icons/icon-deposit'; +import { IconWithdraw } from './svg-icons/icon-withdraw'; +import { IconTransfer } from './svg-icons/icon-transfer'; +import { IconEdit } from './svg-icons/icon-edit'; +import { IconMoon } from './svg-icons/icon-moon'; +import { IconGlobe } from './svg-icons/icon-globe'; +import { IconLinkedIn } from './svg-icons/icon-linkedin'; +import { IconTwitter } from './svg-icons/icon-twitter'; +import { IconQuestionMark } from './svg-icons/icon-question-mark'; +import { IconForum } from './svg-icons/icon-forum'; +import { IconOpenExternal } from './svg-icons/icon-open-external'; + +export enum VegaIconNames { + BREAKDOWN = 'breakdown', + COPY = 'copy', + DEPOSIT = 'deposit', + WITHDRAW = 'withdraw', + EDIT = 'edit', + TRANSFER = 'transfer', + FORUM = 'forum', + GLOBE = 'globe', + LINKEDIN = 'linkedin', + TWITTER = 'twitter', + MOON = 'moon', + OPEN_EXTERNAL = 'open-external', + QUESTION_MARK = 'question-mark', +} + +export const VegaIconNameMap: Record< + VegaIconNames, + ({ size }: { size: number }) => JSX.Element +> = { + breakdown: IconBreakdown, + copy: IconCopy, + deposit: IconDeposit, + withdraw: IconWithdraw, + transfer: IconTransfer, + edit: IconEdit, + moon: IconMoon, + globe: IconGlobe, + linkedin: IconLinkedIn, + twitter: IconTwitter, + 'question-mark': IconQuestionMark, + forum: IconForum, + 'open-external': IconOpenExternal, +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/vega-icon.spec.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/vega-icon.spec.tsx new file mode 100644 index 000000000..4faaee577 --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/vega-icon.spec.tsx @@ -0,0 +1,11 @@ +import { render } from '@testing-library/react'; + +import { VegaIcon } from './vega-icon'; +import { VegaIconNames } from './vega-icon-record'; + +describe('VegaIcon', () => { + it('should render successfully', () => { + const { baseElement } = render(); + expect(baseElement).toBeTruthy(); + }); +}); diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/vega-icon.stories.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/vega-icon.stories.tsx new file mode 100644 index 000000000..ae42d2676 --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/vega-icon.stories.tsx @@ -0,0 +1,28 @@ +import type { Story, Meta } from '@storybook/react'; +import type { VegaIconProps } from './vega-icon'; +import { VegaIcon } from './vega-icon'; +import { VegaIconNames } from './vega-icon-record'; + +export default { + component: VegaIcon, + title: 'VegaIcon', +} as Meta; + +const Template: Story = (args) => ; + +export const Small = Template.bind({}); +Small.args = { + name: VegaIconNames.BREAKDOWN, +}; + +export const Bigger = Template.bind({}); +Bigger.args = { + name: VegaIconNames.DEPOSIT, + size: 24, +}; + +export const EvenBigger = Template.bind({}); +EvenBigger.args = { + name: VegaIconNames.GLOBE, + size: 32, +}; diff --git a/libs/ui-toolkit/src/components/icon/vega-icons/vega-icon.tsx b/libs/ui-toolkit/src/components/icon/vega-icons/vega-icon.tsx new file mode 100644 index 000000000..a5f497278 --- /dev/null +++ b/libs/ui-toolkit/src/components/icon/vega-icons/vega-icon.tsx @@ -0,0 +1,24 @@ +import classNames from 'classnames'; + +import type { VegaIconNames } from './vega-icon-record'; +import { VegaIconNameMap } from './vega-icon-record'; + +export interface VegaIconProps { + name: VegaIconNames; + size?: 16 | 24 | 32; +} + +export const VegaIcon = ({ size = 16, name }: VegaIconProps) => { + const effectiveClassName = classNames( + 'inline-block', + 'align-text-bottom', + 'pr-1', + 'stroke-current' + ); + const Element = VegaIconNameMap[name]; + return ( + + + + ); +}; diff --git a/libs/ui-toolkit/src/components/index.ts b/libs/ui-toolkit/src/components/index.ts index c2ef46544..2e2fb84fc 100644 --- a/libs/ui-toolkit/src/components/index.ts +++ b/libs/ui-toolkit/src/components/index.ts @@ -9,6 +9,7 @@ export * from './callout'; export * from './checkbox'; export * from './copy-with-tooltip'; export * from './dialog'; +export * from './divider'; export * from './drawer'; export * from './dropdown-menu'; export * from './form-group'; @@ -37,6 +38,7 @@ export * from './simple-grid'; export * from './slider'; export * from './sparkline'; export * from './splash'; +export * from './switch'; export * from './syntax-highlighter'; export * from './tabs'; export * from './text-area'; diff --git a/libs/ui-toolkit/src/components/switch/index.ts b/libs/ui-toolkit/src/components/switch/index.ts new file mode 100644 index 000000000..675ddba51 --- /dev/null +++ b/libs/ui-toolkit/src/components/switch/index.ts @@ -0,0 +1 @@ +export { Switch } from './switch'; diff --git a/libs/ui-toolkit/src/components/switch/switch.stories.tsx b/libs/ui-toolkit/src/components/switch/switch.stories.tsx new file mode 100644 index 000000000..f3c0f8289 --- /dev/null +++ b/libs/ui-toolkit/src/components/switch/switch.stories.tsx @@ -0,0 +1,31 @@ +import type { Story, ComponentMeta } from '@storybook/react'; +import type { SwitchProps } from './switch'; +import { Switch } from './switch'; +import { useState } from 'react'; + +export default { + component: Switch, + title: 'Switch', +} as ComponentMeta; + +const Template: Story = (args) => { + const [checked, setChecked] = useState(args.checked || false); + return ( + setChecked(checked)} + /> + ); +}; + +export const Default = Template.bind({}); +Default.args = { + name: 'switch', +}; + +export const WithTextLabel = Template.bind({}); +WithTextLabel.args = { + name: 'switch', + labelText: 'Light mode', +}; diff --git a/libs/ui-toolkit/src/components/switch/switch.tsx b/libs/ui-toolkit/src/components/switch/switch.tsx new file mode 100644 index 000000000..f20a0daf6 --- /dev/null +++ b/libs/ui-toolkit/src/components/switch/switch.tsx @@ -0,0 +1,38 @@ +import type { ReactNode } from 'react'; +import { forwardRef } from 'react'; +import * as RootSwitch from '@radix-ui/react-switch'; + +export interface SwitchProps { + name?: string; + onCheckedChange?: (checked: boolean) => void; + checked?: boolean; + disabled?: boolean; + labelText?: ReactNode | string; +} + +export const Switch = forwardRef( + ( + { name = 'switch', labelText, onCheckedChange, checked = false, disabled }, + ref + ) => { + return ( +
+ + + + {labelText && ( + + )} +
+ ); + } +); diff --git a/libs/ui-toolkit/src/components/theme-switcher/theme-switcher.tsx b/libs/ui-toolkit/src/components/theme-switcher/theme-switcher.tsx index 6ca96ecc6..1b065f75e 100644 --- a/libs/ui-toolkit/src/components/theme-switcher/theme-switcher.tsx +++ b/libs/ui-toolkit/src/components/theme-switcher/theme-switcher.tsx @@ -17,6 +17,7 @@ export const ThemeSwitcher = ({ onClick={() => setTheme()} className={className} data-testid="theme-switcher" + id="theme-switcher" > {theme === 'dark' && } {theme === 'light' && } diff --git a/libs/utils/src/index.ts b/libs/utils/src/index.ts index f099ed873..15f600113 100644 --- a/libs/utils/src/index.ts +++ b/libs/utils/src/index.ts @@ -17,3 +17,4 @@ export * from './lib/remove-0x'; export * from './lib/remove-pagination-wrapper'; export * from './lib/time'; export * from './lib/validate'; +export * from './lib/sentry-utils'; diff --git a/libs/utils/src/lib/sentry-utils.spec.ts b/libs/utils/src/lib/sentry-utils.spec.ts new file mode 100644 index 000000000..731405620 --- /dev/null +++ b/libs/utils/src/lib/sentry-utils.spec.ts @@ -0,0 +1,26 @@ +import * as Sentry from '@sentry/nextjs'; +import { SentryInit, SentryClose } from './sentry-utils'; + +jest.mock('@sentry/nextjs'); + +describe('Sentry utlis', () => { + describe('SentryInit', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('should initialize', () => { + SentryInit('sentry.dsn'); + expect(Sentry.init).toHaveBeenCalled(); + }); + it('should do nothing', () => { + SentryInit(''); + expect(Sentry.init).not.toHaveBeenCalled(); + }); + + it('should close', () => { + SentryClose(); + expect(Sentry.close).toHaveBeenCalled(); + }); + }); +}); diff --git a/libs/utils/src/lib/sentry-utils.ts b/libs/utils/src/lib/sentry-utils.ts new file mode 100644 index 000000000..a308bebb0 --- /dev/null +++ b/libs/utils/src/lib/sentry-utils.ts @@ -0,0 +1,15 @@ +import * as Sentry from '@sentry/nextjs'; +import { BrowserTracing } from '@sentry/tracing'; + +export const SentryInit = (dsn: string, env?: string) => { + if (dsn) { + Sentry.init({ + dsn, + integrations: [new BrowserTracing()], + tracesSampleRate: 1, + environment: env || '', + }); + } +}; + +export const SentryClose = () => Sentry.close(); diff --git a/libs/web3/src/lib/use-eager-connect.ts b/libs/web3/src/lib/use-eager-connect.ts index dd1c741ca..647d19e2e 100644 --- a/libs/web3/src/lib/use-eager-connect.ts +++ b/libs/web3/src/lib/use-eager-connect.ts @@ -1,3 +1,4 @@ +import type { LoggerProps } from '@vegaprotocol/react-helpers'; import { useLocalStorage, useLogger } from '@vegaprotocol/react-helpers'; import type { Web3ReactHooks } from '@web3-react/core'; import { MetaMask } from '@web3-react/metamask'; @@ -8,12 +9,12 @@ import { useWeb3ConnectStore } from './web3-connect-store'; export const ETHEREUM_EAGER_CONNECT = 'ethereum-eager-connect'; -export const useEagerConnect = (sentryDsn?: string) => { +export const useEagerConnect = (loggerConf: LoggerProps) => { const connectors = useWeb3ConnectStore((store) => store.connectors); const [eagerConnector] = useLocalStorage(ETHEREUM_EAGER_CONNECT); const attemptedRef = useRef(false); - const logger = useLogger({ dsn: sentryDsn }); + const logger = useLogger(loggerConf); useEffect(() => { if (attemptedRef.current || 'Cypress' in window) return; diff --git a/package.json b/package.json index 4dcb3db01..35ba287e7 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,9 @@ "@radix-ui/react-popover": "^1.0.3", "@radix-ui/react-radio-group": "^1.1.1", "@radix-ui/react-select": "^1.2.0", + "@radix-ui/react-separator": "^1.0.2", "@radix-ui/react-slider": "^1.1.0", + "@radix-ui/react-switch": "^1.0.2", "@radix-ui/react-tabs": "^1.0.2", "@radix-ui/react-tooltip": "^1.0.3", "@sentry/nextjs": "^6.19.3", @@ -202,6 +204,8 @@ "*.{ts,tsx,js,jsx}": "yarn eslint --fix" }, "resolutions": { - "graphql": "15.8.0" + "graphql": "15.8.0", + "//": "workaround storybook issue: https://github.com/storybookjs/storybook/issues/21642", + "@storybook/react-docgen-typescript-plugin": "1.0.6--canary.9.cd77847.0" } } diff --git a/vegacapsule/genesis.tmpl b/vegacapsule/genesis.tmpl index 061ec2c0e..692bd7efc 100644 --- a/vegacapsule/genesis.tmpl +++ b/vegacapsule/genesis.tmpl @@ -1,7 +1,7 @@ { "app_state": { "assets": { - "fBTC": { + "73174a6fb1d5802ba0ac7bd7ab79e0a3a4837b262de0a4e80815a55442692bd0": { "min_lp_stake": "1", "decimals": 5, "name": "BTC (fake)", @@ -13,7 +13,7 @@ } } }, - "fDAI": { + "8566db7257222b5b7ef2886394ad28b938b28680a54a169bbc795027b89d6665": { "min_lp_stake": "1", "decimals": 5, "name": "DAI (fake)", @@ -25,7 +25,7 @@ } } }, - "fEURO": { + "e02d4c15d790d1d2dffaf2dcd1cf06a1fe656656cf4ed18c8ce99f9e83643567": { "min_lp_stake": "1", "decimals": 5, "name": "EURO (fake)", @@ -37,7 +37,7 @@ } } }, - "fUSDC": { + "816af99af60d684502a40824758f6b5377e6af48e50a9ee8ef478ecb879ea8bc": { "min_lp_stake": "1", "decimals": 5, "name": "USDC (fake)", @@ -49,7 +49,7 @@ } } }, - "XYZalpha": { + "62dfb1ab1cd488862b416cf163c75bc9a279226c65ac287c0dd67650daa444ee": { "min_lp_stake": "1", "decimals": 5, "name": "XYZ (α alpha)", @@ -61,7 +61,7 @@ } } }, - "XYZbeta": { + "dedb3c42e7bc88d98a7fe0d73c7b9870b34c62c79a713071bd4d645ef7c216ee": { "min_lp_stake": "1", "decimals": 5, "name": "XYZ (β beta)", @@ -73,7 +73,7 @@ } } }, - "XYZgamma": { + "a0ea8a48eb5cb024e66be5777bea75165ffcaf0be82d9047e376ce352e202f76": { "min_lp_stake": "1", "decimals": 5, "name": "XYZ (γ gamma)", @@ -85,7 +85,7 @@ } } }, - "XYZdelta": { + "9ed5dd08c88e38f1c92cb8f056bd9d0507512c9ea4e6f308936f73646187b8e9": { "min_lp_stake": "1", "decimals": 5, "name": "XYZ (δ delta)", @@ -97,7 +97,7 @@ } } }, - "XYZepsilon": { + "bdcde894dcc4ffa11d6192065d84f9dcc75814cf24760ff4f3e50d64eaddbc02": { "min_lp_stake": "1", "decimals": 5, "name": "XYZ (ε epsilon)", diff --git a/yarn.lock b/yarn.lock index 3f70c1cf0..0bfb9d0d5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4609,6 +4609,14 @@ "@babel/runtime" "^7.13.10" "@radix-ui/react-slot" "1.0.1" +"@radix-ui/react-primitive@1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@radix-ui/react-primitive/-/react-primitive-1.0.2.tgz#54e22f49ca59ba88d8143090276d50b93f8a7053" + integrity sha512-zY6G5Qq4R8diFPNwtyoLRZBxzu1Z+SXMlfYpChN7Dv8gvmx9X3qhDqiLWvKseKVJMuedFeU/Sa0Sy/Ia+t06Dw== + dependencies: + "@babel/runtime" "^7.13.10" + "@radix-ui/react-slot" "1.0.1" + "@radix-ui/react-radio-group@^1.1.1": version "1.1.1" resolved "https://registry.yarnpkg.com/@radix-ui/react-radio-group/-/react-radio-group-1.1.1.tgz#564549b3e0a5905367dfe9adfe7b0e245cbdb640" @@ -4670,6 +4678,14 @@ aria-hidden "^1.1.1" react-remove-scroll "2.5.5" +"@radix-ui/react-separator@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@radix-ui/react-separator/-/react-separator-1.0.2.tgz#52417c8bfae1e4ef87356b2f7bffbc3dbbeddf23" + integrity sha512-lZoAG/rS2jzb/OSvyBrpN3dmikw20ewmWx1GkM1VldbDyD0DACCbH9LIXSrqyS/2mE1VYKOHmyq5W90Dx4ryqA== + dependencies: + "@babel/runtime" "^7.13.10" + "@radix-ui/react-primitive" "1.0.2" + "@radix-ui/react-slider@^1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@radix-ui/react-slider/-/react-slider-1.1.0.tgz#b3fdaca27619150e9e6067ad9f979a4535f68d5e" @@ -4696,6 +4712,20 @@ "@babel/runtime" "^7.13.10" "@radix-ui/react-compose-refs" "1.0.0" +"@radix-ui/react-switch@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@radix-ui/react-switch/-/react-switch-1.0.2.tgz#e3d1b9fe18b6b1173aadc8b8e6efdc96a28a70f8" + integrity sha512-BcG/LKehxt36NXG0wPnoCitIfSMtU9Xo7BmythYA1PAMLtsMvW7kALfBzmduQoHTWcKr0AVcFyh0gChBUp9TiQ== + dependencies: + "@babel/runtime" "^7.13.10" + "@radix-ui/primitive" "1.0.0" + "@radix-ui/react-compose-refs" "1.0.0" + "@radix-ui/react-context" "1.0.0" + "@radix-ui/react-primitive" "1.0.2" + "@radix-ui/react-use-controllable-state" "1.0.0" + "@radix-ui/react-use-previous" "1.0.0" + "@radix-ui/react-use-size" "1.0.0" + "@radix-ui/react-tabs@^1.0.2": version "1.0.2" resolved "https://registry.yarnpkg.com/@radix-ui/react-tabs/-/react-tabs-1.0.2.tgz#8f5ec73ca41b151a413bdd6e00553408ff34ce07" @@ -6266,17 +6296,17 @@ unfetch "^4.2.0" util-deprecate "^1.0.2" -"@storybook/react-docgen-typescript-plugin@1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0": - version "1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0" - resolved "https://registry.yarnpkg.com/@storybook/react-docgen-typescript-plugin/-/react-docgen-typescript-plugin-1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0.tgz#3103532ff494fb7dc3cf835f10740ecf6a26c0f9" - integrity sha512-eVg3BxlOm2P+chijHBTByr90IZVUtgRW56qEOLX7xlww2NBuKrcavBlcmn+HH7GIUktquWkMPtvy6e0W0NgA5w== +"@storybook/react-docgen-typescript-plugin@1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0", "@storybook/react-docgen-typescript-plugin@1.0.6--canary.9.cd77847.0": + version "1.0.6--canary.9.cd77847.0" + resolved "https://registry.yarnpkg.com/@storybook/react-docgen-typescript-plugin/-/react-docgen-typescript-plugin-1.0.6--canary.9.cd77847.0.tgz#35beed1bd0813569fc8852b372c92069fe74a448" + integrity sha512-I4oBYmnUCX5IsrZhg+ST72dubSIV4wdwY+SfqJiJ3NHvDpdb240ZjdHAmjIy/yJh5rh42Fl4jbG8Tr4SzwV53Q== dependencies: debug "^4.1.1" endent "^2.0.1" find-cache-dir "^3.3.1" flat-cache "^3.0.4" micromatch "^4.0.2" - react-docgen-typescript "^2.1.1" + react-docgen-typescript "^2.2.2" tslib "^2.0.0" "@storybook/react@6.5.10": @@ -20701,7 +20731,7 @@ react-copy-to-clipboard@^5.0.4: copy-to-clipboard "^3.3.1" prop-types "^15.8.1" -react-docgen-typescript@^2.1.1: +react-docgen-typescript@^2.2.2: version "2.2.2" resolved "https://registry.yarnpkg.com/react-docgen-typescript/-/react-docgen-typescript-2.2.2.tgz#4611055e569edc071204aadb20e1c93e1ab1659c" integrity sha512-tvg2ZtOpOi6QDwsb3GZhOjDkkX0h8Z2gipvTg6OVMUyoYoURhEiRNePT8NZItTVCDh39JJHnLdfCOkzoLbFnTg==