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

PairSigner fails to be created from sr25519::Pair #844

Closed
lx38 opened this issue Mar 2, 2023 · 5 comments · Fixed by #853
Closed

PairSigner fails to be created from sr25519::Pair #844

lx38 opened this issue Mar 2, 2023 · 5 comments · Fixed by #853

Comments

@lx38
Copy link

lx38 commented Mar 2, 2023

I'm trying to create a PairSigner to execute transaction, but unable to do so, here is the simple code. Can you help?

use sp_core::Pair;
async fn main() {
    let pair = sp_core::sr25519::Pair::from_string_with_seed(
        "0x1470c36a50ea10822d6c7346ded0cecaccc6e40c9b520d457271082c08628771",
        None,
    )
    .unwrap()
    .0;

    let signer = subxt::tx::PairSigner::new(pair);
}

ERROR

error[E0277]: the trait bound `sp_core::sr25519::Pair: sp_core::crypto::Pair` is not satisfied
  --> test-subxt/src/main.rs:13:34
   |
13 |     let signer = PairSigner::new(pair);
   |                  --------------- ^^^^ the trait `sp_core::crypto::Pair` is not implemented for `sp_core::sr25519::Pair`
   |                  |
   |                  required by a bound introduced by this call
   |
   = help: the following other types implement trait `sp_core::crypto::Pair`:
             sp_application_crypto::ecdsa::app::Pair
             sp_application_crypto::ed25519::app::Pair
             sp_application_crypto::sr25519::app::Pair
             sp_core::crypto::dummy::Dummy
             sp_core::ecdsa::Pair
             sp_core::ed25519::Pair
             sp_core::sr25519::Pair
note: required by a bound in `PairSigner::<T, Pair>::new`
  --> /Users/igorl/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/subxt-0.27.1/src/tx/signer.rs:56:15
   |
56 |         Pair: PairT,
   |               ^^^^^ required by this bound in `PairSigner::<T, Pair>::new`

To me it looks strange as it suggest the trait sp_core::crypto::Pair is not implemented for sp_core::sr25519::Pair
but down the line say
the following other types implement trait sp_core::crypto::Pair:
sp_core::sr25519::Pair

@niklasad1
Copy link
Member

niklasad1 commented Mar 2, 2023

My guess is that sp_core that you are using has a different version than the one from subxt.
If you using the latest subxt version (v0.27.1) try with sp-core v16.0.0 instead that should fix it.

@lx38
Copy link
Author

lx38 commented Mar 2, 2023

Thank you Niklas. I was trying to use versions 7, 17, 18, as I was thinking that might be the reason... but I did not go to 16 and it worked! I appreciate your time and help!

@niklasad1
Copy link
Member

//cc @jsdw might be better to re-export sp-core and sp-runtime as we did before when #[cfg(feature = "substrate-compat")] is enabled.

However, if we follow the substrate release schedule on crates.io in subxt as well I guess that would be fine as well.

@jsdw
Copy link
Collaborator

jsdw commented Mar 2, 2023

Yeah you're right; let's just re-export them again behind the substrate-compat feature flag so that people can be sure to use the versions we are aligning with :)

@deuszx
Copy link

deuszx commented Mar 8, 2023

Yes, please do that before the next release (ideally soonish) as this broke our client as well - we can't update to the latest version b/c of this change and we can't stay on the 0.25.0 and use ink4-related deps b/c of Wasmtime issue.

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

Successfully merging a pull request may close this issue.

4 participants