Skip to content

Commit

Permalink
Merge pull request #875 from UniqueNetwork/release-v937052
Browse files Browse the repository at this point in the history
Release v937052
  • Loading branch information
uandysmith authored Feb 8, 2023
2 parents 8939f8f + 8d17f4c commit d6894f5
Show file tree
Hide file tree
Showing 161 changed files with 1,268 additions and 17,749 deletions.
441 changes: 184 additions & 257 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ panic = 'unwind'

[workspace.dependencies]
# Unique
evm-coder = { default-features = false, path = "crates/evm-coder" }
evm-coder = { git = "https://github.com/uniquenetwork/evm-coder", tag = "v0.3.0", default-features = false }
struct-versioning = { path = "crates/struct-versioning" }
precompile-utils-macro = { path = "runtime/common/ethereum/precompiles/utils/macro" }
up-common = { path = "primitives/common", default-features = false }
Expand All @@ -43,17 +43,13 @@ pallet-identity = { default-features = false, path = "pallets/identity" }
pallet-inflation = { path = "pallets/inflation", default-features = false }
pallet-maintenance = { default-features = false, path = "pallets/maintenance" }
pallet-nonfungible = { default-features = false, path = "pallets/nonfungible" }
pallet-proxy-rmrk-core = { default-features = false, path = "pallets/proxy-rmrk-core", package = "pallet-rmrk-core" }
pallet-proxy-rmrk-equip = { default-features = false, path = "pallets/proxy-rmrk-equip", package = "pallet-rmrk-equip" }
rmrk-traits = { default-features = false, path = "primitives/rmrk-traits" }
pallet-refungible = { default-features = false, path = "pallets/refungible" }
pallet-structure = { default-features = false, path = "pallets/structure" }
pallet-unique = { path = "pallets/unique", default-features = false }
pallet-unique-scheduler-v2 = { path = "pallets/scheduler-v2", default-features = false }
pallet-test-utils = { default-features = false, path = "test-pallets/utils" }
pallet-app-promotion = { path = "pallets/app-promotion", default-features = false }
app-promotion-rpc = { path = "primitives/app_promotion_rpc", default-features = false }
rmrk-rpc = { path = "primitives/rmrk-rpc", default-features = false }

# Unique: Runtimes
unique-runtime = { path = "runtime/unique" }
Expand Down
10 changes: 1 addition & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,6 @@ bench-structure:
bench-scheduler:
make _bench PALLET=unique-scheduler-v2 PALLET_DIR=scheduler-v2

.PHONY: bench-rmrk-core
bench-rmrk-core:
make _bench PALLET=proxy-rmrk-core

.PHONY: bench-rmrk-equip
bench-rmrk-equip:
make _bench PALLET=proxy-rmrk-equip

.PHONY: bench-foreign-assets
bench-foreign-assets:
make _bench PALLET=foreign-assets
Expand All @@ -146,7 +138,7 @@ bench-app-promotion:
make _bench PALLET=app-promotion PALLET_DIR=app-promotion

.PHONY: bench
# Disabled: bench-scheduler, bench-collator-selection, bench-identity, bench-rmrk-core, bench-rmrk-equip
# Disabled: bench-scheduler, bench-collator-selection, bench-identity
bench: bench-common bench-evm-migration bench-unique bench-structure bench-fungible bench-refungible bench-nonfungible bench-configuration bench-foreign-assets

.PHONY: check
Expand Down
1 change: 0 additions & 1 deletion client/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ zstd = { version = "0.11.2", default-features = false }
codec = { workspace = true, package = "parity-scale-codec" }

app-promotion-rpc = { workspace = true }
rmrk-rpc = { workspace = true }
up-common = { workspace = true }
up-data-structs = { workspace = true }
up-pov-estimate-rpc = { workspace = true, optional = true }
Expand Down
231 changes: 1 addition & 230 deletions client/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// Original License
use std::sync::Arc;

use codec::{Decode, Encode};
use codec::Decode;
use jsonrpsee::{
core::{RpcResult as Result},
proc_macros::rpc,
Expand All @@ -33,14 +33,7 @@ use sp_blockchain::HeaderBackend;
use up_rpc::UniqueApi as UniqueRuntimeApi;
use app_promotion_rpc::AppPromotionApi as AppPromotionRuntimeApi;

// RMRK
use rmrk_rpc::RmrkApi as RmrkRuntimeApi;
use up_data_structs::{
RmrkCollectionId, RmrkNftId, RmrkBaseId, RmrkNftChild, RmrkThemeName, RmrkResourceId,
};

pub use app_promotion_unique_rpc::AppPromotionApiServer;
pub use rmrk_unique_rpc::RmrkApiServer;

#[cfg(feature = "pov-estimate")]
pub mod pov_estimate;
Expand Down Expand Up @@ -301,128 +294,6 @@ mod app_promotion_unique_rpc {
}
}

mod rmrk_unique_rpc {
use super::*;

#[rpc(server)]
#[async_trait]
pub trait RmrkApi<
BlockHash,
AccountId,
CollectionInfo,
NftInfo,
ResourceInfo,
PropertyInfo,
BaseInfo,
PartType,
Theme,
>
{
/// Get the latest created collection ID.
#[method(name = "rmrk_lastCollectionIdx")]
fn last_collection_idx(&self, at: Option<BlockHash>) -> Result<RmrkCollectionId>;

/// Get collection info by ID.
#[method(name = "rmrk_collectionById")]
fn collection_by_id(
&self,
id: RmrkCollectionId,
at: Option<BlockHash>,
) -> Result<Option<CollectionInfo>>;

/// Get NFT info by collection and NFT IDs.
#[method(name = "rmrk_nftById")]
fn nft_by_id(
&self,
collection_id: RmrkCollectionId,
nft_id: RmrkNftId,
at: Option<BlockHash>,
) -> Result<Option<NftInfo>>;

/// Get tokens owned by an account in a collection.
#[method(name = "rmrk_accountTokens")]
fn account_tokens(
&self,
account_id: AccountId,
collection_id: RmrkCollectionId,
at: Option<BlockHash>,
) -> Result<Vec<RmrkNftId>>;

/// Get tokens nested in an NFT - its direct children (not the children's children).
#[method(name = "rmrk_nftChildren")]
fn nft_children(
&self,
collection_id: RmrkCollectionId,
nft_id: RmrkNftId,
at: Option<BlockHash>,
) -> Result<Vec<RmrkNftChild>>;

/// Get collection properties, created by the user - not the proxy-specific properties.
#[method(name = "rmrk_collectionProperties")]
fn collection_properties(
&self,
collection_id: RmrkCollectionId,
filter_keys: Option<Vec<String>>,
at: Option<BlockHash>,
) -> Result<Vec<PropertyInfo>>;

/// Get NFT properties, created by the user - not the proxy-specific properties.
#[method(name = "rmrk_nftProperties")]
fn nft_properties(
&self,
collection_id: RmrkCollectionId,
nft_id: RmrkNftId,
filter_keys: Option<Vec<String>>,
at: Option<BlockHash>,
) -> Result<Vec<PropertyInfo>>;

/// Get data of resources of an NFT.
#[method(name = "rmrk_nftResources")]
fn nft_resources(
&self,
collection_id: RmrkCollectionId,
nft_id: RmrkNftId,
at: Option<BlockHash>,
) -> Result<Vec<ResourceInfo>>;

/// Get the priority of a resource in an NFT.
#[method(name = "rmrk_nftResourcePriority")]
fn nft_resource_priority(
&self,
collection_id: RmrkCollectionId,
nft_id: RmrkNftId,
resource_id: RmrkResourceId,
at: Option<BlockHash>,
) -> Result<Option<u32>>;

/// Get base info by its ID.
#[method(name = "rmrk_base")]
fn base(&self, base_id: RmrkBaseId, at: Option<BlockHash>) -> Result<Option<BaseInfo>>;

/// Get all parts of a base.
#[method(name = "rmrk_baseParts")]
fn base_parts(&self, base_id: RmrkBaseId, at: Option<BlockHash>) -> Result<Vec<PartType>>;

/// Get the theme names belonging to a base.
#[method(name = "rmrk_themeNames")]
fn theme_names(
&self,
base_id: RmrkBaseId,
at: Option<BlockHash>,
) -> Result<Vec<RmrkThemeName>>;

/// Get theme info, including properties, optionally limited to the provided keys.
#[method(name = "rmrk_themes")]
fn theme(
&self,
base_id: RmrkBaseId,
theme_name: String,
filter_keys: Option<Vec<String>>,
at: Option<BlockHash>,
) -> Result<Option<Theme>>;
}
}

#[macro_export]
macro_rules! define_struct_for_server_api {
($name:ident { $($arg:ident: $arg_ty:ty),+ $(,)? }) => {
Expand Down Expand Up @@ -454,12 +325,6 @@ define_struct_for_server_api! {
}
}

define_struct_for_server_api! {
Rmrk {
client: Arc<Client>
}
}

macro_rules! pass_method {
(
$method_name:ident(
Expand Down Expand Up @@ -511,12 +376,6 @@ macro_rules! app_promotion_api {
};
}

macro_rules! rmrk_api {
() => {
dyn RmrkRuntimeApi<Block, AccountId, CollectionInfo, NftInfo, ResourceInfo, PropertyInfo, BaseInfo, PartType, Theme>
};
}

#[allow(deprecated)]
impl<C, Block, CrossAccountId, AccountId>
UniqueApiServer<<Block as BlockT>::Hash, CrossAccountId, AccountId> for Unique<C, Block>
Expand Down Expand Up @@ -629,94 +488,6 @@ where
.collect::<Vec<_>>(), app_promotion_api);
}

#[allow(deprecated)]
impl<
C,
Block,
AccountId,
CollectionInfo,
NftInfo,
ResourceInfo,
PropertyInfo,
BaseInfo,
PartType,
Theme,
>
rmrk_unique_rpc::RmrkApiServer<
<Block as BlockT>::Hash,
AccountId,
CollectionInfo,
NftInfo,
ResourceInfo,
PropertyInfo,
BaseInfo,
PartType,
Theme,
> for Rmrk<C, Block>
where
C: Send + Sync + 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,
C::Api: RmrkRuntimeApi<
Block,
AccountId,
CollectionInfo,
NftInfo,
ResourceInfo,
PropertyInfo,
BaseInfo,
PartType,
Theme,
>,
AccountId: Decode + Encode,
CollectionInfo: Decode,
NftInfo: Decode,
ResourceInfo: Decode,
PropertyInfo: Decode,
BaseInfo: Decode,
PartType: Decode,
Theme: Decode,
Block: BlockT,
{
pass_method!(last_collection_idx() -> RmrkCollectionId, rmrk_api);
pass_method!(collection_by_id(id: RmrkCollectionId) -> Option<CollectionInfo>, rmrk_api);
pass_method!(nft_by_id(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Option<NftInfo>, rmrk_api);
pass_method!(account_tokens(account_id: AccountId, collection_id: RmrkCollectionId) -> Vec<RmrkNftId>, rmrk_api);
pass_method!(nft_children(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Vec<RmrkNftChild>, rmrk_api);
pass_method!(
collection_properties(
collection_id: RmrkCollectionId,

#[map(|keys| string_keys_to_bytes_keys(keys))]
filter_keys: Option<Vec<String>>
) -> Vec<PropertyInfo>,
rmrk_api
);
pass_method!(
nft_properties(
collection_id: RmrkCollectionId,
nft_id: RmrkNftId,

#[map(|keys| string_keys_to_bytes_keys(keys))]
filter_keys: Option<Vec<String>>
) -> Vec<PropertyInfo>,
rmrk_api
);
pass_method!(nft_resources(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Vec<ResourceInfo>, rmrk_api);
pass_method!(nft_resource_priority(collection_id: RmrkCollectionId, nft_id: RmrkNftId, resource_id: RmrkResourceId) -> Option<u32>, rmrk_api);
pass_method!(base(base_id: RmrkBaseId) -> Option<BaseInfo>, rmrk_api);
pass_method!(base_parts(base_id: RmrkBaseId) -> Vec<PartType>, rmrk_api);
pass_method!(theme_names(base_id: RmrkBaseId) -> Vec<RmrkThemeName>, rmrk_api);
pass_method!(
theme(
base_id: RmrkBaseId,

#[map(|n| n.into_bytes())]
theme_name: String,

#[map(|keys| string_keys_to_bytes_keys(keys))]
filter_keys: Option<Vec<String>>
) -> Option<Theme>, rmrk_api);
}

fn string_keys_to_bytes_keys(keys: Option<Vec<String>>) -> Option<Vec<Vec<u8>>> {
keys.map(|keys| keys.into_iter().map(|key| key.into_bytes()).collect())
}
48 changes: 0 additions & 48 deletions crates/evm-coder/CHANGELOG.md

This file was deleted.

Loading

0 comments on commit d6894f5

Please sign in to comment.