Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollback signTron #301

Merged
merged 5 commits into from
Jul 22, 2024
Merged

Rollback signTron #301

merged 5 commits into from
Jul 22, 2024

Conversation

haunv3
Copy link
Contributor

@haunv3 haunv3 commented Jul 21, 2024

Summary by CodeRabbit

  • New Features

    • Updated the package to version 1.0.93, indicating potential enhancements or fixes.
    • Enhanced the transaction handling for smart contracts, improving error handling and default settings for fee limits.
  • Bug Fixes

    • Improved robustness in the transaction signing process for enhanced clarity.

Copy link

coderabbitai bot commented Jul 21, 2024

Warning

Rate limit exceeded

@haunv3 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 23 minutes and 50 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between f0d8e6a and fa093aa.

Walkthrough

This update transitions the @oraichain/oraidex-common package to a new release version, enhancing its stability and functionality. Key adjustments include improvements to the submitTronSmartContract method in the EvmWallet class, which now more rigorously handles the presence of options and establishes a default fee limit. These enhancements contribute to a more reliable transaction process, setting the stage for future developments.

Changes

Files Change Summary
packages/oraidex-common/package.json Updated version from 1.0.92 to 1.0.93, indicating a new release with potential enhancements.
packages/oraidex-common/src/wallet.ts Modified submitTronSmartContract method: explicitly checks for options, assigns default feeLimit, improved transaction signing process.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EvmWallet
    participant TronWeb

    User->>EvmWallet: submitTronSmartContract(address, functionSelector, options, parameters, issuerAddress)
    EvmWallet->>EvmWallet: Check if options is defined
    EvmWallet->>EvmWallet: Set feeLimit if not provided
    EvmWallet->>TronWeb: sign(transaction)
    TronWeb-->>EvmWallet: Return signed transaction
    EvmWallet-->>User: Return EvmResponse
Loading

Poem

🐰 In the garden where code does play,
A new version hops in, brightening the day.
With options checked and fees aligned,
The EvmWallet's magic is truly divine!
With each little change, our joy does bloom,
In this world of tech, there's always room! 🌼✨


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

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

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

CodeRabbit Commands (invoked as PR comments)

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

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

CodeRabbit Configuration File (.coderabbit.yaml)

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

Documentation and Community

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

Copy link

badge

Code Coverage Summary

Filename                                                                      Stmts    Miss  Cover    Missing
--------------------------------------------------------------------------  -------  ------  -------  ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
docs/assets/main.js                                                              58      58  0.00%    1-58
docs/assets/search.js                                                             1       1  0.00%    1
packages/ibc-routing/hardhat.config.ts                                           59      59  0.00%    1-75
packages/ibc-routing/src/db.ts                                                  158     158  0.00%    1-263
packages/ibc-routing/src/event.ts                                                85      85  0.00%    1-122
packages/ibc-routing/src/index.ts                                                31      31  0.00%    1-56
packages/ibc-routing/src/machine.ts                                              30      30  0.00%    1-34
packages/ibc-routing/test/mock-eth-ws.ts                                         52      52  0.00%    1-55
packages/ibc-routing/test/mock-tendermint-ws.spec.ts                             25      17  32.00%   7-24
packages/oraidex-common/src/alpha-network.ts                                     61       0  100.00%
packages/oraidex-common/src/axios-request.ts                                     17      17  0.00%    1-20
packages/oraidex-common/src/bigdecimal.ts                                       139      50  64.02%   23-24, 30-33, 40-41, 45-54, 63-65, 71-73, 120-124, 127-146, 149-150, 153-154, 180-181, 184-185
packages/oraidex-common/src/constant.ts                                         157       0  100.00%
packages/oraidex-common/src/helper.ts                                           464     139  70.04%   141-142, 145-156, 159-169, 276-283, 286-299, 309-315, 325-340, 343-350, 353-383, 386-394, 397-399, 402-404, 408-417, 426-440, 446-448, 533-534, 559-562
packages/oraidex-common/src/ibc-info.ts                                         168     168  0.00%    1-200
packages/oraidex-common/src/index.ts                                             13      13  0.00%    1-13
packages/oraidex-common/src/network.ts                                          959       0  100.00%
packages/oraidex-common/src/pairs.ts                                            154       4  97.40%   151-152, 157-158
packages/oraidex-common/src/token.ts                                             71       0  100.00%
packages/oraidex-common/src/wallet.ts                                           148     148  0.00%    1-238
packages/oraidex-common/src/config/chainInfosWithIcon.ts                        196     196  0.00%    1-210
packages/oraidex-common/src/interface/index.ts                                    1       1  0.00%    1
packages/oraidex-common/src/interface/wallet.ts                                  19      19  0.00%    1-20
packages/oraidex-common/tests/bigdecimal.spec.ts                                220       0  100.00%
packages/oraidex-common/tests/helper.spec.ts                                    560       8  98.57%   97-98, 337-338, 628-629, 659-660
packages/oraidex-common/tests/pairs.spec.ts                                      24       0  100.00%
packages/oraiswap-v3/src/const.ts                                                39       0  100.00%
packages/oraiswap-v3/src/handler.ts                                             107       0  100.00%
packages/oraiswap-v3/src/helpers.ts                                             193      10  94.81%   110-111, 121-122, 147-148, 176-177, 187-188
packages/oraiswap-v3/src/index.ts                                                 4       0  100.00%
packages/oraiswap-v3/src/types.ts                                                 0       0  100.00%
packages/oraiswap-v3/tests/handler.spec.ts                                       81       0  100.00%
packages/oraiswap-v3/tests/helpers.spec.ts                                      455       0  100.00%
packages/oraiswap-v3/tests/test-common.ts                                        32       0  100.00%
packages/universal-swap/src/handler.ts                                         1111     552  50.31%   77-78, 99-100, 114-116, 122-125, 136-138, 167-189, 268-298, 401-421, 504-514, 533, 535-539, 552-563, 570-616, 641-651, 654-664, 671-678, 692-770, 774-805, 809-828, 831-848, 852-903, 908-991, 997-1068, 1077-1082, 1101-1102, 1104-1105, 1111, 1115-1130, 1139-1142, 1186-1189, 1196-1204, 1209, 1249-1250, 1280-1291, 1358-1359
packages/universal-swap/src/helper.ts                                           767     244  68.18%   80-82, 218-219, 373-375, 397-403, 427-429, 433-435, 442-468, 523-524, 566-573, 580-621, 635-692, 731-732, 747, 775, 782-803, 805-806, 839-840, 843-846, 856-898, 906-922, 981-991, 1002-1007, 1026
packages/universal-swap/src/index.ts                                              5       5  0.00%    1-5
packages/universal-swap/src/swap-filter.ts                                       40       0  100.00%
packages/universal-swap/src/types.ts                                             10       0  100.00%
packages/universal-swap/src/wrapper.ts                                           79      79  0.00%    1-117
packages/universal-swap/src/proto/proto-gen.ts                                   71       0  100.00%
packages/universal-swap/src/universal-demos/alpha-smart-router.ts                71      71  0.00%    1-546
packages/universal-swap/src/universal-demos/evm-to-evm.ts                        48      48  0.00%    1-63
packages/universal-swap/src/universal-demos/from-cosmos-to-evm.ts                41      41  0.00%    1-53
packages/universal-swap/src/universal-demos/from-oraichain-to-oraichain.ts       49      49  0.00%    1-66
packages/universal-swap/src/universal-demos/ibc-hooks-demo.ts                    40      40  0.00%    1-55
packages/universal-swap/src/universal-demos/neutaro-ibc-demo.ts                  40      40  0.00%    1-47
packages/universal-swap/src/universal-demos/noble-ibc-demo.ts                    41      41  0.00%    1-45
packages/universal-swap/src/universal-demos/offline-wallet.ts                    19      19  0.00%    1-21
packages/universal-swap/tests/helper.spec.ts                                    883      26  97.05%   592-594, 956-978
packages/universal-swap/tests/index.spec.ts                                    1623      32  98.02%   238-241, 269-270, 281-282, 287-288, 290-291, 293-294, 1046-1065
packages/universal-swap/tests/smart-router-common.ts                            805       0  100.00%
packages/universal-swap/tests/test-common.ts                                     56       0  100.00%
TOTAL                                                                         10580    2551  75.88%

Diff against main

Filename      Stmts    Miss  Cover
----------  -------  ------  --------
TOTAL             0       0  +100.00%

Results for commit: 4ce0852

Minimum allowed coverage is 0%

♻️ This comment has been updated with latest results

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Outside diff range, codebase verification and nitpick comments (5)
packages/oraidex-common/src/wallet.ts (5)

133-134: Remove commented-out code.

The commented-out code related to TransactionBuilder and Trx should be removed to improve code readability.

-    // const transactionBuilder = new TransactionBuilder(this.tronWeb);
-    // const trx = new Trx(this.tronWeb);

149-149: Avoid using console.log in production code.

The console.log statement should be removed or replaced with a proper logging mechanism.

-      console.log("before building tx: ", issuerAddress, "options:", options);
+      // Use a proper logging mechanism instead of console.log
+      // logger.info("before building tx: ", issuerAddress, "options:", options);

151-158: Remove commented-out code.

The commented-out code related to transactionBuilder.triggerSmartContract should be removed to improve code readability.

-      // const transaction = await transactionBuilder.triggerSmartContract(
-      //   address,
-      //   functionSelector,
-      //   !options?.feeLimit
-      //     ? { ...options, feeLimit: 40 * 1e6 } // submitToCosmos costs about 40 TRX
-      //     : options,
-      //   parameters,
-      //   ethToTronAddress(issuerAddress)
-      // );

175-175: Avoid using console.log in production code.

The console.log statement should be removed or replaced with a proper logging mechanism.

-      console.log("signed tx: ", singedTransaction);
+      // Use a proper logging mechanism instead of console.log
+      // logger.info("signed tx: ", singedTransaction);

181-185: Remove commented-out code.

The commented-out code related to trx.sign and trx.sendRawTransaction should be removed to improve code readability.

-      // sign from inject tronWeb
-      // const singedTransaction = await trx.sign(transaction.transaction);
-      // console.log("signed tx: ", singedTransaction);
-      // const result = await trx.sendRawTransaction(singedTransaction);
-      // return { transactionHash: result.transaction.txID };
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b2a0952 and 4ce0852.

Files selected for processing (2)
  • packages/oraidex-common/package.json (1 hunks)
  • packages/oraidex-common/src/wallet.ts (3 hunks)
Files skipped from review due to trivial changes (1)
  • packages/oraidex-common/package.json
Additional comments not posted (1)
packages/oraidex-common/src/wallet.ts (1)

124-124: Ensure options parameter is provided.

The method signature has been updated to enforce the presence of the options parameter, which enhances error handling.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4ce0852 and f0d8e6a.

Files selected for processing (1)
  • packages/oraidex-common/package.json (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/oraidex-common/package.json

@haunv3 haunv3 changed the title Feat/fix swap and transfer evm Rollback signTron Jul 22, 2024
Copy link
Member

@trung2891 trung2891 left a comment

Choose a reason for hiding this comment

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

lgtm

@haunv3 haunv3 merged commit 014b82f into main Jul 22, 2024
1 of 2 checks passed
@trung2891 trung2891 deleted the feat/fix-swap-and-transfer-evm branch October 6, 2024 10:45
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