Skip to content

Commit

Permalink
fix polkadot primitives (paritytech#908)
Browse files Browse the repository at this point in the history
  • Loading branch information
svyatonik authored Apr 19, 2021
1 parent 69feacf commit 03168a7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
30 changes: 20 additions & 10 deletions primitives/polkadot-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ use frame_support::{
Blake2_128Concat, RuntimeDebug, StorageHasher, Twox128,
};
use frame_system::limits;
use parity_scale_codec::Compact;
use sp_core::Hasher as HasherT;
use sp_runtime::{
generic,
traits::{BlakeTwo256, IdentifyAccount, Verify},
MultiSignature, OpaqueExtrinsic, Perbill,
MultiAddress, MultiSignature, OpaqueExtrinsic, Perbill,
};
use sp_std::prelude::Vec;

Expand Down Expand Up @@ -192,10 +193,19 @@ pub type SignedBlock = generic::SignedBlock<Block>;
pub type Balance = u128;

/// Unchecked Extrinsic type.
pub type UncheckedExtrinsic<Call> = generic::UncheckedExtrinsic<AccountId, Call, Signature, SignedExtensions<Call>>;
pub type UncheckedExtrinsic<Call> =
generic::UncheckedExtrinsic<MultiAddress<AccountId, ()>, Call, Signature, SignedExtensions<Call>>;

/// A type of the data encoded as part of the transaction.
pub type SignedExtra = ((), (), (), sp_runtime::generic::Era, Nonce, (), Balance);
pub type SignedExtra = (
(),
(),
(),
sp_runtime::generic::Era,
Compact<Nonce>,
(),
Compact<Balance>,
);

/// Parameters which are part of the payload used to produce transaction signature,
/// but don't end up in the transaction itself (i.e. inherent part of the runtime).
Expand Down Expand Up @@ -232,13 +242,13 @@ impl<Call> SignedExtensions<Call> {
) -> Self {
Self {
encode_payload: (
(), // spec version
(), // tx version
(), // genesis
era, // era
nonce, // nonce (compact encoding)
(), // Check weight
tip, // transaction payment / tip (compact encoding)
(), // spec version
(), // tx version
(), // genesis
era, // era
nonce.into(), // nonce (compact encoding)
(), // Check weight
tip.into(), // transaction payment / tip (compact encoding)
),
additional_signed: (
version.spec_version,
Expand Down
7 changes: 6 additions & 1 deletion relays/client-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ impl TransactionSignScheme for Rococo {
let signer: sp_runtime::MultiSigner = signer.public().into();
let (call, extra, _) = raw_payload.deconstruct();

bp_rococo::UncheckedExtrinsic::new_signed(call, signer.into_account(), signature.into(), extra)
bp_rococo::UncheckedExtrinsic::new_signed(
call,
sp_runtime::MultiAddress::Id(signer.into_account()),
signature.into(),
extra,
)
}
}

Expand Down
7 changes: 6 additions & 1 deletion relays/client-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ impl TransactionSignScheme for Westend {
let signer: sp_runtime::MultiSigner = signer.public().into();
let (call, extra, _) = raw_payload.deconstruct();

bp_westend::UncheckedExtrinsic::new_signed(call, signer.into_account(), signature.into(), extra)
bp_westend::UncheckedExtrinsic::new_signed(
call,
sp_runtime::MultiAddress::Id(signer.into_account()),
signature.into(),
extra,
)
}
}

Expand Down

0 comments on commit 03168a7

Please sign in to comment.