diff --git a/src/hooks/useTransaction.ts b/src/hooks/useTransaction.ts deleted file mode 100644 index e0d2b44..0000000 --- a/src/hooks/useTransaction.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { useState } from 'react' -import { signTransaction } from '@stellar/freighter-api' -import { STELLAR_NETWORK } from '../constants/config' - -interface UseTransactionReturn { - isLoading: boolean - error: string | null - execute: ( - getXdr: () => Promise<{ xdr: string }>, - submit: (signedXdr: string) => Promise - ) => Promise -} - -export function useTransaction(): UseTransactionReturn { - const [isLoading, setIsLoading] = useState(false) - const [error, setError] = useState(null) - - const execute = async ( - getXdr: () => Promise<{ xdr: string }>, - submit: (signedXdr: string) => Promise - ): Promise => { - setIsLoading(true) - setError(null) - try { - const { xdr } = await getXdr() - - const networkPassphrase = (STELLAR_NETWORK as string) === 'PUBLIC' - ? 'Public Global Stellar Network ; October 2015' - : 'Test SDF Network ; September 2015' - - const signedResponse = await signTransaction(xdr, { - networkPassphrase, - }) - - if (!signedResponse || signedResponse.error) { - throw new Error(typeof signedResponse.error === 'string' ? signedResponse.error : 'User rejected the transaction') - } - - const result = await submit(signedResponse.signedTxXdr) - return result - } catch (err: unknown) { - console.error('Transaction failed:', err) - const message = err instanceof Error ? err.message : 'Transaction failed' - setError(message) - throw err - } finally { - setIsLoading(false) - } - } - - return { isLoading, error, execute } -} diff --git a/src/services/sponsors.service.ts b/src/services/sponsors.service.ts deleted file mode 100644 index 08db6be..0000000 --- a/src/services/sponsors.service.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { api } from './api' -import type { PoolInfo } from '../types' - -export const sponsorsService = { - getPoolInfo: async (): Promise => { - const res = await api.get('/liquidity/pool-info') - return res.data - }, - - withdraw: async (shares: number): Promise<{ xdr: string }> => { - const res = await api.post('/liquidity/withdraw', { shares }) - return res.data - }, - - submitTransaction: async (signedXdr: string): Promise<{ - hash: string - amount: number - profit: number - }> => { - const res = await api.post('/liquidity/submit', { xdr: signedXdr }) - return res.data - }, -}