Skip to content
This repository was archived by the owner on Nov 15, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes to this project are documented in this file.
- Fix shutdown operations when initializing np-api-server and setting minpeers/maxpeers, opening a wallet, or changing databases
- Minor improvement to network recovery logic when running out of good node addresses
- Fix NEP-5 contract detection causing an EventHub exception due to wrong ApplicationEngine initialization
- Hide contract script in `search contract` output for easier reading of search results

[0.9.1] 2019-09-16
------------------
Expand Down
12 changes: 8 additions & 4 deletions neo/Core/FunctionCode.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def Serialize(self, writer):
writer.WriteVarBytes(self.ParameterList)
writer.WriteByte(self.ReturnType)

def ToJson(self):
def ToJson(self, verbose=True):
"""
Convert object members to a dictionary that can be parsed as JSON.

Expand All @@ -98,9 +98,13 @@ def ToJson(self):
"""
parameters = self.ParameterList.hex()
paramlist = [ToName(ContractParameterType.FromString(parameters[i:i + 2]).value) for i in range(0, len(parameters), 2)]
if verbose:
return {
'hash': self.ScriptHash().To0xString(),
'script': self.Script.hex(),
'parameters': paramlist,
'returntype': ToName(self.ReturnType) if type(self.ReturnType) is int else ToName(int(self.ReturnType))
}
return {
'hash': self.ScriptHash().To0xString(),
'script': self.Script.hex(),
'parameters': paramlist,
'returntype': ToName(self.ReturnType) if type(self.ReturnType) is int else ToName(int(self.ReturnType))
}
5 changes: 2 additions & 3 deletions neo/Core/State/ContractState.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def DetermineIsNEP5(self):
self._is_nep5 = True
return self._is_nep5

def ToJson(self):
def ToJson(self, verbose=True):
"""
Convert object members to a dictionary that can be parsed as JSON.

Expand All @@ -185,7 +185,7 @@ def ToJson(self):

jsn = {'version': self.StateVersion}

jsn_code = self.Code.ToJson()
jsn_code = self.Code.ToJson(verbose=verbose)

jsn_contract = {
'name': name,
Expand All @@ -199,7 +199,6 @@ def ToJson(self):
'payable': self.Payable
}
}

jsn.update(jsn_code)
jsn.update(jsn_contract)

Expand Down
2 changes: 1 addition & 1 deletion neo/Prompt/Commands/Search.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def execute(self, arguments):
contracts = Blockchain.Default().SearchContracts(query=item)
print("Found %s results for %s" % (len(contracts), item))
for contract in contracts:
print(json.dumps(contract.ToJson(), indent=4))
print(json.dumps(contract.ToJson(verbose=False), indent=4))
return contracts
else:
print("run `%s %s help` to see supported queries" % (CommandSearch().command_desc().command, self.command_desc().command))
Expand Down