From 28b4593a1db66d73ccdd4cb6fab355921ea54827 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Fri, 1 Mar 2024 09:25:56 -0500 Subject: [PATCH] refactor(trading,governance,wallet): wallet rewrite (#5815) Co-authored-by: bwallacee --- .../src/integration/view/pubkey-view.cy.ts | 6 - apps/governance/src/app-loader.tsx | 18 +- apps/governance/src/app.tsx | 172 +---- .../balance-manager/balance-manager.tsx | 2 +- .../connect-to-vega/connect-to-vega.tsx | 11 +- .../src/components}/manage-dialog/index.ts | 0 .../manage-dialog/manage-dialog.tsx | 6 +- .../components/page-templates/app-layout.tsx | 2 +- .../page-templates/template-sidebar.tsx | 10 +- .../vega-wallet-container.tsx | 6 +- .../vega-wallet-dialogs/risk-message.tsx | 4 +- .../vega-wallet-dialogs.tsx | 36 +- .../src/components/vega-wallet/hooks.ts | 2 +- .../vega-wallet/vega-wallet-prompt.tsx | 6 +- .../components/vega-wallet/vega-wallet.tsx | 19 +- .../hooks/use-listen-for-staking-events.ts | 2 +- .../src/hooks/use-refresh-balances.ts | 2 +- apps/governance/src/hooks/use-sentry-init.ts | 81 +++ .../src/hooks/use-vega-wallet-config.ts | 41 ++ apps/governance/src/i18n/index.ts | 2 +- apps/governance/src/lib/vega-connectors.ts | 30 - .../proposal-header.spec.tsx | 19 +- .../components/proposal/proposal.spec.tsx | 43 +- .../components/proposal/proposal.tsx | 3 +- .../proposals-list-item-details.spec.tsx | 7 +- .../propose/proposal-form-submit.spec.tsx | 57 +- .../propose/proposal-form-submit.tsx | 2 +- .../proposal-form-transaction-dialog.tsx | 18 +- .../vote-breakdown/vote-breakdown.spec.tsx | 7 +- .../components/vote-details/use-user-vote.tsx | 2 +- .../components/vote-details/user-vote.tsx | 9 +- .../vega-transaction-dialog.spec.tsx | 70 +- .../vote-details/vote-buttons.spec.tsx | 219 ++---- .../components/vote-details/vote-buttons.tsx | 33 +- .../vote-details/vote-transaction-dialog.tsx | 15 +- .../freeform/propose-freeform.spec.tsx | 16 +- .../propose/freeform/propose-freeform.tsx | 6 +- .../propose-network-parameter.spec.tsx | 20 +- .../propose-network-parameter.tsx | 6 +- .../new-asset/propose-new-asset.spec.tsx | 20 +- .../propose/new-asset/propose-new-asset.tsx | 6 +- .../new-market/propose-new-market.spec.tsx | 20 +- .../propose/new-market/propose-new-market.tsx | 6 +- .../propose/raw/proposal-raw.spec.tsx | 81 ++- .../proposals/propose/raw/propose-raw.tsx | 6 +- .../propose-update-asset.spec.tsx | 20 +- .../update-asset/propose-update-asset.tsx | 6 +- .../propose-update-market.spec.tsx | 20 +- .../update-market/propose-update-market.tsx | 6 +- .../routes/proposals/test-helpers/mocks.ts | 15 +- .../routes/rewards/connect-to-see-rewards.tsx | 6 +- .../epoch-individual-rewards.tsx | 2 +- .../src/routes/rewards/home/rewards-page.tsx | 2 +- .../staking-wallets-container.spec.tsx | 4 +- .../staking-wallets-container.tsx | 2 +- .../staking/disassociate/index.spec.tsx | 4 +- .../src/routes/staking/disassociate/index.tsx | 2 +- .../src/routes/staking/home/epoch-data.tsx | 2 +- .../src/routes/staking/node/node.tsx | 2 +- .../routes/staking/node/nodes-container.tsx | 2 +- .../src/routes/staking/node/pending-stake.tsx | 78 -- .../src/routes/staking/node/staking-form.tsx | 8 +- .../src/routes/withdrawals/index.tsx | 2 +- apps/governance/src/toasts-manager.tsx | 6 +- .../competitions/competitions-create-team.tsx | 6 +- .../competitions/competitions-team.tsx | 2 +- .../competitions/competitions-update-team.tsx | 6 +- .../competitions/join-team.spec.tsx | 2 +- .../client-pages/competitions/join-team.tsx | 7 +- .../client-pages/competitions/team-form.tsx | 8 +- .../competitions/update-team-button.tsx | 2 +- .../deposit/deposit-get-started.tsx | 6 +- .../client-pages/liquidity/liquidity.tsx | 2 +- .../client-pages/markets/closed.spec.tsx | 10 +- .../client-pages/markets/mobile-buttons.tsx | 6 +- .../markets/open-markets.spec.tsx | 9 +- .../referrals/apply-code-form.tsx | 8 +- .../referrals/create-code-form.tsx | 6 +- .../referrals/hooks/use-funds-available.ts | 2 +- .../referrals/hooks/use-referral-toasts.tsx | 2 +- .../referrals/hooks/use-referral.ts | 4 +- .../referrals/referral-statistics.spec.tsx | 47 +- .../referrals/referral-statistics.tsx | 2 +- .../client-pages/referrals/referrals.tsx | 2 +- .../accounts-container/accounts-container.tsx | 2 +- .../components/bootstrapper/bootstrapper.tsx | 47 +- .../deposits-container/deposits-container.tsx | 2 +- .../fees-container/fees-container.tsx | 2 +- .../fills-container/fills-container.tsx | 2 +- .../funding-payments-container.tsx | 2 +- .../ledger-container/ledger-container.tsx | 2 +- .../trading/components/navbar/navbar.spec.tsx | 78 +- apps/trading/components/navbar/navbar.tsx | 12 +- .../orders-container/orders-container.tsx | 2 +- .../positions-container.tsx | 2 +- .../rewards-container.spec.tsx | 10 +- .../rewards-container/rewards-container.tsx | 8 +- .../rewards-container/rewards-history.tsx | 6 +- .../rewards-container/use-reward-row-data.ts | 2 +- .../components/risk-ack-content/index.ts | 1 + .../risk-ack-content.tsx} | 34 +- .../components/sidebar/sidebar.spec.tsx | 42 +- apps/trading/components/sidebar/sidebar.tsx | 17 +- .../stop-orders-container.tsx | 2 +- .../components/telemetry/telemetry.tsx | 2 +- .../vega-wallet-connect-button.spec.tsx | 104 +-- .../vega-wallet-connect-button.tsx | 53 +- .../vega-wallet-connect-dialog/index.ts | 1 + .../vega-wallet-connect-dialog.tsx | 30 + .../vega-wallet/vega-wallet-menu.tsx | 5 +- .../components/viewing-banner/index.tsx | 2 +- .../welcome-dialog/get-started.spec.tsx | 65 +- .../components/welcome-dialog/get-started.tsx | 38 +- .../components/welcome-dialog/index.ts | 1 - .../use-get-onboarding-step.spec.tsx | 81 --- .../welcome-dialog/welcome-dialog-content.tsx | 83 ++- .../welcome-dialog/welcome-dialog.tsx | 183 +++-- .../withdraw-container/withdraw-container.tsx | 2 +- .../withdrawals-container.tsx | 2 +- apps/trading/e2e/conftest.py | 100 ++- .../e2e/tests/get_started/test_get_started.py | 17 +- .../e2e/tests/navigation/test_navigation.py | 4 +- .../hooks/use-get-onboarding-step.spec.tsx | 82 +++ .../hooks}/use-get-onboarding-step.ts | 47 +- apps/trading/lib/hooks/use-my-team.ts | 2 +- .../lib/hooks/use-referral-set-transaction.ts | 3 +- apps/trading/lib/hooks/use-stake-available.ts | 2 +- .../lib/hooks/use-vega-wallet-config.ts | 46 ++ apps/trading/lib/i18n/index.ts | 4 +- apps/trading/lib/vega-connectors.ts | 35 - apps/trading/pages/dialogs-container.tsx | 12 +- apps/trading/pages/maybe-connect-eagerly.tsx | 22 +- .../pages/party-active-orders-handler.tsx | 2 +- apps/trading/stores/global.ts | 2 - apps/trading/stores/onboarding.ts | 40 ++ .../src/lib/accounts-data-provider.ts | 2 +- libs/accounts/src/lib/transfer-container.tsx | 2 +- libs/accounts/src/lib/transfer-form.tsx | 2 +- libs/accounts/src/lib/use-account-balance.tsx | 2 +- .../src/lib/use-margin-account-balance.tsx | 2 +- libs/candles-chart/src/lib/candles-chart.tsx | 2 +- .../lib/commands/add-connect-public-key.ts | 8 +- .../src/lib/commands/vega-wallet-connect.ts | 16 +- .../deal-ticket-margin-details.tsx | 2 +- .../deal-ticket-stop-order.spec.tsx | 23 +- .../deal-ticket/deal-ticket-stop-order.tsx | 2 +- .../deal-ticket/deal-ticket.spec.tsx | 18 +- .../components/deal-ticket/deal-ticket.tsx | 4 +- .../deal-ticket/margin-mode-selector.tsx | 5 +- .../src/hooks/use-estimate-fees.spec.tsx | 2 +- .../src/hooks/use-estimate-fees.tsx | 2 +- libs/deposits/src/lib/deposit-form.spec.tsx | 4 +- libs/deposits/src/lib/deposit-form.tsx | 2 +- libs/environment/src/chains.ts | 13 + libs/environment/src/index.ts | 3 + libs/environment/src/types.ts | 1 + .../src/utils/validate-environment.ts | 11 +- libs/funding-payments/src/setup-tests.ts | 13 + libs/i18n/src/index.ts | 2 + libs/i18n/src/locales/en/governance.json | 4 +- libs/i18n/src/locales/en/trading.json | 5 +- libs/i18n/src/locales/en/wallet-react.json | 13 + libs/i18n/src/locales/en/wallet.json | 67 +- .../open-orders-menu/open-orders-menu.tsx | 2 +- .../order-list-manager.spec.tsx | 40 +- .../components/order-list/order-list.spec.tsx | 24 +- .../stop-orders-manager.spec.tsx | 21 +- .../stop-orders-table.spec.tsx | 24 +- .../order-hooks/use-has-amendable-order.ts | 2 +- .../src/lib/positions-data-providers.ts | 5 +- .../src/lib/positions-manager.spec.tsx | 41 +- libs/positions/src/lib/positions-manager.tsx | 2 +- libs/positions/src/lib/use-market-margin.tsx | 2 +- .../vega-transaction-dialog.spec.tsx | 97 +-- .../vega-transaction-dialog.tsx | 32 +- .../proposals-hooks/use-proposal-submit.ts | 13 +- .../use-vega-transaction.spec.tsx | 107 +-- .../proposals-hooks/use-vega-transaction.tsx | 75 +- .../src/lib/voting-hooks/use-vote-submit.ts | 5 +- libs/react-helpers/src/hooks/index.ts | 1 + .../react-helpers/src/hooks/use-user-agent.ts | 12 + .../src/components/button/button.tsx | 2 +- .../src/components/callout/callout.spec.tsx | 4 +- .../src/components/dialog/dialog.tsx | 16 +- .../src/components/tooltip/tooltip.tsx | 4 +- .../src/components/viewing-as-user/index.tsx | 5 +- libs/ui-toolkit/src/utils/intent.ts | 2 +- libs/wallet-react/.babelrc | 12 + libs/wallet-react/.eslintrc.json | 18 + libs/wallet-react/README.md | 7 + libs/wallet-react/jest.config.ts | 12 + libs/wallet-react/package.json | 4 + libs/wallet-react/project.json | 44 ++ .../src/SimpleTransaction.graphql | 0 .../src/__generated__/SimpleTransaction.ts | 0 .../connect-dialog/connect-dialog.spec.tsx | 111 +++ .../connect-dialog/connect-dialog.tsx | 107 +++ .../connect-dialog/connection-options.tsx | 346 +++++++++ .../connect-dialog/connection-status.tsx | 29 + .../connect-dialog/connector-icon.tsx | 68 ++ .../src/components/connect-dialog/index.ts | 8 + .../src/components/risk-ack/index.ts | 1 + .../src/components/risk-ack/risk-ack.tsx | 34 + libs/wallet-react/src/constants.ts | 11 + libs/wallet-react/src/context.ts | 11 + libs/wallet-react/src/hooks/use-chain-id.ts | 6 + libs/wallet-react/src/hooks/use-config.ts | 10 + libs/wallet-react/src/hooks/use-connect.ts | 9 + libs/wallet-react/src/hooks/use-connector.ts | 13 + .../src/hooks/use-dialog-store.ts | 15 + libs/wallet-react/src/hooks/use-disconnect.ts | 8 + .../src/hooks/use-eager-connect.ts | 33 + libs/wallet-react/src/hooks/use-pub-keys.ts | 8 + libs/wallet-react/src/hooks/use-reconnect.ts | 12 + .../src/hooks/use-send-transaction.ts | 8 + .../src/hooks}/use-simple-transaction.ts | 18 +- .../src => wallet-react/src/hooks}/use-t.ts | 2 +- .../wallet-react/src/hooks/use-vega-wallet.ts | 26 + libs/wallet-react/src/hooks/use-wallet.ts | 10 + libs/wallet-react/src/index.ts | 28 + libs/wallet-react/src/setup-tests.ts | 14 + libs/wallet-react/src/testing.ts | 29 + libs/wallet-react/tsconfig.json | 20 + libs/wallet-react/tsconfig.lib.json | 24 + libs/wallet-react/tsconfig.spec.json | 20 + libs/wallet/project.json | 6 +- libs/wallet/src/chains.ts | 29 + .../wallet/src/connect-dialog/chrome-icon.tsx | 77 -- .../connect-dialog-elements.tsx | 78 -- .../connect-dialog/connect-dialog.spec.tsx | 353 --------- .../src/connect-dialog/connect-dialog.tsx | 675 ------------------ libs/wallet/src/connect-dialog/index.ts | 3 - .../injected-connector-form.tsx | 168 ----- .../json-rpc-connector-form.tsx | 231 ------ .../src/connect-dialog/mozilla-icon.tsx | 214 ------ .../vega-wallet-dialog-store.ts | 18 - .../src/connect-dialog/view-as-dialog.tsx | 40 -- .../connect-dialog/view-connector-form.tsx | 105 --- libs/wallet/src/connectors/index.ts | 22 +- .../src/connectors/injected-connector.ts | 208 +++--- .../src/connectors/json-rpc-connector.ts | 376 +++++----- libs/wallet/src/connectors/mock-connector.ts | 57 ++ libs/wallet/src/connectors/snap-connector.ts | 467 ++++++------ libs/wallet/src/connectors/view-connector.tsx | 57 -- .../src/connectors/view-party-connector.ts | 109 +++ libs/wallet/src/context.ts | 71 -- libs/wallet/src/errors.ts | 104 +++ libs/wallet/src/index.ts | 36 +- .../src/manage-dialog/manage-dialog.spec.tsx | 78 -- libs/wallet/src/provider.spec.tsx | 210 ------ libs/wallet/src/provider.tsx | 213 ------ libs/wallet/src/setup-tests.ts | 16 - libs/wallet/src/storage.ts | 40 -- libs/wallet/src/test-helpers.ts | 6 +- ...vega-connector.ts => transaction-types.ts} | 123 +--- libs/wallet/src/types.ts | 130 ++++ libs/wallet/src/use-chain-id.spec.ts | 100 --- libs/wallet/src/use-chain-id.ts | 62 -- libs/wallet/src/use-eager-connect.ts | 57 -- .../src/use-injected-connector.spec.tsx | 100 --- libs/wallet/src/use-injected-connector.ts | 82 --- libs/wallet/src/use-is-alive.ts | 31 - .../src/use-is-wallet-service-running.spec.ts | 41 -- .../src/use-is-wallet-service-running.ts | 39 - libs/wallet/src/use-json-rpc-connect.ts | 77 -- libs/wallet/src/use-snap-status.ts | 37 - libs/wallet/src/use-vega-wallet.ts | 24 - libs/wallet/src/utils.spec.ts | 1 + libs/wallet/src/utils.ts | 76 +- libs/wallet/src/wallet.spec.ts | 222 ++++++ libs/wallet/src/wallet.ts | 196 +++++ .../use-ethereum-transaction-updater.spec.tsx | 12 +- .../lib/use-ethereum-transaction-updater.tsx | 2 +- .../lib/use-vega-transaction-manager.spec.tsx | 61 +- .../src/lib/use-vega-transaction-manager.tsx | 54 +- .../src/lib/use-vega-transaction-toasts.tsx | 46 +- .../lib/use-vega-transaction-updater.spec.tsx | 2 +- .../src/lib/use-vega-transaction-updater.tsx | 2 +- .../lib/use-wallet-disconnected-toasts.tsx | 20 +- .../src/lib/create-withdrawal-dialog.tsx | 2 +- ...eady-to-complete-withdrawals-toast.spec.ts | 4 +- ...se-ready-to-complete-withdrawals-toast.tsx | 2 +- package.json | 4 +- tsconfig.base.json | 4 + yarn.lock | 33 +- 285 files changed, 4526 insertions(+), 5917 deletions(-) rename {libs/wallet/src => apps/governance/src/components}/manage-dialog/index.ts (100%) rename {libs/wallet/src => apps/governance/src/components}/manage-dialog/manage-dialog.tsx (94%) create mode 100644 apps/governance/src/hooks/use-sentry-init.ts create mode 100644 apps/governance/src/hooks/use-vega-wallet-config.ts delete mode 100644 apps/governance/src/lib/vega-connectors.ts delete mode 100644 apps/governance/src/routes/staking/node/pending-stake.tsx create mode 100644 apps/trading/components/risk-ack-content/index.ts rename apps/trading/components/{welcome-dialog/risk-message.tsx => risk-ack-content/risk-ack-content.tsx} (76%) create mode 100644 apps/trading/components/vega-wallet-connect-dialog/index.ts create mode 100644 apps/trading/components/vega-wallet-connect-dialog/vega-wallet-connect-dialog.tsx delete mode 100644 apps/trading/components/welcome-dialog/use-get-onboarding-step.spec.tsx create mode 100644 apps/trading/lib/hooks/use-get-onboarding-step.spec.tsx rename apps/trading/{components/welcome-dialog => lib/hooks}/use-get-onboarding-step.ts (64%) create mode 100644 apps/trading/lib/hooks/use-vega-wallet-config.ts delete mode 100644 apps/trading/lib/vega-connectors.ts create mode 100644 apps/trading/stores/onboarding.ts create mode 100644 libs/environment/src/chains.ts create mode 100644 libs/i18n/src/locales/en/wallet-react.json create mode 100644 libs/react-helpers/src/hooks/use-user-agent.ts create mode 100644 libs/wallet-react/.babelrc create mode 100644 libs/wallet-react/.eslintrc.json create mode 100644 libs/wallet-react/README.md create mode 100644 libs/wallet-react/jest.config.ts create mode 100644 libs/wallet-react/package.json create mode 100644 libs/wallet-react/project.json rename libs/{wallet => wallet-react}/src/SimpleTransaction.graphql (100%) rename libs/{wallet => wallet-react}/src/__generated__/SimpleTransaction.ts (100%) create mode 100644 libs/wallet-react/src/components/connect-dialog/connect-dialog.spec.tsx create mode 100644 libs/wallet-react/src/components/connect-dialog/connect-dialog.tsx create mode 100644 libs/wallet-react/src/components/connect-dialog/connection-options.tsx create mode 100644 libs/wallet-react/src/components/connect-dialog/connection-status.tsx create mode 100644 libs/wallet-react/src/components/connect-dialog/connector-icon.tsx create mode 100644 libs/wallet-react/src/components/connect-dialog/index.ts create mode 100644 libs/wallet-react/src/components/risk-ack/index.ts create mode 100644 libs/wallet-react/src/components/risk-ack/risk-ack.tsx create mode 100644 libs/wallet-react/src/constants.ts create mode 100644 libs/wallet-react/src/context.ts create mode 100644 libs/wallet-react/src/hooks/use-chain-id.ts create mode 100644 libs/wallet-react/src/hooks/use-config.ts create mode 100644 libs/wallet-react/src/hooks/use-connect.ts create mode 100644 libs/wallet-react/src/hooks/use-connector.ts create mode 100644 libs/wallet-react/src/hooks/use-dialog-store.ts create mode 100644 libs/wallet-react/src/hooks/use-disconnect.ts create mode 100644 libs/wallet-react/src/hooks/use-eager-connect.ts create mode 100644 libs/wallet-react/src/hooks/use-pub-keys.ts create mode 100644 libs/wallet-react/src/hooks/use-reconnect.ts create mode 100644 libs/wallet-react/src/hooks/use-send-transaction.ts rename libs/{wallet/src => wallet-react/src/hooks}/use-simple-transaction.ts (89%) rename libs/{wallet/src => wallet-react/src/hooks}/use-t.ts (73%) create mode 100644 libs/wallet-react/src/hooks/use-vega-wallet.ts create mode 100644 libs/wallet-react/src/hooks/use-wallet.ts create mode 100644 libs/wallet-react/src/index.ts create mode 100644 libs/wallet-react/src/setup-tests.ts create mode 100644 libs/wallet-react/src/testing.ts create mode 100644 libs/wallet-react/tsconfig.json create mode 100644 libs/wallet-react/tsconfig.lib.json create mode 100644 libs/wallet-react/tsconfig.spec.json create mode 100644 libs/wallet/src/chains.ts delete mode 100644 libs/wallet/src/connect-dialog/chrome-icon.tsx delete mode 100644 libs/wallet/src/connect-dialog/connect-dialog-elements.tsx delete mode 100644 libs/wallet/src/connect-dialog/connect-dialog.spec.tsx delete mode 100644 libs/wallet/src/connect-dialog/connect-dialog.tsx delete mode 100644 libs/wallet/src/connect-dialog/index.ts delete mode 100644 libs/wallet/src/connect-dialog/injected-connector-form.tsx delete mode 100644 libs/wallet/src/connect-dialog/json-rpc-connector-form.tsx delete mode 100644 libs/wallet/src/connect-dialog/mozilla-icon.tsx delete mode 100644 libs/wallet/src/connect-dialog/vega-wallet-dialog-store.ts delete mode 100644 libs/wallet/src/connect-dialog/view-as-dialog.tsx delete mode 100644 libs/wallet/src/connect-dialog/view-connector-form.tsx create mode 100644 libs/wallet/src/connectors/mock-connector.ts delete mode 100644 libs/wallet/src/connectors/view-connector.tsx create mode 100644 libs/wallet/src/connectors/view-party-connector.ts delete mode 100644 libs/wallet/src/context.ts create mode 100644 libs/wallet/src/errors.ts delete mode 100644 libs/wallet/src/manage-dialog/manage-dialog.spec.tsx delete mode 100644 libs/wallet/src/provider.spec.tsx delete mode 100644 libs/wallet/src/provider.tsx delete mode 100644 libs/wallet/src/storage.ts rename libs/wallet/src/{connectors/vega-connector.ts => transaction-types.ts} (78%) create mode 100644 libs/wallet/src/types.ts delete mode 100644 libs/wallet/src/use-chain-id.spec.ts delete mode 100644 libs/wallet/src/use-chain-id.ts delete mode 100644 libs/wallet/src/use-eager-connect.ts delete mode 100644 libs/wallet/src/use-injected-connector.spec.tsx delete mode 100644 libs/wallet/src/use-injected-connector.ts delete mode 100644 libs/wallet/src/use-is-alive.ts delete mode 100644 libs/wallet/src/use-is-wallet-service-running.spec.ts delete mode 100644 libs/wallet/src/use-is-wallet-service-running.ts delete mode 100644 libs/wallet/src/use-json-rpc-connect.ts delete mode 100644 libs/wallet/src/use-snap-status.ts delete mode 100644 libs/wallet/src/use-vega-wallet.ts create mode 100644 libs/wallet/src/wallet.spec.ts create mode 100644 libs/wallet/src/wallet.ts diff --git a/apps/governance-e2e/src/integration/view/pubkey-view.cy.ts b/apps/governance-e2e/src/integration/view/pubkey-view.cy.ts index bc1b4537f..4e83e2dd7 100644 --- a/apps/governance-e2e/src/integration/view/pubkey-view.cy.ts +++ b/apps/governance-e2e/src/integration/view/pubkey-view.cy.ts @@ -34,12 +34,6 @@ context('View functionality with public key', { tags: '@smoke' }, function () { cy.connectPublicKey(vegaWalletPubKey); }); - it('Able to connect public key using url', function () { - cy.getByTestId('exit-view').click(); - cy.visit(`/?address=${vegaWalletPubKey}`); - verifyConnectedToPubKey(); - }); - it.skip('Able to connect public key via wallet and view assets in wallet', function () { verifyConnectedToPubKey(); cy.getByTestId('currency-title', { timeout: 10000 }) diff --git a/apps/governance/src/app-loader.tsx b/apps/governance/src/app-loader.tsx index ac004f31e..7f4196a96 100644 --- a/apps/governance/src/app-loader.tsx +++ b/apps/governance/src/app-loader.tsx @@ -1,7 +1,7 @@ import * as Sentry from '@sentry/react'; import { toBigNum } from '@vegaprotocol/utils'; import { Splash } from '@vegaprotocol/ui-toolkit'; -import { useVegaWallet, useEagerConnect } from '@vegaprotocol/wallet'; +import { useVegaWallet, useEagerConnect } from '@vegaprotocol/wallet-react'; import { useFeatureFlags, useEnvironment } from '@vegaprotocol/environment'; import { useWeb3React } from '@web3-react/core'; import React, { Suspense } from 'react'; @@ -15,20 +15,6 @@ import { } from './contexts/app-state/app-state-context'; import { useContracts } from './contexts/contracts/contracts-context'; import { useRefreshAssociatedBalances } from './hooks/use-refresh-associated-balances'; -import { useConnectors } from './lib/vega-connectors'; -import { useSearchParams } from 'react-router-dom'; - -const useVegaWalletEagerConnect = () => { - const connectors = useConnectors(); - const vegaConnecting = useEagerConnect(connectors); - const { pubKey, connect } = useVegaWallet(); - const [searchParams] = useSearchParams(); - const [query] = React.useState(searchParams.get('address')); - if (query && !pubKey) { - connect(connectors.view); - } - return vegaConnecting; -}; export const AppLoader = ({ children }: { children: React.ReactElement }) => { const featureFlags = useFeatureFlags((state) => state.flags); @@ -40,7 +26,7 @@ export const AppLoader = ({ children }: { children: React.ReactElement }) => { const { token, staking, vesting } = useContracts(); const setAssociatedBalances = useRefreshAssociatedBalances(); const [balancesLoaded, setBalancesLoaded] = React.useState(false); - const vegaConnecting = useVegaWalletEagerConnect(); + const vegaConnecting = useEagerConnect(); const loaded = balancesLoaded && !vegaConnecting; diff --git a/apps/governance/src/app.tsx b/apps/governance/src/app.tsx index f81db9e1f..bd032dad0 100644 --- a/apps/governance/src/app.tsx +++ b/apps/governance/src/app.tsx @@ -1,7 +1,6 @@ import './i18n'; import React, { useEffect } from 'react'; -import * as Sentry from '@sentry/react'; import { BrowserRouter as Router, useLocation } from 'react-router-dom'; import { AppLoader } from './app-loader'; import { NetworkInfo } from '@vegaprotocol/network-info'; @@ -26,7 +25,7 @@ import { } from '@vegaprotocol/web3'; import { Web3Provider } from '@vegaprotocol/web3'; import { VegaWalletDialogs } from './components/vega-wallet-dialogs'; -import { VegaWalletProvider, useChainId } from '@vegaprotocol/wallet'; +import { WalletProvider } from '@vegaprotocol/wallet-react'; import { useVegaTransactionManager, useVegaTransactionUpdater, @@ -36,26 +35,21 @@ import { useEthereumConfig } from '@vegaprotocol/web3'; import { useEnvironment, NetworkLoader, - useInitializeEnv, NodeGuard, NodeSwitcherDialog, useNodeSwitcherStore, - DocsLinks, NodeFailure, AppLoader as Loader, + useInitializeEnv, } from '@vegaprotocol/environment'; -import { ENV } from './config'; import type { InMemoryCacheConfig } from '@apollo/client'; import { CreateWithdrawalDialog } from '@vegaprotocol/withdraws'; import { SplashLoader } from './components/splash-loader'; import { ToastsManager } from './toasts-manager'; -import { - TelemetryDialog, - TELEMETRY_ON, -} from './components/telemetry-dialog/telemetry-dialog'; -import { useLocalStorage } from '@vegaprotocol/react-helpers'; +import { TelemetryDialog } from './components/telemetry-dialog/telemetry-dialog'; import { useTranslation } from 'react-i18next'; -import { isPartyNotFoundError } from './lib/party'; +import { useSentryInit } from './hooks/use-sentry-init'; +import { useVegaWalletConfig } from './hooks/use-vega-wallet-config'; const cache: InMemoryCacheConfig = { typePolicies: { @@ -104,32 +98,12 @@ const Web3Container = ({ /** Ethereum provider url */ providerUrl: string; }) => { - const InitializeHandlers = () => { - useVegaTransactionManager(); - useVegaTransactionUpdater(); - useEthTransactionManager(); - useEthTransactionUpdater(); - useEthWithdrawApprovalsManager(); - return null; - }; - const [connectors, initializeConnectors] = useWeb3ConnectStore((store) => [ store.connectors, store.initialize, ]); - const { - ETHEREUM_PROVIDER_URL, - ETH_LOCAL_PROVIDER_URL, - ETH_WALLET_MNEMONIC, - VEGA_ENV, - VEGA_URL, - VEGA_EXPLORER_URL, - CHROME_EXTENSION_URL, - MOZILLA_EXTENSION_URL, - VEGA_WALLET_URL, - } = useEnvironment(); - - const vegaChainId = useChainId(VEGA_URL); + const { ETHEREUM_PROVIDER_URL, ETH_LOCAL_PROVIDER_URL, ETH_WALLET_MNEMONIC } = + useEnvironment(); useEffect(() => { if (chainId) { @@ -150,50 +124,31 @@ const Web3Container = ({ ETH_LOCAL_PROVIDER_URL, ETH_WALLET_MNEMONIC, ]); - const sideBar = React.useMemo(() => { - return [, ]; - }, []); - if (connectors.length === 0) { + const vegaWalletConfig = useVegaWalletConfig(); + + if (!vegaWalletConfig || connectors.length === 0) { // Prevent loading when the connectors are not initialized return ; } - if ( - !VEGA_URL || - !VEGA_WALLET_URL || - !VEGA_EXPLORER_URL || - !DocsLinks || - !CHROME_EXTENSION_URL || - !MOZILLA_EXTENSION_URL || - !vegaChainId - ) { - return null; - } - return ( - + <> - + + + + + } + >