diff --git a/contrib/privnet-claim-neo-and-gas.py b/contrib/privnet-claim-neo-and-gas.py index fb8dded46..85e9641b8 100644 --- a/contrib/privnet-claim-neo-and-gas.py +++ b/contrib/privnet-claim-neo-and-gas.py @@ -43,7 +43,6 @@ from neo.Implementations.Blockchains.LevelDB.LevelDBBlockchain import LevelDBBlockchain from neo.Wallets.KeyPair import KeyPair from neo.Prompt.Commands.LoadSmartContract import ImportMultiSigContractAddr -from neo.Prompt.Notify import SubscribeNotifications from neo.Core.Blockchain import Blockchain from neo.Fixed8 import Fixed8 from neo.Prompt.Commands.Send import construct_and_send @@ -301,7 +300,6 @@ def claim_initial_neo(self, target_address): blockchain = LevelDBBlockchain(settings.LEVELDB_PATH) Blockchain.RegisterBlockchain(blockchain) - SubscribeNotifications() reactor.suggestThreadPoolSize(15) NodeLeader.Instance().Start() diff --git a/contrib/privnet-claimall.py b/contrib/privnet-claimall.py index 96b14c1d2..8e02a27dc 100755 --- a/contrib/privnet-claimall.py +++ b/contrib/privnet-claimall.py @@ -33,7 +33,6 @@ from neo.Implementations.Blockchains.LevelDB.LevelDBBlockchain import LevelDBBlockchain from neo.Wallets.KeyPair import KeyPair from neo.Prompt.Commands.LoadSmartContract import ImportMultiSigContractAddr -from neo.Prompt.Notify import SubscribeNotifications from neo.Core.Blockchain import Blockchain from neo.Fixed8 import Fixed8 from neo.Core.TX.Transaction import TransactionOutput, ContractTransaction @@ -232,7 +231,6 @@ def run(self): # Setup the Blockchain blockchain = LevelDBBlockchain(settings.LEVELDB_PATH) Blockchain.RegisterBlockchain(blockchain) - SubscribeNotifications() # Create the claim pc = PrivnetClaimall(args.address) diff --git a/contrib/smartcontract.py b/contrib/smartcontract.py index 6a3991343..bba6d2083 100644 --- a/contrib/smartcontract.py +++ b/contrib/smartcontract.py @@ -1,3 +1,6 @@ +""" +Smart contract API to easily react to events from specific smart contracts. +""" import time from collections import defaultdict @@ -41,7 +44,7 @@ def __init__(self, contract_hash): assert contract_hash self.contract_hash = str(contract_hash) - # Register EventHub.events handlers to forward for SmartContract decorators + # Handle EventHub events for SmartContract decorators @events.on(SmartContractEvent.RUNTIME_NOTIFY) @events.on(SmartContractEvent.RUNTIME_LOG) @events.on(SmartContractEvent.EXECUTION_SUCCESS) diff --git a/neo/BigInteger.py b/neo/BigInteger.py index fbc5d2656..bdeb67188 100644 --- a/neo/BigInteger.py +++ b/neo/BigInteger.py @@ -5,6 +5,14 @@ class BigInteger(int): + @property + def Sign(self): + if self > 0: + return 1 + elif self == 0: + return 0 + return -1 + @staticmethod def FromBytes(data, signed=False): return BigInteger(int.from_bytes(data, 'little', signed=signed)) diff --git a/neo/VM/InteropService.py b/neo/VM/InteropService.py index e377e9fe8..9786f072f 100644 --- a/neo/VM/InteropService.py +++ b/neo/VM/InteropService.py @@ -258,9 +258,10 @@ def __init__(self, value): super(Struct, self).__init__(value) def Clone(self): - newArray = [] + length = len(self._array) + newArray = [None for i in range(0, length)] - for i in range(0, len(self._array)): + for i in range(0, length): if self._array[i] is None: newArray[i] = None elif self._array[i].IsStruct: diff --git a/neo/test_numbers.py b/neo/test_numbers.py index 995c9001b..754d3b439 100644 --- a/neo/test_numbers.py +++ b/neo/test_numbers.py @@ -153,6 +153,24 @@ def test_big_integer_frombytes(self): self.assertEqual(b1, b2) self.assertTrue(b1.Equals(b2)) + def test_big_integer_sign(self): + + b1 = BigInteger(3) + b2 = BigInteger(0) + b3 = BigInteger(-4) + self.assertEqual(b1.Sign, 1) + self.assertEqual(b2.Sign, 0) + self.assertEqual(b3.Sign, -1) + + c1 = BigInteger(-100) + c1_bytes = c1.ToByteArray() + + c2 = BigInteger.FromBytes(c1_bytes, signed=True) + self.assertEqual(c2.Sign, -1) + + c2_unsigned = BigInteger.FromBytes(c1_bytes, signed=False) + self.assertEqual(c2_unsigned.Sign, 1) + class UIntBaseTestCase(NeoTestCase): def test_initialization(self): diff --git a/prompt.py b/prompt.py index ef78ff373..3e4c29c42 100644 --- a/prompt.py +++ b/prompt.py @@ -700,7 +700,7 @@ def configure(self, args): print("smart contract event logging is now enabled") settings.set_log_smart_contract_events(True) if c1 == 'off' or c1 == '0': - print("smart contract event logging is now enabled") + print("smart contract event logging is now disabled") settings.set_log_smart_contract_events(False) else: diff --git a/requirements.txt b/requirements.txt index d663d464b..fb6081684 100644 --- a/requirements.txt +++ b/requirements.txt @@ -31,7 +31,7 @@ mmh3==2.5.1 mock==2.0.0 mpmath==1.0.0 neo-boa==0.1.8 -neo-python-rpc==0.1.6 +neo-python-rpc==0.1.8 numpy==1.13.3 pbr==3.1.1 peewee==2.10.2