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
15 changes: 12 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@ log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).

## [Unreleased]

## [1.0.0b1]
## [1.1.0]

### Changed

- CLI default node changed to [sdk-mainnet.aepp.com](https://sdk-mainnet.aepp.com/v2/status)

### Added

- Native transactions for contracts

## [1.0.0]

### Changed

Expand All @@ -17,7 +27,7 @@ log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).

## [0.25.0.1]

⚠️ KEYSTORE FORMAT CHANGE INCOMPATIBLE WITH PREVIOUS FORMAT ⚠️
⚠️ KEYSTORE FORMAT CHANGE INCOMPATIBLE WITH PREVIOUS FORMAT ⚠️

refer to the [documentation](docs/keystore_format_change.md) about how to update existing keystores

Expand All @@ -41,7 +51,6 @@ refer to the [documentation](docs/keystore_format_change.md) about how to update
- Compatibility with epoch nodes version < [0.25.0](https://github.com/aeternity/epoch/blob/v0.25.0/docs/release-notes/RELEASE-NOTES-0.25.0.md)
- Support for .aet tld for aens


## [0.24.0.2]

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion aeternity/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '1.0.0'
__version__ = '1.1.0'

__compatibility__ = [
'1.0.0',
Expand Down
2 changes: 1 addition & 1 deletion aeternity/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def set_global_options(force, wait, json_):
@click.group()
@click.pass_context
@click.version_option()
@click.option('--url', '-u', default='https://sdk-testnet.aepps.com', envvar='EPOCH_URL', help='Epoch node url', metavar='URL')
@click.option('--url', '-u', default='https://sdk-mainnet.aepps.com', envvar='EPOCH_URL', help='Epoch node url', metavar='URL')
@click.option('--debug-url', '-d', default=None, envvar='EPOCH_URL_DEBUG', metavar='URL')
@global_options
@click.version_option(version=__version__)
Expand Down
47 changes: 43 additions & 4 deletions aeternity/transactions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from aeternity.hashing import _int, _binary, _id, encode, decode, encode_rlp, hash_encode
from aeternity.hashing import _int, _binary, _id, encode, decode, encode_rlp, hash_encode, contract_id
from aeternity.openapi import OpenAPICli
from aeternity.config import ORACLE_DEFAULT_TTL_TYPE_DELTA

Expand Down Expand Up @@ -353,7 +353,20 @@ def tx_contract_create(self, account_id, code, call_data, amount, deposit, gas,
"""

if self.native_transactions:
raise NotImplementedError("Native transaction for contract creation not implemented")
tx = [
_id(account_id),
_int(nonce),
_binary(code),
_int(vm_version),
_int(fee),
_int(ttl),
_int(deposit),
_int(amount),
_int(gas),
_int(gas_price),
_binary(call_data),
]
return encode_rlp("tx", tx), contract_id(account_id, nonce)
# use internal endpoints transaction
body = dict(
owner_id=account_id,
Expand All @@ -372,9 +385,35 @@ def tx_contract_create(self, account_id, code, call_data, amount, deposit, gas,
return tx.tx, tx.contract_id

def tx_contract_call(self, account_id, contract_id, call_data, function, arg, amount, gas, gas_price, vm_version, fee, ttl, nonce)-> str:
# compute the absolute ttl and the nonce
"""
Create a contract call
:param account_id: the account creating the contract
:param contract_id: the contract to call
:param call_data: the call data for the contract
:param function: the function to execute
:param arg: the function arguments
:param amount: TODO: add definition
:param gas: TODO: add definition
:param gas_price: TODO: add definition
:param vm_version: TODO: add definition
:param fee: the transaction fee
:param ttl: the ttl of the transaction
:param nonce: the nonce of the account for the transaction
"""
if self.native_transactions:
raise NotImplementedError("Native transaction for contract calls not implemented")
tx = [
_id(account_id),
_int(nonce),
_id(contract_id),
_int(vm_version),
_int(fee),
_int(ttl),
_int(amount),
_int(gas),
_int(gas_price),
_binary(call_data),
]
return encode_rlp("tx", tx)
# use internal endpoints transaction
body = dict(
call_data=call_data,
Expand Down
39 changes: 30 additions & 9 deletions tests/test_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,16 @@
#


def test_sophia_contract_tx_create_online():
# save settings and go online
original = EPOCH_CLI.set_native(False)

def _sophia_contract_tx_create_online():
# runt tests
contract = EPOCH_CLI.Contract(aer_identity_contract)
contract.tx_create(ACCOUNT, gas=100000, fee=150000)
assert contract.address is not None
assert len(contract.address) > 0
assert contract.address.startswith('ct')
# restore settings
EPOCH_CLI.set_native(original)


def test_sophia_contract_tx_call_online():
# save settings and go online
original = EPOCH_CLI.set_native(False)
def _sophia_contract_tx_call_online():

contract = EPOCH_CLI.Contract(aer_identity_contract)
tx = contract.tx_create(ACCOUNT, gas=100000, fee=150000)
Expand All @@ -56,10 +49,38 @@ def test_sophia_contract_tx_call_online():
assert val == 42
assert remote_type == 'word'


def test_sophia_contract_tx_create_native():
# save settings and go online
original = EPOCH_CLI.set_native(False)
_sophia_contract_tx_create_online()
# restore settings
EPOCH_CLI.set_native(original)


def test_sophia_contract_tx_call_native():
# save settings and go online
original = EPOCH_CLI.set_native(False)
_sophia_contract_tx_call_online()
# restore settings
EPOCH_CLI.set_native(original)


def test_sophia_contract_tx_create_debug():
# save settings and go online
original = EPOCH_CLI.set_native(False)
_sophia_contract_tx_create_online()
# restore settings
EPOCH_CLI.set_native(original)


def test_sophia_contract_tx_call_debug():
# save settings and go online
original = EPOCH_CLI.set_native(False)
_sophia_contract_tx_call_online()
# restore settings
EPOCH_CLI.set_native(original)

# test contracts


Expand Down