-
Notifications
You must be signed in to change notification settings - Fork 502
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
Fix(Tx history filter): incoming amount with decimals #4947
base: dev
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
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,10 @@ export const _isModuleFilter = (filter: TxFilter['filter']): filter is ModuleTxF | |
return 'module' in filter | ||
} | ||
|
||
const NATIVE_DECIMALS = 18 | ||
const parseNativeValue = (value: string) => safeParseUnits(value, NATIVE_DECIMALS)?.toString() | ||
const formatNativeValue = (value: string) => safeFormatUnits(value, NATIVE_DECIMALS) | ||
Comment on lines
+48
to
+50
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. I see that this was 18 before but the native currency decimals can be set on the Config Service. Do you think it's worth reading the config instead? 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. Yes, that would be more correct, although a quick google/chatgpt indicates they try to stick to 18. I'll pass decimals from chain info anyway. |
||
|
||
// Spread TxFilter basically | ||
type TxFilterUrlQuery = { | ||
type: TxFilter['type'] | ||
|
@@ -61,6 +65,8 @@ export const txFilter = { | |
}, | ||
|
||
parseFormData: ({ type, ...formData }: TxFilterFormState): TxFilter => { | ||
const isMultisig = type === TxFilterType.MULTISIG | ||
|
||
const filter: TxFilter['filter'] = _omitNullish({ | ||
...formData, | ||
execution_date__gte: formData.execution_date__gte | ||
|
@@ -69,7 +75,7 @@ export const txFilter = { | |
execution_date__lte: formData.execution_date__lte | ||
? endOfDay(formData.execution_date__lte).toISOString() | ||
: undefined, | ||
value: formData.value ? safeParseUnits(formData.value, 18)?.toString() : undefined, | ||
value: isMultisig && formData.value ? parseNativeValue(formData.value) : formData.value, | ||
}) | ||
|
||
return { | ||
|
@@ -87,13 +93,14 @@ export const txFilter = { | |
|
||
formatFormData: ({ type, filter }: TxFilter): Partial<TxFilterFormState> => { | ||
const isModule = _isModuleFilter(filter) | ||
const isMultisig = type === TxFilterType.MULTISIG | ||
|
||
return { | ||
type, | ||
...filter, | ||
execution_date__gte: !isModule && filter.execution_date__gte ? new Date(filter.execution_date__gte) : null, | ||
execution_date__lte: !isModule && filter.execution_date__lte ? new Date(filter.execution_date__lte) : null, | ||
value: !isModule && filter.value ? safeFormatUnits(filter.value, 18)?.toString() : '', | ||
value: isModule ? '' : isMultisig && filter.value ? formatNativeValue(filter.value) : filter.value, | ||
} | ||
}, | ||
} | ||
|
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.
Not sure if "with decimals" is clear enough. Maybe it should say "with zeroes"?
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.
I think "with zeros" is clearer because "decimals" suggest a float. We also could add a tooltip explaining it's the "base amount".
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.
Done:
