diff --git a/packages/stateful/components/dao/CreateDaoForm.tsx b/packages/stateful/components/dao/CreateDaoForm.tsx index b45b03910..b05a9be80 100644 --- a/packages/stateful/components/dao/CreateDaoForm.tsx +++ b/packages/stateful/components/dao/CreateDaoForm.tsx @@ -204,7 +204,7 @@ export const InnerCreateDaoForm = ({ cached.creator.data = merge( {}, // Start with defaults. - creator?.defaultConfig, + creator?.makeDefaultConfig(chainContext.config), // Overwrite with existing values. cached.creator.data ) @@ -238,7 +238,7 @@ export const InnerCreateDaoForm = ({ // Use overrides passed into component. override ) - }, [_newDaoAtom, chainId, override]) + }, [_newDaoAtom, chainContext.config, chainId, override]) const form = useForm({ defaultValues: defaultForm, diff --git a/packages/stateful/creators/MembershipBased/GovernanceConfigurationInput.tsx b/packages/stateful/creators/MembershipBased/GovernanceConfigurationInput.tsx index d998c11b2..cf6295d9e 100644 --- a/packages/stateful/creators/MembershipBased/GovernanceConfigurationInput.tsx +++ b/packages/stateful/creators/MembershipBased/GovernanceConfigurationInput.tsx @@ -9,6 +9,7 @@ import { InputErrorMessage, VotingPowerDistribution, VotingPowerDistributionEntry, + useSupportedChainContext, } from '@dao-dao/stateless' import { CreateDaoCustomValidator, @@ -39,6 +40,7 @@ export const GovernanceConfigurationInput = ({ }: DaoCreationGovernanceConfigInputProps) => { const { t } = useTranslation() const { address: walletAddress, isWalletConnected } = useWallet() + const { config: chainConfig } = useSupportedChainContext() const { fields: tierFields, @@ -51,13 +53,15 @@ export const GovernanceConfigurationInput = ({ const addTierRef = useRef(null) const addTier = useCallback(() => { - appendTier(cloneDeep(MembershipBasedCreator.defaultConfig.tiers[0])) + appendTier( + cloneDeep(MembershipBasedCreator.makeDefaultConfig(chainConfig).tiers[0]) + ) // Scroll button to bottom of screen. addTierRef.current?.scrollIntoView({ behavior: 'smooth', block: 'end', }) - }, [appendTier]) + }, [appendTier, chainConfig]) // Fill in default first tier info if tiers not yet edited. const [loadedPage, setLoadedPage] = useState(false) diff --git a/packages/stateful/creators/MembershipBased/TierCard.stories.tsx b/packages/stateful/creators/MembershipBased/TierCard.stories.tsx index 6013a8e43..b03f616a5 100644 --- a/packages/stateful/creators/MembershipBased/TierCard.stories.tsx +++ b/packages/stateful/creators/MembershipBased/TierCard.stories.tsx @@ -3,7 +3,10 @@ import { useForm } from 'react-hook-form' import { CHAIN_ID } from '@dao-dao/storybook' import { NewDao } from '@dao-dao/types' -import { MembershipBasedCreatorId } from '@dao-dao/utils' +import { + MembershipBasedCreatorId, + getSupportedChainConfig, +} from '@dao-dao/utils' import { MembershipBasedCreator } from '.' import { makeDefaultNewDao } from '../../recoil/atoms' @@ -28,7 +31,9 @@ const Template: ComponentStory = (args) => { ...makeDefaultNewDao(CHAIN_ID), creator: { id: MembershipBasedCreatorId, - data: MembershipBasedCreator.defaultConfig, + data: MembershipBasedCreator.makeDefaultConfig( + getSupportedChainConfig(CHAIN_ID)! + ), }, }, }) diff --git a/packages/stateful/creators/MembershipBased/index.ts b/packages/stateful/creators/MembershipBased/index.ts index 5e07a45c0..d14f93676 100644 --- a/packages/stateful/creators/MembershipBased/index.ts +++ b/packages/stateful/creators/MembershipBased/index.ts @@ -15,7 +15,7 @@ export const MembershipBasedCreator: DaoCreator = { suppliesI18nKey: 'daoCreator.MembershipBased.supplies', membershipI18nKey: 'daoCreator.MembershipBased.membership', }, - defaultConfig: { + makeDefaultConfig: () => ({ tiers: [ { name: '', @@ -27,7 +27,7 @@ export const MembershipBasedCreator: DaoCreator = { ], }, ], - }, + }), governanceConfig: { Input: GovernanceConfigurationInput, Review: GovernanceConfigurationReview, diff --git a/packages/stateful/creators/NftBased/index.ts b/packages/stateful/creators/NftBased/index.ts index ce54398b2..34493a6c1 100644 --- a/packages/stateful/creators/NftBased/index.ts +++ b/packages/stateful/creators/NftBased/index.ts @@ -18,14 +18,14 @@ export const NftBasedCreator: DaoCreator = { suppliesI18nKey: 'daoCreator.NftBased.supplies', membershipI18nKey: 'daoCreator.NftBased.membership', }, - defaultConfig: { + makeDefaultConfig: () => ({ tokenType: GovernanceTokenType.Existing, existingGovernanceTokenDenomOrAddress: '', unstakingDuration: { value: 2, units: DurationUnits.Weeks, }, - }, + }), governanceConfig: { Input: GovernanceConfigurationInput, Review: GovernanceConfigurationReview, diff --git a/packages/stateful/creators/TokenBased/GovernanceConfigurationInput.tsx b/packages/stateful/creators/TokenBased/GovernanceConfigurationInput.tsx index fab7d8015..de0266d07 100644 --- a/packages/stateful/creators/TokenBased/GovernanceConfigurationInput.tsx +++ b/packages/stateful/creators/TokenBased/GovernanceConfigurationInput.tsx @@ -74,9 +74,9 @@ export const GovernanceConfigurationInput = ({ const { chain: { chain_id: chainId, bech32_prefix: bech32Prefix }, - config: { createWithCw20 }, + config, } = useSupportedChainContext() - const isCw20 = !!createWithCw20 + const isCw20 = !!config.createWithCw20 const { fields: tierFields, @@ -89,13 +89,13 @@ export const GovernanceConfigurationInput = ({ const addTierRef = useRef(null) const addTier = useCallback(() => { - appendTier(cloneDeep(TokenBasedCreator.defaultConfig.tiers[0])) + appendTier(cloneDeep(TokenBasedCreator.makeDefaultConfig(config).tiers[0])) // Scroll button to bottom of screen. addTierRef.current?.scrollIntoView({ behavior: 'smooth', block: 'end', }) - }, [appendTier]) + }, [appendTier, config]) // Load token factory denom creation fee. const tokenFactoryDenomCreationFeeLoading = useCachedLoading( @@ -323,13 +323,18 @@ export const GovernanceConfigurationInput = ({ <> setValue('creator.data.tokenType', tokenType)} selected={data.tokenType} tabs={[ - { - label: t('button.createAToken'), - value: GovernanceTokenType.New, - }, + ...(config.noCreateNewTokens + ? [] + : [ + { + label: t('button.createAToken'), + value: GovernanceTokenType.New, + }, + ]), { label: t('button.useExistingToken'), value: GovernanceTokenType.Existing, diff --git a/packages/stateful/creators/TokenBased/TierCard.stories.tsx b/packages/stateful/creators/TokenBased/TierCard.stories.tsx index 3ab0e4a87..f82b0f8d6 100644 --- a/packages/stateful/creators/TokenBased/TierCard.stories.tsx +++ b/packages/stateful/creators/TokenBased/TierCard.stories.tsx @@ -3,7 +3,7 @@ import { useForm } from 'react-hook-form' import { CHAIN_ID } from '@dao-dao/storybook' import { NewDao } from '@dao-dao/types' -import { TokenBasedCreatorId } from '@dao-dao/utils' +import { TokenBasedCreatorId, getSupportedChainConfig } from '@dao-dao/utils' import { TokenBasedCreator } from '.' import { makeDefaultNewDao } from '../../recoil/atoms' @@ -27,7 +27,9 @@ const Template: ComponentStory = (args) => { ...makeDefaultNewDao(CHAIN_ID), creator: { id: TokenBasedCreatorId, - data: TokenBasedCreator.defaultConfig, + data: TokenBasedCreator.makeDefaultConfig( + getSupportedChainConfig(CHAIN_ID)! + ), }, }, }) diff --git a/packages/stateful/creators/TokenBased/index.ts b/packages/stateful/creators/TokenBased/index.ts index 16ce1feeb..fad8ab69e 100644 --- a/packages/stateful/creators/TokenBased/index.ts +++ b/packages/stateful/creators/TokenBased/index.ts @@ -18,7 +18,7 @@ export const TokenBasedCreator: DaoCreator = { suppliesI18nKey: 'daoCreator.TokenBased.supplies', membershipI18nKey: 'daoCreator.TokenBased.membership', }, - defaultConfig: { + makeDefaultConfig: ({ noCreateNewTokens = false }) => ({ tiers: [ { name: '', @@ -30,7 +30,9 @@ export const TokenBasedCreator: DaoCreator = { ], }, ], - tokenType: GovernanceTokenType.New, + tokenType: noCreateNewTokens + ? GovernanceTokenType.Existing + : GovernanceTokenType.New, newInfo: { initialSupply: 10000000, initialTreasuryPercent: 90, @@ -47,7 +49,7 @@ export const TokenBasedCreator: DaoCreator = { type: 'percent', value: 10, }, - }, + }), governanceConfig: { Input: GovernanceConfigurationInput, Review: GovernanceConfigurationReview, diff --git a/packages/stateful/recoil/atoms/newDao.ts b/packages/stateful/recoil/atoms/newDao.ts index bbd382f10..7e508e4a2 100644 --- a/packages/stateful/recoil/atoms/newDao.ts +++ b/packages/stateful/recoil/atoms/newDao.ts @@ -14,6 +14,7 @@ import { MembershipBasedCreatorId, convertCosmosVetoConfigToVeto, getNativeTokenForChainId, + getSupportedChainConfig, } from '@dao-dao/utils' import { MembershipBasedCreator } from '../../creators/MembershipBased' @@ -31,7 +32,11 @@ export const makeDefaultNewDao = (chainId: string): NewDao => ({ imageUrl: undefined, creator: { id: MembershipBasedCreatorId, - data: cloneDeep(MembershipBasedCreator.defaultConfig), + data: cloneDeep( + MembershipBasedCreator.makeDefaultConfig( + getSupportedChainConfig(chainId)! + ) + ), }, // Default to single and multiple choice proposal configuration. proposalModuleAdapters: [ diff --git a/packages/stateless/components/dao/create/pages/CreateDaoGovernance.stories.tsx b/packages/stateless/components/dao/create/pages/CreateDaoGovernance.stories.tsx index 361414cbc..6835b0972 100644 --- a/packages/stateless/components/dao/create/pages/CreateDaoGovernance.stories.tsx +++ b/packages/stateless/components/dao/create/pages/CreateDaoGovernance.stories.tsx @@ -1,12 +1,13 @@ import { ComponentMeta, ComponentStory } from '@storybook/react' import { TokenBasedCreator } from '@dao-dao/stateful/creators/TokenBased' +import { CHAIN_ID } from '@dao-dao/storybook' import { WalletProviderDecorator, makeCreateDaoFormDecorator, makeDappLayoutDecorator, } from '@dao-dao/storybook/decorators' -import { TokenBasedCreatorId } from '@dao-dao/utils' +import { TokenBasedCreatorId, getSupportedChainConfig } from '@dao-dao/utils' import { CreateDaoGovernance } from './CreateDaoGovernance' @@ -23,7 +24,9 @@ export default { 'https://ipfs.stargaze.zone/ipfs/QmbGvE3wmxex8KiBbbvMjR8f9adR28s3XkiZSTuGmHoMHV/33.jpg', creator: { id: TokenBasedCreatorId, - data: TokenBasedCreator.defaultConfig, + data: TokenBasedCreator.makeDefaultConfig( + getSupportedChainConfig(CHAIN_ID)! + ), }, }), makeDappLayoutDecorator(), diff --git a/packages/stateless/components/dao/create/pages/CreateDaoReview.stories.tsx b/packages/stateless/components/dao/create/pages/CreateDaoReview.stories.tsx index 47cb77b85..be18e6bb0 100644 --- a/packages/stateless/components/dao/create/pages/CreateDaoReview.stories.tsx +++ b/packages/stateless/components/dao/create/pages/CreateDaoReview.stories.tsx @@ -2,10 +2,15 @@ import { ComponentMeta, ComponentStory } from '@storybook/react' import { TokenBasedCreator } from '@dao-dao/stateful/creators/TokenBased' import { DaoProposalSingleAdapter } from '@dao-dao/stateful/proposal-module-adapter/adapters/DaoProposalSingle' +import { CHAIN_ID } from '@dao-dao/storybook' import { WalletProviderDecorator } from '@dao-dao/storybook/decorators' import { makeCreateDaoFormDecorator } from '@dao-dao/storybook/decorators/makeCreateDaoFormDecorator' import { makeDappLayoutDecorator } from '@dao-dao/storybook/decorators/makeDappLayoutDecorator' -import { DaoProposalSingleAdapterId, TokenBasedCreatorId } from '@dao-dao/utils' +import { + DaoProposalSingleAdapterId, + TokenBasedCreatorId, + getSupportedChainConfig, +} from '@dao-dao/utils' import { CreateDaoReview } from './CreateDaoReview' @@ -23,9 +28,13 @@ export default { creator: { id: TokenBasedCreatorId, data: { - ...TokenBasedCreator.defaultConfig, + ...TokenBasedCreator.makeDefaultConfig( + getSupportedChainConfig(CHAIN_ID)! + ), newInfo: { - ...TokenBasedCreator.defaultConfig.newInfo, + ...TokenBasedCreator.makeDefaultConfig( + getSupportedChainConfig(CHAIN_ID)! + ).newInfo, symbol: 'TST', name: 'Test Token', }, diff --git a/packages/stateless/components/dao/create/pages/CreateDaoStart.stories.tsx b/packages/stateless/components/dao/create/pages/CreateDaoStart.stories.tsx index 299bae0a2..bf91b1264 100644 --- a/packages/stateless/components/dao/create/pages/CreateDaoStart.stories.tsx +++ b/packages/stateless/components/dao/create/pages/CreateDaoStart.stories.tsx @@ -2,12 +2,17 @@ import { ComponentMeta, ComponentStory } from '@storybook/react' import { TokenBasedCreator } from '@dao-dao/stateful/creators/TokenBased' import { DaoProposalSingleAdapter } from '@dao-dao/stateful/proposal-module-adapter' +import { CHAIN_ID } from '@dao-dao/storybook' import { WalletProviderDecorator, makeCreateDaoFormDecorator, makeDappLayoutDecorator, } from '@dao-dao/storybook/decorators' -import { DaoProposalSingleAdapterId, TokenBasedCreatorId } from '@dao-dao/utils' +import { + DaoProposalSingleAdapterId, + TokenBasedCreatorId, + getSupportedChainConfig, +} from '@dao-dao/utils' import { CreateDaoStart } from './CreateDaoStart' @@ -21,9 +26,13 @@ export default { creator: { id: TokenBasedCreatorId, data: { - ...TokenBasedCreator.defaultConfig, + ...TokenBasedCreator.makeDefaultConfig( + getSupportedChainConfig(CHAIN_ID)! + ), newInfo: { - ...TokenBasedCreator.defaultConfig.newInfo, + ...TokenBasedCreator.makeDefaultConfig( + getSupportedChainConfig(CHAIN_ID)! + ).newInfo, symbol: 'TST', name: 'Test Token', }, diff --git a/packages/stateless/components/dao/create/pages/CreateDaoStart.tsx b/packages/stateless/components/dao/create/pages/CreateDaoStart.tsx index 6b59b7d59..49b223a0f 100644 --- a/packages/stateless/components/dao/create/pages/CreateDaoStart.tsx +++ b/packages/stateless/components/dao/create/pages/CreateDaoStart.tsx @@ -14,6 +14,7 @@ import { validateRequired, } from '@dao-dao/utils' +import { useSupportedChainContext } from '../../../../hooks' import { Button } from '../../../buttons' import { InputErrorMessage, TextAreaInput, TextInput } from '../../../inputs' import { DaoCreatorCard } from '../DaoCreatorCard' @@ -32,6 +33,7 @@ export const CreateDaoStart = ({ }: CreateDaoContext) => { const { t } = useTranslation() const daoChainId = watch('chainId') + const { config: chainConfig } = useSupportedChainContext() const data = watch() @@ -125,7 +127,7 @@ export const CreateDaoStart = ({ suppliesI18nKey, membershipI18nKey, }, - defaultConfig, + makeDefaultConfig, }) => ( = ( export type DaoCreator = { id: string - defaultConfig: Data + makeDefaultConfig: (chainConfig: SupportedChainConfig) => Data displayInfo: { Icon: ComponentType diff --git a/packages/utils/constants/chains.ts b/packages/utils/constants/chains.ts index 9b731d858..a765db1bf 100644 --- a/packages/utils/constants/chains.ts +++ b/packages/utils/constants/chains.ts @@ -1699,14 +1699,13 @@ export const SUPPORTED_CHAINS: SupportedChainConfig[] = [ name: 'bitsong', mainnet: false, accentColor: '#c53381', - createWithCw20: true, + // No token factory on BitSong. + noCreateNewTokens: true, factoryContractAddress: 'bitsong1ewd84afkxwxmqeu56p5mt3h446mgh3nh8yvmj2238akvu4ax7kss4a3u5c', codeIds: { // https://github.com/CosmWasm/cw-plus Cw1Whitelist: 7, - Cw20Base: 24, - Cw20Stake: 25, // V240 Cw4Group: 8, // v0.16 // https://github.com/CosmWasm/cw-nfts Cw721Base: 9, @@ -1714,7 +1713,7 @@ export const SUPPORTED_CHAINS: SupportedChainConfig[] = [ // ContractVersion.V242 CwPayrollFactory: 11, CwTokenSwap: 12, - CwTokenfactoryIssuerMain: -1, + CwTokenfactoryIssuerMain: 27, CwVesting: 13, DaoCore: 14, DaoMigrator: -1, // not needed since only v2 DAOs exist @@ -1726,8 +1725,7 @@ export const SUPPORTED_CHAINS: SupportedChainConfig[] = [ DaoProposalSingle: 21, DaoVotingCw4: 22, DaoVotingCw721Staked: 23, - DaoVotingTokenStaked: -1, - DaoVotingCw20Staked: 26, // V240 + DaoVotingTokenStaked: 28, }, }, ]