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

add set up util #6

Open
Perelyn-sama opened this issue Apr 22, 2023 · 2 comments
Open

add set up util #6

Perelyn-sama opened this issue Apr 22, 2023 · 2 comments

Comments

@Perelyn-sama
Copy link
Owner

No description provided.

@Perelyn-sama
Copy link
Owner Author

I'm finding it had to complete this because of some issue with generics

error[E0308]: mismatched types
  --> src/utils/mod.rs:38:5
   |
17 | pub fn setup<M>() -> Seaport<M> {
   |              -       ---------- expected `Seaport<M>` because of return type
   |              |
   |              this type parameter
...
38 |     seaport
   |     ^^^^^^^ expected type parameter `M`, found struct `SignerMiddleware`
   |
   = note: expected struct `Seaport<M>`
              found struct `Seaport<ethers::middleware::SignerMiddleware<ethers::providers::Provider<ethers::providers::Http>, Wallet<ethers::core::k256::ecdsa::SigningKey>>>`

@Perelyn-sama
Copy link
Owner Author

code

use crate::prelude::*;
use ethers::prelude::*;
use eyre::Result;
use std::collections::HashMap;
use std::str::FromStr;
use std::sync::Arc;

pub fn setup<M>() -> Seaport<M> {
    let mut map = HashMap::new();
    map.insert(
        SeaportConfig::get_opensea_conduit_key(),
        *constants::OPENSEA_CONDUIT_ADDRESS,
    );

    let provider =
        Provider::<Http>::try_from("https://mainnet.infura.io/v3/c60b0bb42f8a4c6481ecd229eddaca27")
            .unwrap();

    let signer = LocalWallet::new(&mut rand::thread_rng());
    let signer_middleware = SignerMiddleware::new(provider, signer);

    let client = Arc::new(signer_middleware);

    let seaport = Seaport::new(
        client,
        Address::from_str(CROSS_CHAIN_SEAPORT_ADDRESS).unwrap(),
    )
    .build();
    seaport
}

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