Skip to content

Commit f865a37

Browse files
committed
Add ReplyOn and VoteOption support
1 parent 533dc42 commit f865a37

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

packages/go-gen/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ pub fn build_enum_variant(
151151
// we are not interested in that case, so we error out
152152
if let Some(values) = &schema.enum_values {
153153
bail!(
154-
"enum variants {} without inner data not supported",
154+
"enum variant {} without inner data not supported",
155155
values
156156
.iter()
157157
.map(|v| v.to_string())
@@ -436,7 +436,7 @@ mod tests {
436436
compare_codes!(cosmwasm_std::DistributionMsg);
437437
compare_codes!(cosmwasm_std::IbcMsg);
438438
compare_codes!(cosmwasm_std::WasmMsg);
439-
// compare_codes!(cosmwasm_std::GovMsg); // TODO: currently fails because of VoteOption
439+
compare_codes!(cosmwasm_std::GovMsg);
440440
}
441441

442442
#[test]

packages/go-gen/src/schema.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ pub fn custom_type_of(ty: &str) -> Option<&str> {
265265
"Int128" => Some("string"),
266266
"Binary" => Some("[]byte"),
267267
"HexBinary" => Some("string"),
268+
"ReplyOn" => Some("replyOn"),
269+
"VoteOption" => Some("voteOption"),
268270
"Checksum" => Some("Checksum"),
269271
"Addr" => Some("string"),
270272
"Decimal" => Some("string"),
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
type VoteMsg struct {
2+
// Option is the vote option.
3+
//
4+
// This used to be called "vote", but was changed for consistency with Cosmos SDK.
5+
// The old name is still supported for backwards compatibility.
6+
Option voteOption `json:"option"`
7+
ProposalID uint64 `json:"proposal_id"` // in wasmvm, this is `ProposalId`
8+
}
9+
10+
type VoteWeightedMsg struct {
11+
Options []WeightedVoteOption `json:"options"`
12+
ProposalID uint64 `json:"proposal_id"` // in wasmvm, this is `ProposalId`
13+
}
14+
15+
type GovMsg struct {
16+
// 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.
17+
Vote *VoteMsg `json:"vote,omitempty"`
18+
/// This maps directly to [MsgVoteWeighted](https://github.com/cosmos/cosmos-sdk/blob/v0.45.8/proto/cosmos/gov/v1beta1/tx.proto#L66-L78) in the Cosmos SDK with voter set to the contract address.
19+
VoteWeighted *VoteWeightedMsg `json:"vote_weighted,omitempty"`
20+
}
21+
22+
type WeightedVoteOption struct {
23+
Option voteOption `json:"option"`
24+
// Weight is a Decimal string, e.g. "0.25" for 25%
25+
Weight string `json:"weight"`
26+
}

0 commit comments

Comments
 (0)