@@ -10,6 +10,7 @@ use syn::{
1010
1111pub fn write_api_impl ( input : Options ) -> Block {
1212 let api_object = generate_api_impl ( & input) ;
13+ let crate_name = input. crate_name ;
1314 let name = input. name ;
1415
1516 parse_quote ! {
@@ -19,7 +20,7 @@ pub fn write_api_impl(input: Options) -> Block {
1920 use :: std:: env;
2021 use :: std:: fs:: { create_dir_all, write} ;
2122
22- use :: cosmwasm_schema :: { remove_schemas, Api , QueryResponses } ;
23+ use #crate_name :: { remove_schemas, Api , QueryResponses } ;
2324
2425 let mut out_dir = env:: current_dir( ) . unwrap( ) ;
2526 out_dir. push( "schema" ) ;
@@ -50,6 +51,7 @@ pub fn write_api_impl(input: Options) -> Block {
5051
5152pub fn generate_api_impl ( input : & Options ) -> ExprStruct {
5253 let Options {
54+ crate_name,
5355 name,
5456 version,
5557 instantiate,
@@ -61,7 +63,7 @@ pub fn generate_api_impl(input: &Options) -> ExprStruct {
6163 } = input;
6264
6365 parse_quote ! {
64- :: cosmwasm_schema :: Api {
66+ #crate_name :: Api {
6567 contract_name: #name. to_string( ) ,
6668 contract_version: #version. to_string( ) ,
6769 instantiate: #instantiate,
@@ -121,6 +123,7 @@ impl Parse for Pair {
121123
122124#[ derive( Debug ) ]
123125pub struct Options {
126+ crate_name : TokenStream ,
124127 name : TokenStream ,
125128 version : TokenStream ,
126129 instantiate : TokenStream ,
@@ -136,6 +139,13 @@ impl Parse for Options {
136139 let pairs = input. parse_terminated ( Pair :: parse, Token ! [ , ] ) ?;
137140 let mut map: BTreeMap < _ , _ > = pairs. into_iter ( ) . map ( |p| p. 0 ) . collect ( ) ;
138141
142+ let crate_name = if let Some ( crate_name_override) = map. remove ( & parse_quote ! ( crate_name) ) {
143+ let crate_name_override = crate_name_override. get_type ( ) ?;
144+ quote ! { #crate_name_override }
145+ } else {
146+ quote ! { :: cosmwasm_schema }
147+ } ;
148+
139149 let name = if let Some ( name_override) = map. remove ( & parse_quote ! ( name) ) {
140150 let name_override = name_override. get_str ( ) ?;
141151 quote ! {
@@ -206,6 +216,7 @@ impl Parse for Options {
206216 }
207217
208218 Ok ( Self {
219+ crate_name,
209220 name,
210221 version,
211222 instantiate,
0 commit comments