You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Check whether the program name contains any digits
if(/\d/.test(programName)){
// Numbers cannot be properly converted from camelCase to snake_case,
// e.g. if the `programName` is `myProgram2`, the actual program name could
// be `my_program2` or `my_program_2`. This implementation assumes the
// latter as the default and always converts to `_numbers`.
//
// A solution to the conversion of program names with numbers in them
// would be to always convert the `programName` to camelCase instead of
// snake_case. The problem with this approach is that it would require
// converting everything else e.g. program names in Anchor.toml and IDL
// file names which are both snake_case.
programName=programName
.replace(/\d+/g,(match)=>"_"+match)
.replace("__","_");
}
I guess we could add an edge case to check both versions, but generally speaking, you'd have much better time if you avoid using numbers in your identifiers (program name, function name, account name...) because case conversion cross-language can be inconsistent or lossy.
If you have a program with a name like
program_v1
, the resulting IDL will be namedprogram_v1.json
yet the Mocha tests will expectprogram_v_1.json
.Tests should use the same name resolution as Anchor in generating the IDL.
Reproduced:
The text was updated successfully, but these errors were encountered: