def refund_reward(event, agreement_id, did, service_agreement, price, consumer_account,
                  publisher_address, condition_ids):
    """
    Refund the reward to the publisher address.

    :param event: AttributeDict with the event data.
    :param agreement_id: id of the agreement, hex str
    :param did: DID, str
    :param service_agreement: ServiceAgreement instance
    :param price: Asset price, int
    :param consumer_account: Account instance of the consumer
    :param publisher_address: ethereum account address of publisher, hex str
    :param condition_ids: is a list of bytes32 content-addressed Condition IDs, bytes32
    """
    logger.debug(f"trigger refund after event {event}.")
    access_id, lock_id = condition_ids[:2]
    name_to_parameter = {param.name: param for param in
                         service_agreement.condition_by_name['escrowReward'].parameters}
    document_id = add_0x_prefix(name_to_parameter['_documentId'].value)
    asset_id = add_0x_prefix(did_to_id(did))
    assert document_id == asset_id, f'document_id {document_id} <=> asset_id {asset_id} mismatch.'
    assert price == service_agreement.get_price(), 'price mismatch.'
    # logger.info(f'About to do grantAccess: account {account.address},
    # saId {service_agreement_id}, '
    #             f'documentKeyId {document_key_id}')
    try:
        tx_hash = Keeper.get_instance().escrow_reward_condition.fulfill(
            agreement_id,
            price,
            publisher_address,
            consumer_account.address,
            lock_id,
            access_id,
            consumer_account
        )
        process_tx_receipt(
            tx_hash,
            Keeper.get_instance().escrow_reward_condition.FULFILLED_EVENT,
            'EscrowReward.Fulfilled'
        )
    except Exception as e:
        # logger.error(f'Error when doing escrow_reward_condition.fulfills: {e}')
        raise e
def refund_reward ( event , agreement_id , did , service_agreement , price , consumer_account , publisher_address , condition_ids ) : logger . debug ( f"trigger refund after event {event}." ) access_id , lock_id = condition_ids [ : 2 ] name_to_parameter = { param . name : param for param in service_agreement . condition_by_name [ 'escrowReward' ] . parameters } document_id = add_0x_prefix ( name_to_parameter [ '_documentId' ] . value ) asset_id = add_0x_prefix ( did_to_id ( did ) ) assert document_id == asset_id , f'document_id {document_id} <=> asset_id {asset_id} mismatch.' assert price == service_agreement . get_price ( ) , 'price mismatch.' try : tx_hash = Keeper . get_instance ( ) . escrow_reward_condition . fulfill ( agreement_id , price , publisher_address , consumer_account . address , lock_id , access_id , consumer_account ) process_tx_receipt ( tx_hash , Keeper . get_instance ( ) . escrow_reward_condition . FULFILLED_EVENT , 'EscrowReward.Fulfilled' ) except Exception as e : raise e
Refund the reward to the publisher address.

    :param event: AttributeDict with the event data.
    :param agreement_id: id of the agreement, hex str
    :param did: DID, str
    :param service_agreement: ServiceAgreement instance
    :param price: Asset price, int
    :param consumer_account: Account instance of the consumer
    :param publisher_address: ethereum account address of publisher, hex str
    :param condition_ids: is a list of bytes32 content-addressed Condition IDs, bytes32