-
Notifications
You must be signed in to change notification settings - Fork 145
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
Conversation
Important Review skippedMore 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 WalkthroughThe updates primarily involve refactoring and reorganizing import statements across various files to consolidate functionality into the Changes
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
52c3b32
to
4a29ff1
Compare
src/app/pages/send/send-crypto-asset-form/form/stacks/use-stacks-common-send-form.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @fbwoolf 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 🚀 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested and lgtm
@fbwoolf once submit stx tx I don't see pending tx in activity, though see this (1st screenshot) |
Thx, will check this again, it was working ok but maybe something broke. 👀 |
87a0991
to
e10cc52
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
inmigratePositiveAssetBalancesToTop
and forasset.balance
andasset.marketData
inconvertAssetBalanceToFiat
to prevent runtime errors.src/app/pages/swap/hooks/use-alex-swap.tsx (1)
Line range hint
28-28
: ReplaceisNaN
withNumber.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
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 Fragmentsrc/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-negationsrc/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
: TheStacksRecipientField
component correctly utilizes thefetchNameOwner
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
: TheuseSelectedTx
hook correctly utilizes theuseTransactionById
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 forSoftwareStacksAccount
andHardwareStacksAccount
are clear and well-structured, extending theAccount
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 thestacksClient
import is consistent with the PR's objectives. Good use ofuseMemo
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
withinnonce-setter.tsx
has been confirmed.
useFormikContext
is imported and used within thenonce-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.tsxLength of output: 163
src/app/features/settings/network/network-list-item.tsx (1)
1-1
: Updated import ofuseNetworkStatus
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 ofSwapAsset
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 ofuseRemoteConfig
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 hookuseGetFungibleTokenMetadataQuery
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 fromuseCurrentStacksAccount()
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 3Length 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 theStacksClient
type is correctly used throughout the component.src/app/app.tsx (1)
29-29
: Integration ofLeatherQueryProvider
looks good. Ensure that thenetwork
andenvironment
props are correctly configured and passed.Verification successful
The integration of
LeatherQueryProvider
insrc/app/app.tsx
appears to be correctly configured. Thenetwork
andenvironment
props are properly passed, ensuring that theLeatherQueryProvider
is set up with the necessary context.
network
is assigned the value fromuseCurrentNetwork()
.environment
is configured withWALLET_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.tsxLength of output: 1028
src/app/pages/home/components/send-button.tsx (1)
4-4
: Updated imports foruseStxCryptoAssetBalance
anduseTransferableSip10Tokens
look good. Ensure that these hooks are used correctly in theSendButtonSuspense
function.Verification successful
The hooks
useStxCryptoAssetBalance
anduseTransferableSip10Tokens
are correctly imported and used in theSendButtonSuspense
function.
useStxCryptoAssetBalance
is used to get thestxBalance
.useTransferableSip10Tokens
is used to get thestacksFtAssets
.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.tsxLength 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.tsxLength 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 foruseNextNonce
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 thesrc/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 foruseNextNonce
looks good. Ensure that it is used correctly to fetch the nonce for the current address.Verification successful
The usage of
useNextNonce
insrc/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
: UpdatedStacksCryptoAssets
component to receiveaddress
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 useuseCalculateStacksTxFees
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 useisFtAsset
anduseGetFungibleTokenMetadataQuery
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 ofstxClient
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 ofuseStxAvailableUnlockedBalance
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 theaddress
variable are well-integrated. Ensure that the new hooks are fetching data correctly and that theaddress
variable is always defined in the contexts it is used.src/app/pages/swap/components/swap-details/swap-details.tsx (1)
39-39
: Use ofuseGetStackNetworkBlockTimeQuery
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 hookuseAlexSwappableAssets
is correctly fetching data as expected.Verification successful
The
useAlexSwappableAssets
hook is correctly imported and used in thereceive-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 ofuseAlexSwappableAssets
with thestxAddress
parameter.Verification successful
The
stxAddress
parameter is correctly passed and utilized in theuseAlexSwappableAssets
hook within thereceive-tokens.tsx
file. The search results confirm thatstxAddress
is used in multiple contexts, including being passed to theuseAlexSwappableAssets
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.tsxLength of output: 309
src/app/features/stacks-transaction-request/hooks/use-stacks-transaction-summary.ts (1)
37-37
: Verify the correct fetching and usage ofblockTime
fromuseGetStackNetworkBlockTimeQuery
.Verification successful
The verification confirms that
blockTime
is correctly fetched usinguseGetStackNetworkBlockTimeQuery
and is used in thegetEstimatedConfirmationTime
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 ofgetAccountBalance
fromstxClient
.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 ofuseCurrentStacksAccountAddress
anduseUpdateSubmittedTransactions
hooks aligns with the PR's goal to centralize and streamline hook usage.
49-50
: Correct use ofuseCurrentStacksAccountAddress
anduseUpdateSubmittedTransactions
for managing STX addresses and transaction updates.src/app/store/transactions/transaction.hooks.ts (2)
4-5
: The addition ofuseNextNonce
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 ofuseNextNonce
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 ofuseNextNonce
andstxToMicroStx
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
andstxToMicroStx
appears consistent and correct across the codebase. The functions are imported and utilized in various files, includingtransaction.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 ofuseNextNonce
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 whichuseNextNonce
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 usinguseNextNonce
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-20src/app/store/transactions/transaction.hooks.ts
: Lines around 10-30src/app/store/transactions/token-transfer.hooks.ts
: Lines around 10-40src/app/store/transactions/contract-call.hooks.ts
: Lines around 10-20src/app/pages/transaction-request/transaction-request.tsx
: Lines around 10-20src/app/pages/swap/hooks/use-swap-form.tsx
: Lines around 10-20src/app/pages/send/send-crypto-asset-form/form/stacks/use-stacks-common-send-form.tsx
: Lines around 10-20src/app/components/nonce-setter.tsx
: Lines around 10-20Scripts 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.tsxLength of output: 8219
src/app/pages/transaction-request/transaction-request.tsx (1)
6-9
: The use of hooks such asuseCalculateStacksTxFees
,useNextNonce
, anduseStxAvailableUnlockedBalance
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 useuseCurrentStacksAccountAddress
from@app/store/accounts/blockchain/stacks/stacks-account.hooks
.
63-64
: Refactored to useuseCurrentStacksAccountAddress
anduseStxAvailableUnlockedBalance
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
: ImporteduseCurrentStacksAccountAddress
to fetch the current Stacks account address.
61-64
: Refactored to useuseCurrentStacksAccountAddress
,useStxAvailableUnlockedBalance
, anduseNextNonce
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 useuseStxAvailableUnlockedBalance
from@leather-wallet/query
and utility functions from@leather-wallet/utils
.
22-22
: ImporteduseCurrentStacksAccountAddress
to fetch the current Stacks account address.
46-47
: Refactored to useuseCurrentStacksAccountAddress
anduseStxAvailableUnlockedBalance
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 functionsisDefined
andisUndefined
from@leather-wallet/utils
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
: ReplaceisNaN
withNumber.isNaN
.The use of
isNaN
can lead to unexpected results due to type coercion. UseNumber.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
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 Fragmentsrc/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-negationsrc/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 offetchBtcNameOwner
aligns with the PR's goal of centralizing query logic.
Line range hint
1-5
: TheTransferRecipientField
component correctly utilizes thefetchBtcNameOwner
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 ofuseTransactionById
from@leather-wallet/query
is consistent with the PR's goal of centralizing query logic.
Line range hint
1-6
: TheuseSelectedTx
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 functionisFetchedWithSuccess
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 forSoftwareStacksAccount
andHardwareStacksAccount
are clear and enhance the baseAccount
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 optimizeduseStacksClient
function withuseMemo
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 foruseStxCryptoAssetBalance
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 foruseAccountMempoolQuery
anduseCurrentStacksAccountAddress
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 foruseNextNonce
anduseCurrentStacksAccountAddress
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 functionmigratePositiveAssetBalancesToTop
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 ofuseStacksClient
from@leather-wallet/query
aligns with the PR's objective to centralize the query-related code.
19-31
: The use ofuseStacksClient
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 importuseNetworkStatus
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 importSip10TokenAssetDetails
anduseAlexCurrencyPriceAsMarketData
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 importSwapAsset
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 ofuseNextNonce
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 useuseGetBnsNamesOwnedByAddressQuery
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 useisFtAsset
anduseGetFungibleTokenMetadataQuery
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 usesuseMemo
appropriately to optimize performance.src/app/common/hooks/balance/use-total-balance.tsx (1)
Line range hint
3-39
: TheuseTotalBalance
hook is well-implemented, making good use ofuseMemo
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
: TheRecipientBnsNameTypeField
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 useuseNextNonce
anduseCurrentStacksAccountAddress
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 useuseNextNonce
anduseCurrentStacksAccountAddress
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 passaddress
instead ofaccount
toStacksCryptoAssets
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 useuseCalculateStacksTxFees
from@leather-wallet/query
for centralized fee calculation.src/app/common/hooks/use-key-actions.ts (1)
28-28
: Initialization order ofstxClient
andbtcClient
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 useuseCurrentStacksAccountAddress
anduseStacksValidateFeeByNonce
for managing STX transaction form state.src/app/pages/swap/components/swap-details/swap-details.tsx (2)
5-5
: Updated import to useuseGetStackNetworkBlockTimeQuery
from@leather-wallet/query
for centralized query logic.
40-40
: UtilizeduseGetStackNetworkBlockTimeQuery
to fetch block time for estimating transaction confirmation time.src/app/pages/receive/components/receive-tokens.tsx (2)
7-7
: Updated import to useuseAlexSwappableAssets
from@leather-wallet/query
for centralized query logic.
40-40
: UtilizeduseAlexSwappableAssets
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 ofuseGetStackNetworkBlockTimeQuery
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 usingstxClient
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 ofuseCurrentStacksAccountAddress
anduseUpdateSubmittedTransactions
to manage and update transaction states is appropriate.
77-79
: TheuseEffect
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
: EnsureuseNextNonce
is used correctly across the file.
48-48
: Verify thatnextNonce
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 ofnextNonce
appears consistent, with it being used to set thenonce
value in various contexts.
src/app/store/transactions/transaction.hooks.ts
: ThenextNonce
is used to set thenonce
value, ensuring that ifnextNonce?.nonce
is undefined, a default value of0
is used.- Other files also show similar patterns of using
nextNonce
to set thenonce
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 withnextNonce
usage.src/app/store/transactions/token-transfer.hooks.ts (4)
20-20
: EnsureuseNextNonce
is used correctly across the file.
85-85
: Ensure thatnextNonce
is used correctly, especially in the context of fungible token transfers.
38-39
: Verify thatnextNonce
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, includingtoken-transfer.hooks.ts
,transaction.hooks.ts
,contract-call.hooks.ts
, and others. Specifically, intoken-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 tonextNonce?.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 withnextNonce
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 thatuseCurrentStacksAccountAddress
is used correctly in the transaction request context.
54-56
: Check for correct usage ofuseStxAvailableUnlockedBalance
anduseNextNonce
in the transaction request flow.Verification successful
The search results show multiple instances of
useStxAvailableUnlockedBalance
anduseNextNonce
across various files in the codebase. Here are the relevant findings for thetransaction-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
anduseNextNonce
intransaction-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
: EnsureuseStxAvailableUnlockedBalance
is used correctly across the file.
18-18
: Verify thatuseCurrentStacksAccountAddress
is used correctly in the context of error handling.
64-65
: Check for correct usage ofuseStxAvailableUnlockedBalance
anduseCurrentStacksAccountAddress
in the context of insufficient funds error messages.Verification successful
The hooks
useStxAvailableUnlockedBalance
anduseCurrentStacksAccountAddress
are used correctly in the context of handling insufficient funds error messages intransaction-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.tsxLength 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
, anduseNextNonce
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
anduseStxAvailableUnlockedBalance
are indeed used in theincrease-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 insrc/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 hookdefaultSwapFee
integrates correctly with the existing logic.Verification successful
The
defaultSwapFee
is correctly imported and used in thealex-swap-container.tsx
file. Specifically, it is used to set thefee
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 ?? ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
submittedTransactions.map(tx => { | ||
if (pendingTxids.includes(safelyFormatHexTxid(tx.txId))) | ||
return submittedTransactionsActions.transactionEnteredMempool(tx.txId); | ||
return; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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; | |
}); |
import { | ||
useGetBnsNamesOwnedByAddressQuery, | ||
useStacksNonFungibleTokensMetadata, | ||
} from '@leather-wallet/query'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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> | |
); | |
}; |
e10cc52
to
5372d8d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
: ReplaceisNaN
withNumber.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
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 Fragmentsrc/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-negationsrc/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 functionmigratePositiveAssetBalancesToTop
effectively segregates assets based on their balance, aligning with the refactoring goals.
Line range hint
12-18
: LGTM! The functionconvertAssetBalanceToFiat
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 forTxTransferIconWrapper
is correctly implemented.
33-33
: LGTM! TheStxTransferItem
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 useuseCurrentStacksAccountAddress
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 useuseStxAvailableUnlockedBalance
anduseNextNonce
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>(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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 => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
)}` | ||
); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
name={contractFunction?.args[index].name || 'unknown'} |
2c7a233
to
5482af5
Compare
e9d6219
to
2442c7c
Compare
2442c7c
to
caa3382
Compare
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
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
Collectibles
component to handle account addresses more efficiently.Bug Fixes
Refactor
Chores