hyperledger / iroha-javascript

JavaScript library for Iroha, a Distributed Ledger Technology (blockchain) platform.
https://wiki.hyperledger.org/display/iroha
Apache License 2.0
94 stars 64 forks source link

Unexpected type (Quantity / Fixed) #179

Closed 6r1d closed 7 months ago

6r1d commented 7 months ago

Matías Salimbene reported an issue with types in Iroha JS SDK today.

Transaction validation failed reason=Validation failed caused_by=Some(InstructionFailed(Evaluate(Type(AssetValueType(Mismatch { expected: Fixed, actual: Quantity })))))

The valueType is correctly registered as Quantity (not Fixed).

    "value_type": {
        "enum": {
            "tag": "Quantity"
        }
    }

Additionaly, Matías gets an error if he doesn't provide the quantity with decimal precision, i.e quantity: "100" fails, but quantity:"100.0" is fine. He'd like to know whether this should be expected.

Provided context:

a1salimbene commented 7 months ago

I found the problem, I was following an example from the unit tests that created value as Fixed, instead of numericU32.

Now I can pass quantity as number: "quantity": 100.0, I had to define the value as numericU32 to be parsed correctly.