Skip to content
This repository was archived by the owner on Aug 12, 2024. It is now read-only.

Commit d8ae7ce

Browse files
authored
Merge pull request #206 from aeternity/release/3.1.1
Release/3.1.1
2 parents 4aca597 + ee2ca69 commit d8ae7ce

File tree

5 files changed

+48
-16
lines changed

5 files changed

+48
-16
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [3.1.1](https://github.com/aeternity/aepp-sdk-python/releases/tag/3.1.1) ([compare](https://github.com/aeternity/aepp-sdk-python/compare/3.1.0...3.1.1))
8+
9+
### Bug Fixes
10+
- fix(tx): encode spend tx payload as base64 string prefixed by 'ba' (#204) ([488745b](https://github.com/aeternity/aepp-sdk-python/commit/488745bc93167b0a80e2dd1e90691110e0abaf24)). Related issues/PRs: #203
11+
12+
### Code Refactoring
13+
- refactor(cli): add option --secret-key as alias to --private-key.([60bcf6d](https://github.com/aeternity/aepp-sdk-python/commit/60bcf6d4af5d423fcf7660bd3ee4f7ea1e299400)).
14+
15+
⚠️ `--private-key` is deprecated and will be removed in a future release`
16+
17+
### Features
18+
- feat(tx): improve precision for fee calculation (#193) ([04adcb4](https://github.com/aeternity/aepp-sdk-python/commit/04adcb47dd20dd754c3b402227ec251f0c5972e2)).
19+
720
## [3.1.0](https://github.com/aeternity/aepp-sdk-python/releases/tag/3.1.0) ([compare](https://github.com/aeternity/aepp-sdk-python/compare/3.0.1...3.1.0))
821

922
### Features

aeternity/__main__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,17 +310,17 @@ def account_save(keystore_name, private_key, password, overwrite, json_):
310310

311311
@account.command('address', help="Print the account address (public key)")
312312
@click.argument('keystore_name')
313-
@click.option('--private-key', is_flag=True, help="Print the private key instead of the account address")
313+
@click.option('--secret-key', '--private-key', is_flag=True, help="Print the secret key in addition to the account address")
314314
@global_options
315315
@account_options
316-
def account_address(password, keystore_name, private_key, json_):
316+
def account_address(password, keystore_name, secret_key, json_):
317317
try:
318318
set_global_options(json_)
319319
account, keystore_path = _account(keystore_name, password=password)
320320
o = {'Address': account.get_address()}
321-
if private_key:
322-
click.confirm(f'!Warning! this will print your private key on the screen, are you sure?', abort=True)
323-
o["Signing key"] = account.get_private_key()
321+
if secret_key:
322+
click.confirm(f'!Warning! this will print your secret key on the screen, are you sure?', abort=True)
323+
o["SecretKey"] = account.get_secret_key()
324324
_print_object(o, title='account')
325325
except Exception as e:
326326
_print_error(e, exit_code=1)

aeternity/identifiers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
STATE_TREES = "ss" # base64 State trees
2727
STATE = "st" # base64 State
2828
TRANSACTION = "tx" # base64 Transaction
29+
BYTE_ARRAY = "ba" # base64 byte array
2930

3031
IDENTIFIERS_B58 = set([
3132
ACCOUNT_ID,
@@ -53,7 +54,8 @@
5354
PROOF_OF_INCLUSION,
5455
STATE_TREES,
5556
STATE,
56-
TRANSACTION
57+
TRANSACTION,
58+
BYTE_ARRAY
5759
])
5860

5961
# Account address encoding formats

aeternity/transactions.py

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,39 @@ def _tx_native(op, **kwargs):
6666
def std_fee(tx_raw, fee_idx, base_gas_multiplier=1):
6767
# calculates the standard minimum transaction fee
6868
tx_copy = tx_raw # create a copy of the input
69-
tx_copy[fee_idx] = _int(0, 8) # replace fee with a byte array of length 8
70-
return (defaults.BASE_GAS * base_gas_multiplier + len(rlp.encode(tx_copy)) * defaults.GAS_PER_BYTE) * defaults.GAS_PRICE
69+
actual_fee = 0
70+
tx_copy[fee_idx] = _int(actual_fee) # replace fee with a byte array of length 1
71+
expected = (defaults.BASE_GAS * base_gas_multiplier + len(rlp.encode(tx_copy)) * defaults.GAS_PER_BYTE) * defaults.GAS_PRICE
72+
while expected != actual_fee:
73+
actual_fee = expected
74+
tx_copy[fee_idx] = _int(expected)
75+
expected = (defaults.BASE_GAS * base_gas_multiplier + len(rlp.encode(tx_copy)) * defaults.GAS_PER_BYTE) * defaults.GAS_PRICE
76+
return actual_fee
7177

7278
def contract_fee(tx_raw, fee_idx, gas, base_gas_multiplier=1):
7379
# estimate the contract creation fee
7480
tx_copy = tx_raw # create a copy of the input
75-
tx_copy[fee_idx] = _int(0, 8) # replace fee with a byte array of length 8
76-
return (defaults.BASE_GAS * base_gas_multiplier + gas + len(rlp.encode(tx_copy)) * defaults.GAS_PER_BYTE) * defaults.GAS_PRICE
81+
actual_fee = 0
82+
tx_copy[fee_idx] = _int(actual_fee) # replace fee with a byte array of length 1
83+
expected = (defaults.BASE_GAS * base_gas_multiplier + gas + len(rlp.encode(tx_copy)) * defaults.GAS_PER_BYTE) * defaults.GAS_PRICE
84+
while expected != actual_fee:
85+
actual_fee = expected
86+
tx_copy[fee_idx] = _int(expected)
87+
expected = (defaults.BASE_GAS * base_gas_multiplier + gas + len(rlp.encode(tx_copy)) * defaults.GAS_PER_BYTE) * defaults.GAS_PRICE
88+
return actual_fee
7789

7890
def oracle_fee(tx_raw, fee_idx, relative_ttl):
7991
# estimate oracle fees
8092
tx_copy = tx_raw # create a copy of the input
81-
tx_copy[fee_idx] = _int(0, 8) # replace fee with a byte array of length 8
82-
fee = (defaults.BASE_GAS + len(rlp.encode(tx_copy)) * defaults.GAS_PER_BYTE)
83-
fee += math.ceil(32000 * relative_ttl / math.floor(60 * 24 * 365 / defaults.KEY_BLOCK_INTERVAL))
84-
return fee * defaults.GAS_PRICE
93+
actual_fee = 0
94+
tx_copy[fee_idx] = _int(actual_fee) # replace fee with a byte array of length 1
95+
ttl_cost = math.ceil(32000 * relative_ttl / math.floor(60 * 24 * 365 / defaults.KEY_BLOCK_INTERVAL)) # calculate the variable cost for ttl
96+
expected = ((defaults.BASE_GAS + len(rlp.encode(tx_copy)) * defaults.GAS_PER_BYTE) + ttl_cost) * defaults.GAS_PRICE
97+
while expected != actual_fee:
98+
actual_fee = expected
99+
tx_copy[fee_idx] = _int(expected)
100+
expected = ((defaults.BASE_GAS + len(rlp.encode(tx_copy)) * defaults.GAS_PER_BYTE) + ttl_cost) * defaults.GAS_PRICE
101+
return actual_fee
85102

86103
def build_tx_object(tx_data, tx_raw, fee_idx, min_fee):
87104
# if fee is not set use the min fee
@@ -147,7 +164,7 @@ def build_tx_object(tx_data, tx_raw, fee_idx, min_fee):
147164
fee=_int_decode(tx_native[5]),
148165
ttl=_int_decode(tx_native[6]),
149166
nonce=_int_decode(tx_native[7]),
150-
payload=_binary_decode(tx_native[8]),
167+
payload=encode(idf.BYTE_ARRAY, tx_native[8]),
151168
)
152169
min_fee = tx_data.get("fee")
153170
else:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "aepp-sdk"
3-
version = "3.1.0"
3+
version = "3.1.1"
44
description = "Python SDK to interact with the Æternity blockchain"
55
authors = [
66
"Andrea Giacobino <[email protected]>",

0 commit comments

Comments
 (0)