Skip to content

Commit

Permalink
feat: expose deposit transaction hash from ingress-egress-tracker (#5320
Browse files Browse the repository at this point in the history
)

* feat: expose deposit transaction hash from ingress-egress-tracker [WEB-1511]

* fixes

* make deposit_details optional

* fix tests
  • Loading branch information
jerryafr authored Oct 17, 2024
1 parent d59eac6 commit d9253e1
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ source: api/bin/chainflip-ingress-egress-tracker/src/witnessing/state_chain.rs
assertion_line: 487
expression: "store.storage.get(format!(\"deposit:Polkadot:{}\", format!\n (\"0x{}\", hex ::\n encode(polkadot_account_id.aliased_ref()))).as_str()).unwrap()"
---
[{"amount":"0x64","asset":{"asset":"DOT","chain":"Polkadot"},"deposit_chain_block_height":1}]
[{"amount":"0x64","asset":{"asset":"DOT","chain":"Polkadot"},"deposit_chain_block_height":1,"deposit_details":{"extrinsic_index":1}}]
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ source: api/bin/chainflip-ingress-egress-tracker/src/witnessing/state_chain.rs
assertion_line: 497
expression: "store.storage.get(format!(\"deposit:Ethereum:{}\",\n eth_address_str2.to_lowercase()).as_str()).unwrap()"
---
[{"amount":"0x64","asset":{"asset":"ETH","chain":"Ethereum"},"deposit_chain_block_height":1}]
[{"amount":"0x64","asset":{"asset":"ETH","chain":"Ethereum"},"deposit_chain_block_height":1,"deposit_details":null}]
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ source: api/bin/chainflip-ingress-egress-tracker/src/witnessing/state_chain.rs
assertion_line: 521
expression: "store.storage.get(format!(\"deposit:Ethereum:{}\",\n eth_address_str1.to_lowercase()).as_str()).unwrap()"
---
[{"amount":"0x64","asset":{"asset":"ETH","chain":"Ethereum"},"deposit_chain_block_height":1},{"amount":"0x1e8480","asset":{"asset":"ETH","chain":"Ethereum"},"deposit_chain_block_height":1}]
[{"amount":"0x64","asset":{"asset":"ETH","chain":"Ethereum"},"deposit_chain_block_height":1,"deposit_details":null},{"amount":"0x1e8480","asset":{"asset":"ETH","chain":"Ethereum"},"deposit_chain_block_height":1,"deposit_details":null}]
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ source: api/bin/chainflip-ingress-egress-tracker/src/witnessing/state_chain.rs
assertion_line: 483
expression: "store.storage.get(format!(\"deposit:Ethereum:{}\",\n eth_address_str1.to_lowercase()).as_str()).unwrap()"
---
[{"amount":"0x64","asset":{"asset":"ETH","chain":"Ethereum"},"deposit_chain_block_height":1}]
[{"amount":"0x64","asset":{"asset":"ETH","chain":"Ethereum"},"deposit_chain_block_height":1,"deposit_details":null}]
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
};
use cf_chains::{
address::ToHumanreadableAddress,
dot::PolkadotTransactionId,
dot::{PolkadotExtrinsicIndex, PolkadotTransactionId},
evm::{SchnorrVerificationComponents, H256},
AnyChain, Arbitrum, Bitcoin, Chain, Ethereum, Polkadot,
};
Expand Down Expand Up @@ -58,6 +58,15 @@ enum TransactionId {
Arbitrum { signature: SchnorrVerificationComponents },
}

#[derive(Serialize)]
#[serde(untagged)]
enum DepositDetails {
Bitcoin { tx_id: H256, vout: u32 },
Ethereum { tx_hashes: Vec<H256> },
Polkadot { extrinsic_index: PolkadotExtrinsicIndex },
Arbitrum { tx_hashes: Vec<H256> },
}

#[derive(Serialize)]
#[serde(untagged)]
enum WitnessInformation {
Expand All @@ -67,6 +76,7 @@ enum WitnessInformation {
deposit_address: String,
amount: NumberOrHex,
asset: cf_chains::assets::any::Asset,
deposit_details: Option<DepositDetails>,
},
Broadcast {
#[serde(skip_serializing)]
Expand Down Expand Up @@ -121,6 +131,10 @@ impl From<DepositInfo<Ethereum>> for WitnessInformation {
deposit_address: hex_encode_bytes(value.deposit_address.as_bytes()),
amount: value.amount.into(),
asset: value.asset.into(),
deposit_details: value
.deposit_details
.tx_hashes
.map(|tx_hashes| DepositDetails::Ethereum { tx_hashes }),
}
}
}
Expand All @@ -132,6 +146,10 @@ impl From<DepositInfo<Bitcoin>> for WitnessInformation {
deposit_address: value.deposit_address.to_humanreadable(network),
amount: value.amount.into(),
asset: value.asset.into(),
deposit_details: Some(DepositDetails::Bitcoin {
tx_id: value.deposit_details.tx_id,
vout: value.deposit_details.vout,
}),
}
}
}
Expand All @@ -143,6 +161,9 @@ impl From<DepositInfo<Polkadot>> for WitnessInformation {
deposit_address: hex_encode_bytes(value.deposit_address.aliased_ref()),
amount: value.amount.into(),
asset: value.asset.into(),
deposit_details: Some(DepositDetails::Polkadot {
extrinsic_index: value.deposit_details,
}),
}
}
}
Expand All @@ -154,6 +175,10 @@ impl From<DepositInfo<Arbitrum>> for WitnessInformation {
deposit_address: hex_encode_bytes(value.deposit_address.as_bytes()),
amount: value.amount.into(),
asset: value.asset.into(),
deposit_details: value
.deposit_details
.tx_hashes
.map(|tx_hashes| DepositDetails::Arbitrum { tx_hashes }),
}
}
}
Expand Down Expand Up @@ -208,15 +233,8 @@ where
deposit_witnesses,
block_height,
}) =>
for witness in deposit_witnesses as Vec<DepositWitness<Polkadot>> {
store
.save_to_array(&WitnessInformation::from((
witness,
block_height,
chainflip_network,
)))
.await?;
},
save_deposit_witnesses(store, deposit_witnesses, block_height, chainflip_network)
.await?,
ArbitrumIngressEgress(IngressEgressCall::process_deposits {
deposit_witnesses,
block_height,
Expand Down

0 comments on commit d9253e1

Please sign in to comment.