Strung type in Strato API swagger documentation


#1

I’m trying to write unit test against my application logic using your Strato and Bloc APIs in a strongly type, functional language. I’m creating my types at runtime using your swagger json documentation. In the Strato API swagger documentation, the GET /account endpoint purports to return the following json:

[
    {
    "contractRoot": "64e604787cbf194841e7b68d7cd28786f6c9a0a3ab9f8b0a0e87cb4387ab0107",
    "kind": "AddressStateRef",
    "balance": "123",
    "address": "00000000000000000000000000000000deadbeef",
    "latestBlockNum": 23,
    "codeHash": "157dbaa9b67adce425ab2c9398f1017944d4b898aabab5a9d4507b3ae11afc61",
    "code": "60606040526000357c01000000000000000000000000000000000000000000000000000000009004806360fe47b11460415780636d4ce63c14605757603f565b005b605560048080359060200190919050506078565b005b606260048050506086565b6040518082815260200191505060405180910390f35b806000600050819055505b50565b600060006000505490506094565b9056",
    "nonce": 42
    }
]

According to the model documentation of this response, this json represents the Account class. The Account class has a field, ‘balance’ that is type ‘Strung’. The ‘Strung’ class has one property, ‘unstrung’ which is a number. The example json response above makes sense to me, however, if I’m specifically following the swagger documentation, I believe the Account json should look like this:

 [
     {
        "contractRoot": "64e604787cbf194841e7b68d7cd28786f6c9a0a3ab9f8b0a0e87cb4387ab0107",
        "kind": "AddressStateRef",
        "balance": { 
            "unstrung": 123 
        },
        "address": "00000000000000000000000000000000deadbeef",
        "latestBlockNum": 23,
        "codeHash": "157dbaa9b67adce425ab2c9398f1017944d4b898aabab5a9d4507b3ae11afc61",
        "code": "60606040526000357c01000000000000000000000000000000000000000000000000000000009004806360fe47b11460415780636d4ce63c14605757603f565b005b605560048080359060200190919050506078565b005b606260048050506086565b6040518082815260200191505060405180910390f35b806000600050819055505b50565b600060006000505490506094565b9056",
        "nonce": 42
    }
]

The main difference being that the balance field is a Strung object with field unstrung, which is a number.

SO my question is: Why is balance field json schema pointed to the Strung type? Can you explain what this type is supposed to represent and maybe why it is needed instead of just saying the balance is a number? Maybe you could include type information on the balance field to make it a bit clearer. Let me know if I’m missing something in the Swagger 2.0 reference


#2

Hi @andrew!

Sorry for the confusion. This is a bug with how the model is created from it’s corresponding type. The Strung type is an internal type that our API’s generally don’t expose. If you’re curious, we use it as a intermediary type when parsing JSON that sometimes represents numbers as strings.

Thanks for letting us know. Our platform engineers are on it as we speak!

Cheers,
[email protected]


#3

Hey @charles-blockapps, thanks for the information. I really appreciate you guys taking a look at this. My solution for now has been to download the json swagger models and update them to fit the json returned by the api.

Would you mind posting back to this thread when this bug has been resolved?

On a related note, is there a way to stay in the loop on the updates to the STRATO Developer Edition? Right now, I run the ./strato-run.sh command. That let’s me see if the docker images have been updated, but it’s difficult to understand what the updates are. Are there some sort of public release notes by any chance?


#4

@andrew This was resolved earlier this week. Thanks for bringing it to our attention