// Copyright 2017-2023 @polkadot/react-components authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { SubmittableExtrinsicFunction } from '@polkadot/api/types'; import type { DropdownOptions } from '../util/types'; import React, { useCallback } from 'react'; import { ApiPromise } from '@polkadot/api'; import Dropdown from '../Dropdown'; interface Props { api: ApiPromise; className?: string; defaultValue?: string; isDisabled?: boolean; isError?: boolean; onChange?: (value: SubmittableExtrinsicFunction<'promise'>) => void; options: DropdownOptions; value: SubmittableExtrinsicFunction<'promise'>; } function SelectMethod ({ api, className = '', defaultValue, isDisabled, isError, onChange, options, value }: Props): React.ReactElement | null { const transform = useCallback( (method: string): SubmittableExtrinsicFunction<'promise'> => api.tx[value.section][method], [api, value] ); if (!options.length) { return null; } return ( ); } export default React.memo(SelectMethod);