Skip to content

Commit 4f2c527

Browse files
committed
Support RawRangeResponse in go-gen
1 parent 45cd57c commit 4f2c527

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

packages/go-gen/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mod schema;
1111
mod utils;
1212

1313
fn main() -> Result<()> {
14-
let root = cosmwasm_schema::schema_for!(cosmwasm_std::Reply);
14+
let root = cosmwasm_schema::schema_for!(cosmwasm_std::RawRangeResponse);
1515

1616
let code = generate_go(root)?;
1717
println!("{}", code);
@@ -355,6 +355,7 @@ mod tests {
355355
// wasm
356356
compare_codes!(cosmwasm_std::ContractInfoResponse);
357357
compare_codes!(cosmwasm_std::CodeInfoResponse);
358+
compare_codes!(cosmwasm_std::RawRangeResponse);
358359
}
359360

360361
#[test]

packages/go-gen/src/schema.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,16 @@ pub fn array_item_type(
246246
Some(SingleOrVec::Single(array_validation)) => {
247247
schema_object_type(array_validation.object()?, type_context, additional_structs)
248248
}
249+
Some(SingleOrVec::Vec(v))
250+
if v.len() == 1 || v.len() > 1 && v.windows(2).all(|w| w[0] == w[1]) =>
251+
{
252+
// all items are the same type
253+
schema_object_type(
254+
v.first().unwrap().object()?,
255+
type_context,
256+
additional_structs,
257+
)
258+
}
249259
_ => bail!("array type with non-singular item type is not supported"),
250260
}
251261
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
type RawRangeResponse struct {
2+
// The key-value pairs
3+
Data Array[Array[[]byte]] `json:"data"`
4+
// `None` if there are no more key-value pairs within the given key range.
5+
NextKey *[]byte `json:"next_key,omitempty"`
6+
}

0 commit comments

Comments
 (0)