feat: return raw bytes from ABI chunk generators
@@ -23,13 +23,19 @@ pub fn generate(i: &ItemImplInfo) -> TokenStream2 {
#[cfg(not(target_arch = "wasm32"))]
const _: () = {
#[no_mangle]
- pub fn #near_abi_symbol() -> near_sdk::__private::ChunkedAbiEntry {
+ pub extern "C" fn #near_abi_symbol() -> (*const u8, usize) {
let mut gen = near_sdk::__private::schemars::gen::SchemaGenerator::default();
let functions = vec![#(#functions),*];
- near_sdk::__private::ChunkedAbiEntry::new(
+ let mut data = std::mem::ManuallyDrop::new(
+ near_sdk::serde_json::to_vec(&near_sdk::__private::ChunkedAbiEntry::new(
functions,
- gen.into_root_schema_for::<String>()
- )
+ gen.into_root_schema_for::<String>(),
+ ))
+ .unwrap(),
+ );
+ data.shrink_to_fit();
+ assert!(data.len() == data.capacity());
+ (data.as_ptr(), data.len())
}
};
}
