Skip to content

Commit a458077

Browse files
authored
Merge pull request #419 from UniqueNetwork/release-v924010
Release v924010
2 parents 518e58f + 824b60f commit a458077

73 files changed

Lines changed: 5819 additions & 728 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ einstein_key_file
1212

1313
/.idea/
1414
/.cargo/
15+
/.vscode/
1516

1617
tests/.vscode
1718
cumulus-parachain/

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ so that we can keep the builds stable.
4242
1. Install Rust:
4343

4444
```bash
45-
sudo apt-get install git curl libssl-dev llvm pkg-config libclang-dev clang make
45+
sudo apt-get install git curl libssl-dev llvm pkg-config libclang-dev clang make cmake
4646
curl https://sh.rustup.rs -sSf | sh
4747
```
4848

@@ -83,7 +83,8 @@ Note: checkout this project and all related projects (see below) in the sibling
8383
### Polkadot launch utility
8484

8585
```
86-
git clone https://github.com/paritytech/polkadot-launch
86+
git clone https://github.com/UniqueNetwork/polkadot-launch.git
87+
git checkout feature/runtime-upgrade-testing
8788
```
8889

8990
### Build relay

pallets/common/src/lib.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,10 @@ pub trait CommonWeightInfo<CrossAccountId> {
12581258
}
12591259
}
12601260

1261+
pub trait RefungibleExtensionsWeightInfo {
1262+
fn repartition() -> Weight;
1263+
}
1264+
12611265
pub trait CommonCollectionOperations<T: Config> {
12621266
fn create_item(
12631267
&self,
@@ -1307,12 +1311,14 @@ pub trait CommonCollectionOperations<T: Config> {
13071311
sender: T::CrossAccountId,
13081312
token_id: TokenId,
13091313
property: Vec<Property>,
1314+
nesting_budget: &dyn Budget,
13101315
) -> DispatchResultWithPostInfo;
13111316
fn delete_token_properties(
13121317
&self,
13131318
sender: T::CrossAccountId,
13141319
token_id: TokenId,
13151320
property_keys: Vec<PropertyKey>,
1321+
nesting_budget: &dyn Budget,
13161322
) -> DispatchResultWithPostInfo;
13171323
fn set_token_property_permissions(
13181324
&self,
@@ -1357,7 +1363,7 @@ pub trait CommonCollectionOperations<T: Config> {
13571363
sender: T::CrossAccountId,
13581364
from: (CollectionId, TokenId),
13591365
under: TokenId,
1360-
budget: &dyn Budget,
1366+
nesting_budget: &dyn Budget,
13611367
) -> DispatchResult;
13621368

13631369
fn nest(&self, under: TokenId, to_nest: (CollectionId, TokenId));
@@ -1384,6 +1390,19 @@ pub trait CommonCollectionOperations<T: Config> {
13841390
spender: T::CrossAccountId,
13851391
token: TokenId,
13861392
) -> u128;
1393+
fn refungible_extensions(&self) -> Option<&dyn RefungibleExtensions<T>>;
1394+
}
1395+
1396+
pub trait RefungibleExtensions<T>
1397+
where
1398+
T: Config,
1399+
{
1400+
fn repartition(
1401+
&self,
1402+
owner: &T::CrossAccountId,
1403+
token: TokenId,
1404+
amount: u128,
1405+
) -> DispatchResultWithPostInfo;
13871406
}
13881407

13891408
// Flexible enough for implementing CommonCollectionOperations

pallets/fungible/src/common.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use core::marker::PhantomData;
1818

1919
use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight, traits::Get};
2020
use up_data_structs::{TokenId, CollectionId, CreateItemExData, budget::Budget, CreateItemData};
21-
use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};
21+
use pallet_common::{CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions, with_weight};
2222
use pallet_structure::Error as StructureError;
2323
use sp_runtime::ArithmeticError;
2424
use sp_std::{vec::Vec, vec};
@@ -298,6 +298,7 @@ impl<T: Config> CommonCollectionOperations<T> for FungibleHandle<T> {
298298
_sender: T::CrossAccountId,
299299
_token_id: TokenId,
300300
_property: Vec<Property>,
301+
_nesting_budget: &dyn Budget,
301302
) -> DispatchResultWithPostInfo {
302303
fail!(<Error<T>>::SettingPropertiesNotAllowed)
303304
}
@@ -315,6 +316,7 @@ impl<T: Config> CommonCollectionOperations<T> for FungibleHandle<T> {
315316
_sender: T::CrossAccountId,
316317
_token_id: TokenId,
317318
_property_keys: Vec<PropertyKey>,
319+
_nesting_budget: &dyn Budget,
318320
) -> DispatchResultWithPostInfo {
319321
fail!(<Error<T>>::SettingPropertiesNotAllowed)
320322
}
@@ -324,7 +326,7 @@ impl<T: Config> CommonCollectionOperations<T> for FungibleHandle<T> {
324326
_sender: <T>::CrossAccountId,
325327
_from: (CollectionId, TokenId),
326328
_under: TokenId,
327-
_budget: &dyn Budget,
329+
_nesting_budget: &dyn Budget,
328330
) -> sp_runtime::DispatchResult {
329331
fail!(<Error<T>>::FungibleDisallowsNesting)
330332
}
@@ -399,4 +401,8 @@ impl<T: Config> CommonCollectionOperations<T> for FungibleHandle<T> {
399401
}
400402
<Allowance<T>>::get((self.id, sender, spender))
401403
}
404+
405+
fn refungible_extensions(&self) -> Option<&dyn RefungibleExtensions<T>> {
406+
None
407+
}
402408
}

pallets/nonfungible/src/benchmarking.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ benchmarks! {
183183
value: property_value(),
184184
}).collect::<Vec<_>>();
185185
let item = create_max_item(&collection, &owner, owner.clone())?;
186-
}: {<Pallet<T>>::set_token_properties(&collection, &owner, item, props, false)?}
186+
}: {<Pallet<T>>::set_token_properties(&collection, &owner, item, props, false, &Unlimited)?}
187187

188188
delete_token_properties {
189189
let b in 0..MAX_PROPERTIES_PER_ITEM;
@@ -205,7 +205,7 @@ benchmarks! {
205205
value: property_value(),
206206
}).collect::<Vec<_>>();
207207
let item = create_max_item(&collection, &owner, owner.clone())?;
208-
<Pallet<T>>::set_token_properties(&collection, &owner, item, props, false)?;
208+
<Pallet<T>>::set_token_properties(&collection, &owner, item, props, false, &Unlimited)?;
209209
let to_delete = (0..b).map(|k| property_key(k as usize)).collect::<Vec<_>>();
210-
}: {<Pallet<T>>::delete_token_properties(&collection, &owner, item, to_delete)?}
210+
}: {<Pallet<T>>::delete_token_properties(&collection, &owner, item, to_delete, &Unlimited)?}
211211
}

pallets/nonfungible/src/common.rs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ use up_data_structs::{
2222
PropertyKeyPermission, PropertyValue,
2323
};
2424
use pallet_common::{
25-
CommonCollectionOperations, CommonWeightInfo, with_weight, weights::WeightInfo as _,
25+
CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions, with_weight,
26+
weights::WeightInfo as _,
2627
};
2728
use sp_runtime::DispatchError;
2829
use sp_std::vec::Vec;
@@ -219,11 +220,19 @@ impl<T: Config> CommonCollectionOperations<T> for NonfungibleHandle<T> {
219220
sender: T::CrossAccountId,
220221
token_id: TokenId,
221222
properties: Vec<Property>,
223+
nesting_budget: &dyn Budget,
222224
) -> DispatchResultWithPostInfo {
223225
let weight = <CommonWeights<T>>::set_token_properties(properties.len() as u32);
224226

225227
with_weight(
226-
<Pallet<T>>::set_token_properties(self, &sender, token_id, properties, false),
228+
<Pallet<T>>::set_token_properties(
229+
self,
230+
&sender,
231+
token_id,
232+
properties.into_iter(),
233+
false,
234+
nesting_budget,
235+
),
227236
weight,
228237
)
229238
}
@@ -233,11 +242,18 @@ impl<T: Config> CommonCollectionOperations<T> for NonfungibleHandle<T> {
233242
sender: T::CrossAccountId,
234243
token_id: TokenId,
235244
property_keys: Vec<PropertyKey>,
245+
nesting_budget: &dyn Budget,
236246
) -> DispatchResultWithPostInfo {
237247
let weight = <CommonWeights<T>>::delete_token_properties(property_keys.len() as u32);
238248

239249
with_weight(
240-
<Pallet<T>>::delete_token_properties(self, &sender, token_id, property_keys),
250+
<Pallet<T>>::delete_token_properties(
251+
self,
252+
&sender,
253+
token_id,
254+
property_keys.into_iter(),
255+
nesting_budget,
256+
),
241257
weight,
242258
)
243259
}
@@ -367,9 +383,9 @@ impl<T: Config> CommonCollectionOperations<T> for NonfungibleHandle<T> {
367383
sender: T::CrossAccountId,
368384
from: (CollectionId, TokenId),
369385
under: TokenId,
370-
budget: &dyn Budget,
386+
nesting_budget: &dyn Budget,
371387
) -> sp_runtime::DispatchResult {
372-
<Pallet<T>>::check_nesting(self, sender, from, under, budget)
388+
<Pallet<T>>::check_nesting(self, sender, from, under, nesting_budget)
373389
}
374390

375391
fn nest(&self, under: TokenId, to_nest: (CollectionId, TokenId)) {
@@ -467,4 +483,8 @@ impl<T: Config> CommonCollectionOperations<T> for NonfungibleHandle<T> {
467483
0
468484
}
469485
}
486+
487+
fn refungible_extensions(&self) -> Option<&dyn RefungibleExtensions<T>> {
488+
None
489+
}
470490
}

pallets/nonfungible/src/erc.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,16 @@ impl<T: Config> NonfungibleHandle<T> {
8282
.map_err(|_| "key too long")?;
8383
let value = value.try_into().map_err(|_| "value too long")?;
8484

85+
let nesting_budget = self
86+
.recorder
87+
.weight_calls_budget(<StructureWeight<T>>::find_parent());
88+
8589
<Pallet<T>>::set_token_property(
8690
self,
8791
&caller,
8892
TokenId(token_id),
8993
Property { key, value },
90-
false,
94+
&nesting_budget,
9195
)
9296
.map_err(dispatch_to_evm::<T>)
9397
}
@@ -99,7 +103,11 @@ impl<T: Config> NonfungibleHandle<T> {
99103
.try_into()
100104
.map_err(|_| "key too long")?;
101105

102-
<Pallet<T>>::delete_token_property(self, &caller, TokenId(token_id), key)
106+
let nesting_budget = self
107+
.recorder
108+
.weight_calls_budget(<StructureWeight<T>>::find_parent());
109+
110+
<Pallet<T>>::delete_token_property(self, &caller, TokenId(token_id), key, &nesting_budget)
103111
.map_err(dispatch_to_evm::<T>)
104112
}
105113

0 commit comments

Comments
 (0)