2
#[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>,
}

causes error[E0277]: the trait bound `Project: Serialize` is not satisfied, note: required by a bound in `near_sdk::serde_json::to_vec` error.

If I add Serialize and Deserialize to it like this:

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

I get this error error[E0277]: the trait bound `UnorderedMap<u64, Project>: Serialize` is not satisfied, note: required by `near_sdk::serde::ser::SerializeStruct::serialize_field`

Cargo.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

I tried adding Serialize and Deserialize to all of my structs and enums, but I still get the error.

Amir Šaran
  • 406
  • 1
  • 4
  • 14

1 Answers1

1

You have two methods:

Wabinab
  • 21
  • 2
  • 4