-
Notifications
You must be signed in to change notification settings - Fork 149
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: bitcoin contracts query #4679
Conversation
Polybius93
commented
Dec 12, 2023
•
edited by github-actions
bot
Loading
edited by github-actions
bot
22273ce
to
b8478c4
Compare
|
||
export function useBitcoinContractsBalanceQuery(): UseQueryResult<Money> { | ||
const { sumBitcoinContractCollateralAmounts } = useBitcoinContracts(); | ||
const { address } = useCurrentAccountNativeSegwitIndexZeroSigner(); |
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.
This might break if we are using ledger and there is no bitcoin keys. Account index would work the same I think?
or do we only ever cal this when we know the are bitcoin keys?
b8478c4
to
332c4cd
Compare
332c4cd
to
b90619f
Compare
@@ -26,6 +26,8 @@ export function BitcoinContractEntryPointLayout(props: BitcoinContractEntryPoint | |||
: balance.amount.toString(); | |||
const formattedBalance = formatBalance(amount); | |||
|
|||
if (Number(balance.amount) === 0) return false; |
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.
return null?
const [bitcoinContractsBalanceInUSD, setBitcoinContractsBalanceInUSD] = useState<string>('0'); | ||
|
||
useEffect(() => { | ||
if (isUndefined(bitcoinContractsBalance)) return; | ||
setBitcoinContractsBalanceInUSD( | ||
i18nFormatCurrency(calculateFiatValue(createMoney(bitcoinContractsBalance.amount, 'BTC'))) | ||
); | ||
}, [bitcoinContractsBalance, calculateFiatValue]); |
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.
Perhaps better written as a fn that an effect that sets state?
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.
Removed this unnecessary useEffect.
cab7687
to
018622c
Compare
…f balance is undefined
018622c
to
90988c7
Compare
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.
Thanks @Polybius93