|
| 1 | +import { type AssetSelector, LiquidityModal, Tabs } from '@leapwallet/elements'; |
| 2 | +import { useElementsWalletClient } from '../utils'; |
| 3 | +import { useAgoric } from '../hooks'; |
| 4 | +import { Ist } from '../icons/Ist'; |
| 5 | +import { Button } from '@interchain-ui/react'; |
| 6 | + |
| 7 | +import '@leapwallet/elements/styles.css'; |
| 8 | + |
| 9 | +const agoricChainId = 'agoric-3'; |
| 10 | +const istSelector: AssetSelector = ['symbol', 'IST']; |
| 11 | +const bldSelector: AssetSelector = ['symbol', 'BLD']; |
| 12 | + |
| 13 | +export const OnboardIstModal = () => { |
| 14 | + const { address } = useAgoric(); |
| 15 | + const elementsWalletClient = useElementsWalletClient(); |
| 16 | + |
| 17 | + const renderLiquidityButton = ({ onClick }: { onClick: () => void }) => { |
| 18 | + return ( |
| 19 | + <Button onClick={onClick} leftIcon="walletFilled"> |
| 20 | + Deposit IST |
| 21 | + </Button> |
| 22 | + ); |
| 23 | + }; |
| 24 | + |
| 25 | + return ( |
| 26 | + <LiquidityModal |
| 27 | + renderLiquidityButton={renderLiquidityButton} |
| 28 | + theme="light" |
| 29 | + walletClientConfig={{ |
| 30 | + userAddress: address, |
| 31 | + walletClient: elementsWalletClient, |
| 32 | + connectWallet: (chainId?: string) => { |
| 33 | + return elementsWalletClient.enable(chainId ?? []); |
| 34 | + }, |
| 35 | + }} |
| 36 | + defaultActiveTab={Tabs.SWAP} |
| 37 | + config={{ |
| 38 | + icon: Ist, |
| 39 | + title: 'Deposit IST', |
| 40 | + subtitle: '', |
| 41 | + tabsConfig: { |
| 42 | + [Tabs.BRIDGE_USDC]: { |
| 43 | + enabled: false, |
| 44 | + }, |
| 45 | + [Tabs.FIAT_ON_RAMP]: { |
| 46 | + enabled: false, |
| 47 | + }, |
| 48 | + [Tabs.CROSS_CHAIN_SWAPS]: { |
| 49 | + enabled: true, |
| 50 | + defaults: { |
| 51 | + destinationChainId: agoricChainId, |
| 52 | + destinationAssetSelector: istSelector, |
| 53 | + }, |
| 54 | + }, |
| 55 | + [Tabs.SWAP]: { |
| 56 | + enabled: true, |
| 57 | + defaults: { |
| 58 | + sourceChainId: agoricChainId, |
| 59 | + sourceAssetSelector: bldSelector, |
| 60 | + destinationChainId: agoricChainId, |
| 61 | + destinationAssetSelector: istSelector, |
| 62 | + }, |
| 63 | + }, |
| 64 | + [Tabs.TRANSFER]: { |
| 65 | + enabled: true, |
| 66 | + defaults: { |
| 67 | + destinationChainId: agoricChainId, |
| 68 | + sourceChainId: agoricChainId, |
| 69 | + sourceAssetSelector: istSelector, |
| 70 | + }, |
| 71 | + }, |
| 72 | + }, |
| 73 | + }} |
| 74 | + /> |
| 75 | + ); |
| 76 | +}; |
0 commit comments