diff --git a/apps/governance-e2e/src/integration/flow/proposal-details.cy.ts b/apps/governance-e2e/src/integration/flow/proposal-details.cy.ts index e0223ab64..5e9de85ec 100644 --- a/apps/governance-e2e/src/integration/flow/proposal-details.cy.ts +++ b/apps/governance-e2e/src/integration/flow/proposal-details.cy.ts @@ -44,7 +44,8 @@ describe( function () { before('connect wallets and set approval limit', function () { cy.visit('/'); - vegaWalletSetSpecifiedApprovalAmount('1000'); + ethereumWalletConnect(); + cy.associateTokensToVegaWallet('1'); }); beforeEach('visit proposals tab', function () { @@ -213,6 +214,7 @@ describe( // 3001-VOTE-042, 3001-VOTE-057, 3001-VOTE-058, 3001-VOTE-059, 3001-VOTE-060 it('Newly created proposal details - ability to increase associated tokens - by voting again after association', function () { + vegaWalletSetSpecifiedApprovalAmount('1000'); createRawProposal(); cy.get('@rawProposal').then((rawProposal) => { getSubmittedProposalFromProposalList(rawProposal.rationale.title) diff --git a/apps/governance-e2e/src/integration/flow/proposal-enacted.cy.ts b/apps/governance-e2e/src/integration/flow/proposal-enacted.cy.ts index ee0f5863b..5f1fa01d9 100644 --- a/apps/governance-e2e/src/integration/flow/proposal-enacted.cy.ts +++ b/apps/governance-e2e/src/integration/flow/proposal-enacted.cy.ts @@ -13,7 +13,6 @@ import { createUpdateNetworkProposalTxBody, createFreeFormProposalTxBody, } from '../../support/proposal.functions'; -import { ensureSpecifiedUnstakedTokensAreAssociated } from '../../support/staking.functions'; import { ethereumWalletConnect } from '../../support/wallet-eth.functions'; import { vegaWalletSetSpecifiedApprovalAmount } from '../../support/wallet-teardown.functions'; @@ -33,10 +32,6 @@ context( before('Connect wallets and set approval', function () { cy.visit('/'); vegaWalletSetSpecifiedApprovalAmount('1000'); - cy.connectVegaWallet(); - ethereumWalletConnect(); - ensureSpecifiedUnstakedTokensAreAssociated('1'); - cy.clearLocalStorage(); }); beforeEach('visit proposals', function () { @@ -114,7 +109,7 @@ context( navigateTo(navigation.proposals); cy.reload(); waitForSpinner(); - cy.get(openProposals).within(() => { + cy.get(openProposals, { timeout: 6000 }).within(() => { cy.contains(proposalTitle) .parentsUntil('[data-testid="proposals-list-item"]') .within(() => cy.get(viewProposalButton).click()); diff --git a/apps/governance-e2e/src/integration/flow/proposal-flow.cy.ts b/apps/governance-e2e/src/integration/flow/proposal-flow.cy.ts index 0785b8249..da5278d03 100644 --- a/apps/governance-e2e/src/integration/flow/proposal-flow.cy.ts +++ b/apps/governance-e2e/src/integration/flow/proposal-flow.cy.ts @@ -232,7 +232,7 @@ context( it('Unable to create a freeform proposal - when json parent section contains unexpected field', function () { const errorMsg = - 'Invalid params: the transaction does not use a valid Vega command: unknown field unexpected" in vega.commands.v1.ProposalSubmission'; + 'Invalid params: the transaction does not use a valid Vega command: unknown field "unexpected" in vega.commands.v1.ProposalSubmission'; // 3001-VOTE-038 3002-PROP-013 3002-PROP-014 goToMakeNewProposal(governanceProposalType.RAW); @@ -313,7 +313,7 @@ context( it('Unable to vote on a proposal - when vega wallet disconnected - option to connect from within', function () { createRawProposal(); - cy.get('[data-testid="manage-vega-wallet"]').click(); + cy.get('[data-testid="manage-vega-wallet"]:visible').click(); cy.get('[data-testid="disconnect"]').click(); cy.get('@rawProposal').then((rawProposal) => { getSubmittedProposalFromProposalList( diff --git a/apps/governance-e2e/src/integration/flow/proposal-forms.cy.ts b/apps/governance-e2e/src/integration/flow/proposal-forms.cy.ts index dd7209a56..8edb77c66 100644 --- a/apps/governance-e2e/src/integration/flow/proposal-forms.cy.ts +++ b/apps/governance-e2e/src/integration/flow/proposal-forms.cy.ts @@ -218,7 +218,7 @@ context( it('Unable to submit new market proposal with missing/invalid fields', function () { const errorMsg = - 'Invalid params: the transaction is not a valid Vega command: unknown field "filters" in vega.DataSourceDefinition'; + 'Invalid params: the transaction does not use a valid Vega command: unknown field "invalid" in vega.NewMarket'; goToMakeNewProposal(governanceProposalType.NEW_MARKET); cy.get(newProposalSubmitButton).should('be.visible').click(); @@ -436,7 +436,7 @@ context( }); }); - it.only('Able to submit update asset proposal using max deadline', function () { + it('Able to submit update asset proposal using max deadline', function () { goToMakeNewProposal(governanceProposalType.UPDATE_ASSET); enterUpdateAssetProposalDetails(); cy.get(maxVoteDeadline).click(); diff --git a/apps/governance-e2e/src/integration/flow/token-association-flow.cy.ts b/apps/governance-e2e/src/integration/flow/token-association-flow.cy.ts index 330e9a4d3..9bb79171a 100644 --- a/apps/governance-e2e/src/integration/flow/token-association-flow.cy.ts +++ b/apps/governance-e2e/src/integration/flow/token-association-flow.cy.ts @@ -25,11 +25,11 @@ const vegaWalletUnstakedBalance = '[data-testid="vega-wallet-balance-unstaked"]'; const txTimeout = Cypress.env('txTimeout'); const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort'); -const ethWalletAssociateButton = '[data-testid="associate-btn"]'; +const ethWalletAssociateButton = '[data-testid="associate-btn"]:visible'; const associateWalletRadioButton = '[data-testid="associate-radio-wallet"]'; const tokenAmountInputBox = '[data-testid="token-amount-input"]'; const tokenSubmitButton = '[data-testid="token-input-submit-button"]'; -const ethWalletDissociateButton = '[href="/token/disassociate"]'; +const ethWalletDissociateButton = '[href="/token/disassociate"]:visible'; const vestingContractSection = '[data-testid="vega-in-vesting-contract"]'; const vegaInWalletSection = '[data-testid="vega-in-wallet"]'; const connectedVegaKey = '[data-testid="connected-vega-key"]'; @@ -78,12 +78,12 @@ context( cy.getByTestId('currency-title', txTimeout).should( 'have.length.above', - 3 + 6 ); validateWalletCurrency('Associated', '0.00'); validateWalletCurrency('Pending association', '2.00'); validateWalletCurrency('Total associated after pending', '2.00'); - cy.getByTestId('currency-title', txTimeout).should('have.length', 3); + cy.getByTestId('currency-title', txTimeout).should('have.length', 6); // 0005-ETXN-002 verifyEthWalletAssociatedBalance('2.0'); @@ -111,12 +111,12 @@ context( stakingPageDisassociateTokens('2'); cy.getByTestId('currency-title', txTimeout).should( 'have.length.above', - 3 + 6 ); validateWalletCurrency('Associated', '2.00'); validateWalletCurrency('Pending association', '2.00'); validateWalletCurrency('Total associated after pending', '0.00'); - cy.getByTestId('currency-title', txTimeout).should('have.length', 3); + cy.getByTestId('currency-title', txTimeout).should('have.length', 6); cy.getByTestId('eth-wallet-associated-balances', txTimeout).should( 'not.exist' ); @@ -192,12 +192,12 @@ context( cy.getByTestId('currency-title', txTimeout).should( 'have.length.above', - 3 + 6 ); validateWalletCurrency('Associated', '0.00'); validateWalletCurrency('Pending association', '2.00'); validateWalletCurrency('Total associated after pending', '2.00'); - cy.getByTestId('currency-title', txTimeout).should('have.length', 3); + cy.getByTestId('currency-title', txTimeout).should('have.length', 6); verifyEthWalletAssociatedBalance('2.0'); verifyEthWalletTotalAssociatedBalance('2.0'); cy.get(vegaWallet).within(() => { @@ -210,12 +210,12 @@ context( }); cy.getByTestId('currency-title', txTimeout).should( 'have.length.above', - 3 + 6 ); validateWalletCurrency('Associated', '2.00'); validateWalletCurrency('Pending association', '1.00'); validateWalletCurrency('Total associated after pending', '1.00'); - cy.getByTestId('currency-title', txTimeout).should('have.length', 3); + cy.getByTestId('currency-title', txTimeout).should('have.length', 6); verifyEthWalletAssociatedBalance('1.0'); verifyEthWalletTotalAssociatedBalance('1.0'); }); @@ -266,7 +266,7 @@ context( // 1004-ASSO-008 // 1004-ASSO-010 // No warning visible as described in AC, but the button is disabled - cy.get(ethWalletAssociateButton).first().click(); + cy.get(ethWalletAssociateButton).click(); cy.get(associateWalletRadioButton, { timeout: 30000 }).click(); cy.get(tokenSubmitButton, txTimeout).should('be.disabled'); // button disabled with no input cy.get(tokenAmountInputBox, { timeout: 10000 }).type('6500000'); @@ -278,12 +278,12 @@ context( vegaWalletAssociate('2'); cy.getByTestId('currency-title', txTimeout).should( 'have.length.above', - 3 + 6 ); validateWalletCurrency('Associated', '0.00'); validateWalletCurrency('Pending association', '2.00'); validateWalletCurrency('Total associated after pending', '2.00'); - cy.getByTestId('currency-title', txTimeout).should('have.length', 3); + cy.getByTestId('currency-title', txTimeout).should('have.length', 6); validateWalletCurrency('Associated', '2.00'); }); @@ -294,24 +294,24 @@ context( }); cy.getByTestId('currency-title', txTimeout).should( 'have.length.above', - 3 + 6 ); validateWalletCurrency('Associated', '2.00'); validateWalletCurrency('Pending association', '2.00'); validateWalletCurrency('Total associated after pending', '0.00'); - cy.getByTestId('currency-title', txTimeout).should('have.length', 3); + cy.getByTestId('currency-title', txTimeout).should('have.length', 6); validateWalletCurrency('Associated', '0.00'); }); it('Able to associate tokens to different public key of connected vega wallet', function () { - cy.get(ethWalletAssociateButton).first().click(); + cy.get(ethWalletAssociateButton).click(); cy.get(associateWalletRadioButton).click(); cy.get(connectedVegaKey).should( 'have.text', Cypress.env('vegaWalletPublicKey') ); - cy.get('[data-testid="manage-vega-wallet"]').click(); + cy.get('[data-testid="manage-vega-wallet"]:visible').click(); cy.get('[data-testid="select-keypair-button"]').eq(0).click(); cy.get(connectedVegaKey).should( 'have.text', diff --git a/apps/governance-e2e/src/support/governance.functions.ts b/apps/governance-e2e/src/support/governance.functions.ts index c77e394ff..066ab1847 100644 --- a/apps/governance-e2e/src/support/governance.functions.ts +++ b/apps/governance-e2e/src/support/governance.functions.ts @@ -166,6 +166,7 @@ export function goToMakeNewProposal(proposalType: string) { navigateTo(navigation.proposals); cy.get(newProposalButton).should('be.visible').click(); cy.url().should('include', '/proposals/propose'); + cy.get(navigation.pageSpinner, { timeout: 20000 }).should('not.exist'); cy.get('li').should('contain.text', proposalType).and('be.visible'); cy.get('li').contains(proposalType).click(); } diff --git a/apps/governance-e2e/src/support/wallet-teardown.functions.ts b/apps/governance-e2e/src/support/wallet-teardown.functions.ts index 4d81c43ea..ba7baa60f 100644 --- a/apps/governance-e2e/src/support/wallet-teardown.functions.ts +++ b/apps/governance-e2e/src/support/wallet-teardown.functions.ts @@ -8,6 +8,7 @@ import { } from '@vegaprotocol/smart-contracts'; import { ethers, Wallet } from 'ethers'; +const associatedAmountInWallet = '[data-testid="associated-amount"]:visible'; const vegaWalletContainer = 'aside [data-testid="vega-wallet"]'; const vegaWalletMnemonic = Cypress.env('vegaWalletMnemonic'); const vegaWalletPubKey = Cypress.env('vegaWalletPublicKey'); @@ -59,7 +60,7 @@ export async function faucetAsset(assetEthAddress: string) { } export async function vegaWalletTeardown() { - cy.get('[data-testid="associated-amount"]') + cy.get(associatedAmountInWallet) .should('be.visible') .invoke('text') .then((associatedAmount) => { @@ -68,12 +69,12 @@ export async function vegaWalletTeardown() { $body.find('[data-testid="eth-wallet-associated-balances"]').length || associatedAmount != '0.00' ) { - vegaWalletTeardownVesting(vestingContract); vegaWalletTeardownStaking(stakingBridgeContract); + vegaWalletTeardownVesting(vestingContract); } }); cy.get(vegaWalletContainer).within(() => { - cy.getByTestId('associated-amount', { + cy.get(associatedAmountInWallet, { timeout: transactionTimeout, }).contains('0.00', { timeout: transactionTimeout, @@ -90,7 +91,7 @@ export async function vegaWalletSetSpecifiedApprovalAmount( await promiseWithTimeout( token.approve( ethStakingBridgeContractAddress, - resetAmount.concat('000000000000000000') + resetAmount + '0'.repeat(18) ), 10 * 60 * 1000, 'set approval amount' @@ -104,12 +105,23 @@ async function vegaWalletTeardownStaking(stakingBridgeContract: StakingBridge) { { timeout: transactionTimeout, log: false } ).then((stakeBalance) => { if (Number(stakeBalance) != 0) { - cy.wrap( - stakingBridgeContract.remove_stake( - String(stakeBalance), - vegaWalletPubKey - ), - { timeout: transactionTimeout, log: false } + cy.get('[data-testid="vega-wallet-balance-unstaked"]:visible').within( + () => { + cy.get(associatedAmountInWallet) + .invoke('text') + .then(($walletAmount) => { + cy.wrap( + stakingBridgeContract.remove_stake( + String(stakeBalance), + vegaWalletPubKey + ), + { timeout: transactionTimeout, log: false } + ); + cy.get(associatedAmountInWallet, { + timeout: transactionTimeout, + }).should('not.have.text', $walletAmount); + }); + } ); } }); @@ -124,7 +136,6 @@ async function vegaWalletTeardownVesting(vestingContract: TokenVesting) { if (Number(vestingAmount) != 0) { // Wait needed to allow time for ganache to process tx for stakingBridgeContract.remove_stake // eslint-disable-next-line cypress/no-unnecessary-waiting - cy.wait(1000); cy.wrap( vestingContract.remove_stake(String(vestingAmount), vegaWalletPubKey), { timeout: transactionTimeout, log: false } diff --git a/apps/static/src/assets/mainnet-tranches.json b/apps/static/src/assets/mainnet-tranches.json index 82667e100..3d31fde74 100644 --- a/apps/static/src/assets/mainnet-tranches.json +++ b/apps/static/src/assets/mainnet-tranches.json @@ -3,9 +3,9 @@ "tranche_id": 56, "tranche_start": "2023-04-20T00:00:00.000Z", "tranche_end": "2023-05-20T00:00:00.000Z", - "total_added": "15607.625", + "total_added": "15711.125", "total_removed": "0", - "locked_amount": "15607.625", + "locked_amount": "15711.125", "deposits": [ { "amount": "241.5", @@ -82,6 +82,11 @@ "user": "0x268070d5EEd5b24E34a5F4C17B5482178b18089D", "tx": "0x7543f201673298844d68e4dd15222ab85bdd2796b5b95c739d1a1d5c198806e8" }, + { + "amount": "103.5", + "user": "0x697cEF6741F519621fE14c72041e4B8B1f7e2c8A", + "tx": "0xc7483de16af39896b3ae052dd8a6e01fb3dc3794ceb9d2a76d81436992af320e" + }, { "amount": "50", "user": "0x15024E62134A8BFFCce11f5ce58CeCDe853038D7", @@ -356,6 +361,21 @@ "withdrawn_tokens": "0", "remaining_tokens": "138" }, + { + "address": "0x697cEF6741F519621fE14c72041e4B8B1f7e2c8A", + "deposits": [ + { + "amount": "103.5", + "user": "0x697cEF6741F519621fE14c72041e4B8B1f7e2c8A", + "tranche_id": 56, + "tx": "0xc7483de16af39896b3ae052dd8a6e01fb3dc3794ceb9d2a76d81436992af320e" + } + ], + "withdrawals": [], + "total_tokens": "103.5", + "withdrawn_tokens": "0", + "remaining_tokens": "103.5" + }, { "address": "0x15024E62134A8BFFCce11f5ce58CeCDe853038D7", "deposits": [ @@ -581,8 +601,8 @@ "tranche_start": "2023-04-06T00:00:00.000Z", "tranche_end": "2023-05-06T00:00:00.000Z", "total_added": "8865", - "total_removed": "57.68717013147", - "locked_amount": "6942.2971006944436455", + "total_removed": "212.71903124703", + "locked_amount": "6720.641319444444729", "deposits": [ { "amount": "33", @@ -726,6 +746,11 @@ "user": "0x92A1e98C6f09970e45645Cbe57c6DcaF4547c8FE", "tx": "0xb9b9b6b0882ad6e197e540e034c39e785f8b77372ac03f93d2f8960e8cde658b" }, + { + "amount": "155.03186111556", + "user": "0x6F32AA5A6198329c16e438512F992a0548C856f9", + "tx": "0x7da34162df1b167ed5a3de6d98759af7100bcd51ec4e4c55abce2d145c98ba15" + }, { "amount": "52.2185023074", "user": "0x6F32AA5A6198329c16e438512F992a0548C856f9", @@ -939,6 +964,12 @@ } ], "withdrawals": [ + { + "amount": "155.03186111556", + "user": "0x6F32AA5A6198329c16e438512F992a0548C856f9", + "tranche_id": 54, + "tx": "0x7da34162df1b167ed5a3de6d98759af7100bcd51ec4e4c55abce2d145c98ba15" + }, { "amount": "52.2185023074", "user": "0x6F32AA5A6198329c16e438512F992a0548C856f9", @@ -947,8 +978,8 @@ } ], "total_tokens": "858", - "withdrawn_tokens": "52.2185023074", - "remaining_tokens": "805.7814976926" + "withdrawn_tokens": "207.25036342296", + "remaining_tokens": "650.74963657704" }, { "address": "0x0bBf7580e036eA5D69ABe679CC90117EeC2e3dc1", @@ -4245,7 +4276,7 @@ "tranche_end": "2023-12-05T00:00:00.000Z", "total_added": "86666.297", "total_removed": "0", - "locked_amount": "56153.4424125955394179021", + "locked_amount": "55975.3362468715096583895", "deposits": [ { "amount": "86666.297", @@ -4311,7 +4342,7 @@ "tranche_end": "2023-06-01T00:00:00.000Z", "total_added": "2500", "total_removed": "0", - "locked_amount": "679.8542747761499", + "locked_amount": "669.55064611314625", "deposits": [ { "amount": "2500", @@ -4432,7 +4463,7 @@ "tranche_end": "2023-09-01T00:00:00.000Z", "total_added": "17500", "total_removed": "0", - "locked_amount": "13457.251880787036", + "locked_amount": "13385.91045189210925", "deposits": [ { "amount": "12500", @@ -4699,7 +4730,7 @@ "tranche_end": "2023-08-01T00:00:00.000Z", "total_added": "37500", "total_removed": "12151.298246325", - "locked_amount": "22892.27718308778", + "locked_amount": "22736.8688612645775", "deposits": [ { "amount": "7500", @@ -5052,7 +5083,7 @@ "tranche_end": "2023-12-05T00:00:00.000Z", "total_added": "129999.45", "total_removed": "0", - "locked_amount": "56102.2094618910983594025", + "locked_amount": "55924.265795633105973795", "deposits": [ { "amount": "129999.45", @@ -5085,7 +5116,7 @@ "tranche_end": "2024-04-01T00:00:00.000Z", "total_added": "54144.7663", "total_removed": "0", - "locked_amount": "52442.51863830331283731817", + "locked_amount": "52331.55083829013672190566", "deposits": [ { "amount": "54144.7663", @@ -5118,7 +5149,7 @@ "tranche_end": "2023-09-03T00:00:00.000Z", "total_added": "62600", "total_removed": "0", - "locked_amount": "24610.099422881789042", + "locked_amount": "24481.45142059868271", "deposits": [ { "amount": "10000", @@ -5311,7 +5342,7 @@ "tranche_end": "2023-09-17T00:00:00.000Z", "total_added": "5000", "total_removed": "0", - "locked_amount": "2157.44371511922885", + "locked_amount": "2147.16831557584975", "deposits": [ { "amount": "5000", @@ -5852,7 +5883,7 @@ "tranche_end": "2023-05-01T00:00:00.000Z", "total_added": "22500", "total_removed": "6727.9921539", - "locked_amount": "2298.90222145488015", + "locked_amount": "2205.657228360958425", "deposits": [ { "amount": "7500", @@ -6325,7 +6356,7 @@ "tranche_end": "2023-06-02T00:00:00.000Z", "total_added": "1939928.38", "total_removed": "928642.9598472029154", - "locked_amount": "268365.924927416892687982", + "locked_amount": "264379.2170894088612502104", "deposits": [ { "amount": "1852091.69", @@ -40141,7 +40172,7 @@ "tranche_end": "2023-06-05T00:00:00.000Z", "total_added": "3732368.4671", "total_removed": "715655.108029600523393", - "locked_amount": "436886.316251527897819535653", + "locked_amount": "430760.134328755393533225946", "deposits": [ { "amount": "1998.95815", @@ -41534,7 +41565,7 @@ "tranche_end": "2023-12-05T00:00:00.000Z", "total_added": "15870102.715470999700000001", "total_removed": "832085.86755480045340352", - "locked_amount": "6848858.41228621146423137625497604821843745", + "locked_amount": "6827135.3645265337866511762819105499945931", "deposits": [ { "amount": "16249.93", @@ -47914,7 +47945,7 @@ "tranche_end": "2023-05-05T00:00:00.000Z", "total_added": "14597706.0446472999", "total_removed": "5825428.980241267385732886", - "locked_amount": "601377.1295584657774180930334501436", + "locked_amount": "581322.550569700658722837432388667", "deposits": [ { "amount": "129284.449", @@ -57737,8 +57768,8 @@ "tranche_start": "2022-06-05T00:00:00.000Z", "tranche_end": "2023-06-05T00:00:00.000Z", "total_added": "472355.6199999996", - "total_removed": "42362.8219648421949", - "locked_amount": "69227.13415870679476685853018774", + "total_removed": "42408.3252372941949", + "locked_amount": "68256.405614294737212900293658024", "deposits": [ { "amount": "3000", @@ -64367,6 +64398,11 @@ "user": "0xa9a677b0a3Be231C0654CabB0Eaa0A72E91B3E8d", "tx": "0xc0db5f216679203b937bf90415f24231997ea35bc1d418af30913aa313be498d" }, + { + "amount": "45.503272452", + "user": "0x9347177014d3fEA775b5B29fFC96bF6B911686F9", + "tx": "0xd1d4724eae5566e3162c1b210a19d73f5a2e4b9b3d52d9d1e77c4b9cb9bdc2e1" + }, { "amount": "19.918569252", "user": "0xcB555C5602cC0b2434A27d277e14Cb5C7bF4Ead1", @@ -81483,6 +81519,12 @@ } ], "withdrawals": [ + { + "amount": "45.503272452", + "user": "0x9347177014d3fEA775b5B29fFC96bF6B911686F9", + "tranche_id": 5, + "tx": "0xd1d4724eae5566e3162c1b210a19d73f5a2e4b9b3d52d9d1e77c4b9cb9bdc2e1" + }, { "amount": "47.970776254", "user": "0x9347177014d3fEA775b5B29fFC96bF6B911686F9", @@ -81497,8 +81539,8 @@ } ], "total_tokens": "200", - "withdrawn_tokens": "125.533250886", - "remaining_tokens": "74.466749114" + "withdrawn_tokens": "171.036523338", + "remaining_tokens": "28.963476662" }, { "address": "0x1a268a88b586B475FF4bD86882bF2f9D79875964", @@ -87367,7 +87409,7 @@ "tranche_start": "2021-12-05T00:00:00.000Z", "tranche_end": "2022-06-05T00:00:00.000Z", "total_added": "171288.42", - "total_removed": "69140.5995794947989", + "total_removed": "69390.5995794947989", "locked_amount": "0", "deposits": [ { @@ -91602,6 +91644,11 @@ "user": "0xC1991C8BDA29507991EEB230FF2063C2eA74a34C", "tx": "0x71a163020ce928ca230a50c099b8baaf60af6191d6cbc46edc004239d3ff9901" }, + { + "amount": "250", + "user": "0x0715B8bA27dB75F7601A9D8E22c15dcA1487FB70", + "tx": "0x11c685c41ff0c2d5f1d7fe3b08dc84a7ddb9160764a45bc61b8f39df94729634" + }, { "amount": "1250", "user": "0x9405F540EcC1204801De5C4444D06386BD6693F0", @@ -100423,10 +100470,17 @@ "tx": "0x057f65938b1360b6d2c4ebf5e789c67897cf60cb6a13f947004def03891afbd8" } ], - "withdrawals": [], + "withdrawals": [ + { + "amount": "250", + "user": "0x0715B8bA27dB75F7601A9D8E22c15dcA1487FB70", + "tranche_id": 6, + "tx": "0x11c685c41ff0c2d5f1d7fe3b08dc84a7ddb9160764a45bc61b8f39df94729634" + } + ], "total_tokens": "250", - "withdrawn_tokens": "0", - "remaining_tokens": "250" + "withdrawn_tokens": "250", + "remaining_tokens": "0" }, { "address": "0x027306C886Da27fa29Ce9B4DB489C6E44d2ECc55", diff --git a/apps/trading/lib/hooks/use-vega-transaction-toasts.spec.tsx b/apps/trading/lib/hooks/use-vega-transaction-toasts.spec.tsx index 3fb7d229f..10cd72f40 100644 --- a/apps/trading/lib/hooks/use-vega-transaction-toasts.spec.tsx +++ b/apps/trading/lib/hooks/use-vega-transaction-toasts.spec.tsx @@ -7,7 +7,11 @@ import { } from '@vegaprotocol/types'; import type { VegaStoredTxState } from '@vegaprotocol/wallet'; import { VegaTxStatus } from '@vegaprotocol/wallet'; -import { VegaTransactionDetails } from './use-vega-transaction-toasts'; +import { + VegaTransactionDetails, + getVegaTransactionContentIntent, +} from './use-vega-transaction-toasts'; +import { Intent } from '@vegaprotocol/ui-toolkit'; jest.mock('@vegaprotocol/assets', () => { const A1 = { @@ -278,3 +282,27 @@ describe('VegaTransactionDetails', () => { expect(queryByTestId('toast-panel')?.textContent).toEqual(details); }); }); + +describe('getVegaTransactionContentIntent', () => { + it('returns the correct intent for a transaction', () => { + expect(getVegaTransactionContentIntent(withdraw).intent).toBe( + Intent.Primary + ); + expect(getVegaTransactionContentIntent(submitOrder).intent).toBe( + Intent.Success + ); + expect(getVegaTransactionContentIntent(editOrder).intent).toBe( + Intent.Success + ); + expect(getVegaTransactionContentIntent(cancelOrder).intent).toBe( + Intent.Primary + ); + expect(getVegaTransactionContentIntent(cancelAll).intent).toBe( + Intent.Primary + ); + expect(getVegaTransactionContentIntent(closePosition).intent).toBe( + Intent.Primary + ); + expect(getVegaTransactionContentIntent(batch).intent).toBe(Intent.Primary); + }); +}); diff --git a/apps/trading/lib/hooks/use-vega-transaction-toasts.tsx b/apps/trading/lib/hooks/use-vega-transaction-toasts.tsx index c0591a94e..86a70d6c6 100644 --- a/apps/trading/lib/hooks/use-vega-transaction-toasts.tsx +++ b/apps/trading/lib/hooks/use-vega-transaction-toasts.tsx @@ -547,7 +547,11 @@ const VegaTxCompleteToastsContent = ({ tx }: VegaTxToastContentProps) => { return ( <> - {t('Confirmed')} + + {tx.order?.status + ? getOrderToastTitle(tx.order.status) + : t('Confirmed')} +

{t('Your transaction has been confirmed ')}

{tx.txHash && (

@@ -634,25 +638,8 @@ export const useVegaTransactionToasts = () => { ); const fromVegaTransaction = (tx: VegaStoredTxState): Toast => { - let content: ToastContent; const closeAfter = isFinal(tx) ? CLOSE_AFTER : undefined; - if (tx.status === VegaTxStatus.Requested) { - content = ; - } - if (tx.status === VegaTxStatus.Pending) { - content = ; - } - if (tx.status === VegaTxStatus.Complete) { - content = ; - } - if (tx.status === VegaTxStatus.Error) { - content = ; - } - - // Transaction can be successful but the order can be rejected by the network - const intent = - (tx.order && getOrderToastIntent(tx.order.status)) || - intentMap[tx.status]; + const { intent, content } = getVegaTransactionContentIntent(tx); return { id: `vega-${tx.id}`, @@ -676,3 +663,24 @@ export const useVegaTransactionToasts = () => { } ); }; + +export const getVegaTransactionContentIntent = (tx: VegaStoredTxState) => { + let content: ToastContent; + if (tx.status === VegaTxStatus.Requested) { + content = ; + } + if (tx.status === VegaTxStatus.Pending) { + content = ; + } + if (tx.status === VegaTxStatus.Complete) { + content = ; + } + if (tx.status === VegaTxStatus.Error) { + content = ; + } + + // Transaction can be successful but the order can be rejected by the network + const intent = + (tx.order && getOrderToastIntent(tx.order.status)) || intentMap[tx.status]; + return { intent, content }; +}; diff --git a/libs/orders/src/lib/utils.spec.ts b/libs/orders/src/lib/utils.spec.ts new file mode 100644 index 000000000..ac7c8937d --- /dev/null +++ b/libs/orders/src/lib/utils.spec.ts @@ -0,0 +1,129 @@ +import { Intent } from '@vegaprotocol/ui-toolkit'; +import { + getOrderToastIntent, + getOrderToastTitle, + getRejectionReason, + timeInForceLabel, +} from './utils'; +import * as Types from '@vegaprotocol/types'; + +describe('getOrderToastTitle', () => { + it('should return the correct title', () => { + expect(getOrderToastTitle(Types.OrderStatus.STATUS_ACTIVE)).toBe( + 'Order submitted' + ); + expect(getOrderToastTitle(Types.OrderStatus.STATUS_FILLED)).toBe( + 'Order filled' + ); + expect(getOrderToastTitle(Types.OrderStatus.STATUS_PARTIALLY_FILLED)).toBe( + 'Order partially filled' + ); + expect(getOrderToastTitle(Types.OrderStatus.STATUS_PARKED)).toBe( + 'Order parked' + ); + expect(getOrderToastTitle(Types.OrderStatus.STATUS_STOPPED)).toBe( + 'Order stopped' + ); + expect(getOrderToastTitle(Types.OrderStatus.STATUS_CANCELLED)).toBe( + 'Order cancelled' + ); + expect(getOrderToastTitle(Types.OrderStatus.STATUS_EXPIRED)).toBe( + 'Order expired' + ); + expect(getOrderToastTitle(Types.OrderStatus.STATUS_REJECTED)).toBe( + 'Order rejected' + ); + expect(getOrderToastTitle(undefined)).toBe(undefined); + }); +}); + +describe('getOrderToastIntent', () => { + it('should return the correct intent', () => { + expect(getOrderToastIntent(Types.OrderStatus.STATUS_PARKED)).toBe( + Intent.Warning + ); + expect(getOrderToastIntent(Types.OrderStatus.STATUS_EXPIRED)).toBe( + Intent.Warning + ); + expect(getOrderToastIntent(Types.OrderStatus.STATUS_PARTIALLY_FILLED)).toBe( + Intent.Warning + ); + expect(getOrderToastIntent(Types.OrderStatus.STATUS_REJECTED)).toBe( + Intent.Danger + ); + expect(getOrderToastIntent(Types.OrderStatus.STATUS_STOPPED)).toBe( + Intent.Danger + ); + expect(getOrderToastIntent(Types.OrderStatus.STATUS_FILLED)).toBe( + Intent.Success + ); + expect(getOrderToastIntent(Types.OrderStatus.STATUS_ACTIVE)).toBe( + Intent.Success + ); + expect(getOrderToastIntent(Types.OrderStatus.STATUS_CANCELLED)).toBe( + Intent.Success + ); + expect(getOrderToastIntent(undefined)).toBe(undefined); + }); +}); + +describe('getRejectionReason', () => { + it('should return the correct rejection reason for insufficient asset balance', () => { + expect( + getRejectionReason({ + rejectionReason: + Types.OrderRejectionReason.ORDER_ERROR_INSUFFICIENT_ASSET_BALANCE, + status: Types.OrderStatus.STATUS_REJECTED, + id: '', + createdAt: undefined, + size: '', + price: '', + timeInForce: Types.OrderTimeInForce.TIME_IN_FORCE_FOK, + side: Types.Side.SIDE_BUY, + marketId: '', + }) + ).toBe('Insufficient asset balance'); + }); + + it('should return the correct rejection reason when order is stopped', () => { + expect( + getRejectionReason({ + rejectionReason: null, + status: Types.OrderStatus.STATUS_STOPPED, + id: '', + createdAt: undefined, + size: '', + price: '', + timeInForce: Types.OrderTimeInForce.TIME_IN_FORCE_FOK, + side: Types.Side.SIDE_BUY, + marketId: '', + }) + ).toBe( + 'Your Fill or Kill (FOK) order was not filled and it has been stopped' + ); + }); +}); + +describe('timeInForceLabel', () => { + it('should return the correct label for time in force', () => { + expect(timeInForceLabel(Types.OrderTimeInForce.TIME_IN_FORCE_FOK)).toBe( + `Fill or Kill (FOK)` + ); + expect(timeInForceLabel(Types.OrderTimeInForce.TIME_IN_FORCE_GTC)).toBe( + `Good 'til Cancelled (GTC)` + ); + expect(timeInForceLabel(Types.OrderTimeInForce.TIME_IN_FORCE_IOC)).toBe( + `Immediate or Cancel (IOC)` + ); + expect(timeInForceLabel(Types.OrderTimeInForce.TIME_IN_FORCE_GTT)).toBe( + `Good 'til Time (GTT)` + ); + expect(timeInForceLabel(Types.OrderTimeInForce.TIME_IN_FORCE_GFA)).toBe( + `Good for Auction (GFA)` + ); + expect(timeInForceLabel(Types.OrderTimeInForce.TIME_IN_FORCE_GFN)).toBe( + `Good for Normal (GFN)` + ); + expect(timeInForceLabel('')).toBe(''); + }); +}); diff --git a/libs/orders/src/lib/utils.ts b/libs/orders/src/lib/utils.ts index 2acac6fcb..e71ebaf59 100644 --- a/libs/orders/src/lib/utils.ts +++ b/libs/orders/src/lib/utils.ts @@ -82,10 +82,10 @@ export const getOrderToastIntent = ( return Intent.Warning; case Schema.OrderStatus.STATUS_REJECTED: case Schema.OrderStatus.STATUS_STOPPED: - case Schema.OrderStatus.STATUS_CANCELLED: return Intent.Danger; case Schema.OrderStatus.STATUS_FILLED: case Schema.OrderStatus.STATUS_ACTIVE: + case Schema.OrderStatus.STATUS_CANCELLED: return Intent.Success; default: return;