Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

refactor: replace CoinProtocol with a true error type #2376

Open
dimxy opened this issue Feb 27, 2025 · 0 comments
Open

refactor: replace CoinProtocol with a true error type #2376

dimxy opened this issue Feb 27, 2025 · 0 comments

Comments

@dimxy
Copy link
Collaborator

dimxy commented Feb 27, 2025

Problem

We currently use CoinProtocol type as a error type:

fn try_from_coin_protocol(proto: CoinProtocol) -> Result<Self, MmError<CoinProtocol>>

while this looks like a misconception,
we also lose the error reason because of that, for e.g.:

let token_addr = valid_addr_from_str(&contract_address).map_err(|_| CoinProtocol::ERC20 {
                    // TODO: maybe add error description to this err (we're losing 'Invalid address checksum' here)
                    platform: platform.clone(),
                    contract_address,
                })?;

Solution

Let's create a true error type instead of using CoinProtocol and make it propagate lower errors (like Invalid address checksum.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant