Skip to content
This repository was archived by the owner on Aug 12, 2024. It is now read-only.
Merged
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ venv
aepp_sdk.egg-info
dist
build
coverage.xml
docker-compose.override.yml
test-results.xml
13 changes: 7 additions & 6 deletions aeternity/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import json
import sys
import getpass
import namedtupled

from aeternity import __version__

Expand Down Expand Up @@ -130,7 +131,7 @@ def _print_object(data, title=None):

if ctx.obj.get(CTX_OUTPUT_JSON, False):
if isinstance(data, tuple):
print(json.dumps(data._asdict(), indent=2))
print(json.dumps(namedtupled.reduce(data), indent=2))
return
if isinstance(data, str):
print(data)
Expand Down Expand Up @@ -160,8 +161,8 @@ def _print_object(data, title=None):
]

_transaction_options = [
click.option('--native', 'native', is_flag=True, default=False,
help='Use native transaction generation instead of the internal endpoints (always True for offline transactions)'),
click.option('--debug-tx', 'debug_tx', is_flag=True, default=False,
help='Use debug transaction generation endpoints from the node instead of the native python implementation'),
click.option('--ttl', 'ttl', type=int, default=config.DEFAULT_TX_TTL,
help=f'Set the transaction ttl (relative number, ex 100)', show_default=True),
click.option('--fee', 'fee', type=int, default=config.DEFAULT_FEE,
Expand Down Expand Up @@ -408,11 +409,11 @@ def tx_broadcast(signed_transaction, force, wait, json_):
@click.argument('amount', required=True, type=int)
@transaction_options
@click.option('--payload', default="", help="Spend transaction payload")
def tx_spend(sender_id, recipient_id, amount, native, ttl, fee, nonce, payload, force, wait, json_):
def tx_spend(sender_id, recipient_id, amount, debug_tx, ttl, fee, nonce, payload, force, wait, json_):
try:
set_global_options(force, wait, json_)
cli = _node_cli(native=native)
if not native:
cli = _node_cli(native=not debug_tx)
if debug_tx:
nonce, ttl = cli._get_nonce_ttl(sender_id, ttl)
tx = cli.tx_builder.tx_spend(sender_id, recipient_id, amount, payload, fee, ttl, nonce)
# print the results
Expand Down
13 changes: 7 additions & 6 deletions aeternity/aens.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from aeternity.openapi import OpenAPIClientException
from aeternity.config import DEFAULT_TX_TTL, DEFAULT_FEE, DEFAULT_NAME_TTL, NAME_CLIENT_TTL
from aeternity import hashing, utils, oracles
from aeternity.identifiers import ACCOUNT_ID, COMMITMENT, NAME


class NameStatus:
Expand Down Expand Up @@ -49,18 +50,18 @@ def _get_name_id(cls, name):
"""
if isinstance(name, str):
name = name.encode('ascii')
return hashing.encode('nm', name)
return hashing.encode(NAME, name)

def _get_commitment_id(self):
"""
Compute the commitment id
"""
self.preclaim_salt = hashing.randint()
commitment_id = hashing.hash_encode("cm", hashing.namehash(self.domain) + self.preclaim_salt.to_bytes(32, 'big'))
commitment_id = hashing.hash_encode(COMMITMENT, hashing.namehash(self.domain) + self.preclaim_salt.to_bytes(32, 'big'))
return commitment_id

def _get_pointers(self, target):
if target.startswith('ak'):
if target.startswith(ACCOUNT_ID):
pointers = [{'id': target, 'key': 'account_pubkey'}]
else:
pointers = [{'id': target, 'key': 'oracle_pubkey'}]
Expand Down Expand Up @@ -196,7 +197,7 @@ def update(self, account, target,
raise ValueError('You must register the oracle before using it as target')
target = target.oracle_id
# get the name_id and pointers
name_id = hashing.namehash_encode("nm", self.domain)
name_id = hashing.namehash_encode(NAME, self.domain)
pointers = self._get_pointers(target)
# get the transaction builder
txb = self.client.tx_builder
Expand All @@ -216,7 +217,7 @@ def transfer_ownership(self, account, recipient_pubkey, fee=DEFAULT_FEE, tx_ttl=
:return: the transaction
"""
# get the name_id and pointers
name_id = hashing.namehash_encode("nm", self.domain)
name_id = hashing.namehash_encode(NAME, self.domain)
# get the transaction builder
txb = self.client.tx_builder
# get the account nonce and ttl
Expand All @@ -237,7 +238,7 @@ def revoke(self, account, fee=DEFAULT_FEE, tx_ttl=DEFAULT_TX_TTL):
:return: the transaction
"""
# get the name_id and pointers
name_id = hashing.namehash_encode("nm", self.domain)
name_id = hashing.namehash_encode(NAME, self.domain)
# get the transaction builder
txb = self.client.tx_builder
# get the account nonce and ttl
Expand Down
163 changes: 0 additions & 163 deletions aeternity/aevm.py

This file was deleted.

8 changes: 4 additions & 4 deletions aeternity/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
DEFAULT_NAME_TTL = 500
# default relative ttl in number of blocks for executing transaction on the chain
MAX_TX_TTL = sys.maxsize
DEFAULT_TX_TTL = 500
DEFAULT_TX_TTL = 0
# default fee for posting transaction
DEFAULT_FEE = 20000
# contracts
CONTRACT_DEFAULT_GAS = 170000
CONTRACT_DEFAULT_GAS_PRICE = 1
CONTRACT_DEFAULT_DEPOSIT = 4
CONTRACT_DEFAULT_DEPOSIT = 0
CONTRACT_DEFAULT_VM_VERSION = 1
CONTRACT_DEFAULT_AMOUNT = 1
CONTRACT_DEFAULT_AMOUNT = 0
# oracles
# https://github.com/aeternity/protocol/blob/master/oracles/oracles.md#technical-aspects-of-oracle-operations
ORACLE_DEFAULT_QUERY_FEE = 30000
ORACLE_DEFAULT_QUERY_FEE = 0
ORACLE_DEFAULT_TTL_TYPE_DELTA = 'delta'
ORACLE_DEFAULT_TTL_TYPE_BLOCK = 'block'
ORACLE_DEFAULT_TTL_VALUE = 500
Expand Down
8 changes: 4 additions & 4 deletions aeternity/contract.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from aeternity.aevm import pretty_bytecode
from aeternity.openapi import OpenAPIClientException
from aeternity import utils, config
from aeternity.identifiers import CONTRACT_ID


class ContractError(Exception):
Expand Down Expand Up @@ -46,7 +46,7 @@ def tx_call(self, account, function, arg,
tx_ttl=config.DEFAULT_TX_TTL):
"""Call a sophia contract"""

if not utils.is_valid_hash(self.address, prefix="ct"):
if not utils.is_valid_hash(self.address, prefix=CONTRACT_ID):
raise ValueError("Missing contract id")

try:
Expand Down Expand Up @@ -119,7 +119,7 @@ def compile(self, code, options=''):
raise ContractError(e)

def get_pretty_bytecode(self, code, options=''):
return pretty_bytecode(self.bytecode)
return self.bytecode

def call(self, function, arg):
'''"Call a sophia function with a given name and argument in the given
Expand Down Expand Up @@ -164,6 +164,6 @@ def decode_data(self, data, sophia_type):
"data": data,
"sophia-type": sophia_type,
})
return reply.data.get('value'), reply.data.get('type', 'word')
return reply.data.value, reply.data.type
except OpenAPIClientException as e:
raise ContractError(e)
Loading