UNPKG

@orderly.network/react-app

Version:

Create React App with Orderly Network components

82 lines (73 loc) 2.84 kB
import * as react_jsx_runtime from 'react/jsx-runtime'; import { ReactNode, ComponentType, PropsWithChildren } from 'react'; import { ConfigProviderProps, ExclusiveConfigProviderProps, WalletState, Chains, RestrictedInfoOptions, RestrictedInfoReturns } from '@orderly.network/hooks'; import { ExtensionPosition } from '@orderly.network/ui'; import { AccountStatusEnum, Chain, NetworkId } from '@orderly.network/types'; import { OrderlyThemeProviderProps } from '@orderly.network/ui/src/provider/orderlyThemeProvider'; type Logo = { img?: string; component?: ReactNode; className?: string; }; type AppLogos = Partial<{ main: Logo; secondary: Logo; }>; type OrderlyAppConfig = { appIcons?: AppLogos; dateFormatting?: string; components?: { [position in ExtensionPosition]: ComponentType; }; } & Partial<Omit<ConfigProviderProps, "brokerId" | "brokerName" | "configStore" | "networkId">> & ExclusiveConfigProviderProps; declare const useWalletStateHandle: (options: { currentChainId?: number; }) => { connectWallet: () => Promise<{ wallet?: WalletState; status?: AccountStatusEnum; wrongNetwork?: boolean; } | null>; wrongNetwork: boolean; }; type ReturnChain = Pick<Chain, "id"> & Partial<Omit<Chain, "id">>; type DefaultChain = { mainnet?: ReturnChain; testnet?: ReturnChain; } | ((networkId: NetworkId, chains: Chains) => ReturnChain) | undefined; type AppContextState = { connectWallet: ReturnType<typeof useWalletStateHandle>["connectWallet"]; /** * Whether the current network is not supported */ wrongNetwork: boolean; disabledConnect: boolean; currentChainId: number | undefined; setCurrentChainId: (chainId: number | undefined) => void; onChainChanged?: (chainId: number, state: { isTestnet: boolean; isWalletConnected: boolean; }) => void; restrictedInfo: RestrictedInfoReturns; }; declare const useAppContext: () => AppContextState; type AppStateProviderProps = { defaultChain?: DefaultChain; restrictedInfo?: RestrictedInfoOptions; } & Pick<AppContextState, "onChainChanged">; type OrderlyAppProviderProps = PropsWithChildren<OrderlyAppConfig & AppStateProviderProps & OrderlyThemeProviderProps>; declare const OrderlyAppProvider: { (props: OrderlyAppProviderProps): react_jsx_runtime.JSX.Element; displayName: string; }; type ThemeContextState = { appIcons?: AppLogos; brokerName: string; }; declare const useAppConfig: () => ThemeContextState; declare const useDataTap: <T = any>(data: T, options?: { skip?: false; fallbackData?: T; accountStatus?: AccountStatusEnum; }) => T | null; export { type AppLogos, type AppStateProviderProps, OrderlyAppProvider, type OrderlyAppProviderProps, useAppConfig, useAppContext, useDataTap };