Skip to content

Commit

Permalink
Use new Uint64 wasmvm types
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Nov 20, 2023
1 parent ac9d84b commit f9d365c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
22 changes: 22 additions & 0 deletions packages/go-gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,4 +524,26 @@ mod tests {
"#,
);
}

#[test]
fn timestamp_works() {
use cosmwasm_std::Timestamp;

#[cw_serde]
struct A {
a: Timestamp,
b: Option<Timestamp>,
}

let code = generate_go(cosmwasm_schema::schema_for!(A)).unwrap();
assert_code_eq(
code,
r#"
type A struct {
A Uint64 `json:"a"`
B *Uint64 `json:"b,omitempty"`
}
"#,
);
}
}
6 changes: 3 additions & 3 deletions packages/go-gen/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ pub fn documentation(schema: &SchemaObject) -> Option<String> {
/// If the given type is not a special type, returns `None`.
pub fn custom_type_of(ty: &str) -> Option<&str> {
match ty {
"Uint64" => Some("string"),
"Uint64" => Some("Uint64"),
"Uint128" => Some("string"),
"Int64" => Some("string"),
"Int64" => Some("Int64"),
"Int128" => Some("string"),
"Binary" => Some("[]byte"),
"HexBinary" => Some("Checksum"),
Expand All @@ -270,7 +270,7 @@ pub fn custom_type_of(ty: &str) -> Option<&str> {
"Decimal256" => Some("string"),
"SignedDecimal" => Some("string"),
"SignedDecimal256" => Some("string"),
"Timestamp" => Some("uint64"),
"Timestamp" => Some("Uint64"),
_ => None,
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/go-gen/tests/cosmwasm_std__IbcMsg.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Coin struct {
type IBCTimeout struct {
Block *IBCTimeoutBlock `json:"block,omitempty"` // in wasmvm, this does not have "omitempty"
// Nanoseconds since UNIX epoch
Timestamp uint64 `json:"timestamp,omitempty"` // wasmvm has a "string" in here too
Timestamp *Uint64 `json:"timestamp,omitempty"`
}

// IBCTimeoutBlock Height is a monotonically increasing data type
Expand Down

0 comments on commit f9d365c

Please sign in to comment.