hyperledger-iroha / iroha-python

Python library for Hyperledger Iroha, a simple distributed ledger.
https://wiki.hyperledger.org/display/iroha
Apache License 2.0
103 stars 81 forks source link

Incorporate an optional title parameter into the AddAssetQuantity and SubtractAssetQuantity function for the Python client, aligning with the enhanced functionality within Iroha Core for optimized message communication. #157

Closed dominious1 closed 8 months ago

dominious1 commented 11 months ago

Introduce an optional title parameter to the commands.proto bufs GRPC for AddAssetQuantity and SubtractAssetQuantity. This enhancement facilitates a more flexible and comprehensive feature set, aligning with evolving requirements and ensuring seamless integration with the protobuf-based GRPC implementation.

Technology stack:

To regenerate files based on predefined protobufs I used iroha-python/scripts/compile-proto.py

This is part of internship project: https://wiki.hyperledger.org/display/INTERN/Iroha+1%3A+extend+queries+with+optional+arguments

Link to PR to iroha repository compatible with those changes: https://github.com/hyperledger/iroha/pull/4003

dominious1 commented 11 months ago

Generated files added after adding new parameter.

baziorek commented 11 months ago

Generated files added after adding new parameter.

Great!

As I remember there were some problems with protobuf files when they were generated with too new protobuf. Please provide some information how You generated those files, what is Your OS? What version is of protoc in Your system?

And one more think - please correct DCO: image when You click "Details" You will see commands how to fix

andprogrammer commented 8 months ago

Fantastic pull request. Thank you.

baziorek commented 8 months ago

To make sure that everything is working I checked:

  1. I've build Iroha 1 from main (all changes are merged)
  2. I've performed commands to install from the PR locally:
    mkdir checking_internship
    cd checking_internship
    python -m venv $(pwd)/venv
    source ./venv/bin/activate
    pip3 install git+https://github.com/dominious1/iroha-python.git@addtitleparamtoAddAssetQuantity
  3. Then I run attached code: code.py (code.zip) Most important part of the file is running the function:
    def add_coin_to_admin_with_description(asset: str, amount='1000.00', desc=''):
    """
    Add provided amount of specific units to admin account
    """
    tx = iroha.transaction([
        iroha.command('AddAssetQuantity',
                      asset_id=asset, amount=amount, description=desc)
    ])
    IrohaCrypto.sign_transaction(tx, ADMIN_PRIVATE_KEY)
    send_transaction_and_print_status(tx)
  4. The output contained those commands (full output in file: fullOputput.txt )"
    transactions {
    payload {
      reduced_payload {
        commands {
          add_asset_quantity {
            asset_id: "coin#domain"
            amount: "102"
            description: "Testing description"
          }
        }
        creator_account_id: "admin@test"
        created_time: 1707045588320
        quorum: 1
      }
    }
    signatures {
      public_key: "313a07e6384776ed95447710d15e59148473ccfc052a681317a72a69f2a49910"
      signature: "7a904afaaa208fdb9ec0695e4c6f6acb3f36578d2af46741c143a9e3726b8de0b1b71fc323bdc0c27fbbdbe939298393476dd5b89d1e390e424004185a8cb101"
    }
    }
  5. I've checked in blocks files - the transaction is available amoungh commands:
    jq '.blockV1.payload.transactions[0].payload.reducedPayload' < 0000000000000004
    {
    "commands": [
    {
      "addAssetQuantity": {
        "assetId": "coin#domain",
        "amount": "102",
        "description": "Testing description"
      }
    }
    ],
    "creatorAccountId": "admin@test",
    "createdTime": "1707045588320",
    "quorum": 1
    }

    IMO it is done - fully working!