@reown/appkit-ui-react-native 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/lib/commonjs/assets/svg/RecycleHorizontal.js +21 -0
  2. package/lib/commonjs/assets/svg/RecycleHorizontal.js.map +1 -0
  3. package/lib/commonjs/components/wui-icon/index.js +2 -0
  4. package/lib/commonjs/components/wui-icon/index.js.map +1 -1
  5. package/lib/commonjs/components/wui-pressable/index.js +68 -0
  6. package/lib/commonjs/components/wui-pressable/index.js.map +1 -0
  7. package/lib/commonjs/components/wui-shimmer/index.js +5 -1
  8. package/lib/commonjs/components/wui-shimmer/index.js.map +1 -1
  9. package/lib/commonjs/composites/wui-button/index.js +2 -1
  10. package/lib/commonjs/composites/wui-button/index.js.map +1 -1
  11. package/lib/commonjs/composites/wui-button/styles.js +3 -3
  12. package/lib/commonjs/composites/wui-button/styles.js.map +1 -1
  13. package/lib/commonjs/composites/wui-input-text/index.js +2 -1
  14. package/lib/commonjs/composites/wui-input-text/index.js.map +1 -1
  15. package/lib/commonjs/composites/wui-list-token/index.js +29 -9
  16. package/lib/commonjs/composites/wui-list-token/index.js.map +1 -1
  17. package/lib/commonjs/composites/wui-list-token/styles.js +3 -0
  18. package/lib/commonjs/composites/wui-list-token/styles.js.map +1 -1
  19. package/lib/commonjs/composites/wui-snackbar/index.js +4 -1
  20. package/lib/commonjs/composites/wui-snackbar/index.js.map +1 -1
  21. package/lib/commonjs/composites/wui-toggle/index.js +65 -0
  22. package/lib/commonjs/composites/wui-toggle/index.js.map +1 -0
  23. package/lib/commonjs/composites/wui-toggle/styles.js +30 -0
  24. package/lib/commonjs/composites/wui-toggle/styles.js.map +1 -0
  25. package/lib/commonjs/composites/wui-token-button/index.js +21 -11
  26. package/lib/commonjs/composites/wui-token-button/index.js.map +1 -1
  27. package/lib/commonjs/composites/wui-token-button/styles.js +4 -0
  28. package/lib/commonjs/composites/wui-token-button/styles.js.map +1 -1
  29. package/lib/commonjs/context/ThemeContext.js +41 -0
  30. package/lib/commonjs/context/ThemeContext.js.map +1 -0
  31. package/lib/commonjs/hooks/useTheme.js +5 -7
  32. package/lib/commonjs/hooks/useTheme.js.map +1 -1
  33. package/lib/commonjs/index.js +27 -0
  34. package/lib/commonjs/index.js.map +1 -1
  35. package/lib/commonjs/layout/wui-flex/index.js +1 -0
  36. package/lib/commonjs/layout/wui-flex/index.js.map +1 -1
  37. package/lib/commonjs/utils/ThemeUtil.js +18 -1
  38. package/lib/commonjs/utils/ThemeUtil.js.map +1 -1
  39. package/lib/commonjs/utils/TransactionUtil.js +56 -45
  40. package/lib/commonjs/utils/TransactionUtil.js.map +1 -1
  41. package/lib/module/assets/svg/RecycleHorizontal.js +13 -0
  42. package/lib/module/assets/svg/RecycleHorizontal.js.map +1 -0
  43. package/lib/module/components/wui-icon/index.js +2 -0
  44. package/lib/module/components/wui-icon/index.js.map +1 -1
  45. package/lib/module/components/wui-pressable/index.js +62 -0
  46. package/lib/module/components/wui-pressable/index.js.map +1 -0
  47. package/lib/module/components/wui-shimmer/index.js +6 -2
  48. package/lib/module/components/wui-shimmer/index.js.map +1 -1
  49. package/lib/module/composites/wui-button/index.js +2 -1
  50. package/lib/module/composites/wui-button/index.js.map +1 -1
  51. package/lib/module/composites/wui-button/styles.js +3 -3
  52. package/lib/module/composites/wui-button/styles.js.map +1 -1
  53. package/lib/module/composites/wui-input-text/index.js +2 -1
  54. package/lib/module/composites/wui-input-text/index.js.map +1 -1
  55. package/lib/module/composites/wui-list-token/index.js +27 -8
  56. package/lib/module/composites/wui-list-token/index.js.map +1 -1
  57. package/lib/module/composites/wui-list-token/styles.js +3 -0
  58. package/lib/module/composites/wui-list-token/styles.js.map +1 -1
  59. package/lib/module/composites/wui-snackbar/index.js +4 -1
  60. package/lib/module/composites/wui-snackbar/index.js.map +1 -1
  61. package/lib/module/composites/wui-toggle/index.js +58 -0
  62. package/lib/module/composites/wui-toggle/index.js.map +1 -0
  63. package/lib/module/composites/wui-toggle/styles.js +24 -0
  64. package/lib/module/composites/wui-toggle/styles.js.map +1 -0
  65. package/lib/module/composites/wui-token-button/index.js +21 -11
  66. package/lib/module/composites/wui-token-button/index.js.map +1 -1
  67. package/lib/module/composites/wui-token-button/styles.js +4 -0
  68. package/lib/module/composites/wui-token-button/styles.js.map +1 -1
  69. package/lib/module/context/ThemeContext.js +33 -0
  70. package/lib/module/context/ThemeContext.js.map +1 -0
  71. package/lib/module/hooks/useTheme.js +4 -7
  72. package/lib/module/hooks/useTheme.js.map +1 -1
  73. package/lib/module/index.js +4 -1
  74. package/lib/module/index.js.map +1 -1
  75. package/lib/module/layout/wui-flex/index.js +1 -0
  76. package/lib/module/layout/wui-flex/index.js.map +1 -1
  77. package/lib/module/utils/ThemeUtil.js +16 -0
  78. package/lib/module/utils/ThemeUtil.js.map +1 -1
  79. package/lib/module/utils/TransactionUtil.js +56 -45
  80. package/lib/module/utils/TransactionUtil.js.map +1 -1
  81. package/lib/typescript/assets/svg/RecycleHorizontal.d.ts +4 -0
  82. package/lib/typescript/assets/svg/RecycleHorizontal.d.ts.map +1 -0
  83. package/lib/typescript/components/wui-icon/index.d.ts.map +1 -1
  84. package/lib/typescript/components/wui-pressable/index.d.ts +17 -0
  85. package/lib/typescript/components/wui-pressable/index.d.ts.map +1 -0
  86. package/lib/typescript/components/wui-shimmer/index.d.ts.map +1 -1
  87. package/lib/typescript/composites/wui-input-text/index.d.ts +3 -1
  88. package/lib/typescript/composites/wui-input-text/index.d.ts.map +1 -1
  89. package/lib/typescript/composites/wui-list-token/index.d.ts +4 -1
  90. package/lib/typescript/composites/wui-list-token/index.d.ts.map +1 -1
  91. package/lib/typescript/composites/wui-list-token/styles.d.ts +3 -0
  92. package/lib/typescript/composites/wui-list-token/styles.d.ts.map +1 -1
  93. package/lib/typescript/composites/wui-snackbar/index.d.ts +1 -1
  94. package/lib/typescript/composites/wui-snackbar/index.d.ts.map +1 -1
  95. package/lib/typescript/composites/wui-toggle/index.d.ts +11 -0
  96. package/lib/typescript/composites/wui-toggle/index.d.ts.map +1 -0
  97. package/lib/typescript/composites/wui-toggle/styles.d.ts +23 -0
  98. package/lib/typescript/composites/wui-toggle/styles.d.ts.map +1 -0
  99. package/lib/typescript/composites/wui-token-button/index.d.ts +7 -3
  100. package/lib/typescript/composites/wui-token-button/index.d.ts.map +1 -1
  101. package/lib/typescript/composites/wui-token-button/styles.d.ts +4 -0
  102. package/lib/typescript/composites/wui-token-button/styles.d.ts.map +1 -1
  103. package/lib/typescript/context/ThemeContext.d.ts +78 -0
  104. package/lib/typescript/context/ThemeContext.d.ts.map +1 -0
  105. package/lib/typescript/hooks/useTheme.d.ts +1 -1
  106. package/lib/typescript/hooks/useTheme.d.ts.map +1 -1
  107. package/lib/typescript/index.d.ts +4 -1
  108. package/lib/typescript/index.d.ts.map +1 -1
  109. package/lib/typescript/layout/wui-flex/index.d.ts +2 -1
  110. package/lib/typescript/layout/wui-flex/index.d.ts.map +1 -1
  111. package/lib/typescript/utils/ThemeUtil.d.ts +13 -0
  112. package/lib/typescript/utils/ThemeUtil.d.ts.map +1 -1
  113. package/lib/typescript/utils/TransactionUtil.d.ts +9 -1
  114. package/lib/typescript/utils/TransactionUtil.d.ts.map +1 -1
  115. package/lib/typescript/utils/TypesUtil.d.ts +2 -2
  116. package/lib/typescript/utils/TypesUtil.d.ts.map +1 -1
  117. package/package.json +2 -1
  118. package/src/assets/svg/RecycleHorizontal.tsx +12 -0
  119. package/src/components/wui-icon/index.tsx +2 -0
  120. package/src/components/wui-pressable/index.tsx +92 -0
  121. package/src/components/wui-shimmer/index.tsx +9 -2
  122. package/src/composites/wui-button/index.tsx +1 -1
  123. package/src/composites/wui-button/styles.ts +3 -3
  124. package/src/composites/wui-input-text/index.tsx +10 -2
  125. package/src/composites/wui-list-token/index.tsx +31 -8
  126. package/src/composites/wui-list-token/styles.ts +3 -0
  127. package/src/composites/wui-snackbar/index.tsx +7 -2
  128. package/src/composites/wui-toggle/index.tsx +81 -0
  129. package/src/composites/wui-toggle/styles.ts +24 -0
  130. package/src/composites/wui-token-button/index.tsx +37 -8
  131. package/src/composites/wui-token-button/styles.ts +4 -0
  132. package/src/context/ThemeContext.tsx +44 -0
  133. package/src/hooks/useTheme.ts +4 -8
  134. package/src/index.ts +4 -1
  135. package/src/layout/wui-flex/index.tsx +7 -2
  136. package/src/utils/ThemeUtil.ts +18 -0
  137. package/src/utils/TransactionUtil.ts +72 -52
  138. package/src/utils/TypesUtil.ts +2 -0
@@ -1,4 +1,4 @@
1
- import type { Balance } from '@reown/appkit-common-react-native';
1
+ import type { StyleProp, ViewStyle } from 'react-native';
2
2
  import { Image } from '../../components/wui-image';
3
3
  import { Text } from '../../components/wui-text';
4
4
  import { Button } from '../wui-button';
@@ -6,13 +6,30 @@ import styles from './styles';
6
6
 
7
7
  export interface TokenButtonProps {
8
8
  onPress?: () => void;
9
- token?: Balance;
9
+ imageUrl?: string;
10
+ text?: string;
11
+ inverse?: boolean;
12
+ style?: StyleProp<ViewStyle>;
13
+ disabled?: boolean;
10
14
  }
11
15
 
12
- export function TokenButton({ token, onPress }: TokenButtonProps) {
13
- if (!token) {
16
+ export function TokenButton({
17
+ imageUrl,
18
+ text,
19
+ inverse,
20
+ onPress,
21
+ style,
22
+ disabled = false
23
+ }: TokenButtonProps) {
24
+ if (!text) {
14
25
  return (
15
- <Button variant="accent" style={styles.selectButton} size="sm" onPress={onPress}>
26
+ <Button
27
+ variant="accent"
28
+ style={[styles.selectButton, style]}
29
+ size="sm"
30
+ onPress={onPress}
31
+ disabled={disabled}
32
+ >
16
33
  <Text variant="small-600" color="accent-100">
17
34
  Select token
18
35
  </Text>
@@ -20,10 +37,22 @@ export function TokenButton({ token, onPress }: TokenButtonProps) {
20
37
  );
21
38
  }
22
39
 
40
+ const content = [
41
+ imageUrl && (
42
+ <Image key="image" source={imageUrl} style={[styles.image, inverse && styles.imageInverse]} />
43
+ ),
44
+ <Text key="text">{text}</Text>
45
+ ];
46
+
23
47
  return (
24
- <Button variant="shade" style={styles.container} size="sm" onPress={onPress}>
25
- {token?.iconUrl && <Image source={token?.iconUrl} style={styles.image} />}
26
- {token?.symbol && <Text>{token.symbol}</Text>}
48
+ <Button
49
+ variant="shade"
50
+ style={[styles.container, style]}
51
+ size="sm"
52
+ onPress={onPress}
53
+ disabled={disabled}
54
+ >
55
+ {inverse ? content.reverse() : content}
27
56
  </Button>
28
57
  );
29
58
  }
@@ -14,5 +14,9 @@ export default StyleSheet.create({
14
14
  height: 24,
15
15
  borderRadius: BorderRadius.full,
16
16
  marginRight: Spacing['2xs']
17
+ },
18
+ imageInverse: {
19
+ marginRight: 0,
20
+ marginLeft: Spacing['2xs']
17
21
  }
18
22
  });
@@ -0,0 +1,44 @@
1
+ import { useColorScheme } from 'react-native';
2
+ import { createContext, useContext, type ReactNode } from 'react';
3
+ import type { ThemeMode, ThemeVariables } from '@reown/appkit-common-react-native';
4
+
5
+ import { DarkTheme, LightTheme, getAccentColors } from '../utils/ThemeUtil';
6
+
7
+ type ThemeContextType = {
8
+ themeMode?: ThemeMode;
9
+ themeVariables?: ThemeVariables;
10
+ };
11
+
12
+ export const ThemeContext = createContext<ThemeContextType | undefined>(undefined);
13
+
14
+ interface ThemeProviderProps {
15
+ children: ReactNode;
16
+ themeMode?: ThemeMode;
17
+ themeVariables?: ThemeVariables;
18
+ }
19
+
20
+ export function ThemeProvider({ children, themeMode, themeVariables }: ThemeProviderProps) {
21
+ return (
22
+ <ThemeContext.Provider value={{ themeMode, themeVariables }}>{children}</ThemeContext.Provider>
23
+ );
24
+ }
25
+
26
+ export function useTheme() {
27
+ const context = useContext(ThemeContext);
28
+ const scheme = useColorScheme();
29
+
30
+ // If the theme mode is not set, use the system color scheme
31
+ const themeMode = context?.themeMode ?? scheme;
32
+ const themeVariables = context?.themeVariables ?? {};
33
+
34
+ let Theme = themeMode === 'dark' ? DarkTheme : LightTheme;
35
+
36
+ if (themeVariables.accent) {
37
+ Theme = {
38
+ ...Theme,
39
+ ...getAccentColors(themeVariables.accent)
40
+ };
41
+ }
42
+
43
+ return Theme;
44
+ }
@@ -1,9 +1,5 @@
1
- import { useColorScheme } from 'react-native';
2
- import { DarkTheme, LightTheme } from '../utils/ThemeUtil';
1
+ import { useTheme as useThemeContext } from '../context/ThemeContext';
3
2
 
4
- export function useTheme() {
5
- const scheme = useColorScheme();
6
- const Theme = scheme === 'dark' ? DarkTheme : LightTheme;
7
-
8
- return Theme;
9
- }
3
+ export const useTheme = () => {
4
+ return useThemeContext();
5
+ };
package/src/index.ts CHANGED
@@ -42,7 +42,7 @@ export { Link, type LinkProps } from './composites/wui-link';
42
42
  export { ListItem, type ListItemProps } from './composites/wui-list-item';
43
43
  export { ListItemLoader, type ListItemLoaderProps } from './composites/wui-list-item-loader';
44
44
  export { ListSocial, type ListSocialProps } from './composites/wui-list-social';
45
- export { ListToken, type ListTokenProps } from './composites/wui-list-token';
45
+ export { ListToken, ListTokenTotalHeight, type ListTokenProps } from './composites/wui-list-token';
46
46
  export { ListTransaction, type ListTransactionProps } from './composites/wui-list-transaction';
47
47
  export { ListWallet, type ListWalletProps } from './composites/wui-list-wallet';
48
48
  export { Logo, type LogoProps } from './composites/wui-logo';
@@ -50,12 +50,14 @@ export { LogoSelect, type LogoSelectProps } from './composites/wui-logo-select';
50
50
  export { NetworkButton, type NetworkButtonProps } from './composites/wui-network-button';
51
51
  export { NetworkImage, type NetworkImageProps } from './composites/wui-network-image';
52
52
  export { Otp, type OtpProps } from './composites/wui-otp';
53
+ export { Pressable, type PressableProps } from './components/wui-pressable';
53
54
  export { Promo, type PromoProps } from './composites/wui-promo';
54
55
  export { QrCode, type QrCodeProps } from './composites/wui-qr-code';
55
56
  export { SearchBar, type SearchBarProps } from './composites/wui-search-bar';
56
57
  export { Snackbar, type SnackbarProps } from './composites/wui-snackbar';
57
58
  export { Tabs, type TabsProps } from './composites/wui-tabs';
58
59
  export { Tag, type TagProps } from './composites/wui-tag';
60
+ export { Toggle, type ToggleProps } from './composites/wui-toggle';
59
61
  export { TokenButton, type TokenButtonProps } from './composites/wui-token-button';
60
62
  export { Tooltip, type TooltipProps } from './composites/wui-tooltip';
61
63
  export { WalletImage, type WalletImageProps } from './composites/wui-wallet-image';
@@ -83,4 +85,5 @@ export { TransactionUtil } from './utils/TransactionUtil';
83
85
  export { Spacing, BorderRadius } from './utils/ThemeUtil';
84
86
 
85
87
  export { useTheme } from './hooks/useTheme';
88
+ export { ThemeProvider } from './context/ThemeContext';
86
89
  export { useAnimatedValue } from './hooks/useAnimatedValue';
@@ -1,4 +1,4 @@
1
- import { type StyleProp, type ViewStyle, View } from 'react-native';
1
+ import { type LayoutChangeEvent, type StyleProp, type ViewStyle, View } from 'react-native';
2
2
 
3
3
  import type {
4
4
  FlexAlignType,
@@ -13,6 +13,7 @@ import { UiUtil } from '../../utils/UiUtil';
13
13
 
14
14
  export interface FlexViewProps {
15
15
  children?: React.ReactNode;
16
+ onLayout?: (event: LayoutChangeEvent) => void;
16
17
  flexDirection?: FlexDirectionType;
17
18
  flexWrap?: FlexWrapType;
18
19
  flexGrow?: FlexGrowType;
@@ -44,5 +45,9 @@ export function FlexView(props: FlexViewProps) {
44
45
  marginLeft: props.margin && UiUtil.getSpacingStyles(props.margin, 3)
45
46
  };
46
47
 
47
- return <View style={[styles, props.style]}>{props.children}</View>;
48
+ return (
49
+ <View onLayout={props.onLayout} style={[styles, props.style]}>
50
+ {props.children}
51
+ </View>
52
+ );
48
53
  }
@@ -1,5 +1,23 @@
1
+ import { transparentize, darken, lighten } from 'polished';
2
+
1
3
  import type { SpacingType, ThemeKeys } from './TypesUtil';
2
4
 
5
+ export const getAccentColors = (baseAccentColor: string) => {
6
+ return {
7
+ 'accent-100': baseAccentColor,
8
+ 'accent-090': lighten(0.05, baseAccentColor),
9
+ 'accent-080': lighten(0.1, baseAccentColor),
10
+ 'accent-020': darken(0.1, baseAccentColor),
11
+ 'accent-glass-090': transparentize(0.1, baseAccentColor),
12
+ 'accent-glass-080': transparentize(0.2, baseAccentColor),
13
+ 'accent-glass-020': transparentize(0.8, baseAccentColor),
14
+ 'accent-glass-015': transparentize(0.85, baseAccentColor),
15
+ 'accent-glass-010': transparentize(0.9, baseAccentColor),
16
+ 'accent-glass-005': transparentize(0.95, baseAccentColor),
17
+ 'accent-glass-002': transparentize(0.98, baseAccentColor)
18
+ };
19
+ };
20
+
3
21
  export const DarkTheme: { [key in ThemeKeys]: string } = {
4
22
  'accent-100': '#667DFF',
5
23
  'accent-090': '#7388FD',
@@ -2,7 +2,8 @@ import { DateUtil } from '@reown/appkit-common-react-native';
2
2
  import type {
3
3
  TransactionTransfer,
4
4
  Transaction,
5
- TransactionImage
5
+ TransactionImage,
6
+ TransactionMetadata
6
7
  } from '@reown/appkit-common-react-native';
7
8
  import type { TransactionType } from './TypesUtil';
8
9
  import { UiUtil } from './UiUtil';
@@ -24,20 +25,22 @@ export const TransactionUtil = {
24
25
  },
25
26
 
26
27
  getTransactionImages(transfers: TransactionTransfer[]): TransactionImage[] {
27
- const [transfer, secondTransfer] = transfers;
28
- const isAllNFT = Boolean(transfer) && transfers?.every(item => Boolean(item.nft_info));
28
+ const isAllNFT = Boolean(transfers[0]) && transfers?.every(item => Boolean(item.nft_info));
29
29
  const haveMultipleTransfers = transfers?.length > 1;
30
30
  const haveTwoTransfers = transfers?.length === 2;
31
31
 
32
32
  if (haveTwoTransfers && !isAllNFT) {
33
- return [this.getTransactionImage(transfer), this.getTransactionImage(secondTransfer)];
33
+ const first = transfers.find(t => t?.direction === 'out');
34
+ const second = transfers.find(t => t?.direction === 'in');
35
+
36
+ return [this.getTransactionImage(first), this.getTransactionImage(second)];
34
37
  }
35
38
 
36
39
  if (haveMultipleTransfers) {
37
40
  return transfers.map(item => this.getTransactionImage(item));
38
41
  }
39
42
 
40
- return [this.getTransactionImage(transfer)];
43
+ return [this.getTransactionImage(transfers[0])];
41
44
  },
42
45
 
43
46
  getTransactionImage(transfer?: TransactionTransfer): TransactionImage {
@@ -72,66 +75,83 @@ export const TransactionUtil = {
72
75
  },
73
76
 
74
77
  getTransactionDescriptions(transaction: Transaction) {
75
- const type = transaction?.metadata?.operationType as TransactionType;
78
+ if (!transaction.metadata) {
79
+ return ['Unknown transaction'];
80
+ }
76
81
 
82
+ const type = transaction?.metadata?.operationType as TransactionType;
77
83
  const transfers = transaction?.transfers;
78
- const haveTransfer = transaction?.transfers?.length > 0;
79
- const haveMultipleTransfers = transaction?.transfers?.length > 1;
80
- const isSendOrReceive = type === 'send' || type === 'receive';
81
- const isFungible =
82
- haveTransfer && transfers?.every(transfer => Boolean(transfer?.fungible_info));
83
- const [firstTransfer, secondTransfer] = transfers;
84
-
85
- let firstDescription = this.getTransferDescription(firstTransfer);
86
- let secondDescription = this.getTransferDescription(secondTransfer);
87
-
88
- if (!haveTransfer) {
89
- if (isSendOrReceive && isFungible) {
90
- firstDescription = UiUtil.getTruncateString({
91
- string: transaction?.metadata.sentFrom,
92
- charsStart: 4,
93
- charsEnd: 6,
94
- truncate: 'middle'
95
- });
96
- secondDescription = UiUtil.getTruncateString({
97
- string: transaction?.metadata.sentTo,
98
- charsStart: 4,
99
- charsEnd: 6,
100
- truncate: 'middle'
101
- });
102
-
103
- return [firstDescription, secondDescription];
104
- }
105
-
106
- return [transaction.metadata.status];
84
+
85
+ // Early return for trade transactions
86
+ if (type === 'trade') {
87
+ return this.getTradeDescriptions(transfers);
107
88
  }
108
89
 
109
- if (haveMultipleTransfers) {
110
- return transfers.map(item => this.getTransferDescription(item));
90
+ // Handle multiple transfers
91
+ if (transfers.length > 1) {
92
+ return transfers.map(transfer => this.getTransferDescription(transfer));
111
93
  }
112
94
 
113
- let prefix = '';
114
- if (plusTypes.includes(type)) {
115
- prefix = '+';
116
- } else if (minusTypes.includes(type)) {
117
- prefix = '-';
95
+ // Handle single transfer
96
+ if (transfers.length === 1) {
97
+ return [this.formatSingleTransfer(transfers[0]!, type, transaction.metadata)];
118
98
  }
119
99
 
120
- firstDescription = prefix.concat(firstDescription);
100
+ return [transaction.metadata.status];
101
+ },
102
+
103
+ isSendReceiveTransaction(type: TransactionType): boolean {
104
+ return type === 'send' || type === 'receive';
105
+ },
106
+
107
+ hasFungibleTransfers(transfers: TransactionTransfer[]): boolean {
108
+ return transfers.every(transfer => Boolean(transfer?.fungible_info));
109
+ },
110
+
111
+ getSendReceiveDescriptions(metadata: TransactionMetadata): string[] {
112
+ return [this.truncateAddress(metadata.sentFrom), this.truncateAddress(metadata.sentTo)];
113
+ },
114
+
115
+ truncateAddress(address: string): string {
116
+ return UiUtil.getTruncateString({
117
+ string: address,
118
+ charsStart: 4,
119
+ charsEnd: 6,
120
+ truncate: 'middle'
121
+ });
122
+ },
121
123
 
122
- if (isSendOrReceive) {
124
+ formatSingleTransfer(
125
+ transfer: TransactionTransfer,
126
+ type: TransactionType,
127
+ metadata: TransactionMetadata
128
+ ): string {
129
+ const prefix = this.getPrefix(type);
130
+ let description = prefix.concat(this.getTransferDescription(transfer));
131
+
132
+ if (this.isSendReceiveTransaction(type)) {
123
133
  const isSend = type === 'send';
124
- const address = UiUtil.getTruncateString({
125
- string: isSend ? transaction.metadata.sentTo : transaction.metadata.sentFrom,
126
- charsStart: 4,
127
- charsEnd: 4,
128
- truncate: 'middle'
129
- });
134
+
135
+ const address = this.truncateAddress(isSend ? metadata.sentTo : metadata.sentFrom);
130
136
  const arrow = isSend ? '→' : '←';
131
- firstDescription = firstDescription.concat(` ${arrow} ${address}`);
137
+ description = description.concat(` ${arrow} ${address}`);
132
138
  }
133
139
 
134
- return [firstDescription];
140
+ return description;
141
+ },
142
+
143
+ getPrefix(type: TransactionType): string {
144
+ if (plusTypes.includes(type)) return '+';
145
+ if (minusTypes.includes(type)) return '-';
146
+
147
+ return '';
148
+ },
149
+
150
+ getTradeDescriptions(transfers: TransactionTransfer[]): string[] {
151
+ const outTransfer = transfers.find(transfer => transfer?.direction === 'out');
152
+ const inTransfer = transfers.find(transfer => transfer?.direction === 'in');
153
+
154
+ return [this.getTransferDescription(outTransfer), this.getTransferDescription(inTransfer)];
135
155
  },
136
156
 
137
157
  getTransferDescription(transfer?: TransactionTransfer) {
@@ -112,6 +112,7 @@ export type ColorType =
112
112
  | 'gray-glass-020'
113
113
  | 'gray-glass-010'
114
114
  | 'gray-glass-005'
115
+ | 'gray-glass-002'
115
116
  | 'inverse-000'
116
117
  | 'inverse-100'
117
118
  | 'success-100'
@@ -174,6 +175,7 @@ export type IconType =
174
175
  | 'off'
175
176
  | 'paperplane'
176
177
  | 'qrCode'
178
+ | 'recycleHorizontal'
177
179
  | 'refresh'
178
180
  | 'search'
179
181
  | 'swapHorizontal'