-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cosmwasm_std::entry_point
parses data for disabled feature
#2271
Comments
Working workaround is making wrapper around instantiate function and having both instantiate functions included Based on the example from the issue description: #[cfg(feature = "u32")]
#[cosmwasm_std::entry_point]
pub fn instantiate(
deps: DepsMut,
env: Env,
info: MessageInfo,
msg: InstantiateMsg<u32>,
) -> Result<Response, Never> {
_instantiate(deps, env, info, msg)
}
#[cfg(not(feature = "u32"))]
#[cosmwasm_std::entry_point]
pub fn instantiate(
deps: DepsMut,
env: Env,
info: MessageInfo,
msg: InstantiateMsg<u64>,
) -> Result<Response, Never> {
_instantiate(deps, env, info, msg)
}
pub fn _instantiate(
_deps: DepsMut,
_env: Env,
_info: MessageInfo,
#[cfg(feature = "u32")] _msg: InstantiateMsg<u32>,
#[cfg(not(feature = "u32"))] _msg: InstantiateMsg<u64>,
) -> Result<Response, Never> {
Ok(Response::new())
} |
You have a point here. This is a result of the way the entry_point macro is implemented. mod __wasm_export_instantiate {
#[no_mangle]
extern "C" fn instantiate(env_ptr: u32, info_ptr: u32, msg_ptr: u32, msg_ptr2: u32) -> u32 {
cosmwasm_std::do_instantiate(&super::instantiate, env_ptr, info_ptr, msg_ptr, msg_ptr2)
}
} In this specific case, the only fix I can think of would be to keep the |
Won't it be better then to just ignore how many arguments entry point have and just generate always the same extern function? So instead of counting arguments, instantiate will have always 3 pointers |
That already doesn't work as a full solution because we just introduced an additional version of |
cosmwasm_std::entry_point
forward all arguments to the export function from the entry point function, even if this argument should not be included in this feature.I think it's best to see as minimal example
Compiling it with "u32" or without "u32" feature enabled will error with:
The text was updated successfully, but these errors were encountered: