difftreelog
Merge branch 'master' into release-v922000
in: master
9 files changed
README.mddiffbeforeafterboth--- a/README.md
+++ b/README.md
@@ -62,8 +62,18 @@
```
5. Build:
+
+Opal
+```bash
+cargo build --release
+```
+Quartz
+```bash
+cargo build --features=quartz-runtime --release
+```
+Unique
```bash
-cargo build --features=unique-runtime,quartz-runtime --release
+cargo build --features=unique-runtime --release
```
## Building as Parachain locally
@@ -155,13 +165,13 @@
location:
V0(X2(Parent, Parachain(PARA_ID)))
metadata:
- name OPL
- symbol OPL
+ name QTZ
+ symbol QTZ
decimals 18
minimalBalance 1
```
-### Next, we can send tokens from Opal to Karura:
+### Next, we can send tokens from Quartz to Karura:
```
polkadotXcm -> reserveTransferAssets
dest:
@@ -179,7 +189,7 @@
The result will be displayed in ChainState
tokens -> accounts
-### To send tokens from Karura to Opal:
+### To send tokens from Karura to Quartz:
```
xtokens -> transfer
client/rpc/src/lib.rsdiffbeforeafterboth1// 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 std::sync::Arc;1819use codec::{Decode, Encode};20use jsonrpsee::{21 core::{RpcResult as Result},22 proc_macros::rpc,23};24use anyhow::anyhow;25use up_data_structs::{26 RpcCollection, CollectionId, CollectionStats, CollectionLimits, TokenId, Property,27 PropertyKeyPermission, TokenData,28};29use sp_api::{BlockId, BlockT, ProvideRuntimeApi, ApiExt};30use sp_blockchain::HeaderBackend;31use up_rpc::UniqueApi as UniqueRuntimeApi;3233// RMRK34use rmrk_rpc::RmrkApi as RmrkRuntimeApi;35use up_data_structs::{36 RmrkCollectionId, RmrkNftId, RmrkBaseId, RmrkNftChild, RmrkThemeName, RmrkResourceId,37};3839pub use rmrk_unique_rpc::RmrkApiServer;4041#[rpc(server)]42#[async_trait]43pub trait UniqueApi<BlockHash, CrossAccountId, AccountId> {44 #[method(name = "unique_accountTokens")]45 fn account_tokens(46 &self,47 collection: CollectionId,48 account: CrossAccountId,49 at: Option<BlockHash>,50 ) -> Result<Vec<TokenId>>;51 #[method(name = "unique_collectionTokens")]52 fn collection_tokens(53 &self,54 collection: CollectionId,55 at: Option<BlockHash>,56 ) -> Result<Vec<TokenId>>;57 #[method(name = "unique_tokenExists")]58 fn token_exists(59 &self,60 collection: CollectionId,61 token: TokenId,62 at: Option<BlockHash>,63 ) -> Result<bool>;6465 #[method(name = "unique_tokenOwner")]66 fn token_owner(67 &self,68 collection: CollectionId,69 token: TokenId,70 at: Option<BlockHash>,71 ) -> Result<Option<CrossAccountId>>;72 #[method(name = "unique_topmostTokenOwner")]73 fn topmost_token_owner(74 &self,75 collection: CollectionId,76 token: TokenId,77 at: Option<BlockHash>,78 ) -> Result<Option<CrossAccountId>>;7980 #[method(name = "unique_collectionProperties")]81 fn collection_properties(82 &self,83 collection: CollectionId,84 keys: Option<Vec<String>>,85 at: Option<BlockHash>,86 ) -> Result<Vec<Property>>;8788 #[method(name = "unique_tokenProperties")]89 fn token_properties(90 &self,91 collection: CollectionId,92 token_id: TokenId,93 keys: Option<Vec<String>>,94 at: Option<BlockHash>,95 ) -> Result<Vec<Property>>;9697 #[method(name = "unique_propertyPermissions")]98 fn property_permissions(99 &self,100 collection: CollectionId,101 keys: Option<Vec<String>>,102 at: Option<BlockHash>,103 ) -> Result<Vec<PropertyKeyPermission>>;104105 #[method(name = "unique_tokenData")]106 fn token_data(107 &self,108 collection: CollectionId,109 token_id: TokenId,110 keys: Option<Vec<String>>,111 at: Option<BlockHash>,112 ) -> Result<TokenData<CrossAccountId>>;113114 #[method(name = "unique_totalSupply")]115 fn total_supply(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<u32>;116 #[method(name = "unique_accountBalance")]117 fn account_balance(118 &self,119 collection: CollectionId,120 account: CrossAccountId,121 at: Option<BlockHash>,122 ) -> Result<u32>;123 #[method(name = "unique_balance")]124 fn balance(125 &self,126 collection: CollectionId,127 account: CrossAccountId,128 token: TokenId,129 at: Option<BlockHash>,130 ) -> Result<String>;131 #[method(name = "unique_allowance")]132 fn allowance(133 &self,134 collection: CollectionId,135 sender: CrossAccountId,136 spender: CrossAccountId,137 token: TokenId,138 at: Option<BlockHash>,139 ) -> Result<String>;140141 #[method(name = "unique_adminlist")]142 fn adminlist(143 &self,144 collection: CollectionId,145 at: Option<BlockHash>,146 ) -> Result<Vec<CrossAccountId>>;147 #[method(name = "unique_allowlist")]148 fn allowlist(149 &self,150 collection: CollectionId,151 at: Option<BlockHash>,152 ) -> Result<Vec<CrossAccountId>>;153 #[method(name = "unique_allowed")]154 fn allowed(155 &self,156 collection: CollectionId,157 user: CrossAccountId,158 at: Option<BlockHash>,159 ) -> Result<bool>;160 #[method(name = "unique_lastTokenId")]161 fn last_token_id(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<TokenId>;162 #[method(name = "unique_collectionById")]163 fn collection_by_id(164 &self,165 collection: CollectionId,166 at: Option<BlockHash>,167 ) -> Result<Option<RpcCollection<AccountId>>>;168 #[method(name = "unique_collectionStats")]169 fn collection_stats(&self, at: Option<BlockHash>) -> Result<CollectionStats>;170171 #[method(name = "unique_nextSponsored")]172 fn next_sponsored(173 &self,174 collection: CollectionId,175 account: CrossAccountId,176 token: TokenId,177 at: Option<BlockHash>,178 ) -> Result<Option<u64>>;179 #[method(name = "unique_effectiveCollectionLimits")]180 fn effective_collection_limits(181 &self,182 collection_id: CollectionId,183 at: Option<BlockHash>,184 ) -> Result<Option<CollectionLimits>>;185}186187mod rmrk_unique_rpc {188 use super::*;189190 #[rpc(server)]191 #[async_trait]192 pub trait RmrkApi<193 BlockHash,194 AccountId,195 CollectionInfo,196 NftInfo,197 ResourceInfo,198 PropertyInfo,199 BaseInfo,200 PartType,201 Theme,202 >203 {204 #[method(name = "rmrk_lastCollectionIdx")]205 /// Get the latest created collection id206 fn last_collection_idx(&self, at: Option<BlockHash>) -> Result<RmrkCollectionId>;207208 #[method(name = "rmrk_collectionById")]209 /// Get collection by id210 fn collection_by_id(211 &self,212 id: RmrkCollectionId,213 at: Option<BlockHash>,214 ) -> Result<Option<CollectionInfo>>;215216 #[method(name = "rmrk_nftById")]217 /// Get NFT by collection id and NFT id218 fn nft_by_id(219 &self,220 collection_id: RmrkCollectionId,221 nft_id: RmrkNftId,222 at: Option<BlockHash>,223 ) -> Result<Option<NftInfo>>;224225 #[method(name = "rmrk_accountTokens")]226 /// Get tokens owned by an account in a collection227 fn account_tokens(228 &self,229 account_id: AccountId,230 collection_id: RmrkCollectionId,231 at: Option<BlockHash>,232 ) -> Result<Vec<RmrkNftId>>;233234 #[method(name = "rmrk_nftChildren")]235 /// Get NFT children236 fn nft_children(237 &self,238 collection_id: RmrkCollectionId,239 nft_id: RmrkNftId,240 at: Option<BlockHash>,241 ) -> Result<Vec<RmrkNftChild>>;242243 #[method(name = "rmrk_collectionProperties")]244 /// Get collection properties245 fn collection_properties(246 &self,247 collection_id: RmrkCollectionId,248 filter_keys: Option<Vec<String>>,249 at: Option<BlockHash>,250 ) -> Result<Vec<PropertyInfo>>;251252 #[method(name = "rmrk_nftProperties")]253 /// Get NFT properties254 fn nft_properties(255 &self,256 collection_id: RmrkCollectionId,257 nft_id: RmrkNftId,258 filter_keys: Option<Vec<String>>,259 at: Option<BlockHash>,260 ) -> Result<Vec<PropertyInfo>>;261262 #[method(name = "rmrk_nftResources")]263 /// Get NFT resources264 fn nft_resources(265 &self,266 collection_id: RmrkCollectionId,267 nft_id: RmrkNftId,268 at: Option<BlockHash>,269 ) -> Result<Vec<ResourceInfo>>;270271 #[method(name = "rmrk_nftResourcePriorities")]272 /// Get NFT resource priorities273 fn nft_resource_priorities(274 &self,275 collection_id: RmrkCollectionId,276 nft_id: RmrkNftId,277 at: Option<BlockHash>,278 ) -> Result<Vec<RmrkResourceId>>;279280 #[method(name = "rmrk_base")]281 /// Get base info282 fn base(&self, base_id: RmrkBaseId, at: Option<BlockHash>) -> Result<Option<BaseInfo>>;283284 #[method(name = "rmrk_baseParts")]285 /// Get all Base's parts286 fn base_parts(&self, base_id: RmrkBaseId, at: Option<BlockHash>) -> Result<Vec<PartType>>;287288 #[method(name = "rmrk_themeNames")]289 fn theme_names(290 &self,291 base_id: RmrkBaseId,292 at: Option<BlockHash>,293 ) -> Result<Vec<RmrkThemeName>>;294295 #[method(name = "rmrk_themes")]296 fn theme(297 &self,298 base_id: RmrkBaseId,299 theme_name: String,300 filter_keys: Option<Vec<String>>,301 at: Option<BlockHash>,302 ) -> Result<Option<Theme>>;303 }304}305306pub struct Unique<C, P> {307 client: Arc<C>,308 _marker: std::marker::PhantomData<P>,309}310311impl<C, P> Unique<C, P> {312 pub fn new(client: Arc<C>) -> Self {313 Self {314 client,315 _marker: Default::default(),316 }317 }318}319320macro_rules! pass_method {321 (322 $method_name:ident(323 $($(#[map(|$map_arg:ident| $map:expr)])? $name:ident: $ty:ty),* $(,)?324 ) -> $result:ty $(=> $mapper:expr)?,325 //$runtime_name:ident $(<$($lt: tt),+>)*326 $runtime_api_macro:ident327 $(; changed_in $ver:expr, $changed_method_name:ident ($($changed_name:expr), * $(,)?) => $fixer:expr)*328 ) => {329 fn $method_name(330 &self,331 $(332 $name: $ty,333 )*334 at: Option<<Block as BlockT>::Hash>,335 ) -> Result<$result> {336 let api = self.client.runtime_api();337 let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));338 let _api_version = if let Ok(Some(api_version)) =339 api.api_version::<$runtime_api_macro!()>(&at)340 {341 api_version342 } else {343 // unreachable for our runtime344 return Err(anyhow!("api is not available").into())345 };346347 let result = $(if _api_version < $ver {348 api.$changed_method_name(&at, $($changed_name),*).map(|r| r.map($fixer))349 } else)*350 { api.$method_name(&at, $($((|$map_arg: $ty| $map))? ($name)),*) };351352 Ok(result353 .map_err(|e| anyhow!("unable to query: {e}"))?354 .map_err(|e| anyhow!("runtime error: {e:?}"))$(.map($mapper))??)355 }356 };357}358359macro_rules! unique_api {360 () => {361 dyn UniqueRuntimeApi<Block, CrossAccountId, AccountId>362 };363}364365macro_rules! rmrk_api {366 () => {367 dyn RmrkRuntimeApi<Block, AccountId, CollectionInfo, NftInfo, ResourceInfo, PropertyInfo, BaseInfo, PartType, Theme>368 };369}370371#[allow(deprecated)]372impl<C, Block, CrossAccountId, AccountId>373 UniqueApiServer<<Block as BlockT>::Hash, CrossAccountId, AccountId> for Unique<C, Block>374where375 Block: BlockT,376 AccountId: Decode,377 C: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,378 C::Api: UniqueRuntimeApi<Block, CrossAccountId, AccountId>,379 CrossAccountId: pallet_evm::account::CrossAccountId<AccountId>,380{381 pass_method!(382 account_tokens(collection: CollectionId, account: CrossAccountId) -> Vec<TokenId>, unique_api383 );384 pass_method!(385 collection_tokens(collection: CollectionId) -> Vec<TokenId>, unique_api386 );387 pass_method!(388 token_exists(collection: CollectionId, token: TokenId) -> bool, unique_api389 );390 pass_method!(391 token_owner(collection: CollectionId, token: TokenId) -> Option<CrossAccountId>, unique_api392 );393 pass_method!(394 topmost_token_owner(collection: CollectionId, token: TokenId) -> Option<CrossAccountId>, unique_api395 );396 pass_method!(total_supply(collection: CollectionId) -> u32, unique_api);397 pass_method!(account_balance(collection: CollectionId, account: CrossAccountId) -> u32, unique_api);398 pass_method!(balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> String => |v| v.to_string(), unique_api);399 pass_method!(400 allowance(collection: CollectionId, sender: CrossAccountId, spender: CrossAccountId, token: TokenId) -> String => |v| v.to_string(),401 unique_api402 );403404 pass_method!(collection_properties(405 collection: CollectionId,406407 #[map(|keys| string_keys_to_bytes_keys(keys))]408 keys: Option<Vec<String>>409 ) -> Vec<Property>, unique_api);410411 pass_method!(token_properties(412 collection: CollectionId,413 token_id: TokenId,414415 #[map(|keys| string_keys_to_bytes_keys(keys))]416 keys: Option<Vec<String>>417 ) -> Vec<Property>, unique_api);418419 pass_method!(property_permissions(420 collection: CollectionId,421422 #[map(|keys| string_keys_to_bytes_keys(keys))]423 keys: Option<Vec<String>>424 ) -> Vec<PropertyKeyPermission>, unique_api);425426 pass_method!(token_data(427 collection: CollectionId,428 token_id: TokenId,429430 #[map(|keys| string_keys_to_bytes_keys(keys))]431 keys: Option<Vec<String>>,432 ) -> TokenData<CrossAccountId>, unique_api);433434 pass_method!(adminlist(collection: CollectionId) -> Vec<CrossAccountId>, unique_api);435 pass_method!(allowlist(collection: CollectionId) -> Vec<CrossAccountId>, unique_api);436 pass_method!(allowed(collection: CollectionId, user: CrossAccountId) -> bool, unique_api);437 pass_method!(last_token_id(collection: CollectionId) -> TokenId, unique_api);438 pass_method!(collection_by_id(collection: CollectionId) -> Option<RpcCollection<AccountId>>, unique_api);439 pass_method!(collection_stats() -> CollectionStats, unique_api);440 pass_method!(next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Option<u64>, unique_api);441 pass_method!(effective_collection_limits(collection_id: CollectionId) -> Option<CollectionLimits>, unique_api);442}443444#[allow(deprecated)]445impl<446 C,447 Block,448 AccountId,449 CollectionInfo,450 NftInfo,451 ResourceInfo,452 PropertyInfo,453 BaseInfo,454 PartType,455 Theme,456 >457 rmrk_unique_rpc::RmrkApiServer<458 <Block as BlockT>::Hash,459 AccountId,460 CollectionInfo,461 NftInfo,462 ResourceInfo,463 PropertyInfo,464 BaseInfo,465 PartType,466 Theme,467 > for Unique<C, Block>468where469 C: Send + Sync + 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,470 C::Api: RmrkRuntimeApi<471 Block,472 AccountId,473 CollectionInfo,474 NftInfo,475 ResourceInfo,476 PropertyInfo,477 BaseInfo,478 PartType,479 Theme,480 >,481 AccountId: Decode + Encode,482 CollectionInfo: Decode,483 NftInfo: Decode,484 ResourceInfo: Decode,485 PropertyInfo: Decode,486 BaseInfo: Decode,487 PartType: Decode,488 Theme: Decode,489 Block: BlockT,490{491 pass_method!(last_collection_idx() -> RmrkCollectionId, rmrk_api);492 pass_method!(collection_by_id(id: RmrkCollectionId) -> Option<CollectionInfo>, rmrk_api);493 pass_method!(nft_by_id(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Option<NftInfo>, rmrk_api);494 pass_method!(account_tokens(account_id: AccountId, collection_id: RmrkCollectionId) -> Vec<RmrkNftId>, rmrk_api);495 pass_method!(nft_children(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Vec<RmrkNftChild>, rmrk_api);496 pass_method!(497 collection_properties(498 collection_id: RmrkCollectionId,499500 #[map(|keys| string_keys_to_bytes_keys(keys))]501 filter_keys: Option<Vec<String>>502 ) -> Vec<PropertyInfo>,503 rmrk_api504 );505 pass_method!(506 nft_properties(507 collection_id: RmrkCollectionId,508 nft_id: RmrkNftId,509510 #[map(|keys| string_keys_to_bytes_keys(keys))]511 filter_keys: Option<Vec<String>>512 ) -> Vec<PropertyInfo>,513 rmrk_api514 );515 pass_method!(nft_resources(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Vec<ResourceInfo>, rmrk_api);516 pass_method!(nft_resource_priorities(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Vec<RmrkResourceId>, rmrk_api);517 pass_method!(base(base_id: RmrkBaseId) -> Option<BaseInfo>, rmrk_api);518 pass_method!(base_parts(base_id: RmrkBaseId) -> Vec<PartType>, rmrk_api);519 pass_method!(theme_names(base_id: RmrkBaseId) -> Vec<RmrkThemeName>, rmrk_api);520 pass_method!(521 theme(522 base_id: RmrkBaseId,523524 #[map(|n| n.into_bytes())]525 theme_name: String,526527 #[map(|keys| string_keys_to_bytes_keys(keys))]528 filter_keys: Option<Vec<String>>529 ) -> Option<Theme>, rmrk_api);530}531532fn string_keys_to_bytes_keys(keys: Option<Vec<String>>) -> Option<Vec<Vec<u8>>> {533 keys.map(|keys| keys.into_iter().map(|key| key.into_bytes()).collect())534}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/>.1617// Original License18use std::sync::Arc;1920use codec::{Decode, Encode};21use jsonrpsee::{22 core::{RpcResult as Result},23 proc_macros::rpc,24};25use anyhow::anyhow;26use up_data_structs::{27 RpcCollection, CollectionId, CollectionStats, CollectionLimits, TokenId, Property,28 PropertyKeyPermission, TokenData,29};30use sp_api::{BlockId, BlockT, ProvideRuntimeApi, ApiExt};31use sp_blockchain::HeaderBackend;32use up_rpc::UniqueApi as UniqueRuntimeApi;3334// RMRK35use rmrk_rpc::RmrkApi as RmrkRuntimeApi;36use up_data_structs::{37 RmrkCollectionId, RmrkNftId, RmrkBaseId, RmrkNftChild, RmrkThemeName, RmrkResourceId,38};3940pub use rmrk_unique_rpc::RmrkApiServer;4142#[rpc(server)]43#[async_trait]44pub trait UniqueApi<BlockHash, CrossAccountId, AccountId> {45 #[method(name = "unique_accountTokens")]46 fn account_tokens(47 &self,48 collection: CollectionId,49 account: CrossAccountId,50 at: Option<BlockHash>,51 ) -> Result<Vec<TokenId>>;52 #[method(name = "unique_collectionTokens")]53 fn collection_tokens(54 &self,55 collection: CollectionId,56 at: Option<BlockHash>,57 ) -> Result<Vec<TokenId>>;58 #[method(name = "unique_tokenExists")]59 fn token_exists(60 &self,61 collection: CollectionId,62 token: TokenId,63 at: Option<BlockHash>,64 ) -> Result<bool>;6566 #[method(name = "unique_tokenOwner")]67 fn token_owner(68 &self,69 collection: CollectionId,70 token: TokenId,71 at: Option<BlockHash>,72 ) -> Result<Option<CrossAccountId>>;73 #[method(name = "unique_topmostTokenOwner")]74 fn topmost_token_owner(75 &self,76 collection: CollectionId,77 token: TokenId,78 at: Option<BlockHash>,79 ) -> Result<Option<CrossAccountId>>;8081 #[method(name = "unique_collectionProperties")]82 fn collection_properties(83 &self,84 collection: CollectionId,85 keys: Option<Vec<String>>,86 at: Option<BlockHash>,87 ) -> Result<Vec<Property>>;8889 #[method(name = "unique_tokenProperties")]90 fn token_properties(91 &self,92 collection: CollectionId,93 token_id: TokenId,94 keys: Option<Vec<String>>,95 at: Option<BlockHash>,96 ) -> Result<Vec<Property>>;9798 #[method(name = "unique_propertyPermissions")]99 fn property_permissions(100 &self,101 collection: CollectionId,102 keys: Option<Vec<String>>,103 at: Option<BlockHash>,104 ) -> Result<Vec<PropertyKeyPermission>>;105106 #[method(name = "unique_tokenData")]107 fn token_data(108 &self,109 collection: CollectionId,110 token_id: TokenId,111 keys: Option<Vec<String>>,112 at: Option<BlockHash>,113 ) -> Result<TokenData<CrossAccountId>>;114115 #[method(name = "unique_totalSupply")]116 fn total_supply(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<u32>;117 #[method(name = "unique_accountBalance")]118 fn account_balance(119 &self,120 collection: CollectionId,121 account: CrossAccountId,122 at: Option<BlockHash>,123 ) -> Result<u32>;124 #[method(name = "unique_balance")]125 fn balance(126 &self,127 collection: CollectionId,128 account: CrossAccountId,129 token: TokenId,130 at: Option<BlockHash>,131 ) -> Result<String>;132 #[method(name = "unique_allowance")]133 fn allowance(134 &self,135 collection: CollectionId,136 sender: CrossAccountId,137 spender: CrossAccountId,138 token: TokenId,139 at: Option<BlockHash>,140 ) -> Result<String>;141142 #[method(name = "unique_adminlist")]143 fn adminlist(144 &self,145 collection: CollectionId,146 at: Option<BlockHash>,147 ) -> Result<Vec<CrossAccountId>>;148 #[method(name = "unique_allowlist")]149 fn allowlist(150 &self,151 collection: CollectionId,152 at: Option<BlockHash>,153 ) -> Result<Vec<CrossAccountId>>;154 #[method(name = "unique_allowed")]155 fn allowed(156 &self,157 collection: CollectionId,158 user: CrossAccountId,159 at: Option<BlockHash>,160 ) -> Result<bool>;161 #[method(name = "unique_lastTokenId")]162 fn last_token_id(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<TokenId>;163 #[method(name = "unique_collectionById")]164 fn collection_by_id(165 &self,166 collection: CollectionId,167 at: Option<BlockHash>,168 ) -> Result<Option<RpcCollection<AccountId>>>;169 #[method(name = "unique_collectionStats")]170 fn collection_stats(&self, at: Option<BlockHash>) -> Result<CollectionStats>;171172 #[method(name = "unique_nextSponsored")]173 fn next_sponsored(174 &self,175 collection: CollectionId,176 account: CrossAccountId,177 token: TokenId,178 at: Option<BlockHash>,179 ) -> Result<Option<u64>>;180 #[method(name = "unique_effectiveCollectionLimits")]181 fn effective_collection_limits(182 &self,183 collection_id: CollectionId,184 at: Option<BlockHash>,185 ) -> Result<Option<CollectionLimits>>;186}187188mod rmrk_unique_rpc {189 use super::*;190191 #[rpc(server)]192 #[async_trait]193 pub trait RmrkApi<194 BlockHash,195 AccountId,196 CollectionInfo,197 NftInfo,198 ResourceInfo,199 PropertyInfo,200 BaseInfo,201 PartType,202 Theme,203 >204 {205 #[method(name = "rmrk_lastCollectionIdx")]206 /// Get the latest created collection id207 fn last_collection_idx(&self, at: Option<BlockHash>) -> Result<RmrkCollectionId>;208209 #[method(name = "rmrk_collectionById")]210 /// Get collection by id211 fn collection_by_id(212 &self,213 id: RmrkCollectionId,214 at: Option<BlockHash>,215 ) -> Result<Option<CollectionInfo>>;216217 #[method(name = "rmrk_nftById")]218 /// Get NFT by collection id and NFT id219 fn nft_by_id(220 &self,221 collection_id: RmrkCollectionId,222 nft_id: RmrkNftId,223 at: Option<BlockHash>,224 ) -> Result<Option<NftInfo>>;225226 #[method(name = "rmrk_accountTokens")]227 /// Get tokens owned by an account in a collection228 fn account_tokens(229 &self,230 account_id: AccountId,231 collection_id: RmrkCollectionId,232 at: Option<BlockHash>,233 ) -> Result<Vec<RmrkNftId>>;234235 #[method(name = "rmrk_nftChildren")]236 /// Get NFT children237 fn nft_children(238 &self,239 collection_id: RmrkCollectionId,240 nft_id: RmrkNftId,241 at: Option<BlockHash>,242 ) -> Result<Vec<RmrkNftChild>>;243244 #[method(name = "rmrk_collectionProperties")]245 /// Get collection properties246 fn collection_properties(247 &self,248 collection_id: RmrkCollectionId,249 filter_keys: Option<Vec<String>>,250 at: Option<BlockHash>,251 ) -> Result<Vec<PropertyInfo>>;252253 #[method(name = "rmrk_nftProperties")]254 /// Get NFT properties255 fn nft_properties(256 &self,257 collection_id: RmrkCollectionId,258 nft_id: RmrkNftId,259 filter_keys: Option<Vec<String>>,260 at: Option<BlockHash>,261 ) -> Result<Vec<PropertyInfo>>;262263 #[method(name = "rmrk_nftResources")]264 /// Get NFT resources265 fn nft_resources(266 &self,267 collection_id: RmrkCollectionId,268 nft_id: RmrkNftId,269 at: Option<BlockHash>,270 ) -> Result<Vec<ResourceInfo>>;271272 #[method(name = "rmrk_nftResourcePriorities")]273 /// Get NFT resource priorities274 fn nft_resource_priorities(275 &self,276 collection_id: RmrkCollectionId,277 nft_id: RmrkNftId,278 at: Option<BlockHash>,279 ) -> Result<Vec<RmrkResourceId>>;280281 #[method(name = "rmrk_base")]282 /// Get base info283 fn base(&self, base_id: RmrkBaseId, at: Option<BlockHash>) -> Result<Option<BaseInfo>>;284285 #[method(name = "rmrk_baseParts")]286 /// Get all Base's parts287 fn base_parts(&self, base_id: RmrkBaseId, at: Option<BlockHash>) -> Result<Vec<PartType>>;288289 #[method(name = "rmrk_themeNames")]290 fn theme_names(291 &self,292 base_id: RmrkBaseId,293 at: Option<BlockHash>,294 ) -> Result<Vec<RmrkThemeName>>;295296 #[method(name = "rmrk_themes")]297 fn theme(298 &self,299 base_id: RmrkBaseId,300 theme_name: String,301 filter_keys: Option<Vec<String>>,302 at: Option<BlockHash>,303 ) -> Result<Option<Theme>>;304 }305}306307pub struct Unique<C, P> {308 client: Arc<C>,309 _marker: std::marker::PhantomData<P>,310}311312impl<C, P> Unique<C, P> {313 pub fn new(client: Arc<C>) -> Self {314 Self {315 client,316 _marker: Default::default(),317 }318 }319}320321macro_rules! pass_method {322 (323 $method_name:ident(324 $($(#[map(|$map_arg:ident| $map:expr)])? $name:ident: $ty:ty),* $(,)?325 ) -> $result:ty $(=> $mapper:expr)?,326 //$runtime_name:ident $(<$($lt: tt),+>)*327 $runtime_api_macro:ident328 $(; changed_in $ver:expr, $changed_method_name:ident ($($changed_name:expr), * $(,)?) => $fixer:expr)*329 ) => {330 fn $method_name(331 &self,332 $(333 $name: $ty,334 )*335 at: Option<<Block as BlockT>::Hash>,336 ) -> Result<$result> {337 let api = self.client.runtime_api();338 let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));339 let _api_version = if let Ok(Some(api_version)) =340 api.api_version::<$runtime_api_macro!()>(&at)341 {342 api_version343 } else {344 // unreachable for our runtime345 return Err(anyhow!("api is not available").into())346 };347348 let result = $(if _api_version < $ver {349 api.$changed_method_name(&at, $($changed_name),*).map(|r| r.map($fixer))350 } else)*351 { api.$method_name(&at, $($((|$map_arg: $ty| $map))? ($name)),*) };352353 Ok(result354 .map_err(|e| anyhow!("unable to query: {e}"))?355 .map_err(|e| anyhow!("runtime error: {e:?}"))$(.map($mapper))??)356 }357 };358}359360macro_rules! unique_api {361 () => {362 dyn UniqueRuntimeApi<Block, CrossAccountId, AccountId>363 };364}365366macro_rules! rmrk_api {367 () => {368 dyn RmrkRuntimeApi<Block, AccountId, CollectionInfo, NftInfo, ResourceInfo, PropertyInfo, BaseInfo, PartType, Theme>369 };370}371372#[allow(deprecated)]373impl<C, Block, CrossAccountId, AccountId>374 UniqueApiServer<<Block as BlockT>::Hash, CrossAccountId, AccountId> for Unique<C, Block>375where376 Block: BlockT,377 AccountId: Decode,378 C: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,379 C::Api: UniqueRuntimeApi<Block, CrossAccountId, AccountId>,380 CrossAccountId: pallet_evm::account::CrossAccountId<AccountId>,381{382 pass_method!(383 account_tokens(collection: CollectionId, account: CrossAccountId) -> Vec<TokenId>, unique_api384 );385 pass_method!(386 collection_tokens(collection: CollectionId) -> Vec<TokenId>, unique_api387 );388 pass_method!(389 token_exists(collection: CollectionId, token: TokenId) -> bool, unique_api390 );391 pass_method!(392 token_owner(collection: CollectionId, token: TokenId) -> Option<CrossAccountId>, unique_api393 );394 pass_method!(395 topmost_token_owner(collection: CollectionId, token: TokenId) -> Option<CrossAccountId>, unique_api396 );397 pass_method!(total_supply(collection: CollectionId) -> u32, unique_api);398 pass_method!(account_balance(collection: CollectionId, account: CrossAccountId) -> u32, unique_api);399 pass_method!(balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> String => |v| v.to_string(), unique_api);400 pass_method!(401 allowance(collection: CollectionId, sender: CrossAccountId, spender: CrossAccountId, token: TokenId) -> String => |v| v.to_string(),402 unique_api403 );404405 pass_method!(collection_properties(406 collection: CollectionId,407408 #[map(|keys| string_keys_to_bytes_keys(keys))]409 keys: Option<Vec<String>>410 ) -> Vec<Property>, unique_api);411412 pass_method!(token_properties(413 collection: CollectionId,414 token_id: TokenId,415416 #[map(|keys| string_keys_to_bytes_keys(keys))]417 keys: Option<Vec<String>>418 ) -> Vec<Property>, unique_api);419420 pass_method!(property_permissions(421 collection: CollectionId,422423 #[map(|keys| string_keys_to_bytes_keys(keys))]424 keys: Option<Vec<String>>425 ) -> Vec<PropertyKeyPermission>, unique_api);426427 pass_method!(token_data(428 collection: CollectionId,429 token_id: TokenId,430431 #[map(|keys| string_keys_to_bytes_keys(keys))]432 keys: Option<Vec<String>>,433 ) -> TokenData<CrossAccountId>, unique_api);434435 pass_method!(adminlist(collection: CollectionId) -> Vec<CrossAccountId>, unique_api);436 pass_method!(allowlist(collection: CollectionId) -> Vec<CrossAccountId>, unique_api);437 pass_method!(allowed(collection: CollectionId, user: CrossAccountId) -> bool, unique_api);438 pass_method!(last_token_id(collection: CollectionId) -> TokenId, unique_api);439 pass_method!(collection_by_id(collection: CollectionId) -> Option<RpcCollection<AccountId>>, unique_api);440 pass_method!(collection_stats() -> CollectionStats, unique_api);441 pass_method!(next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Option<u64>, unique_api);442 pass_method!(effective_collection_limits(collection_id: CollectionId) -> Option<CollectionLimits>, unique_api);443}444445#[allow(deprecated)]446impl<447 C,448 Block,449 AccountId,450 CollectionInfo,451 NftInfo,452 ResourceInfo,453 PropertyInfo,454 BaseInfo,455 PartType,456 Theme,457 >458 rmrk_unique_rpc::RmrkApiServer<459 <Block as BlockT>::Hash,460 AccountId,461 CollectionInfo,462 NftInfo,463 ResourceInfo,464 PropertyInfo,465 BaseInfo,466 PartType,467 Theme,468 > for Unique<C, Block>469where470 C: Send + Sync + 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,471 C::Api: RmrkRuntimeApi<472 Block,473 AccountId,474 CollectionInfo,475 NftInfo,476 ResourceInfo,477 PropertyInfo,478 BaseInfo,479 PartType,480 Theme,481 >,482 AccountId: Decode + Encode,483 CollectionInfo: Decode,484 NftInfo: Decode,485 ResourceInfo: Decode,486 PropertyInfo: Decode,487 BaseInfo: Decode,488 PartType: Decode,489 Theme: Decode,490 Block: BlockT,491{492 pass_method!(last_collection_idx() -> RmrkCollectionId, rmrk_api);493 pass_method!(collection_by_id(id: RmrkCollectionId) -> Option<CollectionInfo>, rmrk_api);494 pass_method!(nft_by_id(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Option<NftInfo>, rmrk_api);495 pass_method!(account_tokens(account_id: AccountId, collection_id: RmrkCollectionId) -> Vec<RmrkNftId>, rmrk_api);496 pass_method!(nft_children(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Vec<RmrkNftChild>, rmrk_api);497 pass_method!(498 collection_properties(499 collection_id: RmrkCollectionId,500501 #[map(|keys| string_keys_to_bytes_keys(keys))]502 filter_keys: Option<Vec<String>>503 ) -> Vec<PropertyInfo>,504 rmrk_api505 );506 pass_method!(507 nft_properties(508 collection_id: RmrkCollectionId,509 nft_id: RmrkNftId,510511 #[map(|keys| string_keys_to_bytes_keys(keys))]512 filter_keys: Option<Vec<String>>513 ) -> Vec<PropertyInfo>,514 rmrk_api515 );516 pass_method!(nft_resources(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Vec<ResourceInfo>, rmrk_api);517 pass_method!(nft_resource_priorities(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Vec<RmrkResourceId>, rmrk_api);518 pass_method!(base(base_id: RmrkBaseId) -> Option<BaseInfo>, rmrk_api);519 pass_method!(base_parts(base_id: RmrkBaseId) -> Vec<PartType>, rmrk_api);520 pass_method!(theme_names(base_id: RmrkBaseId) -> Vec<RmrkThemeName>, rmrk_api);521 pass_method!(522 theme(523 base_id: RmrkBaseId,524525 #[map(|n| n.into_bytes())]526 theme_name: String,527528 #[map(|keys| string_keys_to_bytes_keys(keys))]529 filter_keys: Option<Vec<String>>530 ) -> Option<Theme>, rmrk_api);531}532533fn string_keys_to_bytes_keys(keys: Option<Vec<String>>) -> Option<Vec<Vec<u8>>> {534 keys.map(|keys| keys.into_iter().map(|key| key.into_bytes()).collect())535}node/cli/src/service.rsdiffbeforeafterboth--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -14,8 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
-
// std
use std::sync::Arc;
use std::sync::Mutex;
pallets/scheduler/src/lib.rsdiffbeforeafterboth--- a/pallets/scheduler/src/lib.rs
+++ b/pallets/scheduler/src/lib.rs
@@ -1,3 +1,20 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+// Original license:
// This file is part of Substrate.
// Copyright (C) 2017-2022 Parity Technologies (UK) Ltd.
tests/flipper-src/lib.rsdiffbeforeafterboth--- a/tests/flipper-src/lib.rs
+++ b/tests/flipper-src/lib.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-// Original license
+// Original License
// Copyright 2018-2020 Parity Technologies (UK) Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
tests/ink-types-node-runtime/src/calls.rsdiffbeforeafterboth--- a/tests/ink-types-node-runtime/src/calls.rs
+++ b/tests/ink-types-node-runtime/src/calls.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-// Original license
+// Original License
// Copyright 2019 Parity Technologies (UK) Ltd.
// This file is part of ink!.
//
tests/ink-types-node-runtime/src/lib.rsdiffbeforeafterboth--- a/tests/ink-types-node-runtime/src/lib.rs
+++ b/tests/ink-types-node-runtime/src/lib.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-// Original license
+// Original License
// Copyright 2018-2019 Parity Technologies (UK) Ltd.
// This file is part of ink!.
//
tests/loadtester-src/lib.rsdiffbeforeafterboth--- a/tests/loadtester-src/lib.rs
+++ b/tests/loadtester-src/lib.rs
@@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+// Original License
#![cfg_attr(not(feature = "std"), no_std)]
use ink_lang as ink;
tests/src/xcmTransfer.test.tsdiffbeforeafterboth--- a/tests/src/xcmTransfer.test.ts
+++ b/tests/src/xcmTransfer.test.ts
@@ -33,7 +33,7 @@
const KARURA_CHAIN = 2000;
const KARURA_PORT = '9946';
-describe('Integration test: Exchanging OPL with Karura', () => {
+describe('Integration test: Exchanging QTZ with Karura', () => {
let alice: IKeyringPair;
before(async () => {
@@ -59,8 +59,8 @@
const metadata =
{
- name: 'OPL',
- symbol: 'OPL',
+ name: 'QTZ',
+ symbol: 'QTZ',
decimals: 18,
minimalBalance: 1,
};
@@ -73,7 +73,7 @@
}, karuraApiOptions);
});
- it('Should connect and send OPL to Karura', async () => {
+ it('Should connect and send QTZ to Karura', async () => {
let balanceOnKaruraBefore: bigint;
await usingApi(async (api) => {
@@ -140,7 +140,7 @@
}, {provider: new WsProvider('ws://127.0.0.1:' + KARURA_PORT)});
});
- it('Should connect to Karura and send OPL back', async () => {
+ it('Should connect to Karura and send QTZ back', async () => {
let balanceBefore: bigint;
await usingApi(async (api) => {