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

refactor: use stacks query pkg #5500

Merged
merged 1 commit into from
Jun 11, 2024
Merged

refactor: use stacks query pkg #5500

merged 1 commit into from
Jun 11, 2024

Conversation

fbwoolf
Copy link
Contributor

@fbwoolf fbwoolf commented Jun 7, 2024

Try out Leather build caa3382Extension build, Test report, Storybook, Chromatic

This PR removes the stacks queries from the extension and installs them from the mono repo. Once these are removed, and the code exists in one place, I will refactor the queries and some code might be brought back.

Summary by CodeRabbit

  • New Features

    • Introduced a new function to filter assets based on positive balances.
    • Updated the Collectibles component to handle account addresses more efficiently.
  • Bug Fixes

    • Improved handling of account data refresh and transaction updates.
  • Refactor

    • Consolidated and reorganized various imports to improve code maintainability.
    • Updated multiple hooks to use new query sources for better performance and consistency.
  • Chores

    • Updated package dependencies to their latest versions for enhanced security and functionality.

Copy link

coderabbitai bot commented Jun 7, 2024

Important

Review skipped

More than 25% of the files skipped due to max files limit. The review is being skipped to prevent a low-quality review.

55 files out of 115 files are above the max files limit of 50. Please upgrade to Pro plan to get higher limits.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The updates primarily involve refactoring and reorganizing import statements across various files to consolidate functionality into the @leather-wallet/query module. Additionally, several hooks and functions have been updated or replaced to improve the handling of account data, transactions, and asset management. These changes aim to streamline the codebase, enhance maintainability, and ensure more efficient data handling.

Changes

File(s) Change Summary
package.json Updated the version of @stacks/stacks-blockchain-api-types from 6.3.4 to 7.8.2.
src/app/app.tsx Added a blank line after the const network = useCurrentNetwork(); statement within the ConnectedApp function.
src/app/common/asset-utils.ts Removed sortAssetsByName function and added migratePositiveAssetBalancesToTop function.
src/shared/constants.ts Removed DEFAULT_FEE_RATE, STX20_API_BASE_URL_MAINNET, and DEFAULT_LIST_LIMIT constants.
src/app/common/hooks/account/use-account-names.ts Refactored useCurrentAccountDisplayName and useAccountDisplayName to use useGetBnsNamesOwnedByAddressQuery.
src/app/common/hooks/account/use-refresh-all-account-data.ts Replaced useCurrentAccountMempool with useCurrentStacksAccountAddress and useAccountMempoolQuery.
src/app/common/hooks/balance/use-total-balance.tsx Added useStxCryptoAssetBalance import alongside useCryptoCurrencyMarketDataMeanAverage.
src/app/common/hooks/use-key-actions.ts Swapped the order of initialization of stxClient and btcClient.
src/app/components/balance/stx-balance.tsx Changed import of useStxCryptoAssetBalance to @leather-wallet/query.
src/app/components/loaders/sip10-tokens-loader.tsx Reorganized imports related to SIP-10 tokens to @leather-wallet/query.
src/app/components/loaders/stx-balance-loader.tsx Changed import of useStxCryptoAssetBalance to @leather-wallet/query.
src/app/components/loaders/stx20-tokens-loader.tsx Updated import statement for useStx20Tokens to @leather-wallet/query.
src/app/components/nonce-setter.tsx Added useNextNonce import from @leather-wallet/query and modified its usage.
src/app/features/activity-list/activity-list.tsx Added useEffect and useGetAccountTransactionsWithTransfersQuery, removed useStacksPendingTransactions, and modified hooks usage.
src/app/features/activity-list/components/transaction-list/stacks-transaction/ft-transfer-item.tsx Reorganized imports for isFtAsset and useGetFungibleTokenMetadataQuery to @leather-wallet/query.
src/app/features/asset-list/stacks/sip10-token-asset-list/sip10-token-asset-list-unsupported.tsx Updated imports for Sip10TokenAssetDetails and useAlexCurrencyPriceAsMarketData to @leather-wallet/query.
src/app/features/asset-list/stacks/sip10-token-asset-list/sip10-token-asset-list.tsx Updated imports for Sip10TokenAssetDetails and useAlexCurrencyPriceAsMarketData to @leather-wallet/query.
src/app/features/collectibles/collectibles.tsx Modified Collectibles function to pass address prop to StacksCryptoAssets component.
src/app/features/collectibles/components/stacks/stacks-crypto-assets.tsx Changed StacksCryptoAssets to receive address prop and updated related hooks.
src/app/features/dialogs/increase-fee-dialog/hooks/use-selected-tx.ts Updated import statement for useTransactionById to @leather-wallet/query.
src/app/features/dialogs/increase-fee-dialog/increase-stx-fee-dialog.tsx Replaced useCurrentStxAvailableUnlockedBalance with useCurrentStacksAccountAddress and introduced useStxAvailableUnlockedBalance.
src/app/features/settings/network/network-list-item.tsx Updated import statement for useNetworkStatus to @leather-wallet/query.
src/app/features/stacks-message-signer/components/clarity-value-list.tsx Consolidated imports from @stacks/transactions to include principalToString.
src/app/features/stacks-transaction-request/contract-call-details/function-argument-item.tsx Added new imports, adjusted hook usage, and handled cases where transactionRequest is not available or contractFunction is null.
src/app/features/stacks-transaction-request/hooks/use-stacks-transaction-summary.ts Added useGetStackNetworkBlockTimeQuery and replaced useStacksBlockTime with it.
src/app/pages/swap/components/swap-asset-dialog/components/swap-asset-item.tsx Updated import statements to reflect changes in module/package organization.
src/app/store/transactions/transaction.hooks.ts Added useNextNonce import from @leather-wallet/query and modified its usage in useUnsignedStacksTransactionBaseState and useGenerateUnsignedStacksTransaction functions.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@fbwoolf fbwoolf force-pushed the feat/stacks-query-pkg branch 4 times, most recently from 52c3b32 to 4a29ff1 Compare June 7, 2024 01:42
Copy link
Contributor

@pete-watters pete-watters left a comment

Choose a reason for hiding this comment

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

Great work @fbwoolf 🚀

It's so satisfying to see:
Screenshot 2024-06-07 at 09 33 19

Copy link
Contributor

@edgarkhanzadian edgarkhanzadian left a comment

Choose a reason for hiding this comment

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

🚀 🚀 🚀

alter-eggo
alter-eggo previously approved these changes Jun 7, 2024
Copy link
Contributor

@alter-eggo alter-eggo left a comment

Choose a reason for hiding this comment

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

tested and lgtm

@alter-eggo alter-eggo dismissed their stale review June 7, 2024 09:54

noticed problem in activity

@alter-eggo
Copy link
Contributor

@fbwoolf once submit stx tx I don't see pending tx in activity, though see this (1st screenshot)
seems in dev it's ok (2 screenshot)
Screenshot 2024-06-07 at 13 53 43
Screenshot 2024-06-07 at 13 56 01

@fbwoolf
Copy link
Contributor Author

fbwoolf commented Jun 7, 2024

@fbwoolf once submit stx tx I don't see pending tx in activity, though see this (1st screenshot) seems in dev it's ok

Thx, will check this again, it was working ok but maybe something broke. 👀

@fbwoolf fbwoolf force-pushed the feat/stacks-query-pkg branch 2 times, most recently from 87a0991 to e10cc52 Compare June 10, 2024 15:22
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 18

Outside diff range and nitpick comments (4)
src/app/common/asset-utils.ts (1)

Line range hint 1-1: Ensure edge cases are handled in utility functions.

Consider adding null checks for assets in migratePositiveAssetBalancesToTop and for asset.balance and asset.marketData in convertAssetBalanceToFiat to prevent runtime errors.

src/app/pages/swap/hooks/use-alex-swap.tsx (1)

Line range hint 28-28: Replace isNaN with Number.isNaN for safer type checking.

- const amountAsBigInt = isNaN(Number(amount)) ? BigInt(0) : BigInt(amount);
+ const amountAsBigInt = Number.isNaN(Number(amount)) ? BigInt(0) : BigInt(amount);
src/app/common/hooks/use-key-actions.ts (1)

Line range hint 37-37: Remove redundant double-negation to simplify the condition.

- if (!!defaultKeyDetails) {
+ if (defaultKeyDetails) {
src/app/features/stacks-transaction-request/stacks-transaction-signer.tsx (1)

Line range hint 68-68:
The comma operator is disallowed due to potential confusion and side effects.

- void analytics.track('view_transaction_signing'), [analytics];
+ void analytics.track('view_transaction_signing');
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 52025c6 and 87a0991.

Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !pnpm-lock.yaml
Files selected for processing (57)
  • package.json (1 hunks)
  • src/app/app.tsx (1 hunks)
  • src/app/common/asset-utils.ts (1 hunks)
  • src/app/common/hooks/account/use-account-names.ts (1 hunks)
  • src/app/common/hooks/account/use-refresh-all-account-data.ts (1 hunks)
  • src/app/common/hooks/balance/use-total-balance.tsx (1 hunks)
  • src/app/common/hooks/use-key-actions.ts (1 hunks)
  • src/app/components/balance/stx-balance.tsx (1 hunks)
  • src/app/components/loaders/sip10-tokens-loader.tsx (1 hunks)
  • src/app/components/loaders/stx-balance-loader.tsx (1 hunks)
  • src/app/components/loaders/stx20-tokens-loader.tsx (1 hunks)
  • src/app/components/nonce-setter.tsx (1 hunks)
  • src/app/features/activity-list/activity-list.tsx (3 hunks)
  • src/app/features/activity-list/components/transaction-list/stacks-transaction/ft-transfer-item.tsx (2 hunks)
  • src/app/features/asset-list/stacks/sip10-token-asset-list/sip10-token-asset-list-unsupported.tsx (1 hunks)
  • src/app/features/asset-list/stacks/sip10-token-asset-list/sip10-token-asset-list.tsx (1 hunks)
  • src/app/features/collectibles/collectibles.tsx (1 hunks)
  • src/app/features/collectibles/components/stacks/stacks-crypto-assets.tsx (2 hunks)
  • src/app/features/dialogs/increase-fee-dialog/hooks/use-selected-tx.ts (1 hunks)
  • src/app/features/dialogs/increase-fee-dialog/increase-stx-fee-dialog.tsx (3 hunks)
  • src/app/features/settings/network/network-list-item.tsx (1 hunks)
  • src/app/features/stacks-message-signer/components/clarity-value-list.tsx (1 hunks)
  • src/app/features/stacks-transaction-request/contract-call-details/function-argument-item.tsx (1 hunks)
  • src/app/features/stacks-transaction-request/hooks/use-stacks-transaction-summary.ts (2 hunks)
  • src/app/features/stacks-transaction-request/hooks/use-transaction-error.ts (2 hunks)
  • src/app/features/stacks-transaction-request/stacks-transaction-signer.tsx (3 hunks)
  • src/app/features/stacks-transaction-request/transaction-error/error-messages.tsx (3 hunks)
  • src/app/pages/home/components/send-button.tsx (2 hunks)
  • src/app/pages/receive/components/receive-tokens.tsx (2 hunks)
  • src/app/pages/send/send-crypto-asset-form/components/recipient-fields/hooks/use-recipient-bns-name.tsx (1 hunks)
  • src/app/pages/send/send-crypto-asset-form/components/recipient-fields/recipient-bns-name-type-field.tsx (1 hunks)
  • src/app/pages/send/send-crypto-asset-form/family/bitcoin/components/bitcoin-recipient-field.tsx (1 hunks)
  • src/app/pages/send/send-crypto-asset-form/family/stacks/components/stacks-recipient-field.tsx (1 hunks)
  • src/app/pages/send/send-crypto-asset-form/form/sip10/sip10-token-send-form.tsx (2 hunks)
  • src/app/pages/send/send-crypto-asset-form/form/sip10/use-sip10-send-form.tsx (1 hunks)
  • src/app/pages/send/send-crypto-asset-form/form/stacks/use-stacks-common-send-form.tsx (4 hunks)
  • src/app/pages/send/send-crypto-asset-form/form/stx/use-stx-send-form.tsx (3 hunks)
  • src/app/pages/swap/alex-swap-container.tsx (3 hunks)
  • src/app/pages/swap/components/swap-asset-dialog/components/swap-asset-item.tsx (1 hunks)
  • src/app/pages/swap/components/swap-asset-dialog/components/swap-asset-list.tsx (1 hunks)
  • src/app/pages/swap/components/swap-details/swap-details.tsx (2 hunks)
  • src/app/pages/swap/hooks/use-alex-swap.tsx (2 hunks)
  • src/app/pages/swap/hooks/use-swap-form.tsx (2 hunks)
  • src/app/pages/swap/swap.context.ts (1 hunks)
  • src/app/pages/transaction-request/transaction-request.tsx (3 hunks)
  • src/app/query/common/remote-config/remote-config.query.ts (1 hunks)
  • src/app/query/query-config.ts (1 hunks)
  • src/app/store/accounts/blockchain/stacks/stacks-account.models.ts (2 hunks)
  • src/app/store/common/api-clients.hooks.ts (2 hunks)
  • src/app/store/software-keys/software-key.actions.ts (3 hunks)
  • src/app/store/submitted-transactions/submitted-transactions.hooks.ts (1 hunks)
  • src/app/store/transactions/contract-call.hooks.ts (2 hunks)
  • src/app/store/transactions/post-conditions.hooks.ts (1 hunks)
  • src/app/store/transactions/raw.hooks.ts (2 hunks)
  • src/app/store/transactions/token-transfer.hooks.ts (5 hunks)
  • src/app/store/transactions/transaction.hooks.ts (5 hunks)
  • src/shared/constants.ts (3 hunks)
Files not processed due to max files limit (4)
  • src/shared/models/account.model.ts
  • src/shared/models/api-types.ts
  • src/shared/models/contract-types.ts
  • tests/mocks/mock-apis.ts
Files not summarized due to errors (11)
  • src/app/pages/send/send-crypto-asset-form/form/sip10/sip10-token-send-form.tsx: Error: Server error. Please try again later.
  • src/app/common/asset-utils.ts: Error: Server error. Please try again later.
  • src/app/pages/swap/swap.context.ts: Error: Server error. Please try again later.
  • src/app/pages/transaction-request/transaction-request.tsx: Error: Server error. Please try again later.
  • src/app/pages/receive/components/receive-tokens.tsx: Error: Server error. Please try again later.
  • src/app/pages/swap/hooks/use-swap-form.tsx: Error: Server error. Please try again later.
  • src/app/store/transactions/post-conditions.hooks.ts: Error: Server error. Please try again later.
  • src/app/components/loaders/sip10-tokens-loader.tsx: Error: Server error. Please try again later.
  • src/app/app.tsx: Error: Server error. Please try again later.
  • src/app/store/software-keys/software-key.actions.ts: Error: Server error. Please try again later.
  • src/app/pages/send/send-crypto-asset-form/family/stacks/components/stacks-recipient-field.tsx: Error: Server error. Please try again later.
Files skipped from review due to trivial changes (5)
  • package.json
  • src/app/components/loaders/stx-balance-loader.tsx
  • src/app/features/asset-list/stacks/sip10-token-asset-list/sip10-token-asset-list-unsupported.tsx
  • src/app/pages/send/send-crypto-asset-form/family/bitcoin/components/bitcoin-recipient-field.tsx
  • src/app/pages/swap/components/swap-asset-dialog/components/swap-asset-list.tsx
Additional context used
Biome
src/app/features/collectibles/components/stacks/stacks-crypto-assets.tsx

[error] 39-39: Avoid using the index of an array as key property in an element. (lint/suspicious/noArrayIndexKey)

This is the source of the key value.

The order of the items may change, and this also affects performances and component state.
Check the React documentation.

src/app/features/stacks-transaction-request/contract-call-details/function-argument-item.tsx

[error] 36-36: Avoid using unnecessary Fragment. (lint/complexity/noUselessFragments)

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

src/app/pages/swap/hooks/use-alex-swap.tsx

[error] 28-28: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead. (lint/suspicious/noGlobalIsNan)

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

src/app/common/hooks/use-key-actions.ts

[error] 37-37: Avoid redundant double-negation. (lint/complexity/noExtraBooleanCast)

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

src/app/features/stacks-transaction-request/hooks/use-transaction-error.ts

[error] 31-31: void is not valid as a constituent in a union type (lint/suspicious/noConfusingVoidType)

Remove void

src/app/features/stacks-transaction-request/stacks-transaction-signer.tsx

[error] 68-68: The comma operator is disallowed. (lint/style/noCommaOperator)

Its use is often confusing and obscures side effects.

Additional comments not posted (61)
src/app/pages/send/send-crypto-asset-form/family/stacks/components/stacks-recipient-field.tsx (2)

1-1: The import statement correctly reflects the centralization of query functions as intended by the PR.


Line range hint 5-5: The StacksRecipientField component correctly utilizes the fetchNameOwner function from the centralized query package.

src/app/features/dialogs/increase-fee-dialog/hooks/use-selected-tx.ts (2)

1-1: The import statement correctly reflects the centralization of query functions as intended by the PR.


Line range hint 8-8: The useSelectedTx hook correctly utilizes the useTransactionById function from the centralized query package, aligning with the PR's refactoring goals.

src/app/query/query-config.ts (1)

1-1: The import statement is correctly updated to reflect the use of types from @tanstack/react-query.

src/app/store/accounts/blockchain/stacks/stacks-account.models.ts (1)

1-1: The type definitions for SoftwareStacksAccount and HardwareStacksAccount are clear and well-structured, extending the Account type from @stacks/wallet-sdk appropriately.

src/app/components/loaders/stx20-tokens-loader.tsx (1)

2-2: The import change aligns with the PR's objective to centralize query logic.

src/app/store/common/api-clients.hooks.ts (1)

3-3: Centralizing the stacksClient import is consistent with the PR's objectives. Good use of useMemo for performance optimization.

Also applies to: 16-16

src/app/components/loaders/sip10-tokens-loader.tsx (1)

2-5: The import change aligns with the PR's objective to centralize query logic.

src/app/components/balance/stx-balance.tsx (1)

3-3: The import change aligns with the PR's objective to centralize query logic.

src/app/components/nonce-setter.tsx (1)

3-3: Changes look good; ensure integration with formik is tested.

Also applies to: 8-8, 14-15

Verification successful

The integration of useFormikContext within nonce-setter.tsx has been confirmed.

  • useFormikContext is imported and used within the nonce-setter.tsx file.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify integration of NonceSetter with formik context.

# Test: Search for formik usage with NonceSetter. Expect: Proper integration.
rg --type typescript $'useFormikContext<.*NonceSetter.*>'

Length of output: 93



Script:

#!/bin/bash
# Description: Verify integration of NonceSetter with formik context.

# Test: Search for formik usage with NonceSetter. Expect: Proper integration.
rg --type tsx 'useFormikContext<.*NonceSetter.*>'

Length of output: 79



Script:

#!/bin/bash
# Description: Verify integration of NonceSetter with formik context.

# Test: Search for formik usage with NonceSetter. Expect: Proper integration.
rg 'useFormikContext<.*NonceSetter.*>'

Length of output: 40



Script:

#!/bin/bash
# Description: Verify integration of NonceSetter with formik context.

# Test: Search for formik context usage within nonce-setter.tsx. Expect: Proper integration.
rg 'useFormikContext' src/app/components/nonce-setter.tsx

Length of output: 163

src/app/features/settings/network/network-list-item.tsx (1)

1-1: Updated import of useNetworkStatus to use the centralized query module.

src/app/features/asset-list/stacks/sip10-token-asset-list/sip10-token-asset-list.tsx (1)

1-4: Updated imports to use centralized query hooks and types.

src/app/pages/swap/swap.context.ts (1)

3-3: Updated import of SwapAsset type to use the centralized query module.

src/app/query/common/remote-config/remote-config.query.ts (2)

Line range hint 1-1: Updated import of useRemoteConfig to use the centralized query module.


Line range hint 7-7: Exported hooks now point to the centralized query module, aligning with the refactoring goals.

src/app/pages/swap/components/swap-asset-dialog/components/swap-asset-item.tsx (1)

1-1: Updated imports to use @leather-wallet/query and @leather-wallet/utils.

This change aligns with the PR's objective to centralize query handling and utility functions.

src/app/pages/send/send-crypto-asset-form/form/sip10/sip10-token-send-form.tsx (1)

4-4: Updated imports to use hooks from @leather-wallet/query.

This change aligns with the PR's objective to centralize query handling.

src/app/pages/send/send-crypto-asset-form/components/recipient-fields/hooks/use-recipient-bns-name.tsx (1)

3-3: Updated imports to use @leather-wallet/query.

This change aligns with the PR's objective to centralize query handling.

src/app/store/transactions/post-conditions.hooks.ts (2)

3-3: Updated imports to use @leather-wallet/query.

This change aligns with the PR's objective to centralize query handling.


3-3: Ensure that the new hook useGetFungibleTokenMetadataQuery is correctly implemented and tested.

src/app/store/submitted-transactions/submitted-transactions.hooks.ts (1)

Line range hint 27-38: Implementation looks good and follows best practices.

src/app/pages/swap/hooks/use-alex-swap.tsx (1)

19-20: Ensure proper handling of empty or undefined addresses.

Verification successful

The useCurrentStacksAccountAddress function returns the address from useCurrentStacksAccount() or an empty string if the address is undefined. This ensures that the function does not return null or undefined, but rather an empty string in such cases.

  • useCurrentStacksAccountAddress implementation:
    export function useCurrentStacksAccountAddress() {
      return useCurrentStacksAccount()?.address ?? '';
    }

Given this implementation, the address will always be a string, either a valid address or an empty string. Therefore, there is no need for additional null or undefined checks in the code using this hook.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `useCurrentStacksAccountAddress` always returns a valid address or is handled properly when undefined.

# Test: Search for the hook usage and check for null checks.
rg --type typescript $'useCurrentStacksAccountAddress'

Length of output: 88



Script:

#!/bin/bash
# Description: Verify that `useCurrentStacksAccountAddress` always returns a valid address or is handled properly when undefined.

# Test: Search for the hook usage and check for null checks.
rg --type tsx 'useCurrentStacksAccountAddress'

Length of output: 74



Script:

#!/bin/bash
# Description: Verify that `useCurrentStacksAccountAddress` always returns a valid address or is handled properly when undefined.

# Test: Search for the hook usage and check for null checks.
rg --type ts 'useCurrentStacksAccountAddress'

Length of output: 5435



Script:

#!/bin/bash
# Description: Verify that `useCurrentStacksAccountAddress` always returns a valid address or is handled properly when undefined.

# Test: Search for null or undefined checks around `useCurrentStacksAccountAddress`.
rg --type ts 'useCurrentStacksAccountAddress\(\)\s*&&' -A 3

Length of output: 61



Script:

#!/bin/bash
# Description: Retrieve the implementation of `useCurrentStacksAccountAddress`.

# Test: Extract the function implementation from the relevant file.
ast-grep --lang ts --pattern 'function useCurrentStacksAccountAddress() { $$$ }'

Length of output: 396

src/app/common/hooks/balance/use-total-balance.tsx (1)

3-6: Ensure that the imported hooks are used correctly and efficiently.

src/app/pages/send/send-crypto-asset-form/components/recipient-fields/recipient-bns-name-type-field.tsx (1)

3-3: Ensure that the StacksClient type is correctly used throughout the component.

src/app/app.tsx (1)

29-29: Integration of LeatherQueryProvider looks good. Ensure that the network and environment props are correctly configured and passed.

Verification successful

The integration of LeatherQueryProvider in src/app/app.tsx appears to be correctly configured. The network and environment props are properly passed, ensuring that the LeatherQueryProvider is set up with the necessary context.

  • network is assigned the value from useCurrentNetwork().
  • environment is configured with WALLET_ENVIRONMENT and GitHub details.

This confirms that the LeatherQueryProvider is correctly integrated and configured.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the configuration of `LeatherQueryProvider` in `src/app/app.tsx`.

# Test: Search for the usage of `LeatherQueryProvider`. Expect: Proper configuration and prop passing.
rg --type python $'LeatherQueryProvider'

Length of output: 70



Script:

#!/bin/bash
# Description: Verify the configuration of `LeatherQueryProvider` in `src/app/app.tsx`.

# Test: Search for the usage of `LeatherQueryProvider`. Expect: Proper configuration and prop passing.
rg --type tsx 'LeatherQueryProvider'

Length of output: 64



Script:

#!/bin/bash
# Description: Verify the configuration of `LeatherQueryProvider` in `src/app/app.tsx`.

# Test: Search for the usage of `LeatherQueryProvider`. Expect: Proper configuration and prop passing.
rg 'LeatherQueryProvider'

Length of output: 193



Script:

#!/bin/bash
# Description: Extract the relevant lines from `src/app/app.tsx` to verify the configuration of `LeatherQueryProvider`.

# Extract lines around the usage of `LeatherQueryProvider`.
rg -A 5 -B 5 'LeatherQueryProvider' src/app/app.tsx

Length of output: 1028

src/app/pages/home/components/send-button.tsx (1)

4-4: Updated imports for useStxCryptoAssetBalance and useTransferableSip10Tokens look good. Ensure that these hooks are used correctly in the SendButtonSuspense function.

Verification successful

The hooks useStxCryptoAssetBalance and useTransferableSip10Tokens are correctly imported and used in the SendButtonSuspense function.

  • useStxCryptoAssetBalance is used to get the stxBalance.
  • useTransferableSip10Tokens is used to get the stacksFtAssets.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of `useStxCryptoAssetBalance` and `useTransferableSip10Tokens` in `src/app/pages/home/components/send-button.tsx`.

# Test: Search for the usage of these hooks. Expect: Correct usage in the function.
rg --type python $'useStxCryptoAssetBalance|useTransferableSip10Tokens'

Length of output: 103



Script:

#!/bin/bash
# Description: Verify the usage of `useStxCryptoAssetBalance` and `useTransferableSip10Tokens` in `src/app/pages/home/components/send-button.tsx`.

# Test: Search for the usage of these hooks. Expect: Correct usage in the function.
rg --type tsx 'useStxCryptoAssetBalance|useTransferableSip10Tokens' src/app/pages/home/components/send-button.tsx

Length of output: 143



Script:

#!/bin/bash
# Description: Verify the usage of `useStxCryptoAssetBalance` and `useTransferableSip10Tokens` in `src/app/pages/home/components/send-button.tsx`.

# Test: Search for the usage of these hooks. Expect: Correct usage in the function.
rg 'useStxCryptoAssetBalance|useTransferableSip10Tokens' src/app/pages/home/components/send-button.tsx

Length of output: 332

src/app/pages/send/send-crypto-asset-form/form/stacks/use-stacks-common-send-form.tsx (2)

30-30: The logic for fetching the nonce and setting initial form values appears correct.


2-2: Updated import for useNextNonce looks good. Ensure that it is used correctly to fetch the nonce for the current address.

Verification successful

The useNextNonce hook is indeed used in the src/app/pages/send/send-crypto-asset-form/form/stacks/use-stacks-common-send-form.tsx file, as well as in several other files across the repository. This confirms that the import statement is necessary and correctly placed.

  • src/app/pages/send/send-crypto-asset-form/form/stacks/use-stacks-common-send-form.tsx: const { data: nextNonce } = useNextNonce(stxAddress);
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of `useNextNonce` in `src/app/pages/send/send-crypto-asset-form/form/stacks/use-stacks-common-send-form.tsx`.

# Test: Search for the usage of `useNextNonce`. Expect: Correct usage in fetching the nonce.
rg --type python $'useNextNonce'

Length of output: 62



Script:

#!/bin/bash
# Description: Verify the usage of `useNextNonce` in `src/app/pages/send/send-crypto-asset-form/form/stacks/use-stacks-common-send-form.tsx`.

# Test: Search for the usage of `useNextNonce`. Expect: Correct usage in fetching the nonce.
rg --type js 'useNextNonce'

Length of output: 27



Script:

#!/bin/bash
# Description: Verify the usage of `useNextNonce` across the entire repository.

# Test: Search for the usage of `useNextNonce`. Expect: Correct usage in fetching the nonce.
rg 'useNextNonce'

Length of output: 2095

src/app/pages/swap/hooks/use-swap-form.tsx (2)

23-23: The logic for fetching the nonce and setting initial form values appears correct.


2-2: Updated import for useNextNonce looks good. Ensure that it is used correctly to fetch the nonce for the current address.

Verification successful

The usage of useNextNonce in src/app/pages/swap/hooks/use-swap-form.tsx appears to be correct, as it is used to fetch the nonce for the current address.

  • src/app/pages/swap/hooks/use-swap-form.tsx: const { data: nextNonce } = useNextNonce(stxAddress);
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of `useNextNonce` in `src/app/pages/swap/hooks/use-swap-form.tsx`.

# Test: Search for the usage of `useNextNonce`. Expect: Correct usage in fetching the nonce.
rg --type python $'useNextNonce'

Length of output: 62



Script:

#!/bin/bash
# Description: Verify the usage of `useNextNonce` in `src/app/pages/swap/hooks/use-swap-form.tsx`.

# Test: Search for the usage of `useNextNonce`. Expect: Correct usage in fetching the nonce.
rg --type tsx 'useNextNonce'

Length of output: 56



Script:

#!/bin/bash
# Description: Verify the usage of `useNextNonce` in `src/app/pages/swap/hooks/use-swap-form.tsx`.

# Test: Search for the usage of `useNextNonce`. Expect: Correct usage in fetching the nonce.
rg 'useNextNonce' --glob '**/*.tsx'

Length of output: 1119

src/app/features/stacks-message-signer/components/clarity-value-list.tsx (1)

1-2: Reorganized imports to align with new module structure.

src/app/features/collectibles/collectibles.tsx (1)

54-54: Updated StacksCryptoAssets component to receive address prop directly.

This change aligns with the PR's objective to refactor the handling of account-related data, ensuring that components receive only the necessary data they need to function, which in this case is the address.

src/app/pages/send/send-crypto-asset-form/form/sip10/use-sip10-send-form.tsx (1)

7-7: Updated import to use useCalculateStacksTxFees from @leather-wallet/query.

This change is part of the broader refactoring effort to centralize query hooks, which should help in maintaining and updating these functionalities in the future.

src/app/features/activity-list/components/transaction-list/stacks-transaction/ft-transfer-item.tsx (1)

1-1: Updated import to use isFtAsset and useGetFungibleTokenMetadataQuery from @leather-wallet/query.

This change is consistent with the PR's goal of centralizing the use of query hooks, which simplifies the management of dependencies and ensures consistency across the application.

src/app/common/hooks/use-key-actions.ts (1)

28-28: Change in the initialization order of stxClient is noted. Ensure this does not affect dependent operations negatively.

src/app/features/stacks-transaction-request/hooks/use-transaction-error.ts (1)

29-29: Use of useStxAvailableUnlockedBalance aligns with the refactoring objectives. Ensure that the hook is correctly fetching data as expected.

src/app/pages/send/send-crypto-asset-form/form/stx/use-stx-send-form.tsx (1)

Line range hint 22-39: Refactoring to use centralized query hooks and the introduction of the address variable are well-integrated. Ensure that the new hooks are fetching data correctly and that the address variable is always defined in the contexts it is used.

src/app/pages/swap/components/swap-details/swap-details.tsx (1)

39-39: Use of useGetStackNetworkBlockTimeQuery aligns with the refactoring objectives. Ensure that the hook is correctly fetching data as expected and integrates well with the existing logic.

src/app/pages/receive/components/receive-tokens.tsx (2)

3-3: Ensure the new hook useAlexSwappableAssets is correctly fetching data as expected.

Verification successful

The useAlexSwappableAssets hook is correctly imported and used in the receive-tokens.tsx file as well as in another file (use-alex-swap.tsx). The hook is fetching data as expected.

  • src/app/pages/receive/components/receive-tokens.tsx: const { data: swapAssets = [] } = useAlexSwappableAssets(stxAddress);
  • src/app/pages/swap/hooks/use-alex-swap.tsx: const { data: swapAssets = [] } = useAlexSwappableAssets(address);
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correct implementation of `useAlexSwappableAssets`.

# Test: Search for the hook usage and its implementation details.
ast-grep --lang javascript --pattern $'import { useAlexSwappableAssets } from "@leather-wallet/query"; $$$ useAlexSwappableAssets($_)'

Length of output: 652



Script:

#!/bin/bash
# Description: Verify the correct implementation of `useAlexSwappableAssets`.

# Step 1: Search for the import statement of `useAlexSwappableAssets`.
ast-grep --lang javascript --pattern $'import { useAlexSwappableAssets } from "@leather-wallet/query"'

# Step 2: Search for the usage of `useAlexSwappableAssets`.
ast-grep --lang javascript --pattern $'useAlexSwappableAssets($_)'

Length of output: 171



Script:

#!/bin/bash
# Description: Verify the correct implementation of `useAlexSwappableAssets`.

# Step 1: Search for the import statement of `useAlexSwappableAssets` across the entire codebase.
rg 'import { useAlexSwappableAssets } from "@leather-wallet/query"'

# Step 2: Search for the usage of `useAlexSwappableAssets` across the entire codebase.
rg 'useAlexSwappableAssets('

Length of output: 351



Script:

#!/bin/bash
# Description: Verify the correct implementation of `useAlexSwappableAssets`.

# Step 1: Search for the import statement of `useAlexSwappableAssets` across the entire codebase.
rg 'import \{ useAlexSwappableAssets \} from "@leather-wallet/query"'

# Step 2: Search for the usage of `useAlexSwappableAssets` across the entire codebase.
rg 'useAlexSwappableAssets\('

Length of output: 339


39-39: Check the integration of useAlexSwappableAssets with the stxAddress parameter.

Verification successful

The stxAddress parameter is correctly passed and utilized in the useAlexSwappableAssets hook within the receive-tokens.tsx file. The search results confirm that stxAddress is used in multiple contexts, including being passed to the useAlexSwappableAssets hook.

  • stxAddress is defined as a string.
  • It is passed to the useAlexSwappableAssets hook.
  • It is used in other parts of the component, indicating it is correctly integrated.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `stxAddress` is correctly passed and utilized in the `useAlexSwappableAssets` hook.

# Test: Search for the hook usage with `stxAddress` parameter.
ast-grep --lang javascript --pattern $'const { data: swapAssets = [] } = useAlexSwappableAssets(stxAddress); $$$'

Length of output: 610



Script:

#!/bin/bash
# Description: Verify that `stxAddress` is correctly passed and utilized in the `useAlexSwappableAssets` hook.

# Test: Search for the hook usage with `stxAddress` parameter.
ast-grep --lang javascript --pattern 'const { data: $_ = [] } = useAlexSwappableAssets(stxAddress);'

Length of output: 102



Script:

#!/bin/bash
# Description: Verify the definition and usage of `useAlexSwappableAssets` with the `stxAddress` parameter.

# Search for the definition of `useAlexSwappableAssets`.
ast-grep --lang javascript --pattern 'function useAlexSwappableAssets($_) { $$$ }'

# Search for all instances where `useAlexSwappableAssets` is used.
rg 'useAlexSwappableAssets'

Length of output: 587



Script:

#!/bin/bash
# Description: Verify the definition of `useAlexSwappableAssets` in the `@leather-wallet/query` module.

# Search for the definition of `useAlexSwappableAssets` in the `@leather-wallet/query` module.
rg 'useAlexSwappableAssets' $(fd -t d @leather-wallet/query)

Length of output: 535



Script:

#!/bin/bash
# Description: Verify the definition of `useAlexSwappableAssets` across the entire codebase.

# Search for the definition of `useAlexSwappableAssets` across the entire codebase.
rg 'function useAlexSwappableAssets' 

Length of output: 38



Script:

#!/bin/bash
# Description: Verify the exports from the `@leather-wallet/query` module to locate the definition of `useAlexSwappableAssets`.

# Search for all exports in the `@leather-wallet/query` module.
rg 'export' $(fd -t d @leather-wallet/query)

Length of output: 188778



Script:

#!/bin/bash
# Description: Verify the definition of `useAlexSwappableAssets` across the entire codebase.

# Search for the definition of `useAlexSwappableAssets` across the entire codebase.
rg 'useAlexSwappableAssets' 

Length of output: 502



Script:

#!/bin/bash
# Description: Verify the usage of `stxAddress` in the files where `useAlexSwappableAssets` is used.

# Search for the usage of `stxAddress` in the relevant files.
rg 'stxAddress' src/app/pages/receive/components/receive-tokens.tsx

Length of output: 309

src/app/features/stacks-transaction-request/hooks/use-stacks-transaction-summary.ts (1)

37-37: Verify the correct fetching and usage of blockTime from useGetStackNetworkBlockTimeQuery.

Verification successful

The verification confirms that blockTime is correctly fetched using useGetStackNetworkBlockTimeQuery and is used in the getEstimatedConfirmationTime function for transaction time estimations.

  • useGetStackNetworkBlockTimeQuery is used in:

    • src/app/features/stacks-transaction-request/hooks/use-stacks-transaction-summary.ts
    • src/app/pages/swap/components/swap-details/swap-details.tsx
  • getEstimatedConfirmationTime is used in:

    • src/app/features/stacks-transaction-request/hooks/use-stacks-transaction-summary.ts
    • src/app/pages/swap/components/swap-details/swap-details.tsx

These usages confirm that blockTime is fetched and utilized as expected.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `blockTime` is correctly fetched and used in transaction time estimations.

# Test: Search for the usage of `blockTime` in transaction time estimations.
ast-grep --lang javascript --pattern $'const { data: blockTime } = useGetStackNetworkBlockTimeQuery(); $$$ getEstimatedConfirmationTime($_, blockTime)'

Length of output: 686



Script:

#!/bin/bash
# Description: Verify that `blockTime` is correctly fetched and used in transaction time estimations.

# Test 1: Search for the fetching of `blockTime`.
ast-grep --lang javascript --pattern $'const { data: blockTime } = useGetStackNetworkBlockTimeQuery()'

# Test 2: Search for the usage of `blockTime` in `getEstimatedConfirmationTime`.
ast-grep --lang javascript --pattern $'getEstimatedConfirmationTime($_, blockTime)'

Length of output: 188



Script:

#!/bin/bash
# Description: Verify the fetching and usage of `blockTime` by searching for the functions `useGetStackNetworkBlockTimeQuery` and `getEstimatedConfirmationTime`.

# Test 1: Search for the definition and usage of `useGetStackNetworkBlockTimeQuery`.
ast-grep --lang javascript --pattern $'function useGetStackNetworkBlockTimeQuery($_) { $$$ }'

# Test 2: Search for the definition and usage of `getEstimatedConfirmationTime`.
ast-grep --lang javascript --pattern $'function getEstimatedConfirmationTime($_, $_) { $$$ }'

Length of output: 189



Script:

#!/bin/bash
# Description: Verify the fetching and usage of `blockTime` by searching for the functions `useGetStackNetworkBlockTimeQuery` and `getEstimatedConfirmationTime`.

# Test 1: Search for the definition and usage of `useGetStackNetworkBlockTimeQuery`.
rg 'useGetStackNetworkBlockTimeQuery'

# Test 2: Search for the definition and usage of `getEstimatedConfirmationTime`.
rg 'getEstimatedConfirmationTime'

Length of output: 1476

src/app/store/software-keys/software-key.actions.ts (1)

45-45: Verify the correct implementation and usage of getAccountBalance from stxClient.

src/app/features/activity-list/activity-list.tsx (3)

8-10: Ensure the new hooks from @leather-wallet/query are correctly replacing the old ones.


17-18: The addition of useCurrentStacksAccountAddress and useUpdateSubmittedTransactions hooks aligns with the PR's goal to centralize and streamline hook usage.


49-50: Correct use of useCurrentStacksAccountAddress and useUpdateSubmittedTransactions for managing STX addresses and transaction updates.

src/app/store/transactions/transaction.hooks.ts (2)

4-5: The addition of useNextNonce from @leather-wallet/query is part of the refactoring to centralize hook usage. Ensure it is correctly replacing the previous implementation.


47-47: The use of useNextNonce to fetch the next nonce for transactions is crucial. Verify that the hook is correctly implemented and returns accurate data.

Also applies to: 106-107

src/app/store/transactions/token-transfer.hooks.ts (2)

4-6: The addition of useNextNonce and stxToMicroStx from @leather-wallet/utils is consistent with the PR's goal to centralize utility functions. Verify their correct usage.

Verification successful

The usage of useNextNonce and stxToMicroStx appears consistent and correct across the codebase. The functions are imported and utilized in various files, including transaction.hooks.ts, token-transfer.hooks.ts, and others, indicating their integration is well-established.

  • useNextNonce is used to fetch the next nonce for a given address.
  • stxToMicroStx is used to convert STX values to microSTX.

The imports and usage patterns align with the intended functionality.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify correct usage of `useNextNonce` and `stxToMicroStx`.

# Test: Search for usage of these utilities in the codebase. Expect: Correct and consistent usage.
rg --type python $'useNextNonce|stxToMicroStx' src/

Length of output: 83



Script:

#!/bin/bash
# Description: Verify correct usage of `useNextNonce` and `stxToMicroStx`.

# Test: Search for usage of these utilities in the codebase. Expect: Correct and consistent usage.
rg 'useNextNonce|stxToMicroStx' src/

Length of output: 4835


37-38: The repeated use of useNextNonce for nonce fetching in different contexts is appropriate. Ensure that the nonce values are correctly handled in each scenario.

Also applies to: 71-72, 84-84

Verification successful

The search results show multiple instances of useNextNonce across various files. To ensure that nonce values are correctly handled in each scenario, we need to verify the context in which useNextNonce is used and how the nonce values are managed.

Let's inspect the relevant lines in these files to confirm the correct handling of nonce values.


The search results provide a comprehensive view of how useNextNonce is utilized across various files. Each instance appears to correctly handle the nonce values by fetching them using useNextNonce and then using the fetched nonce in subsequent logic.

Here are the key observations:

  • Nonce Fetching: In all instances, useNextNonce is used to fetch the nonce value associated with an account address.
  • Contextual Usage: The fetched nonce is then used in different contexts such as transaction signing, token transfers, contract calls, and form handling.
  • Consistency: The nonce values are consistently handled across different files, ensuring that they are correctly integrated into the respective logic.

Given these observations, the nonce values appear to be correctly handled in each scenario where useNextNonce is used.

  • Files and Lines:
    • src/app/features/stacks-transaction-request/stacks-transaction-signer.tsx: Lines around 10-20
    • src/app/store/transactions/transaction.hooks.ts: Lines around 10-30
    • src/app/store/transactions/token-transfer.hooks.ts: Lines around 10-40
    • src/app/store/transactions/contract-call.hooks.ts: Lines around 10-20
    • src/app/pages/transaction-request/transaction-request.tsx: Lines around 10-20
    • src/app/pages/swap/hooks/use-swap-form.tsx: Lines around 10-20
    • src/app/pages/send/send-crypto-asset-form/form/stacks/use-stacks-common-send-form.tsx: Lines around 10-20
    • src/app/components/nonce-setter.tsx: Lines around 10-20
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify correct handling of nonce values.

# Test: Search for nonce handling in different contexts. Expect: Correct handling in each scenario.
rg --type python $'useNextNonce' src/

Length of output: 67



Script:

#!/bin/bash
# Description: Verify correct handling of nonce values.

# Test: Search for nonce handling in different contexts. Expect: Correct handling in each scenario.
rg --type ts 'useNextNonce' src/

Length of output: 2110



Script:

#!/bin/bash
# Description: Verify correct handling of nonce values in different contexts.

# Extract lines around the usage of `useNextNonce` to understand the context.
rg --type ts -A 5 -B 5 'useNextNonce' src/app/features/stacks-transaction-request/stacks-transaction-signer.tsx
rg --type ts -A 5 -B 5 'useNextNonce' src/app/store/transactions/transaction.hooks.ts
rg --type ts -A 5 -B 5 'useNextNonce' src/app/store/transactions/token-transfer.hooks.ts
rg --type ts -A 5 -B 5 'useNextNonce' src/app/store/transactions/contract-call.hooks.ts
rg --type ts -A 5 -B 5 'useNextNonce' src/app/pages/transaction-request/transaction-request.tsx
rg --type ts -A 5 -B 5 'useNextNonce' src/app/pages/swap/hooks/use-swap-form.tsx
rg --type ts -A 5 -B 5 'useNextNonce' src/app/pages/send/send-crypto-asset-form/form/stacks/use-stacks-common-send-form.tsx
rg --type ts -A 5 -B 5 'useNextNonce' src/app/components/nonce-setter.tsx

Length of output: 8219

src/app/pages/transaction-request/transaction-request.tsx (1)

6-9: The use of hooks such as useCalculateStacksTxFees, useNextNonce, and useStxAvailableUnlockedBalance from @leather-wallet/query is in line with the PR's objectives to centralize hook usage. Ensure these hooks are integrated properly.

src/app/features/stacks-transaction-request/transaction-error/error-messages.tsx (3)

4-5: Updated imports to use hooks from @leather-wallet/query and utility functions from @leather-wallet/utils.


17-17: Updated hook imports to use useCurrentStacksAccountAddress from @app/store/accounts/blockchain/stacks/stacks-account.hooks.


63-64: Refactored to use useCurrentStacksAccountAddress and useStxAvailableUnlockedBalance for fetching the current account address and available unlocked balance.

src/app/features/stacks-transaction-request/stacks-transaction-signer.tsx (3)

4-9: Updated imports to use hooks from @leather-wallet/query for transaction fees, nonce, and balance checks.


34-34: Imported useCurrentStacksAccountAddress to fetch the current Stacks account address.


61-64: Refactored to use useCurrentStacksAccountAddress, useStxAvailableUnlockedBalance, and useNextNonce for fetching the current account address, available unlocked balance, and next nonce.

src/app/features/dialogs/increase-fee-dialog/increase-stx-fee-dialog.tsx (3)

4-5: Updated imports to use useStxAvailableUnlockedBalance from @leather-wallet/query and utility functions from @leather-wallet/utils.


22-22: Imported useCurrentStacksAccountAddress to fetch the current Stacks account address.


46-47: Refactored to use useCurrentStacksAccountAddress and useStxAvailableUnlockedBalance for fetching the current account address and available unlocked balance.

src/app/pages/swap/alex-swap-container.tsx (1)

4-5: Updated imports to use utility functions isDefined and isUndefined from @leather-wallet/utils.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Outside diff range and nitpick comments (3)
src/app/pages/swap/hooks/use-alex-swap.tsx (1)

Line range hint 29-29: Replace isNaN with Number.isNaN.

The use of isNaN can lead to unexpected results due to type coercion. Use Number.isNaN for a more reliable check:

- const amountAsBigInt = isNaN(Number(amount)) ? BigInt(0) : BigInt(amount);
+ const amountAsBigInt = Number.isNaN(Number(amount)) ? BigInt(0) : BigInt(amount);
src/app/common/hooks/use-key-actions.ts (1)

Line range hint 37-37: Remove redundant double-negation for cleaner code.

- if (!!defaultKeyDetails) {
+ if (defaultKeyDetails) {
src/app/features/stacks-transaction-request/stacks-transaction-signer.tsx (1)

Line range hint 69-69: Remove the comma operator to avoid potential side effects and improve code clarity.

- void analytics.track('view_transaction_signing'), [analytics];
+ void analytics.track('view_transaction_signing');
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8754ecc and e10cc52.

Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !pnpm-lock.yaml
Files selected for processing (57)
  • package.json (1 hunks)
  • src/app/app.tsx (1 hunks)
  • src/app/common/asset-utils.ts (1 hunks)
  • src/app/common/hooks/account/use-account-names.ts (1 hunks)
  • src/app/common/hooks/account/use-refresh-all-account-data.ts (1 hunks)
  • src/app/common/hooks/balance/use-total-balance.tsx (1 hunks)
  • src/app/common/hooks/use-key-actions.ts (1 hunks)
  • src/app/components/balance/stx-balance.tsx (1 hunks)
  • src/app/components/loaders/sip10-tokens-loader.tsx (1 hunks)
  • src/app/components/loaders/stx-balance-loader.tsx (1 hunks)
  • src/app/components/loaders/stx20-tokens-loader.tsx (1 hunks)
  • src/app/components/nonce-setter.tsx (1 hunks)
  • src/app/features/activity-list/activity-list.tsx (3 hunks)
  • src/app/features/activity-list/components/transaction-list/stacks-transaction/ft-transfer-item.tsx (2 hunks)
  • src/app/features/asset-list/stacks/sip10-token-asset-list/sip10-token-asset-list-unsupported.tsx (1 hunks)
  • src/app/features/asset-list/stacks/sip10-token-asset-list/sip10-token-asset-list.tsx (1 hunks)
  • src/app/features/collectibles/collectibles.tsx (1 hunks)
  • src/app/features/collectibles/components/stacks/stacks-crypto-assets.tsx (2 hunks)
  • src/app/features/dialogs/increase-fee-dialog/hooks/use-selected-tx.ts (1 hunks)
  • src/app/features/dialogs/increase-fee-dialog/increase-stx-fee-dialog.tsx (3 hunks)
  • src/app/features/settings/network/network-list-item.tsx (1 hunks)
  • src/app/features/stacks-message-signer/components/clarity-value-list.tsx (1 hunks)
  • src/app/features/stacks-transaction-request/contract-call-details/function-argument-item.tsx (1 hunks)
  • src/app/features/stacks-transaction-request/hooks/use-stacks-transaction-summary.ts (2 hunks)
  • src/app/features/stacks-transaction-request/hooks/use-transaction-error.ts (3 hunks)
  • src/app/features/stacks-transaction-request/stacks-transaction-signer.tsx (3 hunks)
  • src/app/features/stacks-transaction-request/transaction-error/error-messages.tsx (3 hunks)
  • src/app/pages/home/components/send-button.tsx (1 hunks)
  • src/app/pages/receive/components/receive-tokens.tsx (2 hunks)
  • src/app/pages/send/send-crypto-asset-form/components/recipient-fields/hooks/use-recipient-bns-name.tsx (1 hunks)
  • src/app/pages/send/send-crypto-asset-form/components/recipient-fields/recipient-bns-name-type-field.tsx (1 hunks)
  • src/app/pages/send/send-crypto-asset-form/family/bitcoin/components/bitcoin-recipient-field.tsx (1 hunks)
  • src/app/pages/send/send-crypto-asset-form/family/stacks/components/stacks-recipient-field.tsx (1 hunks)
  • src/app/pages/send/send-crypto-asset-form/form/sip10/sip10-token-send-form.tsx (2 hunks)
  • src/app/pages/send/send-crypto-asset-form/form/sip10/use-sip10-send-form.tsx (1 hunks)
  • src/app/pages/send/send-crypto-asset-form/form/stacks/use-stacks-common-send-form.tsx (4 hunks)
  • src/app/pages/send/send-crypto-asset-form/form/stx/use-stx-send-form.tsx (3 hunks)
  • src/app/pages/swap/alex-swap-container.tsx (2 hunks)
  • src/app/pages/swap/components/swap-asset-dialog/components/swap-asset-item.tsx (1 hunks)
  • src/app/pages/swap/components/swap-asset-dialog/components/swap-asset-list.tsx (2 hunks)
  • src/app/pages/swap/components/swap-details/swap-details.tsx (3 hunks)
  • src/app/pages/swap/hooks/use-alex-swap.tsx (2 hunks)
  • src/app/pages/swap/hooks/use-swap-form.tsx (2 hunks)
  • src/app/pages/swap/swap.context.ts (1 hunks)
  • src/app/pages/transaction-request/transaction-request.tsx (3 hunks)
  • src/app/query/common/remote-config/remote-config.query.ts (1 hunks)
  • src/app/query/query-config.ts (1 hunks)
  • src/app/store/accounts/blockchain/stacks/stacks-account.models.ts (2 hunks)
  • src/app/store/common/api-clients.hooks.ts (2 hunks)
  • src/app/store/software-keys/software-key.actions.ts (3 hunks)
  • src/app/store/submitted-transactions/submitted-transactions.hooks.ts (1 hunks)
  • src/app/store/transactions/contract-call.hooks.ts (1 hunks)
  • src/app/store/transactions/post-conditions.hooks.ts (1 hunks)
  • src/app/store/transactions/raw.hooks.ts (2 hunks)
  • src/app/store/transactions/token-transfer.hooks.ts (4 hunks)
  • src/app/store/transactions/transaction.hooks.ts (4 hunks)
  • src/shared/constants.ts (3 hunks)
Files not processed due to max files limit (4)
  • src/shared/models/account.model.ts
  • src/shared/models/api-types.ts
  • src/shared/models/contract-types.ts
  • tests/mocks/mock-apis.ts
Files not summarized due to errors (1)
  • src/app/store/transactions/post-conditions.hooks.ts: Error: Server error. Please try again later.
Files not reviewed due to errors (1)
  • src/app/features/asset-list/stacks/sip10-token-asset-list/sip10-token-asset-list-unsupported.tsx (no review received)
Files skipped from review due to trivial changes (6)
  • package.json
  • src/app/app.tsx
  • src/app/features/stacks-message-signer/components/clarity-value-list.tsx
  • src/app/pages/send/send-crypto-asset-form/components/recipient-fields/hooks/use-recipient-bns-name.tsx
  • src/app/pages/send/send-crypto-asset-form/family/stacks/components/stacks-recipient-field.tsx
  • src/app/query/common/remote-config/remote-config.query.ts
Additional context used
Biome
src/app/features/collectibles/components/stacks/stacks-crypto-assets.tsx

[error] 39-39: Avoid using the index of an array as key property in an element. (lint/suspicious/noArrayIndexKey)

This is the source of the key value.

The order of the items may change, and this also affects performances and component state.
Check the React documentation.

src/app/features/stacks-transaction-request/contract-call-details/function-argument-item.tsx

[error] 37-37: Avoid using unnecessary Fragment. (lint/complexity/noUselessFragments)

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

src/app/pages/swap/hooks/use-alex-swap.tsx

[error] 29-29: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead. (lint/suspicious/noGlobalIsNan)

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

src/app/common/hooks/use-key-actions.ts

[error] 37-37: Avoid redundant double-negation. (lint/complexity/noExtraBooleanCast)

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

src/app/features/stacks-transaction-request/hooks/use-transaction-error.ts

[error] 32-32: void is not valid as a constituent in a union type (lint/suspicious/noConfusingVoidType)

Remove void

src/app/features/stacks-transaction-request/stacks-transaction-signer.tsx

[error] 69-69: The comma operator is disallowed. (lint/style/noCommaOperator)

Its use is often confusing and obscures side effects.

Additional comments not posted (66)
src/app/pages/send/send-crypto-asset-form/family/bitcoin/components/bitcoin-recipient-field.tsx (2)

1-1: The import of fetchBtcNameOwner aligns with the PR's goal of centralizing query logic.


Line range hint 1-5: The TransferRecipientField component correctly utilizes the fetchBtcNameOwner function for BNS lookup. This is a clean and concise implementation.

src/app/features/dialogs/increase-fee-dialog/hooks/use-selected-tx.ts (2)

1-1: The import of useTransactionById from @leather-wallet/query is consistent with the PR's goal of centralizing query logic.


Line range hint 1-6: The useSelectedTx hook is implemented correctly, handling potential null values gracefully. This ensures robustness in transaction data fetching.

src/app/query/query-config.ts (1)

1-1: The utility function isFetchedWithSuccess is implemented correctly. However, remember to address the TODO item (#40) regarding further centralization.

Also applies to: 3-3

src/app/store/accounts/blockchain/stacks/stacks-account.models.ts (1)

Line range hint 1-14: The type definitions for SoftwareStacksAccount and HardwareStacksAccount are clear and enhance the base Account type with additional properties. This is a good practice for type safety and clarity.

src/app/components/loaders/stx20-tokens-loader.tsx (1)

2-2: Updated import path aligns with the centralization of query logic.

src/app/store/common/api-clients.hooks.ts (1)

3-3: Updated import paths and optimized useStacksClient function with useMemo to ensure efficient re-rendering.

Also applies to: 16-16

src/app/components/loaders/sip10-tokens-loader.tsx (1)

2-5: Updated import paths align with the centralization of query logic.

src/app/components/loaders/stx-balance-loader.tsx (1)

2-2: Updated import path aligns with the centralization of query logic.

src/app/components/balance/stx-balance.tsx (1)

3-3: The updated import path for useStxCryptoAssetBalance aligns with the PR's goal of centralizing query handling.

src/app/common/hooks/account/use-refresh-all-account-data.ts (1)

3-3: The updated import paths for useAccountMempoolQuery and useCurrentStacksAccountAddress align with the PR's goal of centralizing query handling.

Also applies to: 6-6, 11-12

src/app/components/nonce-setter.tsx (1)

5-5: The updated import paths for useNextNonce and useCurrentStacksAccountAddress align with the PR's goal of centralizing query handling.

Also applies to: 9-9, 15-16

src/app/common/asset-utils.ts (1)

Line range hint 3-10: The new function migratePositiveAssetBalancesToTop provides a focused approach to sorting assets based on their balances, aligning with the PR's goal of improving asset management.

src/app/store/transactions/raw.hooks.ts (2)

7-8: The import of useStacksClient from @leather-wallet/query aligns with the PR's objective to centralize the query-related code.


19-31: The use of useStacksClient for fetching raw transactions and the caching mechanism to avoid redundant network requests are both sound improvements.

src/app/features/settings/network/network-list-item.tsx (1)

1-2: The update to import useNetworkStatus from @leather-wallet/query is consistent with the PR's goal of centralizing query-related code.

src/app/features/asset-list/stacks/sip10-token-asset-list/sip10-token-asset-list.tsx (1)

3-6: The updates to import Sip10TokenAssetDetails and useAlexCurrencyPriceAsMarketData from @leather-wallet/query are consistent with the PR's goal of centralizing query-related code.

src/app/pages/swap/swap.context.ts (1)

3-3: The update to import SwapAsset from @leather-wallet/query is consistent with the PR's goal of centralizing query-related code.

src/app/store/transactions/contract-call.hooks.ts (1)

5-5: The integration of useNextNonce to fetch the nonce for transactions is a good addition, ensuring that transactions are always up-to-date with the latest nonce.

Also applies to: 20-20

src/app/common/hooks/account/use-account-names.ts (1)

3-3: The update to use useGetBnsNamesOwnedByAddressQuery from @leather-wallet/query is well-integrated and aligns with the PR's goal to centralize query logic.

Also applies to: 13-13, 24-24

src/app/pages/swap/components/swap-asset-dialog/components/swap-asset-item.tsx (1)

3-3: Ensure the new imports from @leather-wallet/query are correctly utilized in the component.

src/app/pages/send/send-crypto-asset-form/form/sip10/sip10-token-send-form.tsx (1)

4-4: Refactor to use the new hooks from @leather-wallet/query for better integration with the updated query package.

Also applies to: 9-9, 22-23

src/app/store/transactions/post-conditions.hooks.ts (1)

6-7: Correctly updated to use isFtAsset and useGetFungibleTokenMetadataQuery from @leather-wallet/query.

src/app/store/submitted-transactions/submitted-transactions.hooks.ts (1)

Line range hint 27-39: This hook is well-implemented and uses useMemo appropriately to optimize performance.

src/app/common/hooks/balance/use-total-balance.tsx (1)

Line range hint 3-39: The useTotalBalance hook is well-implemented, making good use of useMemo to optimize performance.

src/app/pages/send/send-crypto-asset-form/components/recipient-fields/recipient-bns-name-type-field.tsx (1)

Line range hint 5-43: The RecipientBnsNameTypeField component is well-implemented, effectively managing state and form interactions.

src/app/pages/home/components/send-button.tsx (1)

6-7: LGTM! The updated imports from @leather-wallet/query align with the PR's goal to centralize query handling.

src/app/pages/send/send-crypto-asset-form/form/stacks/use-stacks-common-send-form.tsx (1)

5-5: LGTM! The refactoring to use useNextNonce and useCurrentStacksAccountAddress directly improves maintainability and aligns with the PR's objectives.

Also applies to: 31-32, 61-61

src/app/pages/swap/hooks/use-swap-form.tsx (1)

5-5: LGTM! The refactoring to use useNextNonce and useCurrentStacksAccountAddress directly improves maintainability and aligns with the PR's objectives.

Also applies to: 11-11, 24-25

src/app/features/collectibles/collectibles.tsx (1)

54-54: LGTM! The change to pass address instead of account to StacksCryptoAssets simplifies data handling and aligns with the PR's objectives.

src/app/features/activity-list/components/transaction-list/stacks-transaction/ft-transfer-item.tsx (1)

4-4: Updated imports to use centralized query logic from @leather-wallet/query.

src/app/pages/send/send-crypto-asset-form/form/sip10/use-sip10-send-form.tsx (1)

7-7: Updated to use useCalculateStacksTxFees from @leather-wallet/query for centralized fee calculation.

src/app/common/hooks/use-key-actions.ts (1)

28-28: Initialization order of stxClient and btcClient swapped to align with best practices.

src/app/pages/swap/components/swap-asset-dialog/components/swap-asset-list.tsx (1)

8-8: Updated imports to use centralized utility functions from @leather-wallet/query.

src/app/features/stacks-transaction-request/hooks/use-transaction-error.ts (1)

7-7: Updated imports to use centralized query logic from @leather-wallet/query.

src/app/pages/send/send-crypto-asset-form/form/stx/use-stx-send-form.tsx (2)

6-10: Updated imports to use centralized query logic from @leather-wallet/query.


38-40: Refactored to use useCurrentStacksAccountAddress and useStacksValidateFeeByNonce for managing STX transaction form state.

src/app/pages/swap/components/swap-details/swap-details.tsx (2)

5-5: Updated import to use useGetStackNetworkBlockTimeQuery from @leather-wallet/query for centralized query logic.


40-40: Utilized useGetStackNetworkBlockTimeQuery to fetch block time for estimating transaction confirmation time.

src/app/pages/receive/components/receive-tokens.tsx (2)

7-7: Updated import to use useAlexSwappableAssets from @leather-wallet/query for centralized query logic.


40-40: Utilized useAlexSwappableAssets to fetch swappable assets based on the STX address.

src/app/features/stacks-transaction-request/hooks/use-stacks-transaction-summary.ts (3)

14-17: Imports updated to use centralized query handling from @leather-wallet/query.


38-38: Usage of useGetStackNetworkBlockTimeQuery to fetch block time for transaction confirmation estimation is appropriate.


38-38: The integration of new hooks into the transaction summary logic is well-executed and enhances the module's functionality.

src/app/store/software-keys/software-key.actions.ts (2)

3-3: Imports updated to use centralized query handling from @leather-wallet/query.


46-46: The logic to check STX account balances using stxClient is correctly implemented.

src/app/features/activity-list/activity-list.tsx (3)

1-10: Imports updated to use centralized query handling from @leather-wallet/query.


17-18: Usage of useCurrentStacksAccountAddress and useUpdateSubmittedTransactions to manage and update transaction states is appropriate.


77-79: The useEffect hook logic to update submitted transactions based on mempool data is correctly implemented and crucial for UI accuracy.

src/app/store/transactions/transaction.hooks.ts (3)

17-17: Ensure useNextNonce is used correctly across the file.


48-48: Verify that nextNonce is being handled correctly in the context of transaction nonce management.

Verification successful

The search results indicate that nextNonce is being used in multiple files across the codebase, including the file under review (src/app/store/transactions/transaction.hooks.ts). The handling of nextNonce appears consistent, with it being used to set the nonce value in various contexts.

  • src/app/store/transactions/transaction.hooks.ts: The nextNonce is used to set the nonce value, ensuring that if nextNonce?.nonce is undefined, a default value of 0 is used.
  • Other files also show similar patterns of using nextNonce to set the nonce value.

Based on the search results, it appears that nextNonce is being handled correctly in the context of transaction nonce management.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify correct handling of `nextNonce` across the file.
rg --type python $'nextNonce'

Length of output: 59



Script:

#!/bin/bash
# Description: Verify correct handling of `nextNonce` across the file.
rg --type typescript 'nextNonce'

Length of output: 67



Script:

#!/bin/bash
# Description: Verify correct handling of `nextNonce` across the file.
rg --type ts 'nextNonce'

Length of output: 3304


107-108: Check for potential data races with nextNonce usage.

src/app/store/transactions/token-transfer.hooks.ts (4)

20-20: Ensure useNextNonce is used correctly across the file.


85-85: Ensure that nextNonce is used correctly, especially in the context of fungible token transfers.


38-39: Verify that nextNonce is being handled correctly in the context of token transfer nonce management.

Verification successful

The search results indicate that nextNonce is used in multiple files, including token-transfer.hooks.ts, transaction.hooks.ts, contract-call.hooks.ts, and others. Specifically, in token-transfer.hooks.ts, nextNonce is used in the following contexts:

  • Line 38: const { data: nextNonce } = useNextNonce(account?.address ?? '');
  • Line 39: const network = useCurrentStacksNetworkState();
  • Line 42: nonce: Number(values?.nonce) ?? nextNonce?.nonce,
  • Line 43: [account, nextNonce, network]
  • Line 45: [values, network, account, nextNonce]
  • Line 47: nonce: Number(values?.nonce) ?? nextNonce?.nonce,
  • Line 48: nextNonce?.nonce

These usages suggest that nextNonce is being correctly handled in the context of token transfer nonce management, ensuring that the nonce is either taken from the form values or defaults to nextNonce?.nonce.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify correct handling of `nextNonce` across the file.
rg --type python $'nextNonce'

Length of output: 59



Script:

#!/bin/bash
# Description: Verify correct handling of `nextNonce` across the file.
rg --type typescript 'nextNonce'

Length of output: 67



Script:

#!/bin/bash
# Description: Verify correct handling of `nextNonce` across the file.
rg --type ts 'nextNonce'

Length of output: 3304


72-73: Check for potential data races with nextNonce usage.

src/app/pages/transaction-request/transaction-request.tsx (3)

9-13: Ensure new hooks are integrated correctly and check for any potential side effects.


38-38: Verify that useCurrentStacksAccountAddress is used correctly in the transaction request context.


54-56: Check for correct usage of useStxAvailableUnlockedBalance and useNextNonce in the transaction request flow.

Verification successful

The search results show multiple instances of useStxAvailableUnlockedBalance and useNextNonce across various files in the codebase. Here are the relevant findings for the transaction-request.tsx file:

  • useStxAvailableUnlockedBalance is used to get the available unlocked balance for a given address.
  • useNextNonce is used to get the next nonce for a given address.

These hooks are used in a similar manner in other parts of the codebase, indicating consistent usage patterns.

Relevant Locations:

  • src/app/pages/transaction-request/transaction-request.tsx
    • useStxAvailableUnlockedBalance is used on line 55.
    • useNextNonce is used on line 56.

Other Instances:

  • src/app/features/stacks-transaction-request/stacks-transaction-signer.tsx
  • src/app/features/dialogs/increase-fee-dialog/increase-stx-fee-dialog.tsx
  • src/app/store/transactions/transaction.hooks.ts
  • src/app/store/transactions/token-transfer.hooks.ts
  • src/app/store/transactions/contract-call.hooks.ts

Based on the consistent usage patterns observed, the usage of useStxAvailableUnlockedBalance and useNextNonce in transaction-request.tsx appears to be correct.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify correct usage of `useStxAvailableUnlockedBalance` and `useNextNonce`.
rg --type python $'useStxAvailableUnlockedBalance|useNextNonce'

Length of output: 95



Script:

#!/bin/bash
# Description: Verify correct usage of `useStxAvailableUnlockedBalance` and `useNextNonce`.
rg --type typescript 'useStxAvailableUnlockedBalance|useNextNonce'

Length of output: 103



Script:

#!/bin/bash
# Description: Verify correct usage of `useStxAvailableUnlockedBalance` and `useNextNonce`.
fd -e ts -e tsx | xargs rg 'useStxAvailableUnlockedBalance|useNextNonce'

Length of output: 3850

src/app/features/stacks-transaction-request/transaction-error/error-messages.tsx (3)

7-7: Ensure useStxAvailableUnlockedBalance is used correctly across the file.


18-18: Verify that useCurrentStacksAccountAddress is used correctly in the context of error handling.


64-65: Check for correct usage of useStxAvailableUnlockedBalance and useCurrentStacksAccountAddress in the context of insufficient funds error messages.

Verification successful

The hooks useStxAvailableUnlockedBalance and useCurrentStacksAccountAddress are used correctly in the context of handling insufficient funds error messages in transaction-error/error-messages.tsx. The code retrieves the current STX address and the available unlocked balance, which are then used to display an appropriate error message when the balance is insufficient.

  • useCurrentStacksAccountAddress is used to get the current STX address.
  • useStxAvailableUnlockedBalance is used to get the available unlocked balance for that address.

These hooks are used within the StxTransferInsufficientFundsErrorMessage component to provide relevant information for the error message.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify correct usage of `useStxAvailableUnlockedBalance` and `useCurrentStacksAccountAddress`.
rg --type python $'useStxAvailableUnlockedBalance|useCurrentStacksAccountAddress'

Length of output: 113



Script:

#!/bin/bash
# Description: Verify correct usage of `useStxAvailableUnlockedBalance` and `useCurrentStacksAccountAddress` in TypeScript files.
rg --type tsx 'useStxAvailableUnlockedBalance|useCurrentStacksAccountAddress'

Length of output: 107



Script:

#!/bin/bash
# Description: Verify correct usage of `useStxAvailableUnlockedBalance` and `useCurrentStacksAccountAddress` in TypeScript files.
rg --glob '*.ts' --glob '*.tsx' 'useStxAvailableUnlockedBalance|useCurrentStacksAccountAddress'

Length of output: 7185



Script:

#!/bin/bash
# Description: Extract relevant code from `transaction-error/error-messages.tsx` to verify the usage of `useStxAvailableUnlockedBalance` and `useCurrentStacksAccountAddress`.
rg -A 10 -B 10 'useStxAvailableUnlockedBalance|useCurrentStacksAccountAddress' src/app/features/stacks-transaction-request/transaction-error/error-messages.tsx

Length of output: 2424

src/app/features/stacks-transaction-request/stacks-transaction-signer.tsx (1)

35-35: Ensure that the new hooks integrate correctly with the existing logic.

Also applies to: 62-63, 65-65

Verification successful

The new hooks useCurrentStacksAccountAddress, useStxAvailableUnlockedBalance, and useNextNonce are widely integrated across various files in the codebase. The integration appears consistent and thorough.

  • Files with useCurrentStacksAccountAddress:

    • src/app/components/nonce-setter.tsx
    • src/app/components/transaction/token-transfer-icon.tsx
    • src/app/pages/home/components/send-button.tsx
    • src/app/pages/transaction-request/transaction-request.tsx
    • src/app/pages/send/send-crypto-asset-form/form/stx/use-stx-send-form.tsx
    • src/app/pages/send/send-crypto-asset-form/form/sip10/sip10-token-send-form.tsx
    • src/app/pages/send/send-crypto-asset-form/form/stacks/use-stacks-common-send-form.tsx
    • src/app/pages/swap/hooks/use-swap-form.tsx
    • src/app/pages/swap/hooks/use-alex-swap.tsx
    • src/app/pages/receive/receive-dialog.tsx
    • src/app/features/stacks-transaction-request/stacks-transaction-signer.tsx
    • src/app/features/stacks-transaction-request/transaction-error/error-messages.tsx
    • src/app/features/stacks-transaction-request/contract-deploy-details/contract-deploy-details.tsx
    • src/app/features/dialogs/increase-fee-dialog/increase-stx-fee-dialog.tsx
    • src/app/features/activity-list/activity-list.tsx
  • Files with useStxAvailableUnlockedBalance:

    • src/app/pages/transaction-request/transaction-request.tsx
    • src/app/pages/send/send-crypto-asset-form/form/stx/use-stx-send-form.tsx
    • src/app/features/stacks-transaction-request/stacks-transaction-signer.tsx
    • src/app/features/stacks-transaction-request/transaction-error/error-messages.tsx
    • src/app/features/dialogs/increase-fee-dialog/increase-stx-fee-dialog.tsx
  • Files with useNextNonce:

    • src/app/components/nonce-setter.tsx
    • src/app/pages/transaction-request/transaction-request.tsx
    • src/app/pages/send/send-crypto-asset-form/form/stacks/use-stacks-common-send-form.tsx
    • src/app/pages/swap/hooks/use-swap-form.tsx
    • src/app/features/stacks-transaction-request/stacks-transaction-signer.tsx

The hooks are integrated into the transaction signing process and other related functionalities. The integration seems consistent across the codebase.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the integration of new hooks in the transaction signing process.

# Test: Search for the usage of `useCurrentStacksAccountAddress`, `useStxAvailableUnlockedBalance`, and `useNextNonce`.
rg --type typescript $'useCurrentStacksAccountAddress|useStxAvailableUnlockedBalance|useNextNonce'

Length of output: 134



Script:

#!/bin/bash
# Description: Verify the integration of new hooks in the transaction signing process.

# Test: Search for the usage of `useCurrentStacksAccountAddress`, `useStxAvailableUnlockedBalance`, and `useNextNonce`.
rg --type ts,tsx 'useCurrentStacksAccountAddress|useStxAvailableUnlockedBalance|useNextNonce'

Length of output: 126



Script:

#!/bin/bash
# Description: Verify the integration of new hooks in the transaction signing process.

# Test: Search for the usage of `useCurrentStacksAccountAddress`, `useStxAvailableUnlockedBalance`, and `useNextNonce`.
rg --type ts 'useCurrentStacksAccountAddress|useStxAvailableUnlockedBalance|useNextNonce'
rg --type tsx 'useCurrentStacksAccountAddress|useStxAvailableUnlockedBalance|useNextNonce'

Length of output: 9378



Script:

#!/bin/bash
# Description: Verify the integration of new hooks in the transaction signing process.

# Test: Search for the usage of `useCurrentStacksAccountAddress`, `useStxAvailableUnlockedBalance`, and `useNextNonce` in TSX files.
rg --type tsx 'useCurrentStacksAccountAddress|useStxAvailableUnlockedBalance|useNextNonce'

Length of output: 120



Script:

#!/bin/bash
# Description: Verify the integration of new hooks in the transaction signing process.

# Test: Search for the usage of `useCurrentStacksAccountAddress`, `useStxAvailableUnlockedBalance`, and `useNextNonce` in TSX files.
rg --type tsx --glob '*.tsx' 'useCurrentStacksAccountAddress|useStxAvailableUnlockedBalance|useNextNonce'

Length of output: 135



Script:

#!/bin/bash
# Description: Verify the integration of new hooks in the transaction signing process.

# Test: Search for the usage of `useCurrentStacksAccountAddress`, `useStxAvailableUnlockedBalance`, and `useNextNonce` in TSX files.
rg --glob '*.tsx' 'useCurrentStacksAccountAddress|useStxAvailableUnlockedBalance|useNextNonce'

Length of output: 6974

src/app/features/dialogs/increase-fee-dialog/increase-stx-fee-dialog.tsx (1)

23-23: Ensure that the new hooks integrate correctly with the existing logic.

Also applies to: 47-48

Verification successful

The hooks useCurrentStacksAccountAddress and useStxAvailableUnlockedBalance are indeed used in the increase-stx-fee-dialog.tsx file, as well as in several other files across the codebase. This confirms that the hooks are integrated and utilized within the project.

  • useCurrentStacksAccountAddress is used in src/app/features/dialogs/increase-fee-dialog/increase-stx-fee-dialog.tsx on line 23.
  • useStxAvailableUnlockedBalance is used in the same file.

These usages indicate that the hooks are correctly imported and utilized in the increase-stx-fee-dialog.tsx file.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the integration of new hooks in the fee increase dialog.

# Test: Search for the usage of `useCurrentStacksAccountAddress` and `useStxAvailableUnlockedBalance`.
rg --type typescript $'useCurrentStacksAccountAddress|useStxAvailableUnlockedBalance'

Length of output: 121



Script:

#!/bin/bash
# Description: Verify the integration of new hooks in the fee increase dialog.

# Test: Search for the usage of `useCurrentStacksAccountAddress` and `useStxAvailableUnlockedBalance`.
rg --type ts,tsx 'useCurrentStacksAccountAddress|useStxAvailableUnlockedBalance'

Length of output: 113



Script:

#!/bin/bash
# Description: Verify the integration of new hooks in the fee increase dialog.

# Test: Search for the usage of `useCurrentStacksAccountAddress` and `useStxAvailableUnlockedBalance`.
rg -t ts -t tsx 'useCurrentStacksAccountAddress|useStxAvailableUnlockedBalance'

Length of output: 109



Script:

#!/bin/bash
# Description: Verify the integration of new hooks in the fee increase dialog.

# Test: Search for the usage of `useCurrentStacksAccountAddress` and `useStxAvailableUnlockedBalance`.
rg --glob '*.ts' --glob '*.tsx' 'useCurrentStacksAccountAddress|useStxAvailableUnlockedBalance'

Length of output: 7185

src/app/pages/swap/alex-swap-container.tsx (1)

14-14: Ensure that the new hook defaultSwapFee integrates correctly with the existing logic.

Verification successful

The defaultSwapFee is correctly imported and used in the alex-swap-container.tsx file. Specifically, it is used to set the fee property, ensuring the integration is correct.

  • src/app/pages/swap/alex-swap-container.tsx:
    • Line: import { defaultSwapFee } from '@leather-wallet/query';
    • Line: fee: isSponsoredByAlex ? '0' : defaultSwapFee.amount.toString(),
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the integration of the `defaultSwapFee` hook in the swap container.

# Test: Search for the usage of `defaultSwapFee`.
rg --type typescript $'defaultSwapFee'

Length of output: 72



Script:

#!/bin/bash
# Description: Verify the integration of the `defaultSwapFee` hook in the swap container.

# Test: Search for the usage of `defaultSwapFee` in TypeScript files.
rg 'defaultSwapFee' --glob '*.ts' --glob '*.tsx'

Length of output: 261

@@ -28,7 +27,7 @@ export function useTransactionError() {
const { values } = useFormikContext<StacksTransactionFormValues>();

const currentAccount = useCurrentStacksAccount();
const availableUnlockedBalance = useCurrentStxAvailableUnlockedBalance();
const availableUnlockedBalance = useStxAvailableUnlockedBalance(currentAccount?.address ?? '');
Copy link

Choose a reason for hiding this comment

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

Remove void from the return type to resolve the type issue flagged by static analysis.

- return useMemo<TransactionErrorReason | void>(() => {
+ return useMemo<TransactionErrorReason | undefined>(() => {

Committable suggestion was skipped due to low confidence.

Comment on lines 18 to 23
submittedTransactions.map(tx => {
if (pendingTxids.includes(safelyFormatHexTxid(tx.txId)))
return submittedTransactionsActions.transactionEnteredMempool(tx.txId);
return;
});
Copy link

Choose a reason for hiding this comment

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

Consider using forEach instead of map.

The map function is used here to iterate over transactions and perform side effects without returning a new array. This is semantically incorrect as map is intended for transformations. Use forEach for side effects:

- submittedTransactions.map(tx => {
+ submittedTransactions.forEach(tx => {
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
submittedTransactions.map(tx => {
if (pendingTxids.includes(safelyFormatHexTxid(tx.txId)))
return submittedTransactionsActions.transactionEnteredMempool(tx.txId);
return;
});
submittedTransactions.forEach(tx => {
if (pendingTxids.includes(safelyFormatHexTxid(tx.txId)))
return submittedTransactionsActions.transactionEnteredMempool(tx.txId);
return;
});

Comment on lines +3 to +6
import {
useGetBnsNamesOwnedByAddressQuery,
useStacksNonFungibleTokensMetadata,
} from '@leather-wallet/query';
Copy link

Choose a reason for hiding this comment

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

The updates to use centralized query hooks are correctly implemented. However, using array indices as keys in React lists can lead to issues with rendering and state management.

- {stacksNftsMetadataResp.map((nft, i) => {
-   if (!nft || !nft.metadata) return null;
-   return <StacksNonFungibleTokens key={i} metadata={nft.metadata} />;
- })}
+ {stacksNftsMetadataResp.map((nft) => {
+   if (!nft || !nft.metadata) return null;
+   return <StacksNonFungibleTokens key={nft.id} metadata={nft.metadata} />;
+ })}

Also applies to: 15-15, 18-18, 20-20, 34-34

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import {
useGetBnsNamesOwnedByAddressQuery,
useStacksNonFungibleTokensMetadata,
} from '@leather-wallet/query';
import {
useGetBnsNamesOwnedByAddressQuery,
useStacksNonFungibleTokensMetadata,
} from '@leather-wallet/query';
{stacksNftsMetadataResp.map((nft) => {
if (!nft || !nft.metadata) return null;
return <StacksNonFungibleTokens key={nft.id} metadata={nft.metadata} />;
})}

@@ -1,19 +1,37 @@
import { cvToString, deserializeCV, getCVTypeString } from '@stacks/transactions';

import { useContractFunction } from '@leather-wallet/query';
Copy link

Choose a reason for hiding this comment

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

The updates and new imports enhance the functionality of the component. However, the unnecessary use of React fragments should be removed to simplify the JSX structure.

- name={<>{contractFunction?.args[index].name || 'unknown'}</>}
+ name={contractFunction?.args[index].name || 'unknown'}

Also applies to: 9-9, 16-16, 18-18, 19-19, 23-23, 25-25, 26-26, 27-27, 28-28, 29-29, 30-30, 31-31, 32-32, 33-33, 34-34

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { useContractFunction } from '@leather-wallet/query';
import { useContractFunction } from '@leather-wallet/query';
// Assuming the JSX structure is something like this:
const FunctionArgumentItem = ({ contractFunction, index }) => {
return (
<div>
<span>
name={contractFunction?.args[index].name || 'unknown'}
</span>
{/* Other JSX elements */}
</div>
);
};

@fbwoolf fbwoolf force-pushed the feat/stacks-query-pkg branch from e10cc52 to 5372d8d Compare June 10, 2024 16:49
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Outside diff range and nitpick comments (3)
src/app/pages/swap/hooks/use-alex-swap.tsx (1)

Line range hint 29-29: Replace isNaN with Number.isNaN for safer type checking.

- const amountAsBigInt = isNaN(Number(amount)) ? BigInt(0) : BigInt(amount);
+ const amountAsBigInt = Number.isNaN(Number(amount)) ? BigInt(0) : BigInt(amount);
src/app/common/hooks/use-key-actions.ts (1)

Line range hint 37-37: Remove redundant double-negation for cleaner logic.

- if (!!defaultKeyDetails) {
+ if (defaultKeyDetails) {
src/app/features/stacks-transaction-request/stacks-transaction-signer.tsx (1)

Line range hint 69-69: The comma operator is used in a confusing way.

- void analytics.track('view_transaction_signing'), [analytics];
+ void analytics.track('view_transaction_signing');

The comma operator can lead to unclear code by obscuring side effects. It's better to separate statements clearly.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e10cc52 and 5372d8d.

Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !pnpm-lock.yaml
Files selected for processing (57)
  • package.json (1 hunks)
  • src/app/app.tsx (1 hunks)
  • src/app/common/asset-utils.ts (1 hunks)
  • src/app/common/hooks/account/use-account-names.ts (1 hunks)
  • src/app/common/hooks/account/use-refresh-all-account-data.ts (1 hunks)
  • src/app/common/hooks/balance/use-total-balance.tsx (1 hunks)
  • src/app/common/hooks/use-key-actions.ts (1 hunks)
  • src/app/components/balance/stx-balance.tsx (1 hunks)
  • src/app/components/loaders/sip10-tokens-loader.tsx (1 hunks)
  • src/app/components/loaders/stx-balance-loader.tsx (1 hunks)
  • src/app/components/loaders/stx20-tokens-loader.tsx (1 hunks)
  • src/app/components/nonce-setter.tsx (1 hunks)
  • src/app/features/activity-list/activity-list.tsx (3 hunks)
  • src/app/features/activity-list/components/transaction-list/stacks-transaction/ft-transfer-item.tsx (2 hunks)
  • src/app/features/activity-list/components/transaction-list/stacks-transaction/stx-transfer-item.tsx (2 hunks)
  • src/app/features/asset-list/stacks/sip10-token-asset-list/sip10-token-asset-list-unsupported.tsx (1 hunks)
  • src/app/features/asset-list/stacks/sip10-token-asset-list/sip10-token-asset-list.tsx (1 hunks)
  • src/app/features/collectibles/collectibles.tsx (1 hunks)
  • src/app/features/collectibles/components/stacks/stacks-crypto-assets.tsx (2 hunks)
  • src/app/features/dialogs/increase-fee-dialog/hooks/use-selected-tx.ts (1 hunks)
  • src/app/features/dialogs/increase-fee-dialog/increase-stx-fee-dialog.tsx (3 hunks)
  • src/app/features/settings/network/network-list-item.tsx (1 hunks)
  • src/app/features/stacks-message-signer/components/clarity-value-list.tsx (1 hunks)
  • src/app/features/stacks-transaction-request/contract-call-details/function-argument-item.tsx (1 hunks)
  • src/app/features/stacks-transaction-request/hooks/use-stacks-transaction-summary.ts (2 hunks)
  • src/app/features/stacks-transaction-request/hooks/use-transaction-error.ts (3 hunks)
  • src/app/features/stacks-transaction-request/stacks-transaction-signer.tsx (3 hunks)
  • src/app/features/stacks-transaction-request/transaction-error/error-messages.tsx (3 hunks)
  • src/app/pages/home/components/send-button.tsx (1 hunks)
  • src/app/pages/receive/components/receive-tokens.tsx (2 hunks)
  • src/app/pages/send/send-crypto-asset-form/components/recipient-fields/hooks/use-recipient-bns-name.tsx (1 hunks)
  • src/app/pages/send/send-crypto-asset-form/components/recipient-fields/recipient-bns-name-type-field.tsx (1 hunks)
  • src/app/pages/send/send-crypto-asset-form/family/bitcoin/components/bitcoin-recipient-field.tsx (1 hunks)
  • src/app/pages/send/send-crypto-asset-form/family/stacks/components/stacks-recipient-field.tsx (1 hunks)
  • src/app/pages/send/send-crypto-asset-form/form/sip10/sip10-token-send-form.tsx (2 hunks)
  • src/app/pages/send/send-crypto-asset-form/form/sip10/use-sip10-send-form.tsx (1 hunks)
  • src/app/pages/send/send-crypto-asset-form/form/stacks/use-stacks-common-send-form.tsx (4 hunks)
  • src/app/pages/send/send-crypto-asset-form/form/stx/use-stx-send-form.tsx (3 hunks)
  • src/app/pages/swap/alex-swap-container.tsx (2 hunks)
  • src/app/pages/swap/components/swap-asset-dialog/components/swap-asset-item.tsx (1 hunks)
  • src/app/pages/swap/components/swap-asset-dialog/components/swap-asset-list.tsx (2 hunks)
  • src/app/pages/swap/components/swap-details/swap-details.tsx (3 hunks)
  • src/app/pages/swap/hooks/use-alex-swap.tsx (2 hunks)
  • src/app/pages/swap/hooks/use-swap-form.tsx (2 hunks)
  • src/app/pages/swap/swap.context.ts (1 hunks)
  • src/app/pages/transaction-request/transaction-request.tsx (3 hunks)
  • src/app/query/common/remote-config/remote-config.query.ts (1 hunks)
  • src/app/query/query-config.ts (1 hunks)
  • src/app/store/accounts/blockchain/stacks/stacks-account.models.ts (2 hunks)
  • src/app/store/common/api-clients.hooks.ts (2 hunks)
  • src/app/store/software-keys/software-key.actions.ts (3 hunks)
  • src/app/store/submitted-transactions/submitted-transactions.hooks.ts (1 hunks)
  • src/app/store/transactions/contract-call.hooks.ts (1 hunks)
  • src/app/store/transactions/post-conditions.hooks.ts (1 hunks)
  • src/app/store/transactions/raw.hooks.ts (2 hunks)
  • src/app/store/transactions/token-transfer.hooks.ts (4 hunks)
  • src/app/store/transactions/transaction.hooks.ts (4 hunks)
Files not processed due to max files limit (5)
  • src/shared/constants.ts
  • src/shared/models/account.model.ts
  • src/shared/models/api-types.ts
  • src/shared/models/contract-types.ts
  • tests/mocks/mock-apis.ts
Files skipped from review due to trivial changes (4)
  • src/app/components/loaders/sip10-tokens-loader.tsx
  • src/app/components/nonce-setter.tsx
  • src/app/pages/receive/components/receive-tokens.tsx
  • src/app/pages/send/send-crypto-asset-form/form/stacks/use-stacks-common-send-form.tsx
Files skipped from review as they are similar to previous changes (44)
  • package.json
  • src/app/app.tsx
  • src/app/common/hooks/account/use-account-names.ts
  • src/app/common/hooks/account/use-refresh-all-account-data.ts
  • src/app/common/hooks/balance/use-total-balance.tsx
  • src/app/components/balance/stx-balance.tsx
  • src/app/components/loaders/stx-balance-loader.tsx
  • src/app/components/loaders/stx20-tokens-loader.tsx
  • src/app/features/activity-list/activity-list.tsx
  • src/app/features/activity-list/components/transaction-list/stacks-transaction/ft-transfer-item.tsx
  • src/app/features/asset-list/stacks/sip10-token-asset-list/sip10-token-asset-list-unsupported.tsx
  • src/app/features/asset-list/stacks/sip10-token-asset-list/sip10-token-asset-list.tsx
  • src/app/features/collectibles/collectibles.tsx
  • src/app/features/dialogs/increase-fee-dialog/hooks/use-selected-tx.ts
  • src/app/features/dialogs/increase-fee-dialog/increase-stx-fee-dialog.tsx
  • src/app/features/settings/network/network-list-item.tsx
  • src/app/features/stacks-message-signer/components/clarity-value-list.tsx
  • src/app/features/stacks-transaction-request/hooks/use-stacks-transaction-summary.ts
  • src/app/features/stacks-transaction-request/transaction-error/error-messages.tsx
  • src/app/pages/home/components/send-button.tsx
  • src/app/pages/send/send-crypto-asset-form/components/recipient-fields/hooks/use-recipient-bns-name.tsx
  • src/app/pages/send/send-crypto-asset-form/components/recipient-fields/recipient-bns-name-type-field.tsx
  • src/app/pages/send/send-crypto-asset-form/family/bitcoin/components/bitcoin-recipient-field.tsx
  • src/app/pages/send/send-crypto-asset-form/family/stacks/components/stacks-recipient-field.tsx
  • src/app/pages/send/send-crypto-asset-form/form/sip10/sip10-token-send-form.tsx
  • src/app/pages/send/send-crypto-asset-form/form/sip10/use-sip10-send-form.tsx
  • src/app/pages/send/send-crypto-asset-form/form/stx/use-stx-send-form.tsx
  • src/app/pages/swap/alex-swap-container.tsx
  • src/app/pages/swap/components/swap-asset-dialog/components/swap-asset-item.tsx
  • src/app/pages/swap/components/swap-asset-dialog/components/swap-asset-list.tsx
  • src/app/pages/swap/components/swap-details/swap-details.tsx
  • src/app/pages/swap/hooks/use-swap-form.tsx
  • src/app/pages/swap/swap.context.ts
  • src/app/pages/transaction-request/transaction-request.tsx
  • src/app/query/common/remote-config/remote-config.query.ts
  • src/app/query/query-config.ts
  • src/app/store/accounts/blockchain/stacks/stacks-account.models.ts
  • src/app/store/common/api-clients.hooks.ts
  • src/app/store/software-keys/software-key.actions.ts
  • src/app/store/submitted-transactions/submitted-transactions.hooks.ts
  • src/app/store/transactions/contract-call.hooks.ts
  • src/app/store/transactions/raw.hooks.ts
  • src/app/store/transactions/token-transfer.hooks.ts
  • src/app/store/transactions/transaction.hooks.ts
Additional context used
Biome
src/app/features/collectibles/components/stacks/stacks-crypto-assets.tsx

[error] 39-39: Avoid using the index of an array as key property in an element. (lint/suspicious/noArrayIndexKey)

This is the source of the key value.

The order of the items may change, and this also affects performances and component state.
Check the React documentation.

src/app/features/stacks-transaction-request/contract-call-details/function-argument-item.tsx

[error] 37-37: Avoid using unnecessary Fragment. (lint/complexity/noUselessFragments)

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

src/app/pages/swap/hooks/use-alex-swap.tsx

[error] 29-29: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead. (lint/suspicious/noGlobalIsNan)

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

src/app/common/hooks/use-key-actions.ts

[error] 37-37: Avoid redundant double-negation. (lint/complexity/noExtraBooleanCast)

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

src/app/features/stacks-transaction-request/hooks/use-transaction-error.ts

[error] 32-32: void is not valid as a constituent in a union type (lint/suspicious/noConfusingVoidType)

Remove void

src/app/features/stacks-transaction-request/stacks-transaction-signer.tsx

[error] 69-69: The comma operator is disallowed. (lint/style/noCommaOperator)

Its use is often confusing and obscures side effects.

Additional comments not posted (12)
src/app/common/asset-utils.ts (2)

5-10: LGTM! The function migratePositiveAssetBalancesToTop effectively segregates assets based on their balance, aligning with the refactoring goals.


Line range hint 12-18: LGTM! The function convertAssetBalanceToFiat correctly handles the conversion of asset balances to fiat, ensuring that the market data and balance are valid before proceeding.

src/app/features/collectibles/components/stacks/stacks-crypto-assets.tsx (1)

3-6: LGTM! The updated imports from @leather-wallet/query centralize the query logic, aligning with the PR's refactoring goals.

src/app/features/stacks-transaction-request/contract-call-details/function-argument-item.tsx (1)

3-9: LGTM! The updated imports from @leather-wallet/query centralize the query logic, aligning with the PR's refactoring goals.

src/app/features/activity-list/components/transaction-list/stacks-transaction/stx-transfer-item.tsx (2)

12-13: LGTM! The new import for TxTransferIconWrapper is correctly implemented.


33-33: LGTM! The StxTransferItem function correctly handles the display of transaction details, ensuring accurate representation based on the account's role in the transaction.

src/app/store/transactions/post-conditions.hooks.ts (1)

6-6: Refactored to use centralized query logic for fungible token metadata.

src/app/pages/swap/hooks/use-alex-swap.tsx (1)

5-6: Refactored to use centralized query logic for swappable assets.

src/app/common/hooks/use-key-actions.ts (1)

28-28: Initialization order of blockchain clients adjusted for better clarity.

src/app/features/stacks-transaction-request/stacks-transaction-signer.tsx (3)

11-14: Refactored imports to use the new @leather-wallet/query package.

This change aligns with the PR's objective to centralize query-related code, enhancing maintainability.


35-35: Updated import to use useCurrentStacksAccountAddress from @app/store/accounts/blockchain/stacks/stacks-account.hooks.

This change is consistent with the refactoring strategy to use more specific hooks for better modularity and reusability.


62-65: Refactored to use useStxAvailableUnlockedBalance and useNextNonce from the new query package.

These changes are part of the ongoing effort to consolidate query logic into the @leather-wallet/query package, which should simplify future updates and bug fixes.

@@ -28,7 +27,7 @@ export function useTransactionError() {
const { values } = useFormikContext<StacksTransactionFormValues>();

const currentAccount = useCurrentStacksAccount();
const availableUnlockedBalance = useCurrentStxAvailableUnlockedBalance();
const availableUnlockedBalance = useStxAvailableUnlockedBalance(currentAccount?.address ?? '');

return useMemo<TransactionErrorReason | void>(() => {
Copy link

Choose a reason for hiding this comment

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

Replace void with undefined in the union type for correct type handling.

- return useMemo<TransactionErrorReason | void>(() => {
+ return useMemo<TransactionErrorReason | undefined>(() => {
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return useMemo<TransactionErrorReason | void>(() => {
return useMemo<TransactionErrorReason | undefined>(() => {
Tools
Biome

[error] 32-32: void is not valid as a constituent in a union type (lint/suspicious/noConfusingVoidType)

Remove void

@@ -29,7 +31,7 @@ export function StacksCryptoAssets({ account }: StacksCryptoAssetsProps) {

return (
<>
{names.map(name => (
{(names ?? []).map(name => (
Copy link

Choose a reason for hiding this comment

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

Avoid using array indices as keys in React lists to prevent issues with rendering and state management. Use unique identifiers instead.

- return <StacksNonFungibleTokens key={i} metadata={nft.metadata} />;
+ return <StacksNonFungibleTokens key={nft.id} metadata={nft.metadata} />;

Committable suggestion was skipped due to low confidence.

)}`
);
}

Copy link

Choose a reason for hiding this comment

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

Remove unnecessary React fragments to simplify the JSX structure.

- name={<>{contractFunction?.args[index].name || 'unknown'}</>}
+ name={contractFunction?.args[index].name || 'unknown'}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
name={contractFunction?.args[index].name || 'unknown'}

@fbwoolf fbwoolf force-pushed the feat/stacks-query-pkg branch 3 times, most recently from e9d6219 to 2442c7c Compare June 11, 2024 16:43
@fbwoolf fbwoolf force-pushed the feat/stacks-query-pkg branch from 2442c7c to caa3382 Compare June 11, 2024 17:14
@fbwoolf fbwoolf added this pull request to the merge queue Jun 11, 2024
Merged via the queue into dev with commit 9c67eaf Jun 11, 2024
30 checks passed
@fbwoolf fbwoolf deleted the feat/stacks-query-pkg branch June 11, 2024 17:24
Copy link

sentry-io bot commented Jun 19, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ TimeoutError: Promise timed out after 60000 milliseconds new Promise(<anonymous>) View Issue

Did you find this useful? React with a 👍 or 👎

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.

Fix formatting for transactions in submitted state in activity
5 participants