1- import json
21import random
32
43from 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 ))
0 commit comments