cowprotocol/ethcontract-rs

Trait for deployment_method

bh2smith opened this issue · 1 comments

This bit of code could be made more generic if there was some trait X that has deployment_information. I tried using ethcontract::contracts::Instance but cargo complained that it was a struct and not a trait.

async fn get_deployment_block<C: SomeTrait>(contract: &C) -> Option<u64> {
    match contract.deployment_information() {
        Some(DeploymentInformation::BlockNumber(block_number)) => Some(block_number),
        Some(DeploymentInformation::TransactionHash(hash)) => Some(
            contract
                .raw_instance()
                .web3()
                .block_number_from_tx_hash(hash)
                .await?,
        ),
        None => None,
    }
}

I assume this is all related to #513 .