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

[ts-sdk] Moved formatAmount and formatAmountParts from apps/core to sdk/typescript (#17791) #18716

Closed

Conversation

kkomelin
Copy link
Contributor

@kkomelin kkomelin commented Jul 18, 2024

Description

  1. Moved formatAmount and formatAmountParts utils from the apps/core package to the sdk/typescript package.
  2. Set deprecation warnings for the older versions.
  3. Added corresponding automated tests.

Closes #17791

Test plan

  • Run the automated tests for the @mysten/sui package.
  • Make sure the transaction amount is displayed properly in the wallet.

Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • Indexer:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:
  • REST API:

…dk/typescript (MystenLabs#17791)

    ## Description

    Moved formatAmount and formatAmountParts utils from the apps/core
    package to the sdk/typescript.

    Set deprecation warnings for the older versions.

    Added the corresponding  automated tests.

    ## Test plan

    Run the automated tests for the @mysten/sui package.
    Make sure the transaction amount is displayed properly in the wallet.
@kkomelin kkomelin requested review from a team as code owners July 18, 2024 12:08
@kkomelin kkomelin requested review from pchrysochoidis and mystieanwaya and removed request for a team July 18, 2024 12:08
Copy link

vercel bot commented Jul 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 18, 2024 0:16am

Copy link

vercel bot commented Jul 18, 2024

@kkomelin is attempting to deploy a commit to the Mysten Labs Team on Vercel.

A member of the Team first needs to authorize it.

@hayes-mysten
Copy link
Contributor

Thank you for opening this PR, unfortunately I don't think the formatAmount helper is a good fit for the typescript SDK. The utilities in the SDK need to enforce standard conventions, and can be seen as endorsing specific patterns.

The formatting used in this util isn't based on a specific standard, and isn't the format that we would recommend as a best practice. These conventions are a product decision, and apps should think through things like i18n/localization when considering formatting.

I think there are some lower level helpers we could add, like improved conversion between SUI and MIST, but string formatting is a little too opinionated to be part of the core SDK.

I think the better route here might be to collect and publish opinionated utils as a separate package

@kkomelin
Copy link
Contributor Author

Thank you @hayes-mysten for your time and input. It makes sense.

I think the better route here might be to collect and publish opinionated utils as a separate package

My goal was to remove the bignumber.js dependency from my project by moving formatAmount to the SDK. If I extract the formatAmount functions to a separate package, I will just replace one dependency with another. I don't think I would improve anything by that.

So considering your answer, I think we can close this PR and the corresponding issue for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sui TypeScript SDK: Add formatAmount() util
2 participants