Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

Commit

Permalink
Merge branch 'development' of https://github.com/CityOfZion/neo-python
Browse files Browse the repository at this point in the history
…into development

* 'development' of https://github.com/CityOfZion/neo-python:
  Typo: when disabling sc-events in prompt, now says "disabled"
  requirements.txt update neo-python-rpc to 0.1.8 (fixes #96)
  fix for #95, fix for #94
  Fixed contrib/claim* scripts by removing SubscribeNotifications
  • Loading branch information
ixje committed Nov 21, 2017
2 parents 2c11abe + 58ee377 commit db617bf
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 9 deletions.
2 changes: 0 additions & 2 deletions contrib/privnet-claim-neo-and-gas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 0 additions & 2 deletions contrib/privnet-claimall.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion contrib/smartcontract.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
Smart contract API to easily react to events from specific smart contracts.
"""
import time

from collections import defaultdict
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions neo/BigInteger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
5 changes: 3 additions & 2 deletions neo/VM/InteropService.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 18 additions & 0 deletions neo/test_numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit db617bf

Please sign in to comment.