def _handle_message_signing(self, signing_msg: SigningMessage, signing_dialogue: SigningDialogue) -> None: """ Handle a message for signing. :param signing_msg: the signing message :param signing_dialogue: the signing dialogue :return: None """ signing_msg_response = SigningMessage( performative=SigningMessage.Performative.ERROR, dialogue_reference=signing_dialogue.dialogue_label. dialogue_reference, target=signing_msg.message_id, message_id=signing_msg.message_id + 1, skill_callback_ids=signing_msg.skill_callback_ids, skill_callback_info=signing_msg.skill_callback_info, error_code=SigningMessage.ErrorCode.UNSUCCESSFUL_MESSAGE_SIGNING, ) if self._is_acceptable_for_signing(signing_msg): signed_message = self.wallet.sign_message( signing_msg.raw_message.ledger_id, signing_msg.raw_message.body, signing_msg.raw_message.is_deprecated_mode, ) if signed_message is not None: signing_msg_response = SigningMessage( performative=SigningMessage.Performative.SIGNED_MESSAGE, dialogue_reference=signing_dialogue.dialogue_label. dialogue_reference, target=signing_msg.message_id, message_id=signing_msg.message_id + 1, skill_callback_ids=signing_msg.skill_callback_ids, skill_callback_info=signing_msg.skill_callback_info, signed_message=SignedMessage( signing_msg.raw_message.ledger_id, signed_message, signing_msg.raw_message.is_deprecated_mode, ), ) signing_msg_response.counterparty = signing_msg.counterparty signing_dialogue.update(signing_msg_response) self.message_out_queue.put(signing_msg_response)
def __init__( self, dialogue_label: BaseDialogueLabel, agent_address: Address, role: BaseDialogue.Role, ) -> None: """ Initialize a dialogue. :param dialogue_label: the identifier of the dialogue :param agent_address: the address of the agent for whom this dialogue is maintained :param role: the role of the agent this dialogue is maintained for :return: None """ BaseSigningDialogue.__init__(self, dialogue_label=dialogue_label, agent_address=agent_address, role=role) self._associated_ledger_api_dialogue = None # type: Optional[LedgerApiDialogue]
def _handle_transaction_signing(self, signing_msg: SigningMessage, signing_dialogue: SigningDialogue) -> None: """ Handle a transaction for signing. :param signing_msg: the signing message :param signing_dialogue: the signing dialogue :return: None """ signing_msg_response = SigningMessage( performative=SigningMessage.Performative.ERROR, dialogue_reference=signing_dialogue.dialogue_label. dialogue_reference, target=signing_msg.message_id, message_id=signing_msg.message_id + 1, skill_callback_ids=signing_msg.skill_callback_ids, skill_callback_info=signing_msg.skill_callback_info, error_code=SigningMessage.ErrorCode. UNSUCCESSFUL_TRANSACTION_SIGNING, ) if self._is_acceptable_for_signing(signing_msg): signed_tx = self.wallet.sign_transaction( signing_msg.raw_transaction.ledger_id, signing_msg.raw_transaction.body) if signed_tx is not None: signing_msg_response = SigningMessage( performative=SigningMessage.Performative. SIGNED_TRANSACTION, dialogue_reference=signing_dialogue.dialogue_label. dialogue_reference, target=signing_msg.message_id, message_id=signing_msg.message_id + 1, skill_callback_ids=signing_msg.skill_callback_ids, skill_callback_info=signing_msg.skill_callback_info, signed_transaction=SignedTransaction( signing_msg.raw_transaction.ledger_id, signed_tx), ) signing_msg_response.counterparty = signing_msg.counterparty signing_dialogue.update(signing_msg_response) self.message_out_queue.put(signing_msg_response)
def create_dialogue( self, dialogue_label: BaseDialogueLabel, role: BaseDialogue.Role, ) -> SigningDialogue: """ Create an instance of fipa dialogue. :param dialogue_label: the identifier of the dialogue :param role: the role of the agent this dialogue is maintained for :return: the created dialogue """ dialogue = SigningDialogue( dialogue_label=dialogue_label, agent_address=self.agent_address, role=role ) return dialogue