@@ -10,6 +10,7 @@ use syn::{
10
10
11
11
pub fn write_api_impl ( input : Options ) -> Block {
12
12
let api_object = generate_api_impl ( & input) ;
13
+ let crate_name = input. crate_name ;
13
14
let name = input. name ;
14
15
15
16
parse_quote ! {
@@ -19,7 +20,7 @@ pub fn write_api_impl(input: Options) -> Block {
19
20
use :: std:: env;
20
21
use :: std:: fs:: { create_dir_all, write} ;
21
22
22
- use :: cosmwasm_schema :: { remove_schemas, Api , QueryResponses } ;
23
+ use #crate_name :: { remove_schemas, Api , QueryResponses } ;
23
24
24
25
let mut out_dir = env:: current_dir( ) . unwrap( ) ;
25
26
out_dir. push( "schema" ) ;
@@ -50,6 +51,7 @@ pub fn write_api_impl(input: Options) -> Block {
50
51
51
52
pub fn generate_api_impl ( input : & Options ) -> ExprStruct {
52
53
let Options {
54
+ crate_name,
53
55
name,
54
56
version,
55
57
instantiate,
@@ -61,7 +63,7 @@ pub fn generate_api_impl(input: &Options) -> ExprStruct {
61
63
} = input;
62
64
63
65
parse_quote ! {
64
- :: cosmwasm_schema :: Api {
66
+ #crate_name :: Api {
65
67
contract_name: #name. to_string( ) ,
66
68
contract_version: #version. to_string( ) ,
67
69
instantiate: #instantiate,
@@ -121,6 +123,7 @@ impl Parse for Pair {
121
123
122
124
#[ derive( Debug ) ]
123
125
pub struct Options {
126
+ crate_name : TokenStream ,
124
127
name : TokenStream ,
125
128
version : TokenStream ,
126
129
instantiate : TokenStream ,
@@ -136,6 +139,13 @@ impl Parse for Options {
136
139
let pairs = input. parse_terminated ( Pair :: parse, Token ! [ , ] ) ?;
137
140
let mut map: BTreeMap < _ , _ > = pairs. into_iter ( ) . map ( |p| p. 0 ) . collect ( ) ;
138
141
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
+
139
149
let name = if let Some ( name_override) = map. remove ( & parse_quote ! ( name) ) {
140
150
let name_override = name_override. get_str ( ) ?;
141
151
quote ! {
@@ -206,6 +216,7 @@ impl Parse for Options {
206
216
}
207
217
208
218
Ok ( Self {
219
+ crate_name,
209
220
name,
210
221
version,
211
222
instantiate,
0 commit comments