-
Notifications
You must be signed in to change notification settings - Fork 26
fix(decimal): render Reown/WalletConnect amounts with the network's decimal places #898
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 |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
| import { AlertUI, COLORS } from '../../../styles/themes'; | ||
| import { WarnTextValue } from '../../WarnTextValue'; | ||
| import { CircleError } from '../../Icons/CircleError.icon'; | ||
| import { DEFAULT_ICON_SIZE } from '../../Icons/constants'; | ||
| import { | ||
| getActionTitle, | ||
| isAuthorityAction, | ||
|
|
@@ -143,6 +144,8 @@ | |
| value: [commonStyles.text, commonStyles.field], | ||
| addressSection: { | ||
| marginTop: 8, | ||
| marginLeft: DEFAULT_ICON_SIZE + 16, | ||
| paddingRight: 16, | ||
| }, | ||
| contentWrapper: { | ||
| flex: 1, | ||
|
|
@@ -154,88 +157,91 @@ | |
| const titleParts = isAuthority ? splitAuthorityTitle(title) : null; | ||
|
|
||
| return ( | ||
| <View style={[commonStyles.cardSplit, commonStyles.listItem]}> | ||
| <NanoContractActionIcon type={action.type} /> | ||
| <View style={[commonStyles.cardSplitContent, styles.contentWrapper]}> | ||
| {isAuthority && titleParts ? ( | ||
| <View style={styles.authorityRow}> | ||
| <Text style={styles.authorityTitle}>{titleParts[0]}</Text> | ||
| <Text style={styles.authorityType}>{titleParts[1]}</Text> | ||
| </View> | ||
| ) : ( | ||
| <View style={styles.actionRow}> | ||
| <Text style={styles.action}>{title}</Text> | ||
| {!isRegistered && tokenSymbol && ( | ||
| <TouchableOpacity onPress={() => showTokenInfo(action.token)}> | ||
| <FontAwesomeIcon | ||
| icon={faCircleInfo} | ||
| size={16} | ||
| color={COLORS.textColor} | ||
| /> | ||
| </TouchableOpacity> | ||
| )} | ||
| </View> | ||
| )} | ||
|
|
||
| {/* WITHDRAWAL: Show only address (address to send the amount and create the output) */} | ||
| {action.type === NanoContractActionType.WITHDRAWAL | ||
| && action.address && ( | ||
| <View style={styles.addressSection}> | ||
| <Text style={styles.valueLabel}>{t`Address to send amount:`}</Text> | ||
| <Text style={styles.value}>{action.address}</Text> | ||
| <View style={[{display: 'flex', flexDirection: 'column'}, commonStyles.listItem]}> | ||
|
Check failure on line 160 in src/components/Reown/NanoContract/NanoContractActions.js
|
||
| <View style={[commonStyles.cardSplit]}> | ||
| <NanoContractActionIcon type={action.type} /> | ||
| <View style={[commonStyles.cardSplitContent, styles.contentWrapper]}> | ||
| {isAuthority && titleParts ? ( | ||
| <View style={styles.authorityRow}> | ||
| <Text style={styles.authorityTitle}>{titleParts[0]}</Text> | ||
| <Text style={styles.authorityType}>{titleParts[1]}</Text> | ||
| </View> | ||
| )} | ||
| ) : ( | ||
| <View style={styles.actionRow}> | ||
| <Text style={styles.action}>{title}</Text> | ||
| {!isRegistered && tokenSymbol && ( | ||
| <TouchableOpacity onPress={() => showTokenInfo(action.token)}> | ||
| <FontAwesomeIcon | ||
| icon={faCircleInfo} | ||
| size={16} | ||
| color={COLORS.textColor} | ||
| /> | ||
| </TouchableOpacity> | ||
| )} | ||
| </View> | ||
| )} | ||
|
|
||
| {/* DEPOSIT: Show address (to filter UTXOs) and changeAddress (change address) */} | ||
| {action.type === NanoContractActionType.DEPOSIT && ( | ||
| <View style={[(action.address || action.changeAddress) && styles.addressSection]}> | ||
| {action.address && ( | ||
| <View style={{ marginBottom: 8 }}> | ||
| <Text style={styles.valueLabel}>{t`Address to filter UTXOs:`}</Text> | ||
| <Text style={styles.value}>{action.address}</Text> | ||
| </View> | ||
| )} | ||
| {action.changeAddress && ( | ||
| <View> | ||
| <Text style={styles.valueLabel}>{t`Change address:`}</Text> | ||
| <Text style={styles.value}>{action.changeAddress}</Text> | ||
| </View> | ||
| )} | ||
| </View> | ||
| )} | ||
| </View> | ||
|
|
||
| {/* GRANT_AUTHORITY: Show address (filter UTXOs) and authorityAddress (send authority) */} | ||
| {action.type === NanoContractActionType.GRANT_AUTHORITY && ( | ||
| <View style={[(action.address || action.authorityAddress) && styles.addressSection]}> | ||
| {action.address && ( | ||
| <View style={{ marginBottom: 8 }}> | ||
| <Text style={styles.valueLabel}>{t`Address to filter UTXOs:`}</Text> | ||
| <Text style={styles.value}>{action.address}</Text> | ||
| </View> | ||
| )} | ||
| {action.authorityAddress && ( | ||
| <View> | ||
| <Text style={styles.valueLabel}>{t`Address to send new authority:`}</Text> | ||
| <Text style={styles.value}>{action.authorityAddress}</Text> | ||
| </View> | ||
| )} | ||
| </View> | ||
| {/* Show amount for deposit/withdrawal actions */} | ||
| {action.type !== NanoContractActionType.GRANT_AUTHORITY | ||
| && action.type !== NanoContractActionType.ACQUIRE_AUTHORITY | ||
| && action.amount != null && action.amount !== undefined && ( | ||
| <Amount amount={action.amount} isNft={isNft} /> | ||
| )} | ||
| </View> | ||
|
|
||
| {/* ACQUIRE_AUTHORITY: Show only address (send the authority and create the output) */} | ||
| {action.type === NanoContractActionType.ACQUIRE_AUTHORITY && action.address && ( | ||
| {/* WITHDRAWAL: Show only address (address to send the amount and create the output) */} | ||
| {action.type === NanoContractActionType.WITHDRAWAL | ||
| && action.address && ( | ||
| <View style={styles.addressSection}> | ||
| <Text style={styles.valueLabel}>{t`Address to send authority:`}</Text> | ||
| <Text style={styles.valueLabel}>{t`Address to send amount:`}</Text> | ||
| <Text style={styles.value}>{action.address}</Text> | ||
| </View> | ||
| )} | ||
| </View> | ||
| )} | ||
|
|
||
| {/* DEPOSIT: Show address (to filter UTXOs) and changeAddress (change address) */} | ||
| {action.type === NanoContractActionType.DEPOSIT && ( | ||
| <View style={[(action.address || action.changeAddress) && styles.addressSection]}> | ||
| {action.address && ( | ||
| <View style={{ marginBottom: 8 }}> | ||
| <Text style={styles.valueLabel}>{t`Address to filter UTXOs:`}</Text> | ||
| <Text style={styles.value}>{action.address}</Text> | ||
| </View> | ||
| )} | ||
| {action.changeAddress && ( | ||
| <View> | ||
| <Text style={styles.valueLabel}>{t`Change address:`}</Text> | ||
| <Text style={styles.value}>{action.changeAddress}</Text> | ||
| </View> | ||
| )} | ||
| </View> | ||
| )} | ||
|
|
||
| {/* GRANT_AUTHORITY: Show address (filter UTXOs) and authorityAddress (send authority) */} | ||
| {action.type === NanoContractActionType.GRANT_AUTHORITY && ( | ||
| <View style={[(action.address || action.authorityAddress) && styles.addressSection]}> | ||
| {action.address && ( | ||
| <View style={{ marginBottom: 8 }}> | ||
| <Text style={styles.valueLabel}>{t`Address to filter UTXOs:`}</Text> | ||
| <Text style={styles.value}>{action.address}</Text> | ||
| </View> | ||
| )} | ||
| {action.authorityAddress && ( | ||
| <View> | ||
| <Text style={styles.valueLabel}>{t`Address to send new authority:`}</Text> | ||
| <Text style={styles.value}>{action.authorityAddress}</Text> | ||
| </View> | ||
| )} | ||
| </View> | ||
| )} | ||
|
|
||
| {/* Show amount for deposit/withdrawal actions */} | ||
| {action.type !== NanoContractActionType.GRANT_AUTHORITY | ||
| && action.type !== NanoContractActionType.ACQUIRE_AUTHORITY | ||
| && action.amount != null && action.amount !== undefined && ( | ||
| <Amount amount={action.amount} isNft={isNft} /> | ||
| {/* ACQUIRE_AUTHORITY: Show only address (send the authority and create the output) */} | ||
| {action.type === NanoContractActionType.ACQUIRE_AUTHORITY && action.address && ( | ||
| <View style={styles.addressSection}> | ||
| <Text style={styles.valueLabel}>{t`Address to send authority:`}</Text> | ||
| <Text style={styles.value}>{action.address}</Text> | ||
| </View> | ||
| )} | ||
| </View> | ||
| ) | ||
|
|
@@ -249,13 +255,16 @@ | |
| * @param {boolean} props.isNft | ||
| */ | ||
| const Amount = ({ amount, isNft }) => { | ||
| const amountToRender = renderValue(amount, isNft); | ||
| const decimalPlaces = useSelector((state) => state.serverInfo?.decimal_places); | ||
|
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. question(non-blocking): should these amounts honour the compressed/expanded preference?
|
||
| const amountToRender = renderValue(amount, isNft, decimalPlaces); | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| wrapper: { | ||
| marginLeft: 'auto', | ||
| marginRight: 0, | ||
| paddingRight: 16, | ||
| maxWidth: '50%', | ||
| flexShrink: 1, | ||
| }, | ||
| amount: { | ||
| fontSize: 16, | ||
|
|
||
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.
suggestion(non-blocking): the layout restyle isn't covered by the acceptance criteria
This action item is restructured (addresses moved out of the icon row, indented by
DEFAULT_ICON_SIZE + 16), and four files gainalignItems: 'flex-start'/textAlign: 'right'/maxWidth. Those render differently on a 2-decimal network too, so AC bullet 3 ("no behavior change on a 2-decimal network") no longer holds. Presumably it's making room for longer amounts — worth saying so in the description, so a reviewer knows to check the layout at the old precision as well.