Skip to content

Commit

Permalink
Support Neutron timelocked proposal statuses and overrule actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Jan 19, 2024
1 parent db51ac0 commit 22d79e9
Show file tree
Hide file tree
Showing 29 changed files with 1,236 additions and 55 deletions.
12 changes: 12 additions & 0 deletions packages/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
"go": "Go",
"goBack": "Go back",
"goToDaoPage": "Go to DAO page",
"goToOverruleProposal": "Go to overrule proposal",
"goToProposal": "Go to proposal",
"gotIt": "Got it",
"hide": "Hide",
Expand Down Expand Up @@ -1071,6 +1072,7 @@
"optionInert": "This option will not perform any actions if it wins.",
"orSelectWallet": "or select a wallet...",
"otherNotifiersNotShown": "Notifiers setup by others are not shown.",
"overruleSubDaoProposalDescription": "Overrule a proposal in a SubDAO.",
"overwritingSave": "This save will overwrite the existing one with the same name.",
"paid": "Paid",
"passing": "Passing",
Expand Down Expand Up @@ -1100,16 +1102,23 @@
"notOpenMultipleChoice_closed": "This proposal is closed for voting with a turnout of {{turnoutPercent}}. It was rejected and closed.",
"notOpenMultipleChoice_executed": "This proposal is closed for voting with a turnout of {{turnoutPercent}} and {{turnoutWinningPercent}} of voters voting for {{turnoutWinner}}. It was passed and executed.",
"notOpenMultipleChoice_executionFailed": "This proposal is closed for voting with a turnout of {{turnoutPercent}} and {{turnoutWinningPercent}} of voters voting for {{turnoutWinner}}. It was passed but execution failed.",
"notOpenMultipleChoice_overruleTimelock": "This proposal is closed for voting with a turnout of {{turnoutPercent}} and {{turnoutWinningPercent}} of voters voting for {{turnoutWinner}}. It is now frozen until overruled or until the overrule period expires, after which it can be executed.",
"notOpenMultipleChoice_overruled": "This proposal is closed for voting with a turnout of {{turnoutPercent}} and {{turnoutWinningPercent}} of voters voting for {{turnoutWinner}}. However, it was overruled.",
"notOpenMultipleChoice_passed": "This proposal is closed for voting with a turnout of {{turnoutPercent}} and {{turnoutWinningPercent}} of voters voting for {{turnoutWinner}}. It was passed and now needs to be executed.",
"notOpenMultipleChoice_rejected": "This proposal is closed for voting with a turnout of {{turnoutPercent}}. It was rejected and now needs to be closed.",
"notOpenMultipleChoice_vetoTimelock": "This proposal is closed for voting with a turnout of {{turnoutPercent}} and {{turnoutWinningPercent}} of voters voting for {{turnoutWinner}}. It is now frozen until vetoed or until the veto period expires, after which it can be executed.",
"notOpenMultipleChoice_vetoedNoWinner": "This proposal is closed for voting with a turnout of {{turnoutPercent}}. It was vetoed.",
"notOpenMultipleChoice_vetoedWinner": "This proposal is closed for voting with a turnout of {{turnoutPercent}} and {{turnoutWinningPercent}} of voters voting for {{turnoutWinner}}. However, it was vetoed.",
"notOpenSingleChoice": "This proposal is closed for voting with a turnout of {{turnoutPercent}} and {{turnoutYesPercent}} of voters in favor.",
"notOpenSingleChoice_closed": "This proposal is closed for voting with a turnout of {{turnoutPercent}} and {{turnoutYesPercent}} of voters in favor. It was rejected and closed.",
"notOpenSingleChoice_executed": "This proposal is closed for voting with a turnout of {{turnoutPercent}} and {{turnoutYesPercent}} of voters in favor. It was passed and executed.",
"notOpenSingleChoice_executionFailed": "This proposal is closed for voting with a turnout of {{turnoutPercent}} and {{turnoutYesPercent}} of voters in favor. It was passed but execution failed.",
"notOpenSingleChoice_overruleTimelock": "This proposal is closed for voting with a turnout of {{turnoutPercent}} and {{turnoutYesPercent}} of voters in favor. It is now frozen until overruled or until the overrule period expires, after which it can be executed.",
"notOpenSingleChoice_overruledNotPassed": "This proposal is closed for voting with a turnout of {{turnoutPercent}} and {{turnoutYesPercent}} of voters in favor. It was overruled.",
"notOpenSingleChoice_overruledPassed": "This proposal is closed for voting with a turnout of {{turnoutPercent}} and {{turnoutYesPercent}} of voters in favor. However, it was overruled.",
"notOpenSingleChoice_passed": "This proposal is closed for voting with a turnout of {{turnoutPercent}} and {{turnoutYesPercent}} of voters in favor. It was passed and now needs to be executed.",
"notOpenSingleChoice_rejected": "This proposal is closed for voting with a turnout of {{turnoutPercent}} and {{turnoutYesPercent}} of voters in favor. It was rejected and now needs to be closed.",
"notOpenSingleChoice_vetoTimelock": "This proposal is closed for voting with a turnout of {{turnoutPercent}} and {{turnoutYesPercent}} of voters in favor. It is now frozen until vetoed or until the veto period expires, after which it can be executed.",
"notOpenSingleChoice_vetoedNotPassed": "This proposal is closed for voting with a turnout of {{turnoutPercent}} and {{turnoutYesPercent}} of voters in favor. It was vetoed.",
"notOpenSingleChoice_vetoedPassed": "This proposal is closed for voting with a turnout of {{turnoutPercent}} and {{turnoutYesPercent}} of voters in favor. However, it was vetoed.",
"willFail": "If the current vote stands, this proposal will fail.",
Expand Down Expand Up @@ -1337,6 +1346,7 @@
"proposalClosed": "Proposal closed.",
"proposalCreatedCompleteCompensationCycle": "Proposal published. Complete the compensation cycle by saving the proposal ID.",
"proposalExecuted": "Executed. Updating data and refreshing page...",
"proposalOverruled": "Proposal overruled.",
"proposalSimulation": "Proposal simulated successfully. If executed right now, it would not fail.",
"proposalVetoed": "Proposal vetoed.",
"ratingsSubmitted": "Ratings submitted.",
Expand Down Expand Up @@ -1564,6 +1574,8 @@
"openProposals": "Open proposals",
"other": "Other",
"otherMembers": "Other Members",
"overrule": "Overrule",
"overruleSubDaoProposal": "Overrule SubDAO Proposal",
"owner": "Owner",
"pages": "Pages",
"passingThreshold": "Passing threshold",
Expand Down
294 changes: 294 additions & 0 deletions packages/state/contracts/NeutronCwdPreProposeSingleOverrule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
import { Coin, StdFee } from '@cosmjs/amino'
import {
CosmWasmClient,
ExecuteResult,
SigningCosmWasmClient,
} from '@cosmjs/cosmwasm-stargate'

import {
Addr,
Config,
DepositInfoResponse,
ProposeMessage,
QueryExt,
Status,
UncheckedDenom,
UncheckedDepositInfo,
} from '@dao-dao/types/contracts/NeutronCwdPreProposeSingleOverrule'

export interface NeutronCwdPreProposeSingleOverruleReadOnlyInterface {
contractAddress: string
proposalModule: () => Promise<Addr>
dao: () => Promise<Addr>
config: () => Promise<Config>
depositInfo: ({
proposalId,
}: {
proposalId: number
}) => Promise<DepositInfoResponse>
queryExtension: ({ msg }: { msg: QueryExt }) => Promise<string | number>
}
export class NeutronCwdPreProposeSingleOverruleQueryClient
implements NeutronCwdPreProposeSingleOverruleReadOnlyInterface
{
client: CosmWasmClient
contractAddress: string

constructor(client: CosmWasmClient, contractAddress: string) {
this.client = client
this.contractAddress = contractAddress
this.proposalModule = this.proposalModule.bind(this)
this.dao = this.dao.bind(this)
this.config = this.config.bind(this)
this.depositInfo = this.depositInfo.bind(this)
this.queryExtension = this.queryExtension.bind(this)
}

proposalModule = async (): Promise<Addr> => {
return this.client.queryContractSmart(this.contractAddress, {
proposal_module: {},
})
}
dao = async (): Promise<Addr> => {
return this.client.queryContractSmart(this.contractAddress, {
dao: {},
})
}
config = async (): Promise<Config> => {
return this.client.queryContractSmart(this.contractAddress, {
config: {},
})
}
depositInfo = async ({
proposalId,
}: {
proposalId: number
}): Promise<DepositInfoResponse> => {
return this.client.queryContractSmart(this.contractAddress, {
deposit_info: {
proposal_id: proposalId,
},
})
}
queryExtension = async ({
msg,
}: {
msg: QueryExt
}): Promise<string | number> => {
return this.client.queryContractSmart(this.contractAddress, {
query_extension: {
msg,
},
})
}
}
export interface NeutronCwdPreProposeSingleOverruleInterface
extends NeutronCwdPreProposeSingleOverruleReadOnlyInterface {
contractAddress: string
sender: string
propose: (
{
msg,
}: {
msg: ProposeMessage
},
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[]
) => Promise<ExecuteResult>
updateConfig: (
{
depositInfo,
openProposalSubmission,
}: {
depositInfo?: UncheckedDepositInfo
openProposalSubmission: boolean
},
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[]
) => Promise<ExecuteResult>
withdraw: (
{
denom,
}: {
denom?: UncheckedDenom
},
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[]
) => Promise<ExecuteResult>
proposalCreatedHook: (
{
proposalId,
proposer,
}: {
proposalId: number
proposer: string
},
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[]
) => Promise<ExecuteResult>
proposalCompletedHook: (
{
newStatus,
proposalId,
}: {
newStatus: Status
proposalId: number
},
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[]
) => Promise<ExecuteResult>
}
export class NeutronCwdPreProposeSingleOverruleClient
extends NeutronCwdPreProposeSingleOverruleQueryClient
implements NeutronCwdPreProposeSingleOverruleInterface
{
client: SigningCosmWasmClient
sender: string
contractAddress: string

constructor(
client: SigningCosmWasmClient,
sender: string,
contractAddress: string
) {
super(client, contractAddress)
this.client = client
this.sender = sender
this.contractAddress = contractAddress
this.propose = this.propose.bind(this)
this.updateConfig = this.updateConfig.bind(this)
this.withdraw = this.withdraw.bind(this)
this.proposalCreatedHook = this.proposalCreatedHook.bind(this)
this.proposalCompletedHook = this.proposalCompletedHook.bind(this)
}

propose = async (
{
msg,
}: {
msg: ProposeMessage
},
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[]
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
propose: {
msg,
},
},
fee,
memo,
_funds
)
}
updateConfig = async (
{
depositInfo,
openProposalSubmission,
}: {
depositInfo?: UncheckedDepositInfo
openProposalSubmission: boolean
},
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[]
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
update_config: {
deposit_info: depositInfo,
open_proposal_submission: openProposalSubmission,
},
},
fee,
memo,
_funds
)
}
withdraw = async (
{
denom,
}: {
denom?: UncheckedDenom
},
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[]
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
withdraw: {
denom,
},
},
fee,
memo,
_funds
)
}
proposalCreatedHook = async (
{
proposalId,
proposer,
}: {
proposalId: number
proposer: string
},
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[]
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
proposal_created_hook: {
proposal_id: proposalId,
proposer,
},
},
fee,
memo,
_funds
)
}
proposalCompletedHook = async (
{
newStatus,
proposalId,
}: {
newStatus: Status
proposalId: number
},
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[]
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
proposal_completed_hook: {
new_status: newStatus,
proposal_id: proposalId,
},
},
fee,
memo,
_funds
)
}
}
4 changes: 4 additions & 0 deletions packages/state/contracts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ export {
DaoVotingTokenStakedClient,
DaoVotingTokenStakedQueryClient,
} from './DaoVotingTokenStaked'
export {
NeutronCwdPreProposeSingleOverruleClient,
NeutronCwdPreProposeSingleOverruleQueryClient,
} from './NeutronCwdPreProposeSingleOverrule'
export {
NeutronCwdSubdaoPreProposeSingleClient,
NeutronCwdSubdaoPreProposeSingleQueryClient,
Expand Down
Loading

0 comments on commit 22d79e9

Please sign in to comment.