Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy recent features #1420

Merged
merged 3 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions apps/dapp/pages/dao/[address]/[[...slug]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
DaoInfoBar,
DaoPageWrapper,
DaoPageWrapperProps,
DaoWidgets,
LinkWrapper,
ProfileDaoHomeCard,
SuspenseLoader,
Expand All @@ -22,14 +21,13 @@ import {
} from '@dao-dao/stateful'
import { useActionForKey } from '@dao-dao/stateful/actions'
import { makeGetDaoStaticProps } from '@dao-dao/stateful/server'
import { useWidgets } from '@dao-dao/stateful/widgets'
import {
DaoDappTabbedHome,
useChain,
useDaoInfoContext,
useDaoNavHelpers,
} from '@dao-dao/stateless'
import { ActionKey, DaoPageMode, WidgetLocation } from '@dao-dao/types'
import { ActionKey, DaoPageMode } from '@dao-dao/types'
import {
SITE_URL,
getDaoPath,
Expand Down Expand Up @@ -152,20 +150,7 @@ const InnerDaoHome = () => {
useFollowingDaos(daoInfo.chainId)
const following = isFollowing(daoInfo.coreAddress)

// Add home tab with widgets if any widgets exist.
const loadingDaoWidgets = useWidgets({
// Load widgets before rendering so that home is selected if there are
// widgets.
suspendWhileLoading: true,
// Only load home widgets.
location: WidgetLocation.Home,
})
const hasHomeWidgets =
!loadingDaoWidgets.loading && loadingDaoWidgets.data.length > 0

const tabs = useDaoTabs({
includeHome: hasHomeWidgets ? DaoWidgets : undefined,
})
const tabs = useDaoTabs()
const firstTabId = tabs[0].id

// Pre-fetch tabs.
Expand Down
3 changes: 1 addition & 2 deletions apps/sda/pages/[address]/[[...slug]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import React, { useEffect } from 'react'

import {
ProfileDaoHomeCard,
SdaDaoHome,
SuspenseLoader,
useDaoTabs,
} from '@dao-dao/stateful'
Expand All @@ -25,7 +24,7 @@ const DaoHomePage: NextPage = () => {
const { coreAddress } = useDaoInfoContext()
const { getDaoPath } = useDaoNavHelpers()

const tabs = useDaoTabs({ includeHome: SdaDaoHome })
const tabs = useDaoTabs()
const firstTabId = tabs[0].id

// Pre-fetch tabs.
Expand Down
4 changes: 2 additions & 2 deletions packages/i18n/locales/dog/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"continue": "continnue",
"copy": "copee",
"copyAddressToClipboard": "copee addres 2 clipboar",
"copyDaoAddress": "copee da0 addres",
"copyDaoChainAddress": "copee {{chain}} addres",
"copyToClipboard": "copee 2 clipboar",
"create": "cre8",
"createAProposal": "cre8 a puppozal",
Expand Down Expand Up @@ -273,7 +273,7 @@
"configureWalletModalExplanation": "u hav keplr installd, but it dont seem lyke uv set oop a wallit. 2 continue, oopen da keplr extenshun n set oop a wallit. 2 oopen da keplr extenshun,press da puzzul icon in da top rite ov ur browzer n den press da keplr buttun. wunce uv dun dat, a new pag will oopen wer ull be abbl 2 create a new accoont. configur ur wallit 2 continue",
"considerReturningHome": "considar retorning homm",
"copiedAddressToClipboard": "copy adress 2 clipboar",
"copiedDaoAddress": "coppied da0 addres",
"copiedDaoChainAddress": "coppied {{chain}} addres",
"copiedLinkToClipboard": "coopied link 2 clibpoard",
"copiedToClipboard": "coopied 2 clipboar",
"copyWalletAddressTooltip": "copy wallit adress",
Expand Down
26 changes: 24 additions & 2 deletions packages/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,14 @@
"copy": "Copy",
"copyAddress": "Copy address",
"copyAddressToClipboard": "Copy address to clipboard",
"copyDaoAddress": "Copy DAO address",
"copyDaoChainAddress": "Copy {{chain}} address",
"copyToClipboard": "Copy to clipboard",
"create": "Create",
"createAProposal": "Create a proposal",
"createAToken": "Create a token",
"createAccount": "Create account",
"createDAO": "Create DAO",
"createNftCollection": "Create NFT collection",
"createSubDao": "Create SubDAO",
"delete": "Delete",
"deleteDraft": "Delete draft",
Expand Down Expand Up @@ -112,6 +113,7 @@
"installKeplr": "Install Keplr",
"instantiate": "Instantiate",
"loadDraft": "Load draft",
"loadMessageTemplate": "Load message template",
"loadMore": "Load more",
"loadSaves": "Load saves",
"logIn": "Log in",
Expand Down Expand Up @@ -226,7 +228,9 @@
"only_passed": "Only passed proposals"
},
"emoji": {
"artistPalette": "Artist palette",
"baby": "Baby",
"babyAngel": "Baby Angel",
"ballotBox": "Ballot box",
"bank": "Bank",
"bee": "Bee",
Expand Down Expand Up @@ -289,6 +293,7 @@
"cannotCreateCompensationCycleAlreadyActive": "You cannot create a new compensation cycle while one is already active.",
"cannotStakeMoreThanYouHave": "You can't stake or unstake more tokens than you have.",
"cannotTxZeroTokens": "You can't stake, unstake, or claim zero tokens.",
"cannotUseCreateNftCollectionOnStargaze": "You cannot create a new NFT Collection via this action on Stargaze. Use the Stargaze Studio app on the DAO's Apps page instead.",
"cantSpendMoreThanTreasury": "Can't spend more tokens than are in the treasury ({{amount}} ${{tokenSymbol}}).",
"chainNotConnected": "Chain not connected.",
"checkInternetOrTryAgain": "Check your internet connection, refresh the page, or try again later.",
Expand Down Expand Up @@ -322,6 +327,7 @@
"insufficientFunds": "Insufficient funds.",
"insufficientWalletBalance": "Insufficient wallet balance (total: {{amount}} ${{tokenSymbol}}).",
"invalidActionKeys": "Invalid action keys found: {{keys}}",
"invalidChain": "Invalid chain.",
"invalidCosmosMessage": "Invalid <2>Cosmos message</2>",
"invalidDate": "Invalid date format. Please use YYYY-MM-DD.",
"invalidDateTime": "Invalid date/time format. Please use YYYY-MM-DD HH:MM.",
Expand Down Expand Up @@ -410,6 +416,7 @@
"allowRevotingTitle": "Allow revoting",
"allowedMethods": "Allowed methods",
"allowedMethodsDescription": "Comma separated list of smart contract method names to authorize (i.e. set_item, remove_item)",
"allowsTradingAfter": "Allows trading after",
"amount": "amount",
"attributeName": "Attribute name",
"attributeNamePlaceholder": "Community impact",
Expand Down Expand Up @@ -474,6 +481,8 @@
"existingCollectionAddress": "Existing collection address",
"existingTokenSwapContract": "Existing token swap contract",
"existingTokens": "Existing Tokens",
"explicitContent": "Explicit content",
"externalLink": "External link",
"feeShareContractAddressDescription": "The address to claim fee share for. NOTE: you must be admin or the creator of this smart contract to claim fees for it.",
"feeShareToggleWithdrawerAddress": "Custom withdrawer address",
"feeShareToggleWithdrawerAddressTooltip_dao": "Customize the address allowed to withdraw fees. Defaults to the DAO.",
Expand Down Expand Up @@ -524,6 +533,7 @@
"nftCollectionAddress": "NFT collection address",
"nftMintInstructions": "Create a unique token ID for the NFT and enter the address of the initial owner below.",
"nftUploadMetadataInstructions": "Input the NFT's metadata, and then press 'Upload' to store it on IPFS.",
"oneOneCollection": "1/1 Collection",
"onlyMembersExecuteTitle": "Only members execute",
"onlyMembersExecuteTooltip": "If enabled, only members may execute passed proposals.",
"openDate": "Open date",
Expand Down Expand Up @@ -565,6 +575,8 @@
"requireProposalDepositTitle": "Require proposal deposit",
"requireProposalDepositTooltip": "If enabled, requires that tokens are deposited to create a proposal.",
"revokeAuthorizationOption": "Revoke authorization",
"royalties": "Royalties",
"salt": "Salt",
"sameAsPublicSubmissionCloseDate": "Same as public submission close date",
"selectAnImage": "Select an image",
"showAdvancedNftFields": "Show advanced fields",
Expand All @@ -575,6 +587,7 @@
"smartContractMessageDescription": "The smart contract message to execute.",
"spendingAllowance": "Spending allowance",
"spendingAllowanceDescription": "The amount of funds allowed to be spent by the authorized account.",
"standardCollection": "Standard Collection",
"startDate": "Start date",
"subDaosToRecognize": "SubDAOs to recognize",
"subDaosToRemove": "SubDAOs to remove",
Expand Down Expand Up @@ -728,7 +741,7 @@
"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",
"copiedDaoChainAddress": "Copied {{chain}} address",
"copiedLinkToClipboard": "Copied link to clipboard.",
"copiedToClipboard": "Copied to clipboard.",
"copyWalletAddressTooltip": "Copy wallet address",
Expand All @@ -737,6 +750,9 @@
"createCrossChainAccountDescription": "Create an account for this DAO on another chain.",
"createCrossChainAccountExplanation": "This action creates an account on another chain, allowing this DAO to perform actions on that chain.",
"createFirstOneQuestion": "Create the first one?",
"createNftCollectionDescription_dao": "Create a new NFT collection controlled by the DAO.",
"createNftCollectionDescription_gov": "Create a new NFT collection controlled by the chain.",
"createNftCollectionDescription_wallet": "Create a new NFT collection controlled by you.",
"createPostDescription": "Create a post on the DAO's press.",
"createPressContract": "To publish content, you must first create a press contract.",
"createStep1": "Pick a DAO type and name it",
Expand Down Expand Up @@ -805,6 +821,7 @@
"inboxDescription": "Your notification inbox.",
"inboxEmailTooltip": "Receive inbox notifications in your email.",
"installKeplrMobileOrScanQrCode": "If you don't have Keplr Mobile installed, <2>click here to install it</2> or scan the QR code at the bottom with another device.",
"instantiatePredictableSmartContractActionDescription": "Instantiate a smart contract with a predictable address.",
"instantiateSmartContractActionDescription": "Instantiate a smart contract.",
"intakeClosesAt": "Intake closes at {{date}}.",
"intakeOpensAt": "Intake opens at {{date}}.",
Expand Down Expand Up @@ -949,6 +966,7 @@
"searchForChain": "Search for a chain...",
"searchForToken": "Search for a token...",
"searchForWidget": "Search for a widget...",
"searchMessages": "Search messages",
"searchNftsPlaceholder": "Find an NFT...",
"searchValidatorsPlaceholder": "Find a validator...",
"selfRelayDescription": "One or more messages in this proposal require self-relaying across chains since automatic relayers do not exist or are inactive right now.",
Expand All @@ -967,6 +985,7 @@
"stakedNftsExplanation": "These have been staked by DAO members to earn voting power.",
"stakes": "Stakes",
"stakingAddress": "Staking Contract",
"stargazeCreateCollectionFirst": "On Stargaze, you must first create the NFT Collection via a DAO proposal, and then you can mint NFTs.",
"startedAt": "Started at",
"startsAt": "Starts at",
"startsIn": "Starts in",
Expand Down Expand Up @@ -1190,6 +1209,7 @@
"createAProposal": "Create a proposal",
"createASubDao": "Create a SubDAO",
"createCrossChainAccount": "Create Cross-Chain Account",
"createNftCollection": "Create NFT Collection",
"createPost": "Create Post",
"createProposal": "Create proposal",
"createValidator": "Create a validator",
Expand Down Expand Up @@ -1260,6 +1280,7 @@
"inboxConfiguration": "Inbox configuration",
"inboxWithCount": "Inbox ({{count}})",
"initialTokenDistribution": "Initial Token Distribution",
"instantiatePredictableSmartContract": "Instantiate Predictable Smart Contract",
"instantiateSmartContract": "Instantiate Smart Contract",
"lastUpdated": "Last updated",
"ledger": "Ledger",
Expand Down Expand Up @@ -1322,6 +1343,7 @@
"other": "Other",
"otherMembers": "Other Members",
"owner": "Owner",
"pages": "Pages",
"passingThreshold": "Passing threshold",
"payout": "Payout",
"payroll": "Payroll",
Expand Down
84 changes: 75 additions & 9 deletions packages/stateful/actions/core/advanced/Custom/Component.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,93 @@
import { Check, Close } from '@mui/icons-material'
import JSON5 from 'json5'
import { useMemo } from 'react'
import { useFormContext } from 'react-hook-form'
import { useTranslation } from 'react-i18next'

import { CodeMirrorInput } from '@dao-dao/stateless'
import {
CodeMirrorInput,
FilterableItemPopup,
useChain,
} from '@dao-dao/stateless'
import { ChainId } from '@dao-dao/types'
import { ActionComponent } from '@dao-dao/types/actions'
import {
PROTOBUF_TYPES,
makeStargateMessage,
makeWasmMessage,
validateCosmosMsg,
} from '@dao-dao/utils'

export type CustomData = {
message: string
}

export const CustomComponent: ActionComponent = ({
fieldNamePrefix,
errors,
isCreating,
}) => {
const { t } = useTranslation()
const { control } = useFormContext()
const { control, setValue } = useFormContext<CustomData>()
const { chain_id: chainId } = useChain()

const types = useMemo(
() =>
PROTOBUF_TYPES.filter(
([type]) =>
// Only show protobuf message types.
type.split('.').pop()?.startsWith('Msg') &&
// Only show osmosis message types on Osmosis chains.
(!type.startsWith('/osmosis') ||
chainId === ChainId.OsmosisMainnet ||
chainId === ChainId.OsmosisTestnet)
),
[chainId]
)

return (
<>
{isCreating && (
<FilterableItemPopup
filterableItemKeys={FILTERABLE_KEYS}
items={types.map(([key, type]) => ({
key,
label: key,
type,
}))}
labelClassName="break-words whitespace-normal"
onSelect={({ key, type }) =>
setValue(
(fieldNamePrefix + 'message') as 'message',
JSON.stringify(
{
stargate: {
typeUrl: key,
// Decoding empty data returns default.
value: type.decode(new Uint8Array()),
},
},
null,
2
)
)
}
searchPlaceholder={t('info.searchMessages')}
trigger={{
type: 'button',
props: {
className: 'self-start',
variant: 'secondary',
children: t('button.loadMessageTemplate'),
},
}}
/>
)}

<CodeMirrorInput
control={control}
error={errors?.message}
fieldName={fieldNamePrefix + 'message'}
fieldName={(fieldNamePrefix + 'message') as 'message'}
readOnly={!isCreating}
validation={[
(v: string) => {
Expand All @@ -34,14 +97,15 @@ export const CustomComponent: ActionComponent = ({
} catch (e: any) {
return e.message as string
}
if (msg.wasm) {
msg = makeWasmMessage(msg)
}
if (msg.stargate) {
msg = makeStargateMessage(msg)
}

try {
if (msg.wasm) {
msg = makeWasmMessage(msg)
}
if (msg.stargate) {
msg = makeStargateMessage(msg)
}

validateCosmosMsg(msg)
} catch (err) {
return err instanceof Error ? err.message : `${err}`
Expand Down Expand Up @@ -77,3 +141,5 @@ export const CustomComponent: ActionComponent = ({
</>
)
}

const FILTERABLE_KEYS = ['label']
6 changes: 1 addition & 5 deletions packages/stateful/actions/core/advanced/Custom/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ import {
} from '@dao-dao/types/actions'
import { makeStargateMessage, makeWasmMessage } from '@dao-dao/utils'

import { CustomComponent as Component } from './Component'

interface CustomData {
message: string
}
import { CustomComponent as Component, CustomData } from './Component'

const useDefaults: UseDefaults<CustomData> = () => ({
message: '{}',
Expand Down
Loading
Loading