Skip to content

Commit

Permalink
run cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Neolab-HaDuong committed May 22, 2022
1 parent 220e8ba commit a83ea43
Show file tree
Hide file tree
Showing 36 changed files with 262 additions and 217 deletions.
43 changes: 22 additions & 21 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
{
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#65c89b",
"activityBar.activeBorder": "#945bc4",
"activityBar.background": "#65c89b",
"activityBar.foreground": "#15202b",
"activityBar.inactiveForeground": "#15202b99",
"activityBarBadge.background": "#945bc4",
"activityBarBadge.foreground": "#e7e7e7",
"sash.hoverBorder": "#65c89b",
"statusBar.background": "#42b883",
"statusBar.foreground": "#15202b",
"statusBarItem.hoverBackground": "#359268",
"statusBarItem.remoteBackground": "#42b883",
"statusBarItem.remoteForeground": "#15202b",
"titleBar.activeBackground": "#42b883",
"titleBar.activeForeground": "#15202b",
"titleBar.inactiveBackground": "#42b88399",
"titleBar.inactiveForeground": "#15202b99"
},
"peacock.color": "#42b883"
}
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#65c89b",
"activityBar.activeBorder": "#945bc4",
"activityBar.background": "#65c89b",
"activityBar.foreground": "#15202b",
"activityBar.inactiveForeground": "#15202b99",
"activityBarBadge.background": "#945bc4",
"activityBarBadge.foreground": "#e7e7e7",
"sash.hoverBorder": "#65c89b",
"statusBar.background": "#42b883",
"statusBar.foreground": "#15202b",
"statusBarItem.hoverBackground": "#359268",
"statusBarItem.remoteBackground": "#42b883",
"statusBarItem.remoteForeground": "#15202b",
"titleBar.activeBackground": "#42b883",
"titleBar.activeForeground": "#15202b",
"titleBar.inactiveBackground": "#42b88399",
"titleBar.inactiveForeground": "#15202b99"
},
"peacock.color": "#42b883",
"editor.formatOnSave": true
}
12 changes: 6 additions & 6 deletions node/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed};

fn main() {
generate_cargo_keys();
rerun_if_git_head_changed();
}
use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed};

fn main() {
generate_cargo_keys();
rerun_if_git_head_changed();
}
81 changes: 48 additions & 33 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,26 @@ use sc_service::{ChainType, Properties};

use beefy_primitives::crypto::AuthorityId as BeefyId;
use sp_consensus_babe::AuthorityId as BabeId;
use sp_core::{crypto::{Ss58Codec, UncheckedInto}, sr25519, H160, U256, Pair, Public};
use sp_core::{
crypto::{Ss58Codec, UncheckedInto},
sr25519, Pair, Public, H160, U256,
};
use sp_finality_grandpa::AuthorityId as GrandpaId;
use sp_runtime::{traits::{IdentifyAccount, Verify}, PerU16};
use sp_runtime::{
traits::{IdentifyAccount, Verify},
PerU16,
};

use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use pallet_octopus_appchain::AuthorityId as OctopusId;

use uniqueone_appchain_runtime::{
currency::{OCTS, UNITS as UNET},
opaque::{Block, SessionKeys},
AccountId, BabeConfig, Balance, BalancesConfig, GenesisConfig, OctopusAppchainConfig,
AccountId, BabeConfig, Balance, BalancesConfig, CouncilCollectiveConfig, DemocracyConfig,
EVMConfig, EthereumChainIdConfig, EthereumConfig, GenesisConfig, OctopusAppchainConfig,
OctopusLposConfig, SessionConfig, Signature, SudoConfig, SystemConfig,
CouncilCollectiveConfig, TechComitteeCollectiveConfig, DemocracyConfig, EVMConfig, EthereumConfig,
TokensConfig, UnetConfConfig, UnetNftConfig, EthereumChainIdConfig,
TechComitteeCollectiveConfig, TokensConfig, UnetConfConfig, UnetNftConfig,
BABE_GENESIS_EPOCH_CONFIG, WASM_BINARY,
};

Expand Down Expand Up @@ -130,74 +136,83 @@ pub fn staging_testnet_config() -> Result<ChainSpec, String> {
// Sudo account
// 5FbjQgSg97nvPsfuf21D886B26mwtNvZTgEfGfWR6gdNy3Tx
hex!["9c5e883c0a7795c81d354aa2d596364e71f4bb07d047c8dcb67547fbe1114f12"].into(),

// Initial PoA authorities
vec![
(
// 5HGtNjqdYQxn8mhBX22Z6HPjRSSmeb54zTTs3s798yyu4fk9
hex!["e6778539813675cb74a29d82d68ec7d9626430cf5818bc75da3af738c8a48666"].into(),
hex!["e6778539813675cb74a29d82d68ec7d9626430cf5818bc75da3af738c8a48666"]
.into(),
// 5HGtNjqdYQxn8mhBX22Z6HPjRSSmeb54zTTs3s798yyu4fk9
hex!["e6778539813675cb74a29d82d68ec7d9626430cf5818bc75da3af738c8a48666"].unchecked_into(),
hex!["e6778539813675cb74a29d82d68ec7d9626430cf5818bc75da3af738c8a48666"]
.unchecked_into(),
// 5HgtmpdnGgKJ1Wia5XTsFPGw3JYjKXFrrCXQq7TparBwLzJi
hex!["f8c6bff47eec7c2fe49be0b0d6c638757ff19562ea9ae1a76ed63d22f979b79c"].unchecked_into(),
hex!["f8c6bff47eec7c2fe49be0b0d6c638757ff19562ea9ae1a76ed63d22f979b79c"]
.unchecked_into(),
// 5HGtNjqdYQxn8mhBX22Z6HPjRSSmeb54zTTs3s798yyu4fk9
hex!["e6778539813675cb74a29d82d68ec7d9626430cf5818bc75da3af738c8a48666"].unchecked_into(),
hex!["e6778539813675cb74a29d82d68ec7d9626430cf5818bc75da3af738c8a48666"]
.unchecked_into(),
// 5CtT5c71rGrnnj3VJqvNqvJQKeBwyh73jGm4EduQ32igi1ym
hex!["02e23d37735cebc72732f31c86cca3a70f2c5d3087854ac94fe5aa1fec1bbb0e18"].unchecked_into(),
hex!["02e23d37735cebc72732f31c86cca3a70f2c5d3087854ac94fe5aa1fec1bbb0e18"]
.unchecked_into(),
// 5HGtNjqdYQxn8mhBX22Z6HPjRSSmeb54zTTs3s798yyu4fk9
hex!["e6778539813675cb74a29d82d68ec7d9626430cf5818bc75da3af738c8a48666"].unchecked_into(),

100 * OCTS

hex!["e6778539813675cb74a29d82d68ec7d9626430cf5818bc75da3af738c8a48666"]
.unchecked_into(),
100 * OCTS,
),
(
// 5G9LtRirf1bVqaVChnZmCXmQ2f4dgFCdjDQsS1eA4sGSE8NS
hex!["b47a9211bf46832f093a29965082003d5b40c817cc678808bf177c879abbbc42"].into(),
hex!["b47a9211bf46832f093a29965082003d5b40c817cc678808bf177c879abbbc42"]
.into(),
// 5G9LtRirf1bVqaVChnZmCXmQ2f4dgFCdjDQsS1eA4sGSE8NS
hex!["b47a9211bf46832f093a29965082003d5b40c817cc678808bf177c879abbbc42"].unchecked_into(),
hex!["b47a9211bf46832f093a29965082003d5b40c817cc678808bf177c879abbbc42"]
.unchecked_into(),
// 5CYZaymcu6jdq3bzsch7dgfsQdG347VEjPNbygwrtUXqGqmu
hex!["153f07c39a47483fbdc7be025a78139fec54e350894fbaf567125135571c0e66"].unchecked_into(),
hex!["153f07c39a47483fbdc7be025a78139fec54e350894fbaf567125135571c0e66"]
.unchecked_into(),
// 5G9LtRirf1bVqaVChnZmCXmQ2f4dgFCdjDQsS1eA4sGSE8NS
hex!["b47a9211bf46832f093a29965082003d5b40c817cc678808bf177c879abbbc42"].unchecked_into(),
hex!["b47a9211bf46832f093a29965082003d5b40c817cc678808bf177c879abbbc42"]
.unchecked_into(),
// 5CvRworpEZfn7FYeeXJmTHBVoEZvow3HRDxWCEZ5cN9dJKF6
hex!["036ce9ccdf3a1a4a6f5e65c44cd2453640ba4cee5a148e6362baa5d2129aed94fb"].unchecked_into(),
hex!["036ce9ccdf3a1a4a6f5e65c44cd2453640ba4cee5a148e6362baa5d2129aed94fb"]
.unchecked_into(),
// 5G9LtRirf1bVqaVChnZmCXmQ2f4dgFCdjDQsS1eA4sGSE8NS
hex!["b47a9211bf46832f093a29965082003d5b40c817cc678808bf177c879abbbc42"].unchecked_into(),

100 * OCTS

hex!["b47a9211bf46832f093a29965082003d5b40c817cc678808bf177c879abbbc42"]
.unchecked_into(),
100 * OCTS,
),
],
// Council Members
vec![
// 5HGtNjqdYQxn8mhBX22Z6HPjRSSmeb54zTTs3s798yyu4fk9
hex!["e6778539813675cb74a29d82d68ec7d9626430cf5818bc75da3af738c8a48666"].into(),
// 5G9LtRirf1bVqaVChnZmCXmQ2f4dgFCdjDQsS1eA4sGSE8NS
hex!["b47a9211bf46832f093a29965082003d5b40c817cc678808bf177c879abbbc42"].into()

hex!["b47a9211bf46832f093a29965082003d5b40c817cc678808bf177c879abbbc42"].into(),
],
// Tech Comitee Members
vec![],
// Pre-funded accounts
vec![
(
// 5FbjQgSg97nvPsfuf21D886B26mwtNvZTgEfGfWR6gdNy3Tx
hex!["9c5e883c0a7795c81d354aa2d596364e71f4bb07d047c8dcb67547fbe1114f12"].into(),
hex!["9c5e883c0a7795c81d354aa2d596364e71f4bb07d047c8dcb67547fbe1114f12"]
.into(),
// Balance amount
124_999_990 * UNET,
),
(
// 5HGtNjqdYQxn8mhBX22Z6HPjRSSmeb54zTTs3s798yyu4fk9
hex!["e6778539813675cb74a29d82d68ec7d9626430cf5818bc75da3af738c8a48666"].into(),
hex!["e6778539813675cb74a29d82d68ec7d9626430cf5818bc75da3af738c8a48666"]
.into(),
// Balance amount
10 * UNET,
),
(
// 5G9LtRirf1bVqaVChnZmCXmQ2f4dgFCdjDQsS1eA4sGSE8NS
hex!["b47a9211bf46832f093a29965082003d5b40c817cc678808bf177c879abbbc42"].into(),
hex!["b47a9211bf46832f093a29965082003d5b40c817cc678808bf177c879abbbc42"]
.into(),
// Balance amount
10 * UNET,
)
),
],
// Appchain config
appchain_config(
Expand Down Expand Up @@ -255,7 +270,7 @@ pub fn development_testnet_config() -> Result<ChainSpec, String> {
// Council Members
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob")
get_account_id_from_seed::<sr25519::Public>("Bob"),
],
// Tech Comitee Members
vec![],
Expand Down Expand Up @@ -330,7 +345,7 @@ pub fn local_config() -> Result<ChainSpec, String> {
// Council Members
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob")
get_account_id_from_seed::<sr25519::Public>("Bob"),
],
// Tech Comitee Members
vec![],
Expand Down Expand Up @@ -403,7 +418,7 @@ pub fn development_config() -> Result<ChainSpec, String> {
// Council Members
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob")
get_account_id_from_seed::<sr25519::Public>("Bob"),
],
// Tech Comitee Members
vec![],
Expand Down
2 changes: 1 addition & 1 deletion node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ pub enum Subcommand {
/// Try some command against runtime state. Note: `try-runtime` feature must be enabled.
#[cfg(not(feature = "try-runtime"))]
TryRuntime,
}
}
20 changes: 10 additions & 10 deletions node/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
mod chain_spec;
#[macro_use]
mod service;
mod cli;
mod command;
mod rpc;

fn main() -> sc_cli::Result<()> {
command::run()
}
mod chain_spec;
#[macro_use]
mod service;
mod cli;
mod command;
mod rpc;

fn main() -> sc_cli::Result<()> {
command::run()
}
8 changes: 4 additions & 4 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

use std::sync::Arc;

use uniqueone_appchain_runtime::{
opaque::Block, AccountId, Balance, BlockNumber, EthereumTransactionConverter, Hash, Index,
};
use sc_client_api::AuxStore;
use sc_consensus_babe::{Config, Epoch};
use sc_consensus_babe_rpc::BabeRpcHandler;
Expand All @@ -27,6 +24,9 @@ use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use sp_consensus::SelectChain;
use sp_consensus_babe::BabeApi;
use sp_keystore::SyncCryptoStorePtr;
use uniqueone_appchain_runtime::{
opaque::Block, AccountId, Balance, BlockNumber, EthereumTransactionConverter, Hash, Index,
};

use fc_rpc::{
EthBlockDataCacheTask, OverrideHandle, RuntimeApiStorageOverride, SchemaV1Override,
Expand Down Expand Up @@ -329,4 +329,4 @@ where
)));

Ok(io)
}
}
5 changes: 2 additions & 3 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ pub fn frontier_database_dir(config: &Configuration) -> std::path::PathBuf {
.as_ref()
.map(|base_path| base_path.config_dir(config.chain_spec.id()))
.unwrap_or_else(|| {
BasePath::from_project("", "", "uniqueone")
.config_dir(config.chain_spec.id())
BasePath::from_project("", "", "uniqueone").config_dir(config.chain_spec.id())
});
config_dir.join("frontier").join("db")
}
Expand Down Expand Up @@ -627,4 +626,4 @@ pub fn new_full_base(
/// Builds a new service for a full client.
pub fn new_full(config: Configuration, cli: &crate::cli::Cli) -> Result<TaskManager, ServiceError> {
new_full_base(config, cli, |_, _| ()).map(|NewFullBase { task_manager, .. }| task_manager)
}
}
16 changes: 11 additions & 5 deletions pallets/chain-extension/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ use frame_support::{
log::{error, trace},
traits::Randomness,
};
use unet_traits::{BitFlags, ClassId, ClassProperty, GlobalId, Properties, Signature, TokenId};
use pallet_contracts::chain_extension::{
ChainExtension, Environment, Ext, InitState, RetVal, SysConfig, UncheckedFrom,
};
use sp_runtime::{traits::Verify, AccountId32, DispatchError, PerU16};
use sp_std::vec::Vec;
use unet_traits::{BitFlags, ClassId, ClassProperty, GlobalId, Properties, Signature, TokenId};

pub struct UnetExtension<Runtime>(sp_std::marker::PhantomData<Runtime>);

Expand Down Expand Up @@ -58,8 +58,14 @@ where
let mut env = env.buf_in_buf_out();
let caller = env.ext().caller().clone();
let caller: <Runtime as SysConfig>::AccountId = to_account_id(caller.as_ref())?;
let (metadata, name, description, properties, royalty_rate, cate_ids): (_, _, _, u8, u16, Vec<GlobalId>) =
env.read_as_unbounded(env.in_len())?;
let (metadata, name, description, properties, royalty_rate, cate_ids): (
_,
_,
_,
u8,
u16,
Vec<GlobalId>,
) = env.read_as_unbounded(env.in_len())?;
let p = Properties(
<BitFlags<ClassProperty>>::from_bits(properties)
.map_err(|_| "invalid class properties value")?,
Expand Down Expand Up @@ -140,7 +146,7 @@ where

_ => {
error!("Called an unregistered `func_id`: {:}", func_id);
return Err(DispatchError::Other("Unimplemented func_id"))
return Err(DispatchError::Other("Unimplemented func_id"));
},
}
Ok(RetVal::Converging(0))
Expand All @@ -149,4 +155,4 @@ where
fn enabled() -> bool {
true
}
}
}
10 changes: 5 additions & 5 deletions pallets/ethereum-chain-id/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub mod pallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;

/// The Ethereum Chain Id Pallet
#[pallet::pallet]
pub struct Pallet<T>(PhantomData<T>);
Expand Down Expand Up @@ -64,11 +64,11 @@ pub mod pallet {
/// Allow Root account to change the Ethereum Chain Id
#[pallet::weight(0)]
pub fn set_chain_id(origin: OriginFor<T>, chain_id: u64) -> DispatchResult {
ensure_root(origin)?;
ensure_root(origin)?;

ChainId::<T>::put(chain_id);

Ok(())
}
Ok(())
}
}
}
}
Loading

0 comments on commit a83ea43

Please sign in to comment.