1

The examples in substrate use the sr25519 AccountId and Multisignature for creating offchain workers with signed transactions. Is there a way to use AccountId20 and EthereumSignature for a node using unified accounts?

I've tried this:

use fp_account::{EthereumSigner, EthereumSignature};
impl frame_system::offchain::AppCrypto<EthereumSigner, EthereumSignature> for TestAuthId {
        type RuntimeAppPublic = Public;
        type GenericPublic = sp_core::ecdsa::Public;
        type GenericSignature = sp_core::ecdsa::Signature;
    }

// Implemented for mock runtime in tests
impl frame_system::offchain::AppCrypto<<EcdsaSignature as Verify>::Signer, EcdsaSignature>
    for TestAuthId
    {
        type RuntimeAppPublic = Public;
        type GenericPublic = ecdsa::Public;
        type GenericSignature = ecdsa::Signature;
    }

But I'm getting these errors:

 error[E0277]: the trait bound `sp_core::ecdsa::Public: From<EthereumSigner>` is not satisfied
     --> <pallet>/src/lib.rs:29:30
      |
  29  |         type GenericPublic = sp_core::ecdsa::Public;
      |                              ^^^^^^^^^^^^^^^^^^^^^^ the trait `From<EthereumSigner>` is not implemented for `sp_core::ecdsa::Public`
      |
      = help: the following other types implement trait `From<T>`:
                <sp_core::ecdsa::Public as From<crypto::Public>>
                <sp_core::ecdsa::Public as From<sp_runtime::sp_application_crypto::ecdsa::AppPublic>>
      = note: required for `EthereumSigner` to implement `Into<sp_core::ecdsa::Public>`
      = note: required for `sp_core::ecdsa::Public` to implement `TryFrom<EthereumSigner>`
  note: required by a bound in `frame_system::offchain::AppCrypto::GenericPublic`
     --> <user>/.cargo/git/checkouts/substrate-485ba5260f31c511/c0155a6/frame/system/src/offchain.rs:397:5
      |
  395 |     type GenericPublic: From<Self::RuntimeAppPublic>
      |          ------------- required by a bound in this associated type
  396 |         + Into<Self::RuntimeAppPublic>
  397 |         + TryFrom<Public>
      |           ^^^^^^^^^^^^^^^ required by this bound in `AppCrypto::GenericPublic`

  error[E0277]: the trait bound `EthereumSignature: From<sp_core::ecdsa::Signature>` is not satisfied
     --> <pallet>/src/lib.rs:30:33
      |
  30  |         type GenericSignature = sp_core::ecdsa::Signature;
      |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<sp_core::ecdsa::Signature>` is not implemented for `EthereumSignature`
      |
      = note: required for `sp_core::ecdsa::Signature` to implement `Into<EthereumSignature>`
  note: required by a bound in `frame_system::offchain::AppCrypto::GenericSignature`
     --> <user>/.cargo/git/checkouts/substrate-485ba5260f31c511/c0155a6/frame/system/src/offchain.rs:404:5
      |
  401 |     type GenericSignature: From<<Self::RuntimeAppPublic as RuntimeAppPublic>::Signature>
      |          ---------------- required by a bound in this associated type
  ...
  404 |         + Into<Signature>;
      |           ^^^^^^^^^^^^^^^ required by this bound in `AppCrypto::GenericSignature`

  error[E0277]: the trait bound `sp_core::ecdsa::Signature: From<EthereumSignature>` is not satisfied
     --> <pallet>/src/lib.rs:30:33
      |
  30  |         type GenericSignature = sp_core::ecdsa::Signature;
      |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<EthereumSignature>` is not implemented for `sp_core::ecdsa::Signature`
      |
      = help: the following other types implement trait `From<T>`:
                <sp_core::ecdsa::Signature as From<crypto::Signature>>
                <sp_core::ecdsa::Signature as From<sp_runtime::sp_application_crypto::ecdsa::AppSignature>>
      = note: required for `EthereumSignature` to implement `Into<sp_core::ecdsa::Signature>`
      = note: required for `sp_core::ecdsa::Signature` to implement `TryFrom<EthereumSignature>`
  note: required by a bound in `frame_system::offchain::AppCrypto::GenericSignature`
     --> <user>/.cargo/git/checkouts/substrate-485ba5260f31c511/c0155a6/frame/system/src/offchain.rs:403:5
      |
  401 |     type GenericSignature: From<<Self::RuntimeAppPublic as RuntimeAppPublic>::Signature>
      |          ---------------- required by a bound in this associated type
  402 |         + Into<<Self::RuntimeAppPublic as RuntimeAppPublic>::Signature>
  403 |         + TryFrom<Signature>
      |           ^^^^^^^^^^^^^^^^^^ required by this bound in `AppCrypto::GenericSignature`

  For more information about this error, try `rustc --explain E0277`.

1 Answer 1

0

implement as follow

   impl TryFrom<EthereumSignature> for ecdsa::Signature {
        type Error = ();
        fn try_from(s: EthereumSignature) -> Result<Self, Self::Error> {
            Ok(s.0)
        }
    }
    impl From<ecdsa::Signature> for EthereumSignature {
        fn from(s: ecdsa::Signature)->Self{
            EthereumSignature::new(s)
        }
    }
    impl TryFrom<EthereumSigner> for ecdsa::Public {
        type Error = ();
        fn try_from(_s: EthereumSigner) -> Result<Self, Self::Error> {
            Err(())//TODO  [u8; 20] can not be [u8;33] 
    
        }
    }

Not the answer you're looking for? Browse other questions tagged or ask your own question.