File tree Expand file tree Collapse file tree 3 files changed +30
-10
lines changed Expand file tree Collapse file tree 3 files changed +30
-10
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,9 @@ export function sendTransactionAndWait(
3838 walletClient : WalletClient ,
3939 request : TransactionRequest ,
4040) : ResultAsync < TxHash , SigningError > {
41+ // TODO: verify it's on the correct chain, ask to switch if possible
42+ // TODO: verify if wallet account is correct, switch if possible
43+
4144 return ResultAsync . fromPromise (
4245 sendTransaction ( walletClient , request ) ,
4346 ( err ) => SigningError . from ( err ) ,
Original file line number Diff line number Diff line change @@ -119,12 +119,10 @@ const AsyncTaskState = {
119119 * return <p>Task completed: {data}</p>;
120120 * ```
121121 */
122- export type UseAsyncTask < TInput , TValue , TError > = AsyncTaskState <
123- TValue ,
124- TError
125- > & {
126- execute : AsyncTask < TInput , ResultAsync < TValue , TError > > ;
127- } ;
122+ export type UseAsyncTask < TInput , TValue , TError > = [
123+ AsyncTask < TInput , ResultAsync < TValue , TError > > ,
124+ AsyncTaskState < TValue , TError > ,
125+ ] ;
128126
129127/**
130128 * @internal
@@ -165,8 +163,5 @@ export function useAsyncTask<
165163 [ handler , state ] ,
166164 ) ;
167165
168- return {
169- ...state ,
170- execute,
171- } ;
166+ return [ execute , state ] ;
172167}
Original file line number Diff line number Diff line change 1+ import type { UnexpectedError } from '@aave/client' ;
2+ import type { ExecutionPlan , SupplyRequest } from '@aave/graphql' ;
3+ import { supply } from '../../client/src/actions' ;
4+ import { useAaveClient } from './context' ;
5+ import { type UseAsyncTask , useAsyncTask } from './helpers' ;
6+
7+ /**
8+ * A hook that provides a way to supply assets to an Aave market.
9+ *
10+ * ```ts
11+ * const [supply, { loading, error, data }] = useSupply();
12+ * ```
13+ */
14+ export function useSupply ( ) : UseAsyncTask <
15+ SupplyRequest ,
16+ ExecutionPlan ,
17+ UnexpectedError
18+ > {
19+ const client = useAaveClient ( ) ;
20+
21+ return useAsyncTask ( ( request : SupplyRequest ) => supply ( client , request ) ) ;
22+ }
You can’t perform that action at this time.
0 commit comments