Skip to content

prep-release [wip]#702

Closed
kvhnuke wants to merge 31 commits intodevelopfrom
devop/release-v-2-7-0
Closed

prep-release [wip]#702
kvhnuke wants to merge 31 commits intodevelopfrom
devop/release-v-2-7-0

Conversation

@kvhnuke
Copy link
Contributor

@kvhnuke kvhnuke commented May 29, 2025

Summary by CodeRabbit

  • New Features

    • Added support for the new Ethereum-compatible Hemi network, including network configuration, explorer integration, and activity handling.
    • Enhanced transaction verification UI to display both sender and recipient addresses with identicons.
    • Improved address input fields to fully display short addresses without truncation across multiple components.
    • Introduced safer gas estimation for staking transactions on RSK networks to optimize transaction fees.
  • Chores

    • Updated multiple dependency and development tool versions across several packages to ensure compatibility and improved maintenance.
    • Refactored hardware wallet integrations to dynamically load Trezor Connect for better environment adaptability and initialization.
    • Updated styling for transaction verification labels for improved readability.

@coderabbitai
Copy link

coderabbitai bot commented May 29, 2025

Walkthrough

Multiple package.json files across the project were updated to bump dependency and devDependency versions to newer patch or minor releases. A new Ethereum-compatible network "Hemi" was added with its configuration, network enum entry, and activity handler integration. The Trezor hardware wallet integration was refactored to dynamically import and initialize TrezorConnect. Additionally, staking gas estimation logic was introduced for RSK networks, and UI enhancements were made to show recipient address identicons in transaction verification.

Changes

File(s) Change Summary
package.json Updated @swc/core devDependency version from ^1.11.24 to ^1.11.29.
packages/extension-bridge/package.json Bumped several devDependencies to newer patch/minor versions.
packages/extension/package.json Upgraded multiple dependencies/devDependencies, including Vue, Amplitude, Ledger, Polkadot, and various tools; bumped package version.
packages/hw-wallets/package.json Updated Ledger, Polkadot, Trezor, and Zondax dependencies and devDependencies; added @trezor/connect-web dependency; bumped package version.
packages/keyring/package.json Bumped @polkadot/util and several devDependencies to newer patch/minor versions.
packages/name-resolution/package.json Upgraded several devDependencies to newer patch/minor versions.
packages/request/package.json Updated multiple devDependencies to newer patch/minor versions.
packages/signers/bitcoin/package.json Bumped several devDependencies to newer patch versions.
packages/signers/ethereum/package.json Updated multiple devDependencies to newer patch/minor versions.
packages/signers/kadena/package.json Bumped @polkadot/util-crypto and several devDependencies to newer versions.
packages/signers/polkadot/package.json Upgraded @polkadot/util, @polkadot/util-crypto, and several devDependencies.
packages/storage/package.json Updated multiple devDependencies to newer patch/minor versions.
packages/swap/package.json Bumped several devDependencies to newer patch/minor versions.
packages/types/package.json Updated multiple devDependencies to newer patch/minor versions.
packages/utils/package.json Bumped @polkadot/util-crypto and several devDependencies to newer patch/minor versions.
packages/extension/src/providers/common/libs/new-features.ts Replaced newNetworks array to include only NetworkNames.Hemi instead of previous three networks.
packages/extension/src/providers/common/ui/styles/verify-transaction.less Added .provider-verify-transaction__label style; updated font styles and colors in .provider-verify-transaction__account-info-to.
packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts Added NetworkNames.Hemi with endpoint https://explorer.hemi.xyz/ to NetworkEndpoints mapping.
packages/extension/src/providers/ethereum/libs/transaction/gas-utils.ts Added collectiveGasConfig for RSK staking; introduced safeGasForStaking async function to adjust gas estimation for staking txns.
packages/extension/src/providers/ethereum/libs/transaction/index.ts Modified Transaction.finalizeTransaction to use safeGasForStaking for RSK legacy transactions matching staking method ID.
packages/extension/src/providers/ethereum/networks/hemi.ts Added new hemi network configuration as an EvmNetwork instance with metadata, RPC, explorer, and activity handler.
packages/extension/src/providers/ethereum/networks/index.ts Imported and registered hemi network in exported Ethereum networks object.
packages/extension/src/providers/ethereum/ui/eth-verify-transaction.vue Added "To" section showing recipient address and identicon; introduced identiconTo reactive variable; updated layout and favicon size.
packages/extension/src/providers/ethereum/ui/send-transaction/components/send-address-input.vue Updated visibleAddress computed property to show full address if length < 13 chars, regardless of focus.
packages/extension/src/providers/solana/ui/send-transaction/components/send-address-input.vue Changed address computed getter to return full address if focused or length < 13; else truncated with ellipsis.
packages/extension/src/ui/action/views/swap/components/send-address-input.vue Modified address computed getter to return full address if length < 13, bypassing ellipsis truncation.
packages/hw-wallets/src/trezor/bitcoin/index.ts Refactored to dynamically import TrezorConnect via getTrezorConnect; stored instance as class property; updated method calls accordingly.
packages/hw-wallets/src/trezor/ethereum/index.ts Refactored to use dynamic getTrezorConnect import; stored instance as class property; updated method calls and error handling.
packages/hw-wallets/src/trezor/solana/index.ts Refactored to use dynamic getTrezorConnect import; stored instance as class property; updated method calls and payload casting.
packages/hw-wallets/src/trezor/trezorConnect.ts Added async getTrezorConnect function to dynamically import and initialize TrezorConnect based on environment (webextension or web).
packages/types/src/networks.ts Added new enum member Hemi = "Hemi" to NetworkNames enum.

Possibly related PRs

  • Add Hemi #695: Adds the "Hemi" network with related configurations, network enum, and activity handler endpoints, overlapping on network additions.
  • Add safe buffer to Rootstock collective staking gas estimation #697: Introduces collectiveGasConfig and safeGasForStaking for RSK staking gas estimation, matching the gas-utils and transaction finalization changes.
  • Devop/trezor conditional #699: Refactors Trezor hardware wallet integration to dynamically import and initialize TrezorConnect, similar to the dynamic import and instance management changes here.

Suggested reviewers

  • gamalielhere
  • NickKelly1

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c17d693 and 013aedf.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (18)
  • packages/extension/package.json (6 hunks)
  • packages/extension/src/providers/common/libs/new-features.ts (1 hunks)
  • packages/extension/src/providers/common/ui/styles/verify-transaction.less (2 hunks)
  • packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts (1 hunks)
  • packages/extension/src/providers/ethereum/libs/transaction/gas-utils.ts (2 hunks)
  • packages/extension/src/providers/ethereum/libs/transaction/index.ts (2 hunks)
  • packages/extension/src/providers/ethereum/networks/hemi.ts (1 hunks)
  • packages/extension/src/providers/ethereum/networks/index.ts (2 hunks)
  • packages/extension/src/providers/ethereum/ui/eth-verify-transaction.vue (5 hunks)
  • packages/extension/src/providers/ethereum/ui/send-transaction/components/send-address-input.vue (1 hunks)
  • packages/extension/src/providers/solana/ui/send-transaction/components/send-address-input.vue (1 hunks)
  • packages/extension/src/ui/action/views/swap/components/send-address-input.vue (1 hunks)
  • packages/hw-wallets/package.json (4 hunks)
  • packages/hw-wallets/src/trezor/bitcoin/index.ts (6 hunks)
  • packages/hw-wallets/src/trezor/ethereum/index.ts (7 hunks)
  • packages/hw-wallets/src/trezor/solana/index.ts (4 hunks)
  • packages/hw-wallets/src/trezor/trezorConnect.ts (1 hunks)
  • packages/types/src/networks.ts (1 hunks)
✅ Files skipped from review due to trivial changes (4)
  • packages/extension/src/providers/ethereum/networks/index.ts
  • packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts
  • packages/extension/src/providers/ethereum/networks/hemi.ts
  • packages/hw-wallets/package.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/extension/package.json
🧰 Additional context used
🧬 Code Graph Analysis (2)
packages/hw-wallets/src/trezor/solana/index.ts (3)
packages/hw-wallets/src/types.ts (3)
  • getAddressRequest (74-76)
  • AddressResponse (31-34)
  • SolSignTransaction (61-63)
packages/hw-wallets/src/trezor/solana/configs.ts (1)
  • supportedPaths (8-8)
packages/utils/src/index.ts (1)
  • bufferToHex (38-38)
packages/extension/src/providers/ethereum/libs/transaction/index.ts (2)
packages/utils/src/index.ts (1)
  • numberToHex (46-46)
packages/extension/src/providers/ethereum/libs/transaction/gas-utils.ts (2)
  • collectiveGasConfig (247-247)
  • safeGasForStaking (246-246)
🪛 Biome (1.9.4)
packages/hw-wallets/src/trezor/trezorConnect.ts

[error] 4-4: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: buildAll
  • GitHub Check: test
  • GitHub Check: test
🔇 Additional comments (13)
packages/extension/src/providers/ethereum/ui/eth-verify-transaction.vue (4)

14-16: Good organizational improvement with clear section labeling.

The addition of the "FROM" comment and label improves code readability and user experience by clearly identifying the sender section.


40-40: Explicit sizing improves visual consistency.

Setting explicit width and height attributes for the favicon ensures consistent rendering across different browsers and prevents layout shifts.


83-96: Well-implemented "To" section enhances transaction visibility.

The new "To" section provides valuable UX by showing the recipient address and identicon, making it easier for users to verify transaction details. The structure follows the existing pattern used for the "From" section.


237-239: Correct implementation of recipient identicon generation.

The identicon generation for the recipient address is properly implemented within the transaction decoding flow. The use of toLowerCase() ensures consistency with address formatting.

packages/extension/src/providers/common/ui/styles/verify-transaction.less (1)

10-16: Well-structured label styling for improved UI consistency.

The new &__label style provides consistent typography and spacing for section labels, enhancing the visual hierarchy of the transaction verification interface.

packages/hw-wallets/src/trezor/trezorConnect.ts (1)

9-9: Verify the intentional difference in appUrl values.

The web extension configuration uses https://www.enkrypt.com while the web configuration uses http://www.myetherwallet.com. This inconsistency could be confusing.

Are these different appUrl values intentional? If so, consider adding a comment explaining why different URLs are used for different environments.

Also applies to: 22-22

packages/hw-wallets/src/trezor/bitcoin/index.ts (1)

29-29: LGTM! Dynamic TrezorConnect loading implemented correctly.

The refactoring to use instance-based TrezorConnect through dynamic loading is well implemented. The error handling with type casting is appropriate given the dynamic nature of the imports.

Also applies to: 38-38, 78-78, 93-93

packages/hw-wallets/src/trezor/ethereum/index.ts (1)

29-29: LGTM! Clean refactoring to dynamic TrezorConnect loading.

The implementation correctly follows the new pattern of asynchronous TrezorConnect initialization and instance-based usage. Error handling has been appropriately updated with type casting.

Also applies to: 38-38, 74-74, 96-96, 115-115

packages/hw-wallets/src/trezor/solana/index.ts (1)

40-41: Verify that address and publicKey should have the same value.

Both address and publicKey are set to the same base58 decoded value. In Solana, the address is typically the base58 representation of the public key, but the decoded values should represent different concepts.

Please confirm if this is the intended behavior or if publicKey should contain the actual public key bytes rather than the decoded address.

packages/types/src/networks.ts (2)

114-114: LGTM! Network addition looks correct.

The addition of Hemi = "Hemi" follows the established naming convention and is consistent with similar network entries.


117-182:

Details

❓ Verification inconclusive

Verify if CoingeckoPlatform entry is needed for Hemi.

The CoingeckoPlatform enum doesn't include an entry for the new Hemi network. Please confirm whether this is intentional or if Hemi should be added to the CoingeckoPlatform enum as well.


🏁 Script executed:

#!/bin/bash
# Description: Check if Hemi network is referenced in CoingeckoPlatform elsewhere in the codebase
# Expected: Find any references to Hemi in CoingeckoPlatform usage

# Search for CoingeckoPlatform usage with Hemi
rg -A 3 -B 3 "CoingeckoPlatform.*Hemi|Hemi.*CoingeckoPlatform"

# Check if other networks have corresponding CoingeckoPlatform entries
echo "=== Networks in NetworkNames but not in CoingeckoPlatform ==="
rg -A 5 "enum NetworkNames" packages/types/src/networks.ts
echo "==="
rg -A 5 "enum CoingeckoPlatform" packages/types/src/networks.ts

Length of output: 656


🏁 Script executed:

#!/bin/bash
# Check for Hemi references and list networks missing from CoingeckoPlatform

echo "== Hemi occurrences in networks.ts =="
rg -n "Hemi" packages/types/src/networks.ts || echo "No matches for Hemi"

echo
echo "== Extracting NetworkNames keys =="
awk '/export enum NetworkNames/,/}/' packages/types/src/networks.ts \
  | sed -e '1d;$d' -e 's/[ ,]//g' -e 's/=.*//' \
  | sort > /tmp/network_names.txt
cat /tmp/network_names.txt

echo
echo "== Extracting CoingeckoPlatform keys =="
awk '/export enum CoingeckoPlatform/,/}/' packages/types/src/networks.ts \
  | sed -e '1d;$d' -e 's/[ ,]//g' -e 's/=.*//' \
  | sort > /tmp/coingecko_platforms.txt
cat /tmp/coingecko_platforms.txt

echo
echo "== Networks in NetworkNames but NOT in CoingeckoPlatform =="
comm -23 /tmp/network_names.txt /tmp/coingecko_platforms.txt || echo "None"

Length of output: 2488


Confirm Coingecko support for Hemi
The CoingeckoPlatform enum is intended to list only networks that CoinGecko exposes platform IDs for—any networks without CoinGecko price data (e.g. testnets, emerging chains) are omitted. Currently, Hemi appears in NetworkNames but is not in CoingeckoPlatform.

Please verify whether CoinGecko provides a platform identifier for Hemi (e.g. "hemi").

  • If CoinGecko supports Hemi, add:
    Hemi = "hemi",
    to the CoingeckoPlatform enum.
  • If not, no change is needed—this omission is intentional until CoinGecko adds Hemi.
packages/extension/src/providers/common/libs/new-features.ts (1)

3-3:

Details

✅ Verification successful

LGTM! New networks array updated for release.

The update to highlight only the Hemi network as "new" is appropriate for a release preparation, as the previously listed networks (Derive, Conflux, UnitZero) are likely no longer considered new features.


🏁 Script executed:

#!/bin/bash
# Description: Verify that removing previous networks from newNetworks doesn't break existing functionality
# Expected: Find usages of newNetworks array and confirm the change is safe

# Find all usages of newNetworks
rg -A 5 -B 5 "newNetworks"

# Check if there are any specific references to the removed networks being "new"
rg -A 3 -B 3 "Derive.*new|Conflux.*new|UnitZero.*new"

Length of output: 10429


🏁 Script executed:

#!/bin/bash
# Verify explicit references to the removed networks across the codebase

echo "Searching for NetworkNames.Derive..."
rg -n "NetworkNames\.Derive"

echo "Searching for NetworkNames.Conflux..."
rg -n "NetworkNames\.Conflux"

echo "Searching for NetworkNames\.UnitZero..."
rg -n "NetworkNames\.UnitZero"

Length of output: 1392


Release update verified—no breaking changes

The newNetworks array is only used for UI tagging and feature-flagging new networks. Removing Derive, Conflux, and UnitZero simply stops highlighting them as “new,” which aligns with release prep. All explicit references to those network names live elsewhere and aren’t impacted.

packages/extension/src/providers/ethereum/libs/transaction/index.ts (1)

17-22: LGTM!

The imports are properly organized and follow the existing pattern.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 using PR comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

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

@github-actions
Copy link

github-actions bot commented May 29, 2025

💼 Build Files
chrome: enkrypt-chrome-48c972f6.zip
firefox: enkrypt-firefox-48c972f6.zip

💉 Virus total analysis
chrome: 48c972f6
firefox: 48c972f6

Add safe buffer to Rootstock collective staking gas estimation
@kvhnuke kvhnuke changed the title devop: package updates prep-release: v2.8.0 May 29, 2025
@kvhnuke kvhnuke force-pushed the devop/release-v-2-7-0 branch from 013aedf to 48c972f Compare May 29, 2025 21:40
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 6

🧹 Nitpick comments (7)
packages/extension/src/providers/ethereum/ui/send-transaction/components/send-address-input.vue (1)

74-74: Good UX improvement for short address readability.

This change appropriately displays short addresses in full without truncation, improving readability when ellipsis would be unnecessary.

Consider extracting the magic number 13 to a named constant for better maintainability:

+const SHORT_ADDRESS_THRESHOLD = 13;
+
 const visibleAddress = computed(() => {
   let address = props.value;
   if (props.network.isAddress(address))
     address = props.network.displayAddress(props.value);
   if (isFocus.value) return address;
-  if (address.length < 13) return address;
+  if (address.length < SHORT_ADDRESS_THRESHOLD) return address;
   return replaceWithEllipsis(address, 6, 6);
 });
packages/extension/src/ui/action/views/swap/components/send-address-input.vue (1)

83-83: Consistent UX improvement across components.

This change aligns with the same improvement made in the Ethereum component, ensuring consistent address display behavior across different UI contexts.

For consistency with the recommendation in the Ethereum component, consider extracting the threshold to a shared constant that could be imported across all address input components.

packages/extension/src/providers/solana/ui/send-transaction/components/send-address-input.vue (1)

71-75: Excellent refactoring with clear conditional logic.

This implementation is the clearest of the three address input components. The explicit conditional structure makes it immediately obvious when the full address is displayed (focused OR short) versus when truncation applies.

Consider applying this clearer conditional pattern to the other address input components for consistency. Also, extract the magic number 13 to a shared constant:

+const SHORT_ADDRESS_THRESHOLD = 13;
+
 const address = computed({
   get: () => {
     if (isFocus.value) return solAddress.value;
-    if (solAddress.value.length < 13) return solAddress.value;
+    if (solAddress.value.length < SHORT_ADDRESS_THRESHOLD) return solAddress.value;
     return replaceWithEllipsis(solAddress.value, 6, 6);
   },
   set: value => emit('update:inputAddress', value),
 });
packages/extension/src/providers/common/ui/styles/verify-transaction.less (1)

177-181: Consider alternatives to !important declarations.

While the styling achieves the desired visual effect, the extensive use of !important flags suggests potential CSS specificity issues. This can make future maintenance more difficult.

Consider refactoring to increase specificity naturally instead of using !important:

       &-to {
         font-style: normal;
-        font-weight: 400 !important;
-        font-size: 16px !important;
-        line-height: 20px !important;
+        font-weight: 400;
+        font-size: 16px;
+        line-height: 20px;
         letter-spacing: 0.5px;
-        color: @black !important;
+        color: @black;
         word-break: break-all;
       }

If overriding is necessary, consider increasing the selector specificity or restructuring the CSS hierarchy.

packages/hw-wallets/src/trezor/trezorConnect.ts (1)

4-4: Improve safety with optional chaining.

The chrome runtime detection can be made safer using optional chaining as suggested by the static analysis tool.

-  if (chrome && chrome.runtime && chrome.runtime.getPlatformInfo) {
+  if (chrome?.runtime?.getPlatformInfo) {
🧰 Tools
🪛 Biome (1.9.4)

[error] 4-4: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

packages/extension/src/providers/ethereum/libs/transaction/gas-utils.ts (1)

182-195: Consider making API URLs configurable.

The configuration structure is well-organized. However, hardcoding external API URLs could make maintenance difficult if Blockscout endpoints change or become unavailable.

Consider moving these URLs to environment variables or a configuration file for easier maintenance and environment-specific deployments.

packages/extension/src/providers/ethereum/libs/transaction/index.ts (1)

112-118: Consider adding caching and fallback mechanisms.

The staking gas adjustment relies on external API availability, which could impact reliability and performance.

Consider implementing:

  1. Response caching: Cache successful gas values for a short period to reduce API calls
  2. Circuit breaker pattern: Temporarily disable the feature if APIs are consistently failing
  3. Metrics/monitoring: Track API response times and failures to ensure good user experience
🛑 Comments failed to post (6)
packages/extension/src/providers/ethereum/ui/eth-verify-transaction.vue (1)

203-203: 🛠️ Refactor suggestion

Potential issue with empty string initialization.

The identiconTo is initialized with an empty string passed to network.value.identicon(''). This could potentially cause issues if the identicon function doesn't handle empty strings gracefully.

Consider initializing with a safer default:

-const identiconTo = ref<string>(network.value.identicon(''));
+const identiconTo = ref<string>('');

Or ensure the identicon function handles empty strings properly before initialization.

📝 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.

- const identiconTo = ref<string>(network.value.identicon(''));
+ const identiconTo = ref<string>('');
🤖 Prompt for AI Agents
In packages/extension/src/providers/ethereum/ui/eth-verify-transaction.vue at
line 203, the identiconTo variable is initialized by calling
network.value.identicon with an empty string, which may cause issues if the
identicon function does not handle empty strings properly. To fix this, either
initialize identiconTo with a safer default value that the identicon function
can handle or modify the identicon function to safely process empty string
inputs before this initialization.
packages/hw-wallets/src/trezor/bitcoin/index.ts (1)

18-18: ⚠️ Potential issue

Fix incorrect class name.

The class is named TrezorEthereum but this file implements Bitcoin functionality. This appears to be a copy-paste error.

-class TrezorEthereum implements HWWalletProvider {
+class TrezorBitcoin implements HWWalletProvider {

Also update the export statement:

-export default TrezorEthereum;
+export default TrezorBitcoin;
📝 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.

// ... other imports and code ...

class TrezorBitcoin implements HWWalletProvider {
  // ... existing implementation ...
}

export default TrezorBitcoin;
🤖 Prompt for AI Agents
In packages/hw-wallets/src/trezor/bitcoin/index.ts at line 18, the class is
incorrectly named TrezorEthereum, which does not match the Bitcoin functionality
of this file. Rename the class to TrezorBitcoin to reflect the correct
implementation. Additionally, update the export statement to export
TrezorBitcoin instead of TrezorEthereum.
packages/hw-wallets/src/trezor/solana/index.ts (2)

62-67: 🛠️ Refactor suggestion

Add error handling for transaction signing.

Similar to the address retrieval, the transaction signing lacks error handling present in other implementations.

  return this.TrezorConnect.solanaSignTransaction({
    path: options.pathType.path.replace(`{index}`, options.pathIndex),
    serializedTx: (options.transaction as SolSignTransaction).solTx.toString(
      "hex",
    ),
- }).then((result) => (result.payload as any).signature);
+ }).then((result) => {
+   if (!result.success) throw new Error((result.payload as any).error);
+   return (result.payload as any).signature;
+ });
📝 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 this.TrezorConnect.solanaSignTransaction({
      path: options.pathType.path.replace(`{index}`, options.pathIndex),
      serializedTx: (options.transaction as SolSignTransaction).solTx.toString(
        "hex",
      ),
    }).then((result) => {
      if (!result.success) throw new Error((result.payload as any).error);
      return (result.payload as any).signature;
    });
🤖 Prompt for AI Agents
In packages/hw-wallets/src/trezor/solana/index.ts around lines 62 to 67, the
transaction signing call lacks error handling. Modify the promise chain to check
if the result indicates success; if not, throw or handle the error
appropriately. This can be done by inspecting the result's success or error
properties before returning the signature, ensuring any failure is caught and
managed similarly to the address retrieval method.

35-42: 🛠️ Refactor suggestion

Add error handling for consistency and safety.

The Solana implementation is missing error handling that exists in the Bitcoin and Ethereum implementations. This could lead to runtime errors if the Trezor operation fails.

  const res = await this.TrezorConnect.solanaGetAddress({
    path: options.pathType.path.replace(`{index}`, options.pathIndex),
    showOnTrezor: options.confirmAddress,
  });
+ if (!res.payload) {
+   throw new Error("popup failed to open");
+ }
+ if (!res.success) throw new Error((res.payload as any).error);
  return {
    address: bufferToHex(base58.decode((res.payload as any).address)),
    publicKey: bufferToHex(base58.decode((res.payload as any).address)),
  };
📝 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.

    const res = await this.TrezorConnect.solanaGetAddress({
      path: options.pathType.path.replace(`{index}`, options.pathIndex),
      showOnTrezor: options.confirmAddress,
    });
    if (!res.payload) {
      throw new Error("popup failed to open");
    }
    if (!res.success) {
      throw new Error((res.payload as any).error);
    }
    return {
      address: bufferToHex(base58.decode((res.payload as any).address)),
      publicKey: bufferToHex(base58.decode((res.payload as any).address)),
    };
🤖 Prompt for AI Agents
In packages/hw-wallets/src/trezor/solana/index.ts between lines 35 and 42, add
error handling around the call to this.TrezorConnect.solanaGetAddress to check
if the response indicates success before accessing res.payload. If the call
fails, throw an error or handle it appropriately to prevent runtime exceptions,
ensuring consistency with the Bitcoin and Ethereum implementations.
packages/extension/src/providers/ethereum/libs/transaction/gas-utils.ts (1)

197-242: 🛠️ Refactor suggestion

Enhance error handling and add timeout controls.

The gas calculation logic is sound, but there are several areas for improvement:

  1. Generic error handling: The catch block (lines 239-241) silently returns the original estimate for any error
  2. No timeout protection: External API calls could hang indefinitely
  3. Sequential API calls: Could impact transaction preparation performance

Consider these improvements:

-const safeGasForStaking = async (chainID: string, estimatedGas: number) => {
+const safeGasForStaking = async (chainID: string, estimatedGas: number): Promise<number> => {
   const gasConfig = collectiveGasConfig[chainID];
+  const controller = new AbortController();
+  const timeout = setTimeout(() => controller.abort(), 5000); // 5s timeout
+  
   try {
-    const stakingResponse = await fetch(gasConfig.stakingUrl);
+    const stakingResponse = await fetch(gasConfig.stakingUrl, { signal: controller.signal });
     if (!stakingResponse.ok) {
+        console.warn(`Failed to fetch staking history: ${stakingResponse.status}`);
         return estimatedGas;
     }

Also consider adding more specific error logging to help with debugging issues in production.

📝 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.

const safeGasForStaking = async (chainID: string, estimatedGas: number): Promise<number> => {
  const gasConfig = collectiveGasConfig[chainID];
  const controller = new AbortController();
  const timeout = setTimeout(() => controller.abort(), 5000); // 5s timeout

  try {
    const stakingResponse = await fetch(gasConfig.stakingUrl, { signal: controller.signal });
    if (!stakingResponse.ok) {
        console.warn(`Failed to fetch staking history: ${stakingResponse.status}`);
        return estimatedGas;
    }
    const stakingTxHistory = await stakingResponse.json();

    for (const tx of stakingTxHistory.items) {
      // find stake tx
      if (tx.method === gasConfig.method) {
        const txDetailsResponse = await fetch(`${gasConfig.txUrl}/${tx.transaction_hash}`);

        if (!txDetailsResponse.ok) {
          return estimatedGas;
        }
        const txDetail = await txDetailsResponse.json();
        // tx must be successfull
        if (txDetail.status === 'ok') {
          const txGasLimit = Number(txDetail.gas_limit);
          const txGasUsed = Number(txDetail.gas_used);
          // if web3 estimate gas is less than previous stake tx gas used
          // This could cause tx to fail due to less gas
          // Bump the gas limit particularly in this case 
          if (estimatedGas < txGasUsed) {
            // Check if need to add buffer
            const usedGasPercentage = txGasUsed / txGasLimit * 100;
            if (usedGasPercentage > 80) {
              // add a safe buffer of 30%
              return Math.max(txGasUsed + (txGasUsed * 0.30), txGasLimit);
            }
            // safe buffer not required, just use gas limit 
            return txGasLimit;
          }
          // safe to use max of estimate or tx gas limit
          return Math.max(estimatedGas, txGasLimit);
        }
      }
    }
    // No previous stake tx found, just return web3 estimated gas.
    return estimatedGas;
  } catch {
    return estimatedGas;
  }
};
🤖 Prompt for AI Agents
In packages/extension/src/providers/ethereum/libs/transaction/gas-utils.ts
between lines 197 and 242, improve error handling by catching and logging
specific errors instead of silently returning the estimated gas. Add timeout
controls to the fetch calls to prevent hanging on external API requests.
Refactor the sequential fetch calls to run in parallel where possible to enhance
performance, such as fetching transaction details concurrently after retrieving
the staking transaction history. Ensure all fetch calls handle errors gracefully
and log meaningful messages for easier debugging in production.
packages/extension/src/providers/ethereum/libs/transaction/index.ts (1)

115-118: 🛠️ Refactor suggestion

⚠️ Potential issue

Improve type safety and code formatting.

The logic is correct, but there are type safety and formatting concerns:

  1. Type overflow risk: Converting hex string to Number could cause issues with large gas values
  2. Inconsistent formatting: Missing spaces and inconsistent indentation

Apply this diff to address the issues:

-      if ([rsk.chainID, rskTestnet.chainID].includes(this.tx.chainId) && this.tx.data && 
-        this.tx.data.startsWith(collectiveGasConfig[this.tx.chainId].methodId)) {
-          gasLimit = (numberToHex(await safeGasForStaking(this.tx.chainId, Number(gasLimit))) as `0x${string}`)
-      }  
+      if (
+        [rsk.chainID, rskTestnet.chainID].includes(this.tx.chainId) &&
+        this.tx.data &&
+        this.tx.data.startsWith(collectiveGasConfig[this.tx.chainId].methodId)
+      ) {
+        const currentGasLimit = parseInt(gasLimit, 16);
+        if (!isNaN(currentGasLimit)) {
+          gasLimit = numberToHex(
+            await safeGasForStaking(this.tx.chainId, currentGasLimit)
+          ) as `0x${string}`;
+        }
+      }

This ensures safe hex-to-number conversion and improves readability.

📝 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.

      if (
        [rsk.chainID, rskTestnet.chainID].includes(this.tx.chainId) &&
        this.tx.data &&
        this.tx.data.startsWith(collectiveGasConfig[this.tx.chainId].methodId)
      ) {
        const currentGasLimit = parseInt(gasLimit, 16);
        if (!isNaN(currentGasLimit)) {
          gasLimit = numberToHex(
            await safeGasForStaking(this.tx.chainId, currentGasLimit)
          ) as `0x${string}`;
        }
      }
🤖 Prompt for AI Agents
In packages/extension/src/providers/ethereum/libs/transaction/index.ts around
lines 115 to 118, fix the type safety issue by replacing the direct Number
conversion of the hex gasLimit with a safer hex-to-number conversion method to
avoid overflow risks. Also, improve code formatting by adding necessary spaces
and consistent indentation for better readability.

@kvhnuke kvhnuke changed the title prep-release: v2.8.0 prep-release [wip] May 29, 2025
@kvhnuke kvhnuke closed this May 30, 2025
@kvhnuke kvhnuke deleted the devop/release-v-2-7-0 branch May 30, 2025 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants