import { Env } from '@lombard.finance/sdk-common'; import type { Meta, StoryObj } from '@storybook/react'; import { Button, ErrorDisplay, ResultDisplay } from '../stories/components'; import { functionType } from '../stories/decorators/function-type'; import useQuery from '../stories/hooks/useQuery'; import { getOftAmountCanBeSent } from './getOftAmountCanBeSent'; interface GetOftAmountStoryArgs { env: Env; destinationEid: number; } export const StoryView = ({ env, destinationEid }: GetOftAmountStoryArgs) => { const request = async () => { if (!destinationEid) throw new Error('Destination EID is required.'); try { const amount = await getOftAmountCanBeSent({ env, destinationLzEndpointId: destinationEid, }); return amount.toString(); } catch (err) { console.error('Fetch Amount Error:', err); throw err; } }; const { data: result, error, isLoading, refetch: handleFetch, } = useQuery(request, [env, destinationEid], false); return ( <>
{result !== null && result !== undefined && ( )} {error && } ); }; const meta: Meta = { title: 'read/getOftAmountCanBeSent', component: StoryView, tags: ['autodocs'], decorators: [functionType('read')], parameters: { docs: { description: { component: 'Fetches the rate-limited amount of OFT (like LBTC) that can be sent from Solana using `getOftAmountCanBeSent`.', }, }, }, argTypes: { env: { control: 'select', options: Object.values(Env), }, destinationEid: { control: 'number', name: 'Destination EID', }, }, args: { env: Env.prod, destinationEid: 30101, }, }; export default meta; type Story = StoryObj;