Skip to content
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

Merged
merged 3 commits into from
Dec 14, 2023
Merged

feat: bitcoin contracts query #4679

merged 3 commits into from
Dec 14, 2023

Conversation

Polybius93
Copy link
Collaborator

@Polybius93 Polybius93 commented Dec 12, 2023

Try out this version of Leather — Extension build, Test report

@Polybius93 Polybius93 marked this pull request as ready for review December 12, 2023 16:17

export function useBitcoinContractsBalanceQuery(): UseQueryResult<Money> {
const { sumBitcoinContractCollateralAmounts } = useBitcoinContracts();
const { address } = useCurrentAccountNativeSegwitIndexZeroSigner();
Copy link
Collaborator

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?

@@ -26,6 +26,8 @@ export function BitcoinContractEntryPointLayout(props: BitcoinContractEntryPoint
: balance.amount.toString();
const formattedBalance = formatBalance(amount);

if (Number(balance.amount) === 0) return false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return null?

Comment on lines 16 to 23
const [bitcoinContractsBalanceInUSD, setBitcoinContractsBalanceInUSD] = useState<string>('0');

useEffect(() => {
if (isUndefined(bitcoinContractsBalance)) return;
setBitcoinContractsBalanceInUSD(
i18nFormatCurrency(calculateFiatValue(createMoney(bitcoinContractsBalance.amount, 'BTC')))
);
}, [bitcoinContractsBalance, calculateFiatValue]);
Copy link
Collaborator

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this unnecessary useEffect.

Copy link
Collaborator

@kyranjamie kyranjamie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Polybius93

@Polybius93 Polybius93 added this pull request to the merge queue Dec 14, 2023
Merged via the queue into dev with commit c858abb Dec 14, 2023
26 checks passed
@Polybius93 Polybius93 deleted the feat/contracts-query branch December 14, 2023 11:00
@pete-watters pete-watters linked an issue Dec 18, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hide "Bitcoin Contracts" balance on testnet when zero
2 participants