IDLs with 'account' suffixes cause duplicate methods
Willyham opened this issue · 3 comments
Willyham commented
Assume an IDL with this structure:
{
"version": "0.0.0",
"name": "program",
"instructions": [
"name": "bar",
"accounts": [
{
"name": "foo",
"isMut": false,
"isSigner": true
},
{
"name": "fooAccount",
"isMut": true,
"isSigner": false
}
]
]
}
As Account
is stripped from the latter name, duplicate GetFoo
and SetFoo
receiver methods are created. I'm running into this in the real world with an existing project.
Happy to contribute a fix but not sure what the solution should be. Possibilities:
- Don't strip
Account
entirely - Drop strip if conflict exists.
- Add extra suffix if conflict exists
- Error out and don't generate code
gagliardetto commented
That's a tricky issue.
Let's see what happens in each case:
Don't strip Account entirely
SetFooAccount
SetFooAccountAccount
Drop strip if conflict exists.
That's reasonable.
Add extra suffix if conflict exists
I feel this is the same as the first scenario, with a different suffix.
Error out and don't generate code
This also would make sense.
How about this:
- By default, don't strip the account suffix.
- A special flag allows to strip the suffix.
- Fatal error if there is a name conflict (whether with flag or not).
Willyham commented
Yep, that sounds like a good solution.
gagliardetto commented
Release v0.2.2