Skip to content

Comments

fix: kadena balance issue#622

Merged
kvhnuke merged 4 commits intodevelopfrom
fix/kadena-balance-issue
Feb 27, 2025
Merged

fix: kadena balance issue#622
kvhnuke merged 4 commits intodevelopfrom
fix/kadena-balance-issue

Conversation

@kvhnuke
Copy link
Contributor

@kvhnuke kvhnuke commented Feb 27, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Improved balance retrieval reliability by enhancing error handling. Now, when specific error conditions are encountered, the system returns a default balance value of '0', ensuring a smoother experience.
    • Enhanced error message formatting during transaction failures for clearer output.
  • New Features

    • Introduced support for importing SVG files as strings, enhancing asset handling.
    • Clarified backup functionality in settings, specifying what data is backed up.
  • Chores

    • Updated package version from 2.4.0 to 2.4.1.
    • Expanded TypeScript configuration to include additional type definitions.

@coderabbitai
Copy link

coderabbitai bot commented Feb 27, 2025

Walkthrough

The change updates the error handling logic in the getBalanceByChainId method within the API class. The modified condition now checks if the error message contains either "row not found" or "No value found in table". If either string is present, the method returns a balance of '0'; otherwise, it throws an error. Additionally, the TypeScript configuration has been updated to include env.d.ts, the NodeJS namespace has been modified for better accessibility, and the package version has been incremented. The user interface for backup settings has also been clarified, and type handling has been enforced in the code.

Changes

File Change Summary
packages/extension/.../api.ts Enhanced error handling in the getBalanceByChainId method by adding an additional check for the error message "No value found in table", returning '0' if matched. Modified balance retrieval in getBalanceAPI to cast Pact.modules as any.
packages/extension/.../env.d.ts Updated NodeJS namespace and ProcessEnv interface to be exported. Added module declaration for SVG files to treat them as strings. Semicolons added for consistency.
packages/extension/.../package.json Updated package version from 2.4.0 to 2.4.1.
packages/extension/.../tsconfig.node.json Added "env.d.ts" to the "include" array in TypeScript configuration.
packages/extension/.../activity-handlers/.../index.ts Simplified assignment of status property in mapping function to always set it to ActivityStatus.success.
packages/extension/.../send-transaction/.../index.vue Modified error message handling in validateFields function to format error messages by removing specific characters and keys.
packages/extension/.../settings-backups/.../index.vue Enhanced backup settings UI by clarifying what information is backed up and added non-null assertions for selectedBackup.

Suggested reviewers

  • NickKelly1
  • gamalielhere

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

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

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

CodeRabbit Commands (Invoked 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 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 Feb 27, 2025

💼 Build Files
chrome: enkrypt-chrome-0e3e4faf.zip
firefox: enkrypt-firefox-0e3e4faf.zip

💉 Virus total analysis
chrome: 0e3e4faf
firefox: 0e3e4faf

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 84f8c80 and 0c4d37b.

📒 Files selected for processing (2)
  • packages/extension/src/providers/kadena/libs/activity-handlers/providers/kadena/index.ts (1 hunks)
  • packages/extension/src/providers/kadena/ui/send-transaction/index.vue (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: buildAll
  • GitHub Check: test
🔇 Additional comments (1)
packages/extension/src/providers/kadena/ui/send-transaction/index.vue (1)

294-298: Improved error message formatting for transaction failures.

The PR enhances error message handling by removing double quotes and the request key from error messages, making them more user-friendly.

This change improves the user experience by cleaning up error messages from the Kadena blockchain, making them more readable and less technical.

@enkryptcom enkryptcom deleted a comment from Receptua Feb 27, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
packages/extension/src/ui/action/views/settings/views/settings-backups/index.vue (4)

91-97: Consider using optional chaining instead of non-null assertions.

The non-null assertion operator (!) forces TypeScript to treat selectedBackup as non-nullable, but this could lead to runtime errors if the value is actually null.

A safer approach would be to use optional chaining or add conditional rendering:

-<backup-identicon :hash="selectedBackup!.userId" />
+<backup-identicon :hash="selectedBackup?.userId || ''" />

-{{ generateRandomNameWithSeed(' ', selectedBackup!.userId) }}
+{{ selectedBackup ? generateRandomNameWithSeed(' ', selectedBackup.userId) : '' }}

-<p>Last backup on: {{ formatDate(selectedBackup!.updatedAt) }}</p>
+<p>Last backup on: {{ selectedBackup ? formatDate(selectedBackup.updatedAt) : '' }}</p>

Alternatively, you could add a v-if="selectedBackup" to the parent container to ensure the block only renders when selectedBackup exists.


103-103: Consider using optional chaining for this event handler as well.

Similar to the above, using the non-null assertion operator here may lead to runtime errors.

-@click="deleteBackup(selectedBackup!.userId)"
+@click="selectedBackup && deleteBackup(selectedBackup.userId)"

130-130: Define the ref with a clearer initial state.

The current definition leaves selectedBackup in an ambiguous state that could be either undefined or null.

-const selectedBackup = ref<ListBackupType | null>();
+const selectedBackup = ref<ListBackupType | null>(null);

This makes it explicit that the initial value is null rather than undefined, which is important when using type guards or equality checks.


153-155: Validation in showDeleteBackup method.

This method correctly sets selectedBackup before changing isDelete to true, which ensures that when the delete confirmation is shown, selectedBackup should not be null. However, adding type guards would make this more robust.

const showDeleteBackup = (backup: ListBackupType) => {
  selectedBackup.value = backup;
+  // Only show delete confirmation when we have a valid backup
+  if (selectedBackup.value) {
    isDelete.value = true;
+  }
};
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0c4d37b and 0e3e4fa.

📒 Files selected for processing (1)
  • packages/extension/src/ui/action/views/settings/views/settings-backups/index.vue (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: buildAll
  • GitHub Check: test
🔇 Additional comments (1)
packages/extension/src/ui/action/views/settings/views/settings-backups/index.vue (1)

9-12: Improved backup explanation for better user clarity.

The expanded explanation clearly communicates what information is backed up and explicitly states that sensitive information is never backed up. This helps set correct user expectations about security.

@kvhnuke kvhnuke merged commit 121aa49 into develop Feb 27, 2025
3 of 4 checks passed
@kvhnuke kvhnuke deleted the fix/kadena-balance-issue branch February 27, 2025 23:07
@Receptua
Copy link

Receptua commented Mar 11, 2025 via email

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.

4 participants