diff --git a/.gitmodules b/.gitmodules
index 8737ea8..fd4027c 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,3 @@
-[submodule "ccurl"]
- path = ccurl
+[submodule "ccurl_repo/ccurl"]
+ path = ccurl_repo/ccurl
url = https://github.com/iotaledger/ccurl.git
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..1d9885a
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,23 @@
+language: python
+python:
+- '2.7'
+- '3.5'
+- '3.6'
+- '3.7'
+before_install: "./init.sh"
+install:
+- pip install .
+script:
+- nosetests
+deploy:
+ on:
+ python: '3.7'
+ tags: true
+ provider: pypi
+ distributions: bdist_wheel sdist
+ skip_cleanup: true
+ skip_upload_docs: true
+ skip_existing: true
+ user: __token__
+ password:
+ secure: ppsDd45z2dXEm+fRP8gTSldI+re64/Q+Q8iRXxKUB22mcbkVUEaqNpYrjd7juQIL1T/LncMunSE8vqd+rEEHcVbLR5nCOyjjPaeXdeQaqWlGCUII3TH6o1V7WhnKG4JM9CocOJNLP3COKmxacfH6e+O8iw1dgrDxXx27Erff82xYlTLBBFsEPYk4njvk0ghe5FztOpMT/im2gNglB27PSFawIEbE7DWVxjD7Bv+dSoGKvgxFnTyfVaIQD2y2NAc0PazLSNRFa6tRmMmKePkzxkN3u7Zupao/SHCZRzCA0d9VlcMmFhFzS28V7pfKz/bj5Xz+9u8WnS3TotJGaEFHKj1pnAoRqw0wVdFlsryCt2FT/ZJfYMrTDViGh8x/ZfVUrLbwQjUHcAhsa2JGDThSTqGc3Arz67hkcQa1Asqtm9Pt+GbhskmbTinFRPt0aS//Ncd6jiMcfw3uzN3d0x60ftwPH26Zd8PjVtTnTv6RVJcVKSh5GrUhBDKUsjguEL0124eMLixfSqwMYG8PfhO3PYpHv5wqSvEL+tuexLxavvy1m927XWhufAFbcuezLb7ePLmJrzvL2NpbuO1KU8CIO/6U2DzptEB/TGbL5N5kY/1CLUvls1GSoF435tg13qG1N+nDoocI/rXVlbg9hDcQUV+WrIyhj6aCleWwIt8lyxU=
diff --git a/README.rst b/README.rst
index a745021..7014f6f 100644
--- a/README.rst
+++ b/README.rst
@@ -23,9 +23,9 @@ Installation
To use the module, follow the steps: - Clone the repo from GitHub:
-``$ git clone https://github.com/lzpap/ccurl.interface.py.git``
+``$ git clone https://github.com/iotaledger/ccurl.interface.py.git``
-- Make sure you have `cmake `__ availabke on your
+- Make sure you have `cmake `__ available on your
system. This is a build dependecy for the ccurl library.
- Build ccurl according to `build
instructions `__
@@ -55,17 +55,17 @@ Code Example
::
import iota
- from pprint import *
+ from pprint import pprint
from pow import ccurl_interface
# Generate seed
myseed = iota.crypto.types.Seed.random()
- #Generate two addresses
+ # Generate two addresses
addres_generator = iota.crypto.addresses.AddressGenerator(myseed)
addys = addres_generator.get_addresses(1, count=2)
- # preparing transactions
+ # Preparing transactions
pt = iota.ProposedTransaction(address = iota.Address(addys[0]),
tag = iota.Tag(b'LOCALATTACHINTERFACE99999'),
value = 0)
@@ -74,16 +74,16 @@ Code Example
tag = iota.Tag(b'LOCALATTACHINTERFACE99999'),
value = 0)
- # preparing bundle that consists of both transactions prepared in the previous example
+ # Preparing bundle that consists of both transactions prepared in the previous example
pb = iota.ProposedBundle(transactions=[pt2,pt])
- # generate bundle hash
+ # Generate bundle hash
pb.finalize()
- # declare a api instance
- api = iota.Iota("https://nodes.thetangle.org:443") # selecting IOTA node
+ # Declare an api instance
+ api = iota.Iota("https://nodes.thetangle.org:443")
- # get tips to be approved by your bundle
+ # Get tips to be approved by your bundle
gta = api.get_transactions_to_approve(depth=3)
minimum_weight_magnitude = 14 # target is mainnet
@@ -96,7 +96,7 @@ Code Example
gta['branchTransaction'],
mwm
)
-
+
# Broadcast transactions on the Tangle
broadcasted = api.broadcast_and_store(bundle_trytes)
@@ -115,4 +115,4 @@ Contribute
----------
Raise issues:
-https://github.com/lzpap/ccurl.interface.py/issues
+https://github.com/iotaledger/ccurl.interface.py/issues
diff --git a/ccurl b/ccurl_repo/ccurl
similarity index 100%
rename from ccurl
rename to ccurl_repo/ccurl
diff --git a/init.sh b/init.sh
index 452a02f..14f3d6e 100755
--- a/init.sh
+++ b/init.sh
@@ -1,18 +1,23 @@
-#!/bin/bash
+#!/usr/bin/env bash
+
+# ccurl submodule can't be at root level, because then naming collides with
+# pyota-ccurl's naming in iota.py repo.
+# In iota.crypto.__init__, `from ccurl import ...` tries to import
+# from this `ccurl` rather then from `pyota-ccurl`, that results in ImportError.
# Updating ccurl submodule
git submodule update --init --recursive
# Delete binaries if present
rm -f pow/libccurl.so
-#rm -f pow/helpers.dll
+
# Get current working directory
WD=$(pwd)
# Bulding using cmake
echo "Building ccurl library with cmake..."
-cd ccurl && mkdir -p build && cd build && cmake .. && cmake --build .
-cd ../..
-LIB=$(find . -name "*.so")
+cd ccurl_repo/ccurl && mkdir -p build && cd build && cmake .. && cmake --build .
+cd ../../..
+LIB=$(find ./ccurl_repo -name "*.so")
echo "The built library is at:"
echo $LIB
diff --git a/pow/ccurl_interface.py b/pow/ccurl_interface.py
index 49f43b4..9b6b861 100644
--- a/pow/ccurl_interface.py
+++ b/pow/ccurl_interface.py
@@ -1,5 +1,9 @@
+from __future__ import absolute_import, division, print_function, \
+ unicode_literals
+
from ctypes import *
-import iota
+from iota import Bundle, TransactionTrytes, TransactionHash, TryteString, \
+ Transaction
import math
import time
from iota.exceptions import with_context
@@ -24,10 +28,10 @@ def check_tx_trytes_length(trytes):
"""
Checks if trytes are exactly one transaction in length.
"""
- if len(trytes) != iota.TransactionTrytes.LEN:
+ if len(trytes) != TransactionTrytes.LEN:
raise with_context(
exc=ValueError('Trytes must be {len} trytes long.'.format(
- len= iota.TransactionTrytes.LEN
+ len= TransactionTrytes.LEN
)),
context={
@@ -105,7 +109,7 @@ def attach_to_tangle(bundle_trytes, # Iterable[TryteString]
previoustx = None
# Construct bundle object
- bundle = iota.Bundle.from_tryte_strings(bundle_trytes)
+ bundle = Bundle.from_tryte_strings(bundle_trytes)
# reversed, beause pyota bundles look like [...tx2,tx1,tx0]
# and we need the tail tx first (tx0)
@@ -129,14 +133,14 @@ def attach_to_tangle(bundle_trytes, # Iterable[TryteString]
# returns a python unicode string
powed_txn_string = get_powed_tx_trytes(txn_string, mwm)
# construct trytestring from python string
- powed_txn_trytes = iota.TryteString(powed_txn_string)
+ powed_txn_trytes = TryteString(powed_txn_string)
# compute transaction hash
hash_string = get_hash_trytes(powed_txn_string)
- hash_trytes = iota.TryteString(hash_string)
- hash_= iota.TransactionHash(hash_trytes)
+ hash_trytes = TryteString(hash_string)
+ hash_= TransactionHash(hash_trytes)
# Create powed txn object
- powed_txn = iota.Transaction.from_tryte_string(
+ powed_txn = Transaction.from_tryte_string(
trytes=powed_txn_trytes,
hash_=hash_
)
diff --git a/setup.py b/setup.py
index be20b0b..bf4d3d8 100644
--- a/setup.py
+++ b/setup.py
@@ -6,8 +6,8 @@
setup(
name = 'PyOTA-PoW',
description = 'Ccurl PoW Interface for PyOTA',
- url = 'https://github.com/lzpap/ccurl.interface.py',
- version = '1.0.1',
+ url = 'https://github.com/iotaledger/ccurl.interface.py',
+ version = '1.0.2',
long_description = long_description,
packages=['pow'],
diff --git a/test/test_ccurl_interface.py b/test/test_ccurl_interface.py
index 25222d2..d21b5e4 100644
--- a/test/test_ccurl_interface.py
+++ b/test/test_ccurl_interface.py
@@ -3,7 +3,6 @@
from unittest import TestCase
from pow import ccurl_interface
-import iota
class CcurlPowTestcase(TestCase):
"""