-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add hook for confirmed btc balance, inscription callouts #711
Changes from 2 commits
155ea51
2195750
152e5c1
104b028
7e1da7a
a57e10b
da3fd18
ecdd4c1
5f86b29
4acdb13
3a6f227
6a98b2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,30 @@ | ||||||
import useBtcClient from '@hooks/useBtcClient'; | ||||||
import { useQuery } from '@tanstack/react-query'; | ||||||
import useWalletSelector from '../useWalletSelector'; | ||||||
|
||||||
const useConfirmBtcBalance = () => { | ||||||
const { btcAddress } = useWalletSelector(); | ||||||
const btcClient = useBtcClient(); | ||||||
|
||||||
const fetchBtcAddressData = async () => btcClient.getAddressData(btcAddress); | ||||||
|
||||||
let confirmedBalance: number = 0; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: do we need to explicitly set the type here? I think we can rely on type inference here https://www.typescriptlang.org/docs/handbook/type-inference.html |
||||||
|
||||||
const response = useQuery({ | ||||||
queryKey: ['btc-address-data'], | ||||||
queryFn: fetchBtcAddressData, | ||||||
}); | ||||||
|
||||||
const chainStats = response.data?.chain_stats; | ||||||
const mempoolStats = response.data?.mempool_stats; | ||||||
if (chainStats && mempoolStats) { | ||||||
confirmedBalance = | ||||||
chainStats.funded_txo_sum - chainStats.spent_txo_sum - mempoolStats.spent_txo_sum; | ||||||
} | ||||||
|
||||||
return { | ||||||
confirmedBalance, | ||||||
}; | ||||||
}; | ||||||
|
||||||
export default useConfirmBtcBalance; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -982,7 +982,9 @@ | |
"FAILED_TO_FINALIZE": "The inscription transaction failed to finalize. Please try again or contact support.", | ||
"SERVER_ERROR": "An unknown server error occurred. Please try again or contact support." | ||
}, | ||
"TOO_MANY_REPEATS": "You can only create up to 24 inscriptions in a single request" | ||
"TOO_MANY_REPEATS": "You can only create up to 24 inscriptions in a single request", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a valid point. Although this wasn't included in the current pull request, I've addressed it anyway π |
||
"UNCONFIRMED_UTXO": "Some of your balance consists of unconfirmed outputs. You don't have enough confirmed funds to proceed with this transaction", | ||
"LEDGER_INSCRIPTION": "This inscription service is not compatible with Ledger accounts. Please switch to a standard account to inscribe." | ||
} | ||
}, | ||
"ERROR_SCREEN": { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abdulhaseeb4239 we should revert the
package-lock.json
changes as they're not needed and they also cause the build failure in this PR