received an error:
The replica returned a replica error: reject code CanisterError, reject message Canister be2us-64aaa-aaaaa-qaabq-cai trapped explicitly: Panicked at 'called `Result::unwrap()` on an `Err` value: Custom(Fail to decode argument 0
Caused by:
Subtyping error: field trade_id is not optional field)', src/localicpCore/src/types/offer.rs:85:39, error code None
#[derive(CandidType, Serialize, Clone, Deserialize, Debug)]
pub struct TradeDetails {
pub created_at: u64,
pub time_limit: u64,
pub trade_id: u128,
pub rate: u32,
pub token: Principal,
pub currency: String,
pub total_token_amount: u128,
pub total_amount_to_be_paid: u128,
pub escrow_id: Option<u128>,
pub seller: Principal,
pub buyer: Principal,
pub selected_payment_method: String,
pub msg_count: u32,
pub msgs: HashMap<u32, MessageDetails>,
pub buyer_marked_payment_at: Option<u64>,
pub seller_released_at: Option<u64>,
}
impl Storable for TradeDetails {
fn from_bytes(bytes: std::borrow::Cow<[u8]>) -> Self {
Decode!(bytes.as_ref(), Self).unwrap()
}
fn to_bytes(&self) -> std::borrow::Cow<[u8]> {
std::borrow::Cow::Owned(Encode!(self).unwrap())
}
const BOUND: Bound = Bound::Unbounded;
}
error points out this line caused the error Decode!(bytes.as_ref(), Self).unwrap()
!!