git.delta.rocks / unique-network / refs/commits / 890b4afabe76

difftreelog

Merge branch 'develop' into feature/CORE-324

Yaroslav Bolyukin2022-04-01parents: #4b84a72 #a961c1a.patch.diff
in: master

17 files changed

modified.envdiffbeforeafterboth
--- a/.env
+++ b/.env
@@ -1,6 +1,6 @@
 RUST_TOOLCHAIN=nightly-2021-11-11
 RUST_C=1.58.0-nightly
-POLKA_VERSION=release-v0.9.17
+POLKA_VERSION=release-v0.9.18
 UNIQUE_BRANCH=develop
 USER=***
 PASS=***
modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5575,7 +5575,7 @@
 
 [[package]]
 name = "opal-runtime"
-version = "0.1.0"
+version = "0.9.18"
 dependencies = [
  "cumulus-pallet-aura-ext",
  "cumulus-pallet-dmp-queue",
@@ -8709,7 +8709,7 @@
 
 [[package]]
 name = "quartz-runtime"
-version = "0.1.0"
+version = "0.9.18"
 dependencies = [
  "cumulus-pallet-aura-ext",
  "cumulus-pallet-dmp-queue",
@@ -8723,13 +8723,10 @@
  "fp-evm-mapping",
  "fp-rpc",
  "fp-self-contained",
- "frame-benchmarking",
  "frame-executive",
  "frame-support",
  "frame-system",
- "frame-system-benchmarking",
  "frame-system-rpc-runtime-api",
- "hex-literal",
  "orml-vesting",
  "pallet-aura",
  "pallet-balances",
@@ -12551,7 +12548,7 @@
 
 [[package]]
 name = "unique-runtime"
-version = "0.9.17"
+version = "0.9.18"
 dependencies = [
  "cumulus-pallet-aura-ext",
  "cumulus-pallet-dmp-queue",
@@ -12627,7 +12624,7 @@
 
 [[package]]
 name = "unique-runtime-common"
-version = "0.1.0"
+version = "0.9.18"
 dependencies = [
  "fp-rpc",
  "frame-support",
modifiedCargo.tomldiffbeforeafterboth
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,8 +5,11 @@
     'pallets/*',
     'client/*',
     'primitives/*',
-    'runtime/*',
     'crates/*',
 ]
+exclude = [
+    "runtime/unique",
+    "runtime/quartz"
+]
 [profile.release]
 panic = 'unwind'
modifiedDockerfile-parachaindiffbeforeafterboth
--- a/Dockerfile-parachain
+++ b/Dockerfile-parachain
@@ -1,5 +1,5 @@
 # ===== Rust builder =====
-FROM phusion/baseimage:focal-1.0.0 as rust-builder
+FROM phusion/baseimage:focal-1.1.0 as rust-builder
 LABEL maintainer="Unique.Network"
 
 ARG RUST_TOOLCHAIN=nightly-2021-11-11
@@ -77,7 +77,7 @@
 
 # ===== RUN ======
 
-FROM phusion/baseimage:focal-1.0.0
+FROM phusion/baseimage:focal-1.1.0
 
 ARG PROFILE=release
 
modifiedREADME.mddiffbeforeafterboth
--- a/README.md
+++ b/README.md
@@ -63,12 +63,7 @@
 
 5. Build:
 ```bash
-cargo build
-```
-
-optionally, build in release:
-```bash
-cargo build --release
+cargo build --features=unique-runtime,quartz-runtime --release
 ```
 
 ## Building as Parachain locally
modifiednode/cli/Cargo.tomldiffbeforeafterboth
--- a/node/cli/Cargo.toml
+++ b/node/cli/Cargo.toml
@@ -312,7 +312,7 @@
 unique-rpc = { default-features = false, path = "../rpc" }
 
 [features]
-default = ["unique-runtime", "quartz-runtime"]
+default = []
 runtime-benchmarks = [
     'unique-runtime/runtime-benchmarks',
     'polkadot-service/runtime-benchmarks',
modifiednode/cli/src/chain_spec.rsdiffbeforeafterboth
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
1616
17use cumulus_primitives_core::ParaId;
18use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};17use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
19use sc_service::ChainType;18use sc_service::ChainType;
20use sp_core::{sr25519, Pair, Public};19use sp_core::{sr25519, Pair, Public};
2625
27use unique_runtime_common::types::*;26use unique_runtime_common::types::*;
27
28#[cfg(feature = "unique-runtime")]
29use unique_runtime as default_runtime;
30
31#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]
32use quartz_runtime as default_runtime;
33
34#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]
35use opal_runtime as default_runtime;
2836
29/// The `ChainSpec` parameterized for the unique runtime.37/// The `ChainSpec` parameterized for the unique runtime.
30#[cfg(feature = "unique-runtime")]38#[cfg(feature = "unique-runtime")]
37/// The `ChainSpec` parameterized for the opal runtime.45/// The `ChainSpec` parameterized for the opal runtime.
38pub type OpalChainSpec = sc_service::GenericChainSpec<opal_runtime::GenesisConfig, Extensions>;46pub type OpalChainSpec = sc_service::GenericChainSpec<opal_runtime::GenesisConfig, Extensions>;
47
48#[cfg(feature = "unique-runtime")]
49pub type DefaultChainSpec = UniqueChainSpec;
50
51#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]
52pub type DefaultChainSpec = QuartzChainSpec;
53
54#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]
55pub type DefaultChainSpec = OpalChainSpec;
3956
40pub enum RuntimeId {57pub enum RuntimeId {
58 #[cfg(feature = "unique-runtime")]
41 Unique,59 Unique,
60
61 #[cfg(feature = "quartz-runtime")]
42 Quartz,62 Quartz,
63
43 Opal,64 Opal,
51impl RuntimeIdentification for Box<dyn sc_service::ChainSpec> {72impl RuntimeIdentification for Box<dyn sc_service::ChainSpec> {
52 fn runtime_id(&self) -> RuntimeId {73 fn runtime_id(&self) -> RuntimeId {
53 #[cfg(feature = "unique-runtime")]74 #[cfg(feature = "unique-runtime")]
54 if self.id().starts_with("unique") {75 if self.id().starts_with("unique") || self.id().starts_with("unq") {
55 return RuntimeId::Unique;76 return RuntimeId::Unique;
56 }77 }
5778
58 #[cfg(feature = "quartz-runtime")]79 #[cfg(feature = "quartz-runtime")]
59 if self.id().starts_with("quartz") {80 if self.id().starts_with("quartz") || self.id().starts_with("qtz") {
60 return RuntimeId::Quartz;81 return RuntimeId::Quartz;
61 }82 }
6283
121 AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()142 AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
122}143}
144
145macro_rules! testnet_genesis {
146 (
147 $runtime:path,
148 $root_key:expr,
149 $initial_authorities:expr,
150 $endowed_accounts:expr,
151 $id:expr
152 ) => {{
153 use $runtime::*;
154
155 GenesisConfig {
156 system: SystemConfig {
157 code: WASM_BINARY
158 .expect("WASM binary was not build, please build it!")
159 .to_vec(),
160 },
161 balances: BalancesConfig {
162 balances: $endowed_accounts
163 .iter()
164 .cloned()
165 // 1e13 UNQ
166 .map(|k| (k, 1 << 100))
167 .collect(),
168 },
169 treasury: Default::default(),
170 sudo: SudoConfig {
171 key: Some($root_key),
172 },
173 vesting: VestingConfig { vesting: vec![] },
174 parachain_info: ParachainInfoConfig {
175 parachain_id: $id.into(),
176 },
177 parachain_system: Default::default(),
178 aura: AuraConfig {
179 authorities: $initial_authorities,
180 },
181 aura_ext: Default::default(),
182 evm: EVMConfig {
183 accounts: BTreeMap::new(),
184 },
185 ethereum: EthereumConfig {},
186 }
187 }};
188}
123189
124pub fn development_config() -> OpalChainSpec {190pub fn development_config() -> OpalChainSpec {
125 let mut properties = Map::new();191 let mut properties = Map::new();
126 properties.insert("tokenSymbol".into(), "OPL".into());192 properties.insert("tokenSymbol".into(), opal_runtime::TOKEN_SYMBOL.into());
127 properties.insert("tokenDecimals".into(), 15.into());193 properties.insert("tokenDecimals".into(), 18.into());
128 properties.insert("ss58Format".into(), 42.into());194 properties.insert("ss58Format".into(), opal_runtime::SS58Prefix::get().into());
129195
130 OpalChainSpec::from_genesis(196 OpalChainSpec::from_genesis(
131 // Name197 // Name
132 "Development",198 "OPAL by UNIQUE",
133 // ID199 // ID
134 "dev",200 "opal_dev",
135 ChainType::Local,201 ChainType::Local,
136 move || {202 move || {
137 testnet_genesis(203 testnet_genesis!(
204 opal_runtime,
138 // Sudo account205 // Sudo account
139 get_account_id_from_seed::<sr25519::Public>("Alice"),206 get_account_id_from_seed::<sr25519::Public>("Alice"),
140 vec![207 vec![
141 get_from_seed::<AuraId>("Alice"),208 get_from_seed::<AuraId>("Alice"),
142 get_from_seed::<AuraId>("Bob"),209 get_from_seed::<AuraId>("Bob"),
146 get_account_id_from_seed::<sr25519::Public>("Alice"),213 get_account_id_from_seed::<sr25519::Public>("Alice"),
147 get_account_id_from_seed::<sr25519::Public>("Bob"),214 get_account_id_from_seed::<sr25519::Public>("Bob"),
148 ],215 ],
149 1000.into(),216 1000
150 )217 )
151 },218 },
152 // Bootnodes219 // Bootnodes
166 )233 )
167}234}
168235
169pub fn local_testnet_rococo_config() -> OpalChainSpec {236pub fn local_testnet_rococo_config() -> DefaultChainSpec {
237 let mut properties = Map::new();
238 properties.insert("tokenSymbol".into(), default_runtime::TOKEN_SYMBOL.into());
239 properties.insert("tokenDecimals".into(), 18.into());
240 properties.insert(
241 "ss58Format".into(),
242 default_runtime::SS58Prefix::get().into(),
243 );
244
170 OpalChainSpec::from_genesis(245 DefaultChainSpec::from_genesis(
171 // Name246 // Name
247 format!(
248 "{}{}",
249 default_runtime::RUNTIME_NAME.to_uppercase(),
250 if cfg!(feature = "unique-runtime") {
251 ""
252 } else {
253 " by UNIQUE"
254 }
255 )
172 "Local Testnet",256 .as_str(),
173 // ID257 // ID
174 "local_testnet",258 format!("{}_local", default_runtime::RUNTIME_NAME).as_str(),
175 ChainType::Local,259 ChainType::Local,
176 move || {260 move || {
177 testnet_genesis(261 testnet_genesis!(
262 default_runtime,
178 // Sudo account263 // Sudo account
179 get_account_id_from_seed::<sr25519::Public>("Alice"),264 get_account_id_from_seed::<sr25519::Public>("Alice"),
180 vec![265 vec![
181 get_from_seed::<AuraId>("Alice"),266 get_from_seed::<AuraId>("Alice"),
182 get_from_seed::<AuraId>("Bob"),267 get_from_seed::<AuraId>("Bob"),
196 get_account_id_from_seed::<sr25519::Public>("Eve//stash"),281 get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
197 get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),282 get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
198 ],283 ],
199 1000.into(),284 1000
200 )285 )
201 },286 },
202 // Bootnodes287 // Bootnodes
207 None,292 None,
208 None,293 None,
209 // Properties294 // Properties
210 None,295 Some(properties),
211 // Extensions296 // Extensions
212 Extensions {297 Extensions {
213 relay_chain: "rococo-local".into(),298 relay_chain: "rococo-local".into(),
216 )301 )
217}302}
218
219fn testnet_genesis(
220 root_key: AccountId,
221 initial_authorities: Vec<AuraId>,
222 endowed_accounts: Vec<AccountId>,
223 id: ParaId,
224) -> opal_runtime::GenesisConfig {
225 use opal_runtime::*;
226
227 GenesisConfig {
228 system: SystemConfig {
229 code: WASM_BINARY
230 .expect("WASM binary was not build, please build it!")
231 .to_vec(),
232 },
233 balances: BalancesConfig {
234 balances: endowed_accounts
235 .iter()
236 .cloned()
237 // 1e13 UNQ
238 .map(|k| (k, 1 << 100))
239 .collect(),
240 },
241 treasury: Default::default(),
242 sudo: SudoConfig {
243 key: Some(root_key),
244 },
245 vesting: VestingConfig { vesting: vec![] },
246 parachain_info: ParachainInfoConfig { parachain_id: id },
247 parachain_system: Default::default(),
248 aura: AuraConfig {
249 authorities: initial_authorities,
250 },
251 aura_ext: Default::default(),
252 evm: EVMConfig {
253 accounts: BTreeMap::new(),
254 },
255 ethereum: EthereumConfig {},
256 }
257}
258303
modifiednode/cli/src/service.rsdiffbeforeafterboth
--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -61,9 +61,16 @@
 
 use unique_runtime_common::types::{AuraId, RuntimeInstance, AccountId, Balance, Index, Hash, Block};
 
-/// Native executor instance.
+/// Unique native executor instance.
+#[cfg(feature = "unique-runtime")]
 pub struct UniqueRuntimeExecutor;
+
+#[cfg(feature = "quartz-runtime")]
+/// Quartz native executor instance.
+
 pub struct QuartzRuntimeExecutor;
+
+/// Opal native executor instance.
 pub struct OpalRuntimeExecutor;
 
 #[cfg(feature = "unique-runtime")]
modifiedpallets/unique/src/eth/sponsoring.rsdiffbeforeafterboth
--- a/pallets/unique/src/eth/sponsoring.rs
+++ b/pallets/unique/src/eth/sponsoring.rs
@@ -24,12 +24,13 @@
 use up_sponsorship::SponsorshipHandler;
 use core::marker::PhantomData;
 use core::convert::TryInto;
-use up_data_structs::TokenId;
 use pallet_evm::account::CrossAccountId;
 
-use pallet_nonfungible::erc::{UniqueNFTCall, ERC721UniqueExtensionsCall, ERC721Call};
+use pallet_nonfungible::erc::{
+	UniqueNFTCall, ERC721UniqueExtensionsCall, ERC721MintableCall, ERC721Call,
+};
 use pallet_fungible::erc::{UniqueFungibleCall, ERC20Call};
-use up_data_structs::{CreateItemData, CreateNftData};
+use up_data_structs::{TokenId, CreateItemData, CreateNftData};
 
 pub struct UniqueEthSponsorshipHandler<T: Config>(PhantomData<*const T>);
 impl<T: Config> SponsorshipHandler<T::CrossAccountId, (H160, Vec<u8>)>
@@ -50,6 +51,18 @@
 						let token_id: TokenId = token_id.try_into().ok()?;
 						withdraw_transfer::<T>(&collection, &who, &token_id).map(|()| sponsor)
 					}
+					UniqueNFTCall::ERC721Mintable(
+						ERC721MintableCall::Mint { token_id, .. }
+						| ERC721MintableCall::MintWithTokenUri { token_id, .. },
+					) => {
+						let _token_id: TokenId = token_id.try_into().ok()?;
+						withdraw_create_item::<T>(
+							&collection,
+							&who,
+							&CreateItemData::NFT(CreateNftData::default()),
+						)
+						.map(|()| sponsor)
+					}
 					UniqueNFTCall::ERC721(ERC721Call::TransferFrom { token_id, from, .. }) => {
 						let token_id: TokenId = token_id.try_into().ok()?;
 						let from = T::CrossAccountId::from_eth(from);
@@ -60,18 +73,6 @@
 						withdraw_approve::<T>(&collection, who.as_sub(), &token_id)
 							.map(|()| sponsor)
 					}
-					UniqueNFTCall::ERC721Mintable(call) => match call {
-						pallet_nonfungible::erc::ERC721MintableCall::Mint { .. }
-						| pallet_nonfungible::erc::ERC721MintableCall::MintWithTokenUri {
-							..
-						} => withdraw_create_item(
-							&collection,
-							who.as_sub(),
-							&CreateItemData::NFT(CreateNftData::default()),
-						)
-						.map(|()| sponsor),
-						_ => None,
-					},
 					_ => None,
 				}
 			}
modifiedpallets/unique/src/sponsorship.rsdiffbeforeafterboth
--- a/pallets/unique/src/sponsorship.rs
+++ b/pallets/unique/src/sponsorship.rs
@@ -103,7 +103,7 @@
 
 pub fn withdraw_create_item<T: Config>(
 	collection: &CollectionHandle<T>,
-	who: &T::AccountId,
+	who: &T::CrossAccountId,
 	_properties: &CreateItemData,
 ) -> Option<()> {
 	if _properties.data_size() as u32 > collection.limits.sponsored_data_size() {
@@ -120,14 +120,14 @@
 			CreateItemData::ReFungible(_) => REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,
 		});
 
-	if let Some(last_tx_block) = <CreateItemBasket<T>>::get((collection.id, &who)) {
+	if let Some(last_tx_block) = <CreateItemBasket<T>>::get((collection.id, who.as_sub())) {
 		let timeout = last_tx_block + limit.into();
 		if block_number < timeout {
 			return None;
 		}
 	}
 
-	CreateItemBasket::<T>::insert((collection.id, who.clone()), block_number);
+	CreateItemBasket::<T>::insert((collection.id, who.as_sub()), block_number);
 
 	Some(())
 }
@@ -246,7 +246,12 @@
 				..
 			} => {
 				let (sponsor, collection) = load(*collection_id)?;
-				withdraw_create_item::<T>(&collection, who, data).map(|()| sponsor)
+				withdraw_create_item::<T>(
+					&collection,
+					&T::CrossAccountId::from_sub(who.clone()),
+					data,
+				)
+				.map(|()| sponsor)
 			}
 			Call::transfer {
 				collection_id,
modifiedruntime/common/Cargo.tomldiffbeforeafterboth
--- a/runtime/common/Cargo.toml
+++ b/runtime/common/Cargo.toml
@@ -6,7 +6,7 @@
 license = 'All Rights Reserved'
 name = 'unique-runtime-common'
 repository = 'https://github.com/UniqueNetwork/unique-chain'
-version = '0.1.0'
+version = '0.9.18'
 
 [features]
 default = ['std']
modifiedruntime/opal/Cargo.tomldiffbeforeafterboth
--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -10,7 +10,7 @@
 license = 'GPLv3'
 name = 'opal-runtime'
 repository = 'https://github.com/UniqueNetwork/unique-chain'
-version = '0.1.0'
+version = '0.9.18'
 
 [package.metadata.docs.rs]
 targets = ['x86_64-unknown-linux-gnu']
modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
--- a/runtime/opal/src/lib.rs
+++ b/runtime/opal/src/lib.rs
@@ -116,7 +116,8 @@
 
 use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};
 
-pub const RUNTIME_NAME: &str = "Opal";
+pub const RUNTIME_NAME: &str = "opal";
+pub const TOKEN_SYMBOL: &str = "OPL";
 
 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;
 
@@ -168,7 +169,7 @@
 	spec_name: create_runtime_str!(RUNTIME_NAME),
 	impl_name: create_runtime_str!(RUNTIME_NAME),
 	authoring_version: 1,
-	spec_version: 917004,
+	spec_version: 918001,
 	impl_version: 0,
 	apis: RUNTIME_API_VERSIONS,
 	transaction_version: 1,
modifiedruntime/quartz/Cargo.tomldiffbeforeafterboth
--- a/runtime/quartz/Cargo.toml
+++ b/runtime/quartz/Cargo.toml
@@ -10,7 +10,7 @@
 license = 'GPLv3'
 name = 'quartz-runtime'
 repository = 'https://github.com/UniqueNetwork/unique-chain'
-version = '0.1.0'
+version = '0.9.18'
 
 [package.metadata.docs.rs]
 targets = ['x86_64-unknown-linux-gnu']
modifiedruntime/quartz/src/lib.rsdiffbeforeafterboth
--- a/runtime/quartz/src/lib.rs
+++ b/runtime/quartz/src/lib.rs
@@ -116,7 +116,8 @@
 
 use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};
 
-pub const RUNTIME_NAME: &str = "Quartz";
+pub const RUNTIME_NAME: &str = "quartz";
+pub const TOKEN_SYMBOL: &str = "QTZ";
 
 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;
 
@@ -153,7 +154,7 @@
 	spec_name: create_runtime_str!(RUNTIME_NAME),
 	impl_name: create_runtime_str!(RUNTIME_NAME),
 	authoring_version: 1,
-	spec_version: 917004,
+	spec_version: 918001,
 	impl_version: 0,
 	apis: RUNTIME_API_VERSIONS,
 	transaction_version: 1,
modifiedruntime/unique/Cargo.tomldiffbeforeafterboth
--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -10,7 +10,7 @@
 license = 'GPLv3'
 name = 'unique-runtime'
 repository = 'https://github.com/UniqueNetwork/unique-chain'
-version = '0.9.17'
+version = '0.9.18'
 
 [package.metadata.docs.rs]
 targets = ['x86_64-unknown-linux-gnu']
modifiedruntime/unique/src/lib.rsdiffbeforeafterboth
--- a/runtime/unique/src/lib.rs
+++ b/runtime/unique/src/lib.rs
@@ -115,7 +115,8 @@
 
 use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};
 
-pub const RUNTIME_NAME: &str = "Unique";
+pub const RUNTIME_NAME: &str = "unique";
+pub const TOKEN_SYMBOL: &str = "UNQ";
 
 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;
 
@@ -152,7 +153,7 @@
 	spec_name: create_runtime_str!(RUNTIME_NAME),
 	impl_name: create_runtime_str!(RUNTIME_NAME),
 	authoring_version: 1,
-	spec_version: 917004,
+	spec_version: 918001,
 	impl_version: 0,
 	apis: RUNTIME_API_VERSIONS,
 	transaction_version: 1,