- 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.
- Tried not to leave a single public function undocumented, though did not double-document public function with obvious names
- Remove all mentions of the strategy selector in favour of the strategy registry (to avoid confusion)
Interface changes:
- Rename StrategySelector to StrategyEncoderRegistry
- Implement clone for SwapEncoder
The StrategyEncoderRegistry needs to be initialised at the highest level and the passed to the TychoEncoder.
The TychoEncoder doesn't hold the chain nor the signer_pk as attributes anymore
The StrategyEncoderRegistry does:
- Initialises the SwapEncoderRegistry
- Initialises all the strategies and saves them in a HashMap
- Later, the TychoEncoder only reads from this hashmap
The StrategyEncoder now each holds a SwapEncoderRegistry as an attribute and they use this to get the correct SwapEncoder instead of reading from the global SWAP_ENCODER_REGISTRY
Simplified the SwapEncoderRegistry to not need a Config (everything is done inside itself)
All SwapEncoders implement clone
Took 2 hours 29 minutes
Took 11 seconds
Took 2 minutes
It's a more intuitive order, since these are higher-level attributes.
Also remove the validation from the trait - it doesn't have to be part of the trait.
The issue was that we weren't indexing WETH properly since it was looking for the WETH address in tokens, when only native ETH would be in there
- Found by adding integration tests for the wrapping and unwrapping cases.