nado-sdk 0.3.5

Official Rust SDK for the Nado Protocol API
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use ethers_contract::{ContractError, EthError};
use ethers_providers::Middleware;

pub fn parse_provider_error<M: Middleware>(error: ContractError<M>) -> String {
    match error {
        ContractError::Revert(ref data) => {
            let msg = String::decode_with_selector(data.to_vec().as_slice()).unwrap_or_else(|| {
                println!("failed to decode revert data: {error:?}");
                String::default()
            });
            format!("execution reverted: {msg}")
        }
        _ => error.to_string(),
    }
}