Skip to content

Commit 593646c

Browse files
authored
Update default runtime types to match substrate, format code (paritytech#34)
* Update default runtime types to match latest substrate * Format code
1 parent b39ff17 commit 593646c

File tree

7 files changed

+45
-36
lines changed

7 files changed

+45
-36
lines changed

src/events.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use crate::{
2525
SystemEvent,
2626
};
2727
use log;
28+
use paint_system::Phase;
2829
use parity_scale_codec::{
2930
Codec,
3031
Compact,
@@ -34,7 +35,6 @@ use parity_scale_codec::{
3435
Input,
3536
Output,
3637
};
37-
use paint_system::Phase;
3838
use std::{
3939
collections::{
4040
HashMap,

src/extrinsic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ use runtime_primitives::{
3030
UncheckedExtrinsic,
3131
},
3232
traits::{
33-
Verify,
3433
IdentifyAccount,
3534
SignedExtension,
35+
Verify,
3636
},
3737
transaction_validity::TransactionValidityError,
3838
};

src/lib.rs

+24-25
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ use parity_scale_codec::{
3535
use runtime_primitives::{
3636
generic::UncheckedExtrinsic,
3737
traits::{
38-
Verify,
3938
IdentifyAccount,
39+
Verify,
4040
},
4141
MultiSignature,
4242
};
@@ -62,12 +62,6 @@ use crate::{
6262
SignedExtra,
6363
},
6464
metadata::MetadataError,
65-
rpc::{
66-
BlockNumber,
67-
ChainBlock,
68-
MapStream,
69-
Rpc,
70-
},
7165
paint::{
7266
balances::Balances,
7367
system::{
@@ -77,22 +71,28 @@ use crate::{
7771
},
7872
ModuleCalls,
7973
},
74+
rpc::{
75+
BlockNumber,
76+
ChainBlock,
77+
MapStream,
78+
Rpc,
79+
},
8080
};
8181

8282
mod codec;
8383
mod error;
8484
mod events;
8585
mod extrinsic;
8686
mod metadata;
87+
mod paint;
8788
mod rpc;
8889
mod runtimes;
89-
mod paint;
9090

9191
pub use error::Error;
9292
pub use events::RawEvent;
93+
pub use paint::*;
9394
pub use rpc::ExtrinsicSuccess;
9495
pub use runtimes::*;
95-
pub use paint::*;
9696

9797
fn connect<T: System>(url: &Url) -> impl Future<Item = Rpc<T>, Error = Error> {
9898
ws::connect(url).map_err(Into::into)
@@ -156,13 +156,12 @@ impl<T: System, S> Clone for Client<T, S> {
156156
genesis_hash: self.genesis_hash.clone(),
157157
metadata: self.metadata.clone(),
158158
runtime_version: self.runtime_version.clone(),
159-
_marker:PhantomData,
159+
_marker: PhantomData,
160160
}
161161
}
162162
}
163163

164-
impl<T: System + Balances + 'static, S: 'static> Client<T, S>
165-
{
164+
impl<T: System + Balances + 'static, S: 'static> Client<T, S> {
166165
fn connect(&self) -> impl Future<Item = Rpc<T>, Error = Error> {
167166
connect(&self.url)
168167
}
@@ -339,7 +338,8 @@ where
339338
}
340339
}
341340

342-
impl<T: System + Balances + Send + Sync + 'static, P, S: 'static> XtBuilder<T, P, S, Valid>
341+
impl<T: System + Balances + Send + Sync + 'static, P, S: 'static>
342+
XtBuilder<T, P, S, Valid>
343343
where
344344
P: Pair,
345345
S: Verify + Codec + From<P::Signature>,
@@ -357,8 +357,7 @@ where
357357
<DefaultExtra<T> as SignedExtra<T>>::Extra,
358358
>,
359359
Error,
360-
>
361-
{
360+
> {
362361
let signer = self.signer.clone();
363362
let account_nonce = self.nonce.clone();
364363
let version = self.runtime_version.spec_version;
@@ -415,22 +414,22 @@ where
415414
#[cfg(test)]
416415
mod tests {
417416
use super::*;
418-
use crate::paint::{
419-
balances::{
420-
Balances,
421-
BalancesStore,
422-
BalancesXt,
417+
use crate::{
418+
paint::{
419+
balances::{
420+
Balances,
421+
BalancesStore,
422+
BalancesXt,
423+
},
424+
contracts::ContractsXt,
423425
},
424-
contracts::ContractsXt,
426+
DefaultNodeRuntime as Runtime,
425427
};
426428
use futures::stream::Stream;
427-
use node_runtime::Runtime;
428429
use parity_scale_codec::Encode;
429430
use runtime_support::StorageMap;
430431
use substrate_keyring::AccountKeyring;
431-
use substrate_primitives::{
432-
storage::StorageKey,
433-
};
432+
use substrate_primitives::storage::StorageKey;
434433

435434
type Index = <Runtime as System>::Index;
436435
type AccountId = <Runtime as System>::AccountId;

src/paint/balances.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ use futures::future::{
2020
};
2121
use parity_scale_codec::Codec;
2222
use runtime_primitives::traits::{
23+
IdentifyAccount,
2324
MaybeSerialize,
2425
Member,
2526
SimpleArithmetic,
2627
Verify,
27-
IdentifyAccount,
2828
};
2929
use runtime_support::Parameter;
30-
use substrate_primitives::Pair;
3130
use std::fmt::Debug;
31+
use substrate_primitives::Pair;
3232

3333
/// The subset of the `paint_balances::Trait` that a client must implement.
3434
pub trait Balances: System {
@@ -111,7 +111,10 @@ pub trait BalancesXt {
111111
type Signature: Verify;
112112

113113
/// Create a call for the paint balances module
114-
fn balances<F>(&self, f: F) -> XtBuilder<Self::Balances, Self::Pair, Self::Signature, Valid>
114+
fn balances<F>(
115+
&self,
116+
f: F,
117+
) -> XtBuilder<Self::Balances, Self::Pair, Self::Signature, Valid>
115118
where
116119
F: FnOnce(
117120
ModuleCalls<Self::Balances, Self::Pair>,

src/paint/contracts.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ pub trait ContractsXt {
4848
type Signature: Verify;
4949

5050
/// Create a call for the paint contracts module
51-
fn contracts<F>(&self, f: F) -> XtBuilder<Self::Contracts, Self::Pair, Self::Signature, Valid>
51+
fn contracts<F>(
52+
&self,
53+
f: F,
54+
) -> XtBuilder<Self::Contracts, Self::Pair, Self::Signature, Valid>
5255
where
5356
F: FnOnce(
5457
ModuleCalls<Self::Contracts, Self::Pair>,

src/paint/system.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ use runtime_primitives::traits::{
3333
};
3434
use runtime_support::Parameter;
3535
use serde::de::DeserializeOwned;
36-
use substrate_primitives::Pair;
3736
use std::fmt::Debug;
37+
use substrate_primitives::Pair;
3838

3939
/// The subset of the `paint::Trait` that a client must implement.
4040
pub trait System: 'static + Eq + Clone + Debug {
@@ -155,7 +155,10 @@ pub trait SystemXt {
155155
type Signature: Verify;
156156

157157
/// Create a call for the paint system module
158-
fn system<F>(&self, f: F) -> XtBuilder<Self::System, Self::Pair, Self::Signature, Valid>
158+
fn system<F>(
159+
&self,
160+
f: F,
161+
) -> XtBuilder<Self::System, Self::Pair, Self::Signature, Valid>
159162
where
160163
F: FnOnce(
161164
ModuleCalls<Self::System, Self::Pair>,

src/runtimes.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ use runtime_primitives::{
2323
generic::Header,
2424
traits::{
2525
BlakeTwo256,
26+
IdentifyAccount,
2627
Verify,
2728
},
28-
AnySignature,
29+
MultiSignature,
2930
};
3031

3132
/// Concrete type definitions compatible with those in the default substrate `node_runtime`
@@ -42,13 +43,13 @@ impl System for DefaultNodeRuntime {
4243
type BlockNumber = u32;
4344
type Hash = substrate_primitives::H256;
4445
type Hashing = BlakeTwo256;
45-
type AccountId = <AnySignature as Verify>::Signer;
46+
type AccountId = <<MultiSignature as Verify>::Signer as IdentifyAccount>::AccountId;
4647
type Address = paint_indices::address::Address<Self::AccountId, u32>;
4748
type Header = Header<Self::BlockNumber, BlakeTwo256>;
4849
}
4950

5051
impl Balances for DefaultNodeRuntime {
51-
type Balance = u64;
52+
type Balance = u128;
5253
}
5354

5455
impl Contracts for DefaultNodeRuntime {}

0 commit comments

Comments
 (0)