Skip to content
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

JS SDK Should Auto-Convert camelCase to snake_case for Function Names #136

Closed
idea404 opened this issue Jul 19, 2022 · 7 comments
Closed
Assignees
Labels
bug Something isn't working DevEx v0.7

Comments

@idea404
Copy link
Contributor

idea404 commented Jul 19, 2022

Introduction

During last DevRel working session, Benji pointed out that the names inconsistencies between JS and Rust for functions will lead to inconsistent naming for logic that is performed on chain.

e.g.:
nft_mint for a Rust contract vs. nftMint for a JS contract

Problem

dApps that listen to data on-chain searching for specific function names will miss data. Some dApps might be built foundationally on the assumption of this being consistent.

Solution

JS SDK auto-converts naming for view and call methods from camelCase or whatever case to snake_case to keep consistency with existing function naming for the ecosystem.

@idea404 idea404 added the bug Something isn't working label Jul 19, 2022
@idea404 idea404 added the DevEx label Jul 19, 2022
@idea404
Copy link
Contributor Author

idea404 commented Jul 19, 2022

This issue was created to start the conversation, topic merits a broader discussion!
Mentioned in discussion: #138

@gagdiez
Copy link
Collaborator

gagdiez commented Jul 19, 2022

In my humble opinion, adding an auto-convert from camelCase to snake_case will add an extra layer of complexity in near-sdk-js. Because of this, I think we should not add it. However, I do agree that we should standardize always using snake_case in all our examples, and be clear with the community on why we recommend doing so.

@maxhr
Copy link
Contributor

maxhr commented Jul 19, 2022

I suggest the compiler to wasm to emit a warning, and not do auto-conversions.

@ailisp
Copy link
Member

ailisp commented Jul 20, 2022

auto convert isn't hard to implement, but @gagdiez and @maxhr suggested ways are more robust and no hidden magic would cause user confusion. I think it's a good idea to do they proposed

@ailisp ailisp added the v0.7 label Sep 23, 2022
@volovyks
Copy link
Collaborator

After additional discussions, we came up with a decision on this:

  • No magic, no autoconversion from camelCase to snake_case
  • All standards (FT, NFT, etc.) will use snake_case
  • All other examples can use camelCase since it's more common in JS/TS world.

We should be clear about why we are using snake_case for some contracts and mention this in our docs.

@idea404
Copy link
Contributor Author

idea404 commented Oct 11, 2022

I've created this issue to mention snake_case in JS considering standards for docs

@idea404
Copy link
Contributor Author

idea404 commented Nov 15, 2022

Mentioned in docs now: near/docs#1290

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working DevEx v0.7
Projects
None yet
Development

No branches or pull requests

5 participants