Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions contracts/satoshi-bridge/src/btc_light_client/deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ impl Contract {
if is_success {
Event::UtxoAdded {
utxo_storage_keys: vec![pending_utxo_info.utxo_storage_key.clone()],
balances: Some(vec![U128::from(<u64 as Into<u128>>::into(
pending_utxo_info.utxo.balance,
))]),
}
.emit();
self.internal_set_utxo(&pending_utxo_info.utxo_storage_key, pending_utxo_info.utxo);
Expand Down
1 change: 1 addition & 0 deletions contracts/satoshi-bridge/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ pub enum Event<'a> {
},
UtxoAdded {
utxo_storage_keys: Vec<String>,
balances: Option<Vec<U128>>,
},
UtxoRemoved {
utxo_storage_keys: Vec<String>,
Expand Down
17 changes: 15 additions & 2 deletions contracts/satoshi-bridge/src/nbtc/burn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ impl Contract {
.expect("Deserialization tx_bytes failed");
let withdraw_change_script_pubkey = config.get_change_script_pubkey();
let mut utxo_storage_keys = vec![];
let mut balances = vec![];
for (index, output) in transaction.output().into_iter().enumerate() {
if withdraw_change_script_pubkey == output.script_pubkey {
let utxo = UTXO {
Expand All @@ -93,6 +94,7 @@ impl Contract {
tx_id.clone(),
u32::try_from(index).unwrap_or_else(|_| env::panic_str("Index overflow")),
);
balances.push(U128::from(<u64 as Into<u128>>::into(utxo.balance)));
self.internal_set_utxo(&utxo_storage_key, utxo);
utxo_storage_keys.push(utxo_storage_key);
}
Expand Down Expand Up @@ -138,7 +140,11 @@ impl Contract {
self.internal_transfer_nbtc(&btc_pending_info.account_id, refund);
}
self.internal_remove_btc_pending_info(&tx_id);
Event::UtxoAdded { utxo_storage_keys }.emit();
Event::UtxoAdded {
utxo_storage_keys,
balances: Some(balances),
}
.emit();
} else {
self.internal_unwrap_mut_btc_pending_info(&tx_id)
.to_pending_verify_stage();
Expand All @@ -163,6 +169,7 @@ impl Contract {
let config = self.internal_config();
let withdraw_change_script_pubkey = config.get_change_script_pubkey();
let mut utxo_storage_keys = vec![];
let mut balances: Vec<U128> = vec![];
for (index, output) in transaction.output().into_iter().enumerate() {
if withdraw_change_script_pubkey == output.script_pubkey {
let utxo = UTXO {
Expand All @@ -175,6 +182,8 @@ impl Contract {
tx_id.clone(),
u32::try_from(index).unwrap_or_else(|_| env::panic_str("Index overflow")),
);

balances.push(U128::from(<u64 as Into<u128>>::into(utxo.balance)));
self.internal_set_utxo(&utxo_storage_key, utxo);
utxo_storage_keys.push(utxo_storage_key);
}
Expand Down Expand Up @@ -205,7 +214,11 @@ impl Contract {
self.data_mut().rbf_txs.remove(&tx_id);
}
self.internal_remove_btc_pending_info(&tx_id);
Event::UtxoAdded { utxo_storage_keys }.emit();
Event::UtxoAdded {
utxo_storage_keys,
balances: Some(balances),
}
.emit();
} else {
self.internal_unwrap_mut_btc_pending_info(&tx_id)
.to_pending_verify_stage();
Expand Down
3 changes: 3 additions & 0 deletions contracts/satoshi-bridge/src/nbtc/mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ impl Contract {
}
Event::UtxoAdded {
utxo_storage_keys: vec![pending_utxo_info.utxo_storage_key.clone()],
balances: Some(vec![U128::from(<u64 as Into<u128>>::into(
pending_utxo_info.utxo.balance,
))]),
}
.emit();
self.internal_set_utxo(&pending_utxo_info.utxo_storage_key, pending_utxo_info.utxo);
Expand Down