Skip to content

Commit a15119d

Browse files
Mapped assets pallet DebitFlags struct is private to the crate, so the debitFlags parameter from the afloat_do_burn method was removed and the debitFlags created internally, finally updated the afloat pallet accordingly. AssetId type is no longer Copy, so called the clone method where necessary. CollectionId type is no longer Copy, so called the clone method where necessary. JSON NumberValue struct has a new negative field, so this field was added as necesary. GenesisBuild has been deprecated, so the BitcoinVaults and MappedAssets pallets to use the new BuildGenesisConfig trait. Updated the block_number parameter type to be BlockNumberFor. Added does_asset_exist method to the MappedAssets pallet. Updated the way of checking overflow in the MappedAssets pallet to use checked_add. Added back the Rbac type to the MappedAssets pallet.
1 parent 0187673 commit a15119d

File tree

7 files changed

+102
-86
lines changed

7 files changed

+102
-86
lines changed

pallets/afloat/src/functions.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use sp_runtime::{traits::StaticLookup, Permill};
88
// use frame_support::traits::OriginTrait;
99
use core::convert::TryInto;
1010
use frame_support::{sp_io::hashing::blake2_256, traits::Time};
11-
use pallet_mapped_assets::DebitFlags;
1211
use pallet_rbac::types::{IdOrVec, RoleBasedAccessControl, RoleId};
1312
use scale_info::prelude::vec;
1413
use sp_runtime::{
@@ -73,22 +72,22 @@ impl<T: Config> Pallet<T> {
7372
CreateAsset::New { asset_id, min_balance } => {
7473
pallet_mapped_assets::Pallet::<T>::create(
7574
RawOrigin::Signed(creator.clone()).into(),
76-
asset_id,
75+
asset_id.clone().into(),
7776
T::Lookup::unlookup(creator.clone()),
7877
min_balance,
7978
)?;
80-
asset_id
79+
asset_id.clone()
8180
},
8281
CreateAsset::Existing { asset_id } => {
8382
ensure!(
84-
pallet_mapped_assets::Pallet::<T>::does_asset_exists(asset_id),
83+
pallet_mapped_assets::Pallet::<T>::does_asset_exist(&asset_id),
8584
Error::<T>::AssetNotFound
8685
);
87-
asset_id
86+
asset_id.clone()
8887
},
8988
};
9089

91-
AfloatAssetId::<T>::put(asset_id.clone());
90+
AfloatAssetId::<T>::put(asset_id);
9291
Ok(())
9392
}
9493
/// This functions sets up the roles for the Afloat pallet.
@@ -293,7 +292,6 @@ impl<T: Config> Pallet<T> {
293292
) -> DispatchResult {
294293
let authority = ensure_signed(origin.clone())?;
295294
let asset_id = AfloatAssetId::<T>::get().expect("AfloatAssetId should be set");
296-
let debit_flags = DebitFlags { keep_alive: false, best_effort: true };
297295
ensure!(UserInfo::<T>::contains_key(user_address.clone()), Error::<T>::UserNotFound);
298296

299297
let current_balance = Self::do_get_afloat_balance(user_address.clone());
@@ -304,7 +302,6 @@ impl<T: Config> Pallet<T> {
304302
&user_address.clone(),
305303
diff,
306304
Some(authority.clone()),
307-
debit_flags,
308305
)?;
309306
} else if current_balance < amount {
310307
let diff = amount - current_balance;

pallets/bitcoin-vaults/src/functions.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ impl<T: Config> Pallet<T> {
474474
fraction: 0,
475475
fraction_length: 0,
476476
exponent: 0,
477+
negative: false,
477478
};
478479
body.push(("threshold".chars().collect::<Vec<char>>(), JsonValue::Number(threshold)));
479480
let vault_signers = vault.cosigners.clone().to_vec();
@@ -573,16 +574,18 @@ impl<T: Config> Pallet<T> {
573574
let vault = <Vaults<T>>::get(proposal.vault_id.clone())
574575
.ok_or(Self::build_offchain_err(false, "Vault not found"))?;
575576
let amount = NumberValue {
576-
integer: proposal.amount.clone() as i64,
577+
integer: proposal.amount.clone() as u64,
577578
fraction: 0,
578579
fraction_length: 0,
579580
exponent: 0,
581+
negative: false,
580582
};
581583
let fee = NumberValue {
582584
integer: proposal.fee_sat_per_vb.clone().into(),
583585
fraction: 0,
584586
fraction_length: 0,
585587
exponent: 0,
588+
negative: false,
586589
};
587590
let to_address = str::from_utf8(proposal.to_address.as_slice())
588591
.map_err(|_| {

pallets/bitcoin-vaults/src/lib.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,24 @@ pub mod pallet {
3939
/* --- Genesis Structs Section --- */
4040

4141
#[pallet::genesis_config]
42-
#[derive(Default)]
43-
pub struct GenesisConfig {
42+
pub struct GenesisConfig<T: Config> {
4443
pub bdk_services_url: Vec<u8>,
44+
#[serde(skip)]
45+
pub _config: sp_std::marker::PhantomData<T>,
4546
}
4647

4748
#[cfg(feature = "std")]
48-
impl Default for GenesisConfig {
49+
impl<T: Config> Default for GenesisConfig<T> {
4950
fn default() -> Self {
50-
Self { bdk_services_url: b"https://bdk.hashed.systems".encode() }
51+
Self {
52+
bdk_services_url: b"https://bdk.hashed.systems".encode(),
53+
_config: Default::default(),
54+
}
5155
}
5256
}
5357

5458
#[pallet::genesis_build]
55-
impl<T: Config> GenesisBuild<T> for GenesisConfig {
59+
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
5660
fn build(&self) {
5761
<BDKServicesURL<T>>::put(
5862
BoundedVec::<u8, ConstU32<32>>::try_from(self.bdk_services_url.clone())
@@ -275,7 +279,7 @@ pub mod pallet {
275279
/// Note that it's not guaranteed for offchain workers to run on EVERY block, there might
276280
/// be cases where some blocks are skipped, or for some the worker runs twice (re-orgs),
277281
/// so the code should be able to handle that.
278-
fn offchain_worker(_block_number: T::BlockNumber) {
282+
fn offchain_worker(_block_number: BlockNumberFor<T>) {
279283
// check if the node has an account available, the offchain worker can't submit
280284
// transactions without it
281285
let signer = Signer::<T, T::AuthorityId>::any_account();

pallets/fruniques/src/functions.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl<T: Config> Pallet<T> {
6868
}
6969

7070
pub fn admin_of(class_id: &T::CollectionId, instance_id: &T::ItemId) -> Option<T::AccountId> {
71-
pallet_uniques::Pallet::<T>::owner(*class_id, *instance_id)
71+
pallet_uniques::Pallet::<T>::owner(class_id.clone(), *instance_id)
7272
}
7373

7474
pub fn is_frozen(collection_id: &T::CollectionId, instance_id: &T::ItemId) -> bool {
@@ -79,14 +79,14 @@ impl<T: Config> Pallet<T> {
7979
}
8080

8181
pub fn collection_exists(class_id: &T::CollectionId) -> bool {
82-
if let Some(_owner) = pallet_uniques::Pallet::<T>::collection_owner(*class_id) {
82+
if let Some(_owner) = pallet_uniques::Pallet::<T>::collection_owner(class_id.clone()) {
8383
return true
8484
}
8585
false
8686
}
8787

8888
pub fn instance_exists(class_id: &T::CollectionId, instance_id: &T::ItemId) -> bool {
89-
if let Some(_owner) = pallet_uniques::Pallet::<T>::owner(*class_id, *instance_id) {
89+
if let Some(_owner) = pallet_uniques::Pallet::<T>::owner(class_id.clone(), *instance_id) {
9090
return true
9191
}
9292
false
@@ -164,7 +164,7 @@ impl<T: Config> Pallet<T> {
164164
) -> DispatchResult {
165165
pallet_uniques::Pallet::<T>::set_attribute(
166166
origin,
167-
*class_id.clone(),
167+
class_id.clone(),
168168
Some(instance_id),
169169
key,
170170
value,
@@ -247,7 +247,7 @@ impl<T: Config> Pallet<T> {
247247

248248
pallet_uniques::Pallet::<T>::burn(
249249
origin,
250-
*class_id,
250+
class_id.clone(),
251251
instance_id,
252252
Some(Self::account_id_to_lookup_source(&admin.unwrap())),
253253
)?;
@@ -372,7 +372,7 @@ impl<T: Config> Pallet<T> {
372372
let child_percentage: Permill = parent_info.parent_weight * frunique_parent.weight;
373373

374374
let parent_data: ParentInfo<T> = ParentInfo {
375-
collection_id: parent_info.collection_id,
375+
collection_id: parent_info.collection_id.clone(),
376376
parent_id: parent_info.parent_id,
377377
parent_weight: child_percentage,
378378
is_hierarchical: parent_info.is_hierarchical,
@@ -400,7 +400,7 @@ impl<T: Config> Pallet<T> {
400400
};
401401

402402
<FruniqueInfo<T>>::try_mutate::<_, _, _, DispatchError, _>(
403-
parent_info.collection_id,
403+
parent_info.collection_id.clone(),
404404
parent_info.parent_id,
405405
|frunique_data| -> DispatchResult {
406406
let frunique = frunique_data.as_mut().ok_or(Error::<T>::FruniqueNotFound)?;

0 commit comments

Comments
 (0)