1

我正在尝试在外部参数声明中使用以下结构:

pub struct PriceUpdate {
    pub source_currency: Vec<u8>,
    pub target_currency: Vec<u8>,
    pub provider: Vec<u8>,
    pub price: i64,
}

这是外部声明:

pub fn new_price(origin: OriginFor<T>, price_update: PriceUpdate) -> DispatchResult {

这会导致编译错误:

^^^^^^^^^^^ the trait `WrapperTypeEncode` is not implemented for `PriceUpdate`

有人可以解释对于复杂类型(例如结构/vecs/vecs 的结构/等)的外部参数的要求是什么?我看过 WrapperTypeEncode 文档https://docs.rs/parity-scale-codec/2.2.0/parity_scale_codec/trait.WrapperTypeEncode.html但他们没有拼出这些信息。

非常感谢!

4

1 回答 1

0

简单地从奇偶规模编解码器派生。

use parity_scale_codec::{Encode, Decode};

#[derive(Encode, Decode)]
pub struct ...

外部是托盘级别的调用。在这里,它解释了调用参数需要这些特征绑定。https://crates.parity.io/frame_support/attr.pallet.html#call-palletcall-optional

于 2021-09-10T06:30:48.460 回答