-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typo/Inconistent naming in Pause helper functions #70
Comments
The idea here is that different patterns use different prefixes (like |
I personally prefer verbosity. Abbreviations can be confusing and riskier (more subject to misinterpretation), especially across languages and cultures. I like how Petar added this rule to our standard Eslint config that we're now using: https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prevent-abbreviations.md Do these function names even need prefixes? If yes, I wonder if it would make sense for the prefixes to be |
This is intended to be consistent with the pattern adopted by existing NEPs. For example:
Although I also prefer verbosity, I think convention & consistency with the ecosystem is worth mentioning. Also, at least to me, it is not obvious that That is to say, the prefix is intended to be an identifier, and obvious as an identifier. I think that it is not intended to carry meaning beyond identification, although the prefixes thus far have been derived from the human-readable name of the standard / namespace they represent. |
This is also relevant if we intend to propose the components that expose external functions as NEPs. |
Yes, convention & consistency with the ecosystem is definitely worth considering. Also, NEAR is new enough (and NCT may become important enough) that maybe this will help define convention going forward. I don't have strong opinions here. I'm curious what prefixes you're currently leaning towards @encody and also what @nearken , @sandoche , @twitu, and @RobertNear think too. |
I agree with @encody, i'll avoid prefixes everywhere, except for standards such as |
If I were to propose a naming standard in a vacuum, it would probably be something like:
|
A couple of points to add to uniform naming convention, since I've been looking at more code. Traits to expose external functions have the same keyword as prefix and suffix. Since prefix is needed to avoid namespace collision the suffix can be removed. It'll also result in shorter names without any loss of information. Along with the proposal for fully named prefixes the #[ext_contract(ext_owner)]
pub trait OwnerExternal {
/// Returns the account ID of the current owner
fn owner_get(&self) -> Option<AccountId>;
/// Returns the account ID that the current owner has proposed take over ownership
fn owner_get_proposed(&self) -> Option<AccountId>;
...
} Currently the functions are |
@encody on your suggestion for naming convention. The separator could be a single underscore If there's no specific reason for double underscores we could go with single. The other parts look good 👍. |
The reason for the two underscores is to make it very clear that the prefix is a prefix. If there is some other, better character combination (that wouldn't then be easy to confuse with a non-standard method name), please let me know! |
All the functions being exposed externally will be grouped together in the same trait. It will be visually clear that the same keyword is the prefix, a separate character for distinction may not be necessary. But I'm not opposed to it, if there's something that fits the function naming convention. |
Once the contract is compiled to WASM, the types (traits, etc.) are all erased, so if you query the WASM, only the exposed function names remain. Transactions calling the contract also don't have to reference (or even know about the existence of) a trait, so none of that information is present in a block explorer, for example. |
A method and macro attribute
standard
for the pause utility is namedpaus
which looks inconsistent compared to other methods which are named with fullpause
.https://github.com/NEARFoundation/near-contract-tools/blob/aad160bb15455eff3bb3b733d0e9da46bb01ceae/macros/src/pause.rs#L46-L49
https://github.com/NEARFoundation/near-contract-tools/blob/aad160bb15455eff3bb3b733d0e9da46bb01ceae/src/pause.rs#L25-L32
The text was updated successfully, but these errors were encountered: