Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix dependencies #20

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,109 changes: 583 additions & 526 deletions Cargo.lock

Large diffs are not rendered by default.

20 changes: 11 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
[workspace]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPT summary of c2a02c - fe7e2a:

  • Added resolver = "2" to the [workspace] section
  • Added 8 pallets to the members list
  • Added panic = 'unwind' to the [profile.release] section

resolver = "2"
members = [
'pallets/bitcoin-vaults',
'pallets/confidential-docs',
'pallets/rbac',
'pallets/fruniques',
'pallets/gated-marketplace',
'pallets/mapped-assets',
'pallets/afloat',
'pallets/fund-admin',
'pallets/fund-admin-records',
'pallets/bitcoin-vaults',
'pallets/confidential-docs',
'pallets/rbac',
'pallets/fruniques',
'pallets/gated-marketplace',
'pallets/mapped-assets',
'pallets/afloat',
'pallets/fund-admin',
'pallets/fund-admin-records',
]

[profile.release]
panic = 'unwind'
10 changes: 5 additions & 5 deletions pallets/afloat/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl<T: Config> Pallet<T> {
AfloatCollectionId::<T>::put(collection_id);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPT summary of 037753 - 4c39a1:

  • Added an error return when trying to create a fruniques collection
  • Added an ensure check to make sure the user has enough afloat balance
  • Added a check to ensure the tax credit amount does not overflow
  • Added a check to ensure the tax credit amount does not underflow

Ok(())
} else {
return Err(Error::<T>::FailedToCreateFruniquesCollection.into());
return Err(Error::<T>::FailedToCreateFruniquesCollection.into())
}
}

Expand Down Expand Up @@ -461,8 +461,8 @@ impl<T: Config> Pallet<T> {
);
//ensure user has enough afloat balance
ensure!(
Self::do_get_afloat_balance(who.clone())
>= offer.price_per_credit * tax_credit_amount.into(),
Self::do_get_afloat_balance(who.clone()) >=
offer.price_per_credit * tax_credit_amount.into(),
Error::<T>::NotEnoughAfloatBalanceAvailable
);
let zero_balance: T::Balance = Zero::zero();
Expand Down Expand Up @@ -609,7 +609,7 @@ impl<T: Config> Pallet<T> {
let tax_credit_amount_u32 = if let Ok(amount) = transaction.tax_credit_amount.try_into() {
amount
} else {
return Err(Error::<T>::TaxCreditAmountOverflow.into());
return Err(Error::<T>::TaxCreditAmountOverflow.into())
};

let child_offer_id = pallet_gated_marketplace::Pallet::<T>::do_enlist_sell_offer(
Expand Down Expand Up @@ -713,7 +713,7 @@ impl<T: Config> Pallet<T> {
<AfloatOffers<T>>::try_mutate(offer_id, |offer| -> DispatchResult {
let offer = offer.as_mut().ok_or(Error::<T>::OfferNotFound)?;
if transaction.tax_credit_amount > offer.tax_credit_amount_remaining {
return Err(Error::<T>::Underflow.into());
return Err(Error::<T>::Underflow.into())
}
offer.tax_credit_amount_remaining =
offer.tax_credit_amount_remaining - transaction.tax_credit_amount;
Expand Down
6 changes: 1 addition & 5 deletions pallets/afloat/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use sp_runtime::{
testing::Header,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPT summary of afee51 - eabfa5:

  • Removed type UncheckedExtrinsic
  • Changed type Block from Header to MockBlock
  • Changed type Block from Block to MockBlock
  • Changed type NodeBlock from Block to MockBlock
  • Changed type UncheckedExtrinsic from MockUncheckedExtrinsic to ()
  • Changed type Header from Header to Block

traits::{BlakeTwo256, IdentityLookup},
};
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
use frame_system::EnsureRoot;
use system::EnsureSigned;
Expand All @@ -26,9 +25,6 @@ parameter_types! {
// Configure a mock runtime to test the pallet.
frame_support::construct_runtime!(
pub enum Test where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
GatedMarketplace: pallet_gated_marketplace::{Pallet, Call, Storage, Event<T>},
Expand All @@ -55,7 +51,7 @@ impl system::Config for Test {
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type Version = ();
Expand Down
28 changes: 14 additions & 14 deletions pallets/bitcoin-vaults/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl<T: Config> Pallet<T> {
vault_members.clone().into_iter().try_for_each(|acc| {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPT summary of 046dcc - a963f9:

  • Added a check for if a user has an xpub when creating a vault
  • Updated an error message when a signer does not have the permissions needed to sign a proposal
  • Updated the logic for when a xpub is available
  • Updated logic for when a proposal can be finalized
  • Updated logic for when a vault can be broadcasted
  • Updated the logic for when a proposal can be broadcasted
  • Updated the logic for when a proposal can be retrieved from the network

// check if all users have an xpub
if !<XpubsByOwner<T>>::contains_key(acc.clone()) {
return Err(Error::<T>::XPubNotFound);
return Err(Error::<T>::XPubNotFound)
}
<VaultsBySigner<T>>::try_mutate(acc, |vault_vec| vault_vec.try_push(vault_id.clone()))
.map_err(|_| Error::<T>::SignerVaultLimit)
Expand Down Expand Up @@ -153,8 +153,8 @@ impl<T: Config> Pallet<T> {
ensure!(vault.is_vault_member(&signer), Error::<T>::SignerPermissionsNeeded);
// if its finalized then fire error "already finalized" or "already broadcasted"
ensure!(
proposal.status.eq(&ProposalStatus::Pending)
|| proposal.status.eq(&ProposalStatus::Finalized),
proposal.status.eq(&ProposalStatus::Pending) ||
proposal.status.eq(&ProposalStatus::Finalized),
Error::<T>::PendingProposalRequired
);
// signs must be greater or equal than threshold
Expand Down Expand Up @@ -265,7 +265,7 @@ impl<T: Config> Pallet<T> {
}
} else {
// xpub registered and the account doesnt own it: unavailable
return XpubStatus::Taken;
return XpubStatus::Taken
}
// Does the user owns the registered xpub? if yes, available
}
Expand Down Expand Up @@ -338,9 +338,9 @@ impl<T: Config> Pallet<T> {
pub fn get_pending_vaults() -> Vec<[u8; 32]> {
<Vaults<T>>::iter()
.filter_map(|(entry, vault)| {
if vault.descriptors.output_descriptor.is_empty()
&& (vault.offchain_status.eq(&BDKStatus::<T::VaultDescriptionMaxLen>::Pending)
|| vault.offchain_status.eq(
if vault.descriptors.output_descriptor.is_empty() &&
(vault.offchain_status.eq(&BDKStatus::<T::VaultDescriptionMaxLen>::Pending) ||
vault.offchain_status.eq(
&BDKStatus::<T::VaultDescriptionMaxLen>::RecoverableError(
BoundedVec::<u8, T::VaultDescriptionMaxLen>::default(),
),
Expand All @@ -356,11 +356,11 @@ impl<T: Config> Pallet<T> {
pub fn get_pending_proposals() -> Vec<[u8; 32]> {
<Proposals<T>>::iter()
.filter_map(|(id, proposal)| {
if proposal.psbt.is_empty()
&& (proposal
if proposal.psbt.is_empty() &&
(proposal
.offchain_status
.eq(&BDKStatus::<T::VaultDescriptionMaxLen>::Pending)
|| proposal.offchain_status.eq(
.eq(&BDKStatus::<T::VaultDescriptionMaxLen>::Pending) ||
proposal.offchain_status.eq(
&BDKStatus::<T::VaultDescriptionMaxLen>::RecoverableError(
BoundedVec::<u8, T::VaultDescriptionMaxLen>::default(),
),
Expand Down Expand Up @@ -393,7 +393,7 @@ impl<T: Config> Pallet<T> {
<Proposals<T>>::iter()
.filter_map(|(id, p)| {
if p.can_be_finalized() {
return Some(id);
return Some(id)
}
None
})
Expand Down Expand Up @@ -434,13 +434,13 @@ impl<T: Config> Pallet<T> {
let vec_body = response.body().collect::<Vec<u8>>();
let msj_str =
str::from_utf8(vec_body.as_slice()).unwrap_or("Error 400: Bad request");
return Err(Self::build_offchain_err(false, msj_str));
return Err(Self::build_offchain_err(false, msj_str))
},
500..=599 => {
let vec_body = response.body().collect::<Vec<u8>>();
let msj_str =
str::from_utf8(vec_body.as_slice()).unwrap_or("Error 500: Server error");
return Err(Self::build_offchain_err(false, msj_str));
return Err(Self::build_offchain_err(false, msj_str))
},
_ => return Err(Self::build_offchain_err(true, "Unknown error")),
}
Expand Down
12 changes: 6 additions & 6 deletions pallets/bitcoin-vaults/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ pub mod pallet {
// transactions without it

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPT summary of 67d442 - 632f22:

  • Changed the return type of if !signer.can_sign() from return; to return
  • Changed the return type of if tx_res.is_err() in do_insert_descriptors and do_insert_psbt from return Some(tx_res); to return Some(tx_res)
  • Added checks for signed payloads in ocw_insert_descriptors, ocw_insert_psbts, and ocw_finalize_psbts with return InvalidTransaction::BadProof.into() if the payloads are not verified

let signer = Signer::<T, T::AuthorityId>::any_account();
if !signer.can_sign() {
return;
return
}

// Check if this OCW can modify the vaults
Expand Down Expand Up @@ -745,7 +745,7 @@ pub mod pallet {
let tx_res =
Self::do_insert_descriptors(vault_payload.vault_id, descriptors, status);
if tx_res.is_err() {
return Some(tx_res);
return Some(tx_res)
}
None
})
Expand Down Expand Up @@ -775,7 +775,7 @@ pub mod pallet {
let tx_res =
Self::do_insert_psbt(proposal_psbt.proposal_id, bounded_psbt, status);
if tx_res.is_err() {
return Some(tx_res);
return Some(tx_res)
}
None
})
Expand Down Expand Up @@ -826,19 +826,19 @@ pub mod pallet {
match call {
Call::ocw_insert_descriptors { ref payload, ref signature } => {
if !SignedPayload::<T>::verify::<T::AuthorityId>(payload, signature.clone()) {
return InvalidTransaction::BadProof.into();
return InvalidTransaction::BadProof.into()
}
valid_tx(b"unsigned_extrinsic_with_signed_payload".to_vec())
}, // compiler complains if they aren't on different match arms
Call::ocw_insert_psbts { ref payload, ref signature } => {
if !SignedPayload::<T>::verify::<T::AuthorityId>(payload, signature.clone()) {
return InvalidTransaction::BadProof.into();
return InvalidTransaction::BadProof.into()
}
valid_tx(b"unsigned_extrinsic_with_signed_payload".to_vec())
},
Call::ocw_finalize_psbts { ref payload, ref signature } => {
if !SignedPayload::<T>::verify::<T::AuthorityId>(payload, signature.clone()) {
return InvalidTransaction::BadProof.into();
return InvalidTransaction::BadProof.into()
}
valid_tx(b"unsigned_extrinsic_with_signed_payload".to_vec())
},
Expand Down
6 changes: 1 addition & 5 deletions pallets/bitcoin-vaults/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@ use sp_runtime::{
traits::{BlakeTwo256, Extrinsic as ExtrinsicT, IdentifyAccount, IdentityLookup, Verify},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPT summary of 79c45d - 796819:

  • Removed the UncheckedExtrinsic type and replaced it with Block type.
  • Removed NodeBlock type.
  • Added ValidateUnsigned to the BitcoinVaults pallet.
  • Changed Header type to Block type in Config for Test.

//RuntimeAppPublic,
};
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
//use sp_runtime::generic::SignedPayload;
use sp_core::sr25519::Signature;

// Configure a mock runtime to test the pallet.
frame_support::construct_runtime!(
pub enum Test where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
BitcoinVaults: pallet_bitcoin_vaults::{Pallet, Call, Storage, Event<T>, ValidateUnsigned},
Expand Down Expand Up @@ -113,7 +109,7 @@ impl frame_system::Config for Test {
type Hashing = BlakeTwo256;
type AccountId = sp_core::sr25519::Public;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = ConstU64<250>;
type DbWeight = ();
Expand Down
6 changes: 1 addition & 5 deletions pallets/confidential-docs/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@ use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPT summary of 0cd5c6 - b355d3:

  • Removed definitions of UncheckedExtrinsic and NodeBlock
  • Changed Header to Block in system::Config

};

type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;

// Configure a mock runtime to test the pallet.
frame_support::construct_runtime!(
pub enum Test where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
ConfidentialDocs: pallet_confidential_docs::{Pallet, Call, Storage, Event<T>},
Expand All @@ -41,7 +37,7 @@ impl system::Config for Test {
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type Version = ();
Expand Down
6 changes: 3 additions & 3 deletions pallets/confidential-docs/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ impl<T: Config> GroupMember<T> {
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPT summary of 84881f - 6735c9:

  • Changed the logic of the can_remove_group_member function to require that the group member to be removed is not an owner, and that either the caller is an owner, or the caller is an admin and the group member to be removed was added by the caller.


pub fn can_remove_group_member(&self, group_member: &GroupMember<T>) -> bool {
group_member.role != GroupRole::Owner
&& (self.role == GroupRole::Owner
|| (self.role == GroupRole::Admin && group_member.authorizer == self.member))
group_member.role != GroupRole::Owner &&
(self.role == GroupRole::Owner ||
(self.role == GroupRole::Admin && group_member.authorizer == self.member))
}
}
4 changes: 2 additions & 2 deletions pallets/fruniques/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ scale-info = { default-features = false, version = "2.0.1", features = [
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPT summary of d76a5a - 2ee1e0:

  • Updated scale-info, frame-support, frame-system, frame-benchmarking, sp-runtime, pallet-uniques, pallet-balances, and pallet-rbac to use the polkadot-v1.0.0 branch from the paritytech/substrate repository.
  • Updated sp-core and sp-io in the dev-dependencies section to use the polkadot-v1.0.0 branch from the paritytech/substrate repository.

frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0", optional = true }
sp-runtime = { default-features = false, version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
pallet-uniques = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
pallet-rbac = { path = "../rbac/", default-features = false, version = "4.0.0-dev" }

[dev-dependencies]
sp-core = { default-features = false, version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-io = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }

[features]
Expand Down
23 changes: 12 additions & 11 deletions pallets/fruniques/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl<T: Config> Pallet<T> {
) -> AttributeValue<T> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPT summary of 140932 - a8e637:

  • Changed the attribute function to convert the attribute to a BoundedVec and handle errors when converting
  • Changed the collection_exists and instance_exists functions to return true if the collection/instance exists
  • Changed the create_frunique function to convert the NextFrunique to an ItemId and handle errors when minting
  • Changed the do_nft_division function to clone the collection argument
  • Changed the redeem function to clone the collection argument

if let Some(a) = pallet_uniques::Pallet::<T>::attribute(class_id, instance_id, key) {
return BoundedVec::<u8, T::ValueLimit>::try_from(a)
.expect("Error on converting the attribute to BoundedVec");
.expect("Error on converting the attribute to BoundedVec")
}
BoundedVec::<u8, T::ValueLimit>::default()
}
Expand All @@ -80,14 +80,14 @@ impl<T: Config> Pallet<T> {

pub fn collection_exists(class_id: &T::CollectionId) -> bool {
if let Some(_owner) = pallet_uniques::Pallet::<T>::collection_owner(*class_id) {
return true;
return true
}
false
}

pub fn instance_exists(class_id: &T::CollectionId, instance_id: &T::ItemId) -> bool {
if let Some(_owner) = pallet_uniques::Pallet::<T>::owner(*class_id, *instance_id) {
return true;
return true
}
false
}
Expand Down Expand Up @@ -182,15 +182,15 @@ impl<T: Config> Pallet<T> {
where
<T as pallet_uniques::Config>::ItemId: From<u32>,
{
let nex_item: ItemId = <NextFrunique<T>>::try_get(collection).unwrap_or(0);
<NextFrunique<T>>::insert(collection, nex_item + 1);
let nex_item: ItemId = <NextFrunique<T>>::try_get(collection.clone()).unwrap_or(0);
<NextFrunique<T>>::insert(collection.clone(), nex_item + 1);

let item = Self::u32_to_instance_id(nex_item);
pallet_uniques::Pallet::<T>::do_mint(collection, item, owner, |_| Ok(()))?;
pallet_uniques::Pallet::<T>::do_mint(collection.clone(), item, owner, |_| Ok(()))?;

pallet_uniques::Pallet::<T>::set_metadata(
frame_system::RawOrigin::Root.into(),
collection,
collection.clone(),
item.clone(),
metadata,
false,
Expand Down Expand Up @@ -314,7 +314,7 @@ impl<T: Config> Pallet<T> {
Self::do_mint(collection, owner.clone(), metadata.clone(), attributes)?;

if let Some(ref parent_info) = parent_info {
return Self::do_nft_division(collection, item, metadata, parent_info, owner);
return Self::do_nft_division(collection, item, metadata, parent_info, owner)
}

let frunique_data = FruniqueData {
Expand Down Expand Up @@ -382,7 +382,7 @@ impl<T: Config> Pallet<T> {
verified_by: None,
};

<FruniqueInfo<T>>::insert(collection, item, frunique_data);
<FruniqueInfo<T>>::insert(collection.clone(), item, frunique_data);

let frunique_child: ChildInfo<T> = ChildInfo {
collection_id: collection,
Expand Down Expand Up @@ -422,13 +422,14 @@ impl<T: Config> Pallet<T> {
ensure!(Self::collection_exists(&collection), Error::<T>::CollectionNotFound);
ensure!(Self::instance_exists(&collection, &item), Error::<T>::FruniqueNotFound);

let frunique_data: FruniqueData<T> = <FruniqueInfo<T>>::try_get(collection, item).unwrap();
let frunique_data: FruniqueData<T> =
<FruniqueInfo<T>>::try_get(collection.clone(), item).unwrap();

ensure!(!frunique_data.frozen, Error::<T>::FruniqueFrozen);
ensure!(!frunique_data.redeemed, Error::<T>::FruniqueAlreadyRedeemed);

<FruniqueInfo<T>>::try_mutate::<_, _, _, DispatchError, _>(
collection,
collection.clone(),
item,
|frunique_data| -> DispatchResult {
let frunique = frunique_data.as_mut().ok_or(Error::<T>::FruniqueNotFound)?;
Expand Down
Loading
Loading