Commit 6ec31b69 authored by tom's avatar tom

clean up

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