metaplex-foundation / mpl-candy-machine

Mint your NFT collection on Solana
https://developers.metaplex.com/candy-machine
Other
73 stars 57 forks source link

safeFetchCandyGuard throws errors on missing #57

Open sohrab- opened 10 months ago

sohrab- commented 10 months ago

My understanding of safe* functions was that they return null when the account does not exist. However, it actually throws an UnexpectedAccountError on the empty buffer.

UnexpectedAccountError: The account at the provided address [3ix9kizh1uKa7PEYhWUHLseMRVMtqgu5eSUTZ6LT3Ezt] is not of the expected type [CandyGuard].

Source: SDK

Caused By: DeserializingEmptyBufferError: Serializer [i8] cannot deserialize empty buffers.

    at deserializeAccount (Account.ts:63:11)
    at deserializeCandyGuard (candyGuard.ts:90:10)
    at safeFetchCandyGuard (candyGuard.ts:125:7)

@metaplex-foundation/mpl-candy-machine v6.0.0

lorisleiva commented 10 months ago

Hi there, I think this is to do with an account that exists (i.e. had some lamports) but no data. The "safe" part currently doesn't protect you against accounts that exist but don't have the expected data. I'm in two minds whether it should or not.