-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
shift btc withdrawl option to settings
- Loading branch information
1 parent
be43e41
commit d5c01c4
Showing
5 changed files
with
71 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { getNonOrdinalUtxo } from '@secretkeylabs/xverse-core'; | ||
import { UnspentOutput } from '@secretkeylabs/xverse-core/transactions/btc'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { REFETCH_UNSPENT_UTXO_TIME } from '@utils/constants'; | ||
import { getTimeForNonOrdinalTransferTransaction } from '@utils/localStorage'; | ||
import useWalletSelector from './useWalletSelector'; | ||
|
||
const useNonOrdinalUtxos = () => { | ||
const { | ||
network, ordinalsAddress, | ||
} = useWalletSelector(); | ||
|
||
const fetchNonOrdinalUtxo = async () => { | ||
const lastTransactionTime = await getTimeForNonOrdinalTransferTransaction(ordinalsAddress); | ||
if (!lastTransactionTime) { | ||
return getNonOrdinalUtxo(ordinalsAddress, network.type); | ||
} | ||
const diff = new Date().getTime() - Number(lastTransactionTime); | ||
if (diff > REFETCH_UNSPENT_UTXO_TIME) { | ||
return getNonOrdinalUtxo(ordinalsAddress, network.type); | ||
} | ||
return [] as UnspentOutput[]; | ||
}; | ||
|
||
const { data: unspentUtxos, isLoading } = useQuery({ | ||
keepPreviousData: false, | ||
queryKey: [`getNonOrdinalsUtxo-${ordinalsAddress}`], | ||
queryFn: fetchNonOrdinalUtxo, | ||
}); | ||
return { | ||
unspentUtxos, | ||
isLoading, | ||
}; | ||
}; | ||
|
||
export default useNonOrdinalUtxos; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters