0
#[derive(BorshDeserialize, BorshSerialize, Debug)]
pub struct Project {
    pub name: String,
    pub description: String,
    pub image: String,
    pub owner: AccountId,
    pub supporters: UnorderedMap<AccountId, Supporter>,
    pub balance: u128,
    pub goal: u128,
    pub end_time: u64,
    pub status: ProjectStatus,
    pub plan: SupporterPlans,
    pub level_amounts: LookupMap<SupporterLevel, u128>,
}

#[near_bindgen]
#[derive(BorshDeserialize, BorshSerialize, PanicOnDefault)]
pub struct Nearkick {
    current_id: u64,
    projects: UnorderedMap<u64, Project>,
}

导致error[E0277]: the trait bound `Project: Serialize` is not satisfied, note: required by a bound in `near_sdk::serde_json::to_vec` 错误。

如果我像这样添加序列化和反序列化:

#[near_bindgen]
#[derive(Serialize, Deserialize, BorshDeserialize, BorshSerialize, PanicOnDefault)]
#[serde(crate = "near_sdk::serde")]
pub struct Nearkick {
    current_id: u64,
    projects: UnorderedMap<u64, Project>,
}

我收到这个错误error[E0277]: the trait bound `UnorderedMap<u64, Project>: Serialize` is not satisfied, note: required by `near_sdk::serde::ser::SerializeStruct::serialize_field`

货运.toml

[lib]
crate-type = ["cdylib"]

[dependencies]
near-sdk = "4.0.0-pre.2"

[profile.release]
codegen-units = 1
opt-level = "z"
lto = true
debug = false
panic = "abort"
overflow-checks = true

我尝试将 Serialize 和 Deserialize 添加到我的所有结构和枚举中,但我仍然收到错误消息。

4

0 回答 0