我试图从TopDecode读取输入的内容,但是erdpy contract report报告has-allocator等于true。下面是我当前的片段。
impl<M: ManagedTypeApi> TopDecode for PenguinAttributes<M> {
fn top_decode<I: elrond_codec::TopDecodeInput>(input: I) -> Result<Self, DecodeError> {
let boxed_bytes = input.into_boxed_slice_u8();
return Result::Ok(PenguinAttributes::empty());
}
}我已经注释了boxed_bytes方法,现在已分配器等于false。
但是,在不使用分配器的情况下,如何读取输入的内容呢?
我正在使用elrond 0.29.3和erdpy 1.2.3。
谢谢
我输入Hat:unequipped;Beak:Golden Beak (BEAK-a1a1a1-05)的一个例子。
发布于 2022-04-08 16:22:28
我通过在512数组中加载我的字节来实现这一点。然后,我将数组从0读取到managed_buffer.length。
impl<M: ManagedTypeApi> TopDecode for PenguinAttributes<M> {
fn top_decode<I: elrond_codec::TopDecodeInput>(input: I) -> Result<Self, DecodeError> {
let mut bytes: [u8; 512] = [0; 512];
managed_buffer.load_to_byte_array(&mut bytes);
return Result::Ok(PenguinAttributes::empty());
}
}https://stackoverflow.com/questions/71503778
复制相似问题