Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #30 from CityOfZion/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
localhuman committed Jan 17, 2018
2 parents 799bb37 + 445e434 commit f9753d6
Show file tree
Hide file tree
Showing 40 changed files with 483 additions and 165 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -49,7 +49,7 @@ The compiler supports a subset of the Python language ( in the same way that a _
#### Get Help or give help

- Open a new [issue](https://github.com/CityOfZion/neo-boa/issues/new) if you encounter a problem.
- Or ping **@localhuman** on the [NEO Slack](https://join.slack.com/t/neoblockchainteam/shared_invite/MjE3ODMxNDUzMDE1LTE1MDA4OTY3NDQtNTMwM2MyMTc2NA).
- Or ping **@localhuman** on the [NEO official community chatroom](https://discord.gg/R8v48YA).
- Pull requests welcome. New features, writing tests and documentation are all needed.


Expand Down Expand Up @@ -124,7 +124,7 @@ Tests are important.

## License

- Open-source [MIT](https://github.com/CityOfZion/neo-python/blob/master/LICENSE.md).
- Open-source [MIT](LICENSE.md).
- Main author is [@localhuman](https://github.com/localhuman).


Expand Down
79 changes: 50 additions & 29 deletions README.rst
Expand Up @@ -3,24 +3,24 @@
Python compiler for the Neo Virtual Machine
===========================================


- `Overview`_
- `Installation`_
- `Usage`_
- `License`_
- `Tests`_
- `Donatitons`_

Overview
--------

A Python compiler for the Neo Virtual Machine
The ``neo-boa`` compiler is a tool for compiling Python files to the
``.avm`` format for usage in the `Neo Virtual
Machine <https://github.com/neo-project/neo-vm/>`__ which is used to
execute contracts on the `Neo
Blockchain <https://github.com/neo-project/neo/>`__.

The compiler supports a subset of the Python language ( in the same way
that a *boa constrictor* is a subset of the Python snake species)

What does it currently do
^^^^^^^^^^^^^^^^^^^^^^^^^

- Compiles a subset of the Python language to the ``.avm`` format for
use in the `Neo Virtual Machine`_
use in the `Neo Virtual
Machine <https://github.com/neo-project/neo-vm>`__
- Works for Python 3.4 and 3.5

What will it do
Expand All @@ -32,8 +32,11 @@ What will it do
Get Help or give help
^^^^^^^^^^^^^^^^^^^^^

- Open a new `issue`_ if you encounter a problem.
- Or ping **@localhuman** on the `NEO Slack`_.
- Open a new
`issue <https://github.com/CityOfZion/neo-boa/issues/new>`__ if you
encounter a problem.
- Or ping **@localhuman** on the `NEO official community
chatroom <https://discord.gg/R8v48YA>`__.
- Pull requests welcome. New features, writing tests and documentation
are all needed.

Expand All @@ -47,25 +50,48 @@ Pip

pip install neo-boa

Docker
^^^^^^

This project contains a Dockerfile to batch compile Python smart
contracts. Clone the repository and navigate into the docker sub
directory of the project. Run the following command to build the
container:

::

docker build -t neo-boa .

The neo-boa Docker container takes a directory on the host containing
python smart contracts as an input and a directory to compile the .avm
files to as an output. It can be executed like this:

::

docker run -it -v /absolute/path/input_dir:/python-contracts -v /absolute/path/output_dir:/compiled-contracts neo-boa

The -v (volume) command maps the directories on the host to the
directories within the container.

Manual
^^^^^^

Clone the repository and navigate into the project directory. Make a
Python 3 virtual environment and activate it via
Python 3 virtual environment and activate it via:

::

python3 -m venv venv
source venv/bin/activate

or to install Python 3.5 specifically
or, to install Python 3.5 specifically:

::

virtualenv -p /usr/local/bin/python3.5 venv
source venv/bin/activate

Then install requirements
Then, install the requirements:

::

Expand All @@ -74,14 +100,20 @@ Then install requirements
Usage
-----

The compiler may be used like the following
The compiler may be used like in the following example:

::

from boa.compiler import Compiler

Compiler.load_and_save('path/to/your/file.py')

Docs
----

You can `read the docs
here <http://neo-boa.readthedocs.io/en/latest/>`__.

Tests
-----

Expand All @@ -90,21 +122,10 @@ Tests are important.
License
-------

- Open-source `MIT`_.
- Main author is **localhuman** [ https://github.com/localhuman ].
- Open-source `MIT <LICENSE.md>`__.
- Main author is `localhuman <https://github.com/localhuman>`__.

Donations
---------

Accepted at **ATEMNPSjRVvsXmaJW4ZYJBSVuJ6uR2mjQU**

.. _Overview: #overview
.. _Installation: #installation
.. _Usage: #usage
.. _License: #license
.. _Tests: #tests
.. _Donatitons: #donations
.. _Neo Virtual Machine: https://github.com/neo-project/neo-vm
.. _issue: https://github.com/CityOfZion/neo-boa/issues/new
.. _NEO Slack: https://join.slack.com/t/neoblockchainteam/shared_invite/MjE3ODMxNDUzMDE1LTE1MDA4OTY3NDQtNTMwM2MyMTc2NA
.. _MIT: https://github.com/CityOfZion/neo-python/blob/master/LICENSE.md
2 changes: 1 addition & 1 deletion boa/blockchain/vm/Neo/Account.py
@@ -1,5 +1,5 @@

class Account():
class Account:

@property
def ScriptHash(self):
Expand Down
2 changes: 1 addition & 1 deletion boa/blockchain/vm/Neo/Asset.py
@@ -1,5 +1,5 @@

class Asset():
class Asset:

@property
def AssetId(self):
Expand Down
14 changes: 9 additions & 5 deletions boa/blockchain/vm/Neo/Block.py
@@ -1,8 +1,7 @@
from boa.blockchain.vm.Neo.Transaction import *
from boa.blockchain.vm.Neo.Header import GetIndex, GetHash, GetPrevHash, GetTimestamp, GetVersion, GetNextConsensus, GetMerkleRoot, GetConsensusData


class Block():
class Block:

@property
def TransactionCount(self):
Expand All @@ -22,6 +21,11 @@ def Transactions(self):

@property
def Index(self):
"""
Returns:
"""
return GetIndex(self)

@property
Expand Down Expand Up @@ -81,7 +85,7 @@ def NextConsensus(self):
return GetNextConsensus(self)


def GetTransactionCount(block: Block) -> int:
def GetTransactionCount(block):
"""
returns the number of transactions in a block
Expand All @@ -91,7 +95,7 @@ def GetTransactionCount(block: Block) -> int:
pass


def GetTransactions(block: Block) -> list:
def GetTransactions(block):
"""
returns a list of transactions contained in a block
Expand All @@ -100,7 +104,7 @@ def GetTransactions(block: Block) -> list:
pass


def GetTransaction(block: Block, index: int) -> Transaction:
def GetTransaction(block, index):
"""
:param block: the block to get the transaction from
Expand Down
22 changes: 8 additions & 14 deletions boa/blockchain/vm/Neo/Blockchain.py
@@ -1,66 +1,60 @@
from boa.blockchain.vm.Neo.Header import *
from boa.blockchain.vm.Neo.Block import *
from boa.blockchain.vm.Neo.Transaction import *
from boa.blockchain.vm.Neo.Account import *
from boa.blockchain.vm.Neo.Asset import *
from boa.blockchain.vm.Neo.Contract import *


def GetHeight() -> int:
def GetHeight():
"""
"""
pass


def GetHeader(height_or_hash) -> Header:
def GetHeader(height_or_hash):
"""
:param height_or_hash:
"""
pass


def GetBlock(height_or_hash) -> Block:
def GetBlock(height_or_hash):
"""
:param height_or_hash:
"""
pass


def GetTransaction(hash) -> Transaction:
def GetTransaction(hash):
"""
:param hash:
"""
pass


def GetAccount(script_hash) -> Account:
def GetAccount(script_hash):
"""
:param script_hash:
"""
pass


def GetValidators() -> []:
def GetValidators():
"""
"""
pass


def GetAsset(asset_id) -> Asset:
def GetAsset(asset_id):
"""
:param asset_id:
"""
pass


def GetContract(script_hash) -> Contract:
def GetContract(script_hash):
"""
:param script_hash:
Expand Down
2 changes: 1 addition & 1 deletion boa/blockchain/vm/Neo/Contract.py
@@ -1,5 +1,5 @@

class Contract():
class Contract:

@property
def Script(self):
Expand Down
18 changes: 9 additions & 9 deletions boa/blockchain/vm/Neo/Header.py
@@ -1,6 +1,6 @@


class Header():
class Header:

def getmyhash(self):
return GetHash(self)
Expand Down Expand Up @@ -66,7 +66,7 @@ def NextConsensus(self):
return GetNextConsensus(self)


def GetIndex(header: Header) -> int:
def GetIndex(header):
"""
Returns the height/index of a header
Args:
Expand All @@ -78,7 +78,7 @@ def GetIndex(header: Header) -> int:
pass


def GetHash(header: Header) -> bytearray:
def GetHash(header):
"""
gets the hash of the header
Expand All @@ -87,7 +87,7 @@ def GetHash(header: Header) -> bytearray:
pass


def GetVersion(header: Header) -> int:
def GetVersion(header):
"""
gets the version of the header
Expand All @@ -96,7 +96,7 @@ def GetVersion(header: Header) -> int:
pass


def GetPrevHash(header: Header) -> bytearray:
def GetPrevHash(header):
"""
gets the hash of the previous header in the blockchain
Expand All @@ -105,7 +105,7 @@ def GetPrevHash(header: Header) -> bytearray:
pass


def GetMerkleRoot(header: Header) -> bytearray:
def GetMerkleRoot(header):
"""
gets the merkle root of the transactions contained in the block
Expand All @@ -114,7 +114,7 @@ def GetMerkleRoot(header: Header) -> bytearray:
pass


def GetTimestamp(header: Header) -> int:
def GetTimestamp(header):
"""
gets the timestamp of when the header was created
Expand All @@ -123,7 +123,7 @@ def GetTimestamp(header: Header) -> int:
pass


def GetConsensusData(header: Header) -> bytearray:
def GetConsensusData(header):
"""
gets the address of the consensus
Expand All @@ -132,7 +132,7 @@ def GetConsensusData(header: Header) -> bytearray:
pass


def GetNextConsensus(header: Header) -> bytearray:
def GetNextConsensus(header):
"""
gets the address where the next consensus will occur
Expand Down
2 changes: 1 addition & 1 deletion boa/blockchain/vm/Neo/Input.py
@@ -1,5 +1,5 @@

class TransactionInput():
class TransactionInput:

@property
def Hash(self):
Expand Down

0 comments on commit f9753d6

Please sign in to comment.