Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/multi network #693

Merged
merged 88 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
a4e9987
feat: add networks list in settings
dexturr Jan 4, 2024
d35d083
chore: fix conflicts
dexturr Jan 4, 2024
b60f619
chore: add e2e tests
daro-maj Jan 8, 2024
f98390b
chore: fix bad merge changes
dexturr Jan 24, 2024
110fd89
test: fix settings tets
dexturr Jan 24, 2024
842a361
feat: routes
dexturr Jan 24, 2024
8131cb8
chore: calm down logging on testing
dexturr Jan 24, 2024
eada63c
test: add tests for networks
dexturr Jan 24, 2024
d832747
chore: add tests for networks section
dexturr Jan 24, 2024
9ccf09f
chore: render href if children is not defined for external link
dexturr Jan 24, 2024
b43e236
chore: add all information about the network into network details page
dexturr Jan 24, 2024
4665511
test: add tests for the network details page
dexturr Jan 24, 2024
22f4349
chore: add index file to data table to remove unesseacry charcters in…
dexturr Jan 24, 2024
f463bc5
test: add tests for network list
dexturr Jan 24, 2024
16b2ba2
chore: missed assertion
dexturr Jan 24, 2024
792f97f
test: coverage improvement
dexturr Jan 24, 2024
59a9b4c
style: lint
dexturr Jan 24, 2024
a9270fd
chore: tidying for the sake of consistency
dexturr Jan 24, 2024
cdd729f
chore: more consistency tidying
dexturr Jan 24, 2024
9ce778f
test: fix unit tests
dexturr Jan 24, 2024
d8bc267
test: fix e2e tests
dexturr Jan 24, 2024
5fc4bda
fix: connect wallet fix
dexturr Jan 24, 2024
8123c3a
test: actually use locator in component
dexturr Jan 24, 2024
bbc5da4
test: fix incorrect assertion
dexturr Jan 24, 2024
8388af3
chore: allow type parameter for send request method for better typing
dexturr Dec 18, 2023
4b241b5
chore: do not render switcher if there is only one option
dexturr Dec 18, 2023
7aafd01
chore: generalise dropdown to be used elsewhere
dexturr Dec 18, 2023
de40dab
chore: update selectors
dexturr Dec 18, 2023
592c1c5
style: make txt not always be white for a DD
dexturr Dec 18, 2023
1906cfd
feat: build network switcher in header
dexturr Dec 18, 2023
04eeea1
fix: correct padding
dexturr Dec 18, 2023
e9041a0
feat: create concept of a selected network
dexturr Dec 18, 2023
ef17400
chore: add copy to explain network selector
dexturr Dec 18, 2023
aaa435d
chore: remove uneeded wrapping div
dexturr Dec 18, 2023
1864abd
feat: new networks page in settings
dexturr Dec 18, 2023
6360b25
chore: just tidying up
dexturr Dec 18, 2023
e78f771
chore: add strcuture for network details page
dexturr Dec 18, 2023
4fb89a5
feat: add network details page
dexturr Dec 18, 2023
0e04a73
chore: remove config that is uneeded
dexturr Dec 18, 2023
f872e27
chore: create connection details page
dexturr Dec 19, 2023
1d43dfb
chore: remove details from connections list, add link to new page
dexturr Dec 19, 2023
b770252
chore: create generic backend types file for backend entities
dexturr Dec 19, 2023
adb27ad
test: fix some test type errors
dexturr Dec 19, 2023
8234bf8
test: more test type errors
dexturr Dec 19, 2023
2f61b3f
test: more test fixes based on new behaviour and types
dexturr Dec 19, 2023
5f948f1
chore: more type and test fixes
dexturr Dec 19, 2023
fdcbbdf
test: more refactor fixes
dexturr Dec 19, 2023
617439d
chore: move settings form elements into home directory where they used
dexturr Dec 19, 2023
4338576
chore: fix all types and tests
dexturr Dec 19, 2023
7404475
test: fix auth test for new store that is now being called
dexturr Dec 19, 2023
835a304
feat: begin building out connection details page
dexturr Dec 19, 2023
9bde1ae
chore: rebase issues, get app building
dexturr Jan 24, 2024
ac9cd63
chore: use send message helper type in context
dexturr Jan 24, 2024
91568fb
chore: add network selection functionality
dexturr Jan 25, 2024
3f528cf
chore: remove button for now
dexturr Jan 25, 2024
ed652d5
test: add tests for drop down
dexturr Jan 30, 2024
1550f7c
test: minor test fixes
dexturr Jan 30, 2024
0730ca6
test: more minor test fixesz
dexturr Jan 30, 2024
b555d44
test: fix page header tests
dexturr Jan 30, 2024
8ed7ca3
test: fix key selector tests
dexturr Jan 30, 2024
0acef28
test: add tests for popout button
dexturr Jan 30, 2024
33603fb
chore: make disclaimer always show
dexturr Jan 30, 2024
957b03f
test: add test for selecting a network
dexturr Jan 30, 2024
1eeda8b
test: unit tests passing
dexturr Jan 30, 2024
9d2b505
style: lint
dexturr Jan 30, 2024
0940e85
test: fix e2e test imports
dexturr Jan 30, 2024
44f2910
fix: e2e test imports
dexturr Jan 30, 2024
8c6a282
fix: e2e test imports
dexturr Jan 30, 2024
ebc9a8e
test: fix backend unit test
dexturr Jan 30, 2024
6dccc9c
chore: add header to connections
dexturr Jan 31, 2024
82df79a
feat: change colour of heading based on network
dexturr Jan 31, 2024
77f5cbe
test: fix tests
dexturr Feb 1, 2024
a7a4c36
test: add test for missed branch
dexturr Feb 1, 2024
eceef23
chore: add migration
dexturr Feb 5, 2024
342db4b
chore: add color indicator
dexturr Feb 5, 2024
be445d8
docs: add 2 new specs
dexturr Feb 5, 2024
fc76e35
feat: add color, adjust current color
dexturr Feb 5, 2024
bcdf8bd
test: e2e test for network switching
dexturr Feb 5, 2024
ebda6f1
test: add multi network details test
dexturr Feb 5, 2024
0f8cd07
chore: rebase issues
dexturr Feb 6, 2024
d5364ff
chore: rebase issues
dexturr Feb 6, 2024
f709e43
style: lint
dexturr Feb 6, 2024
e8fe584
chore: rebase issues
dexturr Feb 6, 2024
d5ec45d
test: fix tests
dexturr Feb 6, 2024
59b4233
test: fix e2e test
dexturr Feb 6, 2024
cdc745c
test: fix e2e tests
dexturr Feb 6, 2024
3343588
fix: docs links
dexturr Feb 7, 2024
483d28b
test: fix unit tests
dexturr Feb 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion config/mainnet.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const mainnet = {
sentryDsn: 'https://[email protected]/4505199579758592',
userDataPolicy: 'https://vega.xyz/vega-wallet-user-data-policy/',
logging: false,
showDisclaimer: true,
manifestReplacements: {
buildName: 'Mainnet',
geckoId: '[email protected]',
Expand Down
5 changes: 2 additions & 3 deletions config/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const test = {
test: {
mockPort
},
networks: [networks.testingNetwork, networks.fairground],
networks: [networks.testingNetwork, networks.testingNetwork2],
feedbackLink: 'https://github.com/vegaprotocol/feedback/discussions',
userDataPolicy: 'https://vega.xyz/vega-wallet-user-data-policy/',
encryptionSettings: {
Expand All @@ -18,8 +18,7 @@ const test = {
},
closeWindowOnPopupOpen: false,
sentryDsn: undefined,
logging: true,
showDisclaimer: false,
logging: false,

manifestReplacements: {
buildName: 'Test',
Expand Down
1 change: 0 additions & 1 deletion config/testnet.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const testnet = {
userDataPolicy: 'https://vega.xyz/vega-wallet-user-data-policy/',
sentryDsn: 'https://[email protected]/4505199579758592',
logging: false,
showDisclaimer: false,
features: {
popoutHeader: true
},
Expand Down
22 changes: 14 additions & 8 deletions config/well-known-networks.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const mockPort = 9090

export const mainnet = {
color: '#000000',
secondaryColor: '#FFFFFF',
id: 'mainnet',
name: 'Mainnet',
chainId: 'vega-mainnet-0011',
Expand All @@ -22,14 +24,13 @@ export const mainnet = {
ethereumExplorerLink: 'https://etherscan.io',
explorer: 'https://explorer.vega.xyz',
governance: 'https://governance.vega.xyz',
deposit: 'https://console.vega.xyz/#/portfolio/assets/deposit',
transfer: 'https://console.vega.xyz/#/portfolio/assets/transfer',
withdraw: 'https://console.vega.xyz/#/portfolio/assets/withdraw',
docs: 'https://docs.vega.xyz/mainnet',
docs: 'https://docs.vega.xyz/mainnet/concepts/new-to-vega',
vegaDapps: 'https://vega.xyz/apps'
}

export const fairground = {
color: '#D7FB50',
secondaryColor: '#000000',
id: 'fairground',
name: 'Fairground',
chainId: 'vega-fairground-202305051805',
Expand All @@ -45,10 +46,7 @@ export const fairground = {
ethereumExplorerLink: 'https://sepolia.etherscan.io',
explorer: 'https://explorer.fairground.wtf',
governance: 'https://governance.fairground.wtf',
deposit: 'https://console.fairground.wtf/#/portfolio/assets/deposit',
transfer: 'https://console.fairground.wtf/#/portfolio/assets/transfer',
withdraw: 'https://console.fairground.wtf/#/portfolio/assets/withdraw',
docs: 'https://docs.vega.xyz/testnet',
docs: 'https://docs.vega.xyz/testnet/concepts/new-to-vega',
vegaDapps: 'https://vega.xyz/apps'
}

Expand All @@ -59,3 +57,11 @@ export const testingNetwork = {
chainId: 'test-chain-id',
rest: [`http://localhost:${mockPort}`]
}

export const testingNetwork2 = {
...testingNetwork,
explorer: 'https://different-explorer.vega.xyz',
id: 'test2',
name: 'Test 2',
chainId: 'test-chain-id-2'
}
8 changes: 5 additions & 3 deletions frontend/app.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ jest.mock('@/stores/popover-store', () => ({
}
}))

jest.mock('@/components/global-error-boundary', () => ({ children }: { children: ReactNode }) => (
<div data-testid="global-error-boundary">{children}</div>
))
jest.mock('@/components/global-error-boundary', () => ({
GlobalErrorBoundary: ({ children }: { children: ReactNode }) => (
<div data-testid="global-error-boundary">{children}</div>
)
}))

jest.mock('@/contexts/json-rpc/json-rpc-provider', () => ({
JsonRPCProvider: ({ children }: { children: ReactNode }) => <div data-testid="json-rpc-provider">{children}</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/app.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect } from 'react'
import { MemoryRouter as Router } from 'react-router-dom'

import GlobalErrorBoundary from '@/components/global-error-boundary'
import { GlobalErrorBoundary } from '@/components/global-error-boundary'
import { JsonRPCProvider } from '@/contexts/json-rpc/json-rpc-provider'
import { NetworkProvider } from '@/contexts/network/network-provider'
import { useListenForPopups } from '@/hooks/listen-for-popups'
Expand Down
37 changes: 37 additions & 0 deletions frontend/components/checkbox/checkbox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Checkbox as UICheckbox } from '@vegaprotocol/ui-toolkit'
import classnames from 'classnames'
import type { ReactNode } from 'react'
import type { Control, FieldValues, Path } from 'react-hook-form'
import { Controller } from 'react-hook-form'

import locators from '../locators'

export type CheckboxProperties<T extends FieldValues> = {
name: Path<T>
control: Control<T>
label: ReactNode
disabled?: boolean
className?: string
}

export function Checkbox<T extends FieldValues>({ name, control, label, disabled, className }: CheckboxProperties<T>) {
return (
<Controller
name={name}
control={control}
render={({ field }) => {
return (
<div data-testid={locators.checkboxWrapper} className={classnames('mt-4 flex items-center gap-4', className)}>
<UICheckbox
label={label}
checked={!!field.value}
disabled={disabled}
onCheckedChange={field.onChange}
name={name}
/>
</div>
)
}}
/>
)
}
44 changes: 1 addition & 43 deletions frontend/components/checkbox/index.tsx
Original file line number Diff line number Diff line change
@@ -1,43 +1 @@
import { Checkbox as UICheckbox } from '@vegaprotocol/ui-toolkit'
import classnames from 'classnames'
import type { ReactNode } from 'react'
import type { Control, FieldValues, Path } from 'react-hook-form'
import { Controller } from 'react-hook-form'

import locators from '../locators'

export type CheckboxProperties<T extends FieldValues> = {
name: Path<T>
control: Control<T>
label: ReactNode
disabled?: boolean
className?: string
}

export function Checkbox<T extends FieldValues>({
name,
control,
label,
disabled,
className
}: Readonly<CheckboxProperties<T>>) {
return (
<Controller
name={name}
control={control}
render={({ field }) => {
return (
<div data-testid={locators.checkboxWrapper} className={classnames('mt-4 flex items-center gap-4', className)}>
<UICheckbox
label={label}
checked={!!field.value}
disabled={disabled}
onCheckedChange={field.onChange}
name={name}
/>
</div>
)
}}
/>
)
}
export * from './checkbox'
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { fireEvent, render, screen } from '@testing-library/react'

import locators from '../locators'
import { locators as subHeaderLocators } from '../sub-header'
import { CollapsiblePanel } from './collapsible-panel'

const renderComponent = ({ initiallyOpen }: { initiallyOpen?: boolean }) => {
Expand All @@ -13,7 +14,7 @@ describe('Collapsible panel', () => {
it('renders title, arrow and does not render content', () => {
renderComponent({})
expect(screen.getByTestId(locators.collapsiblePanelButton)).toBeInTheDocument()
expect(screen.getByTestId(locators.collapsiblePanelTitle)).toHaveTextContent('Title')
expect(screen.getByTestId(subHeaderLocators.subHeader)).toHaveTextContent('Title')
expect(screen.getByTestId(locators.collapsiblePanelContent)).toHaveClass('hidden')
expect(screen.getByTestId(locators.dropdownArrow)).toBeInTheDocument()
})
Expand Down
5 changes: 2 additions & 3 deletions frontend/components/collapsible-panel/collapsible-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useState } from 'react'

import { DropdownArrow } from '../icons/dropdown-arrow'
import locators from '../locators'
import { SubHeader } from '../sub-header'

export const CollapsiblePanel = ({
initiallyOpen = false,
Expand All @@ -22,9 +23,7 @@ export const CollapsiblePanel = ({
onClick={() => setIsOpen(!isOpen)}
data-testid={locators.collapsiblePanelButton}
>
<span className="text-sm uppercase" data-testid={locators.collapsiblePanelTitle}>
{title}
</span>
<SubHeader content={title} />
<DropdownArrow
className={classnames('w-3 ml-3 mb-1', {
'rotate-180': isOpen
Expand Down
6 changes: 3 additions & 3 deletions frontend/components/dapps-header/dapps-header.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ describe('WalletsHeader', () => {
expect(governButton).toHaveTextContent('Vote')
expect(governButton).toHaveAttribute('href', fairground.governance)
expect(transferButton).toHaveTextContent('Transfer')
expect(transferButton).toHaveAttribute('href', fairground.transfer)
expect(transferButton).toHaveAttribute('href', `${fairground.console}/#/portfolio/assets/transfer`)
expect(depositButton).toHaveTextContent('Deposit')
expect(depositButton).toHaveAttribute('href', fairground.deposit)
expect(depositButton).toHaveAttribute('href', `${fairground.console}/#/portfolio/assets/deposit`)
expect(withdrawButton).toHaveTextContent('Withdraw')
expect(withdrawButton).toHaveAttribute('href', fairground.withdraw)
expect(withdrawButton).toHaveAttribute('href', `${fairground.console}/#/portfolio/assets/withdraw`)
})

it('renders the correct tooltip content', async () => {
Expand Down
9 changes: 6 additions & 3 deletions frontend/components/dapps-header/dapps-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,19 @@ const DappsHeaderButton = ({

export const DappsHeader = () => {
const { network } = useNetwork()
const transferLink = `${network.console}/#/portfolio/assets/transfer`
const depositLink = `${network.console}/#/portfolio/assets/deposit`
const withdrawLink = `${network.console}/#/portfolio/assets/withdraw`
return (
<div
className="flex justify-evenly bg-vega-dark-150/25 w-full py-3 border-b border-1 border-vega-dark-150"
data-testid={locators.walletsHeader}
>
<DappsHeaderButton href={network.console} tooltipContent="Console" icon={<TradeIcon />} text="Trade" />
<DappsHeaderButton href={network.governance} tooltipContent="Governance" icon={<Tick size={24} />} text="Vote" />
<DappsHeaderButton href={network.transfer} tooltipContent="Transfer" icon={<OpenExternal />} text="Transfer" />
<DappsHeaderButton href={network.deposit} tooltipContent="Deposit" icon={<Deposit />} text="Deposit" />
<DappsHeaderButton href={network.withdraw} tooltipContent="Withdraw" icon={<Withdraw />} text="Withdraw" />
<DappsHeaderButton href={transferLink} tooltipContent="Transfer" icon={<OpenExternal />} text="Transfer" />
<DappsHeaderButton href={depositLink} tooltipContent="Deposit" icon={<Deposit />} text="Deposit" />
<DappsHeaderButton href={withdrawLink} tooltipContent="Withdraw" icon={<Withdraw />} text="Withdraw" />
</div>
)
}
1 change: 1 addition & 0 deletions frontend/components/dapps-header/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './dapps-header'
1 change: 1 addition & 0 deletions frontend/components/data-table/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './data-table'
65 changes: 65 additions & 0 deletions frontend/components/dropdown/dropdown.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { fireEvent, render, screen, waitFor } from '@testing-library/react'

import { Dropdown, DropdownProperties, locators } from './dropdown'

const defaultProps: DropdownProperties = {
trigger: <div data-testid="trigger" />,
content: () => <div data-testid="content" />,
enabled: true
}

const renderComponent = (properties: DropdownProperties = defaultProps) => {
return render(<Dropdown {...properties} />)
}

describe('DropDown', () => {
it('renders the trigger and opens content on click', async () => {
renderComponent()
fireEvent.click(screen.getByTestId(locators.dropdownTrigger))
await screen.findByTestId('content')
})

it('renders the trigger and does not open if enabled is true', async () => {
renderComponent({
...defaultProps,
enabled: false
})
fireEvent.click(screen.getByTestId('trigger'))
expect(screen.queryByTestId('content')).not.toBeInTheDocument()
})

it('closes modal when clicking trigger', async () => {
renderComponent()
fireEvent.click(screen.getByTestId(locators.dropdownTrigger))
await screen.findByTestId('content')
fireEvent.click(screen.getByTestId(locators.dropdownTrigger))
await waitFor(() => expect(screen.queryByTestId('key-list')).not.toBeInTheDocument())
})

it('closes dropdown when clicking outside', async () => {
const { container } = renderComponent()
fireEvent.click(screen.getByTestId(locators.dropdownTrigger))
await screen.findByTestId('content')
fireEvent.pointerDown(
container,
new PointerEvent('pointerdown', {
ctrlKey: false,
button: 0
})
)
await waitFor(() => expect(screen.queryByTestId('key-list')).not.toBeInTheDocument())
})

it('closes dropdown when escape key is pressed', async () => {
const { container } = renderComponent()
fireEvent.click(screen.getByTestId(locators.dropdownTrigger))
await screen.findByTestId('content')
fireEvent.keyDown(container, {
key: 'Escape',
code: 'Escape',
keyCode: 27,
charCode: 27
})
await waitFor(() => expect(screen.queryByTestId('key-list')).not.toBeInTheDocument())
})
})
Loading
Loading