feat: Take Chain object containing native/wrapped addresses
- This way this chain object contains everything we need, we don't need to worry about doing any transformation or calling any supplementary functions inside any of the encoders - Needed to move our new Chain object to a higher level since this is used in the higher-level encoder traits. This required some weird default values in the constants in order to avoid using alloy's hex literal. I could have instead opted to make Bytes parse a string I think, though this would mean possibly returning an error at the constants level, which is not nice either. Question: - Do we want the user to be in charge of passing the native and wrapped token every single time? This may be a bit annoying for the user. For now, I have defaulted to those in constants.rs, this would take 5 mins to remove though if you don't like it, and it would get rid of this complicated bytes initialization.
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
use alloy_primitives::hex;
|
||||
use tycho_core::{dto::Chain, Bytes};
|
||||
|
||||
pub fn native_address(chain: Chain) -> Bytes {
|
||||
match chain {
|
||||
Chain::Ethereum => Bytes::from(hex!("0000000000000000000000000000000000000000").to_vec()),
|
||||
// Placeholder values for other chains; update with real addresses
|
||||
_ => Bytes::from(hex!("0000000000000000000000000000000000000000").to_vec()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn wrapped_address(chain: Chain) -> Bytes {
|
||||
match chain {
|
||||
Chain::Ethereum => Bytes::from(hex!("c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2").to_vec()),
|
||||
// Placeholder values for other chains; update with real addresses
|
||||
_ => Bytes::from(hex!("0000000000000000000000000000000000000000").to_vec()),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user