Commit 98aced4d authored by tom's avatar tom

fix contract read issues

parent bc44650f
...@@ -35,6 +35,7 @@ const ContractRead = ({ isProxy, isCustomAbi }: Props) => { ...@@ -35,6 +35,7 @@ const ContractRead = ({ isProxy, isCustomAbi }: Props) => {
pathParams: { hash: addressHash }, pathParams: { hash: addressHash },
queryParams: { queryParams: {
is_custom_abi: isCustomAbi ? 'true' : 'false', is_custom_abi: isCustomAbi ? 'true' : 'false',
from: userAddress,
}, },
queryOptions: { queryOptions: {
enabled: Boolean(addressHash), enabled: Boolean(addressHash),
...@@ -44,6 +45,9 @@ const ContractRead = ({ isProxy, isCustomAbi }: Props) => { ...@@ -44,6 +45,9 @@ const ContractRead = ({ isProxy, isCustomAbi }: Props) => {
const handleMethodFormSubmit = React.useCallback(async(item: SmartContractReadMethod, args: Array<string | Array<string>>) => { const handleMethodFormSubmit = React.useCallback(async(item: SmartContractReadMethod, args: Array<string | Array<string>>) => {
return apiFetch<'contract_method_query', SmartContractQueryMethodRead>('contract_method_query', { return apiFetch<'contract_method_query', SmartContractQueryMethodRead>('contract_method_query', {
pathParams: { hash: addressHash }, pathParams: { hash: addressHash },
queryParams: {
is_custom_abi: isCustomAbi ? 'true' : 'false',
},
fetchParams: { fetchParams: {
method: 'POST', method: 'POST',
body: { body: {
...@@ -54,11 +58,11 @@ const ContractRead = ({ isProxy, isCustomAbi }: Props) => { ...@@ -54,11 +58,11 @@ const ContractRead = ({ isProxy, isCustomAbi }: Props) => {
}, },
}, },
}); });
}, [ addressHash, apiFetch, isProxy, userAddress ]); }, [ addressHash, apiFetch, isCustomAbi, isProxy, userAddress ]);
const renderContent = React.useCallback((item: SmartContractReadMethod, index: number, id: number) => { const renderContent = React.useCallback((item: SmartContractReadMethod, index: number, id: number) => {
if (item.error) { if (item.error) {
return <Alert status="error" fontSize="sm">{ item.error }</Alert>; return <Alert status="error" fontSize="sm" wordBreak="break-word">{ item.error }</Alert>;
} }
if (item.outputs.some(({ value }) => value)) { if (item.outputs.some(({ value }) => value)) {
......
...@@ -18,12 +18,12 @@ const ContractReadResult = ({ item, result, onSettle }: Props) => { ...@@ -18,12 +18,12 @@ const ContractReadResult = ({ item, result, onSettle }: Props) => {
}, [ onSettle ]); }, [ onSettle ]);
if ('status' in result) { if ('status' in result) {
return <Alert status="error" mt={ 3 } p={ 4 } borderRadius="md" fontSize="sm">{ result.statusText }</Alert>; return <Alert status="error" mt={ 3 } p={ 4 } borderRadius="md" fontSize="sm" wordBreak="break-word">{ result.statusText }</Alert>;
} }
if (result.is_error) { if (result.is_error) {
const message = 'error' in result.result ? result.result.error : result.result.message; const message = 'error' in result.result ? result.result.error : result.result.message;
return <Alert status="error" mt={ 3 } p={ 4 } borderRadius="md" fontSize="sm">{ message }</Alert>; return <Alert status="error" mt={ 3 } p={ 4 } borderRadius="md" fontSize="sm" wordBreak="break-word">{ message }</Alert>;
} }
return ( return (
......
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