OneChainSelector
OneChainSelector 组件渲染支持的区块链网络列表,允许用户为其 AI 交易订单选择一条链。它显示链的 logo、名称和网络类型,并根据策略支持的链进行筛选。
仅限 React Native
OneChainSelector 从 @one_deploy/sdk 的 React Native 入口导出,不适用于 Web。
快速开始
import { useState } from 'react';
import { OneChainSelector } from '@one_deploy/sdk';
function ChainStep() {
const [chainId, setChainId] = useState<number | null>(null);
return (
<OneChainSelector
supportedChains={[8453, 1, 137, 42161]}
onSelect={(id) => {
setChainId(id);
console.log('Selected chain:', id);
}}
/>
);
}
OneChainSelectorProps
interface OneChainSelectorProps {
/** Array of chain IDs the strategy supports. Only these chains are shown. */
supportedChains: number[];
/** Currently selected chain ID. */
selectedChainId?: number;
/** Callback fired when the user selects a chain. */
onSelect: (chainId: number) => void;
/** Whether to show the network type label (Mainnet/Testnet). Defaults to true. */
showNetworkType?: boolean;
/** Whether to show chain logos. Defaults to true. */
showLogos?: boolean;
/** Override chain display data. Merged with CHAIN_CONFIG. */
chainConfig?: Partial<Record<number, ChainDisplayConfig>>;
/** Additional style applied to the container. */
style?: ViewStyle;
/** Style applied to each chain item. */
itemStyle?: ViewStyle;
/** Style applied to the selected chain item. */
selectedItemStyle?: ViewStyle;
/** Test ID for testing frameworks. */
testID?: string;
}
属性表
| 属性 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
supportedChains | number[] | 是 | -- | 要显示的链 ID |
selectedChainId | number | 否 | -- |