-
Notifications
You must be signed in to change notification settings - Fork 369
/
Copy pathlib.rs
41 lines (35 loc) · 1.09 KB
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
pub mod contract;
/** Below we expose wasm exports **/
#[cfg(target_arch = "wasm32")]
pub use cosmwasm::exports::{allocate, deallocate};
#[cfg(target_arch = "wasm32")]
pub use wasm::{handle, init};
#[cfg(target_arch = "wasm32")]
mod wasm {
use super::contract;
use cosmwasm::{exports, imports};
use std::ffi::c_void;
#[no_mangle]
pub extern "C" fn init(params_ptr: *mut c_void, msg_ptr: *mut c_void) -> *mut c_void {
exports::do_init(
&contract::init::<imports::ExternalStorage, imports::ExternalApi>,
params_ptr,
msg_ptr,
)
}
#[no_mangle]
pub extern "C" fn handle(params_ptr: *mut c_void, msg_ptr: *mut c_void) -> *mut c_void {
exports::do_handle(
&contract::handle::<imports::ExternalStorage, imports::ExternalApi>,
params_ptr,
msg_ptr,
)
}
#[no_mangle]
pub extern "C" fn query(msg_ptr: *mut c_void) -> *mut c_void {
exports::do_query(
&contract::query::<imports::ExternalStorage, imports::ExternalApi>,
msg_ptr,
)
}
}