|
@@ -18,8 +18,32 @@ impl FollowerEventWatcher for Watcher {
|
|
|
async fn run_counterparty_funds_locked_watcher<M: Middleware>(
|
|
async fn run_counterparty_funds_locked_watcher<M: Middleware>(
|
|
|
event_tx: channel::Sender<Event>,
|
|
event_tx: channel::Sender<Event>,
|
|
|
contract: SwapCreator<M>,
|
|
contract: SwapCreator<M>,
|
|
|
|
|
+ claim_commitment: [u8; 32],
|
|
|
|
|
+ refund_commitment: [u8; 32],
|
|
|
|
|
+ from_block: u64,
|
|
|
) -> Result<(), crate::Error> {
|
|
) -> Result<(), crate::Error> {
|
|
|
// watch for a `NewSwap` event with the correct swap parameters
|
|
// watch for a `NewSwap` event with the correct swap parameters
|
|
|
|
|
+ // note: we still need to check for correct asset, value, and timeout,
|
|
|
|
|
+ // which is done in the event handler [`Follower`].
|
|
|
|
|
+ let topic2: ethers::types::U256 = claim_commitment.into();
|
|
|
|
|
+ let topic3: ethers::types::U256 = refund_commitment.into();
|
|
|
|
|
+ let events = contract
|
|
|
|
|
+ .ready_filter()
|
|
|
|
|
+ .from_block(from_block)
|
|
|
|
|
+ .address(contract.address().into())
|
|
|
|
|
+ .topic2(topic2) // `newSwap` event sig is topic0 and `contract_swap_id` is topic1
|
|
|
|
|
+ .topic3(topic3);
|
|
|
|
|
+
|
|
|
|
|
+ let mut stream = events.stream().await.unwrap().with_meta();
|
|
|
|
|
+
|
|
|
|
|
+ // we listen for the first event, as there can only be one event
|
|
|
|
|
+ // that matches the filter (ie. has the same swap_id)
|
|
|
|
|
+ let Some(Ok((event, _meta))) = stream.next().await else {
|
|
|
|
|
+ return Err(Error::ReadyEventStreamFailed.into());
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ let contract_swap_id = event.swap_id;
|
|
|
|
|
+ event_tx.send(Event::CounterpartyFundsLocked(contract_swap_id)).await.unwrap();
|
|
|
Ok(())
|
|
Ok(())
|
|
|
}
|
|
}
|
|
|
|
|
|