@cfxdevkit/react 1.0.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/README.md +33 -0
- package/dist/components/index.cjs +506 -0
- package/dist/components/index.cjs.map +1 -0
- package/dist/components/index.d.cts +4 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +465 -0
- package/dist/components/index.js.map +1 -0
- package/dist/hooks/index.cjs +198 -0
- package/dist/hooks/index.cjs.map +1 -0
- package/dist/hooks/index.d.cts +125 -0
- package/dist/hooks/index.d.ts +125 -0
- package/dist/hooks/index.js +169 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/index-CU9Acwhq.d.cts +233 -0
- package/dist/index-CU9Acwhq.d.ts +233 -0
- package/dist/index.cjs +622 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +27 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +573 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/index.cjs +109 -0
- package/dist/providers/index.cjs.map +1 -0
- package/dist/providers/index.d.cts +77 -0
- package/dist/providers/index.d.ts +77 -0
- package/dist/providers/index.js +79 -0
- package/dist/providers/index.js.map +1 -0
- package/package.json +98 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/hooks/useBalance.ts","../src/providers/DevKitProvider.tsx","../src/providers/WalletProvider.tsx","../src/components/account-display/AccountCard.tsx","../src/components/connect-wallet/ConnectButton.tsx","../src/components/contract/ContractReader.tsx","../src/hooks/useContract.ts","../src/components/contract/ContractWriter.tsx","../src/components/swap/SwapWidget.tsx","../src/hooks/useTransaction.ts"],"sourcesContent":["/*\n * Copyright 2025 Conflux DevKit Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Conflux DevKit UI Headless - Customizable React Components\n *\n * This package provides headless React components for Conflux applications.\n * Components use the render prop pattern for maximum customization while\n * also providing default Tailwind-based styling.\n *\n * Features:\n * - Headless components with render props\n * - Default Tailwind styling\n * - React hooks for blockchain operations\n * - Context providers for state management\n * - Full TypeScript support\n *\n * @packageDocumentation\n */\n\nexport type {\n AccountCardProps,\n AccountCardRenderProps,\n ConnectButtonProps,\n ConnectButtonRenderProps,\n ContractReaderProps,\n ContractReaderRenderProps,\n ContractWriterProps,\n ContractWriterRenderProps,\n SwapQuote,\n SwapWidgetProps,\n SwapWidgetRenderProps,\n} from './components/index.js';\n// Components\nexport {\n AccountCard,\n ConnectButton,\n ContractReader,\n ContractWriter,\n SwapWidget,\n} from './components/index.js';\nexport type {\n ReadContractOptions,\n SendTransactionOptions,\n TransactionResult,\n UseBalanceOptions,\n UseBalanceReturn,\n UseContractReturn,\n UseTransactionReturn,\n WriteContractOptions,\n} from './hooks/index.js';\n// Hooks\nexport {\n useBalance,\n useContract,\n useTransaction,\n} from './hooks/index.js';\n// Types\nexport type {\n DevKitContextValue,\n DevKitProviderProps,\n WalletContextValue,\n WalletProviderProps,\n} from './providers/index.js';\n// Providers\nexport {\n DevKitProvider,\n useDevKitContext,\n useWalletContext,\n WalletProvider,\n} from './providers/index.js';\n\nexport type {\n BaseComponentProps,\n ContractDeployment,\n NetworkInfo,\n RenderPropChild,\n TransactionResult as TxResult,\n WalletConnection,\n} from './types/index.js';\n\n// Version\nexport const VERSION = '1.0.0';\n","/*\n * Copyright 2025 Conflux DevKit Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * useBalance Hook\n *\n * Fetches and tracks balance for an address\n */\n\nimport type { ChainType } from '@cfxdevkit/core';\nimport { useCallback, useEffect, useState } from 'react';\nimport { useDevKitContext } from '../providers/DevKitProvider.js';\n\nexport interface UseBalanceOptions {\n address?: string;\n chain: ChainType;\n enabled?: boolean;\n refreshInterval?: number;\n}\n\nexport interface UseBalanceReturn {\n balance?: string;\n isLoading: boolean;\n error?: Error;\n refetch: () => Promise<void>;\n}\n\n/**\n * Hook to fetch and track address balance\n *\n * @example\n * ```tsx\n * const { balance, isLoading } = useBalance({\n * address: '0x...',\n * chain: 'evm'\n * });\n * ```\n */\nexport function useBalance(options: UseBalanceOptions): UseBalanceReturn {\n const { address, enabled = true, refreshInterval } = options;\n useDevKitContext(); // ensure provider is present; apiUrl and chain used in production impl\n\n const [balance, setBalance] = useState<string>();\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error>();\n\n const fetchBalance = useCallback(async () => {\n if (!address || !enabled) return;\n\n setIsLoading(true);\n setError(undefined);\n\n try {\n // In production, call backend API with `chain` to select Core vs eSpace\n // For now, simulate balance fetch\n const mockBalance = '1000000000000000000'; // 1 token\n setBalance(mockBalance);\n } catch (err) {\n setError(\n err instanceof Error ? err : new Error('Failed to fetch balance')\n );\n } finally {\n setIsLoading(false);\n }\n }, [address, enabled]);\n\n useEffect(() => {\n void fetchBalance();\n\n // Set up refresh interval if provided\n if (refreshInterval) {\n const interval = setInterval(() => {\n void fetchBalance();\n }, refreshInterval);\n return () => clearInterval(interval);\n }\n }, [fetchBalance, refreshInterval]);\n\n return {\n balance,\n isLoading,\n error,\n refetch: fetchBalance,\n };\n}\n","/*\n * Copyright 2025 Conflux DevKit Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * DevKit Provider\n *\n * Provides DevKit instance and configuration to all child components\n */\n\nimport { createContext, type ReactNode, useContext } from 'react';\n\nexport interface DevKitContextValue {\n /** Backend API URL */\n apiUrl: string;\n /** WebSocket URL */\n wsUrl?: string;\n /** Current network */\n network: 'local' | 'testnet' | 'mainnet';\n /** Enable debug mode */\n debug?: boolean;\n}\n\nconst DevKitContext = createContext<DevKitContextValue | undefined>(undefined);\n\nexport interface DevKitProviderProps {\n apiUrl: string;\n wsUrl?: string;\n network?: 'local' | 'testnet' | 'mainnet';\n debug?: boolean;\n children: ReactNode;\n}\n\n/**\n * DevKit Provider Component\n *\n * Wrap your app with this provider to enable DevKit functionality\n *\n * @example\n * ```tsx\n * <DevKitProvider apiUrl=\"http://localhost:3000\" network=\"local\">\n * <App />\n * </DevKitProvider>\n * ```\n */\nexport function DevKitProvider({\n apiUrl,\n wsUrl,\n network = 'local',\n debug = false,\n children,\n}: DevKitProviderProps) {\n const value: DevKitContextValue = {\n apiUrl,\n wsUrl,\n network,\n debug,\n };\n\n return (\n <DevKitContext.Provider value={value}>{children}</DevKitContext.Provider>\n );\n}\n\n/**\n * Hook to access DevKit context\n *\n * @throws Error if used outside DevKitProvider\n */\nexport function useDevKitContext() {\n const context = useContext(DevKitContext);\n if (!context) {\n throw new Error('useDevKitContext must be used within DevKitProvider');\n }\n return context;\n}\n","/*\n * Copyright 2025 Conflux DevKit Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Wallet Provider\n *\n * Manages wallet connection state and provides wallet-related functionality\n */\n\nimport type { ChainType } from '@cfxdevkit/core';\nimport { createContext, type ReactNode, useContext, useState } from 'react';\n\nexport interface WalletContextValue {\n isConnected: boolean;\n address?: string;\n coreAddress?: string;\n evmAddress?: string;\n chain?: ChainType;\n accountIndex?: number;\n connect: (accountIndex: number) => Promise<void>;\n disconnect: () => void;\n switchChain: (chain: ChainType) => void;\n}\n\nconst WalletContext = createContext<WalletContextValue | undefined>(undefined);\n\nexport interface WalletProviderProps {\n children: ReactNode;\n}\n\n/**\n * Wallet Provider Component\n *\n * Manages wallet connection state\n *\n * @example\n * ```tsx\n * <WalletProvider>\n * <ConnectButton />\n * <AccountCard />\n * </WalletProvider>\n * ```\n */\nexport function WalletProvider({ children }: WalletProviderProps) {\n const [isConnected, setIsConnected] = useState(false);\n const [coreAddress, setCoreAddress] = useState<string>();\n const [evmAddress, setEvmAddress] = useState<string>();\n const [chain, setChain] = useState<ChainType>('evm');\n const [accountIndex, setAccountIndex] = useState<number>();\n\n const connect = async (index: number) => {\n // In production, this would fetch account info from backend\n // For now, simulate connection\n setAccountIndex(index);\n setCoreAddress(`cfx:account${index}`);\n setEvmAddress(`0xaccount${index}`);\n setIsConnected(true);\n };\n\n const disconnect = () => {\n setIsConnected(false);\n setCoreAddress(undefined);\n setEvmAddress(undefined);\n setAccountIndex(undefined);\n };\n\n const switchChain = (newChain: ChainType) => {\n setChain(newChain);\n };\n\n const value: WalletContextValue = {\n isConnected,\n address: chain === 'core' ? coreAddress : evmAddress,\n coreAddress,\n evmAddress,\n chain,\n accountIndex,\n connect,\n disconnect,\n switchChain,\n };\n\n return (\n <WalletContext.Provider value={value}>{children}</WalletContext.Provider>\n );\n}\n\n/**\n * Hook to access Wallet context\n *\n * @throws Error if used outside WalletProvider\n */\nexport function useWalletContext() {\n const context = useContext(WalletContext);\n if (!context) {\n throw new Error('useWalletContext must be used within WalletProvider');\n }\n return context;\n}\n","/*\n * Copyright 2025 Conflux DevKit Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * AccountCard - Headless Account Display Component\n *\n * Displays account information with customizable rendering\n */\n\nimport type React from 'react';\nimport { useBalance } from '../../hooks/useBalance.js';\nimport { useWalletContext } from '../../providers/WalletProvider.js';\nimport type { BaseComponentProps, RenderPropChild } from '../../types/index.js';\n\nexport interface AccountCardRenderProps {\n isConnected: boolean;\n coreAddress?: string;\n evmAddress?: string;\n coreBalance?: string;\n evmBalance?: string;\n isLoadingBalance: boolean;\n}\n\nexport interface AccountCardProps extends BaseComponentProps {\n showBalance?: boolean;\n children?: RenderPropChild<AccountCardRenderProps> | React.ReactNode;\n}\n\n/**\n * AccountCard Component\n *\n * Headless account information display. Use render prop pattern for custom UI.\n *\n * @example\n * ```tsx\n * // With render prop\n * <AccountCard showBalance>\n * {({ coreAddress, evmAddress, coreBalance, evmBalance }) => (\n * <div>\n * <p>Core: {coreAddress}</p>\n * <p>EVM: {evmAddress}</p>\n * <p>Balance: {coreBalance}</p>\n * </div>\n * )}\n * </AccountCard>\n *\n * // With default styling\n * <AccountCard showBalance className=\"p-4 bg-gray-100 rounded\" />\n * ```\n */\nexport function AccountCard({\n showBalance = true,\n children,\n className,\n}: AccountCardProps) {\n const { isConnected, coreAddress, evmAddress } = useWalletContext();\n\n const { balance: coreBalance, isLoading: isLoadingCore } = useBalance({\n address: coreAddress,\n chain: 'core',\n enabled: showBalance && isConnected,\n });\n\n const { balance: evmBalance, isLoading: isLoadingEvm } = useBalance({\n address: evmAddress,\n chain: 'evm',\n enabled: showBalance && isConnected,\n });\n\n const renderProps: AccountCardRenderProps = {\n isConnected,\n coreAddress,\n evmAddress,\n coreBalance,\n evmBalance,\n isLoadingBalance: isLoadingCore || isLoadingEvm,\n };\n\n // If children is a function, use render prop pattern\n if (typeof children === 'function') {\n return <>{children(renderProps)}</>;\n }\n\n // If not connected, show nothing or custom children\n if (!isConnected) {\n return children ? <div className={className}>{children}</div> : null;\n }\n\n // Default rendering\n return (\n <div className={className || 'p-4 bg-gray-100 rounded-lg space-y-2'}>\n <div>\n <span className=\"font-semibold\">Core Space:</span>\n <span className=\"ml-2 font-mono text-sm\">{coreAddress}</span>\n {showBalance && (\n <span className=\"ml-2 text-gray-600\">\n {isLoadingCore ? 'Loading...' : `${coreBalance} CFX`}\n </span>\n )}\n </div>\n <div>\n <span className=\"font-semibold\">eSpace:</span>\n <span className=\"ml-2 font-mono text-sm\">{evmAddress}</span>\n {showBalance && (\n <span className=\"ml-2 text-gray-600\">\n {isLoadingEvm ? 'Loading...' : `${evmBalance} CFX`}\n </span>\n )}\n </div>\n </div>\n );\n}\n","/*\n * Copyright 2025 Conflux DevKit Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * ConnectButton - Headless Wallet Connection Component\n *\n * Provides wallet connection functionality with customizable rendering\n */\n\nimport React from 'react';\nimport { useWalletContext } from '../../providers/WalletProvider.js';\nimport type { BaseComponentProps, RenderPropChild } from '../../types/index.js';\n\nexport interface ConnectButtonRenderProps {\n isConnected: boolean;\n address?: string;\n connect: () => Promise<void>;\n disconnect: () => void;\n isLoading: boolean;\n}\n\nexport interface ConnectButtonProps extends BaseComponentProps {\n accountIndex?: number;\n onConnect?: () => void;\n onDisconnect?: () => void;\n children?: RenderPropChild<ConnectButtonRenderProps> | React.ReactNode;\n}\n\n/**\n * ConnectButton Component\n *\n * Headless wallet connection button. Use render prop pattern for custom UI.\n *\n * @example\n * ```tsx\n * // With render prop (full control)\n * <ConnectButton>\n * {({ isConnected, address, connect, disconnect }) => (\n * <button onClick={isConnected ? disconnect : connect}>\n * {isConnected ? `Connected: ${address}` : 'Connect Wallet'}\n * </button>\n * )}\n * </ConnectButton>\n *\n * // With default styling\n * <ConnectButton className=\"px-4 py-2 bg-blue-500 text-white rounded\" />\n * ```\n */\nexport function ConnectButton({\n accountIndex = 0,\n onConnect,\n onDisconnect,\n children,\n className,\n}: ConnectButtonProps) {\n const {\n isConnected,\n address,\n connect: contextConnect,\n disconnect: contextDisconnect,\n } = useWalletContext();\n const [isLoading, setIsLoading] = React.useState(false);\n\n const connect = async () => {\n setIsLoading(true);\n try {\n await contextConnect(accountIndex);\n onConnect?.();\n } catch (error) {\n console.error('Connection failed:', error);\n } finally {\n setIsLoading(false);\n }\n };\n\n const disconnect = () => {\n contextDisconnect();\n onDisconnect?.();\n };\n\n const renderProps: ConnectButtonRenderProps = {\n isConnected,\n address,\n connect,\n disconnect,\n isLoading,\n };\n\n // If children is a function, use render prop pattern\n if (typeof children === 'function') {\n return <>{children(renderProps)}</>;\n }\n\n // If children provided, wrap in default button\n if (children) {\n return (\n <button\n onClick={isConnected ? disconnect : connect}\n disabled={isLoading}\n className={className}\n type=\"button\"\n >\n {children}\n </button>\n );\n }\n\n // Default rendering with Tailwind classes\n return (\n <button\n onClick={isConnected ? disconnect : connect}\n disabled={isLoading}\n className={\n className ||\n 'px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50'\n }\n type=\"button\"\n >\n {isLoading\n ? 'Connecting...'\n : isConnected\n ? `Connected: ${address?.slice(0, 6)}...${address?.slice(-4)}`\n : 'Connect Wallet'}\n </button>\n );\n}\n","/*\n * Copyright 2025 Conflux DevKit Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * ContractReader - Headless Contract Read Component\n *\n * Reads data from smart contracts with customizable rendering\n */\n\nimport type { ChainType } from '@cfxdevkit/core';\nimport type React from 'react';\nimport { useState } from 'react';\nimport { useContract } from '../../hooks/useContract.js';\nimport type { BaseComponentProps, RenderPropChild } from '../../types/index.js';\n\nexport interface ContractReaderRenderProps<T = unknown> {\n read: (args?: unknown[]) => Promise<void>;\n result?: T;\n isLoading: boolean;\n error?: Error;\n}\n\nexport interface ContractReaderProps<T = unknown> extends BaseComponentProps {\n address: string;\n abi: unknown[];\n functionName: string;\n chain: ChainType;\n children?: RenderPropChild<ContractReaderRenderProps<T>> | React.ReactNode;\n}\n\n/**\n * ContractReader Component\n *\n * Headless contract read component. Use render prop for custom UI.\n *\n * @example\n * ```tsx\n * <ContractReader\n * address=\"0x...\"\n * abi={ERC20_ABI}\n * functionName=\"balanceOf\"\n * chain=\"evm\"\n * >\n * {({ read, result, isLoading }) => (\n * <div>\n * <button onClick={() => read(['0x...'])}>Get Balance</button>\n * {isLoading && <p>Loading...</p>}\n * {result && <p>Balance: {result}</p>}\n * </div>\n * )}\n * </ContractReader>\n * ```\n */\nexport function ContractReader<T = unknown>({\n address,\n abi,\n functionName,\n chain,\n children,\n className,\n}: ContractReaderProps<T>) {\n const { read: readContract, isLoading, error } = useContract();\n const [result, setResult] = useState<T>();\n\n const read = async (args?: unknown[]) => {\n const data = await readContract<T>({\n address,\n abi,\n functionName,\n args,\n chain,\n });\n setResult(data);\n };\n\n const renderProps: ContractReaderRenderProps<T> = {\n read,\n result,\n isLoading,\n error,\n };\n\n // If children is a function, use render prop pattern\n if (typeof children === 'function') {\n return <>{children(renderProps)}</>;\n }\n\n // Default rendering\n return (\n <div className={className || 'p-4 border rounded'}>\n <h3 className=\"font-semibold mb-2\">Read: {functionName}</h3>\n <button\n onClick={() => read()}\n disabled={isLoading}\n className=\"px-3 py-1 bg-blue-500 text-white rounded disabled:opacity-50\"\n type=\"button\"\n >\n {isLoading ? 'Reading...' : 'Read'}\n </button>\n {result && (\n <div className=\"mt-2\">\n <pre className=\"bg-gray-100 p-2 rounded text-sm\">\n {JSON.stringify(result, null, 2)}\n </pre>\n </div>\n )}\n {error && <p className=\"mt-2 text-red-500\">{error.message}</p>}\n {children}\n </div>\n );\n}\n","/*\n * Copyright 2025 Conflux DevKit Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * useContract Hook\n *\n * Interact with smart contracts (read and write)\n */\n\nimport type { ChainType } from '@cfxdevkit/core';\nimport { useState } from 'react';\nimport { useDevKitContext } from '../providers/DevKitProvider.js';\nimport { useWalletContext } from '../providers/WalletProvider.js';\n\nexport interface ReadContractOptions {\n address: string;\n abi: unknown[];\n functionName: string;\n args?: unknown[];\n chain: ChainType;\n}\n\nexport interface WriteContractOptions extends ReadContractOptions {\n value?: string;\n}\n\nexport interface UseContractReturn {\n read: <T = unknown>(options: ReadContractOptions) => Promise<T>;\n write: (options: WriteContractOptions) => Promise<string>;\n isLoading: boolean;\n error?: Error;\n}\n\n/**\n * Hook to interact with smart contracts\n *\n * @example\n * ```tsx\n * const { read, write, isLoading } = useContract();\n *\n * // Read contract\n * const balance = await read({\n * address: '0x...',\n * abi: ERC20_ABI,\n * functionName: 'balanceOf',\n * args: ['0x...'],\n * chain: 'evm'\n * });\n *\n * // Write contract\n * const hash = await write({\n * address: '0x...',\n * abi: ERC20_ABI,\n * functionName: 'transfer',\n * args: ['0x...', '1000000000000000000'],\n * chain: 'evm'\n * });\n * ```\n */\nexport function useContract(): UseContractReturn {\n useDevKitContext(); // ensure provider is present; apiUrl used in production impl\n const { accountIndex } = useWalletContext();\n\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error>();\n\n const read = async <T = unknown>(\n _options: ReadContractOptions\n ): Promise<T> => {\n setIsLoading(true);\n setError(undefined);\n\n try {\n // In production, call backend API\n // For now, return mock data\n return {} as T;\n } catch (err) {\n const errorObj =\n err instanceof Error ? err : new Error('Contract read failed');\n setError(errorObj);\n throw errorObj;\n } finally {\n setIsLoading(false);\n }\n };\n\n const write = async (_options: WriteContractOptions): Promise<string> => {\n if (accountIndex === undefined) {\n throw new Error('Wallet not connected');\n }\n\n setIsLoading(true);\n setError(undefined);\n\n try {\n // In production, call backend API\n // For now, return mock hash\n const hash = `0x${Array.from({ length: 64 }, () =>\n Math.floor(Math.random() * 16).toString(16)\n ).join('')}`;\n\n return hash;\n } catch (err) {\n const errorObj =\n err instanceof Error ? err : new Error('Contract write failed');\n setError(errorObj);\n throw errorObj;\n } finally {\n setIsLoading(false);\n }\n };\n\n return {\n read,\n write,\n isLoading,\n error,\n };\n}\n","/*\n * Copyright 2025 Conflux DevKit Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * ContractWriter - Headless Contract Write Component\n *\n * Writes to smart contracts with customizable rendering\n */\n\nimport type { ChainType } from '@cfxdevkit/core';\nimport type React from 'react';\nimport { useState } from 'react';\nimport { useContract } from '../../hooks/useContract.js';\nimport type { BaseComponentProps, RenderPropChild } from '../../types/index.js';\n\nexport interface ContractWriterRenderProps {\n write: (args?: unknown[], value?: string) => Promise<void>;\n hash?: string;\n isLoading: boolean;\n error?: Error;\n reset: () => void;\n}\n\nexport interface ContractWriterProps extends BaseComponentProps {\n address: string;\n abi: unknown[];\n functionName: string;\n chain: ChainType;\n onSuccess?: (hash: string) => void;\n children?: RenderPropChild<ContractWriterRenderProps> | React.ReactNode;\n}\n\n/**\n * ContractWriter Component\n *\n * Headless contract write component. Use render prop for custom UI.\n *\n * @example\n * ```tsx\n * <ContractWriter\n * address=\"0x...\"\n * abi={ERC20_ABI}\n * functionName=\"transfer\"\n * chain=\"evm\"\n * onSuccess={(hash) => console.log('Success:', hash)}\n * >\n * {({ write, hash, isLoading }) => (\n * <div>\n * <button onClick={() => write(['0x...', '1000000000000000000'])}>\n * Transfer\n * </button>\n * {isLoading && <p>Sending...</p>}\n * {hash && <p>TX: {hash}</p>}\n * </div>\n * )}\n * </ContractWriter>\n * ```\n */\nexport function ContractWriter({\n address,\n abi,\n functionName,\n chain,\n onSuccess,\n children,\n className,\n}: ContractWriterProps) {\n const { write: writeContract, isLoading, error } = useContract();\n const [hash, setHash] = useState<string>();\n\n const write = async (args?: unknown[], value?: string) => {\n const txHash = await writeContract({\n address,\n abi,\n functionName,\n args,\n chain,\n value,\n });\n setHash(txHash);\n onSuccess?.(txHash);\n };\n\n const reset = () => {\n setHash(undefined);\n };\n\n const renderProps: ContractWriterRenderProps = {\n write,\n hash,\n isLoading,\n error,\n reset,\n };\n\n // If children is a function, use render prop pattern\n if (typeof children === 'function') {\n return <>{children(renderProps)}</>;\n }\n\n // Default rendering\n return (\n <div className={className || 'p-4 border rounded'}>\n <h3 className=\"font-semibold mb-2\">Write: {functionName}</h3>\n <button\n onClick={() => write()}\n disabled={isLoading}\n className=\"px-3 py-1 bg-green-500 text-white rounded disabled:opacity-50\"\n type=\"button\"\n >\n {isLoading ? 'Sending...' : 'Execute'}\n </button>\n {hash && (\n <div className=\"mt-2\">\n <p className=\"text-sm text-gray-600\">Transaction Hash:</p>\n <p className=\"font-mono text-xs break-all\">{hash}</p>\n <button\n onClick={reset}\n className=\"mt-1 text-sm text-blue-500 hover:underline\"\n type=\"button\"\n >\n Reset\n </button>\n </div>\n )}\n {error && <p className=\"mt-2 text-red-500\">{error.message}</p>}\n {children}\n </div>\n );\n}\n","/*\n * Copyright 2025 Conflux DevKit Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * SwapWidget - Headless Swap Component (Swappi)\n *\n * Token swap interface with customizable rendering\n */\n\nimport type React from 'react';\nimport { useState } from 'react';\nimport { useDevKitContext } from '../../providers/DevKitProvider.js';\nimport { useWalletContext } from '../../providers/WalletProvider.js';\nimport type { BaseComponentProps, RenderPropChild } from '../../types/index.js';\n\nexport interface SwapQuote {\n amountIn: string;\n amountOut: string;\n amountOutMin: string;\n priceImpact: string;\n slippage: number;\n}\n\nexport interface SwapWidgetRenderProps {\n getQuote: (\n tokenIn: string,\n tokenOut: string,\n amountIn: string\n ) => Promise<void>;\n executeSwap: () => Promise<void>;\n quote?: SwapQuote;\n isLoadingQuote: boolean;\n isExecutingSwap: boolean;\n error?: Error;\n hash?: string;\n}\n\nexport interface SwapWidgetProps extends BaseComponentProps {\n defaultSlippage?: number;\n onSuccess?: (hash: string) => void;\n children?: RenderPropChild<SwapWidgetRenderProps> | React.ReactNode;\n}\n\n/**\n * SwapWidget Component\n *\n * Headless swap interface for Swappi DEX. Use render prop for custom UI.\n *\n * @example\n * ```tsx\n * <SwapWidget defaultSlippage={0.5}>\n * {({ getQuote, executeSwap, quote, isLoadingQuote }) => (\n * <div>\n * <button onClick={() => getQuote('WCFX', 'USDT', '1.0')}>\n * Get Quote\n * </button>\n * {quote && <p>You get: {quote.amountOut}</p>}\n * <button onClick={executeSwap} disabled={!quote}>\n * Swap\n * </button>\n * </div>\n * )}\n * </SwapWidget>\n * ```\n */\nexport function SwapWidget({\n defaultSlippage = 0.5,\n onSuccess,\n children,\n className,\n}: SwapWidgetProps) {\n useDevKitContext(); // ensure provider is present; apiUrl used in production impl\n const { isConnected, accountIndex } = useWalletContext();\n\n const [quote, setQuote] = useState<SwapQuote>();\n const [isLoadingQuote, setIsLoadingQuote] = useState(false);\n const [isExecutingSwap, setIsExecutingSwap] = useState(false);\n const [error, setError] = useState<Error>();\n const [hash, setHash] = useState<string>();\n\n const [currentQuoteParams, setCurrentQuoteParams] = useState<{\n tokenIn: string;\n tokenOut: string;\n amountIn: string;\n }>();\n\n const getQuote = async (\n tokenIn: string,\n tokenOut: string,\n amountIn: string\n ) => {\n if (!isConnected) {\n setError(new Error('Wallet not connected'));\n return;\n }\n\n setIsLoadingQuote(true);\n setError(undefined);\n\n try {\n // In production, call backend API to get quote from Swappi\n // For now, simulate quote\n const mockQuote: SwapQuote = {\n amountIn,\n amountOut: (parseFloat(amountIn) * 0.997).toString(), // 0.3% fee\n amountOutMin: (parseFloat(amountIn) * 0.997 * 0.995).toString(), // With slippage\n priceImpact: '0.3',\n slippage: defaultSlippage,\n };\n\n setQuote(mockQuote);\n setCurrentQuoteParams({ tokenIn, tokenOut, amountIn });\n } catch (err) {\n setError(err instanceof Error ? err : new Error('Failed to get quote'));\n } finally {\n setIsLoadingQuote(false);\n }\n };\n\n const executeSwap = async () => {\n if (\n !quote ||\n !currentQuoteParams ||\n !isConnected ||\n accountIndex === undefined\n ) {\n setError(new Error('Missing required data for swap'));\n return;\n }\n\n setIsExecutingSwap(true);\n setError(undefined);\n\n try {\n // In production, call backend API to execute swap on Swappi\n // For now, simulate swap\n const mockHash = `0x${Array.from({ length: 64 }, () =>\n Math.floor(Math.random() * 16).toString(16)\n ).join('')}`;\n\n setHash(mockHash);\n onSuccess?.(mockHash);\n } catch (err) {\n setError(err instanceof Error ? err : new Error('Swap failed'));\n } finally {\n setIsExecutingSwap(false);\n }\n };\n\n const renderProps: SwapWidgetRenderProps = {\n getQuote,\n executeSwap,\n quote,\n isLoadingQuote,\n isExecutingSwap,\n error,\n hash,\n };\n\n // If children is a function, use render prop pattern\n if (typeof children === 'function') {\n return <>{children(renderProps)}</>;\n }\n\n // Default rendering\n return (\n <div className={className || 'p-4 border rounded-lg'}>\n <h2 className=\"text-xl font-bold mb-4\">Swap (Swappi)</h2>\n\n {!isConnected && (\n <p className=\"text-gray-600\">Connect wallet to start swapping</p>\n )}\n\n {quote && (\n <div className=\"mt-4 p-3 bg-gray-100 rounded\">\n <p>Amount In: {quote.amountIn}</p>\n <p>Amount Out: {quote.amountOut}</p>\n <p>Min Amount: {quote.amountOutMin}</p>\n <p>Slippage: {quote.slippage}%</p>\n </div>\n )}\n\n {hash && (\n <div className=\"mt-4 p-3 bg-green-100 rounded\">\n <p className=\"text-sm font-semibold\">Swap Successful!</p>\n <p className=\"text-xs font-mono break-all\">{hash}</p>\n </div>\n )}\n\n {error && (\n <div className=\"mt-4 p-3 bg-red-100 rounded\">\n <p className=\"text-red-700\">{error.message}</p>\n </div>\n )}\n\n {children}\n </div>\n );\n}\n","/*\n * Copyright 2025 Conflux DevKit Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * useTransaction Hook\n *\n * Sends transactions and tracks their status\n */\n\nimport type { ChainType } from '@cfxdevkit/core';\nimport { useState } from 'react';\nimport { useDevKitContext } from '../providers/DevKitProvider.js';\nimport { useWalletContext } from '../providers/WalletProvider.js';\n\nexport interface SendTransactionOptions {\n to: string;\n value?: string;\n data?: string;\n chain?: ChainType;\n}\n\nexport interface TransactionResult {\n hash: string;\n status: 'pending' | 'success' | 'failed';\n}\n\nexport interface UseTransactionReturn {\n send: (options: SendTransactionOptions) => Promise<TransactionResult>;\n isLoading: boolean;\n error?: Error;\n transaction?: TransactionResult;\n reset: () => void;\n}\n\n/**\n * Hook to send transactions\n *\n * @example\n * ```tsx\n * const { send, isLoading, transaction } = useTransaction();\n *\n * const handleSend = async () => {\n * const result = await send({\n * to: '0x...',\n * value: '1000000000000000000',\n * chain: 'evm'\n * });\n * };\n * ```\n */\nexport function useTransaction(): UseTransactionReturn {\n useDevKitContext(); // ensure provider is present; apiUrl used in production impl\n const { accountIndex } = useWalletContext();\n\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error>();\n const [transaction, setTransaction] = useState<TransactionResult>();\n\n const send = async (\n _options: SendTransactionOptions\n ): Promise<TransactionResult> => {\n if (accountIndex === undefined) {\n throw new Error('Wallet not connected');\n }\n\n setIsLoading(true);\n setError(undefined);\n\n try {\n // In production, call backend API to send transaction\n // For now, simulate transaction\n const result: TransactionResult = {\n hash: `0x${Array.from({ length: 64 }, () =>\n Math.floor(Math.random() * 16).toString(16)\n ).join('')}`,\n status: 'pending',\n };\n\n setTransaction(result);\n\n // Simulate confirmation\n setTimeout(() => {\n setTransaction({ ...result, status: 'success' });\n }, 2000);\n\n return result;\n } catch (err) {\n const errorObj =\n err instanceof Error ? err : new Error('Transaction failed');\n setError(errorObj);\n throw errorObj;\n } finally {\n setIsLoading(false);\n }\n };\n\n const reset = () => {\n setTransaction(undefined);\n setError(undefined);\n };\n\n return {\n send,\n isLoading,\n error,\n transaction,\n reset,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACuBA,IAAAA,gBAAiD;;;ACDjD,mBAA0D;AAkDtD;AArCJ,IAAM,oBAAgB,4BAA8C,MAAS;AAsBtE,SAAS,eAAe;AAAA,EAC7B;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,QAAQ;AAAA,EACR;AACF,GAAwB;AACtB,QAAM,QAA4B;AAAA,IAChC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,SACE,4CAAC,cAAc,UAAd,EAAuB,OAAe,UAAS;AAEpD;AAOO,SAAS,mBAAmB;AACjC,QAAM,cAAU,yBAAW,aAAa;AACxC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AACA,SAAO;AACT;;;ADpCO,SAAS,WAAW,SAA8C;AACvE,QAAM,EAAE,SAAS,UAAU,MAAM,gBAAgB,IAAI;AACrD,mBAAiB;AAEjB,QAAM,CAAC,SAAS,UAAU,QAAI,wBAAiB;AAC/C,QAAM,CAAC,WAAW,YAAY,QAAI,wBAAS,KAAK;AAChD,QAAM,CAAC,OAAO,QAAQ,QAAI,wBAAgB;AAE1C,QAAM,mBAAe,2BAAY,YAAY;AAC3C,QAAI,CAAC,WAAW,CAAC,QAAS;AAE1B,iBAAa,IAAI;AACjB,aAAS,MAAS;AAElB,QAAI;AAGF,YAAM,cAAc;AACpB,iBAAW,WAAW;AAAA,IACxB,SAAS,KAAK;AACZ;AAAA,QACE,eAAe,QAAQ,MAAM,IAAI,MAAM,yBAAyB;AAAA,MAClE;AAAA,IACF,UAAE;AACA,mBAAa,KAAK;AAAA,IACpB;AAAA,EACF,GA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;AAEA,iBAAa,IAAI;AACjB,aAAS,MAAS;AAElB,QAAI;AAGF,YAAM,SAA4B;AAAA,QAChC,MAAM,KAAK,MAAM;AAAA,UAAK,EAAE,QAAQ,GAAG;AAAA,UAAG,MACpC,KAAK,MAAM,KAAK,OAAO,IAAI,EAAE,EAAE,SAAS,EAAE;AAAA,QAC5C,EAAE,KAAK,EAAE,CAAC;AAAA,QACV,QAAQ;AAAA,MACV;AAEA,qBAAe,MAAM;AAGrB,iBAAW,MAAM;AACf,uBAAe,EAAE,GAAG,QAAQ,QAAQ,UAAU,CAAC;AAAA,MACjD,GAAG,GAAI;AAEP,aAAO;AAAA,IACT,SAAS,KAAK;AACZ,YAAM,WACJ,eAAe,QAAQ,MAAM,IAAI,MAAM,oBAAoB;AAC7D,eAAS,QAAQ;AACjB,YAAM;AAAA,IACR,UAAE;AACA,mBAAa,KAAK;AAAA,IACpB;AAAA,EACF;AAEA,QAAM,QAAQ,MAAM;AAClB,mBAAe,MAAS;AACxB,aAAS,MAAS;AAAA,EACpB;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;;;AV1BO,IAAM,UAAU;","names":["import_react","import_react","import_jsx_runtime","import_jsx_runtime","import_react","import_jsx_runtime","React","import_react","import_react","import_jsx_runtime","import_react","import_jsx_runtime","import_react","import_jsx_runtime","import_react"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { A as AccountCard, a as AccountCardProps, b as AccountCardRenderProps, B as BaseComponentProps, C as ConnectButton, c as ConnectButtonProps, d as ConnectButtonRenderProps, e as ContractDeployment, f as ContractReader, g as ContractReaderProps, h as ContractReaderRenderProps, i as ContractWriter, j as ContractWriterProps, k as ContractWriterRenderProps, N as NetworkInfo, R as RenderPropChild, S as SwapQuote, l as SwapWidget, m as SwapWidgetProps, n as SwapWidgetRenderProps, T as TxResult, W as WalletConnection } from './index-CU9Acwhq.cjs';
|
|
2
|
+
export { ReadContractOptions, SendTransactionOptions, TransactionResult, UseBalanceOptions, UseBalanceReturn, UseContractReturn, UseTransactionReturn, WriteContractOptions, useBalance, useContract, useTransaction } from './hooks/index.cjs';
|
|
3
|
+
export { DevKitContextValue, DevKitProvider, DevKitProviderProps, WalletContextValue, WalletProvider, WalletProviderProps, useDevKitContext, useWalletContext } from './providers/index.cjs';
|
|
4
|
+
import 'react/jsx-runtime';
|
|
5
|
+
import 'react';
|
|
6
|
+
import '@cfxdevkit/core';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Conflux DevKit UI Headless - Customizable React Components
|
|
10
|
+
*
|
|
11
|
+
* This package provides headless React components for Conflux applications.
|
|
12
|
+
* Components use the render prop pattern for maximum customization while
|
|
13
|
+
* also providing default Tailwind-based styling.
|
|
14
|
+
*
|
|
15
|
+
* Features:
|
|
16
|
+
* - Headless components with render props
|
|
17
|
+
* - Default Tailwind styling
|
|
18
|
+
* - React hooks for blockchain operations
|
|
19
|
+
* - Context providers for state management
|
|
20
|
+
* - Full TypeScript support
|
|
21
|
+
*
|
|
22
|
+
* @packageDocumentation
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
declare const VERSION = "1.0.0";
|
|
26
|
+
|
|
27
|
+
export { VERSION };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { A as AccountCard, a as AccountCardProps, b as AccountCardRenderProps, B as BaseComponentProps, C as ConnectButton, c as ConnectButtonProps, d as ConnectButtonRenderProps, e as ContractDeployment, f as ContractReader, g as ContractReaderProps, h as ContractReaderRenderProps, i as ContractWriter, j as ContractWriterProps, k as ContractWriterRenderProps, N as NetworkInfo, R as RenderPropChild, S as SwapQuote, l as SwapWidget, m as SwapWidgetProps, n as SwapWidgetRenderProps, T as TxResult, W as WalletConnection } from './index-CU9Acwhq.js';
|
|
2
|
+
export { ReadContractOptions, SendTransactionOptions, TransactionResult, UseBalanceOptions, UseBalanceReturn, UseContractReturn, UseTransactionReturn, WriteContractOptions, useBalance, useContract, useTransaction } from './hooks/index.js';
|
|
3
|
+
export { DevKitContextValue, DevKitProvider, DevKitProviderProps, WalletContextValue, WalletProvider, WalletProviderProps, useDevKitContext, useWalletContext } from './providers/index.js';
|
|
4
|
+
import 'react/jsx-runtime';
|
|
5
|
+
import 'react';
|
|
6
|
+
import '@cfxdevkit/core';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Conflux DevKit UI Headless - Customizable React Components
|
|
10
|
+
*
|
|
11
|
+
* This package provides headless React components for Conflux applications.
|
|
12
|
+
* Components use the render prop pattern for maximum customization while
|
|
13
|
+
* also providing default Tailwind-based styling.
|
|
14
|
+
*
|
|
15
|
+
* Features:
|
|
16
|
+
* - Headless components with render props
|
|
17
|
+
* - Default Tailwind styling
|
|
18
|
+
* - React hooks for blockchain operations
|
|
19
|
+
* - Context providers for state management
|
|
20
|
+
* - Full TypeScript support
|
|
21
|
+
*
|
|
22
|
+
* @packageDocumentation
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
declare const VERSION = "1.0.0";
|
|
26
|
+
|
|
27
|
+
export { VERSION };
|