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
env:
GO111MODULE: 'on'
GOPROXY: ${{ secrets.GO_PROXY }}
steps:
#######
## Setup langs

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,28 +1,44 @@
const pageSpinner = 'splash-loader';
const menuBar = 'nav';
const validatorList = '[data-testid="node-list-item-name"]';
const removeStakeRadioButton = '[data-testid="remove-stake-radio"]';
const tokenAmountInputBox = '[data-testid="token-amount-input"]';
const tokenSubmitButton = '[data-testid="token-input-submit-button"]';
/// <reference types="cypress" />
const stakeValidatorList = '[data-testid="node-list-item-name"]';
const stakeValidatorWithinList = '[data-testid="node-list-item"]';
const stakeRemoveStakeRadioButton = '[data-testid="remove-stake-radio"]';
const stakeTokenAmountInputBox = '[data-testid="token-amount-input"]';
const stakeTokenSubmitButton = '[data-testid="token-input-submit-button"]';
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 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 () {
before('visit staking tab and connect vega wallet', function () {
cy.vega_wallet_import();
cy.visit('/');
cy.get(menuBar, { timeout: 20000 }).should('be.visible');
cy.verify_page_header('The $VEGA token');
cy.vega_wallet_connect();
cy.vega_wallet_set_specified_approval_amount('1000');
cy.reload();
cy.get(menuBar, { timeout: 20000 }).should('be.visible');
cy.verify_page_header('The $VEGA token');
cy.ethereum_wallet_connect();
cy.navigate_to('staking');
cy.get(pageSpinner, { timeout: 20000 }).should('not.exist');
cy.get(validatorList).first().invoke('text').as('validatorName');
cy.get(validatorList).last().invoke('text').as('otherValidatorName');
cy.wait_for_spinner();
cy.get(stakeValidatorList).first().invoke('text').as('validatorName');
cy.get(stakeValidatorList).last().invoke('text').as('otherValidatorName');
});
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 () {
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.ethereum_wallet_check_associated_vega_key_value_is(
vegaWalletPublicKeyShort,
'3.000000000000000000'
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
3.0,
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(validatorList).contains(this.validatorName).click();
cy.get(stakeValidatorList).contains(this.validatorName).click();
cy.staking_validator_page_add_stake('2');
vega_wallet_check_validator_stake_next_epoch_value_is(
this.validatorName,
'2.000000000000000000'
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');
vega_wallet_check_validator_staked_value_is(
this.validatorName,
'2.000000000000000000'
);
staking_validator_page_check_stake_next_epoch_value('2.0');
staking_validator_page_check_stake_this_epoch_value('2.0');
cy.get(vegaWalletStakedBalances, txTimeout)
.should('contain', 2.0, txTimeout)
.and('contain', this.validatorName);
cy.get(stakeNextEpochValue, epochTimeout)
.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 () {
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(validatorList).contains(this.validatorName).click();
cy.get(stakeValidatorList).contains(this.validatorName).click();
cy.staking_validator_page_add_stake('2');
vega_wallet_check_validator_staked_value_is(
this.validatorName,
'2.000000000000000000'
);
cy.get(vegaWalletStakedBalances, txTimeout)
.contains(this.validatorName, txTimeout)
.parent()
.should('contain', 2.0, txTimeout);
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');
vega_wallet_check_validator_staked_value_is(
this.otherValidatorName,
'1.000000000000000000'
cy.get(vegaWalletStakedBalances, txTimeout)
.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.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(validatorList).contains(this.validatorName).click();
cy.get(stakeValidatorList).contains(this.validatorName).click();
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(
this.validatorName,
'3.000000000000000000'
cy.get(stakeNextEpochValue, epochTimeout)
.contains(3.0, epochTimeout)
.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.get(validatorList).contains(this.validatorName).click();
cy.get(stakeValidatorList).contains(this.validatorName).click();
cy.staking_validator_page_removeStake('1');
staking_validator_page_check_stake_next_epoch_value('2.0');
staking_validator_page_check_stake_this_epoch_value('3.0');
vega_wallet_check_validator_stake_next_epoch_value_is(
this.validatorName,
'2.000000000000000000'
cy.staking_validator_page_remove_stake('1');
cy.get(stakeNextEpochValue, epochTimeout)
.contains(2.0, epochTimeout)
.should('be.visible');
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,
'3.000000000000000000'
);
cy.vega_wallet_check_unstaked_value_is('2.000000000000000000');
vega_wallet_check_validator_staked_value_is(
this.validatorName,
'2.000000000000000000'
);
staking_validator_page_check_stake_next_epoch_value('2.0');
staking_validator_page_check_stake_this_epoch_value('2.0');
cy.get(vegaWalletStakedBalances, txTimeout)
.should('contain', 2.0, txTimeout)
.and('contain', this.validatorName);
cy.get(stakeNextEpochValue, epochTimeout)
.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 remove a full stake against a validator', function () {
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(validatorList).contains(this.validatorName).click();
cy.get(stakeValidatorList).contains(this.validatorName).click();
cy.staking_validator_page_add_stake('1');
vega_wallet_check_validator_stake_next_epoch_value_is(
this.validatorName,
'1.000000000000000000'
cy.get(vegaWalletNextEpochBalances, txTimeout)
.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.get(validatorList).contains(this.validatorName).click();
cy.staking_validator_page_removeStake('1');
staking_validator_page_check_stake_next_epoch_value('0.0');
cy.get(stakeValidatorList).contains(this.validatorName).click();
vega_wallet_check_validator_stake_this_epoch_value_is(
this.validatorName,
'1.000000000000000000'
cy.staking_validator_page_remove_stake('1');
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,
'0.000000000000000000'
);
cy.vega_wallet_check_unstaked_value_is('3.000000000000000000');
staking_validator_page_check_stake_next_epoch_value('0.0');
staking_validator_page_check_stake_this_epoch_value('0.0');
vega_wallet_check_validator_no_longer_showing(this.validatorName);
cy.get(stakeNextEpochValue, epochTimeout)
.contains(0.0, epochTimeout)
.should('be.visible');
cy.get(stakeThisEpochValue, epochTimeout)
.contains(0.0, epochTimeout)
.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.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(validatorList).contains(this.validatorName).click();
cy.get(stakeValidatorList).contains(this.validatorName).click();
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(
this.validatorName,
'2.000000000000000000'
cy.get(stakeNextEpochValue, epochTimeout)
.contains(2.0, epochTimeout)
.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.get(validatorList).contains(this.validatorName).click();
cy.get(removeStakeRadioButton).click({ force: true });
cy.get(tokenAmountInputBox).type('-0.1');
cy.contains('Waiting for next epoch to start', { timeout: 10000 });
cy.get(tokenSubmitButton)
.should('be.disabled', { timeout: 8000 })
cy.get(stakeValidatorList).contains(this.validatorName).click();
cy.get(stakeRemoveStakeRadioButton).click({ force: true });
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('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.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(validatorList).contains(this.validatorName).click();
cy.get(stakeValidatorList).contains(this.validatorName).click();
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(
this.validatorName,
'2.000000000000000000'
cy.get(stakeNextEpochValue, epochTimeout)
.contains(2.0, epochTimeout)
.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.get(validatorList).contains(this.validatorName).click();
cy.get(removeStakeRadioButton).click({ force: true });
cy.get(tokenAmountInputBox).type(4);
cy.contains('Waiting for next epoch to start', { timeout: 10000 });
cy.get(tokenSubmitButton)
.should('be.disabled', { timeout: 8000 })
cy.get(stakeValidatorList).contains(this.validatorName).click();
cy.get(stakeRemoveStakeRadioButton).click({ force: true });
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('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.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(validatorList).contains(this.validatorName).click();
cy.get(stakeValidatorList).contains(this.validatorName).click();
cy.staking_validator_page_add_stake('2');
cy.vega_wallet_check_unstaked_value_is('1.000000000000000000');
vega_wallet_check_validator_staked_value_is(
this.validatorName,
'2.000000000000000000'
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
1.0,
txTimeout
);
cy.get(vegaWalletStakedBalances, txTimeout)
.should('contain', 2.0, txTimeout)
.and('contain', this.validatorName);
cy.navigate_to('staking');
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.get(ethWalletTotalAssociatedBalance, txTimeout)
.contains('0.0', txTimeout)
.should('be.visible');
cy.get(vegaWalletAssociatedBalance, txTimeout).should(
'contain',
'0.000000000000000000',
txTimeout
);
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(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 () {
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(validatorList).contains(this.validatorName).click();
cy.get(stakeValidatorList).contains(this.validatorName).click();
cy.staking_validator_page_add_stake('2');
cy.vega_wallet_check_unstaked_value_is('1.000000000000000000');
vega_wallet_check_validator_staked_value_is(
this.validatorName,
'2.000000000000000000'
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
1.0,
txTimeout
);
cy.get(vegaWalletStakedBalances, txTimeout)
.should('contain', 2.0, txTimeout)
.and('contain', this.validatorName);
cy.navigate_to('staking');
cy.staking_page_disassociate_tokens('1');
cy.ethereum_wallet_check_associated_value_is('2.0');
cy.vega_wallet_check_associated_value_is('2.000000000000000000');
vega_wallet_check_validator_staked_value_is(
this.validatorName,
'2.000000000000000000'
cy.get(ethWalletTotalAssociatedBalance, txTimeout)
.contains('2.0', txTimeout)
.should('be.visible');
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(
@ -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 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');
context(
@ -10,14 +15,14 @@ context(
before('visit staking tab and connect vega wallet', function () {
cy.vega_wallet_import();
cy.visit('/');
cy.get(menuBar, { timeout: 20000 }).should('be.visible');
cy.verify_page_header('The $VEGA token');
cy.vega_wallet_connect();
cy.vega_wallet_set_specified_approval_amount('1000');
cy.reload();
cy.get(menuBar, { timeout: 20000 }).should('be.visible');
cy.verify_page_header('The $VEGA token');
cy.ethereum_wallet_connect();
cy.navigate_to('staking');
cy.get(pageSpinner, { timeout: 20000 }).should('not.exist');
cy.wait_for_spinner();
cy.get(validatorList).first().invoke('text').as('validatorName');
});
@ -27,71 +32,140 @@ context(
function () {
cy.vega_wallet_teardown();
cy.navigate_to('staking');
cy.get(pageSpinner, { timeout: 20000 }).should('not.exist');
cy.wait_for_spinner();
}
);
it('Able to associate tokens', function () {
cy.staking_page_associate_tokens('2');
cy.ethereum_wallet_check_associated_vega_key_value_is(
vegaWalletPublicKeyShort,
'2.000000000000000000'
cy.get(ethWalletAssociatedBalances, txTimeout)
.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 () {
cy.staking_page_associate_tokens('2');
cy.ethereum_wallet_check_associated_vega_key_value_is(
vegaWalletPublicKeyShort,
'2.000000000000000000'
);
cy.vega_wallet_check_associated_value_is('2.000000000000000000');
cy.get(ethWalletAssociatedBalances, txTimeout)
.contains(vegaWalletPublicKeyShort)
.parent()
.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.staking_page_disassociate_tokens('1');
cy.ethereum_wallet_check_associated_vega_key_value_is(
vegaWalletPublicKeyShort,
'1.000000000000000000'
);
cy.ethereum_wallet_check_associated_value_is('1.0');
cy.vega_wallet_check_associated_value_is('1.000000000000000000');
cy.get(ethWalletAssociatedBalances, txTimeout)
.contains(vegaWalletPublicKeyShort)
.parent()
.should('contain', 1.0, txTimeout);
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 () {
cy.staking_page_associate_tokens('1001', true);
cy.ethereum_wallet_check_associated_vega_key_value_is(
vegaWalletPublicKeyShort,
'1,001.000000000000000000'
cy.get(ethWalletAssociatedBalances, txTimeout)
.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 () {
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.staking_page_disassociate_tokens('1');
cy.ethereum_wallet_check_associated_vega_key_value_is(
vegaWalletPublicKeyShort,
'1.000000000000000000'
cy.get(vegaWalletAssociatedBalance, txTimeout).should(
'contain',
2.0,
txTimeout
);
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 () {
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.staking_page_disassociate_all_tokens();
cy.ethereum_wallet_check_associated_vega_key_is_no_longer_showing(
vegaWalletPublicKeyShort
cy.get(vegaWalletAssociatedBalance, txTimeout).should(
'contain',
2.0,
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"]',
withdraw: '[href="/withdraw"]',
governance: '[href="/governance"]',
pageSpinner: 'splash-loader',
};
Cypress.Commands.add('navigate_to', (page) => {
@ -31,3 +32,7 @@ Cypress.Commands.add('verify_tab_highlighted', (page) => {
Cypress.Commands.add('verify_page_header', (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"]';
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(
'not.exist'
);
@ -26,13 +25,9 @@ Cypress.Commands.add('staking_validator_page_add_stake', (stake) => {
.and('contain', `Add ${stake} $VEGA tokens`)
.and('be.visible')
.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.get(removeStakeRadioButton).click({ force: true });
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('be.visible')
.click();
cy.contains(`${stake} $VEGA has been removed from validator`).should(
'be.visible'
);
});
Cypress.Commands.add(

View File

@ -16,42 +16,3 @@ Cypress.Commands.add('ethereum_wallet_connect', () => {
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';
import { ethers, Wallet } from 'ethers';
const vegaWalletAssociatedBalance = '[data-testid="currency-value"]';
const vegaWalletMnemonic = Cypress.env('vegaWalletMnemonic');
const vegaWalletPubKey = Cypress.env('vegaWalletPublicKey');
const vegaTokenContractAddress = Cypress.env('vegaTokenContractAddress');
@ -41,7 +42,12 @@ before('Vega wallet teardown prep', function () {
Cypress.Commands.add('vega_wallet_teardown', function () {
cy.vega_wallet_teardown_staking(this.stakingBridgeContract);
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(

View File

@ -33,24 +33,3 @@ Cypress.Commands.add('vega_wallet_connect', () => {
});
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]) => {
return (
<WalletCardRow
key={key}
label={removeLeadingAddressSymbol(key)}
value={amount}
dark={true}
/>
<div data-testid="eth-wallet-associated-balances">
<WalletCardRow
key={key}
label={removeLeadingAddressSymbol(key)}
value={amount}
dark={true}
/>
</div>
);
})}
</div>

View File

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

View File

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

View File

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

View File

@ -32,11 +32,11 @@ describe('home', () => {
});
cy.visit('/');
cy.wait('@GQL');
cy.contains('Loading...').should('be.visible');
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
});

View File

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

View File

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

View File

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

View File

@ -1,5 +1,6 @@
import { aliasQuery } from '@vegaprotocol/cypress';
import { connectEthereumWallet } from '../support/ethereum-wallet';
import { generateNetworkParameters } from '../support/mocks/generate-network-parameters';
import { generateWithdrawals } from '../support/mocks/generate-withdrawals';
import { connectVegaWallet } from '../support/vega-wallet';
@ -8,6 +9,7 @@ describe('withdrawals', () => {
cy.mockWeb3Provider();
cy.mockGQL((req) => {
aliasQuery(req, 'Withdrawals', generateWithdrawals());
aliasQuery(req, 'NetworkParamsQuery', generateNetworkParameters());
});
cy.visit('/portfolio/withdrawals');
@ -16,8 +18,6 @@ describe('withdrawals', () => {
// It also requires connection Ethereum wallet
connectEthereumWallet();
cy.contains('Withdrawals');
});
it('renders history of withdrawals', () => {
@ -27,7 +27,6 @@ describe('withdrawals', () => {
const etherScanLink = `${Cypress.env(
'ETHERSCAN_URL'
)}/tx/0x5d7b1a35ba6bd23be17bb7a159c13cdbb3121fceb94e9c6c510f5503dce48d03`;
cy.contains('Withdrawals');
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}>
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
<a className="px-[26px]">
<Vega className="fill-black dark:fill-white" />
<Vega className="fill-white" />
</a>
</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',
{
'bg-vega-pink dark:bg-vega-yellow text-white dark:text-black': isActive,
'text-black dark:text-white': !isActive,
'text-white': !isActive,
}
);
return (

View File

@ -24,12 +24,14 @@ export const VegaWalletConnectButton = ({
return (
<span>
{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
data-testid={isConnected ? 'manage-vega-wallet' : 'connect-vega-wallet'}
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'}
</button>

View File

@ -28,9 +28,9 @@ function AppBody({ Component, pageProps }: AppProps) {
return (
<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>
<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 />
<div className="flex items-center gap-4 ml-auto mr-8">
<VegaWalletConnectButton

View File

@ -30,12 +30,12 @@ const TradingViews = {
Candles: CandlesChartContainer,
Depth: DepthChartContainer,
Ticket: DealTicketContainer,
Orderbook: OrderbookContainer,
Orders: OrderListContainer,
Positions: PositionsContainer,
Accounts: AccountsContainer,
Trades: TradesContainer,
Info: MarketInfoContainer,
Orderbook: OrderbookContainer,
Trades: TradesContainer,
Positions: PositionsContainer,
Orders: OrderListContainer,
Collateral: AccountsContainer,
};
type TradingView = keyof typeof TradingViews;
@ -55,7 +55,7 @@ export const TradeMarketHeader = ({
.filter((c): c is CandleClose => c !== null);
const headerItemClassName = 'whitespace-nowrap flex flex-col';
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 =
'capitalize font-sans tracking-tighter text-black dark:text-white text-ui';
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">
<button
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>
<ArrowDown color="yellow" borderX={8} borderTop={12} />
@ -76,7 +76,7 @@ export const TradeMarketHeader = ({
<div
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}>
<span className={itemClassName}>Change (24h)</span>
@ -119,8 +119,8 @@ interface TradeGridProps {
export const TradeGrid = ({ market }: TradeGridProps) => {
const wrapperClasses = classNames(
'h-full max-h-full',
'grid gap-4 grid-cols-[1fr_375px_460px] grid-rows-[min-content_1fr_300px]',
'bg-black-10 dark:bg-white-10',
'grid gap-x-8 gap-y-4 grid-cols-[1fr_325px_425px] grid-rows-[min-content_1fr_200px]',
'bg-black-10 dark:bg-black-70',
'text-ui'
);
@ -153,24 +153,24 @@ export const TradeGrid = ({ market }: TradeGridProps) => {
</TradeGridChild>
<TradeGridChild className="row-start-2 row-end-3 col-start-3 col-end-4">
<Tabs>
<Tab id="trades" name={t('Trades')}>
<TradingViews.Trades marketId={market.id} />
</Tab>
<Tab id="orderbook" name={t('Orderbook')}>
<TradingViews.Orderbook marketId={market.id} />
</Tab>
<Tab id="trades" name={t('Trades')}>
<TradingViews.Trades marketId={market.id} />
</Tab>
</Tabs>
</TradeGridChild>
<TradeGridChild className="col-span-3">
<Tabs>
<Tab id="orders" name={t('Orders')}>
<TradingViews.Orders />
</Tab>
<Tab id="positions" name={t('Positions')}>
<TradingViews.Positions />
</Tab>
<Tab id="accounts" name={t('Accounts')}>
<TradingViews.Accounts />
<Tab id="orders" name={t('Orders')}>
<TradingViews.Orders />
</Tab>
<Tab id="accounts" name={t('Collateral')}>
<TradingViews.Collateral />
</Tab>
</Tabs>
</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 { OrderListContainer } from '@vegaprotocol/orders';
import { AccountsContainer } from '@vegaprotocol/accounts';
import { AnchorButton, Tab, Tabs } from '@vegaprotocol/ui-toolkit';
import { WithdrawalsContainer } from './withdrawals/withdrawals-container';
import { Tab, Tabs } from '@vegaprotocol/ui-toolkit';
import { WithdrawalsContainer } from './withdrawals-container';
import { FillsContainer } from '@vegaprotocol/fills';
import classNames from 'classnames';
import type { ReactNode } from 'react';
import { VegaWalletContainer } from '../../components/vega-wallet-container';
import { DepositsContainer } from './deposits-container';
const Portfolio = () => {
const wrapperClasses = classNames(
@ -22,54 +24,58 @@ const Portfolio = () => {
<PortfolioGridChild>
<Tabs>
<Tab id="positions" name={t('Positions')}>
<div className={tabContentClassName}>
<h4 className="text-h4 text-black dark:text-white p-8">
{t('Positions')}
</h4>
<div>
<PositionsContainer />
<VegaWalletContainer>
<div className={tabContentClassName}>
<h4 className="text-h4 text-black dark:text-white p-8">
{t('Positions')}
</h4>
<div>
<PositionsContainer />
</div>
</div>
</div>
</VegaWalletContainer>
</Tab>
<Tab id="orders" name={t('Orders')}>
<div className={tabContentClassName}>
<h4 className="text-h4 text-black dark:text-white p-8">
{t('Orders')}
</h4>
<div>
<OrderListContainer />
<VegaWalletContainer>
<div className={tabContentClassName}>
<h4 className="text-h4 text-black dark:text-white p-8">
{t('Orders')}
</h4>
<div>
<OrderListContainer />
</div>
</div>
</div>
</VegaWalletContainer>
</Tab>
<Tab id="fills" name={t('Fills')}>
<div className={tabContentClassName}>
<h4 className="text-h4 text-black dark:text-white p-8">
{t('Fills')}
</h4>
<div>
<FillsContainer />
<VegaWalletContainer>
<div className={tabContentClassName}>
<h4 className="text-h4 text-black dark:text-white p-8">
{t('Fills')}
</h4>
<div>
<FillsContainer />
</div>
</div>
</div>
</VegaWalletContainer>
</Tab>
</Tabs>
</PortfolioGridChild>
<PortfolioGridChild>
<Tabs>
<Tab id="collateral" name={t('Collateral')}>
<AccountsContainer />
<VegaWalletContainer>
<AccountsContainer />
</VegaWalletContainer>
</Tab>
<Tab id="deposits" name={t('Deposits')}>
<div className={tabContentClassName}>
<div className="p-8">
<AnchorButton data-testid="deposit" href="/portfolio/deposit">
{t('Deposit')}
</AnchorButton>
</div>
</div>
<DepositsContainer />
</Tab>
<Tab id="withdrawals" name={t('Withdrawals')}>
<Web3Container>
<WithdrawalsContainer />
<VegaWalletContainer>
<WithdrawalsContainer />
</VegaWalletContainer>
</Web3Container>
</Tab>
</Tabs>

View File

@ -1,6 +1,7 @@
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 Link from 'next/link';
export const WithdrawalsContainer = () => {
const { data, loading, error } = useWithdrawals();
@ -16,7 +17,16 @@ export const WithdrawalsContainer = () => {
(w) => new Date(w.createdTimestamp).getTime(),
'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 { Web3Container } from '../../../components/web3-container';
import { WithdrawalsContainer } from './withdrawals-container';
import { WithdrawalsContainer } from '../withdrawals-container';
const Withdrawals = () => {
return (
<VegaWalletContainer>
<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 />
</div>
<WithdrawalsContainer />
</Web3Container>
</VegaWalletContainer>
);

View File

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

View File

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

View File

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

View File

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

View File

@ -8,12 +8,19 @@ interface DepositLimitsProps {
}
export const DepositLimits = ({ limits }: DepositLimitsProps) => {
const maxLimit = limits.max.isEqualTo(Infinity)
? t('No limit')
: limits.max.toString();
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('Temporary deposit limits')}</p>
<p className="text-ui font-bold">{t('Deposit limits')}</p>
<table className="w-full text-ui">
<tbody>
<tr>

View File

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

View File

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

View File

@ -66,7 +66,7 @@ export const OrderbookRow = React.memo(
relativeAsk={cumulativeRelativeAsk}
relativeBid={cumulativeRelativeBid}
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;
return (
<div
className={`h-full overflow-auto relative ${styles['scroll']}`}
className={`h-full overflow-auto relative ${styles['scroll']} pl-4 pt-4`}
onScroll={onScroll}
ref={scrollElement}
data-testid="scroll"
@ -354,7 +354,7 @@ export const Orderbook = ({
<select
onChange={(e) => onResolutionChange(Number(e.currentTarget.value))}
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"
>
{new Array(3)

View File

@ -67,6 +67,7 @@ export const SelectMarketList = ({
onKeyPress={(event) => handleKeyPress(event, id)}
onClick={() => onSelect(id)}
data-testid={`market-link-${id}`}
className={`focus:decoration-vega-yellow`}
>
{marketName}
</a>
@ -106,7 +107,10 @@ export const SelectMarketList = ({
</tbody>
</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')}
</a>
</div>

View File

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

View File

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

View File

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

View File

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

View File

@ -36,7 +36,7 @@ export const Accordion = ({ panels }: AccordionProps) => {
className={triggerClassNames}
>
<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"
>
{title}

View File

@ -4,22 +4,22 @@ export const ChevronDownIcon = ({ active }: ChevronDownIconProps) => {
: 'transform duration-300 ease';
return (
<svg
width="20"
height="20"
width="14"
height="8"
aria-label="chevron icon"
data-testid="accordion-chevron-icon"
viewBox="0 0 20 20"
viewBox="0 0 14 8"
fill="fillCurrent"
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="15" y="10" width="2" height="2" />
<rect x="13" y="12" width="2" height="2" />
<rect x="11" y="14" width="2" height="2" />
<rect x="9" y="12" width="2" height="2" />
<rect x="7" y="10" width="2" height="2" />
<rect x="5" y="8" width="2" height="2" />
<rect x="12" y="0" width="2" height="2" />
<rect x="10" y="2" width="2" height="2" />
<rect x="8" y="4" width="2" height="2" />
<rect x="6" y="6" width="2" height="2" />
<rect x="4" y="4" width="2" height="2" />
<rect x="2" y="2" width="2" height="2" />
<rect x="0" y="0" width="2" height="2" />
</svg>
);
};

View File

@ -42,7 +42,7 @@ export function Dialog({
/>
<DialogPrimitives.Content className={contentClasses}>
<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"
>
<Icon

View File

@ -44,7 +44,7 @@ export const DropdownMenuTrigger = forwardRef<
<DropdownMenuPrimitive.Trigger
asChild={true}
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
variant="secondary"

View File

@ -33,14 +33,14 @@ export const FormGroup = ({
{
<div
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,
'text-right': labelAlign === 'right',
}
)}
>
<div className="font-bold mb-2">{label}</div>
<div className="font-medium mb-2">{label}</div>
{labelDescription && (
<div className={classNames({ 'text-danger': hasError })}>
{labelDescription}

View File

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

View File

@ -18,36 +18,40 @@ export const Tabs = ({ children }: TabsProps) => {
className="h-full grid grid-rows-[min-content_1fr]"
onValueChange={(value) => setActiveTab(value)}
>
<div className="bg-black-10 dark:bg-white-10">
<div className="bg-black-10 dark:bg-black-70">
<TabsPrimitive.List
className="flex flex-nowrap gap-4 overflow-x-auto"
className="flex flex-nowrap overflow-x-auto"
role="tablist"
>
{Children.map(children, (child) => {
if (!isValidElement(child)) return null;
const isActive = child.props.id === activeTab;
const triggerClass = classNames(
'py-4 px-20',
'capitalize',
'focus-visible:outline-none focus-visible:shadow-inset-vega-pink dark:focus-visible:shadow-inset-vega-yellow',
{
'font-semibold text-vega-pink dark:text-vega-yellow': isActive,
'bg-white dark:bg-black': isActive,
'text-black dark:text-white': !isActive,
'bg-white-90 dark:bg-black-70 hover:bg-white-95 dark:hover:bg-black-80':
!isActive,
}
);
return (
<TabsPrimitive.Trigger
data-testid={child.props.name}
value={child.props.id}
className={triggerClass}
>
{child.props.name}
</TabsPrimitive.Trigger>
);
})}
<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) => {
if (!isValidElement(child)) return null;
const isActive = child.props.id === activeTab;
const triggerClass = classNames(
'py-4 px-20',
'capitalize',
'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',
{
'text-vega-pink dark:text-vega-yellow font-bold': isActive,
'bg-white dark:bg-black': isActive,
'text-black dark:text-white': !isActive,
'bg-white-90 dark:bg-black-70 hover:bg-white-95 dark:hover:bg-black-80':
!isActive,
}
);
return (
<TabsPrimitive.Trigger
data-testid={child.props.name}
value={child.props.id}
className={triggerClass}
>
{child.props.name}
</TabsPrimitive.Trigger>
);
})}
</div>
</TabsPrimitive.List>
</div>
<div className="h-full overflow-auto">

View File

@ -11,7 +11,12 @@ export interface TextAreaProps
export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
({ 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} />;
}
);

View File

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

View File

@ -6,7 +6,6 @@ export const defaultFormElement = (hasError?: boolean) =>
'box-border',
'border rounded-none',
'bg-clip-padding',
'shadow-input dark:shadow-input-dark',
'bg-white dark:bg-white-25',
'text-black placeholder:text-black-60 dark:text-white dark:placeholder:text-white-60',
'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(() => {
if (data?.erc20WithdrawalApproval) {
if (
data?.erc20WithdrawalApproval &&
data.erc20WithdrawalApproval.signatures.length > 2
) {
stopPolling();
setApproval(data.erc20WithdrawalApproval);
}

View File

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

View File

@ -18,6 +18,7 @@ import type { ButtonHTMLAttributes, ReactNode } from 'react';
import { useForm, Controller } from 'react-hook-form';
import type { WithdrawalFields } from './use-withdraw';
import type { Asset } from './types';
import { WithdrawLimits } from './withdraw-limits';
interface FormFields {
asset: string;
@ -31,6 +32,9 @@ export interface WithdrawFormProps {
min: BigNumber;
selectedAsset?: Asset;
ethereumAccount?: string;
limits: {
max: BigNumber;
} | null;
onSelectAsset: (assetId: string) => void;
submitWithdraw: (withdrawal: WithdrawalFields) => void;
}
@ -41,6 +45,7 @@ export const WithdrawForm = ({
min,
selectedAsset,
ethereumAccount,
limits,
onSelectAsset,
submitWithdraw,
}: WithdrawFormProps) => {
@ -134,7 +139,11 @@ export const WithdrawForm = ({
</UseButton>
)}
</FormGroup>
{selectedAsset && limits && (
<div className="mb-20">
<WithdrawLimits limits={limits} />
</div>
)}
<FormGroup label={t('Amount')} labelFor="amount" className="relative">
<Input
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,
initialState as ethTxInitialState,
} from '@vegaprotocol/web3';
import BigNumber from 'bignumber.js';
const ethereumAddress = '0x72c22822A19D20DE7e426fB84aa047399Ddd8853';
@ -16,6 +17,12 @@ jest.mock('@web3-react/core', () => ({
useWeb3React: () => ({ account: ethereumAddress }),
}));
jest.mock('./use-get-withdraw-limits', () => ({
useGetWithdrawLimits: () => {
return { max: new BigNumber(1000000) };
},
}));
let props: WithdrawManagerProps;
let useWithdrawValue: ReturnType<typeof withdrawHook.useWithdraw>;
let useWithdraw: jest.SpyInstance;

View File

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