@@ -130,6 +130,14 @@ fn expand_bindings(crate_path: &syn::Path, mut function: syn::ItemFn) -> TokenSt
130
130
let fn_name = & function. sig . ident ;
131
131
let wasm_export = format_ident ! ( "__wasm_export_{fn_name}" ) ;
132
132
133
+ // Prevent contract dev from using the wrong identifier for the do_migrate_with_info function
134
+ if fn_name == "migrate_with_info" {
135
+ return syn:: Error :: new_spanned (
136
+ & function. sig . ident ,
137
+ r#"To use the new migrate function signature, you should provide a "migrate" entry point, not "migrate_with_info""# ,
138
+ ) . into_compile_error ( ) ;
139
+ }
140
+
133
141
// Migrate entry point can take 2 or 3 arguments
134
142
let do_call = if fn_name == "migrate" && args == 3 {
135
143
format_ident ! ( "do_migrate_with_info" )
@@ -263,6 +271,26 @@ mod test {
263
271
} ;
264
272
265
273
assert_eq ! ( actual. to_string( ) , expected. to_string( ) ) ;
274
+
275
+ // this should cause a compiler error
276
+ let code = quote ! {
277
+ #[ entry_point]
278
+ pub fn migrate_with_info(
279
+ deps: DepsMut ,
280
+ env: Env ,
281
+ msg: MigrateMsg ,
282
+ migrate_info: MigrateInfo ,
283
+ ) -> Result <Response , ( ) > {
284
+ // Logic here
285
+ }
286
+ } ;
287
+
288
+ let actual = entry_point_impl ( TokenStream :: new ( ) , code) ;
289
+ let expected = quote ! {
290
+ :: core:: compile_error! { "To use the new migrate function signature, you should provide a \" migrate\" entry point, not \" migrate_with_info\" " }
291
+ } ;
292
+
293
+ assert_eq ! ( actual. to_string( ) , expected. to_string( ) ) ;
266
294
}
267
295
268
296
#[ test]
0 commit comments