@cofhe/react 0.5.1 → 0.5.2

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.
@@ -0,0 +1,234 @@
1
+ import { FheTypeValue } from '@cofhe/sdk';
2
+ import { Address } from 'viem';
3
+
4
+ interface BaseProps {
5
+ /** Additional CSS class names */
6
+ className?: string;
7
+ /** Test ID for testing purposes */
8
+ testId?: string;
9
+ }
10
+ type ComponentSize = 'sm' | 'md' | 'lg';
11
+ interface DropdownOption {
12
+ label: string;
13
+ value: FheTypeValue;
14
+ maxValue?: bigint | null;
15
+ description?: string;
16
+ }
17
+ interface EncryptionProgressData {
18
+ step: string;
19
+ progress: number;
20
+ label: string;
21
+ }
22
+ interface EncryptionResultData {
23
+ value: string;
24
+ encrypted: any;
25
+ }
26
+ interface EncryptionStartData {
27
+ value: string;
28
+ type: string;
29
+ }
30
+
31
+ declare enum FloatingButtonPage$1 {
32
+ Main = "main",
33
+ Settings = "settings",
34
+ TokenInfo = "tokeninfo",
35
+ Send = "send",
36
+ Shield = "shield",
37
+ Activity = "activity",
38
+ Permits = "permits",
39
+ GeneratePermits = "generatePermit",
40
+ DelegatePermits = "delegatePermit",
41
+ ReceivePermits = "receivePermit",
42
+ Debug = "debug",
43
+ Portfolio = "portfolio",
44
+ ClaimableTokens = "claimableTokens"
45
+ }
46
+ interface FloatingButtonPagePropsRegistry {
47
+ }
48
+ type FloatingButtonPagePropsMap = {
49
+ [K in FloatingButtonPage$1]: K extends keyof FloatingButtonPagePropsRegistry ? FloatingButtonPagePropsRegistry[K] : void;
50
+ };
51
+ type PageState<K extends keyof FloatingButtonPagePropsMap = FloatingButtonPage$1> = {
52
+ page: K;
53
+ props?: FloatingButtonPagePropsMap[K];
54
+ };
55
+
56
+ type FloatingButtonPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
57
+ type FloatingButtonPositionType = 'fixed' | 'absolute';
58
+ interface CofheFloatingButtonProps extends BaseProps {
59
+ children?: React.ReactNode;
60
+ /** Position of the floating button */
61
+ position?: FloatingButtonPosition;
62
+ /** Z-index value (default: 9999) */
63
+ zIndex?: number;
64
+ /** Position type: 'fixed' stays on screen, 'absolute' positions within parent (default: 'fixed') */
65
+ positionType?: FloatingButtonPositionType;
66
+ /** Dark mode for the button (independent of page theme) */
67
+ darkMode?: boolean;
68
+ overriddingPage?: PageState;
69
+ }
70
+
71
+ /**
72
+ * Token types shared across hooks/components/utils.
73
+ *
74
+ * IMPORTANT: Keep this file dependency-free (no imports from hooks/providers/utils)
75
+ * to avoid circular dependencies.
76
+ */
77
+
78
+ /**
79
+ * Special address representing native ETH (used in erc20Pair for ConfidentialETH tokens)
80
+ */
81
+ declare const ETH_ADDRESS_LOWERCASE: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
82
+ /**
83
+ * ERC20 pair information for wrapped confidential tokens
84
+ */
85
+ type Erc20Pair = {
86
+ /** Address of the underlying ERC20 token (or ETH_ADDRESS for native ETH) */
87
+ address: Address;
88
+ symbol: string;
89
+ decimals: number;
90
+ logoURI?: string;
91
+ };
92
+ declare const TOKEN_CONFIDENTIALITY_SUPPORT: {
93
+ readonly wrapped: {
94
+ readonly enabled: true;
95
+ readonly label: "Wrapped confidential token";
96
+ readonly confidentialValueType: "uint128";
97
+ readonly publicBalanceSource: "erc20Pair";
98
+ readonly operations: {
99
+ readonly confidentialBalance: true;
100
+ readonly transfer: true;
101
+ readonly publicBalance: true;
102
+ readonly shield: true;
103
+ readonly unshield: true;
104
+ readonly claim: true;
105
+ readonly claimable: true;
106
+ };
107
+ };
108
+ readonly pure: {
109
+ readonly enabled: false;
110
+ readonly label: "Pure confidential token";
111
+ readonly confidentialValueType: "uint64";
112
+ readonly publicBalanceSource: null;
113
+ readonly operations: {
114
+ readonly confidentialBalance: false;
115
+ readonly transfer: false;
116
+ readonly publicBalance: false;
117
+ readonly shield: false;
118
+ readonly unshield: false;
119
+ readonly claim: false;
120
+ readonly claimable: false;
121
+ };
122
+ };
123
+ readonly dual: {
124
+ readonly enabled: false;
125
+ readonly label: "Dual-balance confidential token";
126
+ readonly confidentialValueType: "uint64";
127
+ readonly publicBalanceSource: "token";
128
+ readonly operations: {
129
+ readonly confidentialBalance: false;
130
+ readonly transfer: false;
131
+ readonly publicBalance: false;
132
+ readonly shield: false;
133
+ readonly unshield: false;
134
+ readonly claim: false;
135
+ readonly claimable: false;
136
+ };
137
+ };
138
+ };
139
+ type TokenConfidentialityType = keyof typeof TOKEN_CONFIDENTIALITY_SUPPORT;
140
+ type Token = {
141
+ chainId: number;
142
+ address: `0x${string}`;
143
+ symbol: string;
144
+ decimals: number;
145
+ name: string;
146
+ logoURI?: string;
147
+ extensions: Record<string, unknown> & {
148
+ fhenix: {
149
+ confidentialityType: TokenConfidentialityType;
150
+ confidentialValueType: 'uint64' | 'uint128';
151
+ /** ERC20 pair for wrapped tokens - contains underlying token info */
152
+ erc20Pair?: Erc20Pair;
153
+ };
154
+ };
155
+ };
156
+
157
+ /**
158
+ * Gets the block explorer URL for a given chain ID
159
+ * @param chainId - The chain ID to look up
160
+ * @returns The block explorer base URL, or undefined if not found
161
+ */
162
+ declare const getBlockExplorerUrl: (chainId: number) => string | undefined;
163
+ /**
164
+ * Gets the block explorer transaction URL for a given chain ID and transaction hash
165
+ * @param chainId - The chain ID
166
+ * @param hash - The transaction hash
167
+ * @returns The full transaction URL, or undefined if chain not found
168
+ */
169
+ declare const getBlockExplorerTxUrl: (chainId: number, hash: string) => string | undefined;
170
+ /**
171
+ * Gets the block explorer address URL for a given chain ID and address
172
+ * @param chainId - The chain ID
173
+ * @param address - The address
174
+ * @returns The full address URL, or undefined if chain not found
175
+ */
176
+ declare const getBlockExplorerAddressUrl: (chainId: number, address: string) => string | undefined;
177
+ /**
178
+ * Gets the block explorer token URL for a given chain ID and token address
179
+ * @param chainId - The chain ID
180
+ * @param tokenAddress - The token contract address
181
+ * @returns The full token URL, or undefined if chain not found
182
+ */
183
+ declare const getBlockExplorerTokenUrl: (chainId: number, tokenAddress: string) => string | undefined;
184
+ /**
185
+ * Check if an erc20Pair address is the native ETH address
186
+ * @param erc20Pair - The ERC20 pair object from token extensions
187
+ * @returns True if the pair address matches ETH_ADDRESS
188
+ */
189
+ declare const isEthPair: (erc20Pair: Erc20Pair | undefined) => boolean;
190
+ /**
191
+ * Check if a token is a wrapped ETH token (ConfidentialETH)
192
+ * @param token - The token object
193
+ * @returns True if the token is a wrapped token with ETH as the underlying pair
194
+ */
195
+ declare const isWrappedEthToken: (token: Token) => boolean;
196
+ interface FheTypeOption {
197
+ label: string;
198
+ value: FheTypeValue;
199
+ maxValue: bigint | null;
200
+ description: string;
201
+ }
202
+ declare const FheTypesList: FheTypeOption[];
203
+ /**
204
+ * Truncates a hex string (address or hash) to show beginning and end with ellipsis
205
+ * @param value - The hex string to truncate (address, hash, etc.)
206
+ * @param start - Number of characters to show at the start (default: 6, includes 0x)
207
+ * @param end - Number of characters to show at the end (default: 4)
208
+ * @returns Truncated string, or original if too short
209
+ *
210
+ * @example
211
+ * truncateHash('0x1234567890abcdef1234567890abcdef12345678')
212
+ * // Returns: '0x1234...5678'
213
+ */
214
+ declare const truncateHash: (value: string, start?: number, end?: number) => string;
215
+ /**
216
+ * Formats a timestamp as a relative time string (e.g., "2 hours ago")
217
+ * @param timestamp - Unix timestamp in milliseconds
218
+ * @returns Formatted relative time string
219
+ */
220
+ declare const formatRelativeTime: (timestamp: number) => string;
221
+
222
+ type GeneratePermitPageProps = {
223
+ onSuccessNavigateTo?: () => void;
224
+ onCancel?: () => void;
225
+ onBack?: () => void;
226
+ cause?: 'clicked_on_confidential_balance';
227
+ };
228
+ declare module '../../../pagesConfig/types' {
229
+ interface FloatingButtonPagePropsRegistry {
230
+ [FloatingButtonPage.GeneratePermits]: GeneratePermitPageProps;
231
+ }
232
+ }
233
+
234
+ export { type BaseProps as B, type CofheFloatingButtonProps as C, type DropdownOption as D, ETH_ADDRESS_LOWERCASE as E, type FloatingButtonPosition as F, type GeneratePermitPageProps as G, type Token as T, type Erc20Pair as a, FheTypesList as b, getBlockExplorerTxUrl as c, getBlockExplorerAddressUrl as d, getBlockExplorerTokenUrl as e, formatRelativeTime as f, getBlockExplorerUrl as g, isWrappedEthToken as h, isEthPair as i, type ComponentSize as j, type EncryptionStartData as k, type EncryptionProgressData as l, type EncryptionResultData as m, truncateHash as t };
@@ -0,0 +1,234 @@
1
+ import { FheTypeValue } from '@cofhe/sdk';
2
+ import { Address } from 'viem';
3
+
4
+ interface BaseProps {
5
+ /** Additional CSS class names */
6
+ className?: string;
7
+ /** Test ID for testing purposes */
8
+ testId?: string;
9
+ }
10
+ type ComponentSize = 'sm' | 'md' | 'lg';
11
+ interface DropdownOption {
12
+ label: string;
13
+ value: FheTypeValue;
14
+ maxValue?: bigint | null;
15
+ description?: string;
16
+ }
17
+ interface EncryptionProgressData {
18
+ step: string;
19
+ progress: number;
20
+ label: string;
21
+ }
22
+ interface EncryptionResultData {
23
+ value: string;
24
+ encrypted: any;
25
+ }
26
+ interface EncryptionStartData {
27
+ value: string;
28
+ type: string;
29
+ }
30
+
31
+ declare enum FloatingButtonPage$1 {
32
+ Main = "main",
33
+ Settings = "settings",
34
+ TokenInfo = "tokeninfo",
35
+ Send = "send",
36
+ Shield = "shield",
37
+ Activity = "activity",
38
+ Permits = "permits",
39
+ GeneratePermits = "generatePermit",
40
+ DelegatePermits = "delegatePermit",
41
+ ReceivePermits = "receivePermit",
42
+ Debug = "debug",
43
+ Portfolio = "portfolio",
44
+ ClaimableTokens = "claimableTokens"
45
+ }
46
+ interface FloatingButtonPagePropsRegistry {
47
+ }
48
+ type FloatingButtonPagePropsMap = {
49
+ [K in FloatingButtonPage$1]: K extends keyof FloatingButtonPagePropsRegistry ? FloatingButtonPagePropsRegistry[K] : void;
50
+ };
51
+ type PageState<K extends keyof FloatingButtonPagePropsMap = FloatingButtonPage$1> = {
52
+ page: K;
53
+ props?: FloatingButtonPagePropsMap[K];
54
+ };
55
+
56
+ type FloatingButtonPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
57
+ type FloatingButtonPositionType = 'fixed' | 'absolute';
58
+ interface CofheFloatingButtonProps extends BaseProps {
59
+ children?: React.ReactNode;
60
+ /** Position of the floating button */
61
+ position?: FloatingButtonPosition;
62
+ /** Z-index value (default: 9999) */
63
+ zIndex?: number;
64
+ /** Position type: 'fixed' stays on screen, 'absolute' positions within parent (default: 'fixed') */
65
+ positionType?: FloatingButtonPositionType;
66
+ /** Dark mode for the button (independent of page theme) */
67
+ darkMode?: boolean;
68
+ overriddingPage?: PageState;
69
+ }
70
+
71
+ /**
72
+ * Token types shared across hooks/components/utils.
73
+ *
74
+ * IMPORTANT: Keep this file dependency-free (no imports from hooks/providers/utils)
75
+ * to avoid circular dependencies.
76
+ */
77
+
78
+ /**
79
+ * Special address representing native ETH (used in erc20Pair for ConfidentialETH tokens)
80
+ */
81
+ declare const ETH_ADDRESS_LOWERCASE: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
82
+ /**
83
+ * ERC20 pair information for wrapped confidential tokens
84
+ */
85
+ type Erc20Pair = {
86
+ /** Address of the underlying ERC20 token (or ETH_ADDRESS for native ETH) */
87
+ address: Address;
88
+ symbol: string;
89
+ decimals: number;
90
+ logoURI?: string;
91
+ };
92
+ declare const TOKEN_CONFIDENTIALITY_SUPPORT: {
93
+ readonly wrapped: {
94
+ readonly enabled: true;
95
+ readonly label: "Wrapped confidential token";
96
+ readonly confidentialValueType: "uint128";
97
+ readonly publicBalanceSource: "erc20Pair";
98
+ readonly operations: {
99
+ readonly confidentialBalance: true;
100
+ readonly transfer: true;
101
+ readonly publicBalance: true;
102
+ readonly shield: true;
103
+ readonly unshield: true;
104
+ readonly claim: true;
105
+ readonly claimable: true;
106
+ };
107
+ };
108
+ readonly pure: {
109
+ readonly enabled: false;
110
+ readonly label: "Pure confidential token";
111
+ readonly confidentialValueType: "uint64";
112
+ readonly publicBalanceSource: null;
113
+ readonly operations: {
114
+ readonly confidentialBalance: false;
115
+ readonly transfer: false;
116
+ readonly publicBalance: false;
117
+ readonly shield: false;
118
+ readonly unshield: false;
119
+ readonly claim: false;
120
+ readonly claimable: false;
121
+ };
122
+ };
123
+ readonly dual: {
124
+ readonly enabled: false;
125
+ readonly label: "Dual-balance confidential token";
126
+ readonly confidentialValueType: "uint64";
127
+ readonly publicBalanceSource: "token";
128
+ readonly operations: {
129
+ readonly confidentialBalance: false;
130
+ readonly transfer: false;
131
+ readonly publicBalance: false;
132
+ readonly shield: false;
133
+ readonly unshield: false;
134
+ readonly claim: false;
135
+ readonly claimable: false;
136
+ };
137
+ };
138
+ };
139
+ type TokenConfidentialityType = keyof typeof TOKEN_CONFIDENTIALITY_SUPPORT;
140
+ type Token = {
141
+ chainId: number;
142
+ address: `0x${string}`;
143
+ symbol: string;
144
+ decimals: number;
145
+ name: string;
146
+ logoURI?: string;
147
+ extensions: Record<string, unknown> & {
148
+ fhenix: {
149
+ confidentialityType: TokenConfidentialityType;
150
+ confidentialValueType: 'uint64' | 'uint128';
151
+ /** ERC20 pair for wrapped tokens - contains underlying token info */
152
+ erc20Pair?: Erc20Pair;
153
+ };
154
+ };
155
+ };
156
+
157
+ /**
158
+ * Gets the block explorer URL for a given chain ID
159
+ * @param chainId - The chain ID to look up
160
+ * @returns The block explorer base URL, or undefined if not found
161
+ */
162
+ declare const getBlockExplorerUrl: (chainId: number) => string | undefined;
163
+ /**
164
+ * Gets the block explorer transaction URL for a given chain ID and transaction hash
165
+ * @param chainId - The chain ID
166
+ * @param hash - The transaction hash
167
+ * @returns The full transaction URL, or undefined if chain not found
168
+ */
169
+ declare const getBlockExplorerTxUrl: (chainId: number, hash: string) => string | undefined;
170
+ /**
171
+ * Gets the block explorer address URL for a given chain ID and address
172
+ * @param chainId - The chain ID
173
+ * @param address - The address
174
+ * @returns The full address URL, or undefined if chain not found
175
+ */
176
+ declare const getBlockExplorerAddressUrl: (chainId: number, address: string) => string | undefined;
177
+ /**
178
+ * Gets the block explorer token URL for a given chain ID and token address
179
+ * @param chainId - The chain ID
180
+ * @param tokenAddress - The token contract address
181
+ * @returns The full token URL, or undefined if chain not found
182
+ */
183
+ declare const getBlockExplorerTokenUrl: (chainId: number, tokenAddress: string) => string | undefined;
184
+ /**
185
+ * Check if an erc20Pair address is the native ETH address
186
+ * @param erc20Pair - The ERC20 pair object from token extensions
187
+ * @returns True if the pair address matches ETH_ADDRESS
188
+ */
189
+ declare const isEthPair: (erc20Pair: Erc20Pair | undefined) => boolean;
190
+ /**
191
+ * Check if a token is a wrapped ETH token (ConfidentialETH)
192
+ * @param token - The token object
193
+ * @returns True if the token is a wrapped token with ETH as the underlying pair
194
+ */
195
+ declare const isWrappedEthToken: (token: Token) => boolean;
196
+ interface FheTypeOption {
197
+ label: string;
198
+ value: FheTypeValue;
199
+ maxValue: bigint | null;
200
+ description: string;
201
+ }
202
+ declare const FheTypesList: FheTypeOption[];
203
+ /**
204
+ * Truncates a hex string (address or hash) to show beginning and end with ellipsis
205
+ * @param value - The hex string to truncate (address, hash, etc.)
206
+ * @param start - Number of characters to show at the start (default: 6, includes 0x)
207
+ * @param end - Number of characters to show at the end (default: 4)
208
+ * @returns Truncated string, or original if too short
209
+ *
210
+ * @example
211
+ * truncateHash('0x1234567890abcdef1234567890abcdef12345678')
212
+ * // Returns: '0x1234...5678'
213
+ */
214
+ declare const truncateHash: (value: string, start?: number, end?: number) => string;
215
+ /**
216
+ * Formats a timestamp as a relative time string (e.g., "2 hours ago")
217
+ * @param timestamp - Unix timestamp in milliseconds
218
+ * @returns Formatted relative time string
219
+ */
220
+ declare const formatRelativeTime: (timestamp: number) => string;
221
+
222
+ type GeneratePermitPageProps = {
223
+ onSuccessNavigateTo?: () => void;
224
+ onCancel?: () => void;
225
+ onBack?: () => void;
226
+ cause?: 'clicked_on_confidential_balance';
227
+ };
228
+ declare module '../../../pagesConfig/types' {
229
+ interface FloatingButtonPagePropsRegistry {
230
+ [FloatingButtonPage.GeneratePermits]: GeneratePermitPageProps;
231
+ }
232
+ }
233
+
234
+ export { type BaseProps as B, type CofheFloatingButtonProps as C, type DropdownOption as D, ETH_ADDRESS_LOWERCASE as E, type FloatingButtonPosition as F, type GeneratePermitPageProps as G, type Token as T, type Erc20Pair as a, FheTypesList as b, getBlockExplorerTxUrl as c, getBlockExplorerAddressUrl as d, getBlockExplorerTokenUrl as e, formatRelativeTime as f, getBlockExplorerUrl as g, isWrappedEthToken as h, isEthPair as i, type ComponentSize as j, type EncryptionStartData as k, type EncryptionProgressData as l, type EncryptionResultData as m, truncateHash as t };