mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-10 01:47:58 +00:00
Fix MultiSigner, simplify tests (#2033)
* Fix MultiSigner, use `into_signed_tx` * Rebuild.
This commit is contained in:
committed by
Gavin Wood
parent
b483c5608f
commit
08fda211d8
@@ -30,7 +30,7 @@ pub use serde_derive;
|
||||
pub use runtime_io::{StorageOverlay, ChildrenStorageOverlay};
|
||||
|
||||
use rstd::prelude::*;
|
||||
use substrate_primitives::{ed25519, sr25519, hash::H512};
|
||||
use substrate_primitives::{crypto, ed25519, sr25519, hash::{H256, H512}};
|
||||
use codec::{Encode, Decode};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
@@ -310,6 +310,18 @@ pub enum MultiSignature {
|
||||
Sr25519(sr25519::Signature),
|
||||
}
|
||||
|
||||
impl From<ed25519::Signature> for MultiSignature {
|
||||
fn from(x: ed25519::Signature) -> Self {
|
||||
MultiSignature::Ed25519(x)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<sr25519::Signature> for MultiSignature {
|
||||
fn from(x: sr25519::Signature) -> Self {
|
||||
MultiSignature::Sr25519(x)
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for MultiSignature {
|
||||
fn default() -> Self {
|
||||
MultiSignature::Ed25519(Default::default())
|
||||
@@ -332,6 +344,45 @@ impl Default for MultiSigner {
|
||||
}
|
||||
}
|
||||
|
||||
/// NOTE: This implementations is required by `SimpleAddressDeterminator`,
|
||||
/// we convert the hash into some AccountId, it's fine to use any scheme.
|
||||
impl<T: Into<H256>> crypto::UncheckedFrom<T> for MultiSigner {
|
||||
fn unchecked_from(x: T) -> Self {
|
||||
ed25519::Public::unchecked_from(x.into()).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<[u8]> for MultiSigner {
|
||||
fn as_ref(&self) -> &[u8] {
|
||||
match *self {
|
||||
MultiSigner::Ed25519(ref who) => who.as_ref(),
|
||||
MultiSigner::Sr25519(ref who) => who.as_ref(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ed25519::Public> for MultiSigner {
|
||||
fn from(x: ed25519::Public) -> Self {
|
||||
MultiSigner::Ed25519(x)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<sr25519::Public> for MultiSigner {
|
||||
fn from(x: sr25519::Public) -> Self {
|
||||
MultiSigner::Sr25519(x)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl std::fmt::Display for MultiSigner {
|
||||
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match *self {
|
||||
MultiSigner::Ed25519(ref who) => write!(fmt, "ed25519: {}", who),
|
||||
MultiSigner::Sr25519(ref who) => write!(fmt, "sr25519: {}", who),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Verify for MultiSignature {
|
||||
type Signer = MultiSigner;
|
||||
fn verify<L: Lazy<[u8]>>(&self, msg: L, signer: &Self::Signer) -> bool {
|
||||
@@ -357,8 +408,14 @@ impl Verify for AnySignature {
|
||||
}
|
||||
|
||||
impl From<sr25519::Signature> for AnySignature {
|
||||
fn from(s: sr25519::Signature) -> AnySignature {
|
||||
AnySignature(s.0.into())
|
||||
fn from(s: sr25519::Signature) -> Self {
|
||||
AnySignature(s.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ed25519::Signature> for AnySignature {
|
||||
fn from(s: ed25519::Signature) -> Self {
|
||||
AnySignature(s.into())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user