diff --git a/.github/workflows/check-lint.yml b/.github/workflows/check-lint.yml index 85095a40d5..56bd962e05 100644 --- a/.github/workflows/check-lint.yml +++ b/.github/workflows/check-lint.yml @@ -62,6 +62,8 @@ jobs: - name: Link Checker uses: lycheeverse/lychee-action@v1.5.4 with: + # Ignore the README.md file as some social sharing links are not valid + args: --verbose --no-progress --exclude-path 'README.md' './**/*.md' './**/*.html' './**/*.rst' fail: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index fd68b56a85..728a7bdcbf 100644 --- a/README.md +++ b/README.md @@ -10,120 +10,74 @@ # Webb Monorepo

- ๐Ÿš€ Decentralized interfaces into the Webb protocol ๐Ÿš€ + Decentralized interfaces into the Webb protocol

[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/webb-tools/webb-dapp/check-build.yml?branch=develop&style=flat-square)](https://github.com/webb-tools/webb-dapp/actions) [![License Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=flat-square)](https://opensource.org/license/apache2-0-php/) [![Twitter](https://img.shields.io/badge/follow-%40webbprotocol-1DA1F2?logo=twitter&style=flat-square)](https://twitter.com/webbprotocol) [![Telegram](https://img.shields.io/badge/Telegram-gray?logo=telegram)](https://t.me/webbprotocol) [![Discord](https://img.shields.io/discord/833784453251596298.svg?style=flat-square&label=Discord&logo=discord)](https://discord.gg/cv8EfJu3Tn) -

๐Ÿ“– Table of Contents

+

Table of Contents

- Table of Contents + Table of Contents
-

Getting Started ๐ŸŽ‰

+

Getting Started

-This repo is a monorepo containing decentralized interfaces into the Webb protocol! It makes use of [nx.dev](https://nx.dev/) for fast and extensible build system. The repo consists of 3 notable areas: +This is a monorepo for decentralized interfaces in the Webb protocol. It uses [nx.dev](https://nx.dev/) for fast and extensible building. The `apps` directory contains the protocol's interfaces while `libs` contains the necessary code and logic. -- [bridge-dapp:](https://github.com/webb-tools/webb-dapp/tree/develop/apps/bridge-dapp) an interface for interacting and bridging assets cross-chain using Webb's Asset Protocol. -- [stats-dapp:](https://github.com/webb-tools/webb-dapp/tree/develop/apps/stats-dapp) an interface for displaying statistics data of Webb's Tangle Network. -- [webbsite:](https://github.com/webb-tools/webb-dapp/tree/develop/apps/webbsite) an interface for the Webb ecosystem and development. -- [webb-ui-components:](https://github.com/webb-tools/webb-dapp/tree/develop/libs/webb-ui-components) a collection of reusable components for building interfaces quickly. +### Prerequisites -For additional information, please refer to the [Webb Official Documentation](https://docs.webb.tools/) ๐Ÿ“. Have feedback on how to improve the webb-dapp interface? Or have a specific question to ask? Checkout the [Webb Dapp Feedback Discussion](https://github.com/webb-tools/feedback/discussions/categories/webb-dapp-feedback) ๐Ÿ’ฌ. - -## Prerequisites - -This repository makes use of yarn, nodejs, and requires version node v18. To install node.js binaries, installers, and source tarballs, please visit https://nodejs.org/en/download/. Once node.js is installed you may proceed to install [`yarn`](https://classic.yarnpkg.com/en/docs/install): +This repository makes use of yarn, nodejs, and requires version node v18. To install node.js binaries, installers, and source tarballs, please visit https://nodejs.org/en/download/. Once node.js is installed you may proceed to install [yarn](https://classic.yarnpkg.com/en/docs/install): ```bash npm install --global yarn ``` -Great! Now your **Node** environment is ready! ๐Ÿš€๐Ÿš€ - -## Run Hubble bridge locally ๐Ÿ’ป - -Once the development environment is set up, you may proceed to install the required dependencies and run the dapp locally. - -1. Clone this repo - - ```bash - git clone git@github.com:webb-tools/webb-dapp.git && cd webb-dapp - ``` - -2. Install dependencies by `yarn` +Great! Now your **Node** environment is ready! - ```bash - yarn install - ``` +
โ†‘ Back to top โ†‘
-3. Start the bridge-dapp: +

Applications

- ```bash - yarn start:bridge - ``` +- [bridge-dapp](./apps/bridge-dapp/README.md): an interface for interacting and bridging assets cross-chain using Webb's Asset Protocol. +- [faucet](./apps/faucet/README.md): an interface for requesting cryptocurrencies (assets) on the Webb Protocol System. +- [hubble-stats](./apps/hubble-stats/README.md): an interface for displaying statistical data of the Cross-chain Bridging System. +- [stats-dapp](./apps/stats-dapp/README.md): an interface for displaying statistical data of Webb's Tangle Network (DKG system). +- [tangle-website](./apps/tangle-website/README.md): an interface for the Tangle ecosystem and development. +- [webbsite](./apps/webbsite/README.md): an interface for the Webb ecosystem and development. -Visit `http://localhost:3000/` to see the Webb Bridge Dapp UI! ๐Ÿ•ธ๏ธ ๐Ÿš€ If you would like to utilize the Hubble bridge -with a local EVM network and local relayer refer to the instructions [here](https://github.com/webb-tools/webb-dapp/tree/develop/apps/bridge-dapp#webb-hubble-bridge). +
โ†‘ Back to top โ†‘
-### Setting Up a Local EVM Network with Hubble Bridge +

Libraries

-If you want to create a local EVM network with a local relayer and Hubble bridge, we have step-by-step instructions you can follow [here](https://github.com/webb-tools/webb-dapp/tree/develop/apps/bridge-dapp#webb-hubble-bridge). Before setting up a local EVM network be sure to clear your `localStorage`. +- `abstract-api-provider`: a collection of base and abstract classes that unify the API across multiple providers. +- `api-provider-environment`: contains the React context definitions, the app event, and functions for handling interactive feedback errors for the bridge app. +- `browser-utils`: contains all the browser utility functions, such as fetch with caching, download file and string, the customized logger class, get browser platform, and the storage factory function for interacting with local storage. +- `dapp-config`: contains all configurations (chains, wallets, etc.) for the bridge dApp. +- `dapp-types`: contains all the sharable TypeScript types and interfaces across the apps. +- `icons`: contains all the sharable icons across the apps. +- `note-manager`: contains all the logic for storing note account data. +- `polkadot-api-provider`: the Substrate (or Polkadot) provider for the bridge. +- `react-hooks`: contains all the sharable hooks across the apps. +- `relayer-manager-factory`: contains all the logic for interacting with the relayer. +- `tailwind-preset`: the Webb TailwindCSS preset for all the apps. +- `web3-api-provider`: the EVM provider for the bridge. +- [webb-ui-components](./libs/webb-ui-components/README.md): a collection of reusable components for building interfaces quickly. -If you're comfortable running scripts and using a macOS environment, you can use the following scripts in the `/tools/scripts/` directory to quickly set up a local testing environment: - -- `contracts.sh`: This script compiles Webb smart contracts from [protocol-solidity](https://github.com/webb-tools/protocol-solidity), sets up an EVM localnet (e.g. Hermes, Athena, and Demeter), and populates required fixtures. You can use this script on its own. -- `relayer.sh`: This script sets up the required `.env` variables for running a [Webb relayer](https://github.com/webb-tools/relayer) for the EVM localnets, fetches the `webb-relayer` binary, and executes it. You must have an EVM localnet running to use this script. -- `bridge.sh`: This script sets up and starts the Hubble bridge at `localhost:3000`. You can use this script on its own. -- `local-bridge-network.sh`: This script runs all the above scripts for an entire local network setup. It compiles the Webb smart contracts, sets up the EVM localnet, adds the required `.env` variables, fetches the `webb-relayer` binary, executes it, and starts the local Hubble bridge at `localhost:3000`. It opens three Terminal windows and can only be run in a macOS environment. - -We now have our local environment running, next we will want to setup our MetaMask wallet to add test tokens and **reset the account** on Metamask to reset the accountโ€™s nonce and tx history. Please refer to the support article [here](https://metamask.zendesk.com/hc/en-us/articles/360015488891-How-to-reset-an-account) for instructions on how to reset a MetaMask account. - -Lastly, we will want to one of the following accounts to obtain test tokens. - -``` -// Any of these keys has 1000 ETH on each testnet -0x0000000000000000000000000000000000000000000000000000000000000001 -0x0000000000000000000000000000000000000000000000000000000000000002 -0xc0d375903fd6f6ad3edafc2c5428900c0757ce1da10e5dd864fe387b32b91d7e -``` - -If you are unfamiliar with how to import an account with MetaMask, please refer to the support article [here](https://metamask.zendesk.com/hc/en-us/articles/360015489331-How-to-import-an-account#:~:text=Click%20the%20circle%20icon%20at,key%20and%20click%20%E2%80%9CImport%E2%80%9D). - -## Run stats-dapp locally ๐Ÿ’ป - -Once the development environment is set up, you may proceed to install the required dependencies and run the dapp locally. - -1. Clone this repo - - ```bash - git clone git@github.com:webb-tools/webb-dapp.git && cd webb-dapp - ``` +
โ†‘ Back to top โ†‘
-2. Install dependencies by `yarn` - - ```bash - yarn install - ``` - -3. Start the stats-dapp: - - ```bash - yarn start:stats - ``` - -Visit `http://localhost:3000/` to see the Webb Stats UI! ๐Ÿ•ธ๏ธ ๐Ÿš€ If you would like to setup a local SubQuery backend please refer to the instructions [here](https://github.com/webb-tools/webb-subql#webb-subquery). - -

Testing ๐Ÿงช

+

Testing

The following instructions outlines how to run Webb Dapp test suite. @@ -147,15 +101,17 @@ yarn test yarn nx storybook webb-ui-components ``` -Visit `http://localhost:4400/` to see the Webb Component Library! ๐Ÿ•ธ๏ธ ๐Ÿš€ +Visit `http://localhost:4400/` to see the Webb Component Library! + +
โ†‘ Back to top โ†‘

Contributing

Interested in contributing to the Webb Dapp interface? Thank you so much for your interest! We are always appreciative for contributions from the open-source community! -If you have a contribution in mind, please check out our [Contribution Guide](./.github/CONTRIBUTING.md) for information on how to do so. We are excited for your first contribution! +If you would like to contribute, please refer to our [Contribution Guide](./.github/CONTRIBUTING.md) for instructions. We are excited for your first contribution! -### Lint before you push! ๐Ÿชฅ +### Lint before you push! Please ensure you lint and format your changes prior to opening a PR. @@ -177,8 +133,43 @@ yarn format yarn build ``` +
โ†‘ Back to top โ†‘
+

License

Licensed under Apache 2.0 license. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache 2.0 license, shall be licensed as above, without any additional terms or conditions. + +
โ†‘ Back to top โ†‘
+ +

Need help?

+ +If you need help or you want to additional information please: + +- Refer to the [Webb Official Documentation](https://docs.webb.tools/). +- If you have feedback on how to improve the Webb Dapp interface or you have a specific question? Check out the [Webb Dapp Feedback Discussion](https://github.com/webb-tools/feedback/discussions/categories/webb-dapp-feedback). +- If you found a bug please [open an issue](https://github.com/webb-tools/webb-dapp/issues/new/choose) or [join our Discord](https://discord.gg/jUDeFpggrR) server to report it. + +--- + +**Follow us at** + +[![Follow us on twitter](https://img.shields.io/twitter/follow/webbprotocol.svg?style=social)](https://twitter.com/intent/follow?screen_name=webbprotocol) +[![Follow us on LinkedIn](https://img.shields.io/badge/LinkedIn-webbprotocol-blue?style=flat&logo=linkedin&logoColor=b0c0c0&labelColor=363D44)](https://www.linkedin.com/company/webb-protocol/) + +--- + +**Share** the project link with your network on social media. + + + Share on LinkedIn + + + Shared on Twitter + + + Share on Telegram + + +
โ†‘ Back to top โ†‘
diff --git a/apps/bridge-dapp/README.md b/apps/bridge-dapp/README.md index a23d86b132..79e6269b5a 100644 --- a/apps/bridge-dapp/README.md +++ b/apps/bridge-dapp/README.md @@ -10,18 +10,18 @@ # Webb Hubble Bridge

- ๐Ÿ”ญ Private cross-chain bridge for digital assets ๐Ÿš€ + Private cross-chain bridge for digital assets

-## Run Hubble Bridge ๐Ÿ’ป +## Run Hubble Bridge Once the development environment is set up, you may proceed to install the required dependencies and run the dapp locally. 1. Clone this repo ```bash - git clone git@github.com:webb-tools/webb-dapp.git && cd webb-dapp + git clone git@github.com:webb-tools/webb-dapp.git ``` 2. Install dependencies by `yarn` @@ -36,7 +36,7 @@ Once the development environment is set up, you may proceed to install the requi yarn start:bridge ``` -Visit `http://localhost:3000/` to see the Webb Bridge Dapp UI! ๐Ÿ•ธ๏ธ ๐Ÿš€ +Visit `http://localhost:3000/` to see the Webb Bridge Dapp UI! ### Run local Webb relayer and local network alongside Hubble bridge @@ -190,4 +190,12 @@ You have now successfully setup: - local Hubble bridge - configured your MetaMask wallet for testing / development -Happy hacking! ๐Ÿš€๐Ÿ’ป +Happy hacking! + +

Need help?

+ +If you need help or you want to additional information please: + +- Refer to the [Webb Official Documentation](https://docs.webb.tools/). +- If you have feedback on how to improve the Webb Dapp interface or you have a specific question? Check out the [Webb Dapp Feedback Discussion](https://github.com/webb-tools/feedback/discussions/categories/webb-dapp-feedback). +- If you found a bug please [open an issue](https://github.com/webb-tools/webb-dapp/issues/new/choose) or [join our Discord](https://discord.gg/jUDeFpggrR) server to report it. diff --git a/apps/bridge-dapp/src/App.tsx b/apps/bridge-dapp/src/App.tsx index 379ccd00b8..f4847a08db 100644 --- a/apps/bridge-dapp/src/App.tsx +++ b/apps/bridge-dapp/src/App.tsx @@ -1,5 +1,8 @@ -import { AppEvent, WebbProvider } from '@webb-tools/api-provider-environment'; -import { RouterProvider } from '@webb-tools/react-environment'; +import { + AppEvent, + RouterProvider, + WebbProvider, +} from '@webb-tools/api-provider-environment'; import { FC } from 'react'; import { WebbUIProvider } from '@webb-tools/webb-ui-components'; diff --git a/apps/bridge-dapp/src/routes/index.tsx b/apps/bridge-dapp/src/routes/index.tsx index d271d9509b..0c71b104bb 100644 --- a/apps/bridge-dapp/src/routes/index.tsx +++ b/apps/bridge-dapp/src/routes/index.tsx @@ -1,6 +1,6 @@ +import { RouterConfigData } from '@webb-tools/api-provider-environment'; import { BareProps } from '@webb-tools/dapp-types'; import { Spinner } from '@webb-tools/icons'; -import { RouterConfigData } from '@webb-tools/react-environment'; import { FC, lazy, Suspense } from 'react'; import { Layout } from '../containers'; diff --git a/apps/faucet/.env.local.example b/apps/faucet/.env.local.example index 926b8ec265..81b224bbfc 100644 --- a/apps/faucet/.env.local.example +++ b/apps/faucet/.env.local.example @@ -1,4 +1,4 @@ -NEXT_PUBLIC_AMOUNT="10" -NEXT_PUBLIC_FAUCET_BACKEND_URL="http://127.0.0.1:8000" +NEXT_PUBLIC_AMOUNT="20" +NEXT_PUBLIC_FAUCET_BACKEND_URL="https://faucet-backend.webb.tools" NEXT_PUBLIC_TWITTER_CLIENT_ID="" TWITTER_CLIENT_SECRET="" diff --git a/apps/faucet/README.md b/apps/faucet/README.md new file mode 100644 index 0000000000..5c949c225b --- /dev/null +++ b/apps/faucet/README.md @@ -0,0 +1,67 @@ +
+ + +![Webb Logo](../../.github/assets/webb_banner_light.png#gh-light-mode-only) +![Webb Logo](../../.github/assets/webb_banner_dark.png#gh-dark-mode-only) + + +
+ +# Webb Faucet + +

+ Funding cryptocurrencies (assets) on the Webb Protocol System. +
+

+ +## Run the Faucet + +After setting up the development environment, you can proceed to run the faucet dapp locally by installing the required dependencies, copying the environment variables and running the faucet. + +1. Clone this repo + + ```bash + git clone git@github.com:webb-tools/webb-dapp.git + ``` + +2. Install dependencies by `yarn` + + ```bash + yarn install + ``` + +3. Prepare the Twitter Application for Development + +To run the faucet app locally, you need to create a new Twitter Application for development purposes. You can find the instructions for doing so [here](https://developer.twitter.com/en/docs/twitter-api/getting-started/getting-access-to-the-twitter-api). + +**Notes**: + +- For 'App permissions', select 'Read' permissions. +- For 'Type of App', select 'Native App'. +- For 'App info', fill in the 'Website URL' and 'Callback URLs' fields. Set the 'Callback URLs' field to `http://127.0.0.1:4200` and `http://localhost:4200`. + +Next, initialize the environment variables by running the following command: + +```bash + cp .env.example .env && cp apps/faucet/.env.local.example apps/faucet/.env.local +``` + +Replace the placeholder values for `NEXT_PUBLIC_TWITTER_CLIENT_ID` and `TWITTER_CLIENT_SECRET` with your Twitter Client ID and Twitter Client Secret, respectively. You can find these values in your created Twitter Application on the developer portal. Read more about this process [here](https://developer.twitter.com/en/docs/authentication/oauth-1-0a/api-key-and-secret). + +Visitย `http://localhost:4200/`ย to see the Webb Faucet UI! + +## Run with the Faucet backend + +To use the faucet backend, follow the instructions here to set it up. + +Then, update the `NEXT_PUBLIC_FAUCET_BACKEND_URL` in the `apps/faucet/.env.local` file to point to the locally running faucet backend. + +Happy hacking! + +

Need help?

+ +If you need help or you want to additional information please: + +- Refer to the [Webb Official Documentation](https://docs.webb.tools/). +- If you have feedback on how to improve the Webb Dapp interface or you have a specific question? Check out the [Webb Dapp Feedback Discussion](https://github.com/webb-tools/feedback/discussions/categories/webb-dapp-feedback). +- If you found a bug please [open an issue](https://github.com/webb-tools/webb-dapp/issues/new/choose) or [join our Discord](https://discord.gg/jUDeFpggrR) server to report it. diff --git a/apps/hubble-stats/README.md b/apps/hubble-stats/README.md new file mode 100644 index 0000000000..a7694ca244 --- /dev/null +++ b/apps/hubble-stats/README.md @@ -0,0 +1,19 @@ +
+ + +![Webb Logo](../../.github/assets/webb_banner_light.png#gh-light-mode-only) +![Webb Logo](../../.github/assets/webb_banner_dark.png#gh-dark-mode-only) + + +
+ +# Webb Hubble Bridge Statistics + +

+ An interface for displaying statistical data of the Cross-chain Bridging System. +
+

+ +## Run the Hubble Stats + +TBD diff --git a/apps/stats-dapp/README.md b/apps/stats-dapp/README.md new file mode 100644 index 0000000000..3d68149a08 --- /dev/null +++ b/apps/stats-dapp/README.md @@ -0,0 +1,49 @@ +
+ + +![Webb Logo](../../.github/assets/webb_banner_light.png#gh-light-mode-only) +![Webb Logo](../../.github/assets/webb_banner_dark.png#gh-dark-mode-only) + + +
+ +# Webb DKG Statistics + +

+ An interface for displaying statistical data of Webb's Tangle Network (DKG system). +
+

+ +## Run DKG Stats DApp + +After setting up the development environment, you can proceed to run the DKG stats dApp locally by installing the required dependencies and running the DKG stats dApp. + +1. Clone this repo + + ```bash + git clone git@github.com:webb-tools/webb-dapp.git + ``` + +2. Install dependencies by `yarn` + + ```bash + yarn install + ``` + +3. Start the dApp by the following command: + + ```bash + yarn start:stats + ``` + +Visitย `http://localhost:3001/`ย to see the Webb Stats UI! If you would like to setup a local SubQuery backend please refer to the instructionsย [here](https://github.com/webb-tools/webb-subql#webb-subquery). + +Happy hacking! + +

Need help?

+ +If you need help or you want to additional information please: + +- Refer to the [Webb Official Documentation](https://docs.webb.tools/). +- If you have feedback on how to improve the Webb Dapp interface or you have a specific question? Check out the [Webb Dapp Feedback Discussion](https://github.com/webb-tools/feedback/discussions/categories/webb-dapp-feedback). +- If you found a bug please [open an issue](https://github.com/webb-tools/webb-dapp/issues/new/choose) or [join our Discord](https://discord.gg/jUDeFpggrR) server to report it. diff --git a/apps/stats-dapp/src/App.tsx b/apps/stats-dapp/src/App.tsx index 1549f8d3f3..f2423beb5c 100644 --- a/apps/stats-dapp/src/App.tsx +++ b/apps/stats-dapp/src/App.tsx @@ -1,8 +1,7 @@ -import { RouterProvider } from '@webb-tools/react-environment'; +import * as Sentry from '@sentry/react'; +import { RouterProvider } from '@webb-tools/api-provider-environment'; import { WebbUIProvider } from '@webb-tools/webb-ui-components'; import { FC } from 'react'; -import * as Sentry from '@sentry/react'; - import { routes } from './routes'; const App: FC = () => { diff --git a/apps/stats-dapp/src/routes/index.tsx b/apps/stats-dapp/src/routes/index.tsx index bc4d59abc0..80d6aa56d3 100644 --- a/apps/stats-dapp/src/routes/index.tsx +++ b/apps/stats-dapp/src/routes/index.tsx @@ -1,40 +1,27 @@ -import { FC, lazy, Suspense, PropsWithChildren } from 'react'; - -import { Layout } from '../containers'; +import { RouterConfigData } from '@webb-tools/api-provider-environment'; import { Spinner } from '@webb-tools/icons'; -import { RouterConfigData } from '@webb-tools/react-environment'; +import { FC, PropsWithChildren, Suspense, lazy } from 'react'; +import { Layout } from '../containers'; -const PageAuthorities = lazy( - () => import('@webb-tools/stats-dapp/pages/Authorities') -); +const PageAuthorities = lazy(() => import('../pages/Authorities')); const PageAuthorityDetailDrawer = lazy( - () => import('@webb-tools/stats-dapp/pages/AuthorityDetailDrawer') -); -const PageAuthorityDetail = lazy( - () => import('@webb-tools/stats-dapp/pages/AuthorityDetailPage') + () => import('../pages/AuthorityDetailDrawer') ); +const PageAuthorityDetail = lazy(() => import('../pages/AuthorityDetailPage')); const PageAuthoritiesHistory = lazy( - () => import('@webb-tools/stats-dapp/pages/AuthoritiesHistory') + () => import('../pages/AuthoritiesHistory') ); -const PageKeys = lazy(() => import('@webb-tools/stats-dapp/pages/Keys')); -const PageKeyDetailDrawer = lazy( - () => import('@webb-tools/stats-dapp/pages/KeyDetailDrawer') -); -const PageKeyDetail = lazy( - () => import('@webb-tools/stats-dapp/pages/KeyDetailPage') -); +const PageKeys = lazy(() => import('../pages/Keys')); +const PageKeyDetailDrawer = lazy(() => import('../pages/KeyDetailDrawer')); +const PageKeyDetail = lazy(() => import('../pages/KeyDetailPage')); -const PageProposals = lazy( - () => import('@webb-tools/stats-dapp/pages/Proposals') -); +const PageProposals = lazy(() => import('../pages/Proposals')); const PageProposalDetailDrawer = lazy( - () => import('@webb-tools/stats-dapp/pages/ProposalDetailDrawer') -); -const PageProposalDetail = lazy( - () => import('@webb-tools/stats-dapp/pages/ProposalDetailPage') + () => import('../pages/ProposalDetailDrawer') ); +const PageProposalDetail = lazy(() => import('../pages/ProposalDetailPage')); const CSuspense: FC = ({ children }) => { return ( diff --git a/apps/tangle-website/README.md b/apps/tangle-website/README.md new file mode 100644 index 0000000000..a2f0800e40 --- /dev/null +++ b/apps/tangle-website/README.md @@ -0,0 +1,55 @@ +
+ + +![Webb Logo](../../.github/assets/webb_banner_light.png#gh-light-mode-only) +![Webb Logo](../../.github/assets/webb_banner_dark.png#gh-dark-mode-only) + + +
+ +# Webb Tangle Website + +

+ An interface for the Tangle ecosystem and development. +
+

+ +## Run Tangle Website + +After setting up the development environment, you can proceed to run the Tangle website locally by installing the required dependencies and running the Tangle website. + +1. Clone this repo + + ```bash + git clone git@github.com:webb-tools/webb-dapp.git + ``` + +2. Install dependencies by `yarn` + + ```bash + yarn install + ``` + +3. Copy the environment variables + + ```bash + cp .env.example .env + ``` + +4. Start the dApp by the following command: + + ```bash + yarn start:tangle-website + ``` + +Visitย `http://localhost:4200/`ย to see the Webb Tangle Website! + +Happy hacking! + +

Need help?

+ +If you need help or you want to additional information please: + +- Refer to the [Webb Official Documentation](https://docs.webb.tools/). +- If you have feedback on how to improve the Webb Dapp interface or you have a specific question? Check out the [Webb Dapp Feedback Discussion](https://github.com/webb-tools/feedback/discussions/categories/webb-dapp-feedback). +- If you found a bug please [open an issue](https://github.com/webb-tools/webb-dapp/issues/new/choose) or [join our Discord](https://discord.gg/jUDeFpggrR) server to report it. diff --git a/apps/webbsite/README.md b/apps/webbsite/README.md new file mode 100644 index 0000000000..a0f5dbf72a --- /dev/null +++ b/apps/webbsite/README.md @@ -0,0 +1,55 @@ +
+ + +![Webb Logo](../../.github/assets/webb_banner_light.png#gh-light-mode-only) +![Webb Logo](../../.github/assets/webb_banner_dark.png#gh-dark-mode-only) + + +
+ +# Webbsite + +

+ An interface for the Webb ecosystem and development. +
+

+ +## Run Webbsite + +After setting up the development environment, you can proceed to run the Tangle website locally by installing the required dependencies and running the Webb website. + +1. Clone this repo + + ```bash + git clone git@github.com:webb-tools/webb-dapp.git + ``` + +2. Install dependencies by `yarn` + + ```bash + yarn install + ``` + +3. Copy the environment variables + + ```bash + cp .env.example .env + ``` + +4. Start the dApp by the following command: + + ```bash + yarn start:webbsite + ``` + +Visitย `http://localhost:4200/`ย to see the Webbsite UI! + +Happy hacking! + +

Need help?

+ +If you need help or you want to additional information please: + +- Refer to the [Webb Official Documentation](https://docs.webb.tools/). +- If you have feedback on how to improve the Webb Dapp interface or you have a specific question? Check out the [Webb Dapp Feedback Discussion](https://github.com/webb-tools/feedback/discussions/categories/webb-dapp-feedback). +- If you found a bug please [open an issue](https://github.com/webb-tools/webb-dapp/issues/new/choose) or [join our Discord](https://discord.gg/jUDeFpggrR) server to report it. diff --git a/libs/abstract-api-provider/src/relayer/webb-relayer-manager.ts b/libs/abstract-api-provider/src/relayer/webb-relayer-manager.ts index 0574f5b21d..d1617e284d 100644 --- a/libs/abstract-api-provider/src/relayer/webb-relayer-manager.ts +++ b/libs/abstract-api-provider/src/relayer/webb-relayer-manager.ts @@ -7,7 +7,7 @@ import { BehaviorSubject, Observable, Subject } from 'rxjs'; import { ApiPromise } from '@polkadot/api'; import { VAnchor } from '@webb-tools/anchors'; import { BridgeStorage, LoggerService } from '@webb-tools/browser-utils'; -import { Storage } from '@webb-tools/storage'; +import Storage from '@webb-tools/dapp-types/Storage'; import { NewNotesTxResult, Transaction, diff --git a/libs/abstract-api-provider/src/webb-provider.interface.ts b/libs/abstract-api-provider/src/webb-provider.interface.ts index 42213be2c4..e322492377 100644 --- a/libs/abstract-api-provider/src/webb-provider.interface.ts +++ b/libs/abstract-api-provider/src/webb-provider.interface.ts @@ -13,8 +13,8 @@ import { BehaviorSubject, Observable } from 'rxjs'; import { VAnchor } from '@webb-tools/anchors'; import { BridgeStorage } from '@webb-tools/browser-utils'; +import Storage from '@webb-tools/dapp-types/Storage'; import { Utxo, UtxoGenInput } from '@webb-tools/sdk-core'; -import { Storage } from '@webb-tools/storage'; import { AccountsAdapter } from './account/Accounts.adapter'; import { ChainQuery } from './chain-query'; import { ContributePayload, Crowdloan, CrowdloanEvent } from './crowdloan'; diff --git a/libs/react-environment/src/RouterProvider.tsx b/libs/api-provider-environment/src/RouterProvider.tsx similarity index 100% rename from libs/react-environment/src/RouterProvider.tsx rename to libs/api-provider-environment/src/RouterProvider.tsx diff --git a/libs/api-provider-environment/src/WebbProvider.tsx b/libs/api-provider-environment/src/WebbProvider.tsx index c589a51663..bfa2d3c18d 100644 --- a/libs/api-provider-environment/src/WebbProvider.tsx +++ b/libs/api-provider-environment/src/WebbProvider.tsx @@ -36,8 +36,6 @@ import { import { Spinner } from '@webb-tools/icons'; import { NoteManager } from '@webb-tools/note-manager'; import { WebbPolkadot } from '@webb-tools/polkadot-api-provider'; -import { SettingProvider } from '@webb-tools/react-environment'; -import { StoreProvider } from '@webb-tools/react-environment/store'; import { getRelayerManagerFactory } from '@webb-tools/relayer-manager-factory'; import { ChainType, @@ -59,6 +57,7 @@ import { insufficientApiInterface } from './error/interactive-errors/insufficien import { useTxApiQueue } from './transaction'; import { WebbContext } from './webb-context'; import onChainDataJson from './generated/on-chain-config.json'; +import { StoreProvider } from './store'; interface WebbProviderProps extends BareProps { appEvent: TAppEvent; @@ -490,7 +489,7 @@ export const WebbProvider: FC = ({ children, appEvent }) => { () => new Worker( new URL( - '@webb-tools/react-environment/arkworks-proving-manager.worker', + './arkworks-proving-manager.worker', import.meta.url ) ), @@ -583,10 +582,7 @@ export const WebbProvider: FC = ({ children, appEvent }) => { notificationHandler, () => new Worker( - new URL( - '@webb-tools/react-environment/circom-proving-manager.worker', - import.meta.url - ) + new URL('./circom-proving-manager.worker', import.meta.url) ) ); @@ -961,9 +957,7 @@ export const WebbProvider: FC = ({ children, appEvent }) => { txQueue, }} > - - {children} - + {children} ); }; diff --git a/libs/react-environment/src/arkworks-proving-manager.worker.ts b/libs/api-provider-environment/src/arkworks-proving-manager.worker.ts similarity index 100% rename from libs/react-environment/src/arkworks-proving-manager.worker.ts rename to libs/api-provider-environment/src/arkworks-proving-manager.worker.ts diff --git a/libs/react-environment/src/circom-proving-manager.worker.ts b/libs/api-provider-environment/src/circom-proving-manager.worker.ts similarity index 100% rename from libs/react-environment/src/circom-proving-manager.worker.ts rename to libs/api-provider-environment/src/circom-proving-manager.worker.ts diff --git a/libs/api-provider-environment/src/index.ts b/libs/api-provider-environment/src/index.ts index 063f1585a7..eb6fed7013 100644 --- a/libs/api-provider-environment/src/index.ts +++ b/libs/api-provider-environment/src/index.ts @@ -1,4 +1,8 @@ +export * from './RouterProvider'; export * from './WebbProvider'; export * from './app-event'; +export * from './constants'; export * from './error'; +export * from './store'; +export * from './transaction'; export * from './webb-context'; diff --git a/libs/react-environment/src/store/createStore.ts b/libs/api-provider-environment/src/store/createStore.ts similarity index 100% rename from libs/react-environment/src/store/createStore.ts rename to libs/api-provider-environment/src/store/createStore.ts diff --git a/libs/react-environment/src/store/index.tsx b/libs/api-provider-environment/src/store/index.tsx similarity index 100% rename from libs/react-environment/src/store/index.tsx rename to libs/api-provider-environment/src/store/index.tsx diff --git a/libs/react-environment/src/store/modules/api-query.ts b/libs/api-provider-environment/src/store/modules/api-query.ts similarity index 100% rename from libs/react-environment/src/store/modules/api-query.ts rename to libs/api-provider-environment/src/store/modules/api-query.ts diff --git a/libs/react-environment/src/store/modules/ui.ts b/libs/api-provider-environment/src/store/modules/ui.ts similarity index 98% rename from libs/react-environment/src/store/modules/ui.ts rename to libs/api-provider-environment/src/store/modules/ui.ts index 5e1dc23254..0e2a2453c5 100644 --- a/libs/react-environment/src/store/modules/ui.ts +++ b/libs/api-provider-environment/src/store/modules/ui.ts @@ -64,8 +64,6 @@ export interface UseUIConfigReturnType extends UIData { setSubMenu: (menu: SubMenu | null) => void; } -const storage = Storage; - export const useUIConfig = (): UseUIConfigReturnType => { const [state, dispatch] = useReducer(reducer, initState); diff --git a/libs/react-environment/src/store/useMemorized.ts b/libs/api-provider-environment/src/store/useMemorized.ts similarity index 100% rename from libs/react-environment/src/store/useMemorized.ts rename to libs/api-provider-environment/src/store/useMemorized.ts diff --git a/libs/api-provider-environment/tsconfig.lib.json b/libs/api-provider-environment/tsconfig.lib.json index 8b99997ab5..f33aa5dfa4 100644 --- a/libs/api-provider-environment/tsconfig.lib.json +++ b/libs/api-provider-environment/tsconfig.lib.json @@ -5,6 +5,6 @@ "declaration": true, "types": ["node"] }, - "include": ["**/*.ts", "../../types/**/*.d.ts"], + "include": ["**/*.ts", "**/*.tsx", "../../types/**/*.d.ts"], "exclude": ["jest.config.ts", "**/*.spec.ts", "**/*.test.ts"] } diff --git a/libs/browser-utils/src/download/cached-fetch.ts b/libs/browser-utils/src/download/cachedFetch.ts similarity index 96% rename from libs/browser-utils/src/download/cached-fetch.ts rename to libs/browser-utils/src/download/cachedFetch.ts index 055d3a9fad..4b65d44682 100644 --- a/libs/browser-utils/src/download/cached-fetch.ts +++ b/libs/browser-utils/src/download/cachedFetch.ts @@ -3,7 +3,7 @@ import { LoggerService } from '../logger'; const logger = LoggerService.get('cached fetch'); -export async function cachedFetch( +async function cachedFetch( ...params: Parameters ): Promise { const fixturesCache = await caches.open('fixtures'); @@ -46,3 +46,5 @@ export async function cachedFetch( throw new Error('network error'); } + +export default cachedFetch; diff --git a/libs/browser-utils/src/download/download-blob.ts b/libs/browser-utils/src/download/downloadBlob.ts similarity index 77% rename from libs/browser-utils/src/download/download-blob.ts rename to libs/browser-utils/src/download/downloadBlob.ts index 883e6601fa..a84e731b8e 100644 --- a/libs/browser-utils/src/download/download-blob.ts +++ b/libs/browser-utils/src/download/downloadBlob.ts @@ -1,4 +1,4 @@ -export function downloadBlob(blob: Blob, fileType: string, fileName: string) { +function downloadBlob(blob: Blob, fileType: string, fileName: string) { const a = document.createElement('a'); a.download = fileName; a.href = URL.createObjectURL(blob); @@ -11,3 +11,5 @@ export function downloadBlob(blob: Blob, fileType: string, fileName: string) { URL.revokeObjectURL(a.href); }, 1500); } + +export default downloadBlob; diff --git a/libs/browser-utils/src/download/download-string.ts b/libs/browser-utils/src/download/downloadString.ts similarity index 52% rename from libs/browser-utils/src/download/download-string.ts rename to libs/browser-utils/src/download/downloadString.ts index 9e53196eac..06e8909478 100644 --- a/libs/browser-utils/src/download/download-string.ts +++ b/libs/browser-utils/src/download/downloadString.ts @@ -1,7 +1,7 @@ -import { downloadBlob } from './download-blob'; -import { stringIntoBlob } from './string-into-blob'; +import downloadBlob from './downloadBlob'; +import stringIntoBlob from './stringIntoBlob'; -export function downloadString( +function downloadString( text: string, fileName: string, fileType = 'plan/text' @@ -9,3 +9,5 @@ export function downloadString( const textBlob = stringIntoBlob(text, fileType); downloadBlob(textBlob, fileType, fileName); } + +export default downloadString; diff --git a/libs/browser-utils/src/download/index.ts b/libs/browser-utils/src/download/index.ts index 97ee7a3512..891bebbfbf 100644 --- a/libs/browser-utils/src/download/index.ts +++ b/libs/browser-utils/src/download/index.ts @@ -1,4 +1,4 @@ -export * from './download-string'; -export * from './download-blob'; -export * from './string-into-blob'; -export * from './cached-fetch'; +export { default as cachedFetch } from './cachedFetch'; +export { default as downloadBlob } from './downloadBlob'; +export { default as downloadString } from './downloadString'; +export { default as stringIntoBlob } from './stringIntoBlob'; diff --git a/libs/browser-utils/src/download/string-into-blob.ts b/libs/browser-utils/src/download/string-into-blob.ts deleted file mode 100644 index 687e439acf..0000000000 --- a/libs/browser-utils/src/download/string-into-blob.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function stringIntoBlob(text: string, fileType = 'plan/text'): Blob { - return new Blob([text], { type: fileType }); -} diff --git a/libs/browser-utils/src/download/stringIntoBlob.ts b/libs/browser-utils/src/download/stringIntoBlob.ts new file mode 100644 index 0000000000..c3db606416 --- /dev/null +++ b/libs/browser-utils/src/download/stringIntoBlob.ts @@ -0,0 +1,5 @@ +function stringIntoBlob(text: string, fileType = 'plan/text'): Blob { + return new Blob([text], { type: fileType }); +} + +export default stringIntoBlob; diff --git a/libs/browser-utils/src/promise-utils.ts b/libs/browser-utils/src/executorWithTimeout.ts similarity index 91% rename from libs/browser-utils/src/promise-utils.ts rename to libs/browser-utils/src/executorWithTimeout.ts index 5a6af21dd5..c1e5c73399 100644 --- a/libs/browser-utils/src/promise-utils.ts +++ b/libs/browser-utils/src/executorWithTimeout.ts @@ -5,7 +5,7 @@ * @returns A promise that resolves to the result of the original promise * or rejects after the timeout */ -export const executorWithTimeout = ( +const executorWithTimeout = ( promise: Promise, timeout = 5000 ): Promise => { @@ -25,3 +25,5 @@ export const executorWithTimeout = ( }); }); }; + +export default executorWithTimeout; diff --git a/libs/browser-utils/src/fetchFixtures/fetchVAnchorKeyFromAws.ts b/libs/browser-utils/src/fetchFixtures/fetchVAnchorKeyFromAws.ts new file mode 100644 index 0000000000..468e2c44d5 --- /dev/null +++ b/libs/browser-utils/src/fetchFixtures/fetchVAnchorKeyFromAws.ts @@ -0,0 +1,75 @@ +import { withLocalFixtures } from '@webb-tools/dapp-types/appMode'; +import { cachedFetch } from '../download'; +import getCachedFixtureURI from './getCachedFixtureURI'; + +const fetchVAnchorKeyFromAws = async ( + maxEdges: number, + isSmall?: boolean, + isSubstrate?: boolean, + abortSignal?: AbortSignal +) => { + let filePath: string; + let cachedURI: string; + + const filePathPrefix = isSubstrate ? 'substrate/vanchor/bn254/x5' : ''; + const filePathSuffix = isSubstrate + ? 'proving_key_uncompressed.bin' + : 'circuit_final.zkey'; + + switch (maxEdges) { + case 1: + if (isSmall) { + filePath = isSubstrate ? '2-2-2' : 'vanchor_2/2'; + cachedURI = getCachedFixtureURI(filePath); + } else { + filePath = isSubstrate ? '2-16-2' : 'vanchor_16/2'; + cachedURI = getCachedFixtureURI(filePath); + } + + break; + case 7: + if (isSmall) { + filePath = isSubstrate ? '32-2-2' : 'vanchor_2/8'; + cachedURI = getCachedFixtureURI(filePath); + } else { + filePath = isSubstrate ? '32-16-2' : 'vanchor_16/8'; + cachedURI = getCachedFixtureURI(filePath); + } + + break; + default: + if (isSmall) { + filePath = isSubstrate ? '2-2-2' : 'vanchor_2/2'; + cachedURI = getCachedFixtureURI(filePath); + } else { + filePath = isSubstrate ? '2-16-2' : 'vanchor_16/2'; + cachedURI = getCachedFixtureURI(filePath); + } + + break; + } + + let deployment = process.env['DEPLOYMENT']; + if (!deployment) { + deployment = 'develop'; + } + + try { + const fullFilePath = `${ + filePathPrefix ? `${filePathPrefix}/` : '' + }${filePath}/${filePathSuffix}`; + + const url = withLocalFixtures() + ? cachedURI + : `https://dapp-fixtures.s3.amazonaws.com/${deployment}/${fullFilePath}`; + + const key = await cachedFetch(url, { signal: abortSignal }); + + return key; + } catch (e) { + console.log('error when fetching circuit key from aws: ', e); + throw e; + } +}; + +export default fetchVAnchorKeyFromAws; diff --git a/libs/browser-utils/src/fetchFixtures/fetchVAnchorWasmFromAws.ts b/libs/browser-utils/src/fetchFixtures/fetchVAnchorWasmFromAws.ts new file mode 100644 index 0000000000..76cd24acef --- /dev/null +++ b/libs/browser-utils/src/fetchFixtures/fetchVAnchorWasmFromAws.ts @@ -0,0 +1,67 @@ +import { withLocalFixtures } from '@webb-tools/dapp-types/appMode'; +import { cachedFetch } from '../download'; +import getCachedFixtureURI from './getCachedFixtureURI'; + +const fetchVAnchorWasmFromAws = async ( + maxEdges: number, + isSmall?: boolean, + abortSignal?: AbortSignal +) => { + let filePath: string; + let cachedURI: string; + + switch (maxEdges) { + case 1: + if (isSmall) { + filePath = 'vanchor_2/2/poseidon_vanchor_2_2.wasm'; + cachedURI = getCachedFixtureURI(filePath); + } else { + filePath = 'vanchor_16/2/poseidon_vanchor_16_2.wasm'; + cachedURI = getCachedFixtureURI(filePath); + } + + break; + case 7: + if (isSmall) { + filePath = 'vanchor_2/8/poseidon_vanchor_2_8.wasm'; + cachedURI = getCachedFixtureURI(filePath); + } else { + filePath = 'vanchor_16/8/poseidon_vanchor_16_8.wasm'; + cachedURI = getCachedFixtureURI(filePath); + } + + break; + default: + if (isSmall) { + filePath = 'vanchor_2/2/poseidon_vanchor_2_2.wasm'; + cachedURI = getCachedFixtureURI(filePath); + } else { + filePath = 'vanchor_16/2/poseidon_vanchor_16_2.wasm'; + cachedURI = getCachedFixtureURI(filePath); + } + + break; + } + + let deployment = process.env['DEPLOYMENT']; + if (!deployment) { + deployment = 'develop'; + } + + try { + const url = withLocalFixtures() + ? cachedURI + : `https://dapp-fixtures.s3.amazonaws.com/${deployment}/${filePath}`; + + const wasm = await cachedFetch(url, { + signal: abortSignal, + }); + + return wasm; + } catch (e) { + console.log('error when fetching wasm from aws: ', e); + throw e; + } +}; + +export default fetchVAnchorWasmFromAws; diff --git a/libs/browser-utils/src/fetchFixtures/getCachedFixtureURI.ts b/libs/browser-utils/src/fetchFixtures/getCachedFixtureURI.ts new file mode 100644 index 0000000000..150a9b18fc --- /dev/null +++ b/libs/browser-utils/src/fetchFixtures/getCachedFixtureURI.ts @@ -0,0 +1,8 @@ +/** + * Get the URI for a cached fixture. + */ +function getCachedFixtureURI(fileName: string) { + return `/solidity-fixtures/solidity-fixtures/${fileName}`; +} + +export default getCachedFixtureURI; diff --git a/libs/browser-utils/src/fetchFixtures/index.ts b/libs/browser-utils/src/fetchFixtures/index.ts new file mode 100644 index 0000000000..8db3a7f7d3 --- /dev/null +++ b/libs/browser-utils/src/fetchFixtures/index.ts @@ -0,0 +1,3 @@ +export { default as fetchVAnchorKeyFromAws } from './fetchVAnchorKeyFromAws'; +export { default as fetchVAnchorWasmFromAws } from './fetchVAnchorWasmFromAws'; +export { default as getCachedFixtureURI } from './getCachedFixtureURI'; diff --git a/libs/browser-utils/src/index.ts b/libs/browser-utils/src/index.ts index 7d00f0ed4c..49fcfd2ba6 100644 --- a/libs/browser-utils/src/index.ts +++ b/libs/browser-utils/src/index.ts @@ -1,6 +1,9 @@ export * from './download'; +export * from './executorWithTimeout'; +export { default as executorWithTimeout } from './executorWithTimeout'; +export * from './fetchFixtures'; +export * from './logger'; export * from './platform'; -export * from './retry-promise'; +export * from './retryPromise'; +export { default as retryPromise } from './retryPromise'; export * from './storage'; -export * from './logger'; -export * from './promise-utils'; diff --git a/libs/browser-utils/src/logger/logger-service.ts b/libs/browser-utils/src/logger/LoggerService.ts similarity index 98% rename from libs/browser-utils/src/logger/logger-service.ts rename to libs/browser-utils/src/logger/LoggerService.ts index dcdf1d9602..818e66b622 100644 --- a/libs/browser-utils/src/logger/logger-service.ts +++ b/libs/browser-utils/src/logger/LoggerService.ts @@ -60,7 +60,7 @@ export enum LogLevel { type LoggersMaps = Record; type LoggerFn = (...message: any[]) => void; -export class LoggerService { +class LoggerService { public static readonly eventBus = new LoggerEvent(); private static _loggers: LoggersMaps = {}; public static _enabled = true; @@ -210,3 +210,5 @@ export class LoggerService { ) as LoggerFn; }.call(this); } + +export default LoggerService; diff --git a/libs/browser-utils/src/logger/index.ts b/libs/browser-utils/src/logger/index.ts index 2ab0fcabbd..ff17eea334 100644 --- a/libs/browser-utils/src/logger/index.ts +++ b/libs/browser-utils/src/logger/index.ts @@ -1 +1,2 @@ -export * from './logger-service'; +export * from './LoggerService'; +export { default as LoggerService } from './LoggerService'; diff --git a/libs/browser-utils/src/platform/get-platform-metadata.ts b/libs/browser-utils/src/platform/getPlatformMetaData.ts similarity index 87% rename from libs/browser-utils/src/platform/get-platform-metadata.ts rename to libs/browser-utils/src/platform/getPlatformMetaData.ts index 816e793991..9cdcff8e80 100644 --- a/libs/browser-utils/src/platform/get-platform-metadata.ts +++ b/libs/browser-utils/src/platform/getPlatformMetaData.ts @@ -10,7 +10,7 @@ type PlatformMetaData = { name: string; storeName: string; }; -export const getPlatformMetaData = (): PlatformMetaData => { +const getPlatformMetaData = (): PlatformMetaData => { const browser = detect(); const name = browser?.name; @@ -32,3 +32,5 @@ export const getPlatformMetaData = (): PlatformMetaData => { throw new Error('unsupported platform'); } }; + +export default getPlatformMetaData; diff --git a/libs/browser-utils/src/platform/index.ts b/libs/browser-utils/src/platform/index.ts index 287f4a1586..2b497eccc4 100644 --- a/libs/browser-utils/src/platform/index.ts +++ b/libs/browser-utils/src/platform/index.ts @@ -1 +1,2 @@ -export * from './get-platform-metadata'; +export * from './getPlatformMetaData'; +export { default as getPlatformMetaData } from './getPlatformMetaData'; diff --git a/libs/browser-utils/src/retry-promise.ts b/libs/browser-utils/src/retryPromise.ts similarity index 88% rename from libs/browser-utils/src/retry-promise.ts rename to libs/browser-utils/src/retryPromise.ts index 2e58571481..8d5840360d 100644 --- a/libs/browser-utils/src/retry-promise.ts +++ b/libs/browser-utils/src/retryPromise.ts @@ -4,7 +4,7 @@ export const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); -export async function retryPromise Promise>( +async function retryPromise Promise>( executor: T, maxRetries = 20, sleepTime = 0, @@ -31,3 +31,5 @@ export async function retryPromise Promise>( } throw new Error('Max retries reached'); } + +export default retryPromise; diff --git a/libs/browser-utils/src/storage.ts b/libs/browser-utils/src/storage.ts index 4b3f6a950c..e076940bd9 100644 --- a/libs/browser-utils/src/storage.ts +++ b/libs/browser-utils/src/storage.ts @@ -1,7 +1,7 @@ // Copyright 2022 @webb-tools/ // SPDX-License-Identifier: Apache-2.0 -import { Storage } from '@webb-tools/storage'; +import Storage from '@webb-tools/dapp-types/Storage'; /// The `BridgeStorage` is used to store the leaves of the merkle tree /// of the underlying VAnchor contract. The key is the resource id diff --git a/libs/dapp-config/src/on-chain-config/evm/on-chain-config.ts b/libs/dapp-config/src/on-chain-config/evm/on-chain-config.ts index 9fb9be9e33..093a17df0d 100644 --- a/libs/dapp-config/src/on-chain-config/evm/on-chain-config.ts +++ b/libs/dapp-config/src/on-chain-config/evm/on-chain-config.ts @@ -4,7 +4,7 @@ import { FungibleTokenWrapper__factory, VAnchor__factory, } from '@webb-tools/contracts'; -import { EVMChainId, zeroAddress } from '@webb-tools/dapp-types'; +import { zeroAddress } from '@webb-tools/dapp-types'; import { ChainType, parseTypedChainId } from '@webb-tools/sdk-core'; import { providers } from 'ethers'; diff --git a/libs/storage/src/storage.ts b/libs/dapp-types/src/Storage.ts similarity index 96% rename from libs/storage/src/storage.ts rename to libs/dapp-types/src/Storage.ts index 142ef5e2a1..5f409d4215 100644 --- a/libs/storage/src/storage.ts +++ b/libs/dapp-types/src/Storage.ts @@ -11,7 +11,7 @@ export interface StorageHandler { commit(key: string, data: T): Promise; } -export class Storage extends EventBus<{ +class Storage extends EventBus<{ update: Store; }> { static instances = new Map>(); @@ -86,3 +86,5 @@ export class Storage extends EventBus<{ this.emit('update', this.data); } } + +export default Storage; diff --git a/libs/react-environment/src/app-mode.ts b/libs/dapp-types/src/appMode.ts similarity index 100% rename from libs/react-environment/src/app-mode.ts rename to libs/dapp-types/src/appMode.ts diff --git a/libs/dapp-types/src/index.ts b/libs/dapp-types/src/index.ts index 4b7d0d9020..be53835738 100644 --- a/libs/dapp-types/src/index.ts +++ b/libs/dapp-types/src/index.ts @@ -5,9 +5,12 @@ export * from './ChainId'; export * from './Currency'; export * from './InteractiveFeedback'; export * from './Props'; -export * from './utils'; +export * from './Storage'; +export { default as Storagge } from './Storage'; export * from './WalletId'; export * from './WebbError'; +export * from './appMode'; +export * from './utils'; export const zeroAddress = '0x0000000000000000000000000000000000000000'; export const ZERO = 'ZERO'; diff --git a/libs/fixtures-deployments/.babelrc b/libs/fixtures-deployments/.babelrc deleted file mode 100644 index fd4cbcdef1..0000000000 --- a/libs/fixtures-deployments/.babelrc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "presets": [ - [ - "@nx/js/babel", - { - "useBuiltIns": "usage" - } - ] - ] -} diff --git a/libs/fixtures-deployments/.eslintrc.json b/libs/fixtures-deployments/.eslintrc.json deleted file mode 100644 index 9d9c0db55b..0000000000 --- a/libs/fixtures-deployments/.eslintrc.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "extends": ["../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} - }, - { - "files": ["*.ts", "*.tsx"], - "rules": {} - }, - { - "files": ["*.js", "*.jsx"], - "rules": {} - } - ] -} diff --git a/libs/fixtures-deployments/README.md b/libs/fixtures-deployments/README.md deleted file mode 100644 index 680b6ceab8..0000000000 --- a/libs/fixtures-deployments/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# fixtures-deployments - -This library was generated with [Nx](https://nx.dev). - -## Running unit tests - -Run `nx test fixtures-deployments` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/fixtures-deployments/jest.config.ts b/libs/fixtures-deployments/jest.config.ts deleted file mode 100644 index c851b34741..0000000000 --- a/libs/fixtures-deployments/jest.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* eslint-disable */ -export default { - displayName: 'fixtures-deployments', - preset: '../../jest.preset.js', - globals: { - 'ts-jest': { - tsconfig: '/tsconfig.spec.json', - }, - }, - transform: { - '^.+\\.[tj]s$': 'ts-jest', - }, - moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../coverage/libs/fixtures-deployments', -}; diff --git a/libs/fixtures-deployments/package.json b/libs/fixtures-deployments/package.json deleted file mode 100644 index 1536297e8b..0000000000 --- a/libs/fixtures-deployments/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "@webb-tools/fixtures-deployments", - "version": "0.0.1", - "main": "./src/index.js" -} diff --git a/libs/fixtures-deployments/project.json b/libs/fixtures-deployments/project.json deleted file mode 100644 index 386f804de4..0000000000 --- a/libs/fixtures-deployments/project.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "fixtures-deployments", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "libs/fixtures-deployments/src", - "projectType": "library", - "targets": { - "build": { - "executor": "@nx/js:tsc", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/libs/fixtures-deployments", - "main": "libs/fixtures-deployments/src/index.ts", - "tsConfig": "libs/fixtures-deployments/tsconfig.lib.json", - "assets": ["libs/fixtures-deployments/*.md"] - } - }, - "lint": { - "executor": "@nx/linter:eslint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["libs/fixtures-deployments/**/*.ts"] - } - }, - "test": { - "executor": "@nx/jest:jest", - "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], - "options": { - "jestConfig": "libs/fixtures-deployments/jest.config.ts", - "passWithNoTests": true - } - } - }, - "tags": [] -} diff --git a/libs/fixtures-deployments/src/evm/index.ts b/libs/fixtures-deployments/src/evm/index.ts deleted file mode 100644 index 9663bb107c..0000000000 --- a/libs/fixtures-deployments/src/evm/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2022 @webb-tools/ -// SPDX-License-Identifier: Apache-2.0 - -export * from './vanchor'; diff --git a/libs/fixtures-deployments/src/evm/vanchor.ts b/libs/fixtures-deployments/src/evm/vanchor.ts deleted file mode 100644 index 423417c26c..0000000000 --- a/libs/fixtures-deployments/src/evm/vanchor.ts +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright 2022 @webb-tools/ -// SPDX-License-Identifier: Apache-2.0 - -import { withLocalFixtures } from '@webb-tools/react-environment/app-mode'; - -import { getCachedFixtureURI } from '..'; -import { cachedFetch } from '@webb-tools/browser-utils'; - -export const fetchVAnchorKeyFromAws = async ( - maxEdges: number, - isSmall?: boolean, - isSubstrate?: boolean, - abortSignal?: AbortSignal -) => { - let filePath: string; - let cachedURI: string; - - const filePathPrefix = isSubstrate ? 'substrate/vanchor/bn254/x5' : ''; - const filePathSuffix = isSubstrate - ? 'proving_key_uncompressed.bin' - : 'circuit_final.zkey'; - - switch (maxEdges) { - case 1: - if (isSmall) { - filePath = isSubstrate ? '2-2-2' : 'vanchor_2/2'; - cachedURI = getCachedFixtureURI(filePath); - } else { - filePath = isSubstrate ? '2-16-2' : 'vanchor_16/2'; - cachedURI = getCachedFixtureURI(filePath); - } - - break; - case 7: - if (isSmall) { - filePath = isSubstrate ? '32-2-2' : 'vanchor_2/8'; - cachedURI = getCachedFixtureURI(filePath); - } else { - filePath = isSubstrate ? '32-16-2' : 'vanchor_16/8'; - cachedURI = getCachedFixtureURI(filePath); - } - - break; - default: - if (isSmall) { - filePath = isSubstrate ? '2-2-2' : 'vanchor_2/2'; - cachedURI = getCachedFixtureURI(filePath); - } else { - filePath = isSubstrate ? '2-16-2' : 'vanchor_16/2'; - cachedURI = getCachedFixtureURI(filePath); - } - - break; - } - - let deployment = process.env.DEPLOYMENT; - if (!deployment) { - deployment = 'develop'; - } - - try { - const fullFilePath = `${ - filePathPrefix ? `${filePathPrefix}/` : '' - }${filePath}/${filePathSuffix}`; - - const url = withLocalFixtures() - ? cachedURI - : `https://dapp-fixtures.s3.amazonaws.com/${deployment}/${fullFilePath}`; - - const key = await cachedFetch(url, { signal: abortSignal }); - - return key; - } catch (e) { - console.log('error when fetching circuit key from aws: ', e); - throw e; - } -}; - -export const fetchVAnchorWasmFromAws = async ( - maxEdges: number, - isSmall?: boolean, - abortSignal?: AbortSignal -) => { - let filePath: string; - let cachedURI: string; - - switch (maxEdges) { - case 1: - if (isSmall) { - filePath = 'vanchor_2/2/poseidon_vanchor_2_2.wasm'; - cachedURI = getCachedFixtureURI(filePath); - } else { - filePath = 'vanchor_16/2/poseidon_vanchor_16_2.wasm'; - cachedURI = getCachedFixtureURI(filePath); - } - - break; - case 7: - if (isSmall) { - filePath = 'vanchor_2/8/poseidon_vanchor_2_8.wasm'; - cachedURI = getCachedFixtureURI(filePath); - } else { - filePath = 'vanchor_16/8/poseidon_vanchor_16_8.wasm'; - cachedURI = getCachedFixtureURI(filePath); - } - - break; - default: - if (isSmall) { - filePath = 'vanchor_2/2/poseidon_vanchor_2_2.wasm'; - cachedURI = getCachedFixtureURI(filePath); - } else { - filePath = 'vanchor_16/2/poseidon_vanchor_16_2.wasm'; - cachedURI = getCachedFixtureURI(filePath); - } - - break; - } - - let deployment = process.env.DEPLOYMENT; - if (!deployment) { - deployment = 'develop'; - } - - try { - const url = withLocalFixtures() - ? cachedURI - : `https://dapp-fixtures.s3.amazonaws.com/${deployment}/${filePath}`; - - const wasm = await cachedFetch(url, { - signal: abortSignal, - }); - - return wasm; - } catch (e) { - console.log('error when fetching wasm from aws: ', e); - throw e; - } -}; diff --git a/libs/fixtures-deployments/src/index.ts b/libs/fixtures-deployments/src/index.ts deleted file mode 100644 index bcabb0b07d..0000000000 --- a/libs/fixtures-deployments/src/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2022 @webb-tools/ -// SPDX-License-Identifier: Apache-2.0 - -export * from './substrate'; -export * from './evm'; - -// The cached fixture URI is defined in this fixtures-deployments package; however, the -// dapp-packages that build the entire dapp define the contents of this cached-fixtures/ folder. -export function getCachedFixtureURI(fileName: string) { - return `/solidity-fixtures/solidity-fixtures/${fileName}`; -} diff --git a/libs/fixtures-deployments/src/substrate/index.ts b/libs/fixtures-deployments/src/substrate/index.ts deleted file mode 100644 index 9663bb107c..0000000000 --- a/libs/fixtures-deployments/src/substrate/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2022 @webb-tools/ -// SPDX-License-Identifier: Apache-2.0 - -export * from './vanchor'; diff --git a/libs/fixtures-deployments/src/substrate/vanchor.ts b/libs/fixtures-deployments/src/substrate/vanchor.ts deleted file mode 100644 index 1ebd755b84..0000000000 --- a/libs/fixtures-deployments/src/substrate/vanchor.ts +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2022 @webb-tools/ -// SPDX-License-Identifier: Apache-2.0 - -import { withLocalFixtures } from '@webb-tools/react-environment/app-mode'; - -import { getCachedFixtureURI } from '..'; - -export async function fetchSubstrateVAnchorProvingKey( - edges: number, - abortSignal: AbortSignal -) { - const IPFSUrl = - 'https://ipfs.io/ipfs/QmZiNuAKp2QGp281bqasNqvqccPCGp4yoxWbK8feecefML'; - const cachedURI = getCachedFixtureURI( - 'proving_key_uncompressed_sub_vanchor_2_2_2.bin' - ); - const url = withLocalFixtures() ? cachedURI : IPFSUrl; - const ipfsKeyRequest = await fetch(url, { signal: abortSignal }); - const circuitKeyArrayBuffer = await ipfsKeyRequest.arrayBuffer(); - - const circuitKey = new Uint8Array(circuitKeyArrayBuffer); - - return circuitKey; -} diff --git a/libs/fixtures-deployments/tsconfig.json b/libs/fixtures-deployments/tsconfig.json deleted file mode 100644 index 35b8169b21..0000000000 --- a/libs/fixtures-deployments/tsconfig.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "module": "commonjs", - }, - "files": [], - "include": [], - "references": [ - { - "path": "./tsconfig.lib.json" - }, - { - "path": "./tsconfig.spec.json" - } - ] -} diff --git a/libs/fixtures-deployments/tsconfig.lib.json b/libs/fixtures-deployments/tsconfig.lib.json deleted file mode 100644 index 7bfc80f73e..0000000000 --- a/libs/fixtures-deployments/tsconfig.lib.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../dist/out-tsc", - "declaration": true, - "types": ["node"] - }, - "include": ["**/*.ts"], - "exclude": ["jest.config.ts", "**/*.spec.ts", "**/*.test.ts"] -} diff --git a/libs/fixtures-deployments/tsconfig.spec.json b/libs/fixtures-deployments/tsconfig.spec.json deleted file mode 100644 index 546f12877f..0000000000 --- a/libs/fixtures-deployments/tsconfig.spec.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../dist/out-tsc", - "module": "commonjs", - "types": ["jest", "node"] - }, - "include": ["jest.config.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.d.ts"] -} diff --git a/libs/note-manager/src/note-manager.ts b/libs/note-manager/src/note-manager.ts index c14c1f1b8b..47f50c8143 100644 --- a/libs/note-manager/src/note-manager.ts +++ b/libs/note-manager/src/note-manager.ts @@ -5,18 +5,16 @@ import { NoteStorage, resetNoteStorage, } from '@webb-tools/browser-utils/storage'; +import Storage from '@webb-tools/dapp-types/Storage'; import { CircomUtxo, Keypair, Note, NoteGenInput, ResourceId, - Utxo, UtxoGenInput, - parseTypedChainId, toFixedHex, } from '@webb-tools/sdk-core'; -import { Storage } from '@webb-tools/storage'; import { hexToU8a } from '@webb-tools/utils'; import { Backend } from '@webb-tools/wasm-utils'; import { ethers } from 'ethers'; diff --git a/libs/polkadot-api-provider/src/webb-provider.ts b/libs/polkadot-api-provider/src/webb-provider.ts index fef98398c6..0158648d5b 100644 --- a/libs/polkadot-api-provider/src/webb-provider.ts +++ b/libs/polkadot-api-provider/src/webb-provider.ts @@ -33,11 +33,11 @@ import { NoteManager } from '@webb-tools/note-manager'; import { ChainType, CircomUtxo, - parseTypedChainId, Utxo, UtxoGenInput, buildVariableWitnessCalculator, calculateTypedChainId, + parseTypedChainId, toFixedHex, } from '@webb-tools/sdk-core'; @@ -48,15 +48,20 @@ import { } from '@polkadot/extension-inject/types'; import { VoidFn } from '@polkadot/api/types'; -import { - fetchVAnchorKeyFromAws, - fetchVAnchorWasmFromAws, -} from '@webb-tools/fixtures-deployments'; import { ZERO_BYTES32, ZkComponents, u8aToHex } from '@webb-tools/utils'; import type { Backend } from '@webb-tools/wasm-utils'; import { BehaviorSubject, Observable } from 'rxjs'; +import { VAnchor } from '@webb-tools/anchors'; +import { + BridgeStorage, + fetchVAnchorKeyFromAws, + fetchVAnchorWasmFromAws, +} from '@webb-tools/browser-utils'; +import Storage from '@webb-tools/dapp-types/Storage'; +import { providers } from 'ethers'; import { PolkadotProvider } from './ext-provider'; +import { getLeaves } from './mt-utils'; import { PolkaTXBuilder } from './transaction'; import { PolkadotBridgeApi } from './webb-provider/bridge-api'; import { PolkadotChainQuery } from './webb-provider/chain-query'; @@ -65,11 +70,6 @@ import { PolkadotECDSAClaims } from './webb-provider/ecdsa-claims'; import { PolkadotRelayerManager } from './webb-provider/relayer-manager'; import { PolkadotVAnchorActions } from './webb-provider/vanchor-actions'; import { PolkadotWrapUnwrap } from './webb-provider/wrap-unwrap'; -import { getLeaves } from './mt-utils'; -import { Storage } from '@webb-tools/storage'; -import { BridgeStorage } from '@webb-tools/browser-utils'; -import { providers } from 'ethers'; -import { VAnchor } from '@webb-tools/anchors'; export class WebbPolkadot extends EventBus diff --git a/libs/polkadot-api-provider/src/webb-provider/relayer-manager.ts b/libs/polkadot-api-provider/src/webb-provider/relayer-manager.ts index 7961b6e7f5..c8888f8485 100644 --- a/libs/polkadot-api-provider/src/webb-provider/relayer-manager.ts +++ b/libs/polkadot-api-provider/src/webb-provider/relayer-manager.ts @@ -17,8 +17,8 @@ import { shuffleRelayers, } from '@webb-tools/abstract-api-provider/relayer'; import { BridgeStorage } from '@webb-tools/browser-utils'; +import Storage from '@webb-tools/dapp-types/Storage'; import { ChainType, Note, calculateTypedChainId } from '@webb-tools/sdk-core'; -import { Storage } from '@webb-tools/storage'; export class PolkadotRelayerManager extends WebbRelayerManager<'polkadot'> { supportedPallet = 'VAnchorBn254'; diff --git a/libs/react-environment/.babelrc b/libs/react-environment/.babelrc deleted file mode 100644 index fd4cbcdef1..0000000000 --- a/libs/react-environment/.babelrc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "presets": [ - [ - "@nx/js/babel", - { - "useBuiltIns": "usage" - } - ] - ] -} diff --git a/libs/react-environment/.eslintrc.json b/libs/react-environment/.eslintrc.json deleted file mode 100644 index 9d9c0db55b..0000000000 --- a/libs/react-environment/.eslintrc.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "extends": ["../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} - }, - { - "files": ["*.ts", "*.tsx"], - "rules": {} - }, - { - "files": ["*.js", "*.jsx"], - "rules": {} - } - ] -} diff --git a/libs/react-environment/README.md b/libs/react-environment/README.md deleted file mode 100644 index 5d2fb741cf..0000000000 --- a/libs/react-environment/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# react-environment - -This library was generated with [Nx](https://nx.dev). - -## Running unit tests - -Run `nx test react-environment` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/react-environment/jest.config.ts b/libs/react-environment/jest.config.ts deleted file mode 100644 index 7cb8cdcd38..0000000000 --- a/libs/react-environment/jest.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* eslint-disable */ -export default { - displayName: 'react-environment', - preset: '../../jest.preset.js', - globals: { - 'ts-jest': { - tsconfig: '/tsconfig.spec.json', - }, - }, - transform: { - '^.+\\.[tj]s$': 'ts-jest', - }, - moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../coverage/libs/react-environment', -}; diff --git a/libs/react-environment/package.json b/libs/react-environment/package.json deleted file mode 100644 index 174c78c537..0000000000 --- a/libs/react-environment/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "@webb-tools/react-environment", - "version": "0.0.1", - "description": "react environment", - "main": "./src/index.js", - "author": "Webb Developers ", - "homepage": "https://github.com/webb-tools/webb-dapp#readme" -} diff --git a/libs/react-environment/project.json b/libs/react-environment/project.json deleted file mode 100644 index 2289de5997..0000000000 --- a/libs/react-environment/project.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "react-environment", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "libs/react-environment/src", - "projectType": "library", - "targets": { - "build": { - "executor": "@nx/js:tsc", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/libs/react-environment", - "main": "libs/react-environment/src/index.ts", - "tsConfig": "libs/react-environment/tsconfig.lib.json", - "assets": ["libs/react-environment/*.md"] - } - }, - "lint": { - "executor": "@nx/linter:eslint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["libs/react-environment/**/*.ts"] - } - }, - "test": { - "executor": "@nx/jest:jest", - "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], - "options": { - "jestConfig": "libs/react-environment/jest.config.ts", - "passWithNoTests": true - } - } - }, - "tags": [] -} diff --git a/libs/react-environment/src/SettingProvider.tsx b/libs/react-environment/src/SettingProvider.tsx deleted file mode 100644 index 20c51ef3ba..0000000000 --- a/libs/react-environment/src/SettingProvider.tsx +++ /dev/null @@ -1,146 +0,0 @@ -import { useModal } from '@webb-tools/webb-ui-components'; -import { noop } from 'lodash'; -import { - createContext, - FC, - PropsWithChildren, - useCallback, - useEffect, - useState, -} from 'react'; - -export type Language = 'zh' | 'en'; -export type Theme = 'normal' | 'dark'; -export type Browser = 'firefox' | 'chrome' | 'unknown' | undefined; - -function useSetting( - key: string, - defaultValue?: T -): { value: T; setValue: (value: T) => void } { - const [value, _setValue] = useState(); - - const setValue = useCallback( - (value: T): void => { - window.localStorage.setItem(key, value as any as string); - _setValue(value); - }, - [_setValue, key] - ); - - useEffect(() => { - const storaged = window.localStorage.getItem(key); - - if (storaged) { - _setValue(storaged as any as T); - } else if (defaultValue) { - _setValue(defaultValue); - } - }, [_setValue, defaultValue]); - - return { setValue, value: value as any as T }; -} - -export interface SettingDate { - browser: Browser; - endpoint: string; - theme: 'normal' | 'dark'; - changeEndpoint: (endpoints: string) => void; - setTheme: (theme: Theme) => void; - settingVisible: boolean; - openSetting: () => void; - closeSetting: () => void; -} - -export const SettingContext = createContext({ - browser: 'unknown', - changeEndpoint: noop as any, - closeSetting: noop, - endpoint: '', - openSetting: noop, - setTheme: noop as any, - settingVisible: false, - theme: 'normal', -}); - -export const SettingProvider: FC> = ({ children }) => { - const { - close: closeSetting, - open: openSetting, - status: settingVisible, - } = useModal(); - const [browser, setBrowser] = useState(); - const { setValue: setTheme, value: theme } = useSetting( - 'theme', - 'normal' - ); - const [endpoint, setEndpoint] = useState(''); - - const changeEndpoint = useCallback( - (endpoint: string, reload?: boolean) => { - setEndpoint(endpoint); - window.localStorage.setItem('endpoint', endpoint); - - if (reload) { - window.location.reload(); - } - }, - [setEndpoint] - ); - - // set endpoint - useEffect(() => { - // local setting - const localEndpoint = window.localStorage.getItem('endpoint'); - - // get search params from path - const searchParams = new URLSearchParams(window.location.search); - const urlEndpoint = searchParams.get('endpoint'); - - // if url endpoint exist, use url endpoint and don't store this config - if (urlEndpoint) { - setEndpoint(urlEndpoint); - - return; - } - - if (localEndpoint && /wss?:\/\//.test(localEndpoint)) { - setEndpoint(localEndpoint); - - return; - } - }, [setEndpoint]); - - // set browser type - useEffect(() => { - if (window.navigator.userAgent.includes('Firefox')) { - setBrowser('firefox'); - - return; - } - - if (window.navigator.userAgent.includes('Chrome')) { - setBrowser('chrome'); - - return; - } - - setBrowser('unknown'); - }, []); - - return ( - - {children} - - ); -}; diff --git a/libs/react-environment/src/index.ts b/libs/react-environment/src/index.ts deleted file mode 100644 index 1662f8e9bb..0000000000 --- a/libs/react-environment/src/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './RouterProvider'; -export * from './store'; -export * from './app-mode'; -export * from './arkworks-proving-manager.worker'; -export * from './circom-proving-manager.worker'; -export * from './SettingProvider'; diff --git a/libs/react-environment/tsconfig.json b/libs/react-environment/tsconfig.json deleted file mode 100644 index 35b8169b21..0000000000 --- a/libs/react-environment/tsconfig.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "module": "commonjs", - }, - "files": [], - "include": [], - "references": [ - { - "path": "./tsconfig.lib.json" - }, - { - "path": "./tsconfig.spec.json" - } - ] -} diff --git a/libs/react-environment/tsconfig.lib.json b/libs/react-environment/tsconfig.lib.json deleted file mode 100644 index 7bfc80f73e..0000000000 --- a/libs/react-environment/tsconfig.lib.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../dist/out-tsc", - "declaration": true, - "types": ["node"] - }, - "include": ["**/*.ts"], - "exclude": ["jest.config.ts", "**/*.spec.ts", "**/*.test.ts"] -} diff --git a/libs/react-environment/tsconfig.spec.json b/libs/react-environment/tsconfig.spec.json deleted file mode 100644 index 546f12877f..0000000000 --- a/libs/react-environment/tsconfig.spec.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../dist/out-tsc", - "module": "commonjs", - "types": ["jest", "node"] - }, - "include": ["jest.config.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.d.ts"] -} diff --git a/libs/react-hooks/src/index.ts b/libs/react-hooks/src/index.ts index c3391bdea2..59ea77fb3d 100644 --- a/libs/react-hooks/src/index.ts +++ b/libs/react-hooks/src/index.ts @@ -8,7 +8,6 @@ export * from './useCurrentResourceId'; export * from './useFetch'; export * from './useIp'; export * from './useNoteAccount'; -export * from './useSetting'; export * from './useWallets'; export * from './vanchor/useVAnchor'; diff --git a/libs/react-hooks/src/useSetting.ts b/libs/react-hooks/src/useSetting.ts deleted file mode 100644 index 4c6a2aadba..0000000000 --- a/libs/react-hooks/src/useSetting.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { - SettingContext, - SettingDate, -} from '@webb-tools/react-environment/SettingProvider'; -import { useContext } from 'react'; - -export const useSetting = (): SettingDate => { - return useContext(SettingContext); -}; diff --git a/libs/storage/.babelrc b/libs/storage/.babelrc deleted file mode 100644 index fd4cbcdef1..0000000000 --- a/libs/storage/.babelrc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "presets": [ - [ - "@nx/js/babel", - { - "useBuiltIns": "usage" - } - ] - ] -} diff --git a/libs/storage/.eslintrc.json b/libs/storage/.eslintrc.json deleted file mode 100644 index 9d9c0db55b..0000000000 --- a/libs/storage/.eslintrc.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "extends": ["../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} - }, - { - "files": ["*.ts", "*.tsx"], - "rules": {} - }, - { - "files": ["*.js", "*.jsx"], - "rules": {} - } - ] -} diff --git a/libs/storage/README.md b/libs/storage/README.md deleted file mode 100644 index 301e261d04..0000000000 --- a/libs/storage/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# storage - -This library was generated with [Nx](https://nx.dev). - -## Building - -Run `nx build storage` to build the library. - -## Running unit tests - -Run `nx test storage` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/storage/jest.config.ts b/libs/storage/jest.config.ts deleted file mode 100644 index 474f497afc..0000000000 --- a/libs/storage/jest.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* eslint-disable */ -export default { - displayName: 'storage', - preset: '../../jest.preset.js', - globals: { - 'ts-jest': { - tsconfig: '/tsconfig.spec.json', - }, - }, - transform: { - '^.+\\.[tj]s$': 'ts-jest', - }, - moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../coverage/libs/storage', -}; diff --git a/libs/storage/package.json b/libs/storage/package.json deleted file mode 100644 index 7eb8b3c332..0000000000 --- a/libs/storage/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "@webb-tools/storage", - "version": "0.0.1", - "main": "./src/index.js" -} diff --git a/libs/storage/project.json b/libs/storage/project.json deleted file mode 100644 index a8a1d40be0..0000000000 --- a/libs/storage/project.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "storage", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "libs/storage/src", - "projectType": "library", - "targets": { - "build": { - "executor": "@nx/js:tsc", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/libs/storage", - "main": "libs/storage/src/index.ts", - "tsConfig": "libs/storage/tsconfig.lib.json", - "assets": ["libs/storage/*.md"] - } - }, - "lint": { - "executor": "@nx/linter:eslint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["libs/storage/**/*.ts"] - } - }, - "test": { - "executor": "@nx/jest:jest", - "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], - "options": { - "jestConfig": "libs/storage/jest.config.ts", - "passWithNoTests": true - } - } - }, - "tags": [] -} diff --git a/libs/storage/src/index.ts b/libs/storage/src/index.ts deleted file mode 100644 index c463fd75aa..0000000000 --- a/libs/storage/src/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2022 @webb-tools/ -// SPDX-License-Identifier: Apache-2.0 - -export * from './storage'; diff --git a/libs/storage/tsconfig.json b/libs/storage/tsconfig.json deleted file mode 100644 index 35b8169b21..0000000000 --- a/libs/storage/tsconfig.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "module": "commonjs", - }, - "files": [], - "include": [], - "references": [ - { - "path": "./tsconfig.lib.json" - }, - { - "path": "./tsconfig.spec.json" - } - ] -} diff --git a/libs/storage/tsconfig.lib.json b/libs/storage/tsconfig.lib.json deleted file mode 100644 index 7bfc80f73e..0000000000 --- a/libs/storage/tsconfig.lib.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../dist/out-tsc", - "declaration": true, - "types": ["node"] - }, - "include": ["**/*.ts"], - "exclude": ["jest.config.ts", "**/*.spec.ts", "**/*.test.ts"] -} diff --git a/libs/storage/tsconfig.spec.json b/libs/storage/tsconfig.spec.json deleted file mode 100644 index 546f12877f..0000000000 --- a/libs/storage/tsconfig.spec.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../dist/out-tsc", - "module": "commonjs", - "types": ["jest", "node"] - }, - "include": ["jest.config.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.d.ts"] -} diff --git a/libs/web3-api-provider/src/webb-provider.ts b/libs/web3-api-provider/src/webb-provider.ts index 70c732a630..b0182fa91e 100644 --- a/libs/web3-api-provider/src/webb-provider.ts +++ b/libs/web3-api-provider/src/webb-provider.ts @@ -1,6 +1,7 @@ // Copyright 2022 @webb-tools/ // SPDX-License-Identifier: Apache-2.0 +import { ApiPromise } from '@polkadot/api'; import { AccountsAdapter, Bridge, @@ -19,7 +20,11 @@ import { } from '@webb-tools/abstract-api-provider'; import { VAnchor } from '@webb-tools/anchors'; import { EventBus } from '@webb-tools/app-util'; -import { retryPromise } from '@webb-tools/browser-utils'; +import { + fetchVAnchorKeyFromAws, + fetchVAnchorWasmFromAws, + retryPromise, +} from '@webb-tools/browser-utils'; import { BridgeStorage } from '@webb-tools/browser-utils/storage'; import { VAnchor__factory } from '@webb-tools/contracts'; import { @@ -32,10 +37,7 @@ import { WebbError, WebbErrorCodes, } from '@webb-tools/dapp-types'; -import { - fetchVAnchorKeyFromAws, - fetchVAnchorWasmFromAws, -} from '@webb-tools/fixtures-deployments'; +import Storage from '@webb-tools/dapp-types/Storage'; import { NoteManager } from '@webb-tools/note-manager'; import { ChainType, @@ -48,20 +50,17 @@ import { calculateTypedChainId, toFixedHex, } from '@webb-tools/sdk-core'; -import { Storage } from '@webb-tools/storage'; import { ZkComponents, hexToU8a } from '@webb-tools/utils'; import type { Backend } from '@webb-tools/wasm-utils'; import { Signer, ethers, providers } from 'ethers'; import { BehaviorSubject } from 'rxjs'; import { Eth } from 'web3-eth'; - import { Web3Accounts, Web3Provider } from './ext-provider'; import { Web3BridgeApi } from './webb-provider/bridge-api'; import { Web3ChainQuery } from './webb-provider/chain-query'; import { Web3RelayerManager } from './webb-provider/relayer-manager'; import { Web3VAnchorActions } from './webb-provider/vanchor-actions'; import { Web3WrapUnwrap } from './webb-provider/wrap-unwrap'; -import { ApiPromise } from '@polkadot/api'; export class WebbWeb3Provider extends EventBus> diff --git a/libs/web3-api-provider/src/webb-provider/relayer-manager.ts b/libs/web3-api-provider/src/webb-provider/relayer-manager.ts index 0324846250..156d627510 100644 --- a/libs/web3-api-provider/src/webb-provider/relayer-manager.ts +++ b/libs/web3-api-provider/src/webb-provider/relayer-manager.ts @@ -11,14 +11,13 @@ import { } from '@webb-tools/abstract-api-provider/relayer'; import { VAnchor } from '@webb-tools/anchors'; import { BridgeStorage } from '@webb-tools/browser-utils/storage'; +import Storage from '@webb-tools/dapp-types/Storage'; import { calculateTypedChainId, ChainType, - MerkleTree, Note, parseTypedChainId, } from '@webb-tools/sdk-core'; -import { Storage } from '@webb-tools/storage'; import { NewNotesTxResult, diff --git a/libs/webb-ui-components/README.md b/libs/webb-ui-components/README.md index ac1df5a36b..55c6e9fa94 100644 --- a/libs/webb-ui-components/README.md +++ b/libs/webb-ui-components/README.md @@ -10,13 +10,13 @@ # Webb UI Kit

- ๐Ÿš€ A React implementation of Webb's Design System ๐ŸŽจ + A React implementation of Webb's Design System

[![License Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=flat-square)](https://opensource.org/license/apache2-0-php/) [![Twitter](https://img.shields.io/badge/follow-%40webbprotocol-1DA1F2?logo=twitter&style=flat-square)](https://twitter.com/webbprotocol) [![Telegram](https://img.shields.io/badge/Telegram-gray?logo=telegram)](https://t.me/webbprotocol) [![Discord](https://img.shields.io/discord/833784453251596298.svg?style=flat-square&label=Discord&logo=discord)](https://discord.gg/cv8EfJu3Tn) -

Getting Started ๐ŸŽ‰

+

Getting Started

This is the official component library for the Webb Ecosystem! It utilizes [nx.dev](https://nx.dev/) for a fast and extensible build system, and enables developers to build beautiful user interfaces for Web3 applications quickly. The library includes components that are documented using [Storybook](https://storybook.js.org/). @@ -32,7 +32,7 @@ npm install --global yarn This component library also makes use of [tailwindcss](https://tailwindcss.com/). For installation guides please refer to official documentation [here](https://tailwindcss.com/docs/installation/framework-guides). -Great! Now your environment is ready! ๐Ÿš€๐Ÿš€ +Great! Now your environment is ready! ## Usage @@ -117,7 +117,7 @@ nx build webb-ui-components yarn nx storybook webb-ui-components ``` -Visit `http://localhost:4400/` to see the Webb Component Library! ๐Ÿ•ธ๏ธ ๐Ÿš€ +Visit `http://localhost:4400/` to see the Webb Component Library!

Contributing

@@ -129,7 +129,7 @@ If you have a contribution in mind, please check out our [Contribution Guide](.. We welcome and encourage new component proposals from all developers! If you'd like to kick off a new component proposal, please submit an issue using the [issue template](https://github.com/webb-tools/webb-dapp/issues/new/choose) and we will get in touch! -### Lint before you push! ๐Ÿชฅ +### Lint before you push! Please ensure you lint and format your changes prior to opening a PR. diff --git a/libs/webb-ui-components/src/components/IconsGroup/IconsGroup.tsx b/libs/webb-ui-components/src/components/IconsGroup/IconsGroup.tsx index 27776ef33e..0ad6fdb63e 100644 --- a/libs/webb-ui-components/src/components/IconsGroup/IconsGroup.tsx +++ b/libs/webb-ui-components/src/components/IconsGroup/IconsGroup.tsx @@ -15,13 +15,13 @@ export const IconsGroup = forwardRef( return (
{icons.map((icon, idx) => ( = (props) => { darkMode, path: [ , , , @@ -97,8 +97,8 @@ export const LogoWithoutName: React.FC = (props) => { , @@ -116,8 +116,8 @@ export const LogoWithoutName: React.FC = (props) => { , diff --git a/libs/webb-ui-components/src/components/WalletConnectionCard/WalletConnectionCard.tsx b/libs/webb-ui-components/src/components/WalletConnectionCard/WalletConnectionCard.tsx index 9513bd006b..2d072ee435 100644 --- a/libs/webb-ui-components/src/components/WalletConnectionCard/WalletConnectionCard.tsx +++ b/libs/webb-ui-components/src/components/WalletConnectionCard/WalletConnectionCard.tsx @@ -1,13 +1,12 @@ +import { Wallet } from '@webb-tools/dapp-config'; import { Close, Spinner, WalletLineIcon } from '@webb-tools/icons'; +import { cloneElement, forwardRef, useMemo } from 'react'; +import { twMerge } from 'tailwind-merge'; import { PropsOf } from '../../types'; import { Typography } from '../../typography'; -import { cloneElement, forwardRef, useEffect, useMemo } from 'react'; -import { twMerge } from 'tailwind-merge'; import { Button } from '../Button'; import { ListItem } from '../ListCard/ListItem'; import { WalletConnectionCardProps } from './types'; -import { Wallet } from '@webb-tools/dapp-config'; -import { getPlatformMetaData } from '@webb-tools/browser-utils/platform/get-platform-metadata'; export const WalletConnectionCard = forwardRef< HTMLDivElement, diff --git a/tsconfig.base.json b/tsconfig.base.json index 1e7ef82cea..19c70e7191 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -38,10 +38,6 @@ "@webb-tools/dapp-config/*": ["libs/dapp-config/src/*"], "@webb-tools/dapp-types": ["libs/dapp-types/src/index.ts"], "@webb-tools/dapp-types/*": ["libs/dapp-types/src/*"], - "@webb-tools/fixtures-deployments": [ - "libs/fixtures-deployments/src/index.ts" - ], - "@webb-tools/fixtures-deployments/*": ["libs/fixtures-deployments/src/*"], "@webb-tools/icons": ["libs/icons/src/index.ts"], "@webb-tools/icons/*": ["libs/icons/src/*"], "@webb-tools/logos": ["libs/logos/src/index.ts"], @@ -53,8 +49,6 @@ ], "@webb-tools/react-components": ["libs/react-components/src/index.ts"], "@webb-tools/react-components/*": ["libs/react-components/src/*"], - "@webb-tools/react-environment": ["libs/react-environment/src/index.ts"], - "@webb-tools/react-environment/*": ["libs/react-environment/src/*"], "@webb-tools/react-hooks": ["libs/react-hooks/src/index.ts"], "@webb-tools/react-hooks/*": ["libs/react-hooks/src/*"], "@webb-tools/relayer-manager-factory": [ @@ -64,8 +58,6 @@ "libs/relayer-manager-factory/src/*" ], "@webb-tools/stats-dapp/*": ["apps/stats-dapp/src/*"], - "@webb-tools/storage": ["libs/storage/src/index.ts"], - "@webb-tools/storage/*": ["libs/storage/src/*"], "@webb-tools/tailwind-plugin": ["libs/tailwind-plugin/src/index.ts"], "@webb-tools/tailwind-preset": ["libs/tailwind-preset"], "@webb-tools/web3-api-provider": ["libs/web3-api-provider/src/index.ts"],