Skip to content

Commit

Permalink
feat(rt-sync): add pair_fees_json
Browse files Browse the repository at this point in the history
  • Loading branch information
hydra-yse committed Dec 11, 2024
1 parent 3444ff3 commit 87cf5c4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
10 changes: 5 additions & 5 deletions lib/core/src/persist/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ impl Persister {
refund_private_key,
claim_fees_sat,
created_at,
state,
pair_fees_json
state
)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
(
&chain_swap.id,
&id_hash,
Expand All @@ -57,7 +56,6 @@ impl Persister {
&chain_swap.claim_fees_sat,
&chain_swap.created_at,
&chain_swap.state,
&chain_swap.pair_fees_json,
),
)?;

Expand All @@ -68,7 +66,8 @@ impl Persister {
server_lockup_tx_id = :server_lockup_tx_id,
user_lockup_tx_id = :user_lockup_tx_id,
claim_tx_id = :claim_tx_id,
refund_tx_id = :refund_tx_id
refund_tx_id = :refund_tx_id,
pair_fees_json = :pair_fees_json
WHERE
id = :id",
named_params! {
Expand All @@ -78,6 +77,7 @@ impl Persister {
":user_lockup_tx_id": &chain_swap.user_lockup_tx_id,
":claim_tx_id": &chain_swap.claim_tx_id,
":refund_tx_id": &chain_swap.refund_tx_id,
":pair_fees_json": &chain_swap.pair_fees_json,
},
)?;

Expand Down
2 changes: 1 addition & 1 deletion lib/core/src/persist/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl Persister {
state,
pair_fees_json
)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
(
&send_swap.id,
&id_hash,
Expand Down
9 changes: 9 additions & 0 deletions lib/core/src/sync/model/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub(crate) const LAST_DERIVATION_INDEX_DATA_ID: &str = "last-derivation-index";
pub(crate) struct ChainSyncData {
pub(crate) swap_id: String,
pub(crate) preimage: String,
pub(crate) pair_fees_json: String,
pub(crate) create_response_json: String,
pub(crate) direction: Direction,
pub(crate) lockup_address: String,
Expand Down Expand Up @@ -38,6 +39,7 @@ impl From<ChainSwap> for ChainSyncData {
Self {
swap_id: value.id,
preimage: value.preimage,
pair_fees_json: value.pair_fees_json,
create_response_json: value.create_response_json,
direction: value.direction,
lockup_address: value.lockup_address,
Expand Down Expand Up @@ -67,6 +69,7 @@ impl From<ChainSyncData> for ChainSwap {
receiver_amount_sat: val.receiver_amount_sat,
claim_fees_sat: val.claim_fees_sat,
accept_zero_conf: val.accept_zero_conf,
pair_fees_json: val.pair_fees_json,
create_response_json: val.create_response_json,
created_at: val.created_at,
claim_private_key: val.claim_private_key,
Expand All @@ -85,6 +88,7 @@ impl From<ChainSyncData> for ChainSwap {
pub(crate) struct SendSyncData {
pub(crate) swap_id: String,
pub(crate) invoice: String,
pub(crate) pair_fees_json: String,
pub(crate) create_response_json: String,
pub(crate) refund_private_key: String,
pub(crate) payer_amount_sat: u64,
Expand Down Expand Up @@ -113,6 +117,7 @@ impl From<SendSwap> for SendSyncData {
swap_id: value.id,
payment_hash: value.payment_hash,
invoice: value.invoice,
pair_fees_json: value.pair_fees_json,
create_response_json: value.create_response_json,
refund_private_key: value.refund_private_key,
payer_amount_sat: value.payer_amount_sat,
Expand All @@ -135,6 +140,7 @@ impl From<SendSyncData> for SendSwap {
preimage: val.preimage,
payer_amount_sat: val.payer_amount_sat,
receiver_amount_sat: val.receiver_amount_sat,
pair_fees_json: val.pair_fees_json,
create_response_json: val.create_response_json,
created_at: val.created_at,
refund_private_key: val.refund_private_key,
Expand All @@ -151,6 +157,7 @@ pub(crate) struct ReceiveSyncData {
pub(crate) swap_id: String,
pub(crate) invoice: String,
pub(crate) preimage: String,
pub(crate) pair_fees_json: String,
pub(crate) create_response_json: String,
pub(crate) claim_fees_sat: u64,
pub(crate) claim_private_key: String,
Expand All @@ -169,6 +176,7 @@ impl From<ReceiveSwap> for ReceiveSyncData {
payment_hash: value.payment_hash,
invoice: value.invoice,
preimage: value.preimage,
pair_fees_json: value.pair_fees_json,
create_response_json: value.create_response_json,
claim_fees_sat: value.claim_fees_sat,
claim_private_key: value.claim_private_key,
Expand All @@ -187,6 +195,7 @@ impl From<ReceiveSyncData> for ReceiveSwap {
id: val.swap_id,
preimage: val.preimage,
create_response_json: val.create_response_json,
pair_fees_json: val.pair_fees_json,
claim_private_key: val.claim_private_key,
invoice: val.invoice,
payment_hash: val.payment_hash,
Expand Down
2 changes: 1 addition & 1 deletion lib/core/src/test_utils/swapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ impl Swapper for MockSwapper {
unimplemented!()
}

fn get_zero_amount_chain_swap_quote(&self, swap_id: &str) -> Result<Amount, PaymentError> {
fn get_zero_amount_chain_swap_quote(&self, _swap_id: &str) -> Result<Amount, PaymentError> {
unimplemented!()
}

Expand Down
3 changes: 3 additions & 0 deletions lib/core/src/test_utils/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ pub(crate) fn new_receive_sync_data() -> ReceiveSyncData {
ReceiveSyncData {
swap_id: "receive-swap".to_string(),
invoice: "".to_string(),
pair_fees_json: "".to_string(),
create_response_json: "".to_string(),
payer_amount_sat: 0,
receiver_amount_sat: 0,
Expand All @@ -133,6 +134,7 @@ pub(crate) fn new_send_sync_data(preimage: Option<String>) -> SendSyncData {
SendSyncData {
swap_id: "send-swap".to_string(),
invoice: "".to_string(),
pair_fees_json: "".to_string(),
create_response_json: "".to_string(),
refund_private_key: "".to_string(),
payer_amount_sat: 0,
Expand All @@ -149,6 +151,7 @@ pub(crate) fn new_chain_sync_data(accept_zero_conf: Option<bool>) -> ChainSyncDa
ChainSyncData {
swap_id: "chain-swap".to_string(),
preimage: "".to_string(),
pair_fees_json: "".to_string(),
create_response_json: "".to_string(),
direction: Direction::Incoming,
lockup_address: "".to_string(),
Expand Down

0 comments on commit 87cf5c4

Please sign in to comment.