Skip to content

Commit

Permalink
Merge pull request #1316 from DA0-DA0/development
Browse files Browse the repository at this point in the history
Deploy Cosmos Kit
  • Loading branch information
NoahSaso authored Aug 3, 2023
2 parents 1e3d234 + ab5381f commit 692a089
Show file tree
Hide file tree
Showing 134 changed files with 2,253 additions and 1,737 deletions.
10 changes: 7 additions & 3 deletions apps/dapp/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ const config = {
'@dao-dao/stateful',
'@dao-dao/i18n',
'@dao-dao/types',
'@noahsaso/cosmodal',
'@cosmos-kit/web3auth',
],
// Because @cosmos-kit/web3auth uses a Worker ESM import.
experimental: {
esmExternals: 'loose',
},
webpack: (config) => {
// @noahsaso/cosmodal uses @toruslabs/eccrypto, which uses `stream`. This
// needs to be polyfilled.
// @cosmos-kit/web3auth uses eccrypto, which uses `stream`. This needs to be
// polyfilled.
config.resolve.alias['stream'] = 'stream-browserify'
return config
},
Expand Down
2 changes: 0 additions & 2 deletions apps/dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"ts:watch": "ts --watch"
},
"dependencies": {
"@cosmjs/encoding": "^0.30.1",
"@dao-dao/i18n": "2.2.0",
"@dao-dao/state": "2.2.0",
"@dao-dao/stateful": "2.2.0",
Expand All @@ -31,7 +30,6 @@
"@keplr-wallet/stores": "^0.11.49",
"@keplr-wallet/types": "^0.11.49",
"@mui/icons-material": "^5.10.3",
"@noahsaso/cosmodal": "0.11.4",
"@sentry/nextjs": "^7.7.0",
"@types/formidable": "^2.0.5",
"cors": "^2.8.5",
Expand Down
14 changes: 5 additions & 9 deletions apps/dapp/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
activeThemeAtom,
mountedInBrowserAtom,
navigatingToHrefAtom,
web3AuthPromptAtom,
} from '@dao-dao/state'
import {
AppContextProvider,
Expand All @@ -29,7 +30,7 @@ import {
ThemeProvider,
ToastNotifications,
} from '@dao-dao/stateless'
import { DaoPageMode, Web3AuthPrompt } from '@dao-dao/types'
import { DaoPageMode } from '@dao-dao/types'
import { SITE_IMAGE, SITE_URL } from '@dao-dao/utils'

const InnerApp = ({ Component, pageProps }: AppProps) => {
Expand All @@ -43,9 +44,7 @@ const InnerApp = ({ Component, pageProps }: AppProps) => {
const [theme, setTheme] = useRecoilState(activeThemeAtom)
const [themeChangeCount, setThemeChangeCount] = useState(0)

const [web3AuthPrompt, setWeb3AuthPrompt] = useState<
Web3AuthPrompt | undefined
>()
const setWeb3AuthPrompt = useSetRecoilState(web3AuthPromptAtom)

// Indicate that we are mounted.
useEffect(() => setMountedInBrowser(true), [setMountedInBrowser])
Expand Down Expand Up @@ -82,11 +81,8 @@ const InnerApp = ({ Component, pageProps }: AppProps) => {
<PageLoader />
) : (
<WalletProvider setWeb3AuthPrompt={setWeb3AuthPrompt}>
{/* AppContextProvider uses wallet context. */}
<AppContextProvider
mode={DaoPageMode.Dapp}
web3AuthPrompt={web3AuthPrompt}
>
{/* AppContextProvider uses wallet context via the inbox. */}
<AppContextProvider mode={DaoPageMode.Dapp}>
<DappLayout>
<Component {...pageProps} />
</DappLayout>
Expand Down
8 changes: 4 additions & 4 deletions apps/dapp/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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 { useWallet } from '@noahsaso/cosmodal'
import { GetStaticProps, NextPage } from 'next'
import { useSetRecoilState } from 'recoil'

Expand All @@ -13,11 +12,12 @@ import {
ProfileHomeCard,
useLoadingFeaturedDaoCardInfos,
useLoadingFollowingDaoCardInfos,
useWallet,
} from '@dao-dao/stateful'
import { Home } from '@dao-dao/stateless'

const HomePage: NextPage = () => {
const { connected } = useWallet()
const { isWalletConnected } = useWallet()

const setCommandModalVisible = useSetRecoilState(commandModalVisibleAtom)

Expand All @@ -26,7 +26,7 @@ const HomePage: NextPage = () => {

return (
<Home
connected={connected}
connected={isWalletConnected}
featuredDaosProps={{
Component: DaoCard,
items: featuredDaosLoading,
Expand All @@ -37,7 +37,7 @@ const HomePage: NextPage = () => {
followingDaos: followingDaosLoading,
}}
rightSidebarContent={
connected ? <ProfileHomeCard /> : <ProfileDisconnectedCard />
isWalletConnected ? <ProfileHomeCard /> : <ProfileDisconnectedCard />
}
/>
)
Expand Down
Binary file removed apps/dapp/public/walletconnect-keplr.png
Binary file not shown.
Binary file removed apps/dapp/public/walletconnect.png
Binary file not shown.
10 changes: 7 additions & 3 deletions apps/sda/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ const config = {
'@dao-dao/stateful',
'@dao-dao/i18n',
'@dao-dao/types',
'@noahsaso/cosmodal',
'@cosmos-kit/web3auth',
],
// Because @cosmos-kit/web3auth uses a Worker ESM import.
experimental: {
esmExternals: 'loose',
},
webpack: (config) => {
// @noahsaso/cosmodal uses @toruslabs/eccrypto, which uses `stream`. This
// needs to be polyfilled.
// @cosmos-kit/web3auth uses eccrypto, which uses `stream`. This needs to be
// polyfilled.
config.resolve.alias['stream'] = 'stream-browserify'
return config
},
Expand Down
1 change: 0 additions & 1 deletion apps/sda/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"@keplr-wallet/stores": "^0.11.49",
"@keplr-wallet/types": "^0.11.49",
"@mui/icons-material": "^5.10.3",
"@noahsaso/cosmodal": "0.11.4",
"@sentry/nextjs": "^7.7.0",
"@types/formidable": "^2.0.5",
"cors": "^2.8.5",
Expand Down
14 changes: 5 additions & 9 deletions apps/sda/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
activeThemeAtom,
mountedInBrowserAtom,
navigatingToHrefAtom,
web3AuthPromptAtom,
} from '@dao-dao/state'
import {
AppContextProvider,
Expand All @@ -31,7 +32,7 @@ import {
ThemeProvider,
ToastNotifications,
} from '@dao-dao/stateless'
import { DaoPageMode, Web3AuthPrompt } from '@dao-dao/types'
import { DaoPageMode } from '@dao-dao/types'
import { SITE_IMAGE, SITE_URL } from '@dao-dao/utils'

const InnerApp = ({
Expand All @@ -51,9 +52,7 @@ const InnerApp = ({
const [theme, setTheme] = useRecoilState(activeThemeAtom)
const [themeChangeCount, setThemeChangeCount] = useState(0)

const [web3AuthPrompt, setWeb3AuthPrompt] = useState<
Web3AuthPrompt | undefined
>()
const setWeb3AuthPrompt = useSetRecoilState(web3AuthPromptAtom)

// Indicate that we are mounted.
useEffect(() => setMountedInBrowser(true), [setMountedInBrowser])
Expand Down Expand Up @@ -95,11 +94,8 @@ const InnerApp = ({
<Component {...pageProps} />
) : (
<WalletProvider setWeb3AuthPrompt={setWeb3AuthPrompt}>
{/* AppContextProvider uses wallet context. */}
<AppContextProvider
mode={DaoPageMode.Sda}
web3AuthPrompt={web3AuthPrompt}
>
{/* AppContextProvider uses wallet context via the inbox. */}
<AppContextProvider mode={DaoPageMode.Sda}>
{/* All non-error/discord redirect SDA pages are a DAO page. */}
<DaoPageWrapper setIcon={setIcon} {...pageProps}>
{/* SdaLayout needs DaoPageWrapper for navigation tabs. */}
Expand Down
Binary file removed apps/sda/public/walletconnect-keplr.png
Binary file not shown.
Binary file removed apps/sda/public/walletconnect.png
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/config/ts/nextjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"resolveJsonModule": true,
"strict": false,
"strictNullChecks": true,
"target": "es5"
"target": "es2020"
}
}
2 changes: 1 addition & 1 deletion packages/config/ts/react-library.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"jsx": "react-jsx",
"lib": ["dom", "dom.iterable", "esnext"],
"module": "esnext",
"target": "es6",
"target": "es2020",
"allowJs": true,
"noEmit": true
}
Expand Down
2 changes: 1 addition & 1 deletion packages/email/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"jsx": "react-jsx",
"lib": ["dom", "dom.iterable", "esnext"],
"module": "CommonJS",
"target": "es6",
"target": "es2020",
"allowJs": true,
"noEmit": true
}
Expand Down
6 changes: 5 additions & 1 deletion packages/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
"stake": "Stake",
"unstake": "Unstake"
},
"stopConnecting": "Stop connecting",
"stopFollowing": "Stop following",
"submit": "Submit",
"toggleTheme": "Toggle theme",
Expand Down Expand Up @@ -667,7 +668,7 @@
"compensationCycleClosedAwaitingCompletion": "Contributions and ratings have been submitted. Review the results and create a proposal to complete the cycle.",
"completeRelayOrLoseFunds": "Make sure you have completed the relaying process, or you may lose the tokens you sent to the relayers to pay fees.",
"completed": "Completed",
"configureWalletModalExplanation": "You have Keplr installed, but it doesn't seem like you've set up a wallet. To continue, open the Keplr extension and set up a wallet.\nTo open the Keplr extension, press the puzzle icon in the top right of your browser and then press the Keplr button. Once you've done that, a new page will open where you'll be able to create a new account. Configure your wallet to continue.",
"configureWalletModalExplanation": "You have a wallet extension installed, but it doesn't seem like you've set up a wallet. Create a wallet to continue.",
"connectedTo": "Connected to {{name}}",
"copiedAddressToClipboard": "Copy address to clipboard",
"copiedDaoAddress": "Copied DAO address",
Expand Down Expand Up @@ -1143,6 +1144,7 @@
"executeSmartContract": "Execute Smart Contract",
"existingToken": "Existing token",
"expires": "Expires",
"extension": "Extension",
"factoryToken": "Factory token",
"featuredDaos": "Featured DAOs",
"feeShare": "Fee share",
Expand All @@ -1167,6 +1169,7 @@
"initialTokenDistribution": "Initial Token Distribution",
"instantiateSmartContract": "Instantiate Smart Contract",
"lastUpdated": "Last updated",
"ledger": "Ledger",
"logInWith": "Log in with...",
"loggedIn": "Logged in",
"loggedOut": "Logged out",
Expand Down Expand Up @@ -1354,6 +1357,7 @@
"votingProgress": "Voting Progress",
"votingWeight": "Voting weight",
"wallet": "Wallet",
"walletConnect": "WalletConnect",
"watchOut": "Watch out!",
"website": "Website",
"when": "When",
Expand Down
1 change: 0 additions & 1 deletion packages/state/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"devDependencies": {
"@dao-dao/config": "2.2.0",
"@dao-dao/types": "2.2.0",
"@noahsaso/cosmodal": "0.11.4",
"typescript": "^4.8.3"
},
"prettier": "@dao-dao/config/prettier"
Expand Down
3 changes: 3 additions & 0 deletions packages/state/recoil/atoms/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { atom, atomFamily } from 'recoil'

import { DEFAULT_CHAIN_ID } from '@dao-dao/utils'

import { localStorageEffectJSON } from '../effects'

export const signingCosmWasmClientAtom = atomFamily<
SigningCosmWasmClient | undefined,
{ chainId: string }
Expand All @@ -14,4 +16,5 @@ export const signingCosmWasmClientAtom = atomFamily<
export const walletChainIdAtom = atom<string>({
key: 'walletChainId',
default: DEFAULT_CHAIN_ID,
effects: [localStorageEffectJSON],
})
21 changes: 7 additions & 14 deletions packages/state/recoil/atoms/misc.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { atom } from 'recoil'

import { Web3AuthPrompt } from '@dao-dao/types'

import { localStorageEffectJSON } from '../effects'

// Utility atom to store if the app is running in the browser
Expand Down Expand Up @@ -28,21 +30,12 @@ export const betaWarningAcceptedAtom = atom<boolean>({
effects: [localStorageEffectJSON],
})

export const installWarningVisibleAtom = atom<boolean>({
key: 'installWarningVisible',
export const updateProfileNftVisibleAtom = atom<boolean>({
key: 'updateProfileNftVisible',
default: false,
})

export const noKeplrAccountAtom = atom<boolean>({
key: 'noKeplrAccountAtom',
default: false,
})

// If true, will display wallet modal. The wallet modal will always be visible
// when connecting to a wallet. This atom is used to display the wallet modal
// when not actively connecting to a wallet, likely to display the connected
// wallet or switch to another one.
export const walletModalVisibleAtom = atom<boolean>({
key: 'walletModalVisible',
default: false,
export const web3AuthPromptAtom = atom<Web3AuthPrompt | undefined>({
key: 'web3AuthPrompt',
default: undefined,
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useWallet } from '@noahsaso/cosmodal'
import { useState } from 'react'
import { useFormContext } from 'react-hook-form'
import toast from 'react-hot-toast'
Expand All @@ -8,6 +7,7 @@ import { ActionComponent, ActionContextType, ActionKey } from '@dao-dao/types'
import { CHAIN_GAS_MULTIPLIER, processError } from '@dao-dao/utils'

import { AddressInput } from '../../../../components'
import { useWallet } from '../../../../hooks'
import { useActionOptions } from '../../../react'
import { InstantiateNftCollection as StatelessInstantiateNftCollection } from './stateless/InstantiateNftCollection'

Expand All @@ -17,11 +17,10 @@ export const InstantiateNftCollection: ActionComponent = (props) => {
const {
context,
chainContext: {
chainId,
config: { codeIds },
},
} = useActionOptions()
const { address: walletAddress, signingCosmWasmClient } = useWallet(chainId)
const { address: walletAddress, getSigningCosmWasmClient } = useWallet()

const [instantiating, setInstantiating] = useState(false)

Expand All @@ -33,11 +32,13 @@ export const InstantiateNftCollection: ActionComponent = (props) => {
return
}

if (!signingCosmWasmClient || !walletAddress) {
if (!walletAddress) {
toast.error(t('error.logInToContinue'))
return
}

const signingCosmWasmClient = await getSigningCosmWasmClient()

setInstantiating(true)
try {
const { contractAddress } = await signingCosmWasmClient.instantiate(
Expand Down
5 changes: 2 additions & 3 deletions packages/stateful/actions/core/nfts/TransferNft/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { toBase64, toUtf8 } from '@cosmjs/encoding'
import { useWallet } from '@noahsaso/cosmodal'
import { useCallback } from 'react'
import { useFormContext } from 'react-hook-form'
import { constSelector, useRecoilValue } from 'recoil'
Expand All @@ -21,6 +20,7 @@ import {
} from '@dao-dao/utils'

import { AddressInput } from '../../../../components'
import { useWallet } from '../../../../hooks'
import {
nftCardInfoSelector,
nftCardInfosForDaoSelector,
Expand All @@ -41,8 +41,7 @@ export type TransferNftData = {
}

const useDefaults: UseDefaults<TransferNftData> = () => {
const { chain_id } = useActionOptions().chain
const { address: walletAddress = '' } = useWallet(chain_id)
const { address: walletAddress = '' } = useWallet()

return {
collection: '',
Expand Down
4 changes: 2 additions & 2 deletions packages/stateful/actions/core/treasury/Spend/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { coin } from '@cosmjs/amino'
import { useWallet } from '@noahsaso/cosmodal'
import { MsgTransfer } from 'cosmjs-types/ibc/applications/transfer/v1/tx'
import Long from 'long'
import { useCallback, useEffect, useState } from 'react'
Expand Down Expand Up @@ -41,6 +40,7 @@ import {
} from '@dao-dao/utils'

import { AddressInput } from '../../../../components'
import { useWallet } from '../../../../hooks/useWallet'
import { entitySelector } from '../../../../recoil'
import { useTokenBalances } from '../../../hooks/useTokenBalances'
import { useActionOptions } from '../../../react'
Expand All @@ -55,7 +55,7 @@ const useDefaults: UseDefaults<SpendData> = () => {
const {
chain: { chain_id: chainId },
} = useActionOptions()
const { address: walletAddress = '' } = useWallet(chainId)
const { address: walletAddress = '' } = useWallet()

return {
chainId,
Expand Down
Loading

2 comments on commit 692a089

@vercel
Copy link

@vercel vercel bot commented on 692a089 Aug 3, 2023

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on 692a089 Aug 3, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.