-
Notifications
You must be signed in to change notification settings - Fork 124
Incorrect attribute names in GetBalancesCommand response (using sandbox example script) #55
Comments
Hi @johngrantuk! Thanks for reporting this issue! This looks like a problem with the sandbox node. Could I ask you to collect a little extra debugging info? Please run the following commands: from iota import *
from iota.adapter.sandbox import SandboxAdapter
iota =\
Iota(
adapter = SandboxAdapter(
uri = 'https://sandbox.iota.org/api/v1/',
# Replace with your auth token.
auth_token = 'auth token goes here',
),
)
import logging, sys
logging.basicConfig(level=logging.DEBUG, stream=sys.stderr)
iota.api.set_logger(logging.getLogger(__name__))
iota.get_balances([b'A']) You can scrub out your auth token if it appears in the debug output; what I'm most interested in is the raw response payload from the sandbox. It appears that the sandbox is incorrectly capitalising the attribute names, but I need to confirm. |
I had to add from future import absolute_import, division, print_function, unicode_literals otherwise I got "AttributeError: 'str' object has no attribute 'scheme'". With this added the output is: Traceback (most recent call last): |
Ahhh, shoot. Sorry about that; I copied the wrong command. It should be iota.adapter.set_logger. This is the corrected code: from iota import *
from iota.adapter.sandbox import SandboxAdapter
iota =\
Iota(
adapter = SandboxAdapter(
uri = u'https://sandbox.iota.org/api/v1/',
# Replace with your auth token.
auth_token = 'auth token goes here',
),
)
import logging, sys
logging.basicConfig(level=logging.DEBUG, stream=sys.stderr)
iota.adapter.set_logger(logging.getLogger(__name__))
iota.get_balances([b'A']) |
All good. New output below: DEBUG:main:Sending post to https://sandbox.iota.org/api/v1/commands: '{"threshold": 100, "command": "getBalances", "addresses": ["A99999999999999999999999999999999999999999999999999999999999999999999999999999999"]}' |
Thanks John! Hmm... that's interesting. Looks like the sandbox node is using the wrong case for attribute names in the response after all. I'm-a ping Dom about this to see if this is an issue with the sandbox, or if the attribute names changed in a recent version of the IRI. As soon as I find out what's up, fixing this issue will be top priority. |
Any news on this one? According to the Calling
whereas running IRI v.1.4.0 locally (either via Java or Docker) returns
There is definitely a difference. The first letter of each JSON key is capitalised. There might be an issue with the JSON serialiser at the sandbox runtime. |
Hey guys. Sorry that this is taking so long to resolve! I've logged a couple of issues with the Sandbox and Go projects, and I bugged the IF folks again. This one is a bit tricky to resolve because the issues appear to be caused by core libraries, rather than the sandbox code (thanks @jinnerbichler for the detective work on the capitalised JSON attributes!). Keep an eye on these issues: |
I'm going to go ahead and close this issue, as it's not really a problem with PyOTA. Do keep an eye on the issues linked in the previous comment; if necessary, we can escalate this with the sandbox/iri teams on Discord. |
PyOTA 1.1.3
Python 2.7.10
Mac OS El Capitan 10.11.6
Description:
Running sandbox example. iota.send_transfer gives following error: TypeError: 'NoneType' object is not iterable
Traceback:
Traceback (most recent call last):
File "sandbox.py", line 51, in
message = TryteString.from_string('Hello, Tangle!'),
File "/Users/johngrant/Downloads/iota/env/lib/python2.7/site-packages/iota/api.py", line 822, in send_transfer
minWeightMagnitude = min_weight_magnitude,
File "/Users/johngrant/Downloads/iota/env/lib/python2.7/site-packages/iota/commands/init.py", line 122, in call
self.response = self._execute(self.request)
File "/Users/johngrant/Downloads/iota/env/lib/python2.7/site-packages/iota/commands/extended/send_transfer.py", line 46, in _execute
transfers = transfers,
File "/Users/johngrant/Downloads/iota/env/lib/python2.7/site-packages/iota/commands/init.py", line 122, in call
self.response = self._execute(self.request)
File "/Users/johngrant/Downloads/iota/env/lib/python2.7/site-packages/iota/commands/extended/prepare_transfer.py", line 54, in _execute
threshold = want_to_spend,
File "/Users/johngrant/Downloads/iota/env/lib/python2.7/site-packages/iota/commands/init.py", line 122, in call
self.response = self._execute(self.request)
File "/Users/johngrant/Downloads/iota/env/lib/python2.7/site-packages/iota/commands/extended/get_inputs.py", line 62, in _execute
for i, balance in enumerate(gb_response['balances']):
TypeError: 'NoneType' object is not iterable
Possible fix? (Creating a Pull request)
In get_inputs.py, Line 51, gb_response = GetBalancesCommand( ) is returning: {u'MilestoneIndex': 123423, …. u'Duration': 0, u'Balances': [0, 0, 41, 0, 0, 0]}
Line 62 uses: enumerate(gb_response['balances'])
Changing 'balances' to 'Balances' seems to fix the problem.
The text was updated successfully, but these errors were encountered: