Open swimricky opened 4 days ago
Thanks for opening a separate issue.
I've added my thoughts on this bug here. Copy/pasting below to close the other thread:
Thanks for the detailed updates guys!
Yes, I can see now that the Anchor macro says seeds = [name.as_bytes()],
which basically means "remove the u32
size prefix of the String
type.
The really annoying thing is that this is actually not exposed on the IDL whatsoever.
"pda": {
"seeds": [
{
"kind": "arg",
"path": "name" // argument "name" is `string`, not `string.as_bytes()` or something.
}
]
}
So from the perspective of Codama, you're just getting the string
type which, by default with Anchor, is a u32
prefixed string.
Since I believe this is the way most people using string as seeds anyway, it may be okay to just assume that string seed should never have any prefix. But that would introduce a bug for anyone that currently uses u32
prefixed strings for seeds.
I think it's still worth doing but maybe best to release it in 2.0. 🤔
https://github.com/solana-program/create-solana-program/issues/108
if you have an Anchor program like the following
the generated Encoder for the seeds is incorrect. it generates the following snippet for resolving the
counter
account if not providedit should be using