Skip to content

Commit 79cafc8

Browse files
authored
Merge pull request #973 from CosmWasm/voting-msg
Add GovMsg to CosmosMsg
2 parents 9997ae2 + f819874 commit 79cafc8

File tree

7 files changed

+291
-0
lines changed

7 files changed

+291
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to
1010

1111
- cosmwasm-std: Implement `Sub` and `SubAssign` for `Uint128`
1212
- cosmwasm-std: Implement custom events for contract execution results
13+
- cosmwasm-std: Add `CosmosMsg::Gov` for voting on governance proposals.
1314

1415
### Removed
1516

contracts/ibc-reflect-send/schema/execute_msg.json

+52
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,18 @@
273273
}
274274
},
275275
"additionalProperties": false
276+
},
277+
{
278+
"type": "object",
279+
"required": [
280+
"gov"
281+
],
282+
"properties": {
283+
"gov": {
284+
"$ref": "#/definitions/GovMsg"
285+
}
286+
},
287+
"additionalProperties": false
276288
}
277289
]
278290
},
@@ -329,6 +341,37 @@
329341
"description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)",
330342
"type": "object"
331343
},
344+
"GovMsg": {
345+
"anyOf": [
346+
{
347+
"description": "This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address.",
348+
"type": "object",
349+
"required": [
350+
"vote"
351+
],
352+
"properties": {
353+
"vote": {
354+
"type": "object",
355+
"required": [
356+
"proposal_id",
357+
"vote"
358+
],
359+
"properties": {
360+
"proposal_id": {
361+
"type": "integer",
362+
"format": "uint64",
363+
"minimum": 0.0
364+
},
365+
"vote": {
366+
"$ref": "#/definitions/VoteOption"
367+
}
368+
}
369+
}
370+
},
371+
"additionalProperties": false
372+
}
373+
]
374+
},
332375
"IbcMsg": {
333376
"description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)",
334377
"anyOf": [
@@ -582,6 +625,15 @@
582625
"description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```",
583626
"type": "string"
584627
},
628+
"VoteOption": {
629+
"type": "string",
630+
"enum": [
631+
"yes",
632+
"no",
633+
"abstain",
634+
"no_with_veto"
635+
]
636+
},
585637
"WasmMsg": {
586638
"description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto",
587639
"anyOf": [

contracts/ibc-reflect-send/schema/packet_msg.json

+52
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,18 @@
226226
}
227227
},
228228
"additionalProperties": false
229+
},
230+
{
231+
"type": "object",
232+
"required": [
233+
"gov"
234+
],
235+
"properties": {
236+
"gov": {
237+
"$ref": "#/definitions/GovMsg"
238+
}
239+
},
240+
"additionalProperties": false
229241
}
230242
]
231243
},
@@ -282,6 +294,37 @@
282294
"description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)",
283295
"type": "object"
284296
},
297+
"GovMsg": {
298+
"anyOf": [
299+
{
300+
"description": "This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address.",
301+
"type": "object",
302+
"required": [
303+
"vote"
304+
],
305+
"properties": {
306+
"vote": {
307+
"type": "object",
308+
"required": [
309+
"proposal_id",
310+
"vote"
311+
],
312+
"properties": {
313+
"proposal_id": {
314+
"type": "integer",
315+
"format": "uint64",
316+
"minimum": 0.0
317+
},
318+
"vote": {
319+
"$ref": "#/definitions/VoteOption"
320+
}
321+
}
322+
}
323+
},
324+
"additionalProperties": false
325+
}
326+
]
327+
},
285328
"IbcMsg": {
286329
"description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)",
287330
"anyOf": [
@@ -535,6 +578,15 @@
535578
"description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```",
536579
"type": "string"
537580
},
581+
"VoteOption": {
582+
"type": "string",
583+
"enum": [
584+
"yes",
585+
"no",
586+
"abstain",
587+
"no_with_veto"
588+
]
589+
},
538590
"WasmMsg": {
539591
"description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto",
540592
"anyOf": [

contracts/ibc-reflect/schema/packet_msg.json

+52
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,18 @@
225225
}
226226
},
227227
"additionalProperties": false
228+
},
229+
{
230+
"type": "object",
231+
"required": [
232+
"gov"
233+
],
234+
"properties": {
235+
"gov": {
236+
"$ref": "#/definitions/GovMsg"
237+
}
238+
},
239+
"additionalProperties": false
228240
}
229241
]
230242
},
@@ -281,6 +293,37 @@
281293
"description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)",
282294
"type": "object"
283295
},
296+
"GovMsg": {
297+
"anyOf": [
298+
{
299+
"description": "This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address.",
300+
"type": "object",
301+
"required": [
302+
"vote"
303+
],
304+
"properties": {
305+
"vote": {
306+
"type": "object",
307+
"required": [
308+
"proposal_id",
309+
"vote"
310+
],
311+
"properties": {
312+
"proposal_id": {
313+
"type": "integer",
314+
"format": "uint64",
315+
"minimum": 0.0
316+
},
317+
"vote": {
318+
"$ref": "#/definitions/VoteOption"
319+
}
320+
}
321+
}
322+
},
323+
"additionalProperties": false
324+
}
325+
]
326+
},
284327
"IbcMsg": {
285328
"description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)",
286329
"anyOf": [
@@ -534,6 +577,15 @@
534577
"description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```",
535578
"type": "string"
536579
},
580+
"VoteOption": {
581+
"type": "string",
582+
"enum": [
583+
"yes",
584+
"no",
585+
"abstain",
586+
"no_with_veto"
587+
]
588+
},
537589
"WasmMsg": {
538590
"description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto",
539591
"anyOf": [

contracts/reflect/schema/execute_msg.json

+52
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,18 @@
244244
}
245245
},
246246
"additionalProperties": false
247+
},
248+
{
249+
"type": "object",
250+
"required": [
251+
"gov"
252+
],
253+
"properties": {
254+
"gov": {
255+
"$ref": "#/definitions/GovMsg"
256+
}
257+
},
258+
"additionalProperties": false
247259
}
248260
]
249261
},
@@ -325,6 +337,37 @@
325337
}
326338
]
327339
},
340+
"GovMsg": {
341+
"anyOf": [
342+
{
343+
"description": "This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address.",
344+
"type": "object",
345+
"required": [
346+
"vote"
347+
],
348+
"properties": {
349+
"vote": {
350+
"type": "object",
351+
"required": [
352+
"proposal_id",
353+
"vote"
354+
],
355+
"properties": {
356+
"proposal_id": {
357+
"type": "integer",
358+
"format": "uint64",
359+
"minimum": 0.0
360+
},
361+
"vote": {
362+
"$ref": "#/definitions/VoteOption"
363+
}
364+
}
365+
}
366+
},
367+
"additionalProperties": false
368+
}
369+
]
370+
},
328371
"IbcMsg": {
329372
"description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)",
330373
"anyOf": [
@@ -619,6 +662,15 @@
619662
"description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```",
620663
"type": "string"
621664
},
665+
"VoteOption": {
666+
"type": "string",
667+
"enum": [
668+
"yes",
669+
"no",
670+
"abstain",
671+
"no_with_veto"
672+
]
673+
},
622674
"WasmMsg": {
623675
"description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto",
624676
"anyOf": [

contracts/reflect/schema/response_for__custom_msg.json

+52
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,18 @@
231231
}
232232
},
233233
"additionalProperties": false
234+
},
235+
{
236+
"type": "object",
237+
"required": [
238+
"gov"
239+
],
240+
"properties": {
241+
"gov": {
242+
"$ref": "#/definitions/GovMsg"
243+
}
244+
},
245+
"additionalProperties": false
234246
}
235247
]
236248
},
@@ -332,6 +344,37 @@
332344
}
333345
}
334346
},
347+
"GovMsg": {
348+
"anyOf": [
349+
{
350+
"description": "This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address.",
351+
"type": "object",
352+
"required": [
353+
"vote"
354+
],
355+
"properties": {
356+
"vote": {
357+
"type": "object",
358+
"required": [
359+
"proposal_id",
360+
"vote"
361+
],
362+
"properties": {
363+
"proposal_id": {
364+
"type": "integer",
365+
"format": "uint64",
366+
"minimum": 0.0
367+
},
368+
"vote": {
369+
"$ref": "#/definitions/VoteOption"
370+
}
371+
}
372+
}
373+
},
374+
"additionalProperties": false
375+
}
376+
]
377+
},
335378
"IbcMsg": {
336379
"description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)",
337380
"anyOf": [
@@ -626,6 +669,15 @@
626669
"description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```",
627670
"type": "string"
628671
},
672+
"VoteOption": {
673+
"type": "string",
674+
"enum": [
675+
"yes",
676+
"no",
677+
"abstain",
678+
"no_with_veto"
679+
]
680+
},
629681
"WasmMsg": {
630682
"description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto",
631683
"anyOf": [

0 commit comments

Comments
 (0)