Conversation
|
many thanks for the contribution, but i'd like to use the same (or similar approach) to what agave does in the account decoder: agave doesn't use magic byte offsets at all. Instead, it tries to deserialize the data as each type and lets the unpack logic decide after merging of #385 i'll be unblocked to make something similar to what
MR above already have ParseMintWithExtensions and ParseAccountWithExtensions so the resulting code will be somehow similar to the following: func IsTokenMint(acc *Account) bool {
if acc == nil {
return false
}
data := acc.Data.GetBinary()
switch acc.Owner {
case solana.TokenProgramID:
return len(data) == MintSize // 82
case solana.Token2022ProgramID:
_, err := ParseMintWithExtensions(data)
return err == nil
}
return false
}but to be honest, i don't sure this glad to hear your oppinion on it and actual use-case |
When working with Token2022 determining token mint is a bit annoying
Helper takes raw account and checks the data len + byte to check if its a mint correctly
We could add this as its own helper in token_2022 but thought it sat better pre-decode