difftreelog
CORE-346 Add static tokenURI key
in: master
5 files changed
Cargo.lockdiffbeforeafterboth4290version = "1.4.0"4290version = "1.4.0"4291source = "registry+https://github.com/rust-lang/crates.io-index"4291source = "registry+https://github.com/rust-lang/crates.io-index"4292checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"4292checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"4293dependencies = [4294 "spin",4295]429342964294[[package]]4297[[package]]4295name = "lazycell"4298name = "lazycell"5917 "frame-benchmarking",5920 "frame-benchmarking",5918 "frame-support",5921 "frame-support",5919 "frame-system",5922 "frame-system",5923 "lazy_static",5920 "pallet-evm",5924 "pallet-evm",5921 "pallet-evm-coder-substrate",5925 "pallet-evm-coder-substrate",5922 "parity-scale-codec 3.1.2",5926 "parity-scale-codec 3.1.2",pallets/common/Cargo.tomldiffbeforeafterboth16sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }16sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }17sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }17sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }18sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }18sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }19frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }19fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }20fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }20up-data-structs = { default-features = false, path = '../../primitives/data-structs' }21up-data-structs = { default-features = false, path = '../../primitives/data-structs' }21pallet-evm-coder-substrate = { default-features = false, path = '../../pallets/evm-coder-substrate' }22pallet-evm-coder-substrate = { default-features = false, path = '../../pallets/evm-coder-substrate' }25scale-info = { version = "2.0.1", default-features = false, features = [27scale-info = { version = "2.0.1", default-features = false, features = [26 "derive",28 "derive",27] }29] }28frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }30lazy_static = { version = "1.4.0", default-features = false, features = ["spin_no_std"] }293130[features]32[features]31default = ["std"]33default = ["std"]pallets/common/src/eth.rsdiffbeforeafterboth17use up_data_structs::CollectionId;17use up_data_structs::CollectionId;18use sp_core::H160;18use sp_core::H160;1920lazy_static::lazy_static! {21 pub static ref KEY_TOKEN_URI: up_data_structs::PropertyKey = {22 let key: evm_coder::types::string = "tokenURI".into(); //TODO: make static23 let key: up_data_structs::PropertyKey = key.into_bytes().try_into().expect("Can't create \"tokenURI\" key");24 key25 };26}192720// 0x17c4e6453Cc49AAAaEACA894e6D9683e00000001 - collection 128// 0x17c4e6453Cc49AAAaEACA894e6D9683e00000001 - collection 121// TODO: Unhardcode prefix29// TODO: Unhardcode prefixpallets/nonfungible/src/erc.rsdiffbeforeafterboth158 /// Returns token's const_metadata158 /// Returns token's const_metadata159 #[solidity(rename_selector = "tokenURI")]159 #[solidity(rename_selector = "tokenURI")]160 fn token_uri(&self, token_id: uint256) -> Result<string> {160 fn token_uri(&self, token_id: uint256) -> Result<string> {161 let key: string = "tokenURI".into(); //TODO: make static162 let key: up_data_structs::PropertyKey = key.into_bytes().try_into()161 let key = pallet_common::eth::KEY_TOKEN_URI.clone();163 .map_err(|_| Error::Revert("".into()))?;164 let permission = get_token_permission::<T>(self.id, &key)?;162 let permission = get_token_permission::<T>(self.id, &key)?;165 if !permission.collection_admin {163 if !permission.collection_admin {166 return Err("Operation is not allowed".into());164 return Err("Operation is not allowed".into());362 token_id: uint256,360 token_id: uint256,363 token_uri: string,361 token_uri: string,364 ) -> Result<bool> {362 ) -> Result<bool> {365 let key: string = "tokenURI".into(); //TODO: make static366 let key: up_data_structs::PropertyKey = key.into_bytes().try_into()363 let key = pallet_common::eth::KEY_TOKEN_URI.clone();367 .map_err(|_| Error::Revert("".into()))?;368 let permission = get_token_permission::<T>(self.id, &key)?;364 let permission = get_token_permission::<T>(self.id, &key)?;369 if !permission.collection_admin {365 if !permission.collection_admin {370 return Err("Operation is not allowed".into());366 return Err("Operation is not allowed".into());pallets/unique/src/eth/mod.rsdiffbeforeafterboth77 .try_into()77 .try_into()78 .map_err(|_| error_feild_too_long(stringify!(token_prefix), MAX_TOKEN_PREFIX_LENGTH))?;78 .map_err(|_| error_feild_too_long(stringify!(token_prefix), MAX_TOKEN_PREFIX_LENGTH))?;797980 let key: string = "tokenURI".into(); //TODO: make static81 let key: up_data_structs::PropertyKey = key.into_bytes().try_into().map_err(|_| Error::Revert("".into()))?;80 let key = pallet_common::eth::KEY_TOKEN_URI.clone();82 let permission = up_data_structs::PropertyPermission {81 let permission = up_data_structs::PropertyPermission {83 mutable: true,82 mutable: true,84 collection_admin: true,83 collection_admin: true,