@cofhe/react 0.5.1 → 0.6.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.
package/dist/index.d.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as _cofhe_sdk from '@cofhe/sdk';
3
- import { CofheConfig, CofheInputConfig, FheTypeValue, CofheClient, CofheClientConnectionState, EncryptStep, EncryptStepCallbackContext, EncryptedItemInput, EncryptableItem, EncryptedItemInputs, FheTypes, UnsealedItem } from '@cofhe/sdk';
3
+ import { CofheConfig, CofheInputConfig, CofheClient, CofheClientConnectionState, EncryptStep, EncryptStepCallbackContext, EncryptedItemInput, EncryptableItem, EncryptedItemInputs, FheTypes, UnsealedItem } from '@cofhe/sdk';
4
4
  import { z } from 'zod';
5
5
  import * as _tanstack_react_query from '@tanstack/react-query';
6
6
  import { QueryClient, UseQueryOptions, UseQueryResult, UseMutationOptions, UseMutationResult, MutationFunctionContext } from '@tanstack/react-query';
7
7
  import * as viem from 'viem';
8
- import { WalletClient, PublicClient, Address, ContractFunctionName, Hash, Abi as Abi$1, ContractFunctionArgs, Chain, WriteContractParameters, Account, SimulateContractReturnType, SimulateContractParameters, TransactionReceipt } from 'viem';
8
+ import { WalletClient, PublicClient, ContractFunctionName, Address, Hash, Abi as Abi$1, ContractFunctionArgs, Chain, WriteContractParameters, Account, SimulateContractReturnType, SimulateContractParameters, TransactionReceipt } from 'viem';
9
+ import { F as FloatingButtonPosition, T as Token, G as GeneratePermitPageProps } from './types-BzYdBjL5.js';
10
+ export { E as ETH_ADDRESS_LOWERCASE, a as Erc20Pair, b as FheTypesList, f as formatRelativeTime, d as getBlockExplorerAddressUrl, e as getBlockExplorerTokenUrl, c as getBlockExplorerTxUrl, g as getBlockExplorerUrl, i as isEthPair, h as isWrappedEthToken, t as truncateHash } from './types-BzYdBjL5.js';
9
11
  import { Abi, CofheReturnType, CofheInputArgsPreTransform, CofheFirstReturnFheType } from '@cofhe/abi';
10
12
  import { Permit } from '@cofhe/sdk/permits';
11
13
  import BigNumber from 'bignumber.js';
@@ -73,73 +75,6 @@ type CofheConfigWithReact = CofheConfig & {
73
75
  */
74
76
  declare function createCofheConfig(config: CofheReactInputConfig): CofheConfigWithReact;
75
77
 
76
- interface BaseProps {
77
- /** Additional CSS class names */
78
- className?: string;
79
- /** Test ID for testing purposes */
80
- testId?: string;
81
- }
82
- type ComponentSize = 'sm' | 'md' | 'lg';
83
- interface DropdownOption {
84
- label: string;
85
- value: FheTypeValue;
86
- maxValue?: bigint | null;
87
- description?: string;
88
- }
89
- interface EncryptionProgressData {
90
- step: string;
91
- progress: number;
92
- label: string;
93
- }
94
- interface EncryptionResultData {
95
- value: string;
96
- encrypted: any;
97
- }
98
- interface EncryptionStartData {
99
- value: string;
100
- type: string;
101
- }
102
-
103
- declare enum FloatingButtonPage$1 {
104
- Main = "main",
105
- Settings = "settings",
106
- TokenInfo = "tokeninfo",
107
- Send = "send",
108
- Shield = "shield",
109
- Activity = "activity",
110
- Permits = "permits",
111
- GeneratePermits = "generatePermit",
112
- DelegatePermits = "delegatePermit",
113
- ReceivePermits = "receivePermit",
114
- Debug = "debug",
115
- Portfolio = "portfolio",
116
- ClaimableTokens = "claimableTokens"
117
- }
118
- interface FloatingButtonPagePropsRegistry {
119
- }
120
- type FloatingButtonPagePropsMap = {
121
- [K in FloatingButtonPage$1]: K extends keyof FloatingButtonPagePropsRegistry ? FloatingButtonPagePropsRegistry[K] : void;
122
- };
123
- type PageState<K extends keyof FloatingButtonPagePropsMap = FloatingButtonPage$1> = {
124
- page: K;
125
- props?: FloatingButtonPagePropsMap[K];
126
- };
127
-
128
- type FloatingButtonPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
129
- type FloatingButtonPositionType = 'fixed' | 'absolute';
130
- interface CofheFloatingButtonProps extends BaseProps {
131
- children?: React.ReactNode;
132
- /** Position of the floating button */
133
- position?: FloatingButtonPosition;
134
- /** Z-index value (default: 9999) */
135
- zIndex?: number;
136
- /** Position type: 'fixed' stays on screen, 'absolute' positions within parent (default: 'fixed') */
137
- positionType?: FloatingButtonPositionType;
138
- /** Dark mode for the button (independent of page theme) */
139
- darkMode?: boolean;
140
- overriddingPage?: PageState;
141
- }
142
-
143
78
  interface CofheContextValue {
144
79
  client: CofheClient<CofheConfigWithReact>;
145
80
  state: {
@@ -199,8 +134,6 @@ declare const useCofhePublicClient: () => {
199
134
  number: blockTag extends "pending" ? null : bigint;
200
135
  nonce: blockTag extends "pending" ? null : `0x${string}`;
201
136
  hash: blockTag extends "pending" ? null : `0x${string}`;
202
- size: bigint;
203
- timestamp: bigint;
204
137
  logsBloom: blockTag extends "pending" ? null : `0x${string}`;
205
138
  baseFeePerGas: bigint | null;
206
139
  blobGasUsed: bigint;
@@ -216,7 +149,9 @@ declare const useCofhePublicClient: () => {
216
149
  receiptsRoot: viem.Hex;
217
150
  sealFields: viem.Hex[];
218
151
  sha3Uncles: viem.Hash;
152
+ size: bigint;
219
153
  stateRoot: viem.Hash;
154
+ timestamp: bigint;
220
155
  totalDifficulty: bigint | null;
221
156
  transactionsRoot: viem.Hash;
222
157
  uncles: viem.Hash[];
@@ -14731,92 +14666,6 @@ declare const useCofheWalletClient: () => {
14731
14666
  } & viem.ExactPartial<Pick<viem.PublicActions<viem.Transport, viem.Chain | undefined, viem.Account | undefined>, "getChainId" | "prepareTransactionRequest" | "sendRawTransaction" | "call" | "createContractEventFilter" | "createEventFilter" | "estimateContractGas" | "estimateGas" | "getBlock" | "getBlockNumber" | "getContractEvents" | "getEnsText" | "getFilterChanges" | "getGasPrice" | "getLogs" | "getTransaction" | "getTransactionCount" | "getTransactionReceipt" | "readContract" | "simulateContract" | "uninstallFilter" | "watchBlockNumber" | "watchContractEvent"> & Pick<viem.WalletActions<viem.Chain | undefined, viem.Account | undefined>, "sendTransaction" | "writeContract">>>(fn: (client: viem.Client<viem.Transport, viem.Chain | undefined, viem.Account | undefined, viem.WalletRpcSchema, viem.WalletActions<viem.Chain | undefined, viem.Account | undefined>>) => client) => viem.Client<viem.Transport, viem.Chain | undefined, viem.Account | undefined, viem.WalletRpcSchema, { [K in keyof client]: client[K]; } & viem.WalletActions<viem.Chain | undefined, viem.Account | undefined>>;
14732
14667
  } | undefined;
14733
14668
 
14734
- /**
14735
- * Token types shared across hooks/components/utils.
14736
- *
14737
- * IMPORTANT: Keep this file dependency-free (no imports from hooks/providers/utils)
14738
- * to avoid circular dependencies.
14739
- */
14740
-
14741
- /**
14742
- * Special address representing native ETH (used in erc20Pair for ConfidentialETH tokens)
14743
- */
14744
- declare const ETH_ADDRESS_LOWERCASE: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
14745
- /**
14746
- * ERC20 pair information for wrapped confidential tokens
14747
- */
14748
- type Erc20Pair = {
14749
- /** Address of the underlying ERC20 token (or ETH_ADDRESS for native ETH) */
14750
- address: Address;
14751
- symbol: string;
14752
- decimals: number;
14753
- logoURI?: string;
14754
- };
14755
- declare const TOKEN_CONFIDENTIALITY_SUPPORT: {
14756
- readonly wrapped: {
14757
- readonly enabled: true;
14758
- readonly label: "Wrapped confidential token";
14759
- readonly confidentialValueType: "uint128";
14760
- readonly publicBalanceSource: "erc20Pair";
14761
- readonly operations: {
14762
- readonly confidentialBalance: true;
14763
- readonly transfer: true;
14764
- readonly publicBalance: true;
14765
- readonly shield: true;
14766
- readonly unshield: true;
14767
- readonly claim: true;
14768
- readonly claimable: true;
14769
- };
14770
- };
14771
- readonly pure: {
14772
- readonly enabled: false;
14773
- readonly label: "Pure confidential token";
14774
- readonly confidentialValueType: "uint64";
14775
- readonly publicBalanceSource: null;
14776
- readonly operations: {
14777
- readonly confidentialBalance: false;
14778
- readonly transfer: false;
14779
- readonly publicBalance: false;
14780
- readonly shield: false;
14781
- readonly unshield: false;
14782
- readonly claim: false;
14783
- readonly claimable: false;
14784
- };
14785
- };
14786
- readonly dual: {
14787
- readonly enabled: false;
14788
- readonly label: "Dual-balance confidential token";
14789
- readonly confidentialValueType: "uint64";
14790
- readonly publicBalanceSource: "token";
14791
- readonly operations: {
14792
- readonly confidentialBalance: false;
14793
- readonly transfer: false;
14794
- readonly publicBalance: false;
14795
- readonly shield: false;
14796
- readonly unshield: false;
14797
- readonly claim: false;
14798
- readonly claimable: false;
14799
- };
14800
- };
14801
- };
14802
- type TokenConfidentialityType = keyof typeof TOKEN_CONFIDENTIALITY_SUPPORT;
14803
- type Token = {
14804
- chainId: number;
14805
- address: `0x${string}`;
14806
- symbol: string;
14807
- decimals: number;
14808
- name: string;
14809
- logoURI?: string;
14810
- extensions: Record<string, unknown> & {
14811
- fhenix: {
14812
- confidentialityType: TokenConfidentialityType;
14813
- confidentialValueType: 'uint64' | 'uint128';
14814
- /** ERC20 pair for wrapped tokens - contains underlying token info */
14815
- erc20Pair?: Erc20Pair;
14816
- };
14817
- };
14818
- };
14819
-
14820
14669
  type UseCofheReadContractQueryOptions<TAbi extends Abi, TfunctionName extends ContractFunctionName<TAbi, 'pure' | 'view'>> = Omit<UseQueryOptions<CofheReturnType<TAbi, TfunctionName>, Error>, 'queryKey' | 'queryFn'> & {
14821
14670
  enabled?: boolean;
14822
14671
  };
@@ -15364,6 +15213,22 @@ declare function useTokensWithPublicBalances({ chainId: _chainId, accountAddress
15364
15213
  enabled?: boolean;
15365
15214
  } & Omit<UseTokenBalanceOptions, 'select'>): UseTokensWithPublicBalancesResult;
15366
15215
 
15216
+ type CreatePermitArgs = {
15217
+ name: string;
15218
+ isSelf: true;
15219
+ expirationSeconds: number;
15220
+ } | {
15221
+ name: string;
15222
+ isSelf: false;
15223
+ receiver: `0x${string}`;
15224
+ expirationSeconds: number;
15225
+ };
15226
+ type Input$2 = {
15227
+ onSuccess?: () => void;
15228
+ onError?: (error: Error) => void;
15229
+ };
15230
+ declare const useCofheCreatePermit: ({ onSuccess, onError }?: Input$2) => _tanstack_react_query.UseMutationResult<void, Error, CreatePermitArgs, unknown>;
15231
+
15367
15232
  type Input$1 = {
15368
15233
  publicClient?: PublicClient;
15369
15234
  walletClient?: WalletClient;
@@ -15507,166 +15372,9 @@ declare function useCofheReadContractAndDecrypt<TAbi extends Abi$1, TfunctionNam
15507
15372
  disabledDueToMissingValidPermit: boolean;
15508
15373
  };
15509
15374
 
15510
- declare const CofheFloatingButtonWithProvider: React.FC<CofheFloatingButtonProps>;
15511
-
15512
- declare const MainPage: React.FC;
15513
-
15514
- declare const SettingsPage: React.FC;
15515
-
15516
- type GeneratePermitPageProps = {
15517
- onSuccessNavigateTo?: () => void;
15518
- onCancel?: () => void;
15519
- onBack?: () => void;
15520
- cause?: 'clicked_on_confidential_balance';
15521
- };
15522
- declare module '../../../pagesConfig/types' {
15523
- interface FloatingButtonPagePropsRegistry {
15524
- [FloatingButtonPage.GeneratePermits]: GeneratePermitPageProps;
15525
- }
15526
- }
15527
-
15528
- type DelegatePermitPageProps = {
15529
- onSuccessNavigateTo?: () => void;
15530
- onCancel?: () => void;
15531
- onBack?: () => void;
15532
- };
15533
- declare module '../../../pagesConfig/types' {
15534
- interface FloatingButtonPagePropsRegistry {
15535
- [FloatingButtonPage.DelegatePermits]: DelegatePermitPageProps;
15536
- }
15537
- }
15538
-
15539
- type TokenInfoPageProps = {
15540
- token: Token;
15541
- };
15542
- declare module '../pagesConfig/types' {
15543
- interface FloatingButtonPagePropsRegistry {
15544
- [FloatingButtonPage.TokenInfo]: TokenInfoPageProps;
15545
- }
15546
- }
15547
-
15548
- type SendPageProps = {
15549
- token: Token;
15550
- };
15551
- declare module '../pagesConfig/types' {
15552
- interface FloatingButtonPagePropsRegistry {
15553
- [FloatingButtonPage.Send]: SendPageProps;
15554
- }
15555
- }
15556
-
15557
- type Mode = 'shield' | 'unshield';
15558
- type ShieldPageProps = {
15559
- token: Token;
15560
- defaultMode?: Mode;
15561
- };
15562
- declare module '../pagesConfig/types' {
15563
- interface FloatingButtonPagePropsRegistry {
15564
- [FloatingButtonPage.Shield]: ShieldPageProps;
15565
- }
15566
- }
15567
-
15568
- interface CofheEncryptInputProps extends BaseProps {
15569
- /** Placeholder text for the text field */
15570
- placeholder?: string;
15571
- /** Initial value for the text field */
15572
- initialValue?: string;
15573
- /** Dropdown options for encryption types */
15574
- options?: DropdownOption[];
15575
- /** Component size */
15576
- size?: ComponentSize;
15577
- /** Whether inputs have errors */
15578
- hasError?: boolean;
15579
- /** Error message to display */
15580
- errorMessage?: string;
15581
- /** Whether the component is disabled */
15582
- disabled?: boolean;
15583
- /** Whether to show the progress bar during encryption */
15584
- showProgressBar?: boolean;
15585
- /** Debounce delay for validation in milliseconds (default: 300) */
15586
- debounceMs?: number;
15587
- /** Callback when text changes */
15588
- onTextChange?: (_value: string) => void;
15589
- /** Callback when encryption type selection changes */
15590
- onTypeChange?: (_value: string) => void;
15591
- /** Callback when encryption starts */
15592
- onEncryptStart?: (_data: EncryptionStartData) => void;
15593
- /** Callback for encryption progress updates */
15594
- onEncryptProgress?: (_data: EncryptionProgressData) => void;
15595
- /** Callback when encryption completes successfully */
15596
- onEncryptComplete?: (_data: EncryptionResultData) => void;
15597
- /** Callback when encryption fails */
15598
- onEncryptError?: (_error: string) => void;
15599
- }
15600
- declare const CofheEncryptInput: React.FC<CofheEncryptInputProps>;
15601
-
15602
- /**
15603
- * Gets the block explorer URL for a given chain ID
15604
- * @param chainId - The chain ID to look up
15605
- * @returns The block explorer base URL, or undefined if not found
15606
- */
15607
- declare const getBlockExplorerUrl: (chainId: number) => string | undefined;
15608
- /**
15609
- * Gets the block explorer transaction URL for a given chain ID and transaction hash
15610
- * @param chainId - The chain ID
15611
- * @param hash - The transaction hash
15612
- * @returns The full transaction URL, or undefined if chain not found
15613
- */
15614
- declare const getBlockExplorerTxUrl: (chainId: number, hash: string) => string | undefined;
15615
- /**
15616
- * Gets the block explorer address URL for a given chain ID and address
15617
- * @param chainId - The chain ID
15618
- * @param address - The address
15619
- * @returns The full address URL, or undefined if chain not found
15620
- */
15621
- declare const getBlockExplorerAddressUrl: (chainId: number, address: string) => string | undefined;
15622
- /**
15623
- * Gets the block explorer token URL for a given chain ID and token address
15624
- * @param chainId - The chain ID
15625
- * @param tokenAddress - The token contract address
15626
- * @returns The full token URL, or undefined if chain not found
15627
- */
15628
- declare const getBlockExplorerTokenUrl: (chainId: number, tokenAddress: string) => string | undefined;
15629
- /**
15630
- * Check if an erc20Pair address is the native ETH address
15631
- * @param erc20Pair - The ERC20 pair object from token extensions
15632
- * @returns True if the pair address matches ETH_ADDRESS
15633
- */
15634
- declare const isEthPair: (erc20Pair: Erc20Pair | undefined) => boolean;
15635
- /**
15636
- * Check if a token is a wrapped ETH token (ConfidentialETH)
15637
- * @param token - The token object
15638
- * @returns True if the token is a wrapped token with ETH as the underlying pair
15639
- */
15640
- declare const isWrappedEthToken: (token: Token) => boolean;
15641
- interface FheTypeOption {
15642
- label: string;
15643
- value: FheTypeValue;
15644
- maxValue: bigint | null;
15645
- description: string;
15646
- }
15647
- declare const FheTypesList: FheTypeOption[];
15648
- /**
15649
- * Truncates a hex string (address or hash) to show beginning and end with ellipsis
15650
- * @param value - The hex string to truncate (address, hash, etc.)
15651
- * @param start - Number of characters to show at the start (default: 6, includes 0x)
15652
- * @param end - Number of characters to show at the end (default: 4)
15653
- * @returns Truncated string, or original if too short
15654
- *
15655
- * @example
15656
- * truncateHash('0x1234567890abcdef1234567890abcdef12345678')
15657
- * // Returns: '0x1234...5678'
15658
- */
15659
- declare const truncateHash: (value: string, start?: number, end?: number) => string;
15660
- /**
15661
- * Formats a timestamp as a relative time string (e.g., "2 hours ago")
15662
- * @param timestamp - Unix timestamp in milliseconds
15663
- * @returns Formatted relative time string
15664
- */
15665
- declare const formatRelativeTime: (timestamp: number) => string;
15666
-
15667
15375
  type Input = {
15668
15376
  cause?: GeneratePermitPageProps['cause'];
15669
15377
  };
15670
15378
  declare const useCofheNavigateToCreatePermit: () => ({ cause }?: Input) => void;
15671
15379
 
15672
- export { type ClaimableAmountByTokenAddress, type CofheClientConfig, type CofheContextValue, CofheEncryptInput, type CofheFloatingButtonProps, CofheFloatingButtonWithProvider, CofheProvider, type CofheProviderProps, type CofheReactLogger, type CofheReactLoggerMethod, type CofheConfigWithReact as CofhesdkConfigWithReact, type CoingeckoMarketChartPoint, ETH_ADDRESS_LOWERCASE, type Erc20Pair, FheTypesList, type FloatingButtonPosition, MainPage, SettingsPage, type Token, type Transaction, type TransactionActionString, TransactionActionType, TransactionStatus, type TransactionStatusString, type TransactionStore, type UnshieldClaim, type UnshieldClaimsSummary, type UnshieldClaimsSummaryByTokenAddress, type UseCoingeckoContractMarketChartRangeInput, type UseCoingeckoContractMarketChartRangeOptions, type UseCoingeckoUsdPriceInput, type UseCoingeckoUsdPriceOptions, type UseTransactionReceiptsByHashInput, actionToString, createCofheConfig, formatRelativeTime, getBlockExplorerAddressUrl, getBlockExplorerTokenUrl, getBlockExplorerTxUrl, getBlockExplorerUrl, getCofheTokenClaimUnshieldedCallArgs, getCofheTokenShieldCallArgs, getCofheTokenUnshieldCallArgs, isEthPair, isWrappedEthToken, statusToString, truncateHash, useCofheActivePermit, useCofheAllPermits, useCofheAutoConnect, useCofheClient, useCofheConnection, useCofheContext, useCofheEnabled, useCofheEncrypt, useCofheEncryptAndWriteContract, useCofheNavigateToCreatePermit, useCofhePublicClient, useCofheReadContractAndDecrypt, useCofheRemovePermit, useCofheSelectPermit, useCofheSimulateWriteContract, useCofheTokenClaimUnshielded, useCofheTokenClaimable, useCofheTokenDecryptedBalance, useCofheTokenLists, useCofheTokenShield, useCofheTokenTransfer, useCofheTokenUnshield, useCofheTokens, useCofheTokensClaimable, useCofheTokensWithExistingEncryptedBalances, useCofheWalletClient, useCofheWriteContract, useCoingeckoContractMarketChartRange, useCoingeckoUsdPrice, useInternalQueryClient, useTokenAllowance, useTokensWithPublicBalances, useTransactionReceiptsByHash, useTransactionStore };
15380
+ export { type ClaimableAmountByTokenAddress, type CofheClientConfig, type CofheContextValue, CofheProvider, type CofheProviderProps, type CofheReactLogger, type CofheReactLoggerMethod, type CofheConfigWithReact as CofhesdkConfigWithReact, type CoingeckoMarketChartPoint, Token, type Transaction, type TransactionActionString, TransactionActionType, TransactionStatus, type TransactionStatusString, type TransactionStore, type UnshieldClaim, type UnshieldClaimsSummary, type UnshieldClaimsSummaryByTokenAddress, type UseCoingeckoContractMarketChartRangeInput, type UseCoingeckoContractMarketChartRangeOptions, type UseCoingeckoUsdPriceInput, type UseCoingeckoUsdPriceOptions, type UseTransactionReceiptsByHashInput, actionToString, createCofheConfig, getCofheTokenClaimUnshieldedCallArgs, getCofheTokenShieldCallArgs, getCofheTokenUnshieldCallArgs, statusToString, useCofheActivePermit, useCofheAllPermits, useCofheAutoConnect, useCofheClient, useCofheConnection, useCofheContext, useCofheCreatePermit, useCofheEnabled, useCofheEncrypt, useCofheEncryptAndWriteContract, useCofheNavigateToCreatePermit, useCofhePublicClient, useCofheReadContractAndDecrypt, useCofheRemovePermit, useCofheSelectPermit, useCofheSimulateWriteContract, useCofheTokenClaimUnshielded, useCofheTokenClaimable, useCofheTokenDecryptedBalance, useCofheTokenLists, useCofheTokenShield, useCofheTokenTransfer, useCofheTokenUnshield, useCofheTokens, useCofheTokensClaimable, useCofheTokensWithExistingEncryptedBalances, useCofheWalletClient, useCofheWriteContract, useCoingeckoContractMarketChartRange, useCoingeckoUsdPrice, useInternalQueryClient, useTokenAllowance, useTokensWithPublicBalances, useTransactionReceiptsByHash, useTransactionStore };