code: def handle_onchain_secretreveal(
          mediator_state: MediatorTransferState,
          onchain_secret_reveal: ContractReceiveSecretReveal,
          channelidentifiers_to_channels: ChannelMap,
          pseudo_random_generator: random.Random,
          block_number: BlockNumber,
  ) -> TransitionResult[MediatorTransferState]:
      
      secrethash = onchain_secret_reveal.secrethash
      is_valid_reveal = is_valid_secret_reveal(
          state_change=onchain_secret_reveal,
          transfer_secrethash=mediator_state.secrethash,
          secret=onchain_secret_reveal.secret,
      )
  
      if is_valid_reveal:
          secret = onchain_secret_reveal.secret
          # Compare against the block number at which the event was emitted.
          block_number = onchain_secret_reveal.block_number
  
          secret_reveal = set_onchain_secret(
              state=mediator_state,
              channelidentifiers_to_channels=channelidentifiers_to_channels,
              secret=secret,
              secrethash=secrethash,
              block_number=block_number,
          )
  
          balance_proof = events_for_balanceproof(
              channelidentifiers_to_channels=channelidentifiers_to_channels,
              transfers_pair=mediator_state.transfers_pair,
              pseudo_random_generator=pseudo_random_generator,
              block_number=block_number,
              secret=secret,
              secrethash=secrethash,
          )
          iteration = TransitionResult(mediator_state, secret_reveal + balance_proof)
      else:
          iteration = TransitionResult(mediator_state, list())
  
      return iteration
docs: The secret was revealed on-chain, set the state of all transfers to
      secret known.