Skip to content

Commit

Permalink
add memo and Cosmos Hub x/metaprotocol extension data to proposals (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso authored Oct 9, 2024
1 parent 4401f34 commit f421d13
Show file tree
Hide file tree
Showing 68 changed files with 2,379 additions and 1,142 deletions.
1 change: 1 addition & 0 deletions apps/dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "2.5.0-rc.3",
"license": "AGPL-3.0-only",
"scripts": {
"postinstall": "cd ../../ && patch-package",
"analyze": "ANALYZE=true next build",
"prepare": "npm run build:worker",
"prebuild": "npm run build:worker && cd ../../packages/state && npm run build:gql",
Expand Down
1 change: 1 addition & 0 deletions apps/sda/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "2.5.0-rc.3",
"license": "AGPL-3.0-only",
"scripts": {
"postinstall": "cd ../../ && patch-package",
"analyze": "ANALYZE=true next build",
"prebuild": "cd ../../packages/state && npm run build:gql",
"build": "next build --debug",
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"start": "yarn dapp start",
"format": "prettier --write \"**/*.{css,json,md}\" && turbo run format --continue --parallel",
"lint": "prettier --check \"**/*.{css,json,md}\" && turbo run lint --continue --parallel",
"postinstall": "patch-package",
"test": "jest",
"test:e2e": "yarn dapp test:e2e",
"cwgen": "yarn workspace @dao-dao/config cwgen",
Expand All @@ -33,6 +34,7 @@
"@types/jest": "^29.5.0",
"jest": "^29.5.0",
"lerna": "^6.4.1",
"patch-package": "^8.0.0",
"ts-jest": "^29.0.5",
"turbo": "latest",
"turbo-ignore": "latest"
Expand Down
9 changes: 9 additions & 0 deletions packages/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"addAttribute": "Add attribute",
"addChains": "Add chains",
"addCollection": "Add collection",
"addEntry": "Add entry",
"addFile": "Add file",
"addImage": "Add image",
"addMember": "Add a member",
Expand Down Expand Up @@ -402,6 +403,7 @@
"alreadySentTokenSwap_dao": "The DAO has already sent its share of this token swap.",
"alreadySentTokenSwap_gov": "The chain has already sent its share of this token swap.",
"alreadySentTokenSwap_wallet": "You have already sent your share of this token swap.",
"browserExtensionWalletRequiredForProposalExecution": "Executing this proposal requires a browser extension wallet due to its execution metadata. Please try again with a supported wallet.",
"browserNotSupported": "Not supported in this browser.",
"cannotStakeMoreThanYouHave": "You can't stake or unstake more tokens than you have.",
"cannotTxZeroTokens": "You can't stake, unstake, or claim zero tokens.",
Expand Down Expand Up @@ -638,6 +640,7 @@
"daoName": "Name",
"daoNamePlaceholder": "Give your DAO a name",
"daosCurrentlyEnabled": "DAOs currently enabled",
"data": "Data",
"dates": "Dates",
"defaultTierName": "Core contributors",
"delegatorAddress": "Delegator address",
Expand Down Expand Up @@ -769,6 +772,8 @@
"proposalsDescriptionPlaceholder": "Give your proposal a description (supports Markdown)...",
"proposalsTitlePlaceholder": "Give your proposal a title",
"proposedSpends": "Proposed spends",
"protocolId": "Protocol ID",
"protocolVersion": "Protocol version",
"quorumDescription": "The minimum percentage of voting power that must vote on a proposal for it to be considered. For example, in the US House of Representatives, 218 members must be present for a vote. If you have a DAO with many inactive members, setting this value too high may make it difficult to pass proposals.",
"quorumDescription_create": "The minimum percentage of voting power that must vote on a proposal for it to be considered. For example, in the US House of Representatives, 218 members must be present for a vote. If you have a DAO with many inactive members, setting this value too high may make it difficult to pass proposals.\n\n*If not using a quorum for the single choice proposal passing threshold, this quorum will only apply to multiple choice proposals.*",
"quorumTitle": "Quorum",
Expand Down Expand Up @@ -1311,6 +1316,7 @@
"proposalAllAbstainClarification": "When all voters abstain, a proposal will fail.",
"proposalDepositTooltip": "The deposit the proposer must pay when creating a proposal.",
"proposalDepositWillBeRefunded": "Proposal deposit will be refunded once closed.",
"proposalExecutionMemoTooltip": "The memo that will be attached to the transaction when this proposal is executed.",
"proposalExecutionPolicyDescription": "Who is allowed to execute passed proposals?",
"proposalFixesChildAdmin": "This proposal fixes that by setting the contract-level admin of {{child}} to {{parent}}.",
"proposalModuleInfoCardsTooltip": "Different proposal types are configured separately. This is the configuration for the {{type}} proposal type.",
Expand Down Expand Up @@ -1804,6 +1810,7 @@
"established": "Established",
"executeProposal": "Execute Proposal",
"executeSmartContract": "Execute Smart Contract",
"executionMetadata": "Execution Metadata",
"existingProposal": "Existing proposal",
"existingToken": "Existing token",
"expires": "Expires",
Expand Down Expand Up @@ -1868,8 +1875,10 @@
"memberOfDao": "Member of {{daoName}}",
"members": "Members",
"membership": "Membership",
"memo": "Memo",
"mergeProfiles": "Merge Profiles",
"metadata": "Metadata",
"metaprotocolExtensionData": "Metaprotocol Extension Data",
"migrateFollowing": "Migrate Followed DAOs",
"migrateSmartContract": "Migrate Smart Contract",
"migrateTokenFactoryModule": "Migrate Token Factory Module",
Expand Down
7 changes: 5 additions & 2 deletions packages/state/contracts/CwProposalSingle.v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ExecuteResult,
SigningCosmWasmClient,
} from '@cosmjs/cosmwasm-stargate'
import { EncodeObject } from '@cosmjs/proto-signing'

import {
Coin,
Expand Down Expand Up @@ -394,7 +395,8 @@ export class CwProposalSingleV1Client
},
fee: number | StdFee | 'auto' = CHAIN_GAS_MULTIPLIER,
memo?: string,
_funds?: Coin[]
_funds?: Coin[],
nonCriticalExtensionOptions?: EncodeObject[]
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
Expand All @@ -406,7 +408,8 @@ export class CwProposalSingleV1Client
},
fee,
memo,
_funds
_funds,
nonCriticalExtensionOptions
)
}
close = async (
Expand Down
7 changes: 5 additions & 2 deletions packages/state/contracts/DaoProposalMultiple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ExecuteResult,
SigningCosmWasmClient,
} from '@cosmjs/cosmwasm-stargate'
import { EncodeObject } from '@cosmjs/proto-signing'

import {
Addr,
Expand Down Expand Up @@ -465,7 +466,8 @@ export class DaoProposalMultipleClient
},
fee: number | StdFee | 'auto' = CHAIN_GAS_MULTIPLIER,
memo?: string,
_funds?: Coin[]
_funds?: Coin[],
nonCriticalExtensionOptions?: EncodeObject[]
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
Expand All @@ -477,7 +479,8 @@ export class DaoProposalMultipleClient
},
fee,
memo,
_funds
_funds,
nonCriticalExtensionOptions
)
}
veto = async (
Expand Down
7 changes: 5 additions & 2 deletions packages/state/contracts/DaoProposalSingle.v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ExecuteResult,
SigningCosmWasmClient,
} from '@cosmjs/cosmwasm-stargate'
import { EncodeObject } from '@cosmjs/proto-signing'

import {
Addr,
Expand Down Expand Up @@ -491,7 +492,8 @@ export class DaoProposalSingleV2Client
},
fee: number | StdFee | 'auto' = CHAIN_GAS_MULTIPLIER,
memo?: string,
_funds?: Coin[]
_funds?: Coin[],
nonCriticalExtensionOptions?: EncodeObject[]
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
Expand All @@ -503,7 +505,8 @@ export class DaoProposalSingleV2Client
},
fee,
memo,
_funds
_funds,
nonCriticalExtensionOptions
)
}
veto = async (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ import { useTranslation } from 'react-i18next'
import {
ChainPickerPopup,
CopyToClipboard,
InfoLineCard,
useActionOptions,
} from '@dao-dao/stateless'
import {
ActionChainContextType,
ActionComponent,
ActionContextType,
} from '@dao-dao/types/actions'
import { getDisplayNameForChainId, getImageUrlForChainId } from '@dao-dao/utils'
import {
MAINNET,
getDisplayNameForChainId,
getImageUrlForChainId,
} from '@dao-dao/utils'

export type CreateCrossChainAccountData = {
chainId: string
Expand All @@ -38,7 +43,11 @@ export const CreateCrossChainAccountComponent: ActionComponent = ({
}

if (!chainContext.config.polytone) {
throw new Error(`Cross-chain accounts have not been enabled for ${name}.`)
throw new Error(
`Cross-chain accounts have not been enabled for ${
name || (MAINNET ? 'this chain' : 'testnets')
}.`
)
}

const missingChainIds = Object.keys(chainContext.config.polytone).filter(
Expand Down Expand Up @@ -77,31 +86,23 @@ export const CreateCrossChainAccountComponent: ActionComponent = ({
</p>
)
) : (
<div className="flex flex-row flex-wrap items-center justify-between gap-x-4 gap-y-2 rounded-md bg-background-secondary px-4 py-3">
<div className="flex flex-row items-center gap-2">
{imageUrl && (
<div
className="h-6 w-6 bg-contain bg-center bg-no-repeat"
style={{
backgroundImage: `url(${imageUrl})`,
}}
></div>
)}

<p className="primary-text shrink-0">{name}</p>
</div>

{createdAddress ? (
<CopyToClipboard
className="min-w-0"
takeN={18}
tooltip={t('button.clickToCopyAddress')}
value={createdAddress}
/>
) : (
<p className="secondary-text">{t('info.pending')}</p>
)}
</div>
<InfoLineCard
imageUrl={imageUrl}
label={name}
value={
createdAddress ? (
<CopyToClipboard
className="min-w-0"
takeN={18}
tooltip={t('button.clickToCopyAddress')}
value={createdAddress}
/>
) : (
t('info.pending')
)
}
valueClassName="!secondary-text"
/>
)}
</>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EncodeObject } from '@cosmjs/proto-signing'
import { FetchQueryOptions, QueryClient } from '@tanstack/react-query'

import {
Expand Down Expand Up @@ -308,19 +309,23 @@ export class MultipleChoiceProposalModule extends ProposalModuleBase<
getSigningClient,
sender,
memo,
nonCriticalExtensionOptions,
}: {
proposalId: number
getSigningClient: () => Promise<SupportedSigningCosmWasmClient>
sender: string
memo?: string
nonCriticalExtensionOptions?: EncodeObject[]
}): Promise<void> {
const client = await getSigningClient()
await new DaoProposalMultipleClient(client, sender, this.address).execute(
{
proposalId,
},
undefined,
memo
memo,
undefined,
nonCriticalExtensionOptions
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EncodeObject } from '@cosmjs/proto-signing'
import { FetchQueryOptions, QueryClient } from '@tanstack/react-query'

import {
Expand Down Expand Up @@ -339,11 +340,13 @@ export class SingleChoiceProposalModule extends ProposalModuleBase<
getSigningClient,
sender,
memo,
nonCriticalExtensionOptions,
}: {
proposalId: number
getSigningClient: () => Promise<SupportedSigningCosmWasmClient>
sender: string
memo?: string
nonCriticalExtensionOptions?: EncodeObject[]
}): Promise<void> {
const client = await getSigningClient()

Expand All @@ -357,7 +360,9 @@ export class SingleChoiceProposalModule extends ProposalModuleBase<
proposalId,
},
undefined,
memo
memo,
undefined,
nonCriticalExtensionOptions
)
}

Expand Down
2 changes: 2 additions & 0 deletions packages/stateful/clients/proposal-module/base.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate'
import { EncodeObject } from '@cosmjs/proto-signing'
import { FetchQueryOptions, QueryClient } from '@tanstack/react-query'

import {
Expand Down Expand Up @@ -115,6 +116,7 @@ export abstract class ProposalModuleBase<
getSigningClient: () => Promise<SigningCosmWasmClient>
sender: string
memo?: string
nonCriticalExtensionOptions?: EncodeObject[]
}): Promise<void>

/**
Expand Down
Loading

0 comments on commit f421d13

Please sign in to comment.