Commit 2feeaa51 authored by tom's avatar tom

custom methods

parent d3785d84
......@@ -27,7 +27,7 @@ const ContractMethodField = ({ control, name, placeholder, setValue, isDisabled,
const renderInput = React.useCallback(({ field }: { field: ControllerRenderProps<MethodFormFields> }) => {
return (
<FormControl id={ name } minW={{ base: '100%', lg: 'calc((100% - 24px) / 3 - 65px)' }} w="auto" flexGrow={ 1 } isDisabled={ isDisabled }>
<FormControl id={ name } flexBasis={{ base: '100%', lg: 'calc((100% - 24px) / 3 - 65px)' }} w="auto" flexGrow={ 1 } isDisabled={ isDisabled }>
<InputGroup size="xs">
<Input
{ ...field }
......
......@@ -19,9 +19,10 @@ import ContractReadResult from './ContractReadResult';
interface Props {
isProxy?: boolean;
isCustomAbi?: boolean;
}
const ContractRead = ({ isProxy }: Props) => {
const ContractRead = ({ isProxy, isCustomAbi }: Props) => {
const router = useRouter();
const apiFetch = useApiFetch();
const { address: userAddress } = useAccount();
......@@ -30,6 +31,9 @@ const ContractRead = ({ isProxy }: Props) => {
const { data, isLoading, isError } = useApiQuery(isProxy ? 'contract_methods_read_proxy' : 'contract_methods_read', {
pathParams: { id: addressHash },
queryParams: {
is_custom_abi: isCustomAbi ? 'true' : 'false',
},
queryOptions: {
enabled: Boolean(router.query.id),
},
......
......@@ -20,9 +20,10 @@ import { getNativeCoinValue, isExtendedError } from './utils';
interface Props {
isProxy?: boolean;
isCustomAbi?: boolean;
}
const ContractWrite = ({ isProxy }: Props) => {
const ContractWrite = ({ isProxy, isCustomAbi }: Props) => {
const router = useRouter();
const addressHash = router.query.id?.toString();
......@@ -31,6 +32,9 @@ const ContractWrite = ({ isProxy }: Props) => {
const { data, isLoading, isError } = useApiQuery(isProxy ? 'contract_methods_write_proxy' : 'contract_methods_write', {
pathParams: { id: addressHash },
queryParams: {
is_custom_abi: isCustomAbi ? 'true' : 'false',
},
queryOptions: {
enabled: Boolean(addressHash),
},
......
......@@ -53,9 +53,10 @@ const AddressPageContent = () => {
const contractTabs = React.useMemo(() => {
return [
{ id: 'contact_code', title: 'Code', component: <ContractCode/> },
addressQuery.data?.has_decompiled_code ?
{ id: 'contact_decompiled_code', title: 'Decompiled code', component: <div>Decompiled code</div> } :
undefined,
// this is not implemented in api yet
// addressQuery.data?.has_decompiled_code ?
// { id: 'contact_decompiled_code', title: 'Decompiled code', component: <div>Decompiled code</div> } :
// undefined,
addressQuery.data?.has_methods_read ?
{ id: 'read_contract', title: 'Read contract', component: <ContractRead/> } :
undefined,
......@@ -63,7 +64,7 @@ const AddressPageContent = () => {
{ id: 'read_proxy', title: 'Read proxy', component: <ContractRead isProxy/> } :
undefined,
addressQuery.data?.has_custom_methods_read ?
{ id: 'read_custom_methods', title: 'Read custom methods', component: <div>Read custom methods</div> } :
{ id: 'read_custom_methods', title: 'Read custom methods', component: <ContractRead isCustomAbi/> } :
undefined,
addressQuery.data?.has_methods_write ?
{ id: 'write_contract', title: 'Write contract', component: <ContractWrite/> } :
......@@ -72,7 +73,7 @@ const AddressPageContent = () => {
{ id: 'write_proxy', title: 'Write proxy', component: <ContractWrite isProxy/> } :
undefined,
addressQuery.data?.has_custom_methods_write ?
{ id: 'write_custom_methods', title: 'Write custom methods', component: <div>Write custom methods</div> } :
{ id: 'write_custom_methods', title: 'Write custom methods', component: <ContractWrite isCustomAbi/> } :
undefined,
].filter(notEmpty);
}, [ addressQuery.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