5

I currently have defined a Ship struct in my backend code, as well as a Port struct which contains an attribute ships_berthed that is of type Vec.

However, on my frontend (Svelte), when I try to call on the aforementioned vector, I receive an error that goes: IdlError: Type not found: {"type":{"defined":"Ship"}}

I am assuming this is from my .ts file in my types folder but I am unsure how to resolve it. Any help would be greatly appreciated! :))

1 Answer 1

1

I also having the same issue then i came across this thread. The mistake was silly/funny.

I had this

#[derive(AnchorSerialize, AnchorDeserialize, Clone)]
struct Friend {
    address: Pubkey,
    friend_at: i64,
    last_meet: i64
}

#[account]
pub struct User {
    name: String,
    age: u8,
    friends: Vec<Friend>,
    school: String
}

Then is changed it to this

#[derive(AnchorSerialize, AnchorDeserialize, Clone)]
pub struct Friend {
    address: Pubkey,
    friend_at: i64,
    last_meet: i64
}

#[account]
pub struct User {
    name: String,
    age: u8,
    friends: Vec<Friend>,
    school: String
}

Yeah just forget to add pub keyword in front of Friend struct. Your problem could be something else but this was the case for me. Thank You.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.