Skip to content

Commit f9d365c

Browse files
committed
Use new Uint64 wasmvm types
1 parent ac9d84b commit f9d365c

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

packages/go-gen/src/main.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,4 +524,26 @@ mod tests {
524524
"#,
525525
);
526526
}
527+
528+
#[test]
529+
fn timestamp_works() {
530+
use cosmwasm_std::Timestamp;
531+
532+
#[cw_serde]
533+
struct A {
534+
a: Timestamp,
535+
b: Option<Timestamp>,
536+
}
537+
538+
let code = generate_go(cosmwasm_schema::schema_for!(A)).unwrap();
539+
assert_code_eq(
540+
code,
541+
r#"
542+
type A struct {
543+
A Uint64 `json:"a"`
544+
B *Uint64 `json:"b,omitempty"`
545+
}
546+
"#,
547+
);
548+
}
527549
}

packages/go-gen/src/schema.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ pub fn documentation(schema: &SchemaObject) -> Option<String> {
259259
/// If the given type is not a special type, returns `None`.
260260
pub fn custom_type_of(ty: &str) -> Option<&str> {
261261
match ty {
262-
"Uint64" => Some("string"),
262+
"Uint64" => Some("Uint64"),
263263
"Uint128" => Some("string"),
264-
"Int64" => Some("string"),
264+
"Int64" => Some("Int64"),
265265
"Int128" => Some("string"),
266266
"Binary" => Some("[]byte"),
267267
"HexBinary" => Some("Checksum"),
@@ -270,7 +270,7 @@ pub fn custom_type_of(ty: &str) -> Option<&str> {
270270
"Decimal256" => Some("string"),
271271
"SignedDecimal" => Some("string"),
272272
"SignedDecimal256" => Some("string"),
273-
"Timestamp" => Some("uint64"),
273+
"Timestamp" => Some("Uint64"),
274274
_ => None,
275275
}
276276
}

packages/go-gen/tests/cosmwasm_std__IbcMsg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type Coin struct {
3030
type IBCTimeout struct {
3131
Block *IBCTimeoutBlock `json:"block,omitempty"` // in wasmvm, this does not have "omitempty"
3232
// Nanoseconds since UNIX epoch
33-
Timestamp uint64 `json:"timestamp,omitempty"` // wasmvm has a "string" in here too
33+
Timestamp *Uint64 `json:"timestamp,omitempty"`
3434
}
3535

3636
// IBCTimeoutBlock Height is a monotonically increasing data type

0 commit comments

Comments
 (0)