diff --git a/examples/next/src/hooks/useApi.tsx b/examples/next/src/hooks/useApi.tsx index 4f8f63e8..218deb2d 100644 --- a/examples/next/src/hooks/useApi.tsx +++ b/examples/next/src/hooks/useApi.tsx @@ -10,7 +10,11 @@ export const useApi = () => { const handleLoadApi = useCallback(async () => setApi(await activate(config)), []) const handleQuery = useCallback( - async (query: any, setValue: (value: any) => void, setErrorForm?: (error: any) => void) => { + async ( + query: () => any, + setValue: (value: any) => void, + setErrorForm?: (error: any) => void, + ) => { setErrorForm && setErrorForm('') try { if (!api) { @@ -24,6 +28,8 @@ export const useApi = () => { } setValue(query) + + return query } catch (error) { setErrorForm && setErrorForm((error as any).message) } diff --git a/examples/next/src/hooks/useTx.tsx b/examples/next/src/hooks/useTx.tsx index 26df401e..aebf6714 100644 --- a/examples/next/src/hooks/useTx.tsx +++ b/examples/next/src/hooks/useTx.tsx @@ -1,5 +1,7 @@ import { useApi } from '@/hooks/useApi' import { useWallets } from '@/hooks/useWallet' +import type { SubmittableExtrinsic } from '@polkadot/api/types' +import type { ISubmittableResult } from '@polkadot/types/types' import { useCallback, useState } from 'react' export const useTx = () => { @@ -8,7 +10,7 @@ export const useTx = () => { const [txHash, setTxHash] = useState('') const handleTx = useCallback( - async (tx: any, setErrorForm: any) => { + async (tx: SubmittableExtrinsic<'promise', ISubmittableResult>, setErrorForm: any) => { try { if (!selectedWallet) { setErrorForm('Wallet not selected') @@ -19,7 +21,7 @@ export const useTx = () => { if (result.status.isInBlock) console.log('Successful tx') else if (result.status.isFinalized) console.log('Finalized tx') }), - (v) => setTxHash(v.hash.toString()), + () => setTxHash(tx.hash.toString()), setErrorForm, ) } catch (error) {