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

Implement ubiquity-os logger instead of console logs #181

Open
gentlementlegen opened this issue Oct 31, 2024 · 10 comments
Open

Implement ubiquity-os logger instead of console logs #181

gentlementlegen opened this issue Oct 31, 2024 · 10 comments

Comments

@gentlementlegen
Copy link
Member

gentlementlegen commented Oct 31, 2024

          It's the kernel so our logger instance does not exist here, but yes ideally we should use it.

Originally posted by @gentlementlegen in #179 (comment)

Currently the kernel uses plain console.log to log messages. We should implement https://github.com/ubiquity-os/ubiquity-os-logger for more detailed / prettier logs.

@gentlementlegen
Copy link
Member Author

/query @gentlementlegen

Copy link

Property Value
Wallet 0x0fC1b909ba9265A846b82CF4CE352fc3e7EeB2ED

@gentlementlegen
Copy link
Member Author

/help

Copy link

Available Commands

Command Description Example
/help List all available commands. /help
/allow Allows the user to modify the given label. /allow @user1 label
/ask Ask any question about the repository, issue or pull request /ask
/query Returns the user's wallet, access, and multiplier information. /query @UbiquityOS
/start Assign yourself and/or others to the issue/task. /start
/stop Unassign yourself from the issue/task. /stop
/wallet Register your wallet address for payments. /wallet ubq.eth

@gentlementlegen
Copy link
Member Author

/ask can you tell me more about this issue?

Copy link

This issue centers around enabling users to manage their associated wallets within our system through GitHub commands. Specifically, it involves implementing a /wallet command that allows users to set, update, and query their wallet addresses, which are essential for collecting rewards.

Key Objectives:

  1. Implement the /wallet Command:
    • Set Wallet: Users can register their wallet by issuing the /wallet command followed by their wallet address or ENS name.
      • Example: /wallet 0xFaF2BD96905b7DAf432534FF4Fa75D90A36614eE or /wallet ubiquibot.eth
    • Update Wallet: Users can update their existing wallet address using the same command with a new address.
    • Query Wallet: Users can query their currently registered wallet address by simply issuing the /wallet command without any arguments.

Implementation Details:

  • Command Parsing:

    • The CommandParser class located in src/handlers/command-parser.ts is responsible for parsing the /wallet command. It validates the input to ensure that a valid Ethereum address or ENS name is provided.
  • Wallet Registration and Management:

    • The registerWallet function in src/handlers/query-wallet.ts handles the logic for registering and updating wallet addresses. It resolves ENS names to Ethereum addresses when necessary and ensures that only valid, non-null addresses are recorded.
    • The system uses the ethers library for address validation and ENS resolution, ensuring robust and secure handling of wallet data.
  • Database Integration:

    • Wallet information is stored in the wallets table within the Supabase database. The Wallet adapter in src/adapters/supabase/helpers/wallet.ts manages interactions with this table, including inserting new wallet addresses and updating existing ones.
    • The users table maintains a reference to the associated wallet through a wallet_id field, establishing a relational link between users and their wallets.
  • Logging Enhancements:

    • The project has transitioned from using console.log to a more sophisticated logging system. Methods like logger.ok, logger.info, and logger.error provide clearer and more categorized logging outputs, enhancing debugging and monitoring capabilities.
  • Pull Request Highlights (ubiquibot/command-wallet/2):

    • Environment Variables: Added SUPABASE_URL and SUPABASE_KEY to securely manage database connections.
    • Database Schema Updates: Introduced new tables and relationships to handle wallet registrations effectively.
    • Command Handling: Implemented robust parsing and validation for the /wallet command, including ENS name resolution.
    • Error Handling: Enhanced error logging to provide meaningful feedback in case of failures during wallet registration or updates.

Usage Examples:

  1. Registering a New Wallet:

    • User Input:
      /wallet 0xFaF2BD96905b7DAf432534FF4Fa75D90A36614eE
      
    • Bot Response:
      Successfully registered wallet address 0xFaF2BD96905b7DAf432534FF4Fa75D90A36614eE for user @ubiquibot.
      
  2. Updating an Existing Wallet:

    • User Input:
      /wallet 0xABCDE12345ABCDE12345ABCDE12345ABCDE12345
      
    • Bot Response:
      Successfully updated wallet address to 0xABCDE12345ABCDE12345ABCDE12345ABCDE12345 for user @ubiquibot.
      
  3. Querying the Current Wallet:

    • User Input:
      /wallet
      
    • Bot Response:
      Your current registered wallet address is 0xABCDE12345ABCDE12345ABCDE12345ABCDE12345.
      

Additional Notes:

  • ENS Name Resolution: If a user provides an ENS name instead of a direct wallet address, the system will automatically resolve it to the corresponding Ethereum address.

    • Example:
      • User Input: /wallet ubiquibot.eth
      • Bot Response: Successfully registered wallet address 0xFaF2BD96905b7DAf432534FF4Fa75D90A36614eE for user @ubiquibot.
  • Error Handling: The system gracefully handles errors such as invalid wallet addresses or ENS names, providing users with clear feedback to correct their inputs.

    • Example:
      • User Input: /wallet invalid_address
      • Bot Response: Error: The provided wallet address is invalid. Please enter a valid Ethereum address or ENS name.

This implementation ensures that users have a seamless and secure way to manage their wallets directly through GitHub interactions, enhancing the overall user experience and streamlining the rewards collection process.

@gentlementlegen
Copy link
Member Author

@UbiquityOS assign me to this issue

@gentlementlegen
Copy link
Member Author

@whilefoo Isn't this how it is supposed to be used?

@0x4007
Copy link
Member

0x4007 commented Nov 26, 2024

The bot response is totally off topic. It is accurate for wallet but this issue has nothing to do with wallet. Why is this happening? @sshivaditya2019

@gentlementlegen
Copy link
Member Author

@UbiquityOS assign me to this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants