@@ -184,6 +184,75 @@ async def dispute_coldkey_swap_extrinsic(
184184 return ExtrinsicResponse .from_exception (raise_error = raise_error , error = error )
185185
186186
187+ async def clear_coldkey_swap_announcement_extrinsic (
188+ subtensor : "AsyncSubtensor" ,
189+ wallet : "Wallet" ,
190+ * ,
191+ mev_protection : bool = DEFAULT_MEV_PROTECTION ,
192+ period : Optional [int ] = None ,
193+ raise_error : bool = False ,
194+ wait_for_inclusion : bool = True ,
195+ wait_for_finalization : bool = True ,
196+ wait_for_revealed_execution : bool = True ,
197+ ) -> ExtrinsicResponse :
198+ """
199+ Clears (withdraws) a pending coldkey swap announcement.
200+
201+ Callable by the coldkey that has an active, undisputed swap announcement. The reannouncement delay must have
202+ elapsed past the execution block before the announcement can be cleared.
203+
204+ Parameters:
205+ subtensor: AsyncSubtensor instance with the connection to the chain.
206+ wallet: Bittensor wallet object (should be the current coldkey with an active announcement).
207+ mev_protection: If ``True``, encrypts and submits the transaction through the MEV Shield pallet.
208+ period: The number of blocks during which the transaction will remain valid.
209+ raise_error: Raises a relevant exception rather than returning ``False`` if unsuccessful.
210+ wait_for_inclusion: Whether to wait for the inclusion of the transaction.
211+ wait_for_finalization: Whether to wait for the finalization of the transaction.
212+ wait_for_revealed_execution: Whether to wait for the revealed execution if mev_protection used.
213+
214+ Returns:
215+ ExtrinsicResponse: The result object of the extrinsic execution.
216+
217+ Notes:
218+ - The coldkey must have an active, undisputed swap announcement.
219+ - The reannouncement delay must have elapsed past the execution block.
220+ """
221+ try :
222+ if not (
223+ unlocked := ExtrinsicResponse .unlock_wallet (wallet , raise_error )
224+ ).success :
225+ return unlocked
226+
227+ call = await SubtensorModule (subtensor ).clear_coldkey_swap_announcement ()
228+
229+ if mev_protection :
230+ response = await submit_encrypted_extrinsic (
231+ subtensor = subtensor ,
232+ wallet = wallet ,
233+ call = call ,
234+ period = period ,
235+ raise_error = raise_error ,
236+ wait_for_inclusion = wait_for_inclusion ,
237+ wait_for_finalization = wait_for_finalization ,
238+ wait_for_revealed_execution = wait_for_revealed_execution ,
239+ )
240+ else :
241+ response = await subtensor .sign_and_send_extrinsic (
242+ call = call ,
243+ wallet = wallet ,
244+ wait_for_inclusion = wait_for_inclusion ,
245+ wait_for_finalization = wait_for_finalization ,
246+ period = period ,
247+ raise_error = raise_error ,
248+ )
249+
250+ return response
251+
252+ except Exception as error :
253+ return ExtrinsicResponse .from_exception (raise_error = raise_error , error = error )
254+
255+
187256async def swap_coldkey_announced_extrinsic (
188257 subtensor : "AsyncSubtensor" ,
189258 wallet : "Wallet" ,
0 commit comments