Merge branch 'master' of github.com:vegaprotocol/frontend-monorepo into fix/603-656-609-filter-rejected-markets-order-when-suspended-remove-trading-continuous

This commit is contained in:
madalinaraicu 2022-07-15 11:17:55 +02:00
commit b18b8da594
66 changed files with 1127 additions and 560 deletions

View File

@ -12,7 +12,6 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
GO111MODULE: 'on' GO111MODULE: 'on'
GOPROXY: ${{ secrets.GO_PROXY }}
steps: steps:
####### #######
## Setup langs ## Setup langs

View File

@ -14,7 +14,6 @@ jobs:
if: ${{ github.event_name == 'pull_request' }} if: ${{ github.event_name == 'pull_request' }}
env: env:
GO111MODULE: 'on' GO111MODULE: 'on'
GOPROXY: ${{ secrets.GO_PROXY }}
steps: steps:
####### #######
## Setup langs ## Setup langs

View File

@ -15,6 +15,8 @@ module.exports = defineConfig({
videosFolder: '../../dist/cypress/apps/explorer-e2e/videos', videosFolder: '../../dist/cypress/apps/explorer-e2e/videos',
screenshotsFolder: '../../dist/cypress/apps/explorer-e2e/screenshots', screenshotsFolder: '../../dist/cypress/apps/explorer-e2e/screenshots',
chromeWebSecurity: false, chromeWebSecurity: false,
viewportWidth: 1440,
viewportHeight: 900,
}, },
env: { env: {
environment: 'CUSTOM', environment: 'CUSTOM',

View File

@ -15,5 +15,7 @@ module.exports = defineConfig({
videosFolder: '../../dist/cypress/apps/explorer-e2e/videos', videosFolder: '../../dist/cypress/apps/explorer-e2e/videos',
screenshotsFolder: '../../dist/cypress/apps/explorer-e2e/screenshots', screenshotsFolder: '../../dist/cypress/apps/explorer-e2e/screenshots',
chromeWebSecurity: false, chromeWebSecurity: false,
viewportWidth: 1440,
viewportHeight: 900,
}, },
}); });

View File

@ -42,8 +42,8 @@ describe('market selector', () => {
.find('[role="button"]') .find('[role="button"]')
.should('have.length', 1); .should('have.length', 1);
cy.get('input[placeholder="Search"]').clear(); cy.get('input[placeholder="Search"]').clear();
cy.get('input[placeholder="Search"]').type('a'); cy.get('input[placeholder="Search"]').type('app');
const filtered = markets.filter((market) => market.name.match(/a/i)); const filtered = markets.filter((market) => market.name.match(/app/i));
cy.getByTestId('market-pane') cy.getByTestId('market-pane')
.children() .children()
.find('[role="button"]') .find('[role="button"]')
@ -76,7 +76,6 @@ describe('market selector', () => {
.children() .children()
.find('[role="button"]') .find('[role="button"]')
.should('have.length', markets.length); .should('have.length', markets.length);
cy.pause();
cy.getByTestId('dialog-close').click(); cy.getByTestId('dialog-close').click();
cy.get('input[placeholder="Search"]').should( cy.get('input[placeholder="Search"]').should(
'have.value', 'have.value',

View File

@ -71,7 +71,7 @@
"tranche_end": "2023-12-05T00:00:00.000Z", "tranche_end": "2023-12-05T00:00:00.000Z",
"total_added": "129999.45", "total_added": "129999.45",
"total_removed": "0", "total_removed": "0",
"locked_amount": "120687.60294909203186805", "locked_amount": "120450.26235752800414383",
"deposits": [ "deposits": [
{ {
"amount": "129999.45", "amount": "129999.45",
@ -521,7 +521,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z", "tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "97499.58", "total_added": "97499.58",
"total_removed": "0", "total_removed": "0",
"locked_amount": "61605.4975572212290407", "locked_amount": "61372.6885461730976664",
"deposits": [ "deposits": [
{ {
"amount": "97499.58", "amount": "97499.58",
@ -554,7 +554,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z", "tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "135173.4239508", "total_added": "135173.4239508",
"total_removed": "0", "total_removed": "0",
"locked_amount": "84204.0794152667057160273426", "locked_amount": "83885.86968996291364071230136",
"deposits": [ "deposits": [
{ {
"amount": "135173.4239508", "amount": "135173.4239508",
@ -587,7 +587,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z", "tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "32499.86", "total_added": "32499.86",
"total_removed": "0", "total_removed": "0",
"locked_amount": "25916.368952284834442322", "locked_amount": "25818.43022173346529338",
"deposits": [ "deposits": [
{ {
"amount": "32499.86", "amount": "32499.86",
@ -620,7 +620,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z", "tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "10833.29", "total_added": "10833.29",
"total_removed": "0", "total_removed": "0",
"locked_amount": "8435.52660747719195897", "locked_amount": "8403.648501057666105483",
"deposits": [ "deposits": [
{ {
"amount": "10833.29", "amount": "10833.29",
@ -708,7 +708,7 @@
"tranche_end": "2022-11-01T00:00:00.000Z", "tranche_end": "2022-11-01T00:00:00.000Z",
"total_added": "22500", "total_added": "22500",
"total_removed": "0", "total_removed": "0",
"locked_amount": "13420.127094655797", "locked_amount": "13297.7850430253625",
"deposits": [ "deposits": [
{ {
"amount": "15000", "amount": "15000",
@ -794,7 +794,7 @@
"tranche_end": "2023-06-02T00:00:00.000Z", "tranche_end": "2023-06-02T00:00:00.000Z",
"total_added": "1939928.38", "total_added": "1939928.38",
"total_removed": "179856.049568108351", "total_removed": "179856.049568108351",
"locked_amount": "1715358.109875174368620276", "locked_amount": "1710040.653982735209492448",
"deposits": [ "deposits": [
{ {
"amount": "1852091.69", "amount": "1852091.69",
@ -1846,7 +1846,7 @@
"tranche_end": "2022-09-30T00:00:00.000Z", "tranche_end": "2022-09-30T00:00:00.000Z",
"total_added": "60916.66666633337", "total_added": "60916.66666633337",
"total_removed": "19238.601152747179372649", "total_removed": "19238.601152747179372649",
"locked_amount": "12143.787034497502163478850106205", "locked_amount": "11987.514524408138935750336335075",
"deposits": [ "deposits": [
{ {
"amount": "2833.333333", "amount": "2833.333333",
@ -3330,8 +3330,8 @@
"tranche_id": 10, "tranche_id": 10,
"tranche_start": "2021-07-15T23:37:11.000Z", "tranche_start": "2021-07-15T23:37:11.000Z",
"tranche_end": "2021-07-15T23:37:11.000Z", "tranche_end": "2021-07-15T23:37:11.000Z",
"total_added": "3904968.150000000000000001", "total_added": "4170968.150000000000000001",
"total_removed": "3896778.640000000000000001", "total_removed": "4162778.640000000000000001",
"locked_amount": "0", "locked_amount": "0",
"deposits": [ "deposits": [
{ {
@ -3339,6 +3339,11 @@
"user": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f", "user": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f",
"tx": "0x167fe6c654897398dcfdab9305133b4410b15bac8f5a30bb1260a94a14a65aad" "tx": "0x167fe6c654897398dcfdab9305133b4410b15bac8f5a30bb1260a94a14a65aad"
}, },
{
"amount": "266000",
"user": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f",
"tx": "0x38ac30c041395b629839409fb10385426997cf40be0e3026dd726e7c77e019cc"
},
{ {
"amount": "30000", "amount": "30000",
"user": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f", "user": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f",
@ -3786,6 +3791,11 @@
"user": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f", "user": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f",
"tx": "0x873061bbe5702251e087833b87033296fef9c6fb4f6c2be7586e1e74e20a4f52" "tx": "0x873061bbe5702251e087833b87033296fef9c6fb4f6c2be7586e1e74e20a4f52"
}, },
{
"amount": "266000",
"user": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f",
"tx": "0x5b5515073f03593ae5cddd66030154af5847aedbd680835bbc1998a168e74699"
},
{ {
"amount": "30000", "amount": "30000",
"user": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f", "user": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f",
@ -4177,6 +4187,12 @@
"tranche_id": 10, "tranche_id": 10,
"tx": "0x167fe6c654897398dcfdab9305133b4410b15bac8f5a30bb1260a94a14a65aad" "tx": "0x167fe6c654897398dcfdab9305133b4410b15bac8f5a30bb1260a94a14a65aad"
}, },
{
"amount": "266000",
"user": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f",
"tranche_id": 10,
"tx": "0x38ac30c041395b629839409fb10385426997cf40be0e3026dd726e7c77e019cc"
},
{ {
"amount": "30000", "amount": "30000",
"user": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f", "user": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f",
@ -4281,6 +4297,12 @@
"tranche_id": 10, "tranche_id": 10,
"tx": "0x873061bbe5702251e087833b87033296fef9c6fb4f6c2be7586e1e74e20a4f52" "tx": "0x873061bbe5702251e087833b87033296fef9c6fb4f6c2be7586e1e74e20a4f52"
}, },
{
"amount": "266000",
"user": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f",
"tranche_id": 10,
"tx": "0x5b5515073f03593ae5cddd66030154af5847aedbd680835bbc1998a168e74699"
},
{ {
"amount": "30000", "amount": "30000",
"user": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f", "user": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f",
@ -4372,8 +4394,8 @@
"tx": "0xac16a4ce688d40a482a59914d68c3a676592f8804ee8f0781b66a4ba5ccfbdfc" "tx": "0xac16a4ce688d40a482a59914d68c3a676592f8804ee8f0781b66a4ba5ccfbdfc"
} }
], ],
"total_tokens": "745651", "total_tokens": "1011651",
"withdrawn_tokens": "745651", "withdrawn_tokens": "1011651",
"remaining_tokens": "0" "remaining_tokens": "0"
}, },
{ {
@ -5393,9 +5415,9 @@
"tranche_id": 11, "tranche_id": 11,
"tranche_start": "2021-09-03T00:00:00.000Z", "tranche_start": "2021-09-03T00:00:00.000Z",
"tranche_end": "2022-09-03T00:00:00.000Z", "tranche_end": "2022-09-03T00:00:00.000Z",
"total_added": "24284.000000000000000003", "total_added": "24344.000000000000000003",
"total_removed": "6875.88980798578", "total_removed": "7424.31284562443",
"locked_amount": "3376.2614414003058740004170970319634705", "locked_amount": "3317.87584195839735528040887395357686461",
"deposits": [ "deposits": [
{ {
"amount": "25", "amount": "25",
@ -5862,6 +5884,11 @@
"user": "0x44d145E145B7811ad309032D4c5CdeB1bf044719", "user": "0x44d145E145B7811ad309032D4c5CdeB1bf044719",
"tx": "0x8e664532cfa2031eb5f6ce7c99cd673fa767599654a35b73d76407ed46763ad4" "tx": "0x8e664532cfa2031eb5f6ce7c99cd673fa767599654a35b73d76407ed46763ad4"
}, },
{
"amount": "60",
"user": "0x44d145E145B7811ad309032D4c5CdeB1bf044719",
"tx": "0x23fdff0f268bba36817cb496454cbc4be34306eaaaf330d5d26134849c480153"
},
{ {
"amount": "75", "amount": "75",
"user": "0x3a380f7CFdEeb723228cA57d2795EA215094000d", "user": "0x3a380f7CFdEeb723228cA57d2795EA215094000d",
@ -9084,6 +9111,11 @@
"user": "0x3a380f7CFdEeb723228cA57d2795EA215094000d", "user": "0x3a380f7CFdEeb723228cA57d2795EA215094000d",
"tx": "0x4c4e0fd7a8adbad24d6cc6e8fdf4f832ac9a39b2a04b954ec0d77e36a79c0e90" "tx": "0x4c4e0fd7a8adbad24d6cc6e8fdf4f832ac9a39b2a04b954ec0d77e36a79c0e90"
}, },
{
"amount": "548.42303763865",
"user": "0x44d145E145B7811ad309032D4c5CdeB1bf044719",
"tx": "0x48c16186c1e0021ee4b7194df991c93ec3a26971d009a9a3aaaec67c0abc89e9"
},
{ {
"amount": "4.429693048", "amount": "4.429693048",
"user": "0xc5467213593778E528f0eB8117cc7AFBC5b7491b", "user": "0xc5467213593778E528f0eB8117cc7AFBC5b7491b",
@ -10086,12 +10118,25 @@
"user": "0x44d145E145B7811ad309032D4c5CdeB1bf044719", "user": "0x44d145E145B7811ad309032D4c5CdeB1bf044719",
"tranche_id": 11, "tranche_id": 11,
"tx": "0x8e664532cfa2031eb5f6ce7c99cd673fa767599654a35b73d76407ed46763ad4" "tx": "0x8e664532cfa2031eb5f6ce7c99cd673fa767599654a35b73d76407ed46763ad4"
},
{
"amount": "60",
"user": "0x44d145E145B7811ad309032D4c5CdeB1bf044719",
"tranche_id": 11,
"tx": "0x23fdff0f268bba36817cb496454cbc4be34306eaaaf330d5d26134849c480153"
} }
], ],
"withdrawals": [], "withdrawals": [
"total_tokens": "575", {
"withdrawn_tokens": "0", "amount": "548.42303763865",
"remaining_tokens": "575" "user": "0x44d145E145B7811ad309032D4c5CdeB1bf044719",
"tranche_id": 11,
"tx": "0x48c16186c1e0021ee4b7194df991c93ec3a26971d009a9a3aaaec67c0abc89e9"
}
],
"total_tokens": "635",
"withdrawn_tokens": "548.42303763865",
"remaining_tokens": "86.57696236135"
}, },
{ {
"address": "0x3a380f7CFdEeb723228cA57d2795EA215094000d", "address": "0x3a380f7CFdEeb723228cA57d2795EA215094000d",
@ -15925,7 +15970,7 @@
"tranche_end": "2023-06-05T00:00:00.000Z", "tranche_end": "2023-06-05T00:00:00.000Z",
"total_added": "3732368.4671", "total_added": "3732368.4671",
"total_removed": "106452.6400159857469", "total_removed": "106452.6400159857469",
"locked_amount": "2660409.42081862296035011689", "locked_amount": "2652238.43698016889396750676",
"deposits": [ "deposits": [
{ {
"amount": "1998.95815", "amount": "1998.95815",
@ -16659,8 +16704,8 @@
"tranche_start": "2022-06-05T00:00:00.000Z", "tranche_start": "2022-06-05T00:00:00.000Z",
"tranche_end": "2023-12-05T00:00:00.000Z", "tranche_end": "2023-12-05T00:00:00.000Z",
"total_added": "15788853.065470999700000001", "total_added": "15788853.065470999700000001",
"total_removed": "62889.84066484668888", "total_removed": "63288.646809993954255",
"locked_amount": "14657898.8329277585456883041909973431305758", "locked_amount": "14629073.3850061841914328106732955796688294",
"deposits": [ "deposits": [
{ {
"amount": "16249.93", "amount": "16249.93",
@ -17209,6 +17254,11 @@
"user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b",
"tx": "0x148f389a5771abdc96c5a51c1fc0e306d135763c60f6839db6763690022a1a36" "tx": "0x148f389a5771abdc96c5a51c1fc0e306d135763c60f6839db6763690022a1a36"
}, },
{
"amount": "398.806145147265375",
"user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b",
"tx": "0x4961efbe6ce942c38f74c5cbf8a5c7f8f6586c1bda1df0a17c7a1fd80aae6905"
},
{ {
"amount": "579.636872035866225", "amount": "579.636872035866225",
"user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b",
@ -17411,6 +17461,12 @@
"tranche_id": 2, "tranche_id": 2,
"tx": "0x148f389a5771abdc96c5a51c1fc0e306d135763c60f6839db6763690022a1a36" "tx": "0x148f389a5771abdc96c5a51c1fc0e306d135763c60f6839db6763690022a1a36"
}, },
{
"amount": "398.806145147265375",
"user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b",
"tranche_id": 2,
"tx": "0x4961efbe6ce942c38f74c5cbf8a5c7f8f6586c1bda1df0a17c7a1fd80aae6905"
},
{ {
"amount": "579.636872035866225", "amount": "579.636872035866225",
"user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b",
@ -17551,8 +17607,8 @@
} }
], ],
"total_tokens": "194999.1675", "total_tokens": "194999.1675",
"withdrawn_tokens": "13652.2521999360072", "withdrawn_tokens": "14051.058345083272575",
"remaining_tokens": "181346.9153000639928" "remaining_tokens": "180948.109154916727425"
}, },
{ {
"address": "0x89051CAb67Bc7F8CC44F7e270c6EDaf1EC57676c", "address": "0x89051CAb67Bc7F8CC44F7e270c6EDaf1EC57676c",
@ -18991,8 +19047,8 @@
"tranche_start": "2021-11-05T00:00:00.000Z", "tranche_start": "2021-11-05T00:00:00.000Z",
"tranche_end": "2023-05-05T00:00:00.000Z", "tranche_end": "2023-05-05T00:00:00.000Z",
"total_added": "14597706.0446472999", "total_added": "14597706.0446472999",
"total_removed": "2413723.131389663831937297", "total_removed": "2414153.780525405655617797",
"locked_amount": "7880269.64303812390931654596122858", "locked_amount": "7853521.23058973302728403033753401",
"deposits": [ "deposits": [
{ {
"amount": "129284.449", "amount": "129284.449",
@ -19276,6 +19332,11 @@
"user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b",
"tx": "0x5b2ba568e3f60b624456972f011948b6870274b94ddba2f11eb876b4e875be1a" "tx": "0x5b2ba568e3f60b624456972f011948b6870274b94ddba2f11eb876b4e875be1a"
}, },
{
"amount": "430.6491357418236805",
"user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b",
"tx": "0x63919ba0a519b04dfe5a5b222e5952117f1cdbb1e6194ae85b22a4ed8cef6fa5"
},
{ {
"amount": "509.31853983395369725", "amount": "509.31853983395369725",
"user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b",
@ -21004,6 +21065,12 @@
"tranche_id": 3, "tranche_id": 3,
"tx": "0x5b2ba568e3f60b624456972f011948b6870274b94ddba2f11eb876b4e875be1a" "tx": "0x5b2ba568e3f60b624456972f011948b6870274b94ddba2f11eb876b4e875be1a"
}, },
{
"amount": "430.6491357418236805",
"user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b",
"tranche_id": 3,
"tx": "0x63919ba0a519b04dfe5a5b222e5952117f1cdbb1e6194ae85b22a4ed8cef6fa5"
},
{ {
"amount": "509.31853983395369725", "amount": "509.31853983395369725",
"user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b",
@ -22350,8 +22417,8 @@
} }
], ],
"total_tokens": "359123.469575", "total_tokens": "359123.469575",
"withdrawn_tokens": "164980.154441085289241", "withdrawn_tokens": "165410.8035768271129215",
"remaining_tokens": "194143.315133914710759" "remaining_tokens": "193712.6659981728870785"
}, },
{ {
"address": "0xBdd412797c1B78535Afc5F71503b91fAbD0160fB", "address": "0xBdd412797c1B78535Afc5F71503b91fAbD0160fB",
@ -23414,8 +23481,8 @@
"tranche_start": "2021-10-05T00:00:00.000Z", "tranche_start": "2021-10-05T00:00:00.000Z",
"tranche_end": "2023-04-05T00:00:00.000Z", "tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "5778205.3912159303", "total_added": "5778205.3912159303",
"total_removed": "1543188.041113165491270727", "total_removed": "1572374.955637071973431516",
"locked_amount": "2796638.79189818404440572191528324", "locked_amount": "2786070.33236677382072939102631165",
"deposits": [ "deposits": [
{ {
"amount": "552496.6455", "amount": "552496.6455",
@ -23569,6 +23636,16 @@
"user": "0xafa64cCa337eFEE0AD827F6C2684e69275226e90", "user": "0xafa64cCa337eFEE0AD827F6C2684e69275226e90",
"tx": "0x9c4cfa505550e13a41c2eb84a767412539ccae45bb280b5235423aadce942f2e" "tx": "0x9c4cfa505550e13a41c2eb84a767412539ccae45bb280b5235423aadce942f2e"
}, },
{
"amount": "4864.10259512983202665",
"user": "0x6ae83EAB68b7112BaD5AfD72d6B24546AbFF137D",
"tx": "0x36fed3740bfbe979fd84ff55a1f65310eaf83047b27a9dc5516e083acfcc3b3f"
},
{
"amount": "24322.811928776650134139",
"user": "0xC24da173A250e9Ca5c54870639EbE5f88be5102d",
"tx": "0xc391f34bee2ee3186396191a8828e498e817ec73ebde827b525322561d6c10ac"
},
{ {
"amount": "4089.266768653121589", "amount": "4089.266768653121589",
"user": "0xafa64cCa337eFEE0AD827F6C2684e69275226e90", "user": "0xafa64cCa337eFEE0AD827F6C2684e69275226e90",
@ -24191,6 +24268,12 @@
} }
], ],
"withdrawals": [ "withdrawals": [
{
"amount": "4864.10259512983202665",
"user": "0x6ae83EAB68b7112BaD5AfD72d6B24546AbFF137D",
"tranche_id": 4,
"tx": "0x36fed3740bfbe979fd84ff55a1f65310eaf83047b27a9dc5516e083acfcc3b3f"
},
{ {
"amount": "3536.43115201266299695", "amount": "3536.43115201266299695",
"user": "0x6ae83EAB68b7112BaD5AfD72d6B24546AbFF137D", "user": "0x6ae83EAB68b7112BaD5AfD72d6B24546AbFF137D",
@ -24223,8 +24306,8 @@
} }
], ],
"total_tokens": "92082.572555", "total_tokens": "92082.572555",
"withdrawn_tokens": "42713.498699646151249", "withdrawn_tokens": "47577.60129477598327565",
"remaining_tokens": "49369.073855353848751" "remaining_tokens": "44504.97126022401672435"
}, },
{ {
"address": "0x1dC9B91DE003fd503F25cB5d114cf0fc68F7aFe6", "address": "0x1dC9B91DE003fd503F25cB5d114cf0fc68F7aFe6",
@ -24252,6 +24335,12 @@
} }
], ],
"withdrawals": [ "withdrawals": [
{
"amount": "24322.811928776650134139",
"user": "0xC24da173A250e9Ca5c54870639EbE5f88be5102d",
"tranche_id": 4,
"tx": "0xc391f34bee2ee3186396191a8828e498e817ec73ebde827b525322561d6c10ac"
},
{ {
"amount": "17683.07845319664597116", "amount": "17683.07845319664597116",
"user": "0xC24da173A250e9Ca5c54870639EbE5f88be5102d", "user": "0xC24da173A250e9Ca5c54870639EbE5f88be5102d",
@ -24290,8 +24379,8 @@
} }
], ],
"total_tokens": "460415.072915097", "total_tokens": "460415.072915097",
"withdrawn_tokens": "213567.593206108177102902", "withdrawn_tokens": "237890.405134884827237041",
"remaining_tokens": "246847.479708988822897098" "remaining_tokens": "222524.667780212172762959"
}, },
{ {
"address": "0xd66e4853c0880df150e7329974715BFC8d2da47D", "address": "0xd66e4853c0880df150e7329974715BFC8d2da47D",
@ -24615,7 +24704,7 @@
"tranche_end": "2023-06-05T00:00:00.000Z", "tranche_end": "2023-06-05T00:00:00.000Z",
"total_added": "472355.6199999996", "total_added": "472355.6199999996",
"total_removed": "279.2296426169", "total_removed": "279.2296426169",
"locked_amount": "421557.080277297961550599391172", "locked_amount": "420262.3411807600824310398427194",
"deposits": [ "deposits": [
{ {
"amount": "3000", "amount": "3000",
@ -50413,7 +50502,7 @@
"tranche_start": "2021-12-05T00:00:00.000Z", "tranche_start": "2021-12-05T00:00:00.000Z",
"tranche_end": "2022-06-05T00:00:00.000Z", "tranche_end": "2022-06-05T00:00:00.000Z",
"total_added": "171288.42", "total_added": "171288.42",
"total_removed": "36329.8823647506377", "total_removed": "36852.7133578316377",
"locked_amount": "0", "locked_amount": "0",
"deposits": [ "deposits": [
{ {
@ -54678,6 +54767,21 @@
"user": "0x5cce57661D758497446B57592D31667aafd60465", "user": "0x5cce57661D758497446B57592D31667aafd60465",
"tx": "0x8d9b31eaaecaa4f74f05f93d33e61d0691eba3a6f23a9033dbfcaeca1c9a00c4" "tx": "0x8d9b31eaaecaa4f74f05f93d33e61d0691eba3a6f23a9033dbfcaeca1c9a00c4"
}, },
{
"amount": "250",
"user": "0x57a88037954e15AFFDf9bc29097e0B5f5A1BfF35",
"tx": "0x3da3cd5b323439c576ad7a3410d833da0da994ee652b29dd751a4c0edbf0ca99"
},
{
"amount": "250",
"user": "0x5f3Bce4B242d00ED748d48172C1f2D47A0bcB19B",
"tx": "0xc06577f7fd53a100da581edbc8231a870d7b148329c8aa250eb942473004e5e6"
},
{
"amount": "22.830993081",
"user": "0xe627552C6338855983a147fa5235E5D92a3C2891",
"tx": "0x3c75d0f2db07e4b2c54411e3d1a6124e63bc0f99ca4d171bd8679158aee3e698"
},
{ {
"amount": "60.4448387275", "amount": "60.4448387275",
"user": "0xEe3183EcE9ee7d73Fb7bA7F4eB262A2dE68C42B0", "user": "0xEe3183EcE9ee7d73Fb7bA7F4eB262A2dE68C42B0",
@ -56736,6 +56840,12 @@
} }
], ],
"withdrawals": [ "withdrawals": [
{
"amount": "22.830993081",
"user": "0xe627552C6338855983a147fa5235E5D92a3C2891",
"tranche_id": 6,
"tx": "0x3c75d0f2db07e4b2c54411e3d1a6124e63bc0f99ca4d171bd8679158aee3e698"
},
{ {
"amount": "24.17784646", "amount": "24.17784646",
"user": "0xe627552C6338855983a147fa5235E5D92a3C2891", "user": "0xe627552C6338855983a147fa5235E5D92a3C2891",
@ -56756,8 +56866,8 @@
} }
], ],
"total_tokens": "100", "total_tokens": "100",
"withdrawn_tokens": "77.169006919", "withdrawn_tokens": "100",
"remaining_tokens": "22.830993081" "remaining_tokens": "0"
}, },
{ {
"address": "0x2394462d77c51A174D912E229d426917051af04F", "address": "0x2394462d77c51A174D912E229d426917051af04F",
@ -69757,10 +69867,17 @@
"tx": "0xe32a466fc780a0fb3fd84a804f622931ebfaf3f428bff0dc6d141270410e75f8" "tx": "0xe32a466fc780a0fb3fd84a804f622931ebfaf3f428bff0dc6d141270410e75f8"
} }
], ],
"withdrawals": [], "withdrawals": [
{
"amount": "250",
"user": "0x5f3Bce4B242d00ED748d48172C1f2D47A0bcB19B",
"tranche_id": 6,
"tx": "0xc06577f7fd53a100da581edbc8231a870d7b148329c8aa250eb942473004e5e6"
}
],
"total_tokens": "250", "total_tokens": "250",
"withdrawn_tokens": "0", "withdrawn_tokens": "250",
"remaining_tokens": "250" "remaining_tokens": "0"
}, },
{ {
"address": "0x57a88037954e15AFFDf9bc29097e0B5f5A1BfF35", "address": "0x57a88037954e15AFFDf9bc29097e0B5f5A1BfF35",
@ -69772,10 +69889,17 @@
"tx": "0xe32a466fc780a0fb3fd84a804f622931ebfaf3f428bff0dc6d141270410e75f8" "tx": "0xe32a466fc780a0fb3fd84a804f622931ebfaf3f428bff0dc6d141270410e75f8"
} }
], ],
"withdrawals": [], "withdrawals": [
{
"amount": "250",
"user": "0x57a88037954e15AFFDf9bc29097e0B5f5A1BfF35",
"tranche_id": 6,
"tx": "0x3da3cd5b323439c576ad7a3410d833da0da994ee652b29dd751a4c0edbf0ca99"
}
],
"total_tokens": "250", "total_tokens": "250",
"withdrawn_tokens": "0", "withdrawn_tokens": "250",
"remaining_tokens": "250" "remaining_tokens": "0"
}, },
{ {
"address": "0x949ECa8174BBa367901e9a195B77B2eA7d862c43", "address": "0x949ECa8174BBa367901e9a195B77B2eA7d862c43",

View File

@ -38,7 +38,7 @@
"tranche_end": "2022-11-26T13:48:10.000Z", "tranche_end": "2022-11-26T13:48:10.000Z",
"total_added": "100", "total_added": "100",
"total_removed": "0", "total_removed": "0",
"locked_amount": "37.074508498224257", "locked_amount": "36.800409056316585",
"deposits": [ "deposits": [
{ {
"amount": "100", "amount": "100",
@ -242,7 +242,7 @@
"tranche_end": "2022-10-12T00:53:20.000Z", "tranche_end": "2022-10-12T00:53:20.000Z",
"total_added": "1100", "total_added": "1100",
"total_removed": "673.04388635", "total_removed": "673.04388635",
"locked_amount": "270.58154807204466", "locked_amount": "267.5664542110604",
"deposits": [ "deposits": [
{ {
"amount": "1000", "amount": "1000",

View File

@ -69,7 +69,7 @@
"tranche_end": "2022-10-12T00:53:20.000Z", "tranche_end": "2022-10-12T00:53:20.000Z",
"total_added": "1010.000000000000000001", "total_added": "1010.000000000000000001",
"total_removed": "668.4622323651", "total_removed": "668.4622323651",
"locked_amount": "248.4430577752410060002459832255200406", "locked_amount": "245.674653411973640000243242231100964",
"deposits": [ "deposits": [
{ {
"amount": "1000", "amount": "1000",

View File

@ -15,5 +15,7 @@ module.exports = defineConfig({
videosFolder: '../../dist/cypress/apps/explorer-e2e/videos', videosFolder: '../../dist/cypress/apps/explorer-e2e/videos',
screenshotsFolder: '../../dist/cypress/apps/explorer-e2e/screenshots', screenshotsFolder: '../../dist/cypress/apps/explorer-e2e/screenshots',
chromeWebSecurity: false, chromeWebSecurity: false,
viewportWidth: 1440,
viewportHeight: 900,
}, },
}); });

View File

@ -14,6 +14,8 @@ module.exports = defineConfig({
videosFolder: '../../dist/cypress/apps/explorer-e2e/videos', videosFolder: '../../dist/cypress/apps/explorer-e2e/videos',
screenshotsFolder: '../../dist/cypress/apps/explorer-e2e/screenshots', screenshotsFolder: '../../dist/cypress/apps/explorer-e2e/screenshots',
chromeWebSecurity: false, chromeWebSecurity: false,
viewportWidth: 1440,
viewportHeight: 900,
}, },
env: { env: {
ethProviderUrl: 'http://localhost:8545/', ethProviderUrl: 'http://localhost:8545/',

View File

@ -1,28 +1,44 @@
const pageSpinner = 'splash-loader'; /// <reference types="cypress" />
const menuBar = 'nav'; const stakeValidatorList = '[data-testid="node-list-item-name"]';
const validatorList = '[data-testid="node-list-item-name"]'; const stakeValidatorWithinList = '[data-testid="node-list-item"]';
const removeStakeRadioButton = '[data-testid="remove-stake-radio"]'; const stakeRemoveStakeRadioButton = '[data-testid="remove-stake-radio"]';
const tokenAmountInputBox = '[data-testid="token-amount-input"]'; const stakeTokenAmountInputBox = '[data-testid="token-amount-input"]';
const tokenSubmitButton = '[data-testid="token-input-submit-button"]'; const stakeTokenSubmitButton = '[data-testid="token-input-submit-button"]';
const stakeNextEpochValue = '[data-testid="stake-next-epoch"]'; const stakeNextEpochValue = '[data-testid="stake-next-epoch"]';
const vegaWalletContainer = '[data-testid="vega-wallet"]'; const stakeThisEpochValue = '[data-testid="stake-this-epoch"]';
const stakeAddStakeRadioButton = '[data-testid="add-stake-radio"]';
const stakeMaximumTokens = '[data-testid="token-amount-use-maximum"]';
const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort'); const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort');
const vegaWalletAssociatedBalance = '[data-testid="currency-value"]';
const vegaWalletUnstakedBalance =
'[data-testid="vega-wallet-balance-unstaked"]';
const vegaWalletStakedBalances =
'[data-testid="vega-wallet-balance-staked-validators"]';
const vegaWalletThisEpochBalances =
'[data-testid="vega-wallet-balance-this-epoch"]';
const vegaWalletNextEpochBalances =
'[data-testid="vega-wallet-balance-next-epoch"]';
const ethWalletAssociatedBalances =
'[data-testid="eth-wallet-associated-balances"]';
const ethWalletTotalAssociatedBalance = '[data-testid="currency-locked"]';
const ethWalletContainer = '[data-testid="ethereum-wallet"]';
const txTimeout = { timeout: 40000 };
const epochTimeout = { timeout: 10000 };
context('Staking Flow - with eth and vega wallets connected', function () { context('Staking Flow - with eth and vega wallets connected', function () {
before('visit staking tab and connect vega wallet', function () { before('visit staking tab and connect vega wallet', function () {
cy.vega_wallet_import(); cy.vega_wallet_import();
cy.visit('/'); cy.visit('/');
cy.get(menuBar, { timeout: 20000 }).should('be.visible'); cy.verify_page_header('The $VEGA token');
cy.vega_wallet_connect(); cy.vega_wallet_connect();
cy.vega_wallet_set_specified_approval_amount('1000'); cy.vega_wallet_set_specified_approval_amount('1000');
cy.reload(); cy.reload();
cy.get(menuBar, { timeout: 20000 }).should('be.visible'); cy.verify_page_header('The $VEGA token');
cy.ethereum_wallet_connect(); cy.ethereum_wallet_connect();
cy.navigate_to('staking'); cy.navigate_to('staking');
cy.get(pageSpinner, { timeout: 20000 }).should('not.exist'); cy.wait_for_spinner();
cy.get(validatorList).first().invoke('text').as('validatorName'); cy.get(stakeValidatorList).first().invoke('text').as('validatorName');
cy.get(validatorList).last().invoke('text').as('otherValidatorName'); cy.get(stakeValidatorList).last().invoke('text').as('otherValidatorName');
}); });
describe('Eth wallet - contains VEGA tokens', function () { describe('Eth wallet - contains VEGA tokens', function () {
@ -36,219 +52,505 @@ context('Staking Flow - with eth and vega wallets connected', function () {
it('Able to stake against a validator', function () { it('Able to stake against a validator', function () {
cy.staking_page_associate_tokens('3'); cy.staking_page_associate_tokens('3');
cy.vega_wallet_check_unstaked_value_is('3.000000000000000000');
cy.ethereum_wallet_check_associated_value_is('3.0'); cy.get(vegaWalletUnstakedBalance, txTimeout).should(
cy.ethereum_wallet_check_associated_vega_key_value_is( 'contain',
vegaWalletPublicKeyShort, 3.0,
'3.000000000000000000' txTimeout
); );
cy.get(ethWalletTotalAssociatedBalance, txTimeout)
.contains('3.0', txTimeout)
.should('be.visible');
cy.get(ethWalletAssociatedBalances, txTimeout)
.contains(vegaWalletPublicKeyShort)
.parent()
.should('contain', 3.0, txTimeout);
cy.get('button').contains('Select a validator to nominate').click(); cy.get('button').contains('Select a validator to nominate').click();
cy.get(validatorList).contains(this.validatorName).click();
cy.get(stakeValidatorList).contains(this.validatorName).click();
cy.staking_validator_page_add_stake('2'); cy.staking_validator_page_add_stake('2');
vega_wallet_check_validator_stake_next_epoch_value_is(
this.validatorName, cy.get(vegaWalletNextEpochBalances, txTimeout)
'2.000000000000000000' .should('contain', 2.0, txTimeout)
.and('contain', this.validatorName)
.and('contain', 'Next epoch');
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
1.0,
txTimeout
); );
cy.vega_wallet_check_unstaked_value_is('1.000000000000000000');
vega_wallet_check_validator_staked_value_is( cy.get(vegaWalletStakedBalances, txTimeout)
this.validatorName, .should('contain', 2.0, txTimeout)
'2.000000000000000000' .and('contain', this.validatorName);
);
staking_validator_page_check_stake_next_epoch_value('2.0'); cy.get(stakeNextEpochValue, epochTimeout)
staking_validator_page_check_stake_this_epoch_value('2.0'); .contains(2.0, epochTimeout)
.should('be.visible');
cy.get(stakeThisEpochValue, epochTimeout)
.contains(2.0, epochTimeout)
.should('be.visible');
cy.navigate_to('staking');
cy.get(stakeValidatorWithinList, epochTimeout)
.contains(this.validatorName)
.parent()
.contains('Total stake')
.parent()
.should('contain', '2.0')
.and('contain', '100%');
}); });
it('Able to stake against mulitple validators', function () { it('Able to stake against mulitple validators', function () {
cy.staking_page_associate_tokens('5'); cy.staking_page_associate_tokens('5');
cy.vega_wallet_check_unstaked_value_is('5.000000000000000000');
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
5.0,
txTimeout
);
cy.get('button').contains('Select a validator to nominate').click(); cy.get('button').contains('Select a validator to nominate').click();
cy.get(validatorList).contains(this.validatorName).click(); cy.get(stakeValidatorList).contains(this.validatorName).click();
cy.staking_validator_page_add_stake('2'); cy.staking_validator_page_add_stake('2');
vega_wallet_check_validator_staked_value_is(
this.validatorName, cy.get(vegaWalletStakedBalances, txTimeout)
'2.000000000000000000' .contains(this.validatorName, txTimeout)
); .parent()
.should('contain', 2.0, txTimeout);
cy.navigate_to('staking'); cy.navigate_to('staking');
cy.get(validatorList).contains(this.otherValidatorName).click(); cy.get(stakeValidatorList).contains(this.otherValidatorName).click();
cy.staking_validator_page_add_stake('1'); cy.staking_validator_page_add_stake('1');
vega_wallet_check_validator_staked_value_is(
this.otherValidatorName, cy.get(vegaWalletStakedBalances, txTimeout)
'1.000000000000000000' .should('have.length', 2, txTimeout)
.contains(this.otherValidatorName, txTimeout)
.parent()
.should('contain', 1.0, txTimeout);
cy.get(vegaWalletStakedBalances, txTimeout)
.contains(this.validatorName, txTimeout)
.parent()
.should('contain', 2.0, txTimeout);
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
2.0,
txTimeout
); );
cy.vega_wallet_check_unstaked_value_is('2.000000000000000000');
cy.navigate_to('staking');
cy.get(stakeValidatorWithinList, epochTimeout)
.contains(this.validatorName)
.parent()
.contains('Total stake')
.parent()
.should('contain', '2.0')
.and('contain', '66.67%');
cy.get(stakeValidatorWithinList, epochTimeout)
.contains(this.otherValidatorName)
.parent()
.contains('Total stake')
.parent()
.should('contain', '1.0')
.and('contain', '33.33%');
}); });
it.skip('Able to remove part of a stake against a validator', function () { it('Able to remove part of a stake against a validator', function () {
cy.staking_page_associate_tokens('4'); cy.staking_page_associate_tokens('4');
cy.vega_wallet_check_unstaked_value_is('4.000000000000000000');
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
4.0,
txTimeout
);
cy.get('button').contains('Select a validator to nominate').click(); cy.get('button').contains('Select a validator to nominate').click();
cy.get(validatorList).contains(this.validatorName).click(); cy.get(stakeValidatorList).contains(this.validatorName).click();
cy.staking_validator_page_add_stake('3'); cy.staking_validator_page_add_stake('3');
staking_validator_page_check_stake_next_epoch_value('3.0');
vega_wallet_check_validator_stake_next_epoch_value_is( cy.get(stakeNextEpochValue, epochTimeout)
this.validatorName, .contains(3.0, epochTimeout)
'3.000000000000000000' .should('be.visible');
cy.get(vegaWalletNextEpochBalances, txTimeout)
.should('contain', 3.0, txTimeout)
.and('contain', this.validatorName)
.and('contain', 'Next epoch');
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
1.0,
txTimeout
); );
cy.vega_wallet_check_unstaked_value_is('1.000000000000000000');
cy.navigate_to('staking'); cy.navigate_to('staking');
cy.get(validatorList).contains(this.validatorName).click(); cy.get(stakeValidatorList).contains(this.validatorName).click();
cy.staking_validator_page_removeStake('1'); cy.staking_validator_page_remove_stake('1');
staking_validator_page_check_stake_next_epoch_value('2.0');
staking_validator_page_check_stake_this_epoch_value('3.0'); cy.get(stakeNextEpochValue, epochTimeout)
vega_wallet_check_validator_stake_next_epoch_value_is( .contains(2.0, epochTimeout)
this.validatorName, .should('be.visible');
'2.000000000000000000'
cy.get(vegaWalletNextEpochBalances, txTimeout)
.should('contain', 2.0, txTimeout)
.and('contain', this.validatorName)
.and('contain', 'Next epoch');
cy.get(vegaWalletThisEpochBalances, txTimeout)
.should('contain', 3.0, txTimeout)
.and('contain', this.validatorName)
.and('contain', 'This Epoch');
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
2.0,
txTimeout
); );
vega_wallet_check_validator_stake_this_epoch_value_is(
this.validatorName, cy.get(vegaWalletStakedBalances, txTimeout)
'3.000000000000000000' .should('contain', 2.0, txTimeout)
); .and('contain', this.validatorName);
cy.vega_wallet_check_unstaked_value_is('2.000000000000000000');
vega_wallet_check_validator_staked_value_is( cy.get(stakeNextEpochValue, epochTimeout)
this.validatorName, .contains(2.0, epochTimeout)
'2.000000000000000000' .should('be.visible');
);
staking_validator_page_check_stake_next_epoch_value('2.0'); cy.get(stakeThisEpochValue, epochTimeout)
staking_validator_page_check_stake_this_epoch_value('2.0'); .contains(2.0, epochTimeout)
.should('be.visible');
cy.navigate_to('staking');
cy.get(stakeValidatorWithinList, epochTimeout)
.contains(this.validatorName)
.parent()
.contains('Total stake')
.parent()
.should('contain', '2.0')
.and('contain', '100%');
}); });
it('Able to remove a full stake against a validator', function () { it('Able to remove a full stake against a validator', function () {
cy.staking_page_associate_tokens('3'); cy.staking_page_associate_tokens('3');
cy.vega_wallet_check_unstaked_value_is('3.000000000000000000');
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
3.0,
txTimeout
);
cy.get('button').contains('Select a validator to nominate').click(); cy.get('button').contains('Select a validator to nominate').click();
cy.get(validatorList).contains(this.validatorName).click();
cy.get(stakeValidatorList).contains(this.validatorName).click();
cy.staking_validator_page_add_stake('1'); cy.staking_validator_page_add_stake('1');
vega_wallet_check_validator_stake_next_epoch_value_is(
this.validatorName, cy.get(vegaWalletNextEpochBalances, txTimeout)
'1.000000000000000000' .should('contain', 1.0, txTimeout)
.and('contain', this.validatorName)
.and('contain', 'Next epoch');
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
2.0,
txTimeout
); );
cy.vega_wallet_check_unstaked_value_is('2.000000000000000000');
cy.navigate_to('staking'); cy.navigate_to('staking');
cy.get(validatorList).contains(this.validatorName).click();
cy.staking_validator_page_removeStake('1'); cy.get(stakeValidatorList).contains(this.validatorName).click();
staking_validator_page_check_stake_next_epoch_value('0.0');
vega_wallet_check_validator_stake_this_epoch_value_is( cy.staking_validator_page_remove_stake('1');
this.validatorName,
'1.000000000000000000' cy.get(stakeNextEpochValue, epochTimeout)
.contains(0.0, epochTimeout)
.should('be.visible');
cy.get(vegaWalletThisEpochBalances, txTimeout)
.should('contain', 1.0, txTimeout)
.and('contain', this.validatorName)
.and('contain', 'This Epoch');
cy.get(vegaWalletNextEpochBalances, txTimeout)
.should('contain', 0.0, txTimeout)
.and('contain', this.validatorName)
.and('contain', 'Next epoch');
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
3.0,
txTimeout
); );
vega_wallet_check_validator_stake_next_epoch_value_is(
this.validatorName, cy.get(stakeNextEpochValue, epochTimeout)
'0.000000000000000000' .contains(0.0, epochTimeout)
); .should('be.visible');
cy.vega_wallet_check_unstaked_value_is('3.000000000000000000');
staking_validator_page_check_stake_next_epoch_value('0.0'); cy.get(stakeThisEpochValue, epochTimeout)
staking_validator_page_check_stake_this_epoch_value('0.0'); .contains(0.0, epochTimeout)
vega_wallet_check_validator_no_longer_showing(this.validatorName); .should('be.visible');
cy.get(vegaWalletStakedBalances, txTimeout)
.contains(this.validatorName, txTimeout)
.should('not.exist', txTimeout);
cy.navigate_to('staking');
cy.get(stakeValidatorWithinList, epochTimeout)
.contains(this.validatorName)
.parent()
.contains('Total stake')
.parent()
.should('contain', '0.0');
}); });
it.skip('Unable to remove a stake with a negative value for a validator', function () { it('Unable to remove a stake with a negative value for a validator', function () {
cy.staking_page_associate_tokens('3'); cy.staking_page_associate_tokens('3');
cy.vega_wallet_check_unstaked_value_is('3.000000000000000000');
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
3.0,
txTimeout
);
cy.get('button').contains('Select a validator to nominate').click(); cy.get('button').contains('Select a validator to nominate').click();
cy.get(validatorList).contains(this.validatorName).click();
cy.get(stakeValidatorList).contains(this.validatorName).click();
cy.staking_validator_page_add_stake('2'); cy.staking_validator_page_add_stake('2');
staking_validator_page_check_stake_next_epoch_value('2.0');
vega_wallet_check_validator_stake_next_epoch_value_is( cy.get(stakeNextEpochValue, epochTimeout)
this.validatorName, .contains(2.0, epochTimeout)
'2.000000000000000000' .should('be.visible');
cy.get(vegaWalletNextEpochBalances, txTimeout)
.should('contain', 2.0, txTimeout)
.and('contain', this.validatorName)
.and('contain', 'Next epoch');
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
3.0,
txTimeout
); );
cy.vega_wallet_check_unstaked_value_is('1.000000000000000000');
cy.navigate_to('staking'); cy.navigate_to('staking');
cy.get(validatorList).contains(this.validatorName).click();
cy.get(removeStakeRadioButton).click({ force: true }); cy.get(stakeValidatorList).contains(this.validatorName).click();
cy.get(tokenAmountInputBox).type('-0.1');
cy.contains('Waiting for next epoch to start', { timeout: 10000 }); cy.get(stakeRemoveStakeRadioButton).click({ force: true });
cy.get(tokenSubmitButton)
.should('be.disabled', { timeout: 8000 }) cy.get(stakeTokenAmountInputBox).type('-0.1');
cy.contains('Waiting for next epoch to start', epochTimeout);
cy.get(stakeTokenSubmitButton)
.should('be.disabled', epochTimeout)
.and('contain', `Remove -0.1 $VEGA tokens at the end of epoch`) .and('contain', `Remove -0.1 $VEGA tokens at the end of epoch`)
.and('be.visible'); .and('be.visible');
}); });
it.skip('Unable to remove a stake greater than staked amount next epoch for a validator', function () { it('Unable to remove a stake greater than staked amount next epoch for a validator', function () {
cy.staking_page_associate_tokens('3'); cy.staking_page_associate_tokens('3');
cy.vega_wallet_check_unstaked_value_is('3.000000000000000000');
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
3.0,
txTimeout
);
cy.get('button').contains('Select a validator to nominate').click(); cy.get('button').contains('Select a validator to nominate').click();
cy.get(validatorList).contains(this.validatorName).click();
cy.get(stakeValidatorList).contains(this.validatorName).click();
cy.staking_validator_page_add_stake('2'); cy.staking_validator_page_add_stake('2');
staking_validator_page_check_stake_next_epoch_value('2.0');
vega_wallet_check_validator_stake_next_epoch_value_is( cy.get(stakeNextEpochValue, epochTimeout)
this.validatorName, .contains(2.0, epochTimeout)
'2.000000000000000000' .should('be.visible');
cy.get(vegaWalletNextEpochBalances, txTimeout)
.should('contain', 2.0, txTimeout)
.and('contain', this.validatorName)
.and('contain', 'Next epoch');
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
1.0,
txTimeout
); );
cy.vega_wallet_check_unstaked_value_is('1.000000000000000000');
cy.navigate_to('staking'); cy.navigate_to('staking');
cy.get(validatorList).contains(this.validatorName).click();
cy.get(removeStakeRadioButton).click({ force: true }); cy.get(stakeValidatorList).contains(this.validatorName).click();
cy.get(tokenAmountInputBox).type(4);
cy.contains('Waiting for next epoch to start', { timeout: 10000 }); cy.get(stakeRemoveStakeRadioButton).click({ force: true });
cy.get(tokenSubmitButton)
.should('be.disabled', { timeout: 8000 }) cy.get(stakeTokenAmountInputBox).type(4);
cy.contains('Waiting for next epoch to start', epochTimeout);
cy.get(stakeTokenSubmitButton)
.should('be.disabled', epochTimeout)
.and('contain', `Remove 4 $VEGA tokens at the end of epoch`) .and('contain', `Remove 4 $VEGA tokens at the end of epoch`)
.and('be.visible'); .and('be.visible');
}); });
it.skip('Disassociating all tokens - removes all staked tokens', function () { it('Disassociating all tokens - removes all staked tokens', function () {
cy.staking_page_associate_tokens('3'); cy.staking_page_associate_tokens('3');
cy.vega_wallet_check_unstaked_value_is('3.000000000000000000');
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
3.0,
txTimeout
);
cy.get('button').contains('Select a validator to nominate').click(); cy.get('button').contains('Select a validator to nominate').click();
cy.get(validatorList).contains(this.validatorName).click();
cy.get(stakeValidatorList).contains(this.validatorName).click();
cy.staking_validator_page_add_stake('2'); cy.staking_validator_page_add_stake('2');
cy.vega_wallet_check_unstaked_value_is('1.000000000000000000');
vega_wallet_check_validator_staked_value_is( cy.get(vegaWalletUnstakedBalance, txTimeout).should(
this.validatorName, 'contain',
'2.000000000000000000' 1.0,
txTimeout
); );
cy.get(vegaWalletStakedBalances, txTimeout)
.should('contain', 2.0, txTimeout)
.and('contain', this.validatorName);
cy.navigate_to('staking'); cy.navigate_to('staking');
cy.staking_page_disassociate_all_tokens(); cy.staking_page_disassociate_all_tokens();
cy.ethereum_wallet_check_associated_vega_key_is_no_longer_showing(
vegaWalletPublicKeyShort cy.get(ethWalletContainer).within(() => {
cy.contains(vegaWalletPublicKeyShort, { timeout: 20000 }).should(
'not.exist'
); );
cy.ethereum_wallet_check_associated_value_is('0.0'); });
cy.vega_wallet_check_associated_value_is('0.000000000000000000');
vega_wallet_check_validator_no_longer_showing(this.validatorName); cy.get(ethWalletTotalAssociatedBalance, txTimeout)
.contains('0.0', txTimeout)
.should('be.visible');
cy.get(vegaWalletAssociatedBalance, txTimeout).should(
'contain',
'0.000000000000000000',
txTimeout
);
cy.get(vegaWalletStakedBalances, txTimeout)
.contains(this.validatorName, txTimeout)
.should('not.exist', txTimeout);
cy.navigate_to('staking');
cy.get(stakeValidatorWithinList, epochTimeout)
.contains(this.validatorName)
.parent()
.contains('Total stake')
.parent()
.should('contain', '0.0');
}); });
it('Disassociating some tokens - prioritizes unstaked tokens', function () { it('Disassociating some tokens - prioritizes unstaked tokens', function () {
cy.staking_page_associate_tokens('3'); cy.staking_page_associate_tokens('3');
cy.vega_wallet_check_unstaked_value_is('3.000000000000000000');
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
3.0,
txTimeout
);
cy.get('button').contains('Select a validator to nominate').click(); cy.get('button').contains('Select a validator to nominate').click();
cy.get(validatorList).contains(this.validatorName).click(); cy.get(stakeValidatorList).contains(this.validatorName).click();
cy.staking_validator_page_add_stake('2'); cy.staking_validator_page_add_stake('2');
cy.vega_wallet_check_unstaked_value_is('1.000000000000000000'); cy.get(vegaWalletUnstakedBalance, txTimeout).should(
vega_wallet_check_validator_staked_value_is( 'contain',
this.validatorName, 1.0,
'2.000000000000000000' txTimeout
); );
cy.get(vegaWalletStakedBalances, txTimeout)
.should('contain', 2.0, txTimeout)
.and('contain', this.validatorName);
cy.navigate_to('staking'); cy.navigate_to('staking');
cy.staking_page_disassociate_tokens('1'); cy.staking_page_disassociate_tokens('1');
cy.ethereum_wallet_check_associated_value_is('2.0');
cy.vega_wallet_check_associated_value_is('2.000000000000000000'); cy.get(ethWalletTotalAssociatedBalance, txTimeout)
vega_wallet_check_validator_staked_value_is( .contains('2.0', txTimeout)
this.validatorName, .should('be.visible');
'2.000000000000000000'
cy.get(vegaWalletAssociatedBalance, txTimeout).should(
'contain',
'2.000000000000000000',
txTimeout
); );
cy.get(vegaWalletStakedBalances, txTimeout)
.should('contain', 2.0, txTimeout)
.and('contain', this.validatorName);
cy.navigate_to('staking');
cy.get(stakeValidatorWithinList, epochTimeout)
.contains(this.validatorName)
.parent()
.contains('Total stake')
.parent()
.should('contain', '2.0')
.and('contain', '100%');
});
it('Selecting use maximum where tokens are allready staked - suggests the unstaked token amount', function () {
cy.staking_page_associate_tokens('3');
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
3.0,
txTimeout
);
cy.get('button').contains('Select a validator to nominate').click();
cy.get(stakeValidatorList).contains(this.validatorName).click();
cy.staking_validator_page_add_stake('2');
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
1.0,
txTimeout
);
cy.navigate_to('staking');
cy.get(stakeValidatorList).contains(this.otherValidatorName).click();
cy.get(stakeAddStakeRadioButton).click({ force: true });
cy.get(stakeMaximumTokens, { timeout: 60000 }).click();
cy.get(stakeTokenSubmitButton).should('contain', 'Add 1 $VEGA tokens');
}); });
after( after(
@ -259,77 +561,3 @@ context('Staking Flow - with eth and vega wallets connected', function () {
); );
}); });
}); });
function staking_validator_page_check_stake_next_epoch_value(expectedVal) {
cy.highlight(
`Checking Staking Page - Validator Stake Next Epoch Value is ${expectedVal}`
);
cy.get(stakeNextEpochValue, { timeout: 10000 })
.contains(expectedVal, { timeout: 10000 })
.should('be.visible');
}
function staking_validator_page_check_stake_this_epoch_value(expectedVal) {
cy.highlight(
`Checking Staking Page - Validator Stake This Epoch Value is ${expectedVal}`
);
cy.get(stakeNextEpochValue, { timeout: 10000 })
.contains(expectedVal, { timeout: 10000 })
.should('be.visible');
}
function vega_wallet_check_validator_stake_next_epoch_value_is(
validatorName,
expectedVal
) {
cy.highlight(
`Checking vega wallet - Stake Next Epoch Value for ${validatorName} is ${expectedVal}`
);
cy.get(vegaWalletContainer).within(() => {
cy.contains(`${validatorName} (Next epoch)`, { timeout: 40000 })
.siblings()
.contains(expectedVal, { timeout: 40000 })
.should('be.visible');
});
}
function vega_wallet_check_validator_stake_this_epoch_value_is(
validatorName,
expectedVal
) {
cy.highlight(
`Checking vega wallet - Stake This Epoch Value for ${validatorName} is ${expectedVal}`
);
cy.get(vegaWalletContainer).within(() => {
cy.contains(`${validatorName} (This Epoch)`, { timeout: 40000 })
.siblings()
.contains(expectedVal, { timeout: 40000 })
.should('be.visible');
});
}
function vega_wallet_check_validator_no_longer_showing(validatorName) {
cy.highlight(
`Checking Validator and therefore stake removed for ${validatorName}`
);
cy.get(vegaWalletContainer).within(() => {
cy.contains(`${validatorName}`, { timeout: 40000 }).should('not.exist', {
timeout: 40000,
});
});
}
function vega_wallet_check_validator_staked_value_is(
validatorName,
expectedVal
) {
cy.highlight(
`Checking Validator Stake Value for ${validatorName} is ${expectedVal}`
);
cy.get(vegaWalletContainer).within(() => {
cy.contains(`${validatorName}`, { timeout: 40000 })
.siblings()
.contains(expectedVal, { timeout: 40000 })
.should('be.visible');
});
}

View File

@ -1,7 +1,12 @@
const pageSpinner = 'splash-loader';
const menuBar = 'nav';
const validatorList = '[data-testid="node-list-item-name"]'; const validatorList = '[data-testid="node-list-item-name"]';
const ethWalletContainer = '[data-testid="ethereum-wallet"]';
const ethWalletAssociatedBalances =
'[data-testid="eth-wallet-associated-balances"]';
const ethWalletTotalAssociatedBalance = '[data-testid="currency-locked"]';
const vegaWalletAssociatedBalance = '[data-testid="currency-value"]';
const vegaWalletUnstakedBalance =
'[data-testid="vega-wallet-balance-unstaked"]';
const txTimeout = { timeout: 40000 };
const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort'); const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort');
context( context(
@ -10,14 +15,14 @@ context(
before('visit staking tab and connect vega wallet', function () { before('visit staking tab and connect vega wallet', function () {
cy.vega_wallet_import(); cy.vega_wallet_import();
cy.visit('/'); cy.visit('/');
cy.get(menuBar, { timeout: 20000 }).should('be.visible'); cy.verify_page_header('The $VEGA token');
cy.vega_wallet_connect(); cy.vega_wallet_connect();
cy.vega_wallet_set_specified_approval_amount('1000'); cy.vega_wallet_set_specified_approval_amount('1000');
cy.reload(); cy.reload();
cy.get(menuBar, { timeout: 20000 }).should('be.visible'); cy.verify_page_header('The $VEGA token');
cy.ethereum_wallet_connect(); cy.ethereum_wallet_connect();
cy.navigate_to('staking'); cy.navigate_to('staking');
cy.get(pageSpinner, { timeout: 20000 }).should('not.exist'); cy.wait_for_spinner();
cy.get(validatorList).first().invoke('text').as('validatorName'); cy.get(validatorList).first().invoke('text').as('validatorName');
}); });
@ -27,71 +32,140 @@ context(
function () { function () {
cy.vega_wallet_teardown(); cy.vega_wallet_teardown();
cy.navigate_to('staking'); cy.navigate_to('staking');
cy.get(pageSpinner, { timeout: 20000 }).should('not.exist'); cy.wait_for_spinner();
} }
); );
it('Able to associate tokens', function () { it('Able to associate tokens', function () {
cy.staking_page_associate_tokens('2'); cy.staking_page_associate_tokens('2');
cy.ethereum_wallet_check_associated_vega_key_value_is(
vegaWalletPublicKeyShort, cy.get(ethWalletAssociatedBalances, txTimeout)
'2.000000000000000000' .contains(vegaWalletPublicKeyShort)
.parent()
.should('contain', 2.0, txTimeout);
cy.get(ethWalletTotalAssociatedBalance, txTimeout)
.contains('2.0', txTimeout)
.should('be.visible');
cy.get(vegaWalletAssociatedBalance, txTimeout).should(
'contain',
2.0,
txTimeout
);
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
2.0,
txTimeout
); );
cy.ethereum_wallet_check_associated_value_is('2.0');
cy.vega_wallet_check_associated_value_is('2.000000000000000000');
cy.vega_wallet_check_unstaked_value_is('2.000000000000000000');
}); });
it('Able to disassociate tokens', function () { it('Able to disassociate tokens', function () {
cy.staking_page_associate_tokens('2'); cy.staking_page_associate_tokens('2');
cy.ethereum_wallet_check_associated_vega_key_value_is(
vegaWalletPublicKeyShort, cy.get(ethWalletAssociatedBalances, txTimeout)
'2.000000000000000000' .contains(vegaWalletPublicKeyShort)
); .parent()
cy.vega_wallet_check_associated_value_is('2.000000000000000000'); .should('contain', 2.0, txTimeout);
cy.get(ethWalletTotalAssociatedBalance, txTimeout)
.contains('2.0', txTimeout)
.should('be.visible');
cy.get('button').contains('Select a validator to nominate').click(); cy.get('button').contains('Select a validator to nominate').click();
cy.staking_page_disassociate_tokens('1'); cy.staking_page_disassociate_tokens('1');
cy.ethereum_wallet_check_associated_vega_key_value_is(
vegaWalletPublicKeyShort, cy.get(ethWalletAssociatedBalances, txTimeout)
'1.000000000000000000' .contains(vegaWalletPublicKeyShort)
); .parent()
cy.ethereum_wallet_check_associated_value_is('1.0'); .should('contain', 1.0, txTimeout);
cy.vega_wallet_check_associated_value_is('1.000000000000000000');
cy.get(ethWalletTotalAssociatedBalance, txTimeout)
.contains('1.0', txTimeout)
.should('be.visible');
}); });
it('Able to associate more tokens than the approved amount of 1000 - requires re-approval', function () { it('Able to associate more tokens than the approved amount of 1000 - requires re-approval', function () {
cy.staking_page_associate_tokens('1001', true); cy.staking_page_associate_tokens('1001', true);
cy.ethereum_wallet_check_associated_vega_key_value_is(
vegaWalletPublicKeyShort, cy.get(ethWalletAssociatedBalances, txTimeout)
'1,001.000000000000000000' .contains(vegaWalletPublicKeyShort)
.parent()
.should('contain', '1,001.000000000000000000', txTimeout);
cy.get(ethWalletTotalAssociatedBalance, txTimeout)
.contains('1,001.00', txTimeout)
.should('be.visible');
cy.get(vegaWalletAssociatedBalance, txTimeout).should(
'contain',
'1,001.000000000000000000',
txTimeout
); );
cy.ethereum_wallet_check_associated_value_is('1,001.00');
cy.vega_wallet_check_associated_value_is('1,001.000000000000000000');
}); });
it('Able to disassociate a partial amount of tokens currently associated', function () { it('Able to disassociate a partial amount of tokens currently associated', function () {
cy.staking_page_associate_tokens('2'); cy.staking_page_associate_tokens('2');
cy.vega_wallet_check_associated_value_is('2.000000000000000000');
cy.get('button').contains('Select a validator to nominate').click(); cy.get(vegaWalletAssociatedBalance, txTimeout).should(
cy.staking_page_disassociate_tokens('1'); 'contain',
cy.ethereum_wallet_check_associated_vega_key_value_is( 2.0,
vegaWalletPublicKeyShort, txTimeout
'1.000000000000000000' );
cy.get('button').contains('Select a validator to nominate').click();
cy.staking_page_disassociate_tokens('1');
cy.get(ethWalletAssociatedBalances, txTimeout)
.contains(vegaWalletPublicKeyShort)
.parent()
.should('contain', 1.0, txTimeout);
cy.get(ethWalletAssociatedBalances, txTimeout)
.contains(vegaWalletPublicKeyShort)
.parent()
.should('contain', 1.0, txTimeout);
cy.get(vegaWalletAssociatedBalance, txTimeout).should(
'contain',
1.0,
txTimeout
); );
cy.ethereum_wallet_check_associated_value_is('1.0');
cy.vega_wallet_check_associated_value_is('1.000000000000000000');
}); });
it('Able to disassociate all tokens', function () { it('Able to disassociate all tokens', function () {
cy.staking_page_associate_tokens('2'); cy.staking_page_associate_tokens('2');
cy.vega_wallet_check_associated_value_is('2.000000000000000000');
cy.get('button').contains('Select a validator to nominate').click(); cy.get(vegaWalletAssociatedBalance, txTimeout).should(
cy.staking_page_disassociate_all_tokens(); 'contain',
cy.ethereum_wallet_check_associated_vega_key_is_no_longer_showing( 2.0,
vegaWalletPublicKeyShort txTimeout
);
cy.get('button').contains('Select a validator to nominate').click();
cy.staking_page_disassociate_all_tokens();
cy.get(ethWalletContainer).within(() => {
cy.contains(vegaWalletPublicKeyShort, { timeout: 20000 }).should(
'not.exist'
);
});
cy.get(ethWalletContainer).within(() => {
cy.contains(vegaWalletPublicKeyShort, { timeout: 20000 }).should(
'not.exist'
);
});
cy.get(vegaWalletAssociatedBalance, txTimeout).should(
'contain',
0.0,
txTimeout
); );
cy.ethereum_wallet_check_associated_value_is('0.0');
cy.vega_wallet_check_associated_value_is('0.000000000000000000');
}); });
}); });
} }

View File

@ -14,6 +14,7 @@ const navigation = {
rewards: '[href="/rewards"]', rewards: '[href="/rewards"]',
withdraw: '[href="/withdraw"]', withdraw: '[href="/withdraw"]',
governance: '[href="/governance"]', governance: '[href="/governance"]',
pageSpinner: 'splash-loader',
}; };
Cypress.Commands.add('navigate_to', (page) => { Cypress.Commands.add('navigate_to', (page) => {
@ -31,3 +32,7 @@ Cypress.Commands.add('verify_tab_highlighted', (page) => {
Cypress.Commands.add('verify_page_header', (text) => { Cypress.Commands.add('verify_page_header', (text) => {
return cy.get('header h1').should('be.visible').and('have.text', text); return cy.get('header h1').should('be.visible').and('have.text', text);
}); });
Cypress.Commands.add('wait_for_spinner', () => {
cy.get(navigation.pageSpinner, { timeout: 20000 }).should('not.exist');
});

View File

@ -9,7 +9,6 @@ const associateWalletRadioButton = '[data-testid="associate-radio-wallet"]';
const stakeMaximumTokens = '[data-testid="token-amount-use-maximum"]'; const stakeMaximumTokens = '[data-testid="token-amount-use-maximum"]';
Cypress.Commands.add('wait_for_begining_of_epoch', () => { Cypress.Commands.add('wait_for_begining_of_epoch', () => {
cy.highlight(`Waiting for next epoch to start`);
cy.contains('Waiting for next epoch to start', { timeout: 10000 }).should( cy.contains('Waiting for next epoch to start', { timeout: 10000 }).should(
'not.exist' 'not.exist'
); );
@ -26,13 +25,9 @@ Cypress.Commands.add('staking_validator_page_add_stake', (stake) => {
.and('contain', `Add ${stake} $VEGA tokens`) .and('contain', `Add ${stake} $VEGA tokens`)
.and('be.visible') .and('be.visible')
.click(); .click();
cy.contains(
'At the beginning of the next epoch your $VEGA will be nominated to the validator',
{ timeout: 20000 }
).should('be.visible');
}); });
Cypress.Commands.add('staking_validator_page_removeStake', (stake) => { Cypress.Commands.add('staking_validator_page_remove_stake', (stake) => {
cy.highlight(`Removing a stake of ${stake}`); cy.highlight(`Removing a stake of ${stake}`);
cy.get(removeStakeRadioButton).click({ force: true }); cy.get(removeStakeRadioButton).click({ force: true });
cy.get(tokenAmountInputBox).type(stake); cy.get(tokenAmountInputBox).type(stake);
@ -42,9 +37,6 @@ Cypress.Commands.add('staking_validator_page_removeStake', (stake) => {
.and('contain', `Remove ${stake} $VEGA tokens at the end of epoch`) .and('contain', `Remove ${stake} $VEGA tokens at the end of epoch`)
.and('be.visible') .and('be.visible')
.click(); .click();
cy.contains(`${stake} $VEGA has been removed from validator`).should(
'be.visible'
);
}); });
Cypress.Commands.add( Cypress.Commands.add(

View File

@ -16,42 +16,3 @@ Cypress.Commands.add('ethereum_wallet_connect', () => {
cy.contains('Locked', { timeout: 15000 }).should('be.visible'); cy.contains('Locked', { timeout: 15000 }).should('be.visible');
}); });
}); });
Cypress.Commands.add(
'ethereum_wallet_check_associated_value_is',
(expectedVal) => {
cy.highlight(`Checking Eth Wallet - Associated Value is ${expectedVal}`);
cy.get(ethWalletContainer).within(() => {
cy.contains('Associated', { timeout: 20000 })
.parent()
.siblings()
.contains(expectedVal, { timeout: 40000 })
.should('be.visible');
});
}
);
Cypress.Commands.add(
'ethereum_wallet_check_associated_vega_key_value_is',
(vegaShortPublicKey, expectedVal) => {
cy.highlight(
`Checking Eth Wallet - Vega Key Associated Value is ${expectedVal} for key ${vegaShortPublicKey}`
);
cy.get(ethWalletContainer).within(() => {
cy.contains(vegaShortPublicKey, { timeout: 20000 })
.parent()
.contains(expectedVal, { timeout: 40000 })
.should('be.visible');
});
}
);
Cypress.Commands.add(
'ethereum_wallet_check_associated_vega_key_is_no_longer_showing',
(vegaShortPublicKey) => {
cy.highlight('Checking Eth Wallet - Vega Key Associated is not showing');
cy.get(ethWalletContainer).within(() => {
cy.contains(vegaShortPublicKey, { timeout: 20000 }).should('not.exist');
});
}
);

View File

@ -5,6 +5,7 @@ import {
} from '@vegaprotocol/smart-contracts'; } from '@vegaprotocol/smart-contracts';
import { ethers, Wallet } from 'ethers'; import { ethers, Wallet } from 'ethers';
const vegaWalletAssociatedBalance = '[data-testid="currency-value"]';
const vegaWalletMnemonic = Cypress.env('vegaWalletMnemonic'); const vegaWalletMnemonic = Cypress.env('vegaWalletMnemonic');
const vegaWalletPubKey = Cypress.env('vegaWalletPublicKey'); const vegaWalletPubKey = Cypress.env('vegaWalletPublicKey');
const vegaTokenContractAddress = Cypress.env('vegaTokenContractAddress'); const vegaTokenContractAddress = Cypress.env('vegaTokenContractAddress');
@ -41,7 +42,12 @@ before('Vega wallet teardown prep', function () {
Cypress.Commands.add('vega_wallet_teardown', function () { Cypress.Commands.add('vega_wallet_teardown', function () {
cy.vega_wallet_teardown_staking(this.stakingBridgeContract); cy.vega_wallet_teardown_staking(this.stakingBridgeContract);
cy.vega_wallet_teardown_vesting(this.vestingContract); cy.vega_wallet_teardown_vesting(this.vestingContract);
cy.vega_wallet_check_associated_value_is('0.000000000000000000');
cy.get(vegaWalletAssociatedBalance, { timeout: transactionTimeout }).should(
'contain',
'0.000000000000000000',
{ timeout: transactionTimeout }
);
}); });
Cypress.Commands.add( Cypress.Commands.add(

View File

@ -33,24 +33,3 @@ Cypress.Commands.add('vega_wallet_connect', () => {
}); });
cy.contains(`${vegaWalletName} key`, { timeout: 20000 }).should('be.visible'); cy.contains(`${vegaWalletName} key`, { timeout: 20000 }).should('be.visible');
}); });
Cypress.Commands.add('vega_wallet_check_unstaked_value_is', (expectedVal) => {
cy.highlight(`Checking vega wallet - Unstaked Value is ${expectedVal}`);
cy.get(vegaWalletContainer).within(() => {
cy.contains('Unstaked', { timeout: 40000 })
.siblings()
.contains(expectedVal, { timeout: 40000 })
.should('be.visible');
});
});
Cypress.Commands.add('vega_wallet_check_associated_value_is', (expectedVal) => {
cy.highlight(`Checking vega wallet - Associated Value is ${expectedVal}`);
cy.get(vegaWalletContainer).within(() => {
cy.contains('Associated', { timeout: 40000 })
.parent()
.siblings()
.contains(expectedVal, { timeout: 40000 })
.should('be.visible');
});
});

View File

@ -83,12 +83,14 @@ const AssociatedAmounts = ({
/> />
{vestingAssociationByVegaKey.map(([key, amount]) => { {vestingAssociationByVegaKey.map(([key, amount]) => {
return ( return (
<div data-testid="eth-wallet-associated-balances">
<WalletCardRow <WalletCardRow
key={key} key={key}
label={removeLeadingAddressSymbol(key)} label={removeLeadingAddressSymbol(key)}
value={amount} value={amount}
dark={true} dark={true}
/> />
</div>
); );
})} })}
</div> </div>

View File

@ -154,13 +154,16 @@ const VegaWalletConnected = ({ vegaKeys }: VegaWalletConnectedProps) => {
balance={currentStakeAvailable} balance={currentStakeAvailable}
dark={true} dark={true}
/> />
<div data-testid="vega-wallet-balance-unstaked">
<WalletCardRow label={t('unstaked')} value={unstaked} dark={true} /> <WalletCardRow label={t('unstaked')} value={unstaked} dark={true} />
</div>
{delegatedNodes.length ? ( {delegatedNodes.length ? (
<WalletCardRow label={t('stakedValidators')} dark={true} bold={true} /> <WalletCardRow label={t('stakedValidators')} dark={true} bold={true} />
) : null} ) : null}
{delegatedNodes.map((d) => ( {delegatedNodes.map((d) => (
<div key={d.nodeId}> <div key={d.nodeId} data-testid="vega-wallet-balance-staked-validators">
{d.currentEpochStake && d.currentEpochStake.isGreaterThan(0) && ( {d.currentEpochStake && d.currentEpochStake.isGreaterThan(0) && (
<div data-testid="vega-wallet-balance-this-epoch">
<WalletCardRow <WalletCardRow
label={`${d.name || truncateMiddle(d.nodeId)} ${ label={`${d.name || truncateMiddle(d.nodeId)} ${
d.hasStakePending ? `(${t('thisEpoch')})` : '' d.hasStakePending ? `(${t('thisEpoch')})` : ''
@ -169,8 +172,10 @@ const VegaWalletConnected = ({ vegaKeys }: VegaWalletConnectedProps) => {
value={d.currentEpochStake} value={d.currentEpochStake}
dark={true} dark={true}
/> />
</div>
)} )}
{d.hasStakePending && ( {d.hasStakePending && (
<div data-testid="vega-wallet-balance-next-epoch">
<WalletCardRow <WalletCardRow
label={`${d.name || truncateMiddle(d.nodeId)} (${t( label={`${d.name || truncateMiddle(d.nodeId)} (${t(
'nextEpoch' 'nextEpoch'
@ -179,6 +184,7 @@ const VegaWalletConnected = ({ vegaKeys }: VegaWalletConnectedProps) => {
value={d.nextEpochStake} value={d.nextEpochStake}
dark={true} dark={true}
/> />
</div>
)} )}
</div> </div>
))} ))}

View File

@ -27,6 +27,8 @@ module.exports = defineConfig({
chromeWebSecurity: false, chromeWebSecurity: false,
projectId: 'et4snf', projectId: 'et4snf',
defaultCommandTimeout: 10000, defaultCommandTimeout: 10000,
viewportWidth: 1440,
viewportHeight: 900,
}, },
env: { env: {
TRADING_TEST_VEGA_WALLET_NAME: 'UI_Trading_Test', TRADING_TEST_VEGA_WALLET_NAME: 'UI_Trading_Test',

View File

@ -1,10 +1,12 @@
import { aliasQuery } from '@vegaprotocol/cypress'; import { aliasQuery } from '@vegaprotocol/cypress';
import { generateDepositPage } from '../support/mocks/generate-deposit-page'; import { generateDepositPage } from '../support/mocks/generate-deposit-page';
import { generateNetworkParameters } from '../support/mocks/generate-network-parameters';
describe('deposit form validation', () => { describe('deposit form validation', () => {
beforeEach(() => { beforeEach(() => {
cy.mockWeb3Provider(); cy.mockWeb3Provider();
cy.mockGQL((req) => { cy.mockGQL((req) => {
aliasQuery(req, 'NetworkParamsQuery', generateNetworkParameters());
aliasQuery(req, 'DepositPage', generateDepositPage()); aliasQuery(req, 'DepositPage', generateDepositPage());
}); });
cy.visit('/portfolio/deposit'); cy.visit('/portfolio/deposit');

View File

@ -32,11 +32,11 @@ describe('home', () => {
}); });
cy.visit('/'); cy.visit('/');
cy.wait('@GQL');
cy.contains('Loading...').should('be.visible'); cy.contains('Loading...').should('be.visible');
cy.contains('Loading...').should('not.exist'); cy.contains('Loading...').should('not.exist');
cy.get('main[data-testid="market"]').should('exist'); // Wait for page to be rendered to before checking url cy.wait('@GQL');
cy.get('main[data-testid="market"]', { timeout: 20000 }).should('exist'); // Wait for page to be rendered to before checking url
cy.url().should('include', `/markets/${oldestMarket.id}`); // Should redirect to oldest market cy.url().should('include', `/markets/${oldestMarket.id}`); // Should redirect to oldest market
}); });

View File

@ -2,6 +2,7 @@ import { aliasQuery } from '@vegaprotocol/cypress';
import { generateFill, generateFills } from '../support/mocks/generate-fills'; import { generateFill, generateFills } from '../support/mocks/generate-fills';
import { Side } from '@vegaprotocol/types'; import { Side } from '@vegaprotocol/types';
import { connectVegaWallet } from '../support/vega-wallet'; import { connectVegaWallet } from '../support/vega-wallet';
import { generateNetworkParameters } from '../support/mocks/generate-network-parameters';
describe('fills', () => { describe('fills', () => {
before(() => { before(() => {
@ -58,6 +59,7 @@ describe('fills', () => {
}); });
cy.mockGQL((req) => { cy.mockGQL((req) => {
aliasQuery(req, 'Fills', result); aliasQuery(req, 'Fills', result);
aliasQuery(req, 'NetworkParamsQuery', generateNetworkParameters());
}); });
cy.visit('/portfolio'); cy.visit('/portfolio');
cy.get('main[data-testid="portfolio"]').should('exist'); cy.get('main[data-testid="portfolio"]').should('exist');
@ -65,7 +67,7 @@ describe('fills', () => {
it('renders fills', () => { it('renders fills', () => {
cy.getByTestId('Fills').click(); cy.getByTestId('Fills').click();
cy.getByTestId('tab-fills').contains('Please connect Vega wallet'); cy.getByTestId('tab-fills').contains('Connect your Vega wallet');
connectVegaWallet(); connectVegaWallet();

View File

@ -11,7 +11,7 @@ beforeEach(() => {
describe('accounts', () => { describe('accounts', () => {
it('renders accounts', () => { it('renders accounts', () => {
cy.getByTestId('Accounts').click(); cy.getByTestId('Collateral').click();
cy.getByTestId('tab-accounts').contains('Please connect Vega wallet'); cy.getByTestId('tab-accounts').contains('Please connect Vega wallet');
connectVegaWallet(); connectVegaWallet();

View File

@ -1,5 +1,6 @@
import { aliasQuery } from '@vegaprotocol/cypress'; import { aliasQuery } from '@vegaprotocol/cypress';
import { connectEthereumWallet } from '../support/ethereum-wallet'; import { connectEthereumWallet } from '../support/ethereum-wallet';
import { generateNetworkParameters } from '../support/mocks/generate-network-parameters';
import { generateWithdrawPageQuery } from '../support/mocks/generate-withdraw-page-query'; import { generateWithdrawPageQuery } from '../support/mocks/generate-withdraw-page-query';
import { connectVegaWallet } from '../support/vega-wallet'; import { connectVegaWallet } from '../support/vega-wallet';
@ -15,6 +16,7 @@ describe('withdraw', () => {
cy.mockWeb3Provider(); cy.mockWeb3Provider();
cy.mockGQL((req) => { cy.mockGQL((req) => {
aliasQuery(req, 'WithdrawPageQuery', generateWithdrawPageQuery()); aliasQuery(req, 'WithdrawPageQuery', generateWithdrawPageQuery());
aliasQuery(req, 'NetworkParamsQuery', generateNetworkParameters());
}); });
cy.visit('/portfolio/withdraw'); cy.visit('/portfolio/withdraw');

View File

@ -1,5 +1,6 @@
import { aliasQuery } from '@vegaprotocol/cypress'; import { aliasQuery } from '@vegaprotocol/cypress';
import { connectEthereumWallet } from '../support/ethereum-wallet'; import { connectEthereumWallet } from '../support/ethereum-wallet';
import { generateNetworkParameters } from '../support/mocks/generate-network-parameters';
import { generateWithdrawals } from '../support/mocks/generate-withdrawals'; import { generateWithdrawals } from '../support/mocks/generate-withdrawals';
import { connectVegaWallet } from '../support/vega-wallet'; import { connectVegaWallet } from '../support/vega-wallet';
@ -8,6 +9,7 @@ describe('withdrawals', () => {
cy.mockWeb3Provider(); cy.mockWeb3Provider();
cy.mockGQL((req) => { cy.mockGQL((req) => {
aliasQuery(req, 'Withdrawals', generateWithdrawals()); aliasQuery(req, 'Withdrawals', generateWithdrawals());
aliasQuery(req, 'NetworkParamsQuery', generateNetworkParameters());
}); });
cy.visit('/portfolio/withdrawals'); cy.visit('/portfolio/withdrawals');
@ -16,8 +18,6 @@ describe('withdrawals', () => {
// It also requires connection Ethereum wallet // It also requires connection Ethereum wallet
connectEthereumWallet(); connectEthereumWallet();
cy.contains('Withdrawals');
}); });
it('renders history of withdrawals', () => { it('renders history of withdrawals', () => {
@ -27,7 +27,6 @@ describe('withdrawals', () => {
const etherScanLink = `${Cypress.env( const etherScanLink = `${Cypress.env(
'ETHERSCAN_URL' 'ETHERSCAN_URL'
)}/tx/0x5d7b1a35ba6bd23be17bb7a159c13cdbb3121fceb94e9c6c510f5503dce48d03`; )}/tx/0x5d7b1a35ba6bd23be17bb7a159c13cdbb3121fceb94e9c6c510f5503dce48d03`;
cy.contains('Withdrawals');
const row = '.ag-center-cols-container[role="rowgroup"] > [role="row"]'; const row = '.ag-center-cols-container[role="rowgroup"] > [role="row"]';

View File

@ -0,0 +1,37 @@
import merge from 'lodash/merge';
import type { NetworkParamsQuery } from '@vegaprotocol/web3';
import type { PartialDeep } from 'type-fest';
export const generateNetworkParameters = (
override?: PartialDeep<NetworkParamsQuery>
): NetworkParamsQuery => {
const defaultResult: NetworkParamsQuery = {
networkParameters: [
{
__typename: 'NetworkParameter',
key: 'blockchains.ethereumConfig',
value: JSON.stringify({
network_id: '3',
chain_id: '3',
collateral_bridge_contract: {
address: '0x947893AaA0A7b55f66990b3B4781514b691Fdd4a',
},
multisig_control_contract: {
address: '0xaE15126d2d1fAbF7cfA7cAD3cbD4921DfC87F620',
deployment_block_height: 12341882,
},
staking_bridge_contract: {
address: '0x7896C9491962D5839783CB6e0492ECebd34Bb35F',
deployment_block_height: 11177313,
},
token_vesting_contract: {
address: '0x9F10cBeEf03A564Fb914c2010c0Cd55E9BB11406',
deployment_block_height: 11177353,
},
confirmations: 3,
}),
},
],
};
return merge(defaultResult, override);
};

View File

@ -10,7 +10,7 @@ export const Navbar = () => {
<Link href="/" passHref={true}> <Link href="/" passHref={true}>
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */} {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
<a className="px-[26px]"> <a className="px-[26px]">
<Vega className="fill-black dark:fill-white" /> <Vega className="fill-white" />
</a> </a>
</Link> </Link>
{[ {[
@ -39,7 +39,7 @@ const NavLink = ({ name, path, exact, testId = name }: NavLinkProps) => {
'uppercase xs:text-ui sm:text-body-large md:text-h5 lg:text-h4', 'uppercase xs:text-ui sm:text-body-large md:text-h5 lg:text-h4',
{ {
'bg-vega-pink dark:bg-vega-yellow text-white dark:text-black': isActive, 'bg-vega-pink dark:bg-vega-yellow text-white dark:text-black': isActive,
'text-black dark:text-white': !isActive, 'text-white': !isActive,
} }
); );
return ( return (

View File

@ -24,12 +24,14 @@ export const VegaWalletConnectButton = ({
return ( return (
<span> <span>
{isConnected && ( {isConnected && (
<span className="text-ui-small font-mono mr-2">Vega key:</span> <span className="text-ui-small font-mono mr-2 text-white-90">
Vega key:
</span>
)} )}
<button <button
data-testid={isConnected ? 'manage-vega-wallet' : 'connect-vega-wallet'} data-testid={isConnected ? 'manage-vega-wallet' : 'connect-vega-wallet'}
onClick={handleClick} onClick={handleClick}
className="ml-auto inline-block text-ui-small font-mono hover:underline" className="ml-auto inline-block text-ui-small font-mono hover:underline text-white-90"
> >
{isConnected ? truncateByChars(keypair.pub) : 'Connect Vega wallet'} {isConnected ? truncateByChars(keypair.pub) : 'Connect Vega wallet'}
</button> </button>

View File

@ -28,9 +28,9 @@ function AppBody({ Component, pageProps }: AppProps) {
return ( return (
<ThemeContext.Provider value={theme}> <ThemeContext.Provider value={theme}>
<div className="h-full dark:bg-black dark:text-white-60 bg-white relative z-0 text-black-60 grid grid-rows-[min-content,1fr]"> <div className="h-full text-white relative text-black-60 dark:text-white-60 z-0 grid grid-rows-[min-content,1fr]">
<AppLoader> <AppLoader>
<div className="flex items-stretch border-b-[7px] border-vega-pink dark:border-vega-yellow"> <div className="flex items-stretch border-b-[7px] bg-black border-vega-pink dark:border-vega-yellow">
<Navbar /> <Navbar />
<div className="flex items-center gap-4 ml-auto mr-8"> <div className="flex items-center gap-4 ml-auto mr-8">
<VegaWalletConnectButton <VegaWalletConnectButton

View File

@ -30,12 +30,12 @@ const TradingViews = {
Candles: CandlesChartContainer, Candles: CandlesChartContainer,
Depth: DepthChartContainer, Depth: DepthChartContainer,
Ticket: DealTicketContainer, Ticket: DealTicketContainer,
Orderbook: OrderbookContainer,
Orders: OrderListContainer,
Positions: PositionsContainer,
Accounts: AccountsContainer,
Trades: TradesContainer,
Info: MarketInfoContainer, Info: MarketInfoContainer,
Orderbook: OrderbookContainer,
Trades: TradesContainer,
Positions: PositionsContainer,
Orders: OrderListContainer,
Collateral: AccountsContainer,
}; };
type TradingView = keyof typeof TradingViews; type TradingView = keyof typeof TradingViews;
@ -55,7 +55,7 @@ export const TradeMarketHeader = ({
.filter((c): c is CandleClose => c !== null); .filter((c): c is CandleClose => c !== null);
const headerItemClassName = 'whitespace-nowrap flex flex-col'; const headerItemClassName = 'whitespace-nowrap flex flex-col';
const itemClassName = const itemClassName =
'font-sans font-normal mb-0 text-dark/80 dark:text-white/80 text-ui-small'; 'font-sans font-normal mb-0 text-black-60 dark:text-white-80 text-ui-small';
const itemValueClassName = const itemValueClassName =
'capitalize font-sans tracking-tighter text-black dark:text-white text-ui'; 'capitalize font-sans tracking-tighter text-black dark:text-white text-ui';
const headerClassName = classNames( const headerClassName = classNames(
@ -68,7 +68,7 @@ export const TradeMarketHeader = ({
<div className="flex flex-col md:flex-row gap-20 md:gap-64 ml-auto mr-8"> <div className="flex flex-col md:flex-row gap-20 md:gap-64 ml-auto mr-8">
<button <button
onClick={() => setOpen(!open)} onClick={() => setOpen(!open)}
className="shrink-0 dark:text-vega-yellow text-black text-h5 flex items-center gap-8 px-4 py-0 h-37 hover:bg-black/20 dark:hover:bg-white/20" className="shrink-0 text-vega-pink dark:text-vega-yellow font-medium text-h5 flex items-center gap-8 px-4 py-0 h-37 hover:bg-black/10 dark:hover:bg-white/20"
> >
<span className="break-words text-left">{market.name}</span> <span className="break-words text-left">{market.name}</span>
<ArrowDown color="yellow" borderX={8} borderTop={12} /> <ArrowDown color="yellow" borderX={8} borderTop={12} />
@ -76,7 +76,7 @@ export const TradeMarketHeader = ({
<div <div
data-testid="market-summary" data-testid="market-summary"
className="flex flex-auto items-start gap-64 overflow-x-auto whitespace-nowrap w-[400px]" className="flex flex-auto items-start gap-64 overflow-x-auto whitespace-nowrap"
> >
<div className={headerItemClassName}> <div className={headerItemClassName}>
<span className={itemClassName}>Change (24h)</span> <span className={itemClassName}>Change (24h)</span>
@ -119,8 +119,8 @@ interface TradeGridProps {
export const TradeGrid = ({ market }: TradeGridProps) => { export const TradeGrid = ({ market }: TradeGridProps) => {
const wrapperClasses = classNames( const wrapperClasses = classNames(
'h-full max-h-full', 'h-full max-h-full',
'grid gap-4 grid-cols-[1fr_375px_460px] grid-rows-[min-content_1fr_300px]', 'grid gap-x-8 gap-y-4 grid-cols-[1fr_325px_425px] grid-rows-[min-content_1fr_200px]',
'bg-black-10 dark:bg-white-10', 'bg-black-10 dark:bg-black-70',
'text-ui' 'text-ui'
); );
@ -153,24 +153,24 @@ export const TradeGrid = ({ market }: TradeGridProps) => {
</TradeGridChild> </TradeGridChild>
<TradeGridChild className="row-start-2 row-end-3 col-start-3 col-end-4"> <TradeGridChild className="row-start-2 row-end-3 col-start-3 col-end-4">
<Tabs> <Tabs>
<Tab id="trades" name={t('Trades')}>
<TradingViews.Trades marketId={market.id} />
</Tab>
<Tab id="orderbook" name={t('Orderbook')}> <Tab id="orderbook" name={t('Orderbook')}>
<TradingViews.Orderbook marketId={market.id} /> <TradingViews.Orderbook marketId={market.id} />
</Tab> </Tab>
<Tab id="trades" name={t('Trades')}>
<TradingViews.Trades marketId={market.id} />
</Tab>
</Tabs> </Tabs>
</TradeGridChild> </TradeGridChild>
<TradeGridChild className="col-span-3"> <TradeGridChild className="col-span-3">
<Tabs> <Tabs>
<Tab id="orders" name={t('Orders')}>
<TradingViews.Orders />
</Tab>
<Tab id="positions" name={t('Positions')}> <Tab id="positions" name={t('Positions')}>
<TradingViews.Positions /> <TradingViews.Positions />
</Tab> </Tab>
<Tab id="accounts" name={t('Accounts')}> <Tab id="orders" name={t('Orders')}>
<TradingViews.Accounts /> <TradingViews.Orders />
</Tab>
<Tab id="accounts" name={t('Collateral')}>
<TradingViews.Collateral />
</Tab> </Tab>
</Tabs> </Tabs>
</TradeGridChild> </TradeGridChild>

View File

@ -0,0 +1,15 @@
import { t } from '@vegaprotocol/react-helpers';
import { AnchorButton } from '@vegaprotocol/ui-toolkit';
export const DepositsContainer = () => {
return (
<div className="grid grid-cols-[1fr_min-content] gap-12 h-full">
<div />
<div className="p-12">
<AnchorButton data-testid="deposit" href="/portfolio/deposit">
{t('Deposit')}
</AnchorButton>
</div>
</div>
);
};

View File

@ -3,11 +3,13 @@ import { t } from '@vegaprotocol/react-helpers';
import { PositionsContainer } from '@vegaprotocol/positions'; import { PositionsContainer } from '@vegaprotocol/positions';
import { OrderListContainer } from '@vegaprotocol/orders'; import { OrderListContainer } from '@vegaprotocol/orders';
import { AccountsContainer } from '@vegaprotocol/accounts'; import { AccountsContainer } from '@vegaprotocol/accounts';
import { AnchorButton, Tab, Tabs } from '@vegaprotocol/ui-toolkit'; import { Tab, Tabs } from '@vegaprotocol/ui-toolkit';
import { WithdrawalsContainer } from './withdrawals/withdrawals-container'; import { WithdrawalsContainer } from './withdrawals-container';
import { FillsContainer } from '@vegaprotocol/fills'; import { FillsContainer } from '@vegaprotocol/fills';
import classNames from 'classnames'; import classNames from 'classnames';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
import { VegaWalletContainer } from '../../components/vega-wallet-container';
import { DepositsContainer } from './deposits-container';
const Portfolio = () => { const Portfolio = () => {
const wrapperClasses = classNames( const wrapperClasses = classNames(
@ -22,6 +24,7 @@ const Portfolio = () => {
<PortfolioGridChild> <PortfolioGridChild>
<Tabs> <Tabs>
<Tab id="positions" name={t('Positions')}> <Tab id="positions" name={t('Positions')}>
<VegaWalletContainer>
<div className={tabContentClassName}> <div className={tabContentClassName}>
<h4 className="text-h4 text-black dark:text-white p-8"> <h4 className="text-h4 text-black dark:text-white p-8">
{t('Positions')} {t('Positions')}
@ -30,8 +33,10 @@ const Portfolio = () => {
<PositionsContainer /> <PositionsContainer />
</div> </div>
</div> </div>
</VegaWalletContainer>
</Tab> </Tab>
<Tab id="orders" name={t('Orders')}> <Tab id="orders" name={t('Orders')}>
<VegaWalletContainer>
<div className={tabContentClassName}> <div className={tabContentClassName}>
<h4 className="text-h4 text-black dark:text-white p-8"> <h4 className="text-h4 text-black dark:text-white p-8">
{t('Orders')} {t('Orders')}
@ -40,8 +45,10 @@ const Portfolio = () => {
<OrderListContainer /> <OrderListContainer />
</div> </div>
</div> </div>
</VegaWalletContainer>
</Tab> </Tab>
<Tab id="fills" name={t('Fills')}> <Tab id="fills" name={t('Fills')}>
<VegaWalletContainer>
<div className={tabContentClassName}> <div className={tabContentClassName}>
<h4 className="text-h4 text-black dark:text-white p-8"> <h4 className="text-h4 text-black dark:text-white p-8">
{t('Fills')} {t('Fills')}
@ -50,26 +57,25 @@ const Portfolio = () => {
<FillsContainer /> <FillsContainer />
</div> </div>
</div> </div>
</VegaWalletContainer>
</Tab> </Tab>
</Tabs> </Tabs>
</PortfolioGridChild> </PortfolioGridChild>
<PortfolioGridChild> <PortfolioGridChild>
<Tabs> <Tabs>
<Tab id="collateral" name={t('Collateral')}> <Tab id="collateral" name={t('Collateral')}>
<VegaWalletContainer>
<AccountsContainer /> <AccountsContainer />
</VegaWalletContainer>
</Tab> </Tab>
<Tab id="deposits" name={t('Deposits')}> <Tab id="deposits" name={t('Deposits')}>
<div className={tabContentClassName}> <DepositsContainer />
<div className="p-8">
<AnchorButton data-testid="deposit" href="/portfolio/deposit">
{t('Deposit')}
</AnchorButton>
</div>
</div>
</Tab> </Tab>
<Tab id="withdrawals" name={t('Withdrawals')}> <Tab id="withdrawals" name={t('Withdrawals')}>
<Web3Container> <Web3Container>
<VegaWalletContainer>
<WithdrawalsContainer /> <WithdrawalsContainer />
</VegaWalletContainer>
</Web3Container> </Web3Container>
</Tab> </Tab>
</Tabs> </Tabs>

View File

@ -1,6 +1,7 @@
import orderBy from 'lodash/orderBy'; import orderBy from 'lodash/orderBy';
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import { AsyncRenderer, Button } from '@vegaprotocol/ui-toolkit';
import { useWithdrawals, WithdrawalsTable } from '@vegaprotocol/withdraws'; import { useWithdrawals, WithdrawalsTable } from '@vegaprotocol/withdraws';
import Link from 'next/link';
export const WithdrawalsContainer = () => { export const WithdrawalsContainer = () => {
const { data, loading, error } = useWithdrawals(); const { data, loading, error } = useWithdrawals();
@ -16,7 +17,16 @@ export const WithdrawalsContainer = () => {
(w) => new Date(w.createdTimestamp).getTime(), (w) => new Date(w.createdTimestamp).getTime(),
'desc' 'desc'
); );
return <WithdrawalsTable withdrawals={withdrawals} />; return (
<div className="grid grid-cols-[1fr_min-content] gap-12 h-full">
<WithdrawalsTable withdrawals={withdrawals} />
<div className="p-12">
<Link href="/portfolio/withdraw" passHref={true}>
<Button data-testid="start-withdrawal">Withdraw</Button>
</Link>
</div>
</div>
);
}} }}
/> />
); );

View File

@ -1,25 +1,12 @@
import { t } from '@vegaprotocol/react-helpers';
import { AnchorButton } from '@vegaprotocol/ui-toolkit';
import { VegaWalletContainer } from '../../../components/vega-wallet-container'; import { VegaWalletContainer } from '../../../components/vega-wallet-container';
import { Web3Container } from '../../../components/web3-container'; import { Web3Container } from '../../../components/web3-container';
import { WithdrawalsContainer } from './withdrawals-container'; import { WithdrawalsContainer } from '../withdrawals-container';
const Withdrawals = () => { const Withdrawals = () => {
return ( return (
<VegaWalletContainer> <VegaWalletContainer>
<Web3Container> <Web3Container>
<div className="h-full grid grid grid-rows-[min-content,1fr]">
<header className="flex justify-between p-24">
<h1 className="text-h3">{t('Withdrawals')}</h1>
<AnchorButton
href="/portfolio/withdraw"
data-testid="start-withdrawal"
>
{t('Start withdrawal')}
</AnchorButton>
</header>
<WithdrawalsContainer /> <WithdrawalsContainer />
</div>
</Web3Container> </Web3Container>
</VegaWalletContainer> </VegaWalletContainer>
); );

View File

@ -32,7 +32,7 @@ export const DealTicketLimitAmount = ({
/> />
</FormGroup> </FormGroup>
</div> </div>
<div>@</div> <div className="pt-4 text-black dark:text-white">@</div>
<div className="flex-1"> <div className="flex-1">
<FormGroup <FormGroup
labelFor="input-price-quote" labelFor="input-price-quote"

View File

@ -33,8 +33,11 @@ export const DealTicketMarketAmount = ({
/> />
</FormGroup> </FormGroup>
</div> </div>
<div className="pt-4">@</div> <div className="pt-4 text-black dark:text-white">@</div>
<div className="flex-1 pt-4" data-testid="last-price"> <div
className="flex-1 pt-4 text-black dark:text-white"
data-testid="last-price"
>
{price && quoteName ? ( {price && quoteName ? (
<> <>
~{price} {quoteName} ~{price} {quoteName}

View File

@ -62,7 +62,7 @@ export const DealTicket = ({
); );
return ( return (
<form onSubmit={handleSubmit(onSubmit)} className="px-4 py-8" noValidate> <form onSubmit={handleSubmit(onSubmit)} className="px-12 py-8" noValidate>
<Controller <Controller
name="type" name="type"
control={control} control={control}

View File

@ -134,7 +134,7 @@ export const MarketInfoContainer = ({ marketId }: MarketInfoContainerProps) => {
export const Info = ({ market }: InfoProps) => { export const Info = ({ market }: InfoProps) => {
const headerClassName = const headerClassName =
'text-h5 font-bold uppercase text-black dark:text-white'; 'text-h5 font-medium uppercase text-black dark:text-white';
const marketDataPanels = [ const marketDataPanels = [
{ {
title: t('Current fees'), title: t('Current fees'),

View File

@ -8,12 +8,19 @@ interface DepositLimitsProps {
} }
export const DepositLimits = ({ limits }: DepositLimitsProps) => { export const DepositLimits = ({ limits }: DepositLimitsProps) => {
const maxLimit = limits.max.isEqualTo(Infinity) let maxLimit = '';
? t('No limit')
: limits.max.toString(); if (limits.max.isEqualTo(Infinity)) {
maxLimit = t('No limit');
} else if (limits.max.isGreaterThan(1_000_000)) {
maxLimit = t('1m+');
} else {
maxLimit = limits.max.toString();
}
return ( return (
<> <>
<p className="text-ui font-bold">{t('Temporary deposit limits')}</p> <p className="text-ui font-bold">{t('Deposit limits')}</p>
<table className="w-full text-ui"> <table className="w-full text-ui">
<tbody> <tbody>
<tr> <tr>

View File

@ -77,7 +77,7 @@ export const DepositManager = ({
const allowance = useGetAllowance(tokenContract, decimals); const allowance = useGetAllowance(tokenContract, decimals);
// Set up approve transaction // Set up approve transaction
const approve = useSubmitApproval(tokenContract); const approve = useSubmitApproval(tokenContract, decimals);
// Set up deposit transaction // Set up deposit transaction
const { confirmationEvent, ...deposit } = useSubmitDeposit(); const { confirmationEvent, ...deposit } = useSubmitDeposit();

View File

@ -1,17 +1,21 @@
import { removeDecimal } from '@vegaprotocol/react-helpers';
import type { Token } from '@vegaprotocol/smart-contracts'; import type { Token } from '@vegaprotocol/smart-contracts';
import { useEthereumConfig, useEthereumTransaction } from '@vegaprotocol/web3'; import { useEthereumConfig, useEthereumTransaction } from '@vegaprotocol/web3';
export const useSubmitApproval = (contract: Token | null) => { export const useSubmitApproval = (
contract: Token | null,
decimals: number | undefined
) => {
const { config } = useEthereumConfig(); const { config } = useEthereumConfig();
const transaction = useEthereumTransaction(() => { const transaction = useEthereumTransaction(() => {
if (!contract || !config) { if (!contract || !config || decimals === undefined) {
return null; return null;
} }
return contract.approve(
config.collateral_bridge_contract.address, const amount = removeDecimal('1000000', decimals);
Number.MAX_SAFE_INTEGER.toString()
); return contract.approve(config.collateral_bridge_contract.address, amount);
}); });
return transaction; return transaction;

View File

@ -66,7 +66,7 @@ export const OrderbookRow = React.memo(
relativeAsk={cumulativeRelativeAsk} relativeAsk={cumulativeRelativeAsk}
relativeBid={cumulativeRelativeBid} relativeBid={cumulativeRelativeBid}
indicativeVolume={indicativeVolume} indicativeVolume={indicativeVolume}
className="pr-4" className="pr-4 text-black dark:text-white"
/> />
</> </>
); );

View File

@ -282,7 +282,7 @@ export const Orderbook = ({
const hasData = renderedRows.data && renderedRows.data.length !== 0; const hasData = renderedRows.data && renderedRows.data.length !== 0;
return ( return (
<div <div
className={`h-full overflow-auto relative ${styles['scroll']}`} className={`h-full overflow-auto relative ${styles['scroll']} pl-4 pt-4`}
onScroll={onScroll} onScroll={onScroll}
ref={scrollElement} ref={scrollElement}
data-testid="scroll" data-testid="scroll"
@ -354,7 +354,7 @@ export const Orderbook = ({
<select <select
onChange={(e) => onResolutionChange(Number(e.currentTarget.value))} onChange={(e) => onResolutionChange(Number(e.currentTarget.value))}
value={resolution} value={resolution}
className="block bg-black-25 dark:bg-white-25 text-black dark:text-white focus-visible:shadow-focus dark:focus-visible:shadow-focus-dark focus-visible:outline-0 font-mono w-100 text-right w-full h-full" className="block bg-black-10 dark:bg-black-70 text-black dark:text-white focus-visible:shadow-focus dark:focus-visible:shadow-focus-dark focus-visible:outline-0 font-mono w-100 text-right w-full h-full"
data-testid="resolution" data-testid="resolution"
> >
{new Array(3) {new Array(3)

View File

@ -67,6 +67,7 @@ export const SelectMarketList = ({
onKeyPress={(event) => handleKeyPress(event, id)} onKeyPress={(event) => handleKeyPress(event, id)}
onClick={() => onSelect(id)} onClick={() => onSelect(id)}
data-testid={`market-link-${id}`} data-testid={`market-link-${id}`}
className={`focus:decoration-vega-yellow`}
> >
{marketName} {marketName}
</a> </a>
@ -106,7 +107,10 @@ export const SelectMarketList = ({
</tbody> </tbody>
</table> </table>
<a className={`${boldUnderlineClassNames} text-ui-small`} href="/markets"> <a
className={`${boldUnderlineClassNames} text-ui-small focus:decoration-vega-yellow`}
href="/markets"
>
{t('Or view full market list')} {t('Or view full market list')}
</a> </a>
</div> </div>

View File

@ -20,13 +20,13 @@ export const PriceCell = React.memo(
: [value]; : [value];
return ( return (
<span <span
className="font-mono relative text-ui-small" className="font-mono relative text-ui-small text-black dark:text-white"
data-testid={testId || 'price'} data-testid={testId || 'price'}
> >
{valueSplit[0]} {valueSplit[0]}
{valueSplit[1] ? decimalSeparator : null} {valueSplit[1] ? decimalSeparator : null}
{valueSplit[1] ? ( {valueSplit[1] ? (
<span className="text-black-muted dark:text-white-muted"> <span className="text-black-60 dark:text-white-60">
{valueSplit[1]} {valueSplit[1]}
</span> </span>
) : null} ) : null}

View File

@ -36,6 +36,9 @@ export class CollateralBridgeNew {
isAssetListed(address: string) { isAssetListed(address: string) {
return this.contract.is_asset_listed(address); return this.contract.is_asset_listed(address);
} }
getWithdrawThreshold(assetSource: string) {
return this.contract.get_withdraw_threshold(assetSource);
}
withdrawAsset( withdrawAsset(
assetSource: string, assetSource: string,
amount: string, amount: string,

View File

@ -41,6 +41,9 @@ export class CollateralBridge {
isAssetListed(address: string) { isAssetListed(address: string) {
return this.contract.is_asset_listed(address); return this.contract.is_asset_listed(address);
} }
getWithdrawThreshold(assetSource: string) {
return this.contract.get_withdraw_threshold(assetSource);
}
withdrawAsset( withdrawAsset(
assetSource: string, assetSource: string,
amount: string, amount: string,

View File

@ -59,13 +59,13 @@ export const TradesTable = forwardRef<AgGridReact, TradesTableProps>(
getRowId={({ data }) => data.id} getRowId={({ data }) => data.id}
ref={ref} ref={ref}
defaultColDef={{ defaultColDef={{
flex: 1,
resizable: true, resizable: true,
}} }}
> >
<AgGridColumn <AgGridColumn
headerName={t('Price')} headerName={t('Price')}
field="price" field="price"
width={130}
cellClass={changeCellClass('price')} cellClass={changeCellClass('price')}
valueFormatter={({ value, data }: ValueFormatterParams) => { valueFormatter={({ value, data }: ValueFormatterParams) => {
return addDecimalsFormatNumber(value, data.market.decimalPlaces); return addDecimalsFormatNumber(value, data.market.decimalPlaces);
@ -74,6 +74,7 @@ export const TradesTable = forwardRef<AgGridReact, TradesTableProps>(
<AgGridColumn <AgGridColumn
headerName={t('Size')} headerName={t('Size')}
field="size" field="size"
width={125}
valueFormatter={({ value, data }: ValueFormatterParams) => { valueFormatter={({ value, data }: ValueFormatterParams) => {
return addDecimal(value, data.market.positionDecimalPlaces); return addDecimal(value, data.market.positionDecimalPlaces);
}} }}
@ -82,6 +83,7 @@ export const TradesTable = forwardRef<AgGridReact, TradesTableProps>(
<AgGridColumn <AgGridColumn
headerName={t('Created at')} headerName={t('Created at')}
field="createdAt" field="createdAt"
width={170}
valueFormatter={({ value }: ValueFormatterParams) => { valueFormatter={({ value }: ValueFormatterParams) => {
return getDateTimeFormat().format(new Date(value)); return getDateTimeFormat().format(new Date(value));
}} }}

View File

@ -36,7 +36,7 @@ export const Accordion = ({ panels }: AccordionProps) => {
className={triggerClassNames} className={triggerClassNames}
> >
<p <p
className="inline-block text-footnote font-bold text-h6 text-black dark:text-white pt-5" className="inline-block text-footnote font-medium text-h6 text-black dark:text-white pt-5"
data-testid="accordion-title" data-testid="accordion-title"
> >
{title} {title}

View File

@ -4,22 +4,22 @@ export const ChevronDownIcon = ({ active }: ChevronDownIconProps) => {
: 'transform duration-300 ease'; : 'transform duration-300 ease';
return ( return (
<svg <svg
width="20" width="14"
height="20" height="8"
aria-label="chevron icon" aria-label="chevron icon"
data-testid="accordion-chevron-icon" data-testid="accordion-chevron-icon"
viewBox="0 0 20 20" viewBox="0 0 14 8"
fill="fillCurrent" fill="fillCurrent"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
className={`${rotate} inline-block fill-black dark:fill-white`} className={`${rotate} inline-block fill-black dark:fill-white mx-4`}
> >
<rect x="17" y="8" width="2" height="2" /> <rect x="12" y="0" width="2" height="2" />
<rect x="15" y="10" width="2" height="2" /> <rect x="10" y="2" width="2" height="2" />
<rect x="13" y="12" width="2" height="2" /> <rect x="8" y="4" width="2" height="2" />
<rect x="11" y="14" width="2" height="2" /> <rect x="6" y="6" width="2" height="2" />
<rect x="9" y="12" width="2" height="2" /> <rect x="4" y="4" width="2" height="2" />
<rect x="7" y="10" width="2" height="2" /> <rect x="2" y="2" width="2" height="2" />
<rect x="5" y="8" width="2" height="2" /> <rect x="0" y="0" width="2" height="2" />
</svg> </svg>
); );
}; };

View File

@ -42,7 +42,7 @@ export function Dialog({
/> />
<DialogPrimitives.Content className={contentClasses}> <DialogPrimitives.Content className={contentClasses}>
<DialogPrimitives.Close <DialogPrimitives.Close
className="p-2 absolute top-8 right-8 leading-[0] focus:outline-none focus-visible:outline-none focus-visible:border focus-visible:border-vega-yellow" className="p-2 absolute top-8 right-8 leading-[0] focus:outline-none focus-visible:outline-none focus-visible:border focus-visible:border-vega-yellow focus-visible:top-[7px] focus-visible:right-[7px]"
data-testid="dialog-close" data-testid="dialog-close"
> >
<Icon <Icon

View File

@ -44,7 +44,7 @@ export const DropdownMenuTrigger = forwardRef<
<DropdownMenuPrimitive.Trigger <DropdownMenuPrimitive.Trigger
asChild={true} asChild={true}
ref={forwardedRef} ref={forwardedRef}
className="focus-visible:outline-none focus-visible:shadow-inset-vega-pink dark:focus-visible:shadow-inset-vega-yellow" className="focus-visible:outline-none focus-visible:shadow-inset-vega-pink dark:focus-visible:shadow-inset-vega-yellow transition-none hover:bg-white-95 dark:hover:bg-black-80"
> >
<Button <Button
variant="secondary" variant="secondary"

View File

@ -33,14 +33,14 @@ export const FormGroup = ({
{ {
<div <div
className={classNames( className={classNames(
'mb-4 text-body-large text-black dark:text-white', 'mb-4 text-large text-black dark:text-white',
{ {
'border-l-4 border-danger pl-8': hasError, 'border-l-4 border-danger pl-8': hasError,
'text-right': labelAlign === 'right', 'text-right': labelAlign === 'right',
} }
)} )}
> >
<div className="font-bold mb-2">{label}</div> <div className="font-medium mb-2">{label}</div>
{labelDescription && ( {labelDescription && (
<div className={classNames({ 'text-danger': hasError })}> <div className={classNames({ 'text-danger': hasError })}>
{labelDescription} {labelDescription}

View File

@ -135,6 +135,7 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(
'appearance-none', 'appearance-none',
'h-28', 'h-28',
'dark:color-scheme-dark', 'dark:color-scheme-dark',
'shadow-input dark:shadow-input-dark',
className, className,
{ {
'pl-28': hasPrepended, 'pl-28': hasPrepended,

View File

@ -18,11 +18,12 @@ export const Tabs = ({ children }: TabsProps) => {
className="h-full grid grid-rows-[min-content_1fr]" className="h-full grid grid-rows-[min-content_1fr]"
onValueChange={(value) => setActiveTab(value)} onValueChange={(value) => setActiveTab(value)}
> >
<div className="bg-black-10 dark:bg-white-10"> <div className="bg-black-10 dark:bg-black-70">
<TabsPrimitive.List <TabsPrimitive.List
className="flex flex-nowrap gap-4 overflow-x-auto" className="flex flex-nowrap overflow-x-auto"
role="tablist" role="tablist"
> >
<div className="gap-4 bg-white dark:bg-black flex border-r-4 border-r-white dark:border-r-black inline-block">
{Children.map(children, (child) => { {Children.map(children, (child) => {
if (!isValidElement(child)) return null; if (!isValidElement(child)) return null;
const isActive = child.props.id === activeTab; const isActive = child.props.id === activeTab;
@ -30,8 +31,10 @@ export const Tabs = ({ children }: TabsProps) => {
'py-4 px-20', 'py-4 px-20',
'capitalize', 'capitalize',
'focus-visible:outline-none focus-visible:shadow-inset-vega-pink dark:focus-visible:shadow-inset-vega-yellow', 'focus-visible:outline-none focus-visible:shadow-inset-vega-pink dark:focus-visible:shadow-inset-vega-yellow',
'transition-[font-weight] duration-75',
'inline-block after:content-[attr(data-testid)] after:block after:font-bold after:invisible after:overflow-hidden after:h-0',
{ {
'font-semibold text-vega-pink dark:text-vega-yellow': isActive, 'text-vega-pink dark:text-vega-yellow font-bold': isActive,
'bg-white dark:bg-black': isActive, 'bg-white dark:bg-black': isActive,
'text-black dark:text-white': !isActive, 'text-black dark:text-white': !isActive,
'bg-white-90 dark:bg-black-70 hover:bg-white-95 dark:hover:bg-black-80': 'bg-white-90 dark:bg-black-70 hover:bg-white-95 dark:hover:bg-black-80':
@ -48,6 +51,7 @@ export const Tabs = ({ children }: TabsProps) => {
</TabsPrimitive.Trigger> </TabsPrimitive.Trigger>
); );
})} })}
</div>
</TabsPrimitive.List> </TabsPrimitive.List>
</div> </div>
<div className="h-full overflow-auto"> <div className="h-full overflow-auto">

View File

@ -11,7 +11,12 @@ export interface TextAreaProps
export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>( export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
({ className, hasError, ...props }, ref) => { ({ className, hasError, ...props }, ref) => {
const classes = classNames(defaultFormElement(hasError), className); const textAreaClassName = classNames(
'shadow-input dark:shadow-input-dark',
className
);
const classes = classNames(defaultFormElement(hasError), textAreaClassName);
return <textarea {...props} ref={ref} className={classes} />; return <textarea {...props} ref={ref} className={classes} />;
} }
); );

View File

@ -13,7 +13,7 @@ export const ThemeSwitcher = ({
sunClassName?: string; sunClassName?: string;
moonClassName?: string; moonClassName?: string;
}) => { }) => {
const sunClasses = classNames('dark:hidden text-black', sunClassName); const sunClasses = classNames('dark:hidden text-white', sunClassName);
const moonClasses = classNames( const moonClasses = classNames(
'hidden dark:inline text-white', 'hidden dark:inline text-white',
moonClassName moonClassName

View File

@ -6,7 +6,6 @@ export const defaultFormElement = (hasError?: boolean) =>
'box-border', 'box-border',
'border rounded-none', 'border rounded-none',
'bg-clip-padding', 'bg-clip-padding',
'shadow-input dark:shadow-input-dark',
'bg-white dark:bg-white-25', 'bg-white dark:bg-white-25',
'text-black placeholder:text-black-60 dark:text-white dark:placeholder:text-white-60', 'text-black placeholder:text-black-60 dark:text-white dark:placeholder:text-white-60',
'text-ui', 'text-ui',

View File

@ -0,0 +1,28 @@
import { useCallback } from 'react';
import type { Asset } from './types';
import { useBridgeContract, useEthereumReadContract } from '@vegaprotocol/web3';
import BigNumber from 'bignumber.js';
import { addDecimal } from '@vegaprotocol/react-helpers';
export const useGetWithdrawLimits = (asset?: Asset) => {
const contract = useBridgeContract(true);
const getLimits = useCallback(async () => {
if (!contract || !asset || asset.source.__typename !== 'ERC20') {
return;
}
return contract.getWithdrawThreshold(asset.source.contractAddress);
}, [asset, contract]);
const {
state: { data },
} = useEthereumReadContract(getLimits);
if (!data || !asset) return null;
const max = new BigNumber(addDecimal(data.toString(), asset.decimals));
return {
max: max.isEqualTo(0) ? new BigNumber(Infinity) : max,
};
};

View File

@ -104,7 +104,10 @@ export const useWithdraw = (cancelled: boolean, isNewContract: boolean) => {
); );
useEffect(() => { useEffect(() => {
if (data?.erc20WithdrawalApproval) { if (
data?.erc20WithdrawalApproval &&
data.erc20WithdrawalApproval.signatures.length > 2
) {
stopPolling(); stopPolling();
setApproval(data.erc20WithdrawalApproval); setApproval(data.erc20WithdrawalApproval);
} }

View File

@ -20,6 +20,9 @@ beforeEach(() => {
assets, assets,
min: new BigNumber(0.00001), min: new BigNumber(0.00001),
max: new BigNumber(100), max: new BigNumber(100),
limits: {
max: new BigNumber(200),
},
ethereumAccount: undefined, ethereumAccount: undefined,
selectedAsset: undefined, selectedAsset: undefined,
onSelectAsset: jest.fn(), onSelectAsset: jest.fn(),

View File

@ -18,6 +18,7 @@ import type { ButtonHTMLAttributes, ReactNode } from 'react';
import { useForm, Controller } from 'react-hook-form'; import { useForm, Controller } from 'react-hook-form';
import type { WithdrawalFields } from './use-withdraw'; import type { WithdrawalFields } from './use-withdraw';
import type { Asset } from './types'; import type { Asset } from './types';
import { WithdrawLimits } from './withdraw-limits';
interface FormFields { interface FormFields {
asset: string; asset: string;
@ -31,6 +32,9 @@ export interface WithdrawFormProps {
min: BigNumber; min: BigNumber;
selectedAsset?: Asset; selectedAsset?: Asset;
ethereumAccount?: string; ethereumAccount?: string;
limits: {
max: BigNumber;
} | null;
onSelectAsset: (assetId: string) => void; onSelectAsset: (assetId: string) => void;
submitWithdraw: (withdrawal: WithdrawalFields) => void; submitWithdraw: (withdrawal: WithdrawalFields) => void;
} }
@ -41,6 +45,7 @@ export const WithdrawForm = ({
min, min,
selectedAsset, selectedAsset,
ethereumAccount, ethereumAccount,
limits,
onSelectAsset, onSelectAsset,
submitWithdraw, submitWithdraw,
}: WithdrawFormProps) => { }: WithdrawFormProps) => {
@ -134,7 +139,11 @@ export const WithdrawForm = ({
</UseButton> </UseButton>
)} )}
</FormGroup> </FormGroup>
{selectedAsset && limits && (
<div className="mb-20">
<WithdrawLimits limits={limits} />
</div>
)}
<FormGroup label={t('Amount')} labelFor="amount" className="relative"> <FormGroup label={t('Amount')} labelFor="amount" className="relative">
<Input <Input
type="number" type="number"

View File

@ -0,0 +1,34 @@
import { t } from '@vegaprotocol/react-helpers';
import type BigNumber from 'bignumber.js';
interface WithdrawLimitsProps {
limits: {
max: BigNumber;
};
}
export const WithdrawLimits = ({ limits }: WithdrawLimitsProps) => {
let maxLimit = '';
if (limits.max.isEqualTo(Infinity)) {
maxLimit = t('No limit');
} else if (limits.max.isGreaterThan(1_000_000)) {
maxLimit = t('1m+');
} else {
maxLimit = limits.max.toString();
}
return (
<>
<p className="text-ui font-bold">{t('Withdraw limits')}</p>
<table className="w-full text-ui">
<tbody>
<tr>
<th className="text-left font-normal">{t('Maximum')}</th>
<td className="text-right">{maxLimit}</td>
</tr>
</tbody>
</table>
</>
);
};

View File

@ -9,6 +9,7 @@ import {
EthTxStatus, EthTxStatus,
initialState as ethTxInitialState, initialState as ethTxInitialState,
} from '@vegaprotocol/web3'; } from '@vegaprotocol/web3';
import BigNumber from 'bignumber.js';
const ethereumAddress = '0x72c22822A19D20DE7e426fB84aa047399Ddd8853'; const ethereumAddress = '0x72c22822A19D20DE7e426fB84aa047399Ddd8853';
@ -16,6 +17,12 @@ jest.mock('@web3-react/core', () => ({
useWeb3React: () => ({ account: ethereumAddress }), useWeb3React: () => ({ account: ethereumAddress }),
})); }));
jest.mock('./use-get-withdraw-limits', () => ({
useGetWithdrawLimits: () => {
return { max: new BigNumber(1000000) };
},
}));
let props: WithdrawManagerProps; let props: WithdrawManagerProps;
let useWithdrawValue: ReturnType<typeof withdrawHook.useWithdraw>; let useWithdrawValue: ReturnType<typeof withdrawHook.useWithdraw>;
let useWithdraw: jest.SpyInstance; let useWithdraw: jest.SpyInstance;

View File

@ -10,6 +10,7 @@ import { AccountType } from '@vegaprotocol/types';
import BigNumber from 'bignumber.js'; import BigNumber from 'bignumber.js';
import type { Account, Asset } from './types'; import type { Account, Asset } from './types';
import { useWeb3React } from '@web3-react/core'; import { useWeb3React } from '@web3-react/core';
import { useGetWithdrawLimits } from './use-get-withdraw-limits';
export interface WithdrawManagerProps { export interface WithdrawManagerProps {
assets: Asset[]; assets: Asset[];
@ -39,6 +40,8 @@ export const WithdrawManager = ({
return assets?.find((a) => a.id === assetId); return assets?.find((a) => a.id === assetId);
}, [assets, assetId]); }, [assets, assetId]);
const limits = useGetWithdrawLimits(asset);
const max = useMemo(() => { const max = useMemo(() => {
if (!asset) { if (!asset) {
return new BigNumber(0); return new BigNumber(0);
@ -48,13 +51,11 @@ export const WithdrawManager = ({
(a) => a.type === AccountType.General && a.asset.id === asset.id (a) => a.type === AccountType.General && a.asset.id === asset.id
); );
if (!account) { const v = account
return new BigNumber(0); ? new BigNumber(addDecimal(account.balance, asset.decimals))
} : new BigNumber(0);
return BigNumber.minimum(v, limits ? limits.max : new BigNumber(Infinity));
const v = new BigNumber(addDecimal(account.balance, asset.decimals)); }, [asset, accounts, limits]);
return v;
}, [asset, accounts]);
const min = useMemo(() => { const min = useMemo(() => {
return asset return asset
@ -92,6 +93,7 @@ export const WithdrawManager = ({
max={max} max={max}
min={min} min={min}
submitWithdraw={handleSubmit} submitWithdraw={handleSubmit}
limits={limits}
/> />
<WithdrawDialog <WithdrawDialog
vegaTx={vegaTx} vegaTx={vegaTx}