-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -120,6 +120,8 @@ interface LegacyMapFile { | |
| // building-block cleaners | ||
| // --------------------------------------------------------------------- | ||
|
|
||
| export const asEdgeTokenId = asEither(asString, asNull) | ||
|
|
||
| const asFeeRate: Cleaner<'high' | 'standard' | 'low'> = asValue( | ||
| 'high', | ||
| 'standard', | ||
|
|
@@ -141,6 +143,7 @@ export const asEdgeTxSwap = asObject<EdgeTxSwap>({ | |
| // Address information: | ||
| payoutAddress: asString, | ||
| payoutCurrencyCode: asString, | ||
| payoutTokenId: asEdgeTokenId, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Required field breaks loading old transaction filesThe
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This, exactly. We cannot add new mandatory fields to old data. If we truly wanted to go down this path, we would first have to add the tokenId as an optional field, and then incorporate a migration path for old data. However, since this is a strict save-and-return workflow, I would propose not to add a migration path, but to simply add the |
||
| payoutNativeAmount: asString, | ||
| payoutWalletId: asString, | ||
| refundAddress: asOptional(asString) | ||
|
|
@@ -158,8 +161,6 @@ export function asIntegerString(raw: unknown): string { | |
| // file cleaners | ||
| // --------------------------------------------------------------------- | ||
|
|
||
| export const asEdgeTokenId = asEither(asString, asNull) | ||
|
|
||
| export const asEdgeAssetAmount = asObject<EdgeAssetAmount>({ | ||
| pluginId: asString, | ||
| tokenId: asEdgeTokenId, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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
denominationToNativeandnativeToDenominationfunctions 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.