-
Notifications
You must be signed in to change notification settings - Fork 22
/
proposal.ts
244 lines (216 loc) · 6.06 KB
/
proposal.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
import { ReactNode } from 'react'
import { PolytoneConnection } from './chain'
import { ProposalCardProps } from './components/ProposalCard'
import { CosmosMsgFor_Empty, ProposalStatus } from './contracts'
import { ProposalStatusKey as PreProposeApprovalProposalStatus } from './contracts/DaoPreProposeApprovalSingle'
import { ProposalResponse } from './contracts/DaoProposalSingle.v2'
import { Event } from './contracts/PolytoneListener'
import { DurationWithUnits } from './units'
export type ProposalCreatedCardProps = Omit<
ProposalCardProps,
'className' | 'onMouseOver' | 'onMouseLeave' | 'LinkWrapper'
>
export type ProposalRelayState = {
/**
* Whether or not there are any cross-chain messages.
*/
hasCrossChainMessages: boolean
/**
* The relay states for the decoded message packets.
*/
states: {
all: CrossChainPacketInfoState[]
pending: (CrossChainPacketInfoStatePending & { index: number })[]
relayed: (CrossChainPacketInfoStateRelayed & { index: number })[]
errored: (CrossChainPacketInfoStateErrored & { index: number })[]
timedOut: (CrossChainPacketInfoStateTimedOut & { index: number })[]
}
/**
* Whether or not there are cross-chain messages that need to be self-relayed.
* Most chains have relayers set up, so no need to self-relay on those chains.
* After a few minutes if there are still messages that need to be relayed,
* they can be self-relayed. This will be true when unrelayed messages exist
* on a chain with no relayers or when there are still unrelayed messages
* after a few minutes.
*/
needsSelfRelay: boolean
/**
* Opens the execute and self-relay modal.
*/
openSelfRelay: () => void
}
export type DecodedPolytoneMsgMatch = {
match: true
chainId: string
polytoneConnection: PolytoneConnection
// The first message, or empty object if none.
msg: Record<string, any>
// The first message, or undefined if none.
cosmosMsg: CosmosMsgFor_Empty | undefined
// All messages.
msgs: Record<string, any>[]
cosmosMsgs: CosmosMsgFor_Empty[]
initiatorMsg: string
}
export type DecodedPolytoneMsgNoMatch = {
match: false
}
export type DecodedPolytoneMsg =
| DecodedPolytoneMsgNoMatch
| DecodedPolytoneMsgMatch
export type DecodedIcaMsgMatch = {
match: true
chainId: string
// The first message, or undefined if none.
msgWithSender:
| {
sender: string
msg: Record<string, any>
}
| undefined
// The first message, or undefined if none.
cosmosMsgWithSender:
| {
sender: string
msg: CosmosMsgFor_Empty
}
| undefined
// All messages.
msgsWithSenders: {
sender: string
msg: Record<string, any>
}[]
cosmosMsgsWithSenders: {
sender: string
msg: CosmosMsgFor_Empty
}[]
}
export type DecodedIcaMsgNoMatch = {
match: false
}
export type DecodedIcaMsg = DecodedIcaMsgNoMatch | DecodedIcaMsgMatch
export enum CrossChainPacketInfoType {
Polytone = 'polytone',
Ica = 'ica',
}
export type PolytoneCrossChainPacketInfo = {
type: CrossChainPacketInfoType.Polytone
data: DecodedPolytoneMsgMatch
sender: string
srcConnection: string
srcChannel: string
srcPort: string
dstConnection: string
dstChannel: string
dstPort: string
}
export type IcaCrossChainPacketInfo = {
type: CrossChainPacketInfoType.Ica
data: DecodedIcaMsgMatch
sender: string
srcConnection: string
// Cannot determine srcChannel from decoded message.
srcPort: string
dstConnection: string
// Cannot determine dstChannel from decoded message.
dstPort: string
}
export type CrossChainPacketInfo =
| PolytoneCrossChainPacketInfo
| IcaCrossChainPacketInfo
export enum CrossChainPacketInfoStatus {
Pending = 'pending',
Relayed = 'relayed',
Errored = 'errored',
TimedOut = 'timedOut',
}
export type CrossChainPacketInfoStatePending = {
status: CrossChainPacketInfoStatus.Pending
packet: CrossChainPacketInfo
}
export type CrossChainPacketInfoStateRelayed = {
status: CrossChainPacketInfoStatus.Relayed
packet: CrossChainPacketInfo
/**
* Execution events per message within the cross-chain packet.
*/
msgResponses: {
events: Event[]
}[]
}
export type CrossChainPacketInfoStateErrored = {
status: CrossChainPacketInfoStatus.Errored
packet: CrossChainPacketInfo
/**
* The captured error string.
*/
error: string
}
export type CrossChainPacketInfoStateTimedOut = {
status: CrossChainPacketInfoStatus.TimedOut
packet: CrossChainPacketInfo
}
export type CrossChainPacketInfoState =
| CrossChainPacketInfoStatePending
| CrossChainPacketInfoStateRelayed
| CrossChainPacketInfoStateErrored
| CrossChainPacketInfoStateTimedOut
export enum ProcessedTQType {
Majority,
Absolute,
Percent,
}
export type ProcessedTQ = { display: string } & (
| { type: ProcessedTQType.Majority }
| { type: ProcessedTQType.Absolute | ProcessedTQType.Percent; value: number }
)
export type ProcessedThresholdQuorum = {
threshold: ProcessedTQ
quorum?: ProcessedTQ
}
export type ProcessedQuorum = {
quorum: ProcessedTQ
}
export enum ApprovalProposalContextType {
Approval = 'approval',
Approver = 'approver',
}
export type ApprovalProposalContext =
| {
type: ApprovalProposalContextType.Approval
status: PreProposeApprovalProposalStatus
}
| {
type: ApprovalProposalContextType.Approver
status: ProposalStatus
}
export type ProposalVetoConfig = {
enabled: boolean
addresses: {
address: string
}[]
// If there are multiple addresses, this must be set to the cw1-whitelist
// contract from the list of addresses. If there is only one address, then
// this should be undefined.
cw1WhitelistAddress: string | undefined
timelockDuration: DurationWithUnits
earlyExecute: boolean
vetoBeforePassed: boolean
}
/**
* Information about the timelock overrule that was created for a timelocked
* proposal on Neutron.
*/
export type NeutronTimelockOverrule = {
dao: string
proposalModulePrefix: string
proposal: ProposalResponse
}
export type ProposalTimestampInfo = {
display?: {
label: string
tooltip?: string
content: ReactNode
}
expirationDate?: Date
}