|
|
@@ -13,26 +13,16 @@ use std::{
|
|
|
fmt::{Display, Formatter},
|
|
|
};
|
|
|
|
|
|
+pub(crate) use crate::ethereum::swap_creator::Swap as ContractSwapArgs;
|
|
|
+
|
|
|
// Initial parameters required by the swap initiator.
|
|
|
// TODO: make Address/U256 generic; these are ethers-specific right now
|
|
|
#[allow(dead_code)]
|
|
|
#[derive(Debug, Clone)]
|
|
|
pub(crate) struct InitiationArgs {
|
|
|
- pub(crate) claim_commitment: [u8; 32],
|
|
|
+ pub(crate) owner: Address,
|
|
|
pub(crate) claimer: Address,
|
|
|
- pub(crate) timeout_duration_1: U256,
|
|
|
- pub(crate) timeout_duration_2: U256,
|
|
|
- pub(crate) asset: Address,
|
|
|
- pub(crate) value: U256,
|
|
|
- pub(crate) nonce: U256,
|
|
|
-}
|
|
|
-
|
|
|
-// TODO: make Address/U256 generic; these are ethers-specific right now
|
|
|
-#[derive(Debug)]
|
|
|
-pub(crate) struct InitiateSwapArgs {
|
|
|
pub(crate) claim_commitment: [u8; 32],
|
|
|
- pub(crate) refund_commitment: [u8; 32],
|
|
|
- pub(crate) claimer: Address,
|
|
|
pub(crate) timeout_duration_1: U256,
|
|
|
pub(crate) timeout_duration_2: U256,
|
|
|
pub(crate) asset: Address,
|
|
|
@@ -40,6 +30,36 @@ pub(crate) struct InitiateSwapArgs {
|
|
|
pub(crate) nonce: U256,
|
|
|
}
|
|
|
|
|
|
+// // TODO: make Address/U256 generic; these are ethers-specific right now
|
|
|
+// #[derive(Debug, Clone)]
|
|
|
+// pub(crate) struct ContractSwapArgs {
|
|
|
+// pub(crate) owner: Address,
|
|
|
+// pub(crate) claimer: Address,
|
|
|
+// pub(crate) claim_commitment: [u8; 32],
|
|
|
+// pub(crate) refund_commitment: [u8; 32],
|
|
|
+// pub(crate) timeout_duration_1: U256,
|
|
|
+// pub(crate) timeout_duration_2: U256,
|
|
|
+// pub(crate) asset: Address,
|
|
|
+// pub(crate) value: U256,
|
|
|
+// pub(crate) nonce: U256,
|
|
|
+// }
|
|
|
+
|
|
|
+// impl From<ContractSwapArgs> for crate::ethereum::swap_creator::Swap {
|
|
|
+// fn from(args: ContractSwapArgs) -> Self {
|
|
|
+// Self {
|
|
|
+// owner: args.owner,
|
|
|
+// claim_commitment: args.claim_commitment,
|
|
|
+// refund_commitment: args.refund_commitment,
|
|
|
+// claimer: args.claimer,
|
|
|
+// timeout_1: args.timeout_duration_1,
|
|
|
+// timeout_2: args.timeout_duration_2,
|
|
|
+// asset: args.asset,
|
|
|
+// value: args.value,
|
|
|
+// nonce: args.nonce,
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
// Initial parameters required by the swap follower.
|
|
|
#[derive(Debug)]
|
|
|
pub(crate) struct FollowerArgs {
|
|
|
@@ -88,7 +108,7 @@ pub(crate) trait Initiator {
|
|
|
// initiates the swap by locking funds on chain A
|
|
|
async fn handle_counterparty_keys_received(
|
|
|
&self,
|
|
|
- args: InitiateSwapArgs,
|
|
|
+ args: ContractSwapArgs,
|
|
|
) -> Result<HandleCounterpartyKeysReceivedResult, Error>;
|
|
|
|
|
|
// handles the counterparty locking funds
|
|
|
@@ -143,8 +163,8 @@ pub(crate) trait InitiatorEventWatcher {
|
|
|
pub(crate) trait Follower {
|
|
|
// handle the swap initiation by locking funds on chain B
|
|
|
fn handle_counterparty_funds_locked(
|
|
|
- &self,
|
|
|
- contract_swap_id: [u8; 32],
|
|
|
+ &mut self,
|
|
|
+ contract_swap_id: ContractSwapArgs,
|
|
|
) -> Result<(), crate::Error>;
|
|
|
|
|
|
// handle the funds being ready to be claimed by us
|
|
|
@@ -162,6 +182,7 @@ pub(crate) trait FollowerEventWatcher {
|
|
|
async fn run_counterparty_funds_locked_watcher<M: Middleware>(
|
|
|
event_tx: channel::Sender<follower::Event>,
|
|
|
contract: SwapCreator<M>,
|
|
|
+ middleware: std::sync::Arc<M>,
|
|
|
claim_commitment: [u8; 32],
|
|
|
refund_commitment: [u8; 32],
|
|
|
from_block: u64,
|