diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a72d12d08b..6441fb62da 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,44 +9,47 @@ Contributions will fall under varying open-source license agreements depending on package. Most of our packages use [BSD 3-Clause Clear License](https://choosealicense.com/licenses/bsd-3-clause-clear), while our main `dapp` uses [GNU Affero General Public License v3.0 -](https://choosealicense.com/licenses/agpl-3.0). `LICENSE.md` files exist in -each package describing the license that applies to them. +](https://choosealicense.com/licenses/agpl-3.0). `LICENSE` files exist in each +package describing the license that applies to them. In this guide you will get an overview of the contribution workflow from opening an issue, creating a PR, reviewing, and merging the PR. ## New contributor guide -Look at [our wiki](https://github.com/DA0-DA0/dao-dao-ui/wiki/) for the most up-to-date information on how to contribute to the DAO DAO UI. +Look at [our wiki](https://github.com/DA0-DA0/dao-dao-ui/wiki/) for the most +up-to-date information on how to contribute to the DAO DAO UI. -In general, you'll want to either (1) create issues for bugs or (2) create pull requests that close open issues. Find some information on what those terms mean below. +In general, you'll want to either (1) create issues for bugs or (2) create pull +requests that close open issues. Find some information on what those terms mean +below. ### Issues #### Create a new issue -If you spot a problem, [search if an issue already -exists](https://docs.github.com/en/github/searching-for-information-on-github/searching-on-github/searching-issues-and-pull-requests#search-by-the-title-body-or-comments). -If a related issue doesn't exist, you can open a new issue using a relevant -[issue form](https://github.com/DA0-DA0/dao-dao-ui/issues/new/choose). +If you spot a problem, [search for an already existing +issue](https://docs.github.com/en/github/searching-for-information-on-github/searching-on-github/searching-issues-and-pull-requests#search-by-the-title-body-or-comments). +If a related issue doesn't exist, you can open a [new +issue](https://github.com/DA0-DA0/dao-dao-ui/issues/new). #### Solve an issue -Scan through our [existing issues](https://github.com/DA0-DA0/dao-dao-ui/issues) to -find one that interests you. You can narrow down the search using `labels` as -filters. As a general rule, we don't assign issues to anyone. If you find an -issue to work on, you are welcome to open a PR with a fix. +Scan through our [existing issues](https://github.com/DA0-DA0/dao-dao-ui/issues) +to find one that interests you. You can narrow down the search using `labels` as +filters. If you find an issue to work on, you are welcome to open a PR with a +fix. ### Make Changes -#### Make changes in the UI +### Fork the codebase -1. [Install Git - LFS](https://docs.github.com/en/github/managing-large-files/versioning-large-files/installing-git-large-file-storage). +You must first [install Git](https://github.com/git-guides/install-git) to work +with the codebase. -2. Fork the repository. - -3. Create a working branch and start with your changes! +Follow this guide on [contributing to projects through +forks](https://docs.github.com/en/get-started/quickstart/contributing-to-projects) +to start. ### Commit your update @@ -60,7 +63,7 @@ PR. - Don't forget to [link the PR to an issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) if you are solving one. Once you submit your PR, a team member will review - your proposal. We may ask questions or request for additional information. + your proposal. We may ask questions or request additional information. - We may ask for changes to be made before a PR can be merged, either using [suggested changes](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/incorporating-feedback-in-your-pull-request) @@ -71,7 +74,9 @@ PR. [resolved](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/commenting-on-a-pull-request#resolving-conversations). - If you run into any merge issues, checkout this [git tutorial](https://lab.github.com/githubtraining/managing-merge-conflicts) to - help you resolve merge conflicts and other issues. + help you resolve merge conflicts and other issues. Feel free to ask for help + resolving merge conflicts if needed; it can get confusing, and you don't want + to accidentally erase any of your hard work. ### Your PR is merged! diff --git a/README.md b/README.md index 70f650b5dd..34387d999e 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,18 @@ ## DAO DAO UI -This project creates a web UI around the [DAO DAO V1 smart contracts](https://github.com/DA0-DA0/dao-contracts). Enabling users to: +This project creates a web UI for the [DAO DAO smart +contracts](https://github.com/DA0-DA0/dao-contracts), enabling users to: -- Create a governance token based DAO or multisig -- View proposals and treasury info -- Easily create proposals -- Vote on proposals +- create a governance token-based DAO, membership-based DAO (multisig), or other + type of DAO. +- create and vote on proposals. +- view the treasury and manage it democratically. All without having to code! -You can find more info in our [documentation](https://docs.daodao.zone). Join the [DAO DAO Discord](https://discord.gg/sAaGuyW3D2) if you're interested in becoming a contributor. +You can find more info in our [documentation](https://docs.daodao.zone). Join +the [DAO DAO Discord](https://discord.gg/sAaGuyW3D2) if you're interested in +becoming a contributor. ## Development @@ -21,38 +24,61 @@ cd dao-dao-ui yarn ``` -If you're here to work on UI components in isolation: +If you're here to work on UI components in isolation, you will likely want to +run the [Storybook](https://storybook.js.org/) server to mock up components and +iterate quickly without having to access live chain data. Check out the +[storybook package README](./packages/storybook/README.md) for usage +instructions. + +To start the Storybook server, run this command from the root of this monorepo: ```bash yarn storybook start ``` -If you're here to work on app-wide stuff, run the `yarn dev` script (equivalent to running `yarn dev` from the `apps/dapp` folder) to run the main app in development mode. +If you're here to work on any other part of the app, likely accessing live chain +data, run the `yarn dev` script (equivalent to running `yarn dev` from the +[`./apps/dapp`](./apps/dapp) package) to run the main app in development mode. ```bash yarn dev ``` -Learn more about [Turborepo](https://turborepo.org/docs). +If something is misconfigured, check out the docs for +[Turborepo](https://turborepo.org/docs), the monorepo build system we use. ## Packages #### `apps/` -- [`dapp`](./apps/dapp/README.md) +| App | Summary | +| ------------------------------- | ----------- | +| [`dapp`](./apps/dapp/README.md) | DAO DAO UI. | #### `packages/` -- [(wip)](https://github.com/DA0-DA0/dao-dao-ui/issues/368) - -### Learn More - -This project was bootstrapped with [`npx create-turbo@latest`](https://turborepo.org/docs/getting-started). +| Package | Summary | +| --------------------------------------------- | ----------------------------------------------------------------------------------------------------- | +| [`config`](./packages/config/README.md) | Configurations for various dev tools. | +| [`i18n`](./packages/i18n/README.md) | Translation system. | +| [`state`](./packages/state/README.md) | State retrieval and management for the DAO DAO UI. | +| [`stateful`](./packages/stateful/README.md) | Stateful components, hooks, and systems that access and manipulate live data. | +| [`stateless`](./packages/stateless/README.md) | React components, React hooks, and other stateless rendering utilities which do not access live data. | +| [`storybook`](./packages/storybook/README.md) | [Storybook](https://storybook.js.org/) server configuration. | +| [`types`](./packages/types/README.md) | Types used across packages. | +| [`utils`](./packages/utils/README.md) | Utility functions used across packages. | ## Contributing -Interested in contributing to DAO DAO? Check out [CONTRIBUTING.md](./CONTRIBUTING.md). +Interested in contributing to DAO DAO? Check out +[CONTRIBUTING.md](./CONTRIBUTING.md). ## Disclaimer -DAO DAO TOOLING IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND. No developer or entity involved in creating the DAO DAO UI or smart contracts will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of DAO DAO tooling, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value. +DAO DAO TOOLING IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF +ANY KIND. No developer or entity involved in creating the DAO DAO UI or smart +contracts will be liable for any claims or damages whatsoever associated with +your use, inability to use, or your interaction with other users of DAO DAO +tooling, including any direct, indirect, incidental, special, exemplary, +punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, +or anything else of value. diff --git a/apps/dapp/README.md b/apps/dapp/README.md index fd4c08f80d..8cb7998335 100644 --- a/apps/dapp/README.md +++ b/apps/dapp/README.md @@ -1,18 +1,33 @@ # dao-dao-dapp -Web application for creating and managing multiple DAOs. Live in production at [daodao.zone](https://daodao.zone). +Web application for creating and managing multiple DAOs. Live in production at +[daodao.zone](https://daodao.zone). ## Development -See [development](../README.md) for working with Turborepo. +```bash +yarn dev +# or +npm run dev +``` + +Open [http://localhost:3000](http://localhost:3000) with your browser to see the +result. + +You can start editing the page by modifying `pages/index.tsx`. The page +auto-updates as you edit the file. ## Environments -You can choose which environment you want to connect to. The default development environment is [Juno Testnet](#testnet). +You can choose which environment you want to connect to. The default development +environment is [Juno Testnet](#testnet). ### Testnet -Note: you can get Juno Testnet tokens ($JUNOX) from the #faucet channel in the main [Juno Discord](https://discord.com/invite/QcWPfK4gJ2). Testnet environment variables are in `.env.development` and available by default when running `yarn dev` command. +Note: you can get Juno Testnet tokens ($JUNOX) from the #faucet channel in the +main [Juno Discord](https://discord.com/invite/QcWPfK4gJ2). Testnet environment +variables are in `.env.development` and available by default when running the +`yarn dev` command. ```bash yarn dev # starts nextjs dev server @@ -20,61 +35,74 @@ yarn dev # starts nextjs dev server ### Advanced: Other environments -By default `yarn dev` connects to the testnet. For developing against localhost or mainnet, copy the appropriate `.env` file to `.env.local`. Having a `.env.local` file will override the default `.env.development` file when running `yarn dev`. - -#### Localhost - -This will be using a local development instance in Docker. See the [dao-contracts repo](https://github.com/DA0-DA0/dao-contracts#deploying-in-a-development-environment) for instructions on running a local development environment. - -```bash -cp .env.localhost .env.local -``` +By default `yarn dev` connects to the testnet. For developing against localhost +or mainnet, copy the appropriate `.env` file to `.env.local`. Having a +`.env.local` file will override the default `.env.development` file when running +`yarn dev`. #### Mainnet -NOTE: this will be using the real Juno network and real $JUNO tokens. Use with caution. We highly recommend using the [Juno Testnet .env config](#testnet) for local development. +NOTE: this will be using the real Juno network and real $JUNO tokens. Use with +caution. We highly recommend using the [Juno Testnet .env config](#testnet) for +local development. ```bash cp .env.mainnet .env.local ``` -Then, run the development server: +#### Localhost + +This will be using a local development instance in Docker. See the +[dao-contracts +repo](https://github.com/DA0-DA0/dao-contracts#deploying-in-a-development-environment) +for instructions on running a local development environment. ```bash -npm run dev -# or -yarn dev +cp .env.localhost .env.local ``` -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. - -You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file. - -Note: If you change `.env.local`, you'll sometimes need to re-add the chain to Keplr. If you [select a different chain](https://highlander-nodes.medium.com/junoswap-how-to-reset-chain-config-3e2470a9c1e1) in Keplr (like Cosmos), you can scroll down and remove the "Wasmd Test" chain, then you can re-add it by connecting your wallet. - ## Requirements -Please ensure you have the [Keplr wallet extension](https://chrome.google.com/webstore/detail/keplr/dmkamcknogkgcdfhhbddcghachkejeap) installed in your Chrome based browser (Chrome, Brave, etc). +Please ensure you have the [Keplr wallet +extension](https://chrome.google.com/webstore/detail/keplr/dmkamcknogkgcdfhhbddcghachkejeap) +installed in your Chrome-based browser (Chrome, Brave, etc). ## Learn More -This project was bootstrapped with [`next-cosmwasm-keplr-starter`](https://github.com/ebaker/next-cosmwasm-keplr-starter). +This project was bootstrapped with +[`next-cosmwasm-keplr-starter`](https://github.com/ebaker/next-cosmwasm-keplr-starter). -To learn more about Next.js, CosmJS, Keplr, and Tailwind CSS - take a look at the following resources: +To learn more about Next.js, CosmJS, Keplr, and Tailwind CSS, take a look at the +following resources: -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. +- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js + features and API. - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. -- [CosmJS Repository](https://github.com/cosmos/cosmjs) -JavaScript library for Cosmos ecosystem. -- [@cosmjs/cosmwasm-stargate Documentation](https://cosmos.github.io/cosmjs/latest/cosmwasm-stargate/modules.html) - CosmJS CosmWasm Stargate module documentation. -- [Keplr Wallet Documentation](https://docs.keplr.app/api/cosmjs.html) - using Keplr wallet with CosmJS. -- [Tailwind CSS Documentation](https://tailwindcss.com/docs) - utility-first CSS framework. - -You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! +- [CosmJS Repository](https://github.com/cosmos/cosmjs) -JavaScript library for + Cosmos ecosystem. +- [@cosmjs/cosmwasm-stargate + Documentation](https://cosmos.github.io/cosmjs/latest/cosmwasm-stargate/modules.html) + - CosmJS CosmWasm Stargate module documentation. +- [Keplr Wallet Documentation](https://docs.keplr.app/api/cosmjs.html) - using + Keplr wallet with CosmJS. +- [Tailwind CSS Documentation](https://tailwindcss.com/docs) - utility-first CSS + framework. + +You can check out [the Next.js GitHub +repository](https://github.com/vercel/next.js/) - your feedback and +contributions are welcome! ## Contributing -Interested in contributing to DAO DAO? Check out [CONTRIBUTING.md](../CONTRIBUTING.md). +Interested in contributing to DAO DAO? Check out +[CONTRIBUTING.md](../CONTRIBUTING.md). ## Disclaimer -DAO DAO TOOLING IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND. No developer or entity involved in creating the DAO DAO UI or smart contracts will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of DAO DAO tooling, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value. +DAO DAO TOOLING IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF +ANY KIND. No developer or entity involved in creating the DAO DAO UI or smart +contracts will be liable for any claims or damages whatsoever associated with +your use, inability to use, or your interaction with other users of DAO DAO +tooling, including any direct, indirect, incidental, special, exemplary, +punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, +or anything else of value. diff --git a/apps/dapp/components/AppLayout.tsx b/apps/dapp/components/AppLayout.tsx index 7aef91ef84..716787c81f 100644 --- a/apps/dapp/components/AppLayout.tsx +++ b/apps/dapp/components/AppLayout.tsx @@ -21,8 +21,6 @@ import { proposalCreatedCardPropsAtom, refreshBlockHeightAtom, refreshTokenUsdcPriceAtom, - usePinnedDaos, - useWalletProfile, } from '@dao-dao/state' import { LinkWrapper, @@ -30,6 +28,8 @@ import { SidebarWallet, daoCreatedCardPropsAtom, pinnedDaoDropdownInfosSelector, + usePinnedDaos, + useWalletProfile, } from '@dao-dao/stateful' import { CommandModal, makeGenericContext } from '@dao-dao/stateful/command' import { diff --git a/apps/dapp/components/dao/DaoCard.tsx b/apps/dapp/components/dao/DaoCard.tsx index b5cb16ade3..c430576709 100644 --- a/apps/dapp/components/dao/DaoCard.tsx +++ b/apps/dapp/components/dao/DaoCard.tsx @@ -4,8 +4,11 @@ import { useWallet } from '@noahsaso/cosmodal' import { useEffect } from 'react' -import { usePinnedDaos } from '@dao-dao/state' -import { LinkWrapper, daoCardInfoLazyDataSelector } from '@dao-dao/stateful' +import { + LinkWrapper, + daoCardInfoLazyDataSelector, + usePinnedDaos, +} from '@dao-dao/stateful' import { DaoCard as StatelessDaoCard, useCachedLoadable, diff --git a/apps/dapp/components/dao/tabs/ProposalsTab.tsx b/apps/dapp/components/dao/tabs/ProposalsTab.tsx index 2f53470a93..fd24884abc 100644 --- a/apps/dapp/components/dao/tabs/ProposalsTab.tsx +++ b/apps/dapp/components/dao/tabs/ProposalsTab.tsx @@ -1,8 +1,7 @@ // GNU AFFERO GENERAL PUBLIC LICENSE Version 3. Copyright (C) 2022 DAO DAO Contributors. // See the "LICENSE" file in the root directory of this package for more copyright information. -import { useVotingModule } from '@dao-dao/state' -import { ButtonLink, ProposalList } from '@dao-dao/stateful' +import { ButtonLink, ProposalList, useVotingModule } from '@dao-dao/stateful' import { ProposalsTab as StatelessProposalsTab, useDaoInfoContext, diff --git a/apps/dapp/components/dao/tabs/SubDaosTab.tsx b/apps/dapp/components/dao/tabs/SubDaosTab.tsx index b28b6f29f2..259ff910fe 100644 --- a/apps/dapp/components/dao/tabs/SubDaosTab.tsx +++ b/apps/dapp/components/dao/tabs/SubDaosTab.tsx @@ -3,10 +3,11 @@ import { useEffect } from 'react' import { constSelector, useRecoilValueLoadable } from 'recoil' -import { subDaoCardInfosSelector, useVotingModule } from '@dao-dao/state' +import { subDaoCardInfosSelector } from '@dao-dao/state' import { ButtonLink, useEncodedCwdProposalSinglePrefill, + useVotingModule, } from '@dao-dao/stateful' import { SubDaosTab as StatelessSubDaosTab, diff --git a/apps/dapp/components/dao/tabs/TreasuryAndNftsTab.tsx b/apps/dapp/components/dao/tabs/TreasuryAndNftsTab.tsx index e126ece2e4..052b9e26f8 100644 --- a/apps/dapp/components/dao/tabs/TreasuryAndNftsTab.tsx +++ b/apps/dapp/components/dao/tabs/TreasuryAndNftsTab.tsx @@ -5,11 +5,11 @@ import { useEffect } from 'react' import { nftCardInfosSelector, treasuryTokenCardInfosSelector, - useVotingModule, } from '@dao-dao/state' import { StargazeNftImportModal, useEncodedCwdProposalSinglePrefill, + useVotingModule, } from '@dao-dao/stateful' import { useActionForKey } from '@dao-dao/stateful/actions' import { diff --git a/apps/dapp/components/profile/ProfileHomeCard.tsx b/apps/dapp/components/profile/ProfileHomeCard.tsx index 2197f653cb..a5b9eb0067 100644 --- a/apps/dapp/components/profile/ProfileHomeCard.tsx +++ b/apps/dapp/components/profile/ProfileHomeCard.tsx @@ -1,7 +1,8 @@ // GNU AFFERO GENERAL PUBLIC LICENSE Version 3. Copyright (C) 2022 DAO DAO Contributors. // See the "LICENSE" file in the root directory of this package for more copyright information. -import { useWalletProfile, useWalletProposalsQuery } from '@dao-dao/state' +import { useWalletProposalsQuery } from '@dao-dao/state' +import { useWalletProfile } from '@dao-dao/stateful' import { ProfileHomeCard as StatelessProfileHomeCard, useAppLayoutContext, diff --git a/apps/dapp/components/profile/ProfileNewProposalCard.tsx b/apps/dapp/components/profile/ProfileNewProposalCard.tsx index 65a60c4e73..1c8cf898e9 100644 --- a/apps/dapp/components/profile/ProfileNewProposalCard.tsx +++ b/apps/dapp/components/profile/ProfileNewProposalCard.tsx @@ -3,8 +3,7 @@ import { useTranslation } from 'react-i18next' -import { useWalletProfile } from '@dao-dao/state' -import { SuspenseLoader } from '@dao-dao/stateful' +import { SuspenseLoader, useWalletProfile } from '@dao-dao/stateful' import { matchAndLoadCommon } from '@dao-dao/stateful/proposal-module-adapter' import { useVotingModuleAdapter } from '@dao-dao/stateful/voting-module-adapter' import { diff --git a/apps/dapp/components/profile/ProfileProposalCard.tsx b/apps/dapp/components/profile/ProfileProposalCard.tsx index 84b102caa2..9e2f2d0412 100644 --- a/apps/dapp/components/profile/ProfileProposalCard.tsx +++ b/apps/dapp/components/profile/ProfileProposalCard.tsx @@ -5,7 +5,7 @@ import { useMemo } from 'react' import { useTranslation } from 'react-i18next' import { useRecoilValue, waitForAll } from 'recoil' -import { useVotingModule, useWalletProfile } from '@dao-dao/state' +import { useVotingModule, useWalletProfile } from '@dao-dao/stateful' import { matchAndLoadCommon, useProposalModuleAdapter, diff --git a/apps/dapp/pages/dao/[address]/index.tsx b/apps/dapp/pages/dao/[address]/index.tsx index a095be635e..7055dd0e9c 100644 --- a/apps/dapp/pages/dao/[address]/index.tsx +++ b/apps/dapp/pages/dao/[address]/index.tsx @@ -14,18 +14,16 @@ import { waitForAll, } from 'recoil' -import { - CwdCoreV2Selectors, - usePinnedDaos, - useVotingModule, - useWalletProfile, -} from '@dao-dao/state' +import { CwdCoreV2Selectors } from '@dao-dao/state' import { DaoInfoBar, DaoPageWrapper, DaoPageWrapperProps, SuspenseLoader, useEncodedCwdProposalSinglePrefill, + usePinnedDaos, + useVotingModule, + useWalletProfile, } from '@dao-dao/stateful' import { useActionForKey } from '@dao-dao/stateful/actions' import { matchAndLoadCommon } from '@dao-dao/stateful/proposal-module-adapter' diff --git a/apps/dapp/pages/dao/[address]/proposals/[proposalId].tsx b/apps/dapp/pages/dao/[address]/proposals/[proposalId].tsx index 8b5904cdb8..c46831079f 100644 --- a/apps/dapp/pages/dao/[address]/proposals/[proposalId].tsx +++ b/apps/dapp/pages/dao/[address]/proposals/[proposalId].tsx @@ -8,11 +8,11 @@ import { useCallback, useMemo } from 'react' import toast from 'react-hot-toast' import { useTranslation } from 'react-i18next' -import { useProfile } from '@dao-dao/state' import { DaoPageWrapper, DaoProposalPageWrapperProps, Trans, + useProfile, } from '@dao-dao/stateful' import { useActions } from '@dao-dao/stateful/actions' import { diff --git a/apps/dapp/pages/dao/[address]/proposals/create.tsx b/apps/dapp/pages/dao/[address]/proposals/create.tsx index 36589aa8d2..5b1b391651 100644 --- a/apps/dapp/pages/dao/[address]/proposals/create.tsx +++ b/apps/dapp/pages/dao/[address]/proposals/create.tsx @@ -24,12 +24,12 @@ import { proposalCreatedCardPropsAtom, proposalDraftsAtom, refreshProposalsIdAtom, - useVotingModule, } from '@dao-dao/state' import { DaoPageWrapper, DaoPageWrapperProps, SuspenseLoader, + useVotingModule, } from '@dao-dao/stateful' import { CwdProposalSingleAdapter, diff --git a/apps/dapp/pages/home.tsx b/apps/dapp/pages/home.tsx index 273c184f5b..ea49003010 100644 --- a/apps/dapp/pages/home.tsx +++ b/apps/dapp/pages/home.tsx @@ -9,7 +9,7 @@ import { serverSideTranslations } from '@dao-dao/i18n/serverSideTranslations' import { useLoadingFeaturedDaoCardInfos, useLoadingPinnedDaoCardInfos, -} from '@dao-dao/state' +} from '@dao-dao/stateful' import { Home, ProfileDisconnectedCard } from '@dao-dao/stateless' import { commandModalVisibleAtom } from '@/atoms' diff --git a/apps/dapp/pages/index.tsx b/apps/dapp/pages/index.tsx index 1a6ade92bb..16cc2e0084 100644 --- a/apps/dapp/pages/index.tsx +++ b/apps/dapp/pages/index.tsx @@ -7,8 +7,10 @@ import { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import { serverSideTranslations } from '@dao-dao/i18n/serverSideTranslations' -import { useLoadingFeaturedDaoCardInfos } from '@dao-dao/state' -import { SuspenseLoader } from '@dao-dao/stateful' +import { + SuspenseLoader, + useLoadingFeaturedDaoCardInfos, +} from '@dao-dao/stateful' import { FeaturedDaos, Logo, diff --git a/packages/config/eslint/index.js b/packages/config/eslint/index.js index 2d13c872a1..3a34ce2418 100644 --- a/packages/config/eslint/index.js +++ b/packages/config/eslint/index.js @@ -103,16 +103,6 @@ const eslintConfig = { message: 'Import from root @dao-dao/stateless instead of a direct path. Ensure the export has been added to its sibling index.', }, - { - regex: '\\@dao\\-dao\\/state\\/hooks\\/clients[^\'"]*', - message: - 'Import from root @dao-dao/state using a grouped export, such as CwCoreHooks, instead of a direct path.', - }, - { - regex: '\\@dao\\-dao\\/state\\/recoil\\/selectors[^\'"]*', - message: - 'Import from root @dao-dao/state instead of a direct path. If using contract client selectors, use a grouped export, such as CwCoreV1Selectors.', - }, { regex: '(?:\\.\\.\\/)+(atoms|components|hooks|util)', replacement: { diff --git a/packages/state/README.md b/packages/state/README.md new file mode 100644 index 0000000000..af1ccacd7c --- /dev/null +++ b/packages/state/README.md @@ -0,0 +1,11 @@ +# @dao-dao/state + +State retrieval and management for the DAO DAO UI. + +## Folders + +| Folder | Summary | +| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | +| [`contracts`](./contracts) | Smart contract query and execute clients auto-generated with [@cosmwasm/ts-codegen](https://www.npmjs.com/package/@cosmwasm/ts-codegen). | +| [`recoil`](./recoil) | [Recoil](https://recoiljs.org/) atoms and selectors for loading and caching state. | +| [`subquery`](./subquery) | [Apollo GraphQL](https://www.apollographql.com/docs/react/) React hooks for querying the DAO DAO [SubQuery](https://subquery.network/) indexers. | diff --git a/packages/state/clients/Cw20Base.ts b/packages/state/contracts/Cw20Base.ts similarity index 100% rename from packages/state/clients/Cw20Base.ts rename to packages/state/contracts/Cw20Base.ts diff --git a/packages/state/clients/Cw20Stake.ts b/packages/state/contracts/Cw20Stake.ts similarity index 100% rename from packages/state/clients/Cw20Stake.ts rename to packages/state/contracts/Cw20Stake.ts diff --git a/packages/state/clients/Cw4Group.ts b/packages/state/contracts/Cw4Group.ts similarity index 100% rename from packages/state/clients/Cw4Group.ts rename to packages/state/contracts/Cw4Group.ts diff --git a/packages/state/clients/Cw721Base.ts b/packages/state/contracts/Cw721Base.ts similarity index 100% rename from packages/state/clients/Cw721Base.ts rename to packages/state/contracts/Cw721Base.ts diff --git a/packages/state/clients/CwAdminFactory.ts b/packages/state/contracts/CwAdminFactory.ts similarity index 100% rename from packages/state/clients/CwAdminFactory.ts rename to packages/state/contracts/CwAdminFactory.ts diff --git a/packages/state/clients/CwCore.v1.ts b/packages/state/contracts/CwCore.v1.ts similarity index 100% rename from packages/state/clients/CwCore.v1.ts rename to packages/state/contracts/CwCore.v1.ts diff --git a/packages/state/clients/CwdCore.v2.ts b/packages/state/contracts/CwdCore.v2.ts similarity index 100% rename from packages/state/clients/CwdCore.v2.ts rename to packages/state/contracts/CwdCore.v2.ts diff --git a/packages/state/clients/CwdVotingCw20Staked.ts b/packages/state/contracts/CwdVotingCw20Staked.ts similarity index 100% rename from packages/state/clients/CwdVotingCw20Staked.ts rename to packages/state/contracts/CwdVotingCw20Staked.ts diff --git a/packages/state/clients/CwdVotingCw4.ts b/packages/state/contracts/CwdVotingCw4.ts similarity index 100% rename from packages/state/clients/CwdVotingCw4.ts rename to packages/state/contracts/CwdVotingCw4.ts diff --git a/packages/state/clients/CwdVotingNativeStaked.ts b/packages/state/contracts/CwdVotingNativeStaked.ts similarity index 100% rename from packages/state/clients/CwdVotingNativeStaked.ts rename to packages/state/contracts/CwdVotingNativeStaked.ts diff --git a/packages/state/clients/index.ts b/packages/state/contracts/index.ts similarity index 100% rename from packages/state/clients/index.ts rename to packages/state/contracts/index.ts diff --git a/packages/state/hooks/clients/CwCore.v1.ts b/packages/state/hooks/clients/CwCore.v1.ts deleted file mode 100644 index 58fe0dd9d7..0000000000 --- a/packages/state/hooks/clients/CwCore.v1.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* eslint-disable react-hooks/rules-of-hooks */ - -import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' -import { useCallback } from 'react' -import { useRecoilValueLoadable } from 'recoil' - -import { CwCoreV1Client as ExecuteClient } from '../../clients/CwCore.v1' -import { - ExecuteClientParams, - executeClient, -} from '../../recoil/selectors/clients/CwCore.v1' -import { FunctionKeyOf } from '../../types' - -// This hook wrapper lets us easily make hooks out of all execution functions on -// the contract clients, without having to fetch the `executeClient` selector as -// a loadable and add `useCallback` hooks in all the components. -const wrapExecuteHook = - >(fn: T) => - (params: ExecuteClientParams) => { - const clientLoadable = useRecoilValueLoadable(executeClient(params)) - const client = - clientLoadable.state === 'hasValue' ? clientLoadable.contents : undefined - - return useCallback( - (...args: Parameters) => { - if (client) - return ( - client[fn] as ( - ...args: Parameters - ) => Promise - )(...args) - throw new Error('Client undefined.') - }, - [client] - ) - } - -export const useExecuteAdminMsgs = wrapExecuteHook('executeAdminMsgs') -export const useExecuteProposalHook = wrapExecuteHook('executeProposalHook') -export const usePause = wrapExecuteHook('pause') -export const useUpdateAdmin = wrapExecuteHook('updateAdmin') -export const useUpdateConfig = wrapExecuteHook('updateConfig') -export const useUpdateVotingModule = wrapExecuteHook('updateVotingModule') -export const useUpdateProposalModules = wrapExecuteHook('updateProposalModules') -export const useSetItem = wrapExecuteHook('setItem') -export const useRemoveItem = wrapExecuteHook('removeItem') -export const useReceive = wrapExecuteHook('receive') -export const useReceiveNft = wrapExecuteHook('receiveNft') -export const useUpdateCw20List = wrapExecuteHook('updateCw20List') -export const useUpdateCw721List = wrapExecuteHook('updateCw721List') diff --git a/packages/state/hooks/clients/CwdCore.v2.ts b/packages/state/hooks/clients/CwdCore.v2.ts deleted file mode 100644 index 5fbcc590b6..0000000000 --- a/packages/state/hooks/clients/CwdCore.v2.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* eslint-disable react-hooks/rules-of-hooks */ - -import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' -import { useCallback } from 'react' -import { useRecoilValueLoadable } from 'recoil' - -import { FunctionKeyOf } from '@dao-dao/types' - -import { CwdCoreV2Client as ExecuteClient } from '../../clients/CwdCore.v2' -import { - ExecuteClientParams, - executeClient, -} from '../../recoil/selectors/clients/CwdCore.v2' - -// This hook wrapper lets us easily make hooks out of all execution functions on -// the contract clients, without having to fetch the `executeClient` selector as -// a loadable and add `useCallback` hooks in all the components. -const wrapExecuteHook = - >(fn: T) => - (params: ExecuteClientParams) => { - const clientLoadable = useRecoilValueLoadable(executeClient(params)) - const client = - clientLoadable.state === 'hasValue' ? clientLoadable.contents : undefined - - return useCallback( - (...args: Parameters) => { - if (client) - return ( - client[fn] as ( - ...args: Parameters - ) => Promise - )(...args) - throw new Error('Client undefined.') - }, - [client] - ) - } - -export const useExecuteAdminMsgs = wrapExecuteHook('executeAdminMsgs') -export const useExecuteProposalHook = wrapExecuteHook('executeProposalHook') -export const usePause = wrapExecuteHook('pause') -export const useUpdateConfig = wrapExecuteHook('updateConfig') -export const useUpdateVotingModule = wrapExecuteHook('updateVotingModule') -export const useUpdateProposalModules = wrapExecuteHook('updateProposalModules') -export const useSetItem = wrapExecuteHook('setItem') -export const useRemoveItem = wrapExecuteHook('removeItem') -export const useReceive = wrapExecuteHook('receive') -export const useReceiveNft = wrapExecuteHook('receiveNft') -export const useUpdateCw20List = wrapExecuteHook('updateCw20List') -export const useUpdateCw721List = wrapExecuteHook('updateCw721List') diff --git a/packages/state/hooks/index.ts b/packages/state/hooks/index.ts deleted file mode 100644 index 9cbe90256b..0000000000 --- a/packages/state/hooks/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from './clients' - -export * from './useAwaitNextBlock' -export * from './useLoadingDaoCardInfos' -export * from './usePinnedDaos' -export * from './useProfile' -export * from './useVotingModule' -export * from './useWalletProfile' diff --git a/packages/state/index.ts b/packages/state/index.ts index 27e6b802fd..03b8c7eab2 100644 --- a/packages/state/index.ts +++ b/packages/state/index.ts @@ -1,4 +1,3 @@ -export * from './clients' -export * from './hooks' +export * from './contracts' export * from './recoil' export * from './subquery' diff --git a/packages/state/package.json b/packages/state/package.json index 9aa42291f3..f84c5c2249 100644 --- a/packages/state/package.json +++ b/packages/state/package.json @@ -2,6 +2,7 @@ "name": "@dao-dao/state", "version": "2.0.1", "scripts": { + "build": "tsc", "format": "eslint . --fix", "lint": "eslint ." }, diff --git a/packages/state/recoil/selectors/contract.ts b/packages/state/recoil/selectors/contract.ts index 3e5a541123..8e27aca573 100644 --- a/packages/state/recoil/selectors/contract.ts +++ b/packages/state/recoil/selectors/contract.ts @@ -7,7 +7,7 @@ import { blockHeightTimestampSafeSelector, cosmWasmClientForChainSelector, } from './chain' -import { CwdCoreV2Selectors } from './clients' +import { CwdCoreV2Selectors } from './contracts' export const contractInstantiateTimeSelector = selectorFamily< Date | undefined, diff --git a/packages/state/recoil/selectors/clients/Cw20Base.ts b/packages/state/recoil/selectors/contracts/Cw20Base.ts similarity index 98% rename from packages/state/recoil/selectors/clients/Cw20Base.ts rename to packages/state/recoil/selectors/contracts/Cw20Base.ts index fd1c6e0e44..c22205585b 100644 --- a/packages/state/recoil/selectors/clients/Cw20Base.ts +++ b/packages/state/recoil/selectors/contracts/Cw20Base.ts @@ -12,7 +12,10 @@ import { TokenInfoResponse, } from '@dao-dao/types/contracts/Cw20Base' -import { Cw20BaseClient, Cw20BaseQueryClient } from '../../../clients/Cw20Base' +import { + Cw20BaseClient, + Cw20BaseQueryClient, +} from '../../../contracts/Cw20Base' import { refreshWalletBalancesIdAtom, signingCosmWasmClientAtom, diff --git a/packages/state/recoil/selectors/clients/Cw20Stake.ts b/packages/state/recoil/selectors/contracts/Cw20Stake.ts similarity index 99% rename from packages/state/recoil/selectors/clients/Cw20Stake.ts rename to packages/state/recoil/selectors/contracts/Cw20Stake.ts index f84ec1e1dc..64fcc83e42 100644 --- a/packages/state/recoil/selectors/clients/Cw20Stake.ts +++ b/packages/state/recoil/selectors/contracts/Cw20Stake.ts @@ -15,7 +15,7 @@ import { import { Cw20StakeClient, Cw20StakeQueryClient, -} from '../../../clients/Cw20Stake' +} from '../../../contracts/Cw20Stake' import { refreshClaimsIdAtom, refreshWalletBalancesIdAtom, diff --git a/packages/state/recoil/selectors/clients/Cw4Group.ts b/packages/state/recoil/selectors/contracts/Cw4Group.ts similarity index 98% rename from packages/state/recoil/selectors/clients/Cw4Group.ts rename to packages/state/recoil/selectors/contracts/Cw4Group.ts index 73cd303055..f893db2789 100644 --- a/packages/state/recoil/selectors/clients/Cw4Group.ts +++ b/packages/state/recoil/selectors/contracts/Cw4Group.ts @@ -9,7 +9,7 @@ import { TotalWeightResponse, } from '@dao-dao/types/contracts/Cw4Group' -import { Cw4GroupQueryClient } from '../../../clients/Cw4Group' +import { Cw4GroupQueryClient } from '../../../contracts/Cw4Group' import { cosmWasmClientForChainSelector } from '../chain' type QueryClientParams = WithChainId<{ diff --git a/packages/state/recoil/selectors/clients/Cw721Base.ts b/packages/state/recoil/selectors/contracts/Cw721Base.ts similarity index 98% rename from packages/state/recoil/selectors/clients/Cw721Base.ts rename to packages/state/recoil/selectors/contracts/Cw721Base.ts index 2af8edcf9f..470168fbea 100644 --- a/packages/state/recoil/selectors/clients/Cw721Base.ts +++ b/packages/state/recoil/selectors/contracts/Cw721Base.ts @@ -15,7 +15,7 @@ import { TokensResponse, } from '@dao-dao/types/contracts/Cw721Base' -import { Cw721BaseQueryClient } from '../../../clients/Cw721Base' +import { Cw721BaseQueryClient } from '../../../contracts/Cw721Base' import { cosmWasmClientForChainSelector } from '../chain' type QueryClientParams = WithChainId<{ diff --git a/packages/state/recoil/selectors/clients/CwAdminFactory.ts b/packages/state/recoil/selectors/contracts/CwAdminFactory.ts similarity index 96% rename from packages/state/recoil/selectors/clients/CwAdminFactory.ts rename to packages/state/recoil/selectors/contracts/CwAdminFactory.ts index fada2d858d..caec76202a 100644 --- a/packages/state/recoil/selectors/clients/CwAdminFactory.ts +++ b/packages/state/recoil/selectors/contracts/CwAdminFactory.ts @@ -1,6 +1,6 @@ import { selectorFamily } from 'recoil' -import { CwAdminFactoryClient as ExecuteClient } from '../../../clients/CwAdminFactory' +import { CwAdminFactoryClient as ExecuteClient } from '../../../contracts/CwAdminFactory' import { signingCosmWasmClientAtom } from '../../atoms' export type ExecuteClientParams = { diff --git a/packages/state/recoil/selectors/clients/CwCore.v1.ts b/packages/state/recoil/selectors/contracts/CwCore.v1.ts similarity index 99% rename from packages/state/recoil/selectors/clients/CwCore.v1.ts rename to packages/state/recoil/selectors/contracts/CwCore.v1.ts index 49324dcd08..aaf7c29a60 100644 --- a/packages/state/recoil/selectors/clients/CwCore.v1.ts +++ b/packages/state/recoil/selectors/contracts/CwCore.v1.ts @@ -21,7 +21,7 @@ import { import { CwCoreV1Client as ExecuteClient, CwCoreV1QueryClient as QueryClient, -} from '../../../clients/CwCore.v1' +} from '../../../contracts/CwCore.v1' import { refreshDaoVotingPowerAtom, refreshWalletBalancesIdAtom, diff --git a/packages/state/recoil/selectors/clients/CwdCore.v2.ts b/packages/state/recoil/selectors/contracts/CwdCore.v2.ts similarity index 99% rename from packages/state/recoil/selectors/clients/CwdCore.v2.ts rename to packages/state/recoil/selectors/contracts/CwdCore.v2.ts index a03173f8e5..1495fe02d8 100644 --- a/packages/state/recoil/selectors/clients/CwdCore.v2.ts +++ b/packages/state/recoil/selectors/contracts/CwdCore.v2.ts @@ -27,7 +27,7 @@ import { Cw20BaseSelectors } from '.' import { CwdCoreV2Client, CwdCoreV2QueryClient, -} from '../../../clients/CwdCore.v2' +} from '../../../contracts/CwdCore.v2' import { refreshDaoVotingPowerAtom, refreshWalletBalancesIdAtom, diff --git a/packages/state/recoil/selectors/clients/CwdVotingCw20Staked.ts b/packages/state/recoil/selectors/contracts/CwdVotingCw20Staked.ts similarity index 97% rename from packages/state/recoil/selectors/clients/CwdVotingCw20Staked.ts rename to packages/state/recoil/selectors/contracts/CwdVotingCw20Staked.ts index 6d20f18411..e1da6c1793 100644 --- a/packages/state/recoil/selectors/clients/CwdVotingCw20Staked.ts +++ b/packages/state/recoil/selectors/contracts/CwdVotingCw20Staked.ts @@ -12,7 +12,7 @@ import { VotingPowerAtHeightResponse, } from '@dao-dao/types/contracts/CwdVotingCw20Staked' -import { CwdVotingCw20StakedQueryClient } from '../../../clients/CwdVotingCw20Staked' +import { CwdVotingCw20StakedQueryClient } from '../../../contracts/CwdVotingCw20Staked' import { refreshWalletBalancesIdAtom } from '../../atoms/refresh' import { cosmWasmClientForChainSelector } from '../chain' diff --git a/packages/state/recoil/selectors/clients/CwdVotingCw4.ts b/packages/state/recoil/selectors/contracts/CwdVotingCw4.ts similarity index 98% rename from packages/state/recoil/selectors/clients/CwdVotingCw4.ts rename to packages/state/recoil/selectors/contracts/CwdVotingCw4.ts index 0e7adbef97..669ba0a756 100644 --- a/packages/state/recoil/selectors/clients/CwdVotingCw4.ts +++ b/packages/state/recoil/selectors/contracts/CwdVotingCw4.ts @@ -12,7 +12,7 @@ import { import { CwdVotingCw4Client, CwdVotingCw4QueryClient, -} from '../../../clients/CwdVotingCw4' +} from '../../../contracts/CwdVotingCw4' import { signingCosmWasmClientAtom } from '../../atoms' import { cosmWasmClientForChainSelector } from '../chain' diff --git a/packages/state/recoil/selectors/clients/CwdVotingNativeStaked.ts b/packages/state/recoil/selectors/contracts/CwdVotingNativeStaked.ts similarity index 98% rename from packages/state/recoil/selectors/clients/CwdVotingNativeStaked.ts rename to packages/state/recoil/selectors/contracts/CwdVotingNativeStaked.ts index 9d6fb8110f..18aadeead7 100644 --- a/packages/state/recoil/selectors/clients/CwdVotingNativeStaked.ts +++ b/packages/state/recoil/selectors/contracts/CwdVotingNativeStaked.ts @@ -14,7 +14,7 @@ import { import { CwdVotingNativeStakedClient, CwdVotingNativeStakedQueryClient, -} from '../../../clients/CwdVotingNativeStaked' +} from '../../../contracts/CwdVotingNativeStaked' import { signingCosmWasmClientAtom } from '../../atoms' import { refreshWalletBalancesIdAtom } from '../../atoms/refresh' import { cosmWasmClientForChainSelector } from '../chain' diff --git a/packages/state/recoil/selectors/clients/index.ts b/packages/state/recoil/selectors/contracts/index.ts similarity index 100% rename from packages/state/recoil/selectors/clients/index.ts rename to packages/state/recoil/selectors/contracts/index.ts diff --git a/packages/state/recoil/selectors/dao/info.ts b/packages/state/recoil/selectors/dao/info.ts index dc4fb70808..7ab8fd6ea2 100644 --- a/packages/state/recoil/selectors/dao/info.ts +++ b/packages/state/recoil/selectors/dao/info.ts @@ -21,7 +21,7 @@ import { getFallbackImage, } from '@dao-dao/utils' -import { CwCoreV1Selectors, CwdCoreV2Selectors } from '../clients' +import { CwCoreV1Selectors, CwdCoreV2Selectors } from '../contracts' import { contractInstantiateTimeSelector, contractVersionSelector, diff --git a/packages/state/recoil/selectors/dao/treasury.ts b/packages/state/recoil/selectors/dao/treasury.ts index d67867add1..98878f92a0 100644 --- a/packages/state/recoil/selectors/dao/treasury.ts +++ b/packages/state/recoil/selectors/dao/treasury.ts @@ -24,7 +24,7 @@ import { nativeStakingInfoSelector, nativeUnstakingDurationSecondsSelector, } from '../chain' -import { CwdCoreV2Selectors } from '../clients' +import { CwdCoreV2Selectors } from '../contracts' import { usdcPerMacroTokenSelector } from '../price' export const treasuryTokenCardInfosSelector = selectorFamily< diff --git a/packages/state/recoil/selectors/index.ts b/packages/state/recoil/selectors/index.ts index 8a2b39a1b7..2027957fb2 100644 --- a/packages/state/recoil/selectors/index.ts +++ b/packages/state/recoil/selectors/index.ts @@ -1,9 +1,10 @@ -export * from './clients' +export * from './contracts' export * from './dao' export * from './chain' export * from './contract' export * from './nft' +export * from './pools' export * from './price' export * from './proposal' -export * from './pools' +export * from './wallet' diff --git a/packages/state/recoil/selectors/nft.ts b/packages/state/recoil/selectors/nft.ts index 026107c21d..03095cb0b6 100644 --- a/packages/state/recoil/selectors/nft.ts +++ b/packages/state/recoil/selectors/nft.ts @@ -15,7 +15,7 @@ import { } from '@dao-dao/utils' import { refreshWalletStargazeNftsAtom } from '../atoms/refresh' -import { Cw721BaseSelectors, CwdCoreV2Selectors } from './clients' +import { Cw721BaseSelectors, CwdCoreV2Selectors } from './contracts' export const walletStargazeNftCardInfosSelector = selectorFamily< NftCardInfo[], diff --git a/packages/state/recoil/selectors/price.ts b/packages/state/recoil/selectors/price.ts index 79ba42d478..79d96774b8 100644 --- a/packages/state/recoil/selectors/price.ts +++ b/packages/state/recoil/selectors/price.ts @@ -10,7 +10,7 @@ import { import { refreshTokenUsdcPriceAtom } from '../atoms/refresh' import { cosmWasmClientForChainSelector, nativeBalancesSelector } from './chain' -import { CwdCoreV2Selectors } from './clients' +import { CwdCoreV2Selectors } from './contracts' import { junoswapPoolsListSelector } from './pools' // TODO(multichain): Figure out how to match CW20s on other chains to CW20s in diff --git a/packages/state/types.ts b/packages/state/types.ts deleted file mode 100644 index 4f49d1b96a..0000000000 --- a/packages/state/types.ts +++ /dev/null @@ -1 +0,0 @@ -export type { FunctionKeyOf } from '@dao-dao/types' diff --git a/packages/stateful/README.md b/packages/stateful/README.md index 30425838dc..ececfe4789 100644 --- a/packages/stateful/README.md +++ b/packages/stateful/README.md @@ -4,13 +4,11 @@ This package combines the `@dao-dao/stateless` and `@dao-dao/state` packages into stateful components, hooks, and other systems. These are the live, intelligent components that do fun stuff with data. -Systems included in their own subfolders: +## Systems -- [`actions`](./actions): UI components that allow for the creation and viewing - of Cosmos messages in a proposal. -- [`command`](./command): Interface that allows customizing command modal - actions and contexts. -- [`proposal-module-adapter`](./proposal-module-adapter): Proposal module - adapter system that allows dynamic support for proposal modules in the UI. -- [`voting-module-adapter`](./voting-module-adapter): Voting module - adapter system that allows dynamic support for voting modules in the UI. +| System | Summary | +| ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | +| [`actions`](./actions/README.md) | UI components that allow for the creation and viewing of Cosmos messages in a proposal. | +| [`command`](./command/README.md) | Interface that allows customizing command modal actions and contexts. | +| [`proposal-module-adapter`](./proposal-module-adapter/README.md) | Proposal module adapter system that allows dynamic support for proposal modules in the UI. | +| [`voting-module-adapter`](./voting-module-adapter/README.md) | Voting module adapter system that allows dynamic support for voting modules in the UI. | diff --git a/packages/stateful/command/contexts/generic/dao.ts b/packages/stateful/command/contexts/generic/dao.ts index 57faaceadf..efefa13827 100644 --- a/packages/stateful/command/contexts/generic/dao.ts +++ b/packages/stateful/command/contexts/generic/dao.ts @@ -12,11 +12,8 @@ import { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import { useRecoilState } from 'recoil' -import { - navigatingToHrefAtom, - usePinnedDaos, - useVotingModule, -} from '@dao-dao/state' +import { navigatingToHrefAtom } from '@dao-dao/state' +import { usePinnedDaos, useVotingModule } from '@dao-dao/stateful' import { CommandModalContextMaker, CommandModalContextSection, diff --git a/packages/stateful/command/hooks/usePinnedAndFilteredDaosSections.ts b/packages/stateful/command/hooks/usePinnedAndFilteredDaosSections.ts index 585205effe..fbae9c4e57 100644 --- a/packages/stateful/command/hooks/usePinnedAndFilteredDaosSections.ts +++ b/packages/stateful/command/hooks/usePinnedAndFilteredDaosSections.ts @@ -1,10 +1,10 @@ import { useTranslation } from 'react-i18next' +import { useSearchDaos } from '@dao-dao/state/subquery/daos' import { useLoadingFeaturedDaoCardInfos, useLoadingPinnedDaoCardInfos, -} from '@dao-dao/state' -import { useSearchDaos } from '@dao-dao/state/subquery/daos' +} from '@dao-dao/stateful' import { CommandModalContextSection, CommandModalContextUseSectionsOptions, diff --git a/packages/stateful/components/CreateDaoForm.tsx b/packages/stateful/components/CreateDaoForm.tsx index d1f5af7c8b..5702242d40 100644 --- a/packages/stateful/components/CreateDaoForm.tsx +++ b/packages/stateful/components/CreateDaoForm.tsx @@ -9,12 +9,6 @@ import toast from 'react-hot-toast' import { useTranslation } from 'react-i18next' import { useRecoilState } from 'recoil' -import { - CwAdminFactoryHooks, - useAwaitNextBlock, - usePinnedDaos, - useWalletProfile, -} from '@dao-dao/state' import { Button, CreateDaoPages, @@ -54,6 +48,12 @@ import { daoCreatedCardPropsAtom, newDaoAtom, } from '../atoms/newDao' +import { + CwAdminFactoryHooks, + useAwaitNextBlock, + usePinnedDaos, + useWalletProfile, +} from '../hooks' import { getAdapterById as getProposalModuleAdapterById } from '../proposal-module-adapter' import { CwdVotingCw20StakedAdapter, diff --git a/packages/stateful/components/DaoMemberCard.tsx b/packages/stateful/components/DaoMemberCard.tsx index 4a3655f29d..64751f6d6f 100644 --- a/packages/stateful/components/DaoMemberCard.tsx +++ b/packages/stateful/components/DaoMemberCard.tsx @@ -1,7 +1,8 @@ -import { useProfile } from '@dao-dao/state' import { DaoMemberCard as StatelessDaoMemberCard } from '@dao-dao/stateless' import { DaoMemberCardProps } from '@dao-dao/types/components/DaoMemberCard' +import { useProfile } from '../hooks' + export const DaoMemberCard = (props: Omit) => { const { profile } = useProfile({ walletAddress: props.address }) diff --git a/packages/stateful/components/DaoTokenDepositModal.tsx b/packages/stateful/components/DaoTokenDepositModal.tsx index 22c8e24f64..d652521f11 100644 --- a/packages/stateful/components/DaoTokenDepositModal.tsx +++ b/packages/stateful/components/DaoTokenDepositModal.tsx @@ -5,7 +5,6 @@ import toast from 'react-hot-toast' import { useTranslation } from 'react-i18next' import { useSetRecoilState } from 'recoil' -import { Cw20BaseHooks, useWalletProfile } from '@dao-dao/state/hooks' import { Cw20BaseSelectors, nativeDenomBalanceWithTimestampSelector, @@ -24,6 +23,8 @@ import { processError, } from '@dao-dao/utils' +import { Cw20BaseHooks, useWalletProfile } from '../hooks' + export type DaoTokenDepositModalProps = Omit< TokenDepositModalProps, 'loadingBalance' | 'onDeposit' | 'loading' | 'amount' | 'setAmount' diff --git a/packages/stateful/components/PfpkNftSelectionModal.tsx b/packages/stateful/components/PfpkNftSelectionModal.tsx index bddb894944..0d34a7bc96 100644 --- a/packages/stateful/components/PfpkNftSelectionModal.tsx +++ b/packages/stateful/components/PfpkNftSelectionModal.tsx @@ -9,7 +9,6 @@ import { useTranslation } from 'react-i18next' import { useGetLoopNftsQuery, - useWalletProfile, walletStargazeNftCardInfosSelector, } from '@dao-dao/state' import { @@ -28,6 +27,7 @@ import { processError, } from '@dao-dao/utils' +import { useWalletProfile } from '../hooks' import { SuspenseLoader } from './SuspenseLoader' export interface PfpkNftSelectionModalProps diff --git a/packages/stateful/components/ProfileDisplay.tsx b/packages/stateful/components/ProfileDisplay.tsx index 8d3f8106a9..482408c44b 100644 --- a/packages/stateful/components/ProfileDisplay.tsx +++ b/packages/stateful/components/ProfileDisplay.tsx @@ -1,7 +1,8 @@ -import { useProfile } from '@dao-dao/state' import { ProfileDisplay as StatelessProfileDisplay } from '@dao-dao/stateless' import { ProfileDisplayProps } from '@dao-dao/types' +import { useProfile } from '../hooks' + export const ProfileDisplay = ( props: Omit ) => { diff --git a/packages/stateful/components/ProposalList.tsx b/packages/stateful/components/ProposalList.tsx index f46a381b0a..b294d99874 100644 --- a/packages/stateful/components/ProposalList.tsx +++ b/packages/stateful/components/ProposalList.tsx @@ -4,7 +4,6 @@ import { useEffect, useMemo, useState } from 'react' import { useRecoilCallback } from 'recoil' -import { useVotingModule } from '@dao-dao/state' import { Loader, Logo, @@ -12,6 +11,7 @@ import { useDaoInfoContext, } from '@dao-dao/stateless' +import { useVotingModule } from '../hooks' import { matchAndLoadCommon } from '../proposal-module-adapter' import { ProposalLine, ProposalLineProps } from './ProposalLine' diff --git a/packages/stateful/components/SidebarWallet.tsx b/packages/stateful/components/SidebarWallet.tsx index 820ffefd12..c3be4b2458 100644 --- a/packages/stateful/components/SidebarWallet.tsx +++ b/packages/stateful/components/SidebarWallet.tsx @@ -1,9 +1,9 @@ import { WalletConnectionStatus, useWalletManager } from '@noahsaso/cosmodal' -import { useWalletProfile } from '@dao-dao/state' import { SidebarWallet as OriginalSidebarWallet } from '@dao-dao/stateless' import { NATIVE_DECIMALS, NATIVE_DENOM, nativeTokenLabel } from '@dao-dao/utils' +import { useWalletProfile } from '../hooks' import { SuspenseLoader } from './SuspenseLoader' export const SidebarWallet = () => { diff --git a/packages/state/featured_daos.json b/packages/stateful/featured_daos.json similarity index 100% rename from packages/state/featured_daos.json rename to packages/stateful/featured_daos.json diff --git a/packages/state/hooks/clients/Cw20Base.ts b/packages/stateful/hooks/contracts/Cw20Base.ts similarity index 90% rename from packages/state/hooks/clients/Cw20Base.ts rename to packages/stateful/hooks/contracts/Cw20Base.ts index 38d8c6fc18..cef69911a0 100644 --- a/packages/state/hooks/clients/Cw20Base.ts +++ b/packages/stateful/hooks/contracts/Cw20Base.ts @@ -4,12 +4,12 @@ import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' import { useCallback } from 'react' import { useRecoilValueLoadable } from 'recoil' -import { Cw20BaseClient as ExecuteClient } from '../../clients/Cw20Base' +import { Cw20BaseClient as ExecuteClient } from '@dao-dao/state/contracts/Cw20Base' import { ExecuteClientParams, executeClient, -} from '../../recoil/selectors/clients/Cw20Base' -import { FunctionKeyOf } from '../../types' +} from '@dao-dao/state/recoil/selectors/contracts/Cw20Base' +import { FunctionKeyOf } from '@dao-dao/types' // This hook wrapper lets us easily make hooks out of all execution functions on // the contract clients, without having to fetch the `executeClient` selector as diff --git a/packages/state/hooks/clients/Cw20Stake.ts b/packages/stateful/hooks/contracts/Cw20Stake.ts similarity index 87% rename from packages/state/hooks/clients/Cw20Stake.ts rename to packages/stateful/hooks/contracts/Cw20Stake.ts index 23cec335e3..dd4ac1eea7 100644 --- a/packages/state/hooks/clients/Cw20Stake.ts +++ b/packages/stateful/hooks/contracts/Cw20Stake.ts @@ -4,12 +4,12 @@ import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' import { useCallback } from 'react' import { useRecoilValueLoadable } from 'recoil' -import { Cw20StakeClient as ExecuteClient } from '../../clients/Cw20Stake' +import { Cw20StakeClient as ExecuteClient } from '@dao-dao/state/contracts/Cw20Stake' import { ExecuteClientParams, executeClient, -} from '../../recoil/selectors/clients/Cw20Stake' -import { FunctionKeyOf } from '../../types' +} from '@dao-dao/state/recoil/selectors/contracts/Cw20Stake' +import { FunctionKeyOf } from '@dao-dao/types' // This hook wrapper lets us easily make hooks out of all execution functions on // the contract clients, without having to fetch the `executeClient` selector as diff --git a/packages/state/hooks/clients/CwAdminFactory.ts b/packages/stateful/hooks/contracts/CwAdminFactory.ts similarity index 85% rename from packages/state/hooks/clients/CwAdminFactory.ts rename to packages/stateful/hooks/contracts/CwAdminFactory.ts index f47547799e..ef6bdbfcf1 100644 --- a/packages/state/hooks/clients/CwAdminFactory.ts +++ b/packages/stateful/hooks/contracts/CwAdminFactory.ts @@ -4,12 +4,12 @@ import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' import { useCallback } from 'react' import { useRecoilValueLoadable } from 'recoil' -import { CwAdminFactoryClient as ExecuteClient } from '../../clients/CwAdminFactory' +import { CwAdminFactoryClient as ExecuteClient } from '@dao-dao/state/contracts/CwAdminFactory' import { ExecuteClientParams, executeClient, -} from '../../recoil/selectors/clients/CwAdminFactory' -import { FunctionKeyOf } from '../../types' +} from '@dao-dao/state/recoil/selectors/contracts/CwAdminFactory' +import { FunctionKeyOf } from '@dao-dao/types' // This hook wrapper lets us easily make hooks out of all execution functions on // the contract clients, without having to fetch the `executeClient` selector as diff --git a/packages/state/hooks/clients/CwdVotingNativeStaked.ts b/packages/stateful/hooks/contracts/CwdVotingNativeStaked.ts similarity index 85% rename from packages/state/hooks/clients/CwdVotingNativeStaked.ts rename to packages/stateful/hooks/contracts/CwdVotingNativeStaked.ts index 8254a98f3c..be1be4086d 100644 --- a/packages/state/hooks/clients/CwdVotingNativeStaked.ts +++ b/packages/stateful/hooks/contracts/CwdVotingNativeStaked.ts @@ -4,12 +4,12 @@ import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' import { useCallback } from 'react' import { useRecoilValueLoadable } from 'recoil' -import { CwdVotingNativeStakedClient as ExecuteClient } from '../../clients/CwdVotingNativeStaked' +import { CwdVotingNativeStakedClient as ExecuteClient } from '@dao-dao/state/contracts/CwdVotingNativeStaked' import { ExecuteClientParams, executeClient, -} from '../../recoil/selectors/clients/CwdVotingNativeStaked' -import { FunctionKeyOf } from '../../types' +} from '@dao-dao/state/recoil/selectors/contracts/CwdVotingNativeStaked' +import { FunctionKeyOf } from '@dao-dao/types' // This hook wrapper lets us easily make hooks out of all execution functions on // the contract clients, without having to fetch the `executeClient` selector as diff --git a/packages/state/hooks/clients/index.ts b/packages/stateful/hooks/contracts/index.ts similarity index 70% rename from packages/state/hooks/clients/index.ts rename to packages/stateful/hooks/contracts/index.ts index 7cbdff69c1..97e96ad7f3 100644 --- a/packages/state/hooks/clients/index.ts +++ b/packages/stateful/hooks/contracts/index.ts @@ -1,6 +1,4 @@ export * as Cw20BaseHooks from './Cw20Base' export * as Cw20StakeHooks from './Cw20Stake' export * as CwAdminFactoryHooks from './CwAdminFactory' -export * as CwCoreV1Hooks from './CwCore.v1' -export * as CwdCoreV2Hooks from './CwdCore.v2' export * as CwdVotingNativeStakedHooks from './CwdVotingNativeStaked' diff --git a/packages/stateful/hooks/index.ts b/packages/stateful/hooks/index.ts index 0a88258510..8778424650 100644 --- a/packages/stateful/hooks/index.ts +++ b/packages/stateful/hooks/index.ts @@ -1,2 +1,10 @@ +export * from './contracts' + +export * from './useAwaitNextBlock' export * from './useEncodedCwdProposalSinglePrefill' export * from './useInbox' +export * from './useLoadingDaoCardInfos' +export * from './usePinnedDaos' +export * from './useProfile' +export * from './useVotingModule' +export * from './useWalletProfile' diff --git a/packages/state/hooks/useAwaitNextBlock.ts b/packages/stateful/hooks/useAwaitNextBlock.ts similarity index 98% rename from packages/state/hooks/useAwaitNextBlock.ts rename to packages/stateful/hooks/useAwaitNextBlock.ts index d6b842c02d..185b018804 100644 --- a/packages/state/hooks/useAwaitNextBlock.ts +++ b/packages/stateful/hooks/useAwaitNextBlock.ts @@ -4,7 +4,7 @@ import { useRecoilValue, useSetRecoilState } from 'recoil' import { cosmWasmClientForChainSelector, refreshBlockHeightAtom, -} from '../recoil' +} from '@dao-dao/state' // Returns a function that polls the chain's block height and resolves once it // increments. diff --git a/packages/state/hooks/useLoadingDaoCardInfos.ts b/packages/stateful/hooks/useLoadingDaoCardInfos.ts similarity index 96% rename from packages/state/hooks/useLoadingDaoCardInfos.ts rename to packages/stateful/hooks/useLoadingDaoCardInfos.ts index e7e39b0657..f0371b9f6f 100644 --- a/packages/state/hooks/useLoadingDaoCardInfos.ts +++ b/packages/stateful/hooks/useLoadingDaoCardInfos.ts @@ -1,10 +1,10 @@ import { ChainInfoID } from '@noahsaso/cosmodal' +import { GetDaosApiName, useGetDaos } from '@dao-dao/state' import { DaoCardInfo, LoadingData } from '@dao-dao/types' import { CHAIN_ID, getFallbackImage } from '@dao-dao/utils' import featuredDaos from '../featured_daos.json' -import { GetDaosApiName, useGetDaos } from '../subquery/daos/info' import { usePinnedDaos } from './usePinnedDaos' export interface UseLoadingDaoCardInfosOptions { diff --git a/packages/state/hooks/usePinnedDaos.ts b/packages/stateful/hooks/usePinnedDaos.ts similarity index 92% rename from packages/state/hooks/usePinnedDaos.ts rename to packages/stateful/hooks/usePinnedDaos.ts index e72b22defd..e4a7a2eeb7 100644 --- a/packages/state/hooks/usePinnedDaos.ts +++ b/packages/stateful/hooks/usePinnedDaos.ts @@ -1,7 +1,7 @@ import { useCallback } from 'react' import { useRecoilState } from 'recoil' -import { pinnedAddressesAtom } from '../recoil/atoms/pinned' +import { pinnedAddressesAtom } from '@dao-dao/state' export const usePinnedDaos = () => { const [pinnedAddresses, setPinnedAddresses] = diff --git a/packages/state/hooks/useProfile.ts b/packages/stateful/hooks/useProfile.ts similarity index 98% rename from packages/state/hooks/useProfile.ts rename to packages/stateful/hooks/useProfile.ts index cb1b115601..ad5100b6be 100644 --- a/packages/state/hooks/useProfile.ts +++ b/packages/stateful/hooks/useProfile.ts @@ -1,14 +1,13 @@ import { constSelector, useRecoilValueLoadable } from 'recoil' -import { useCachedLoadable } from '@dao-dao/stateless' -import { LoadingData, WalletProfile, WithChainId } from '@dao-dao/types' -import { getFallbackImage, loadableToLoadingData } from '@dao-dao/utils' - import { keplrProfileImageSelector, walletHexPublicKeySelector, walletProfileSelector, -} from '../recoil/selectors/wallet' +} from '@dao-dao/state' +import { useCachedLoadable } from '@dao-dao/stateless' +import { LoadingData, WalletProfile, WithChainId } from '@dao-dao/types' +import { getFallbackImage, loadableToLoadingData } from '@dao-dao/utils' export type UseProfileOptions = WithChainId< | { diff --git a/packages/state/hooks/useVotingModule.ts b/packages/stateful/hooks/useVotingModule.ts similarity index 97% rename from packages/state/hooks/useVotingModule.ts rename to packages/stateful/hooks/useVotingModule.ts index 7289c6047e..a58c531dac 100644 --- a/packages/state/hooks/useVotingModule.ts +++ b/packages/stateful/hooks/useVotingModule.ts @@ -1,10 +1,9 @@ import { useWallet } from '@noahsaso/cosmodal' import { constSelector, useRecoilValue } from 'recoil' +import { CwdCoreV2Selectors } from '@dao-dao/state' import { useCachedLoadable } from '@dao-dao/stateless' -import { CwdCoreV2Selectors } from '../recoil/selectors' - interface UseVotingModuleOptions { chainId?: string fetchMembership?: boolean diff --git a/packages/state/hooks/useWalletProfile.tsx b/packages/stateful/hooks/useWalletProfile.tsx similarity index 99% rename from packages/state/hooks/useWalletProfile.tsx rename to packages/stateful/hooks/useWalletProfile.tsx index c239b2def6..292134ace0 100644 --- a/packages/state/hooks/useWalletProfile.tsx +++ b/packages/stateful/hooks/useWalletProfile.tsx @@ -7,6 +7,13 @@ import { import { useCallback, useEffect, useRef, useState } from 'react' import { useSetRecoilState } from 'recoil' +import { + nativeBalanceSelector, + nativeBalancesFetchedAtSelector, + nativeDelegatedBalanceSelector, + refreshWalletBalancesIdAtom, + refreshWalletProfileAtom, +} from '@dao-dao/state' import { useCachedLoadable } from '@dao-dao/stateless' import { LoadingData, WalletProfile, WalletProfileUpdate } from '@dao-dao/types' import { @@ -15,13 +22,6 @@ import { convertMicroDenomToDenomWithDecimals, } from '@dao-dao/utils' -import { - nativeBalanceSelector, - nativeBalancesFetchedAtSelector, - nativeDelegatedBalanceSelector, - refreshWalletBalancesIdAtom, - refreshWalletProfileAtom, -} from '../recoil' import { useProfile } from './useProfile' export interface UseWalletProfileReturn { diff --git a/packages/stateful/package.json b/packages/stateful/package.json index c2aba221d3..09c6910f3d 100644 --- a/packages/stateful/package.json +++ b/packages/stateful/package.json @@ -2,6 +2,7 @@ "name": "@dao-dao/stateful", "version": "2.0.1", "scripts": { + "build": "tsc", "format": "eslint . --fix", "lint": "eslint ." }, diff --git a/packages/stateful/proposal-module-adapter/adapters/CwdProposalSingle/common/components/NewProposal.tsx b/packages/stateful/proposal-module-adapter/adapters/CwdProposalSingle/common/components/NewProposal.tsx index 1b68b1e087..9685f2b759 100644 --- a/packages/stateful/proposal-module-adapter/adapters/CwdProposalSingle/common/components/NewProposal.tsx +++ b/packages/stateful/proposal-module-adapter/adapters/CwdProposalSingle/common/components/NewProposal.tsx @@ -14,7 +14,6 @@ import { } from 'recoil' import { - Cw20BaseHooks, Cw20BaseSelectors, CwCoreV1Selectors, blockHeightSelector, @@ -22,8 +21,6 @@ import { cosmWasmClientForChainSelector, nativeDenomBalanceSelector, refreshWalletBalancesIdAtom, - useAwaitNextBlock, - useVotingModule, } from '@dao-dao/state' import { useCachedLoadable, useDaoInfoContext } from '@dao-dao/stateless' import { @@ -43,6 +40,11 @@ import { } from '@dao-dao/utils' import { useActions } from '../../../../../actions' +import { + Cw20BaseHooks, + useAwaitNextBlock, + useVotingModule, +} from '../../../../../hooks' import { useVotingModuleAdapter } from '../../../../../voting-module-adapter' import { usePropose as useProposePrePropose } from '../../contracts/CwdPreProposeSingle.hooks' import { proposalSelector } from '../../contracts/CwdProposalSingle.common.recoil' diff --git a/packages/stateful/proposal-module-adapter/adapters/CwdProposalSingle/common/ui/NewProposal.tsx b/packages/stateful/proposal-module-adapter/adapters/CwdProposalSingle/common/ui/NewProposal.tsx index 78b97d5de8..5e84c33077 100644 --- a/packages/stateful/proposal-module-adapter/adapters/CwdProposalSingle/common/ui/NewProposal.tsx +++ b/packages/stateful/proposal-module-adapter/adapters/CwdProposalSingle/common/ui/NewProposal.tsx @@ -15,7 +15,6 @@ import { } from 'react-hook-form' import { useTranslation } from 'react-i18next' -import { useWalletProfile } from '@dao-dao/state' import { ActionCardLoader, ActionSelector, @@ -47,6 +46,7 @@ import { } from '@dao-dao/utils' import { SuspenseLoader } from '../../../../../components/SuspenseLoader' +import { useWalletProfile } from '../../../../../hooks' import { NewProposalData, NewProposalForm } from '../../types' enum ProposeSubmitValue { diff --git a/packages/stateful/proposal-module-adapter/adapters/CwdProposalSingle/components/ProposalLine/index.tsx b/packages/stateful/proposal-module-adapter/adapters/CwdProposalSingle/components/ProposalLine/index.tsx index d24bdb09db..ca5f5508f6 100644 --- a/packages/stateful/proposal-module-adapter/adapters/CwdProposalSingle/components/ProposalLine/index.tsx +++ b/packages/stateful/proposal-module-adapter/adapters/CwdProposalSingle/components/ProposalLine/index.tsx @@ -1,8 +1,8 @@ -import { useVotingModule } from '@dao-dao/state/hooks' import { ProposalLine as StatelessProposalLine } from '@dao-dao/stateless' import { BaseProposalLineProps } from '@dao-dao/types' import { Status } from '@dao-dao/types/contracts/CwdProposalSingle.common' +import { useVotingModule } from '../../../../../hooks' import { useProposalModuleAdapterOptions } from '../../../../react' import { useProposal, diff --git a/packages/stateful/proposal-module-adapter/adapters/CwdProposalSingle/components/ProposalStatusAndInfo.tsx b/packages/stateful/proposal-module-adapter/adapters/CwdProposalSingle/components/ProposalStatusAndInfo.tsx index aeec6068dc..70226a7604 100644 --- a/packages/stateful/proposal-module-adapter/adapters/CwdProposalSingle/components/ProposalStatusAndInfo.tsx +++ b/packages/stateful/proposal-module-adapter/adapters/CwdProposalSingle/components/ProposalStatusAndInfo.tsx @@ -15,7 +15,6 @@ import toast from 'react-hot-toast' import { useTranslation } from 'react-i18next' import { useRecoilValue } from 'recoil' -import { useVotingModule } from '@dao-dao/state' import { CopyToClipboardUnderline, IconButtonLink, @@ -38,6 +37,7 @@ import { import { ButtonLink } from '../../../../components/ButtonLink' import { ProfileDisplay } from '../../../../components/ProfileDisplay' +import { useVotingModule } from '../../../../hooks' import { useProposalModuleAdapterOptions } from '../../../react' import { configSelector } from '../contracts/CwdProposalSingle.common.recoil' import { diff --git a/packages/stateful/voting-module-adapter/adapters/CwdVotingCw20Staked/components/ProfileCardMemberInfo/StakingModal.tsx b/packages/stateful/voting-module-adapter/adapters/CwdVotingCw20Staked/components/ProfileCardMemberInfo/StakingModal.tsx index 1bb562a540..8d4b33c8e2 100644 --- a/packages/stateful/voting-module-adapter/adapters/CwdVotingCw20Staked/components/ProfileCardMemberInfo/StakingModal.tsx +++ b/packages/stateful/voting-module-adapter/adapters/CwdVotingCw20Staked/components/ProfileCardMemberInfo/StakingModal.tsx @@ -10,13 +10,9 @@ import { } from 'recoil' import { - Cw20BaseHooks, - Cw20StakeHooks, Cw20StakeSelectors, refreshDaoVotingPowerAtom, stakingLoadingAtom, - useAwaitNextBlock, - useWalletProfile, } from '@dao-dao/state' import { Modal, @@ -32,6 +28,12 @@ import { } from '@dao-dao/utils' import { SuspenseLoader } from '../../../../../components' +import { + Cw20BaseHooks, + Cw20StakeHooks, + useAwaitNextBlock, + useWalletProfile, +} from '../../../../../hooks' import { useVotingModuleAdapterOptions } from '../../../../react/context' import { useGovernanceTokenInfo, useStakingInfo } from '../../hooks' diff --git a/packages/stateful/voting-module-adapter/adapters/CwdVotingCw20Staked/components/ProfileCardMemberInfo/index.tsx b/packages/stateful/voting-module-adapter/adapters/CwdVotingCw20Staked/components/ProfileCardMemberInfo/index.tsx index 022dc3c790..1d722892ea 100644 --- a/packages/stateful/voting-module-adapter/adapters/CwdVotingCw20Staked/components/ProfileCardMemberInfo/index.tsx +++ b/packages/stateful/voting-module-adapter/adapters/CwdVotingCw20Staked/components/ProfileCardMemberInfo/index.tsx @@ -5,13 +5,10 @@ import { useTranslation } from 'react-i18next' import { useRecoilValue } from 'recoil' import { - Cw20StakeHooks, blockHeightSelector, blocksPerYearSelector, junoswapPoolsListSelector, stakingLoadingAtom, - useAwaitNextBlock, - useWalletProfile, } from '@dao-dao/state' import { useCachedLoadable, useDaoInfoContext } from '@dao-dao/stateless' import { @@ -28,6 +25,11 @@ import { processError, } from '@dao-dao/utils' +import { + Cw20StakeHooks, + useAwaitNextBlock, + useWalletProfile, +} from '../../../../../hooks' import { ProfileCardMemberInfoTokens } from '../../../../components' import { useGovernanceTokenInfo, useStakingInfo } from '../../hooks' import { StakingModal } from './StakingModal' diff --git a/packages/stateful/voting-module-adapter/adapters/CwdVotingCw20Staked/hooks/useDaoInfoBarItems.tsx b/packages/stateful/voting-module-adapter/adapters/CwdVotingCw20Staked/hooks/useDaoInfoBarItems.tsx index 66e485d62e..a8e3a6ee68 100644 --- a/packages/stateful/voting-module-adapter/adapters/CwdVotingCw20Staked/hooks/useDaoInfoBarItems.tsx +++ b/packages/stateful/voting-module-adapter/adapters/CwdVotingCw20Staked/hooks/useDaoInfoBarItems.tsx @@ -1,13 +1,13 @@ import { LayersOutlined, PeopleAltOutlined } from '@mui/icons-material' import { useTranslation } from 'react-i18next' -import { useVotingModule } from '@dao-dao/state' import { DaoInfoBarItem, TokenAmountDisplay } from '@dao-dao/stateless' import { convertMicroDenomToDenomWithDecimals, formatPercentOf100, } from '@dao-dao/utils' +import { useVotingModule } from '../../../../hooks' import { useVotingModuleAdapterOptions } from '../../../react/context' import { useGovernanceTokenInfo } from './useGovernanceTokenInfo' diff --git a/packages/stateful/voting-module-adapter/adapters/CwdVotingCw4/components/MembersTab.tsx b/packages/stateful/voting-module-adapter/adapters/CwdVotingCw4/components/MembersTab.tsx index 0bcc59af2e..7a23304846 100644 --- a/packages/stateful/voting-module-adapter/adapters/CwdVotingCw4/components/MembersTab.tsx +++ b/packages/stateful/voting-module-adapter/adapters/CwdVotingCw4/components/MembersTab.tsx @@ -1,13 +1,15 @@ import { ComponentPropsWithoutRef } from 'react' import { useTranslation } from 'react-i18next' -import { useVotingModule } from '@dao-dao/state' import { MembersTab as StatelessMembersTab } from '@dao-dao/stateless' import { ActionKey } from '@dao-dao/types' import { useActionForKey } from '../../../../actions' import { ButtonLink, DaoMemberCard } from '../../../../components' -import { useEncodedCwdProposalSinglePrefill } from '../../../../hooks' +import { + useEncodedCwdProposalSinglePrefill, + useVotingModule, +} from '../../../../hooks' import { useVotingModuleAdapterOptions } from '../../../react/context' import { useVotingModule as useCw4VotingModule } from '../hooks/useVotingModule' diff --git a/packages/stateful/voting-module-adapter/adapters/CwdVotingCw4/components/ProfileCardMemberInfo.tsx b/packages/stateful/voting-module-adapter/adapters/CwdVotingCw4/components/ProfileCardMemberInfo.tsx index 3ba6fc1bc7..2b6719a804 100644 --- a/packages/stateful/voting-module-adapter/adapters/CwdVotingCw4/components/ProfileCardMemberInfo.tsx +++ b/packages/stateful/voting-module-adapter/adapters/CwdVotingCw4/components/ProfileCardMemberInfo.tsx @@ -1,9 +1,9 @@ import { useTranslation } from 'react-i18next' -import { useVotingModule } from '@dao-dao/state' import { useDaoInfoContext } from '@dao-dao/stateless' import { BaseProfileCardMemberInfoProps } from '@dao-dao/types' +import { useVotingModule } from '../../../../hooks' import { useVotingModuleAdapterOptions } from '../../../react/context' import { ProfileCardMemberInfo as StatelessProfileCardMemberInfo } from '../ui/ProfileCardMemberInfo' diff --git a/packages/stateful/voting-module-adapter/adapters/CwdVotingNativeStaked/components/ProfileCardMemberInfo/StakingModal.tsx b/packages/stateful/voting-module-adapter/adapters/CwdVotingNativeStaked/components/ProfileCardMemberInfo/StakingModal.tsx index 3253c5b7ea..1ca28d5856 100644 --- a/packages/stateful/voting-module-adapter/adapters/CwdVotingNativeStaked/components/ProfileCardMemberInfo/StakingModal.tsx +++ b/packages/stateful/voting-module-adapter/adapters/CwdVotingNativeStaked/components/ProfileCardMemberInfo/StakingModal.tsx @@ -5,13 +5,7 @@ import toast from 'react-hot-toast' import { useTranslation } from 'react-i18next' import { useRecoilState, useSetRecoilState } from 'recoil' -import { - CwdVotingNativeStakedHooks, - refreshDaoVotingPowerAtom, - stakingLoadingAtom, - useAwaitNextBlock, - useWalletProfile, -} from '@dao-dao/state' +import { refreshDaoVotingPowerAtom, stakingLoadingAtom } from '@dao-dao/state' import { Modal, StakingMode, @@ -25,6 +19,11 @@ import { } from '@dao-dao/utils' import { SuspenseLoader } from '../../../../../components' +import { + CwdVotingNativeStakedHooks, + useAwaitNextBlock, + useWalletProfile, +} from '../../../../../hooks' import { useVotingModuleAdapterOptions } from '../../../../react/context' import { useGovernanceTokenInfo, useStakingInfo } from '../../hooks' diff --git a/packages/stateful/voting-module-adapter/adapters/CwdVotingNativeStaked/components/ProfileCardMemberInfo/index.tsx b/packages/stateful/voting-module-adapter/adapters/CwdVotingNativeStaked/components/ProfileCardMemberInfo/index.tsx index 133615d7c0..82539526fb 100644 --- a/packages/stateful/voting-module-adapter/adapters/CwdVotingNativeStaked/components/ProfileCardMemberInfo/index.tsx +++ b/packages/stateful/voting-module-adapter/adapters/CwdVotingNativeStaked/components/ProfileCardMemberInfo/index.tsx @@ -5,13 +5,10 @@ import { useTranslation } from 'react-i18next' import { useRecoilValue } from 'recoil' import { - CwdVotingNativeStakedHooks, blockHeightSelector, blocksPerYearSelector, junoswapPoolsListSelector, stakingLoadingAtom, - useAwaitNextBlock, - useWalletProfile, } from '@dao-dao/state' import { useCachedLoadable, useDaoInfoContext } from '@dao-dao/stateless' import { @@ -28,6 +25,11 @@ import { processError, } from '@dao-dao/utils' +import { + CwdVotingNativeStakedHooks, + useAwaitNextBlock, + useWalletProfile, +} from '../../../../../hooks' import { ProfileCardMemberInfoTokens } from '../../../../components' import { useVotingModuleAdapterOptions } from '../../../../react/context' import { useGovernanceTokenInfo, useStakingInfo } from '../../hooks' diff --git a/packages/stateless/README.md b/packages/stateless/README.md index e6eae80d59..8246fc622b 100644 --- a/packages/stateless/README.md +++ b/packages/stateless/README.md @@ -1,3 +1,14 @@ # @dao-dao/stateless -Reusable React components and stylesheets for various projects +React components, React hooks, and other stateless rendering utilities which do +not access live data. + +## Folders + +| Folder | Summary | +| ------------------------------ | ----------------------------------------------------- | +| [`components`](./components) | Individual React components. | +| [`hooks`](./hooks) | React hooks. | +| [`pages`](./pages) | React components pieced together into complete pages. | +| [`styles`](./styles/index.css) | CSS. | +| [`theme`](./theme/index.tsx) | Theme system components and hooks. | diff --git a/packages/storybook/README.md b/packages/storybook/README.md index 78bd01d335..ea5078801f 100644 --- a/packages/storybook/README.md +++ b/packages/storybook/README.md @@ -1,6 +1,7 @@ # @dao-dao/storybook -Storybook renderer for all packages in the monorepo. +[Storybook](https://storybook.js.org/) renderer for all packages in the +monorepo. ## Running diff --git a/packages/types/README.md b/packages/types/README.md index f17d2854f1..02be5e4774 100644 --- a/packages/types/README.md +++ b/packages/types/README.md @@ -1,3 +1,3 @@ # @dao-dao/types -A collection of types used in various packages. +A collection of types used across packages. diff --git a/packages/utils/README.md b/packages/utils/README.md index 5c4142c622..ce7701fe22 100644 --- a/packages/utils/README.md +++ b/packages/utils/README.md @@ -1,3 +1,3 @@ # @dao-dao/utils -Collection of TypeScript utilities +A collection of simple utility functions used across packages.