|
1 | | -import { |
2 | | - type SolutionResponse, |
3 | | - Sprinter, |
4 | | -} from "@chainsafe/sprinter-sdk"; |
5 | | -import {useCallback} from "react"; |
6 | | -import {useAsyncRequest} from "./useAsyncRequest"; |
7 | | -import type {Infer} from "superstruct"; |
| 1 | +import { type SolutionResponse, Sprinter } from "@chainsafe/sprinter-sdk"; |
| 2 | +import { useCallback } from "react"; |
| 3 | +import { useAsyncRequest } from "./useAsyncRequest"; |
| 4 | +import type { Infer } from "superstruct"; |
8 | 5 | import { |
9 | 6 | MultiHopSchema, |
10 | 7 | MultiHopWithContractSchema, |
11 | | - SingleHopSchema, SingleHopWithContractSchema |
| 8 | + SingleHopSchema, |
| 9 | + SingleHopWithContractSchema, |
| 10 | + SweepSchema, |
12 | 11 | } from "@chainsafe/sprinter-sdk/dist/internal/validators"; |
13 | 12 |
|
14 | 13 | export function useTransfers(sprinter: Sprinter) { |
15 | 14 | const { state: solution, makeRequest } = useAsyncRequest<SolutionResponse>(); |
16 | 15 |
|
17 | | - const getPoolAssetOnDestination = useCallback((settings: Infer<typeof MultiHopSchema>) => { |
18 | | - makeRequest(sprinter.poolAssetOnDestination(settings)); |
19 | | - }, [sprinter, makeRequest]); |
| 16 | + const getPoolAssetOnDestination = useCallback( |
| 17 | + (settings: Infer<typeof MultiHopSchema>) => { |
| 18 | + makeRequest(sprinter.poolAssetOnDestination(settings)); |
| 19 | + }, |
| 20 | + [sprinter, makeRequest], |
| 21 | + ); |
| 22 | + |
| 23 | + const getPoolAssetOnDestinationWithHook = useCallback( |
| 24 | + (settings: Infer<typeof MultiHopWithContractSchema>) => { |
| 25 | + makeRequest(sprinter.poolAssetOnDestinationWithHook(settings)); |
| 26 | + }, |
| 27 | + [sprinter, makeRequest], |
| 28 | + ); |
20 | 29 |
|
21 | | - const getPoolAssetOnDestinationWithHook = useCallback((settings: Infer<typeof MultiHopWithContractSchema>) => { |
22 | | - makeRequest(sprinter.poolAssetOnDestinationWithHook(settings)); |
23 | | - }, [sprinter, makeRequest]); |
| 30 | + const getTransfer = useCallback( |
| 31 | + (settings: Infer<typeof SingleHopSchema>) => { |
| 32 | + makeRequest(sprinter.transfer(settings)); |
| 33 | + }, |
| 34 | + [sprinter, makeRequest], |
| 35 | + ); |
24 | 36 |
|
25 | | - const getTransfer = useCallback((settings: Infer<typeof SingleHopSchema>) => { |
26 | | - makeRequest(sprinter.transfer(settings)); |
27 | | - }, [sprinter, makeRequest]); |
| 37 | + const getTransferWithHook = useCallback( |
| 38 | + (settings: Infer<typeof SingleHopWithContractSchema>) => { |
| 39 | + makeRequest(sprinter.transferWithHook(settings)); |
| 40 | + }, |
| 41 | + [sprinter, makeRequest], |
| 42 | + ); |
28 | 43 |
|
29 | | - const getTransferWithHook = useCallback((settings: Infer<typeof SingleHopWithContractSchema>) => { |
30 | | - makeRequest(sprinter.transferWithHook(settings)); |
31 | | - }, [sprinter, makeRequest]); |
| 44 | + const getSweep = useCallback( |
| 45 | + (settings: Infer<typeof SweepSchema>) => { |
| 46 | + makeRequest(sprinter.sweep(settings)); |
| 47 | + }, |
| 48 | + [sprinter, makeRequest], |
| 49 | + ); |
32 | 50 |
|
33 | | - return { solution, getTransfer, getTransferWithHook, getPoolAssetOnDestination, getPoolAssetOnDestinationWithHook }; |
| 51 | + return { |
| 52 | + solution, |
| 53 | + getTransfer, |
| 54 | + getTransferWithHook, |
| 55 | + getPoolAssetOnDestination, |
| 56 | + getPoolAssetOnDestinationWithHook, |
| 57 | + getSweep, |
| 58 | + }; |
34 | 59 | } |
0 commit comments