Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Trait for deployment_method #531

Closed
bh2smith opened this issue Jun 12, 2021 · 1 comment
Closed

Trait for deployment_method #531

bh2smith opened this issue Jun 12, 2021 · 1 comment

Comments

@bh2smith
Copy link
Contributor

bh2smith commented Jun 12, 2021

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,
    }
}
@bh2smith
Copy link
Contributor Author

I assume this is all related to #513 .

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

No branches or pull requests

1 participant