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(explorer): update project and migrate to vite #3579

Merged
merged 21 commits into from
Jan 10, 2024
Merged

Conversation

shoom3301
Copy link
Collaborator

@shoom3301 shoom3301 commented Jan 8, 2024

Summary

This is the final PR in the sequence:

  1. [1] chore(explorer): setup blank react project #3577
  2. [2] feat(explorer): copy-paste files from previous repo #3578
  3. feat(explorer): update project and migrate to vite #3579

In this PR you can find many files changed, but don't worry, most of them contain only import changes and code-style fixes.

I've left several TODO: MGR comments at places where I've changed to code but haven't tested it.

Changes

  1. Updated vite to fix a bug with loading schema file for app-data.
await metadataApiSDK.getAppDataSchema(LATEST_APP_DATA_VERSION)

In the previous version of vite the code above didn't work due to some problem inside of vite.
First time I've faced this issue in Istanbul during the hackathon.

  1. Migrated favicon

  2. Set up jest

  3. Integrated loadConfig.js to vite config

  4. Moved test directory inside of src

  5. Moved src/apps/explorer to src/explorer because it was confusing typescript since we have apps directory in the root of repo

  6. Migrated react-router to the 6.x version (guide)

  7. Changed require.context to import.meta.glob since we migrated from webpack to vite

To Test

All Explorer functionalities.
Probably better to tests via #3580 to avoid double work

Copy link

vercel bot commented Jan 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
cosmos ✅ Ready (Inspect) Visit Preview Jan 10, 2024 8:43am
explorer ✅ Ready (Inspect) Visit Preview Jan 10, 2024 8:43am
swap-dev ✅ Ready (Inspect) Visit Preview Jan 10, 2024 8:43am
widget-configurator ✅ Ready (Inspect) Visit Preview Jan 10, 2024 8:43am

Copy link

socket-security bot commented Jan 8, 2024

New and updated dependencies detected. Learn more about Socket for GitHub ↗︎

Packages Version New capabilities Transitives Size Publisher
combine-reducers 1.0.0 None +0 3.34 kB wesleytodd
@types/cytoscape-popper 2.0.4 None +1 238 kB types
@types/react-copy-to-clipboard 4.3.0 None +0 3.75 kB types
cytoscape-no-overlap 1.0.1 None +3 4.7 MB martinheon
@types/flexsearch 0.7.6 None +0 15.2 kB types
@apollo/client 3.8.8 eval, network +13 6.8 MB apollo-bot
@gnosis.pm/dex-js 0.10.0 environment +1 20.9 MB alfetopito
@types/react-cytoscapejs 1.2.5 None +1 240 kB types
@types/cytoscape 3.19.16 None +0 233 kB types
@material-ui/core 4.12.4 eval, environment +18 10.9 MB eps1lon
flexsearch 0.7.41 eval, filesystem, shell +0 720 kB nextapps
console-feed 3.5.0 eval +6 1.91 MB samdd
cytoscape-klay 3.1.4 None +3 5.07 MB maxkfranz
@fortawesome/fontawesome-svg-core 6.5.1 None +1 1.18 MB robmadole
@fortawesome/react-fontawesome 0.2.0 environment +2 1.22 MB robmadole
@fortawesome/free-regular-svg-icons 6.5.1 None +1 1.47 MB robmadole
styled-theming 2.2.0 None +0 8.52 kB thejameskyle
react-copy-to-clipboard 5.1.0 None +0 40.6 kB nkbt
@fortawesome/free-solid-svg-icons 6.5.1 None +1 5.86 MB robmadole
cytoscape-popper 2.0.0 None +2 4.51 MB maxkfranz
react-cytoscapejs 1.2.1 None +2 4.54 MB maxkfranz
cytoscape-fcose 2.2.0 None +4 13.8 MB ivisatbilkent
web3modal 1.9.0 None +0 1.28 MB pedrouid
polished 4.2.2 environment +0 2.8 MB bhough
node-cache 5.1.2 None +1 72.4 kB erdii
vite-plugin-dynamic-import 1.5.0 None +0 48.1 kB caoxie
@rjsf/core 4.2.3 eval, environment +13 6.16 MB rjsf-bot
cytoscape 3.28.1 environment +1 4.47 MB maxkfranz
vite 4.4.11...5.0.11 None +42/-2 262 MB vitebot
@lingui/vite-plugin 4.3.0...4.7.0 None +51/-10 262 MB andrii.bodnar
@lingui/react 4.3.0...4.7.0 None +4/-3 143 kB andrii.bodnar
@lingui/core 4.3.0...4.7.0 None +3/-2 117 kB andrii.bodnar
@lingui/macro 4.3.0...4.7.0 None +6/-5 294 kB andrii.bodnar
@nx/vite 16.4.0...17.2.8 eval, environment +106/-16 364 MB nrwl-jason
@lingui/cli 4.3.0...4.7.0 None +7/-6 323 kB andrii.bodnar

@@ -100,6 +100,7 @@ export class Erc20ApiImpl implements Erc20Api {

public constructor(injectedDependencies: Erc20ApiDependencies) {
Object.assign(this, injectedDependencies)
this.web3 = injectedDependencies.web3
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to fix typescript error

@@ -29,3 +30,15 @@ export function useResolveEns(address: string): AddressAccount | undefined {

return addressAccount
}

async function resolveENS(name: string): Promise<string | null> {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the function from another file because here is the only place where it is used

return networkId || Network.MAINNET
}

export const NetworkUpdater: React.FC = () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just extracted the component from state/network/updater.tsx to solve circular dependency

@@ -81,7 +81,7 @@ const plurals: LocalePlural = {
export async function dynamicActivate(locale: SupportedLocale) {
i18n.loadLocaleData(locale, { plurals: plurals[locale] })
try {
const catalog = await import(`../locales/${locale}.js?lingui`)
const catalog = await import(`../locales/${locale}.po`)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only change in cowswap app related to vite update

@shoom3301 shoom3301 requested review from a team and elena-zh January 8, 2024 07:23
@shoom3301 shoom3301 self-assigned this Jan 8, 2024
@shoom3301 shoom3301 marked this pull request as ready for review January 8, 2024 07:26
Copy link
Collaborator

@alfetopito alfetopito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finished with code review, will test the app next.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably get rid of this.
Not for this PR, though.

apps/explorer/loadConfig.ts Outdated Show resolved Hide resolved
try {
order = await getOrderApi.api({ ...getOrderApi.defaultParams, networkId })
order = await getOrderApi.api({ ...getOrderApi.defaultParams, networkId } as never)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why as never?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Due to typescript error. I'm afraid of changing the logic here.
I would prefer keep it as it is + TODO to fix types in the future

apps/explorer/vite.config.ts Outdated Show resolved Hide resolved
package.json Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does CoW Swap build looks like after this?
I hope vite is smart enough to not include any of the new dependencies in the unrelated build, but I you never know.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://swap-dev-git-feat-explorer-3-cowswap.vercel.app/#/1/swap/WETH

I don't see any excessive size comparing with prod

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants