git.delta.rocks / unique-network / refs/commits / e83438b2f76b

difftreelog

Merge pull request #330 from UniqueNetwork/release-v918001

kozyrevdev2022-03-31parents: #8691db9 #bbc0e86.patch.diff
in: master
Release v918001

9 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -8706,13 +8706,10 @@
  "derivative",
  "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",
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
 
modifiednode/cli/src/chain_spec.rsdiffbeforeafterboth
before · node/cli/src/chain_spec.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};18use sc_service::ChainType;19use sp_core::{sr25519, Pair, Public};20use sp_runtime::traits::{IdentifyAccount, Verify};21use std::collections::BTreeMap;2223use serde::{Deserialize, Serialize};24use serde_json::map::Map;2526use unique_runtime_common::types::*;2728#[cfg(feature = "unique-runtime")]29use unique_runtime as default_runtime;3031#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]32use quartz_runtime as default_runtime;3334#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]35use opal_runtime as default_runtime;3637/// The `ChainSpec` parameterized for the unique runtime.38#[cfg(feature = "unique-runtime")]39pub type UniqueChainSpec = sc_service::GenericChainSpec<unique_runtime::GenesisConfig, Extensions>;4041/// The `ChainSpec` parameterized for the quartz runtime.42#[cfg(feature = "quartz-runtime")]43pub type QuartzChainSpec = sc_service::GenericChainSpec<quartz_runtime::GenesisConfig, Extensions>;4445/// The `ChainSpec` parameterized for the opal runtime.46pub type OpalChainSpec = sc_service::GenericChainSpec<opal_runtime::GenesisConfig, Extensions>;4748#[cfg(feature = "unique-runtime")]49pub type DefaultChainSpec = UniqueChainSpec;5051#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]52pub type DefaultChainSpec = QuartzChainSpec;5354#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]55pub type DefaultChainSpec = OpalChainSpec;5657pub enum RuntimeId {58	#[cfg(feature = "unique-runtime")]59	Unique,6061	#[cfg(feature = "quartz-runtime")]62	Quartz,6364	Opal,65	Unknown(String),66}6768pub trait RuntimeIdentification {69	fn runtime_id(&self) -> RuntimeId;70}7172impl RuntimeIdentification for Box<dyn sc_service::ChainSpec> {73	fn runtime_id(&self) -> RuntimeId {74		#[cfg(feature = "unique-runtime")]75		if self.id().starts_with("unique") {76			return RuntimeId::Unique;77		}7879		#[cfg(feature = "quartz-runtime")]80		if self.id().starts_with("quartz") {81			return RuntimeId::Quartz;82		}8384		if self.id().starts_with("opal") || self.id() == "dev" || self.id() == "local_testnet" {85			return RuntimeId::Opal;86		}8788		RuntimeId::Unknown(self.id().into())89	}90}9192pub enum ServiceId {93	Prod,94	Dev,95}9697pub trait ServiceIdentification {98	fn service_id(&self) -> ServiceId;99}100101impl ServiceIdentification for Box<dyn sc_service::ChainSpec> {102	fn service_id(&self) -> ServiceId {103		if self.id().ends_with("dev") {104			ServiceId::Dev105		} else {106			ServiceId::Prod107		}108	}109}110111/// Helper function to generate a crypto pair from seed112pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {113	TPublic::Pair::from_string(&format!("//{}", seed), None)114		.expect("static values are valid; qed")115		.public()116}117118/// The extensions for the [`ChainSpec`].119#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)]120#[serde(deny_unknown_fields)]121pub struct Extensions {122	/// The relay chain of the Parachain.123	pub relay_chain: String,124	/// The id of the Parachain.125	pub para_id: u32,126}127128impl Extensions {129	/// Try to get the extension from the given `ChainSpec`.130	pub fn try_get(chain_spec: &dyn sc_service::ChainSpec) -> Option<&Self> {131		sc_chain_spec::get_extension(chain_spec.extensions())132	}133}134135type AccountPublic = <Signature as Verify>::Signer;136137/// Helper function to generate an account ID from seed138pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId139where140	AccountPublic: From<<TPublic::Pair as Pair>::Public>,141{142	AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()143}144145macro_rules! testnet_genesis {146	(147		$runtime:path,148		$root_key:expr,149		$initial_authorities:expr,150		$endowed_accounts:expr,151		$id:expr152	) => {{153		use $runtime::*;154155		GenesisConfig {156			system: SystemConfig {157				code: WASM_BINARY158					.expect("WASM binary was not build, please build it!")159					.to_vec(),160			},161			balances: BalancesConfig {162				balances: $endowed_accounts163					.iter()164					.cloned()165					// 1e13 UNQ166					.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}189190pub fn development_config() -> OpalChainSpec {191	let mut properties = Map::new();192	properties.insert("tokenSymbol".into(), opal_runtime::TOKEN_SYMBOL.into());193	properties.insert("tokenDecimals".into(), 18.into());194	properties.insert("ss58Format".into(), opal_runtime::SS58Prefix::get().into());195196	OpalChainSpec::from_genesis(197		// Name198		"OPAL by UNIQUE",199		// ID200		"opal_dev",201		ChainType::Local,202		move || {203			testnet_genesis!(204				opal_runtime,205				// Sudo account206				get_account_id_from_seed::<sr25519::Public>("Alice"),207				vec![208					get_from_seed::<AuraId>("Alice"),209					get_from_seed::<AuraId>("Bob"),210				],211				// Pre-funded accounts212				vec![213					get_account_id_from_seed::<sr25519::Public>("Alice"),214					get_account_id_from_seed::<sr25519::Public>("Bob"),215				],216				1000217			)218		},219		// Bootnodes220		vec![],221		// Telemetry222		None,223		// Protocol ID224		None,225		None,226		// Properties227		Some(properties),228		// Extensions229		Extensions {230			relay_chain: "rococo-dev".into(),231			para_id: 1000,232		},233	)234}235236pub 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	);244245	DefaultChainSpec::from_genesis(246		// Name247		format!(248			"{}{}",249			default_runtime::RUNTIME_NAME.to_uppercase(),250			if cfg!(feature = "unique-runtime") {251				""252			} else {253				" by UNIQUE"254			}255		)256		.as_str(),257		// ID258		format!("{}_local", default_runtime::RUNTIME_NAME).as_str(),259		ChainType::Local,260		move || {261			testnet_genesis!(262				default_runtime,263				// Sudo account264				get_account_id_from_seed::<sr25519::Public>("Alice"),265				vec![266					get_from_seed::<AuraId>("Alice"),267					get_from_seed::<AuraId>("Bob"),268				],269				// Pre-funded accounts270				vec![271					get_account_id_from_seed::<sr25519::Public>("Alice"),272					get_account_id_from_seed::<sr25519::Public>("Bob"),273					get_account_id_from_seed::<sr25519::Public>("Charlie"),274					get_account_id_from_seed::<sr25519::Public>("Dave"),275					get_account_id_from_seed::<sr25519::Public>("Eve"),276					get_account_id_from_seed::<sr25519::Public>("Ferdie"),277					get_account_id_from_seed::<sr25519::Public>("Alice//stash"),278					get_account_id_from_seed::<sr25519::Public>("Bob//stash"),279					get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),280					get_account_id_from_seed::<sr25519::Public>("Dave//stash"),281					get_account_id_from_seed::<sr25519::Public>("Eve//stash"),282					get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),283				],284				1000285			)286		},287		// Bootnodes288		vec![],289		// Telemetry290		None,291		// Protocol ID292		None,293		None,294		// Properties295		Some(properties),296		// Extensions297		Extensions {298			relay_chain: "rococo-local".into(),299			para_id: 1000,300		},301	)302}
modifiedpallets/unique/src/eth/sponsoring.rsdiffbeforeafterboth
--- a/pallets/unique/src/eth/sponsoring.rs
+++ b/pallets/unique/src/eth/sponsoring.rs
@@ -24,11 +24,13 @@
 use up_sponsorship::SponsorshipHandler;
 use core::marker::PhantomData;
 use core::convert::TryInto;
-use up_data_structs::TokenId;
+use up_data_structs::{TokenId, CreateItemData, CreateNftData};
 use up_evm_mapping::EvmBackwardsAddressMapping;
 use pallet_common::account::CrossAccountId;
 
-use pallet_nonfungible::erc::{UniqueNFTCall, ERC721UniqueExtensionsCall, ERC721Call};
+use pallet_nonfungible::erc::{
+	UniqueNFTCall, ERC721UniqueExtensionsCall, ERC721MintableCall, ERC721Call,
+};
 use pallet_fungible::erc::{UniqueFungibleCall, ERC20Call};
 
 pub struct UniqueEthSponsorshipHandler<T: Config>(PhantomData<*const T>);
@@ -51,6 +53,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);
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/opal/src/lib.rsdiffbeforeafterboth
--- a/runtime/opal/src/lib.rs
+++ b/runtime/opal/src/lib.rs
@@ -152,7 +152,7 @@
 	spec_name: create_runtime_str!(RUNTIME_NAME),
 	impl_name: create_runtime_str!(RUNTIME_NAME),
 	authoring_version: 1,
-	spec_version: 918000,
+	spec_version: 918001,
 	impl_version: 0,
 	apis: RUNTIME_API_VERSIONS,
 	transaction_version: 1,
modifiedruntime/quartz/src/lib.rsdiffbeforeafterboth
--- a/runtime/quartz/src/lib.rs
+++ b/runtime/quartz/src/lib.rs
@@ -152,7 +152,7 @@
 	spec_name: create_runtime_str!(RUNTIME_NAME),
 	impl_name: create_runtime_str!(RUNTIME_NAME),
 	authoring_version: 1,
-	spec_version: 918000,
+	spec_version: 918001,
 	impl_version: 0,
 	apis: RUNTIME_API_VERSIONS,
 	transaction_version: 1,
modifiedruntime/unique/src/lib.rsdiffbeforeafterboth
--- a/runtime/unique/src/lib.rs
+++ b/runtime/unique/src/lib.rs
@@ -151,7 +151,7 @@
 	spec_name: create_runtime_str!(RUNTIME_NAME),
 	impl_name: create_runtime_str!(RUNTIME_NAME),
 	authoring_version: 1,
-	spec_version: 918000,
+	spec_version: 918001,
 	impl_version: 0,
 	apis: RUNTIME_API_VERSIONS,
 	transaction_version: 1,