Commit 6ec31b69 authored by tom's avatar tom

clean up

parent d181a186
import type { Abi } from 'abitype';
// import type { ArrayElement } from 'types/utils';
export type SmartContractMethodArgType = 'address' | 'uint256' | 'bool' | 'string' | 'bytes' | 'bytes32';
export type SmartContractMethodStateMutability = 'view' | 'nonpayable' | 'payable';
......@@ -82,19 +80,15 @@ export interface SmartContractWriteReceive {
}
export type SmartContractWriteMethod = SmartContractMethodBase | SmartContractWriteFallback | SmartContractWriteReceive;
// export type SmartContractWriteMethod = ArrayElement<Abi> & {name?: string};
// export type SmartContractReadMethod = ArrayElement<Abi> & {name?: string};
export type SmartContractMethod = SmartContractReadMethod | SmartContractWriteMethod;
// export type SmartContractMethodInput = ArrayElement<Abi> & {name?: string};
export interface SmartContractMethodInput {
internalType?: SmartContractMethodArgType;
name: string;
type: SmartContractMethodArgType;
}
// export type SmartContractMethodOutput = ArrayElement<Abi> & {name?: string};
export interface SmartContractMethodOutput extends SmartContractMethodInput {
value?: string;
}
......
......@@ -7,7 +7,6 @@ import { useForm } from 'react-hook-form';
import type { MethodFormFields, ContractMethodCallResult } from './types';
import type { SmartContractMethodInput, SmartContractMethod } from 'types/api/contract';
import appConfig from 'configs/app/config';
import arrowIcon from 'icons/arrows/down-right.svg';
import ContractMethodField from './ContractMethodField';
......@@ -67,14 +66,13 @@ const ContractMethodCallable = <T extends SmartContractMethod>({ data, onSubmit,
const [ result, setResult ] = React.useState<ContractMethodCallResult<T>>();
const [ isLoading, setLoading ] = React.useState(false);
const inputs = React.useMemo(() => {
const inputs: Array<SmartContractMethodInput> = React.useMemo(() => {
return [
// eslint-disable-next-line @typescript-eslint/no-explicit-any
...('inputs' in data ? data.inputs as Array<any> : []), // todo_tom fix type
...('inputs' in data ? data.inputs : []),
...('stateMutability' in data && data.stateMutability === 'payable' ? [ {
name: 'value',
type: appConfig.network.currency.symbol,
internalType: appConfig.network.currency.symbol,
type: 'uint256' as const,
internalType: 'uint256' as const,
} ] : []),
];
}, [ data ]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment