Skip to content

Commit

Permalink
working version
Browse files Browse the repository at this point in the history
  • Loading branch information
magiodev committed Jul 11, 2024
1 parent c659d09 commit 79ab707
Show file tree
Hide file tree
Showing 75 changed files with 8,824 additions and 85 deletions.
55 changes: 55 additions & 0 deletions packages/quasar/contracts/DaoProposalSingleInstant.common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Addr, Decimal, Uint128 } from '@dao-dao/types/contracts/common'

export enum Vote {
Yes = 'yes',
No = 'no',
Abstain = 'abstain',
}

export type Threshold =
| {
absolute_percentage: {
percentage: PercentageThreshold
}
}
| {
threshold_quorum: {
quorum: PercentageThreshold
threshold: PercentageThreshold
}
}
| {
absolute_count: {
threshold: Uint128
}
}

export type PercentageThreshold =
| {
majority: {}
}
| {
percent: Decimal
}

export interface Votes {
abstain: Uint128
no: Uint128
yes: Uint128
}

export interface VoteInfo {
power: Uint128
vote: Vote
voter: Addr
rationale?: string | null
votedAt?: string
}

export interface ListVotesResponse {
votes: VoteInfo[]
}

export interface VoteResponse {
vote?: VoteInfo | null
}
239 changes: 239 additions & 0 deletions packages/quasar/contracts/DaoProposalSingleInstant.v2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
import {
Addr,
Binary,
ContractVersionInfo,
CosmosMsgFor_Empty,
Duration,
Expiration,
ModuleInstantiateInfo,
ProposalStatus,
Uint128,
} from '@dao-dao/types/contracts/common'
import { Threshold, Vote, Votes } from './DaoProposalSingleInstant.common'

export interface ConfigResponse {
allow_revoting: boolean
close_proposal_on_execution_failure: boolean
dao: Addr
max_voting_period: Duration
min_voting_period?: Duration | null
only_members_execute: boolean
threshold: Threshold
veto?: VetoConfig | null
}
export type DaoResponse = string
export type ExecuteMsg =
| {
propose: {
description: string
msgs: CosmosMsgFor_Empty[]
proposer?: string | null
title: string
}
}
| {
vote: {
proposal_id: number
vote: Vote
}
}
| {
execute: {
proposal_id: number
}
}
| {
veto: {
proposal_id: number
}
}
| {
close: {
proposal_id: number
}
}
| {
update_config: {
allow_revoting: boolean
close_proposal_on_execution_failure: boolean
dao: string
max_voting_period: Duration
min_voting_period?: Duration | null
only_members_execute: boolean
threshold: Threshold
veto?: VetoConfig | null
}
}
| {
update_pre_propose_info: {
info: PreProposeInfo
}
}
| {
add_proposal_hook: {
address: string
}
}
| {
remove_proposal_hook: {
address: string
}
}
| {
add_vote_hook: {
address: string
}
}
| {
remove_vote_hook: {
address: string
}
}
export type PreProposeInfo =
| {
anyone_may_propose: {}
}
| {
module_may_propose: {
info: ModuleInstantiateInfo
}
}
export type GovernanceModulesResponse = Addr[]
export type ExtensionResponse = Binary
export interface InfoResponse {
info: ContractVersionInfo
}
export interface InstantiateMsg {
allow_revoting: boolean
close_proposal_on_execution_failure: boolean
max_voting_period: Duration
min_voting_period?: Duration | null
only_members_execute: boolean
pre_propose_info: PreProposeInfo
threshold: Threshold
veto?: VetoConfig | null
}
export interface VetoConfig {
early_execute: boolean
timelock_duration: Duration
veto_before_passed: boolean
vetoer: string
}
export interface ListProposalsResponse {
proposals: ProposalResponse[]
}
export interface ProposalResponse {
id: number
proposal: SingleChoiceProposal
// Indexer may return these.
createdAt?: string
completedAt?: string
executedAt?: string
closedAt?: string
}
export interface SingleChoiceProposal {
allow_revoting: boolean
description: string
expiration: Expiration
min_voting_period?: Expiration | null
msgs: CosmosMsgFor_Empty[]
proposer: Addr
start_height: number
status: ProposalStatus
threshold: Threshold
title: string
total_power: Uint128
veto?: VetoConfig | null
votes: Votes
}
export type MigrateMsg =
| {
from_v1: {
close_proposal_on_execution_failure: boolean
pre_propose_info: PreProposeInfo
veto?: VetoConfig | null
}
}
| {
from_compatible: {}
}
export type ProposalCountResponse = number
// v2 changed case.
export type ProposalCreationPolicyResponse =
| {
Anyone: {}
}
| {
anyone: {}
}
| {
Module: {
addr: Addr
}
}
| {
module: {
addr: Addr
}
}
export interface ProposalHooksResponse {
hooks: string[]
}
export type QueryMsg =
| {
config: {}
}
| {
proposal: {
proposal_id: number
}
}
| {
list_proposals: {
limit?: number | null
start_after?: number | null
}
}
| {
reverse_proposals: {
limit?: number | null
start_before?: number | null
}
}
| {
proposal_count: {}
}
| {
get_vote: {
proposal_id: number
voter: string
}
}
| {
list_votes: {
limit?: number | null
proposal_id: number
start_after?: string | null
}
}
| {
proposal_creation_policy: {}
}
| {
proposal_hooks: {}
}
| {
vote_hooks: {}
}
| {
dao: {}
}
| {
info: {}
}
export interface ReverseProposalsResponse {
proposals: ProposalResponse[]
}
export interface VoteHooksResponse {
hooks: string[]
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,21 @@ const useUpdatePreProposeConfigActions = (): ProposalModuleWithAction[] => {
() =>
proposalModules.flatMap(
(proposalModule): ProposalModuleWithAction | [] => {
if (proposalModule.contractName === 'crates.io:dao-proposal-single-instant') {
return [];
}
const action = matchAndLoadCommon(proposalModule, {
chain: options.chain,
coreAddress,
}).fields.updatePreProposeConfigActionMaker?.(options);
}).fields.updatePreProposeConfigActionMaker?.(options)

return action
? {
proposalModule,
action,
}
: [];
proposalModule,
action,
}
: []
}
),
[coreAddress, options, proposalModules]
);
)

return proposalModuleActions
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,21 @@ const useUpdateProposalConfigActions = (): ProposalModuleWithAction[] => {
() =>
proposalModules.flatMap(
(proposalModule): ProposalModuleWithAction | [] => {
if (proposalModule.contractName === 'crates.io:dao-proposal-single-instant') {
return [];
}

const action = matchAndLoadCommon(proposalModule, {
chain: options.chain,
coreAddress,
}).fields.updateConfigActionMaker?.(options);
}).fields.updateConfigActionMaker(options)

return action
? {
proposalModule,
action,
}
: [];
proposalModule,
action,
}
: []
}
),
[coreAddress, options, proposalModules]
);
)

return proposalModuleActions
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback, useMemo } from 'react'
import { atom, useRecoilValueLoadable, waitForAll, waitForAllSettled } from 'recoil'
import { useRecoilValueLoadable, waitForAll, waitForAllSettled } from 'recoil'

import {
DaoCoreV2Selectors,
Expand Down Expand Up @@ -227,20 +227,14 @@ export const makeUpgradeV1ToV2Action: ActionMaker<UpgradeV1ToV2Data> = ({
// Get proposal module deposit info to pass through to pre-propose.
const depositInfoSelectors = availableDaos?.map(
({ address: coreAddress, proposalModules }) =>
proposalModules.map((proposalModule) => {
if (proposalModule.contractName === 'crates.io:dao-proposal-single-instant') {
return atom({
key: 'dummyRecoilState',
default: null,
});
}
return matchAndLoadCommon(proposalModule, {
chain,
coreAddress,
}).selectors.depositInfo;
})
);

proposalModules.map(
(proposalModule) =>
matchAndLoadCommon(proposalModule, {
chain,
coreAddress,
}).selectors.depositInfo
)
)
// The deposit infos are ordered to match the proposal modules in the DAO
// core list, which is what the migration contract expects.
const proposalModuleDepositInfosLoadable = useCachedLoadable(
Expand Down
Loading

0 comments on commit 79ab707

Please sign in to comment.