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

Add governance proposal submit and deposit actions #1300

Merged
merged 20 commits into from
Jul 13, 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
2 changes: 1 addition & 1 deletion apps/dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@types/formidable": "^2.0.5",
"cors": "^2.8.5",
"formidable": "^2.0.1",
"interchain-rpc": "1.5.0",
"interchain-rpc": "^1.5.0",
"lodash.clonedeep": "^4.5.0",
"next": "^13.3.0",
"next-intercept-stdout": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion apps/sda/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@types/formidable": "^2.0.5",
"cors": "^2.8.5",
"formidable": "^2.0.1",
"interchain-rpc": "1.5.0",
"interchain-rpc": "^1.5.0",
"lodash.clonedeep": "^4.5.0",
"next": "^13.3.0",
"next-intercept-stdout": "^1.0.1",
Expand Down
21 changes: 21 additions & 0 deletions packages/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"emoji": {
"baby": "Baby",
"ballotBox": "Ballot box",
"bank": "Bank",
"bee": "Bee",
"box": "Box",
"brokenHeart": "Broken heart",
Expand Down Expand Up @@ -236,6 +237,7 @@
"pencil": "Pencil",
"people": "People",
"pick": "Mining pick",
"raisedHand": "Raised hand",
"recycle": "Recycle",
"robot": "Robot",
"suitAndTie": "Suit and tie",
Expand Down Expand Up @@ -402,6 +404,7 @@
"dates": "Dates",
"defaultTierName": "Core contributors",
"delegatorAddress": "Delegator address",
"deposit": "Deposit",
"description": "Description",
"descriptionOptional": "Description (optional)",
"dragFileHereOrClick": "Drag file here or <2>click</2> to select.",
Expand Down Expand Up @@ -438,6 +441,7 @@
"iContributedPlaceholder": "I contributed...",
"image": "Image",
"imageUrlTooltip": "A link to an image. For example: https://moonphase.is/image.svg",
"initialDeposit": "Initial deposit",
"initialSupply": "Total token supply",
"instantiatedAddress": "Instantiated address",
"instructions": "Instructions",
Expand Down Expand Up @@ -473,21 +477,25 @@
"options": "Options",
"orUploadOne": "...or upload one below.",
"outputToken": "Output token",
"parameterChanges": "Parameter changes",
"passingThresholdDescription": "Passing threshold works differently depending on whether your DAO has a quorum.\n- If your DAO has *no quorum*, this is the percentage of the DAO's voting power that must vote 'yes' for a proposal to pass.\n- If your DAO *has a quorum*, the passing threshold is only calculated from those who voted.",
"passingThresholdTitle": "Passing threshold",
"passingThresholdWithQuorumDescription": "The proportion of those who voted on a single choice proposal who must vote 'Yes' for it to pass.",
"payment": "Payment",
"percentOfTotalSupply": "Percent of total token supply",
"percentOfTotalSupplyTooltip": "{{weight}} of the total token supply will be split evenly among all of the members in this tier. Want to add members with different voting power? Add another tier.",
"plan": "Plan",
"postToDelete": "Post to delete",
"postToUpdate": "Post to update",
"proposalDepositDescription": "The number of tokens that must be deposited to create a proposal. Setting this may deter spam, but setting it too high may limit broad participation.",
"proposalDepositTitle": "Proposal deposit",
"proposalSubmissionPolicyDescription": "Who is allowed to submit proposals to the DAO?",
"proposalSubmissionPolicyTitle": "Proposal submission policy",
"proposalType": "Proposal type",
"proposalsDescriptionPlaceholder": "Give your proposal a description...",
"proposalsName": "Proposal's name",
"proposalsNamePlaceholder": "Give your proposal a name",
"proposedSpends": "Proposed spends",
"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.",
"quorumTitle": "Quorum",
"ratingInstructionsPlaceholder": "This is what DAO members will see when they are rating the contributions. Explain how they should rate.",
Expand Down Expand Up @@ -577,11 +585,19 @@
"depositPeriod": "Deposit Period",
"failed": "Failed",
"passed": "Passed",
"pendingSubmission": "Pending Submission",
"rejected": "Rejected",
"unrecognized": "Unrecognized",
"unspecified": "Unspecified",
"votingPeriod": "Voting Period"
},
"govProposalType": {
"CancelSoftwareUpgradeProposal": "Cancel Software Upgrade",
"CommunityPoolSpendProposal": "Community Pool Spend",
"ParameterChangeProposal": "Parameter Change",
"SoftwareUpgradeProposal": "Software Upgrade",
"TextProposal": "Text"
},
"info": {
"abstainVote": "Abstain",
"actionPageWarning": "There are {{actions}} actions across {{pages}} pages. Make sure you view all pages before voting.",
Expand Down Expand Up @@ -649,6 +665,7 @@
"depositFiatDescription": "Buy $USDC with a card or bank account, and it will be sent directly to the DAO's treasury. Balances may take some time to update once the Kado transaction completes.",
"depositFromStargazeQuestion": "Deposit NFTs from Stargaze?",
"depositNftsModalSubtitle": "Select the NFTs you want to deposit into {{daoName}} from your Stargaze wallet.",
"depositToGovernanceProposalDescription": "Deposit to a chain governance proposal in the deposit period.",
"depositTokenSubtitle": "Tokens will be sent from your wallet.",
"depositTokenWarning": "Tokens will be sent from your wallet to the DAO. You cannot undo a deposit. You will not gain voting power by depositing tokens.",
"disabled": "Disabled",
Expand Down Expand Up @@ -734,6 +751,7 @@
"noDaosFollowedYet": "You have not yet followed any DAOs.",
"noDisplayName": "no display name",
"noFundsDuringInstantiation": "No funds will be transferred during instantiation.",
"noGovernanceProposalsNeedDeposit": "There are no governance proposals that need deposits.",
"noGovernanceProposalsOpenForVoting": "There are no governance proposals open for voting.",
"noNftsFound": "No NFTs found.",
"noNftsYet": "No NFTs to appreciate yet.",
Expand Down Expand Up @@ -841,6 +859,7 @@
"subjectsCurrentlyCastVoteTooltip": "This is the vote that {{subject}} already cast. Casting another vote will replace this one.",
"subjectsVote": "{{subject}} vote",
"submissionsBeingRated": "Members of the DAO are rating submissions. After the rating period closes, the DAO will publish a proposal to distribute compensation according to their responses.",
"submitGovernanceProposalDescription": "Submit a proposal to chain governance.",
"submitUpgradeProposal": "Submit a proposal to upgrade the DAO?",
"submitted": "Submitted",
"supportsMarkdownFormat": "Supports Markdown format",
Expand Down Expand Up @@ -1057,6 +1076,7 @@
"depositFiat": "Deposit fiat",
"depositNfts": "Import NFTs",
"depositRefunds": "Deposit refunds",
"depositToGovernanceProposal": "Deposit to Governance Proposal",
"depositToken": "Deposit ${{tokenSymbol}}",
"deposits": "Deposits",
"description": "Description",
Expand Down Expand Up @@ -1214,6 +1234,7 @@
"start": "Start",
"status": "Status",
"subDaos": "SubDAOs",
"submitGovernanceProposal": "Submit Governance Proposal",
"suggestions": "Suggestions",
"summary": "Summary",
"supplies": "Supplies",
Expand Down
2 changes: 1 addition & 1 deletion packages/state/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@dao-dao/utils": "2.2.0",
"cosmjs-types": "^0.5.2",
"graphql": "^16.6.0",
"interchain-rpc": "1.5.0",
"interchain-rpc": "^1.5.0",
"json5": "^2.2.0",
"meilisearch": "^0.30.0",
"pusher-js": "^7.6.0",
Expand Down
39 changes: 36 additions & 3 deletions packages/state/recoil/selectors/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
Proposal as GovProposal,
WeightedVoteOption,
} from 'interchain-rpc/types/codegen/cosmos/gov/v1beta1/gov'
import { QueryParamsResponse as GovQueryParamsResponse } from 'interchain-rpc/types/codegen/cosmos/gov/v1beta1/query'
import {
DelegationResponse,
UnbondingDelegation as RpcUnbondingDelegation,
Expand Down Expand Up @@ -43,7 +44,7 @@ import {
NATIVE_TOKEN,
cosmWasmClientRouter,
cosmosValidatorToValidator,
decodeGovProposalContent,
decodeGovProposal,
getAllRpcResponse,
getRpcForChainId,
isJunoIbcUsdc,
Expand Down Expand Up @@ -412,7 +413,7 @@ export const govProposalsSelector = selectorFamily<
}

return proposals
.map((proposal) => decodeGovProposalContent(proposal))
.map((proposal) => decodeGovProposal(proposal))
.sort((a, b) => a.votingEndTime.getTime() - b.votingEndTime.getTime())
},
})
Expand All @@ -434,7 +435,7 @@ export const govProposalSelector = selectorFamily<
})
)?.proposal

return proposal && decodeGovProposalContent(proposal)
return proposal && decodeGovProposal(proposal)
},
})

Expand All @@ -458,6 +459,38 @@ export const govProposalVoteSelector = selectorFamily<
},
})

// Queries the chain for the minimum deposit required.
export const govQueryParamsSelector = selectorFamily<
Required<GovQueryParamsResponse>,
WithChainId<{}>
>({
key: 'govQueryParams',
get:
({ chainId }) =>
async ({ get }) => {
const client = get(cosmosRpcClientForChainSelector(chainId))

const [{ votingParams }, { depositParams }, { tallyParams }] =
await Promise.all([
client.gov.v1beta1.params({
paramsType: 'voting',
}),
client.gov.v1beta1.params({
paramsType: 'deposit',
}),
client.gov.v1beta1.params({
paramsType: 'tallying',
}),
])

return {
votingParams,
depositParams,
tallyParams,
}
},
})

export const validatorsSelector = selectorFamily<Validator[], WithChainId<{}>>({
key: 'validators',
get:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { ComponentMeta, ComponentStory } from '@storybook/react'
import { cosmos } from 'interchain-rpc'
import Long from 'long'

import { ReactHookFormDecorator } from '@dao-dao/storybook'
import { GovProposalWithDecodedContent } from '@dao-dao/types'

import { PayEntityDisplay } from '../../../../components/PayEntityDisplay'
import { TokenAmountDisplay } from '../../../../components/TokenAmountDisplay'
import { GovernanceDepositComponent } from './Component'

export default {
title:
'DAO DAO / packages / stateful / actions / core / chain_governance / GovernanceDeposit',
component: GovernanceDepositComponent,
decorators: [ReactHookFormDecorator],
} as ComponentMeta<typeof GovernanceDepositComponent>

const Template: ComponentStory<typeof GovernanceDepositComponent> = (args) => (
<GovernanceDepositComponent {...args} />
)

const { ProposalStatus } = cosmos.gov.v1beta1

const makeProposal = (): GovProposalWithDecodedContent => ({
proposalId: Long.fromInt(1),
content: {} as any,
decodedContent: {
'@type': '/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal',
title: 'Upgrade to v10 Alpha 1',
description:
'Full details on the testnets github. Target binary is v10.0.0-alpha.2',
plan: {
name: 'v10',
time: '0001-01-01T00:00:00Z',
height: '20000',
info: '',
upgraded_client_state: null,
},
} as any,
status: ProposalStatus.PROPOSAL_STATUS_DEPOSIT_PERIOD,
finalTallyResult: {
yes: '54076995000',
abstain: '0',
no: '0',
noWithVeto: '0',
},
submitTime: new Date('2022-09-23T22:56:17.961690524Z'),
depositEndTime: new Date('2022-10-03T22:56:17.961690524Z'),
totalDeposit: [
{
denom: 'ujunox',
amount: '500000000',
},
],
votingStartTime: new Date('2022-09-23T22:56:17.961690524Z'),
votingEndTime: new Date('2022-09-24T10:56:17.961690524Z'),
})

export const Default = Template.bind({})
Default.args = {
fieldNamePrefix: '',
allActionsWithData: [],
index: 0,
data: {
proposalId: '',
deposit: [
{
denom: 'JUNOX',
amount: 1,
},
],
},
isCreating: true,
errors: {},
options: {
proposals: [makeProposal(), makeProposal(), makeProposal(), makeProposal()],
depositTokens: { loading: false, data: [] },
PayEntityDisplay,
TokenAmountDisplay,
},
}
Loading