-
Notifications
You must be signed in to change notification settings - Fork 137
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
Update Meta Standard to include snake case method names as a standard #96
Comments
We can do both. Every contract method can be exposed in both camel and snake case, it is a tiny modification to near-sdk-rs and will have a negligible effect on contract size. |
Specifically, currently for each impl method |
Closing in favor of near/near-sdk-rs#209 |
We still need the guideline for standards. The standards is what people will be using when composing contracts and using them from frontend. E.g. when writing code like this should work with ANY contract in the future: https://github.com/ilblackdragon/balancer-near/blob/master/balancer-pool/src/btoken.rs#L127 |
This issue does not explain why we need standard, if near-sdk-* can expose all contract methods in both camel and snake case. For example. Alice writes Rust contract #[near_bindgen]
impl AliceContract {
pub fn alice_method() {
}
} Bob writes AS contract: export function bobMethod(): void {
} Then anyone can call Alice's contract from near-api-js as How standardization or guidelines would be useful here? |
IMHO, generating additional names only create confusions. I like styles and naming conventions. I don't see much reason of duplicating names through SDK. Especially, that it will incure extra gas cost. |
We need standard because we have standards - https://nomicon.io/Standards/Tokens/FungibleToken.html#reference-level-explanation. |
This is more critical then before with 141 finalization. |
Both approaches (duplicate method names or stick to single style) look wrong for me. How about removing the root cause of a problem by sticking to single-word names for common methods, and leaving complete freedom for user-defined methods? Here is what I mean: in both Rust, AS or what-so-ever-language-NEAR-is-gonna-support-in-the-future we can write all public methods required by standard this way:
It is a matter of finding enough single-word names for a handful of mandatory methods. And when it comes to private methods, or to contract-specific methods, there should be no limit imposed how to name things. Anyhow developer working with contract must familiarise himself with its interfaces. |
That simply won't work because all contract functions are effectively scoped globally. NEAR standard API interfaces must be namespaced to avoid collisions. The problem is that the NEAR library ecosystem is pretty much non-existent at this phase of the lifecycle. Think of defining the JSON RPC API just like defining any HTTP API. Regardless which route you go, i.e., REST, GraphQL, etc, the HTTP API is too low level to work with. Higher level client libraries, frameworks, and tooling is lacking in the NEAR ecosystem. This is what we need to make developers productive and accelerate time to market. I have said this before multiple times on multiple other posts ... and I'll keep saying it until the idea sticks ... As for NEAR standard APIs .. the bottom line is
I would argue that at a minimum, the NEAR DEV team is responsible for delivering on the high level libraries for every NEAR standard API by any means necessary. If the NEAR DEV team does not have the personnel and time to develop them internally, then I propose that the NEAR DEV team tap into the NEAR developer community through bounties, guilds, and partners. It's a chicken and egg problem ... |
Let's just with snake_case since we're going for mostly Rust. |
Yes. Having a single style for standards has a benefit in readability. As @evgenykuzyakov - for whatever reasons, libraries can do the translation if needed. |
Let's publish this as part of meta-standard here in NEPs. FYI @mikedotexe I do want to mention that camelCase is actually more compact (less bytes on chain :D) and leave this topic silent forever. |
We need to define which naming convention standards suppose to follow:
Specifically, it's important because frontend is mostly in JS and expectation is that all calling of arguments will be in Camel Case. While Rust is enforcing Snake case.
I think we can lean toward Camel case to maintain compatibility with frontend and Ethereum standards and add whatever flags required in Rust to enforce that instead of Snake case. This though requires among other things adjusting our Fungible Token standard.
Thoughts?
The text was updated successfully, but these errors were encountered: