def confirm_remove_task_owners(txn_key, batch_key, proposal_id, task_id, user_id, reason): confirm = task_transaction_pb2.ConfirmRemoveTaskOwner( proposal_id=proposal_id, task_id=task_id, user_id=user_id, reason=reason) inputs = [ addresser.proposal.address(task_id, user_id), addresser.task.owner.address(task_id, user_id), addresser.task.admin.address(task_id, txn_key.public_key), ] outputs = [ addresser.proposal.address(task_id, user_id), addresser.task.owner.address(task_id, user_id), ] rbac_payload = rbac_payload_pb2.RBACPayload( content=confirm.SerializeToString(), message_type=rbac_payload_pb2.RBACPayload.CONFIRM_REMOVE_TASK_OWNERS, ) return make_header_and_batch(rbac_payload, inputs, outputs, txn_key, batch_key)
def apply_confirm(header, payload, state, is_remove=False): """Apply the (Add | Remove) TaskOwners transaction. Args: header (TransactionHeader): The protobuf TransactionHeader. payload (RBACPayload): The protobuf RBACPayload. state (Context): The class that handles state gets and sets. is_remove (boolean): Determines if task owner is being added or removed. Raises: InvalidTransaction: - The transaction is invalid. """ if not is_remove: confirm_payload = task_transaction_pb2.ConfirmAddTaskOwner() else: confirm_payload = task_transaction_pb2.ConfirmRemoveTaskOwner() confirm_payload.ParseFromString(payload.content) task_owners_address = addresser.task.owner.address( confirm_payload.task_id, confirm_payload.user_id ) txn_signer_admin_address = addresser.task.admin.address( confirm_payload.task_id, header.signer_public_key ) state_entries = task_validator.validate_task_admin_or_owner( header=header, confirm=confirm_payload, txn_signer_rel_address=txn_signer_admin_address, task_rel_address=task_owners_address, state=state, is_remove=is_remove, ) state_change.confirm_task_action( state_entries=state_entries, header=header, confirm=confirm_payload, task_rel_address=task_owners_address, state=state, is_remove=is_remove, )