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

(OraklNode) Public address retrieval functionalities #1498

Merged
merged 1 commit into from
May 20, 2024

Conversation

nick-bisonai
Copy link
Collaborator

Description

  • adds admin endpoint which returns all stored wallets' public addresses
  • if reporter pk from env variable is not inside the table, it'll try to insert it
  • adds por endpoint which returns por reporter wallet's public address

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist before requesting a review

  • I have performed a self-review of my code.
  • If it is a core feature, I have added thorough tests.

Deployment

  • Should publish npm package
  • Should publish Docker image

@nick-bisonai nick-bisonai self-assigned this May 18, 2024
@nick-bisonai nick-bisonai requested a review from a team as a code owner May 18, 2024 02:33
Copy link
Contributor

coderabbitai bot commented May 18, 2024

Warning

Rate Limit Exceeded

@nick-bisonai has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 47 minutes and 19 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 2085ce6 and b789c1c.

Walkthrough

The changes across the node/pkg directory focus on enhancing wallet management and encryption. Key updates include modifying encryption keys in tests, adding functions to retrieve wallet addresses, improving error handling in wallet insertion, and introducing utility functions for database operations and key conversions. These enhancements aim to improve security, testing accuracy, and functionality of wallet-related features.

Changes

File Path Change Summary
node/pkg/admin/tests/main_test.go Updated encryption key and corresponding values in insertSampleData function.
node/pkg/admin/tests/wallet_test.go Updated Pk field values in mockWallet and added TestWalletGetAddress function.
node/pkg/admin/wallet/controller.go Added function getAddresses to retrieve and return wallet addresses.
node/pkg/admin/wallet/route.go Modified route to use getAddresses function.
node/pkg/chain/helper/helper.go Added check for primaryWallet existence before appending in NewChainHelper function.
node/pkg/chain/tests/chain_test.go Added TestGetWallets and TestInsertWalletEmptyDbEnv functions.
node/pkg/chain/utils/utils.go Added InsertWallet and StringPkToAddressHex utility functions.
node/pkg/por/app.go Added import for chainUtils and a new function to handle HTTP requests.

In code we trust, with keys so fine,
Encrypting wallets, making them shine.
New tests arise, addresses we fetch,
In the land of bytes, there's no stretch.
With each commit, our code does grow,
Like a rabbit's warren, deep below.
🐇✨


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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

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

CodeRabbit Configration File (.coderabbit.yaml)

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

Documentation and Community

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

Copy link
Contributor

@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 UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 28a2f1e and 2085ce6.
Files selected for processing (8)
  • node/pkg/admin/tests/main_test.go (1 hunks)
  • node/pkg/admin/tests/wallet_test.go (3 hunks)
  • node/pkg/admin/wallet/controller.go (2 hunks)
  • node/pkg/admin/wallet/route.go (1 hunks)
  • node/pkg/chain/helper/helper.go (1 hunks)
  • node/pkg/chain/tests/chain_test.go (1 hunks)
  • node/pkg/chain/utils/utils.go (2 hunks)
  • node/pkg/por/app.go (2 hunks)
Additional comments not posted (8)
node/pkg/admin/wallet/route.go (1)

12-12: The addition of the /addresses route is consistent with the PR objectives and is correctly implemented.

node/pkg/admin/tests/main_test.go (1)

94-102: The update to use specific Ethereum addresses for encryption and wallet PK is noted. Consider adding a comment explaining the choice of these addresses for clarity.

node/pkg/admin/wallet/controller.go (1)

66-87: The implementation of the getAddresses function correctly handles the retrieval and decryption of wallet addresses, aligning with the PR objectives.

node/pkg/admin/tests/wallet_test.go (1)

74-89: The new test function TestWalletGetAddress is well-implemented and correctly tests the new wallet address retrieval functionality.

node/pkg/por/app.go (1)

107-117: The implementation of the endpoint handler for /api/v1/address correctly retrieves and converts the POR reporter PK to an address, aligning with the PR objectives.

node/pkg/chain/helper/helper.go (1)

112-126: The modifications to the NewChainHelper function to check and conditionally insert the primary wallet are logical and improve the robustness of the wallet handling.

node/pkg/chain/tests/chain_test.go (1)

477-520: The new test functions TestGetWallets and TestInsertWalletEmptyDbEnv are well-implemented and effectively test the wallet retrieval and insertion functionalities under different conditions.

node/pkg/chain/utils/utils.go (1)

609-625: The implementation of converting a private key string to an Ethereum address is correct and handles errors appropriately.

node/pkg/chain/utils/utils.go Show resolved Hide resolved
feat: updates to get public addresses

fix: fix linter err
@nick-bisonai nick-bisonai force-pushed the feat/add-oraklnode-admin-endpoint branch from 2085ce6 to b789c1c Compare May 18, 2024 12:38
@nick-bisonai nick-bisonai merged commit d9e79da into master May 20, 2024
2 checks passed
@nick-bisonai nick-bisonai deleted the feat/add-oraklnode-admin-endpoint branch May 20, 2024 13:07
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.

1 participant