-
Notifications
You must be signed in to change notification settings - Fork 55
Add tokenId denom conversion utils #688
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
base: master
Are you sure you want to change the base?
Conversation
| export function getTokenMultiplier( | ||
| currencyInfo: EdgeCurrencyInfo, | ||
| allTokens: EdgeTokenMap, | ||
| tokenId: EdgeTokenId | ||
| ): string { | ||
| if (tokenId == null) { | ||
| for (const denomination of currencyInfo.denominations) { | ||
| if (denomination.name === currencyInfo.currencyCode) { | ||
| return denomination.multiplier | ||
| } | ||
| } | ||
| } else { | ||
| const token: EdgeToken | undefined = allTokens[tokenId] | ||
| if (token != null) { | ||
| for (const denomination of token.denominations) { | ||
| if (denomination.name === token.currencyCode) { | ||
| return denomination.multiplier | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return '1' | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The core should not provide utility functions like this, since everything goes over an expensive bridge. The denominationToNative and nativeToDenomination functions were historical accidents, and deprecation message says to "Use the information in EdgeCurrencyInfo / EdgeToken". We want to delete these guys, not replace them.
These types of utilities should move into edge-currency-accountbased and edge-react-gui in some sort of /utils file, since then they can be fast & synchronous.
…ols" This reverts commit ac53f48.
swansontec
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description is weird now (maybe edit that before merging), but the code is solid.
CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
noneDescription
noneNote
Add optional
payoutTokenIdtoEdgeTxSwap, updating cleaners and tests accordingly.payoutTokenId?: EdgeTokenIdtoEdgeTxSwap(src/types/types.ts).asEdgeTokenIdand include optionalpayoutTokenIdinasEdgeTxSwap(src/core/currency/wallet/currency-wallet-cleaners.ts).payoutTokenId(test/fake/fake-transactions.ts,test/core/currency/wallet/currency-wallet.test.ts).payoutTokenIdtoEdgeTxSwap.Written by Cursor Bugbot for commit 9bc3e1b. This will update automatically on new commits. Configure here.