Skip to content
This repository has been archived by the owner on Jun 7, 2023. It is now read-only.

Incorrect attribute names/types in getBalances response #7

Open
todofixthis opened this issue Oct 12, 2017 · 5 comments
Open

Incorrect attribute names/types in getBalances response #7

todofixthis opened this issue Oct 12, 2017 · 5 comments

Comments

@todofixthis
Copy link

From iotaledger/iota.py#55:

According to the getNodeInfo the IRI version of the sandbox is 1.4.0.

Calling getBalances on the sandbox returns

{
    "Duration": 0,
    "Balances": [0],
    "Milestone": "RXTDTARWZPYTWBFXDHGZDTCDYBWGMKAHDKIAYKKKGUTUNJAXIVIKYDVCTVE9WGJ9GAPFCEZOFYZPA9999",
    "MilestoneIndex": 233555
}

whereas running IRI v.1.4.0 locally (either via Java or Docker) returns

{
    "duration": 6,
    "balances": ["0"],
    "milestone": "999999999999999999999999999999999999999999999999999999999999999999999999999999999",
    "milestoneIndex": 217000
}

Note that the first letter of each JSON key is capitalised, and the balances are returned as integers instead of strings.

@todofixthis
Copy link
Author

todofixthis commented Oct 12, 2017

I think the incorrect type for balances is due to iotaledger/iota.go#11 I think the Go lib is doing the right thing; in my opinion, the sandbox application is the exception to the rule. For the majority of applications, I would expect that developers would prefer that balances are returned as integers rather than strings. The sandbox app is unique in that it acts as a proxy for IRI, so it has to return exactly what the IRI would in these situations.

@todofixthis
Copy link
Author

The capitalised attribute names may be due to iotaledger/iri#319

@knarz
Copy link
Collaborator

knarz commented Oct 14, 2017

This was fixed here iotaledger/iota.go@63fcd33, seems like the sandbox was just not updated.

As far as string vs. int goes, I'm open to change that to comply with the actual IRI API.

@todofixthis
Copy link
Author

todofixthis commented Oct 14, 2017

Thanks @knarz! Who is responsible for updating the sandbox?

WRT string vs. int, I think most libraries will work fine either way. There might be an edge case where the JS lib is trying to process a getBalances response from the Sandbox that contains really really big numbers (see https://stackoverflow.com/a/9643650/5568265). That's the only issue I can think of.

@todofixthis
Copy link
Author

btw did this fix ever get deployed to the Sandbox node?

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

No branches or pull requests

2 participants