Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@1yam
Copy link
Member

@1yam 1yam commented Apr 29, 2025

On aleph-client we never really handle Vouchers we only accept it as args and trust the input,
now we want to be able to fetch Vouchers to ensure user have it .

Related ClickUp, GitHub or Jira tickets : ALEPH-458 (This feature is missing for this tickets)

Self proofreading checklist

  • The new code clear, easy to read and well commented.
  • New code does not duplicate the functions of builtin or popular libraries.
  • An LLM was used to review the new code and look for simplifications.
  • New classes and functions contain docstrings explaining what they provide.
  • All new code is covered by relevant tests.

Changes

This pull request introduces a new VoucherManager class and associated functionality to manage and display voucher information within the aleph_client. It enhances the balance command to show voucher details, adds a new vouchers command for detailed voucher information, and integrates voucher handling into the instance creation process. Additionally, a new voucher.py file implements the core logic for fetching and processing vouchers.

Voucher Management Integration:

  • New VoucherManager Class: Added voucher.py to handle voucher-related operations, including fetching metadata, Solana vouchers, and EVM vouchers. The class provides methods like get_all, fetch_vouchers_by_chain, and fetch_metadata. (src/aleph_client/voucher.py)
  • Voucher Models: Introduced Voucher, VoucherMetadata, and VoucherAttribute models using Pydantic for structured data representation. (src/aleph_client/voucher.py)

Command Enhancements:

  • balance Command Update: Enhanced the balance command to display basic voucher information by integrating VoucherManager. (src/aleph_client/commands/account.py) [1] [2]
  • New vouchers Command: Added a new command to display detailed voucher information, including attributes and descriptions, in a formatted table using the rich library. (src/aleph_client/commands/account.py)

Instance Creation Updates:

  • NFT Payment Type: Integrated VoucherManager into the instance creation process to handle NFT-based voucher payments, including chain-specific voucher fetching. (src/aleph_client/commands/instance/__init__.py)

Dependencies and Imports:

  • New Imports: Added necessary imports for VoucherManager and rich library components in the relevant files. (src/aleph_client/commands/account.py, src/aleph_client/commands/instance/__init__.py) [1] [2] [3]

How to test

To be tested :
Account with chain {AVAX SOL BASE}
Create instance with nft payment method

Print screen / video

aleph account balance
image

aleph account balance --address Boy5zDxzcX63bsACiavM4R2hyXSMiWZZA5D7uTp2BQ4n
image

aleph account vouchers
image

aleph account vouchers --address 6VJFTyxctk7UAYsqjiqQK7BVvfRYZwJ5BgtPnyjqjGNn
image

Notes

The Voucher Class should be move to the sdk in the future

@1yam 1yam requested a review from nesitor April 29, 2025 12:54
@aleph-im aleph-im deleted a comment from github-actions bot May 7, 2025
@nesitor nesitor merged commit d83c877 into master May 7, 2025
15 checks passed
@nesitor nesitor deleted the 1yam-voucher branch May 7, 2025 11:17
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.

3 participants