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

Commit ea6fc22

Browse files
authored
Merge pull request #49 from aeternity/release/0.22.0.1rc1
Release/0.22.0.1rc1
2 parents 627c529 + 13fa8c3 commit ea6fc22

26 files changed

+308
-12703
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# this is used by docker-compose.yml to for the epoch image tag
2-
TAG=v0.20.0
2+
TAG=v0.22.0

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).
44

55
## [Unreleased]
66

7+
## [0.22.0.1]
8+
9+
### Removed
10+
- Compatiblity with epoch nodes version < [0.22.0](https://github.com/aeternity/epoch/blob/v0.22.0/docs/release-notes/RELEASE-NOTES-0.22.0.md)
11+
12+
### Changed
13+
- change hash prefix separator from `$` to `_`
14+
15+
## [0.21.0.1]
16+
17+
### Removed
18+
- Compatiblity with epoch nodes version < 0.21.0
19+
720
## [0.20.0.2]
821

922
### Fixed

Jenkinsfile

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ pipeline {
2727
}
2828
}
2929

30-
stage('Publish-Test') {
31-
when {
32-
beforeAgent true
33-
branch 'develop'
34-
}
35-
steps {
36-
withCredentials([
37-
usernamePassword(credentialsId: 'test_pypi',
38-
usernameVariable: 'TWINE_USERNAME',
39-
passwordVariable: 'TWINE_PASSWORD'),
40-
string(credentialsId: 'pypi_test_repo_url', variable: 'TWINE_REPOSITORY_URL')]) {
41-
sh '''make clean && make build && make publish'''
42-
}
43-
}
44-
}
30+
// stage('Publish-Test') {
31+
// when {
32+
// beforeAgent true
33+
// branch 'develop'
34+
// }
35+
// steps {
36+
// withCredentials([
37+
// usernamePassword(credentialsId: 'test_pypi',
38+
// usernameVariable: 'TWINE_USERNAME',
39+
// passwordVariable: 'TWINE_PASSWORD'),
40+
// string(credentialsId: 'pypi_test_repo_url', variable: 'TWINE_REPOSITORY_URL')]) {
41+
// sh '''make clean && make build && make publish'''
42+
// }
43+
// }
44+
// }
4545

4646
stage('Publish') {
4747
when {

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class MyOracleQuery(OracleQuery):
122122
print('The oracle responded %s' % query)
123123

124124
my_query = MyOracleQuery(
125-
oracle_pubkey='ok$deadbeef...', # oracle id as published by the operator
125+
oracle_pubkey='ok_deadbeef...', # oracle id as published by the operator
126126
query_fee=4, # these are the same values as the Oracle
127127
fee=6,
128128
response_ttl=10,
@@ -165,7 +165,7 @@ if not name.is_available():
165165

166166
name.preclaim() # preclaim will mark the domain as yours in the current block
167167
name.claim_blocking() # will wait for the next block to claim the domain
168-
name.update(target='ak$1234deadbeef') # set what this domain stands for
168+
name.update(target='ak_1234deadbeef') # set what this domain stands for
169169
```
170170

171171
you can also pass an oracle instance directly to in the `target` parameter

aeternity/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.20.0.2'
1+
__version__ = '0.22.0.1rc1'

aeternity/__main__.py

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,16 @@ def _check_prefix(data, prefix):
7070
"""
7171

7272
if len(data) < 3:
73-
print("Invalid input, likely you forgot to escape the $ sign (use \\$)")
73+
print(f"Invalid input: '{data}'")
7474
exit(1)
7575

76-
if not data.startswith(f"{prefix}$"):
76+
if not data.startswith(f"{prefix}_"):
7777
if prefix == 'ak':
78-
print("Invalid account address, it shoudld be like: ak$....")
78+
print("Invalid account address, it shoudld be like: ak_....")
7979
if prefix == 'th':
80-
print("Invalid transaction hash, it shoudld be like: th$....")
81-
if prefix == 'bh':
82-
print("Invalid block hash, it shoudld be like: bh$....")
80+
print("Invalid transaction hash, it shoudld be like: th_....")
81+
if prefix in ('bh', 'kh'):
82+
print("Invalid block hash, it shoudld be like: bh_...., kh_...")
8383
exit(1)
8484

8585

@@ -274,9 +274,9 @@ def wallet_balance(password):
274274
kp, _ = _keypair(password=password)
275275

276276
try:
277-
balance = _epoch_cli().get_balance(kp.get_address())
277+
account = _epoch_cli().get_account_by_pubkey(pubkey=kp.get_address())
278278
_pp(
279-
("Account balance", balance)
279+
("Account balance", account.balance)
280280
)
281281
except Exception as e:
282282
_ppe(e)
@@ -555,39 +555,39 @@ def inspect():
555555
pass
556556

557557

558-
@inspect.command('block', help='The block hash to inspect (eg: bh$...)')
558+
@inspect.command('block', help='The block hash to inspect (eg: bh_...)')
559559
@click.argument('block_hash')
560560
def inspect_block(block_hash):
561-
_check_prefix(block_hash, "bh")
562-
data = _epoch_cli().get_block_by_hash(block_hash)
561+
_check_prefix(block_hash, "kh")
562+
data = _epoch_cli().get_key_block_by_hash(hash=block_hash)
563563
_p_block(data)
564564

565565

566566
@inspect.command('height', help='The height of the chain to inspect (eg:14352)')
567567
@click.argument('chain_height', default=1)
568568
def inspect_height(chain_height):
569-
data = _epoch_cli().get_key_block_by_height(chain_height)
569+
data = _epoch_cli().get_key_block_by_height(height=chain_height)
570570
_p_block(data)
571571

572572

573-
@inspect.command('transaction', help='The transaction hash to inspect (eg: th$...)')
573+
@inspect.command('transaction', help='The transaction hash to inspect (eg: th_...)')
574574
@click.argument('tx_hash')
575575
def inspect_transaction(tx_hash):
576576
try:
577577
_check_prefix(tx_hash, "th")
578-
data = _epoch_cli().get_transaction_by_transaction_hash(tx_hash)
578+
data = _epoch_cli().get_transaction_by_hash(hash=tx_hash)
579579
_p_tx(data.transaction)
580580
except Exception as e:
581581
print(e)
582582

583583

584-
@inspect.command('account', help='The address of the account to inspect (eg: ak$...)')
584+
@inspect.command('account', help='The address of the account to inspect (eg: ak_...)')
585585
@click.argument('account')
586586
def inspect_account(account):
587587
_check_prefix(account, "ak")
588588
try:
589-
data = _epoch_cli().get_balance(account)
590-
_pp(("Account balance", data))
589+
data = _epoch_cli().get_account_by_pubkey(pubkey=account)
590+
_pp(("Account balance", data.balance))
591591
except Exception as e:
592592
print(e)
593593

@@ -627,7 +627,7 @@ def inspect_deploy(contract_deploy_descriptor):
627627
('Owner', contract.get('owner', 'N/A')),
628628
('Created_at', contract.get('created_at', 'N/A')),
629629
])
630-
data = _epoch_cli().get_transaction_by_transaction_hash(contract.get('transaction', 'N/A'))
630+
data = _epoch_cli().get_transaction_by_hash(hash=contract.get('transaction', 'N/A'))
631631
print("Transaction")
632632
_p_tx(data.transaction)
633633
except Exception as e:
@@ -654,7 +654,7 @@ def chain_top():
654654
"""
655655
Print the information of the top block of the chain.
656656
"""
657-
data = _epoch_cli().get_top()
657+
data = _epoch_cli().get_top_block()
658658
_p_block(data)
659659

660660

@@ -663,8 +663,18 @@ def chain_version():
663663
"""
664664
Print the epoch node version.
665665
"""
666-
data = _epoch_cli().get_version()
667-
_pp(("Epoch node version", data))
666+
data = _epoch_cli().get_status()
667+
_pp([
668+
("Epoch node version", data.node_version),
669+
("Epoch node revision", data.node_revision),
670+
("Difficulty", data.difficulty),
671+
("Genesis key block hash", data.genesis_key_block_hash),
672+
("Peers", data.peer_count),
673+
("Pending transactions", data.pending_transactions_count),
674+
("Solutions", data.solutions),
675+
("Listening", data.listening),
676+
("syncing", data.syncing),
677+
])
668678

669679

670680
@chain.command('play')
@@ -677,11 +687,11 @@ def chain_play(height, block_hash, limit):
677687
"""
678688
if block_hash is not None:
679689
_check_prefix(block_hash, "bh")
680-
b = _epoch_cli().get_block_by_hash(block_hash)
690+
b = _epoch_cli().get_key_block_by_hash(hash=block_hash)
681691
elif height is not None:
682-
b = _epoch_cli().get_key_block_by_height(height)
692+
b = _epoch_cli().get_key_block_by_height(height=height)
683693
else:
684-
b = _epoch_cli().get_top()
694+
b = _epoch_cli().get_top_block()
685695
# check the limit
686696
limit = limit if limit > 0 else 0
687697
while b is not None and limit > 0:
@@ -690,7 +700,7 @@ def chain_play(height, block_hash, limit):
690700
limit -= 1
691701
if limit <= 0:
692702
break
693-
b = _epoch_cli().get_block_by_hash(b.prev_hash)
703+
b = _epoch_cli().get_key_block_by_hash(hash=b.prev_hash)
694704
except Exception as e:
695705
_ppe(e)
696706
b = None

aeternity/aens.py

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import json
21
import random
32

43
from aeternity.exceptions import NameNotAvailable, TooEarlyClaim, MissingPreclaim # ,PreclaimFailed
@@ -52,10 +51,10 @@ def validate_pointer(cls, pointer):
5251

5352
@classmethod
5453
def validate_address(cls, address, raise_exception=True):
55-
if not address.startswith(('ak$', 'ok$')):
54+
if not address.startswith(('ak_', 'ok_')):
5655
if raise_exception:
5756
raise ValueError(
58-
'pointer addresses must start with in ak$'
57+
'pointer addresses must start with in ak_'
5958
)
6059
return False
6160
return True
@@ -73,11 +72,11 @@ def validate_name(cls, domain, raise_exception=True):
7372
def update_status(self):
7473
try:
7574
# use the openapi client inside the epoch client
76-
response = self.client.cli.get_name(name=self.domain)
75+
response = self.client.get_name_entry_by_name(name=self.domain)
7776
self.status = NameStatus.CLAIMED
78-
self.name_ttl = response.name_ttl
79-
self.name_hash = response.name_hash
80-
self.pointers = json.loads(response.pointers)
77+
self.name_ttl = response.ttl
78+
self.name_hash = response.id
79+
self.pointers = response.pointers
8180
except OpenAPIClientException:
8281
# e.g. if the status is already PRECLAIMED or CLAIMED, don't reset
8382
# it to AVAILABLE.
@@ -135,16 +134,16 @@ def preclaim(self, keypair, fee=DEFAULT_FEE, tx_ttl=DEFAULT_TX_TTL):
135134
Execute a name preclaim
136135
"""
137136
# check which block we used to create the preclaim
138-
self.preclaimed_block_height = self.client.get_height()
137+
self.preclaimed_block_height = self.client.get_current_key_block_height()
139138
# calculate the commitment hash
140139
commitment_hash = self._get_commitment_hash()
141140
# compute the absolute ttl
142141
ttl = self.client.compute_absolute_ttl(tx_ttl)
143142
# preclaim
144143
preclaim_transaction = self.client.cli.post_name_preclaim(body=dict(
145-
commitment=commitment_hash,
144+
commitment_id=commitment_hash,
146145
fee=fee,
147-
account=keypair.get_address(),
146+
account_id=keypair.get_address(),
148147
ttl=ttl
149148
))
150149
signed_tx = self.client.post_transaction(keypair, preclaim_transaction)
@@ -168,7 +167,7 @@ def claim(self, keypair, fee=DEFAULT_FEE, tx_ttl=DEFAULT_TX_TTL):
168167
if self.preclaimed_block_height is None:
169168
raise MissingPreclaim('You must call preclaim before claiming a name')
170169

171-
current_block_height = self.client.get_height()
170+
current_block_height = self.client.get_current_key_block_height()
172171
if self.preclaimed_block_height >= current_block_height:
173172
raise TooEarlyClaim(
174173
'You must wait for one block to call claim.'
@@ -177,7 +176,7 @@ def claim(self, keypair, fee=DEFAULT_FEE, tx_ttl=DEFAULT_TX_TTL):
177176
# compute the absolute ttl
178177
ttl = self.client.compute_absolute_ttl(tx_ttl)
179178
claim_transaction = self.client.cli.post_name_claim(body=dict(
180-
account=keypair.get_address(),
179+
account_id=keypair.get_address(),
181180
name=AEName._encode_name(self.domain),
182181
name_salt=self.preclaim_salt,
183182
fee=fee,
@@ -188,12 +187,22 @@ def claim(self, keypair, fee=DEFAULT_FEE, tx_ttl=DEFAULT_TX_TTL):
188187
self.status = AEName.Status.CLAIMED
189188
return signed_tx.tx_hash, self.preclaim_salt
190189

191-
def _get_pointers_json(self, target):
190+
def _get_pointers(self, target):
192191
if target.startswith('ak'):
193-
pointers = {'account_pubkey': target}
192+
pointers = [
193+
{
194+
'id': target,
195+
'key': 'account_pubkey'
196+
}
197+
]
194198
else:
195-
pointers = {'oracle_pubkey': target}
196-
return json.dumps(pointers)
199+
pointers = [
200+
{
201+
'id': target,
202+
'key': 'oracle_pubkey'
203+
}
204+
]
205+
return pointers
197206

198207
def update(self, keypair, target,
199208
name_ttl=NAME_MAX_TLL,
@@ -211,11 +220,11 @@ def update(self, keypair, target,
211220
ttl = self.client.compute_absolute_ttl(tx_ttl)
212221
# send the update transaction
213222
update_transaction = self.client.cli.post_name_update(body=dict(
214-
account=keypair.get_address(),
215-
name_hash=AEName.calculate_name_hash(self.domain),
223+
account_id=keypair.get_address(),
224+
name_id=AEName.calculate_name_hash(self.domain),
216225
client_ttl=client_ttl,
217226
name_ttl=name_ttl,
218-
pointers=self._get_pointers_json(target),
227+
pointers=self._get_pointers(target),
219228
ttl=ttl,
220229
fee=fee,
221230
))
@@ -232,9 +241,9 @@ def transfer_ownership(self, keypair, receipient_pubkey,
232241
# compute the absolute ttl
233242
ttl = self.client.compute_absolute_ttl(tx_ttl)
234243
transfer_transaction = self.client.cli.post_name_transfer(body=dict(
235-
account=keypair.get_address(),
236-
name_hash=self.calculate_name_hash(self.domain),
237-
recipient_pubkey=receipient_pubkey,
244+
account_id=keypair.get_address(),
245+
name_id=self.calculate_name_hash(self.domain),
246+
recipient_id=receipient_pubkey,
238247
ttl=ttl,
239248
fee=fee,
240249
))
@@ -250,8 +259,8 @@ def revoke(self, keypair, fee=DEFAULT_FEE, tx_ttl=DEFAULT_TX_TTL):
250259
# compute the absolute ttl
251260
ttl = self.client.compute_absolute_ttl(tx_ttl)
252261
revoke_transaction = self.client.cli.post_name_revoke(body=dict(
253-
account=keypair.get_address(),
254-
name_hash=self.calculate_name_hash(self.domain),
262+
account_id=keypair.get_address(),
263+
name_id=self.calculate_name_hash(self.domain),
255264
fee=fee,
256265
ttl=ttl
257266
))

aeternity/config.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121
CONTRACT_DEFAULT_DEPOSIT = 4
2222
CONTRACT_DEFAULT_VM_VERSION = 1
2323

24-
# params
25-
# can be message_pack or json
26-
PARAM_DEFAULT_ENCODING = 'json'
27-
2824

2925
class ConfigException(Exception):
3026
pass
@@ -47,8 +43,8 @@ def __init__(self,
4743
self.pubkey = None
4844
# retrieve the version of the node we are connecting to
4945
try:
50-
r = requests.get(f"{self.api_url}/v2/version").json()
51-
self.node_version = r['version']
46+
r = requests.get(f"{self.api_url}/v2/status").json()
47+
self.node_version = r['node_version']
5248
except requests.exceptions.ConnectionError as e:
5349
raise ConfigException(f"Error connecting to the epoch node at {self.api_url}, connection unavailable")
5450

0 commit comments

Comments
 (0)