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

Feature/bump v1.3.0 #25

Merged
merged 36 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
21370f5
update format to match the one for polkadot
tlacloc Oct 18, 2023
de38b35
📦 chore(rust-toolchain.toml): add rust-toolchain.toml file to specify…
tlacloc Oct 18, 2023
c796692
🔧 chore(Cargo.toml): update sp-runtime dependency to remove version c…
tlacloc Oct 18, 2023
6ac39b0
🔄 chore(rust-toolchain.toml): update Rust toolchain to nightly-2023-0…
tlacloc Oct 18, 2023
d53eb3e
🔧 chore(lib.rs): update Scale trait implementation to use BlockNumber…
tlacloc Oct 18, 2023
9dfef1d
📦 chore(pallets): update dependency versions in Cargo.toml files
tlacloc Oct 18, 2023
d384a53
wip update mapped assets
tlacloc Oct 24, 2023
17d6130
🚀 chore(mapped-assets): update dependencies in Cargo.toml to latest v…
tlacloc Oct 24, 2023
5e443de
update deps
tlacloc Oct 24, 2023
711e290
🚀 chore(Cargo.toml): update dependencies versions to improve compatib…
tlacloc Oct 24, 2023
8dc111c
🚀 chore(Cargo.toml): update dependencies versions for lite-json, fram…
tlacloc Oct 24, 2023
64f1f0d
🔍 chore(.gitignore): add log files to be ignored by git
tlacloc Oct 24, 2023
0187673
🔧 chore(lib.rs): add #[derive(Default)] to the GenesisConfig struct i…
tlacloc Oct 24, 2023
b05e7bf
Fix build issues polkadotv1 (#22)
sebastianmontero Oct 27, 2023
ddc4779
update deps
tlacloc Oct 30, 2023
d61dc78
🐛 fix(mock.rs): change Balance type from u128 to u64 to reduce memory…
tlacloc Oct 30, 2023
1970cf8
🔧 fix(tests.rs): update struct field names in sign_up_works, update_u…
tlacloc Oct 30, 2023
13d45c2
update tests
tlacloc Oct 30, 2023
d19802d
🐛 fix(functions.rs): remove unnecessary mutability of transaction var…
tlacloc Oct 30, 2023
cb14366
🔧 chore(lib.rs): remove unused code and comments for improved code re…
tlacloc Oct 31, 2023
abcf44e
🔀 chore(lib.rs): refactor BDKServicesURL initialization to use self.b…
tlacloc Oct 31, 2023
14c8bbc
Updated polkadot dependencies to v1.2.0. sp-io is no longer exported …
sebastianmontero Nov 1, 2023
8cac63a
Fixed mock afloat assets callback handler.
sebastianmontero Nov 1, 2023
2bf4484
Merged latest changes
sebastianmontero Nov 3, 2023
665298f
Updated polkadot version to 1.3
sebastianmontero Nov 3, 2023
6466cef
Pallet balances added RuntimeFreezeReason type, added definition for …
sebastianmontero Nov 3, 2023
6f90b30
Updated confidential docs pallet storage version.
sebastianmontero Nov 14, 2023
d35fcfa
Updated dependencies to use tag instead of branch
sebastianmontero Nov 15, 2023
73cd134
Updated storage version for those pallets that dont have migrations t…
sebastianmontero Nov 15, 2023
1cca491
Developed migration fro the fruniques pallet. Incremented fruniques p…
sebastianmontero Dec 4, 2023
1c1b187
Merge branch 'main' of github.com:hashed-io/hashed-pallets into featu…
tlacloc Dec 7, 2023
f99076b
🐛 fix(afloat): update pallet-timestamp dependency version to "4.0.0-d…
tlacloc Dec 7, 2023
5712308
🐛 fix(functions.rs): fix import statement formatting to follow conven…
tlacloc Dec 7, 2023
8ddb136
🔧 chore(lib.rs): reorder import statements for better readability and…
tlacloc Dec 7, 2023
3e7ff6c
🔒 chore(functions.rs): change visibility of get_timestamp_in_millisec…
tlacloc Dec 7, 2023
9bfc152
update dep
tlacloc Dec 7, 2023
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
401 changes: 145 additions & 256 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pallets/afloat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", tag =
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", tag = "v1.3.0-rc1", default-features = false }
Copy link

Choose a reason for hiding this comment

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

GPT summary of e344d4 - a36bc6:

  • The version of the pallet-timestamp dependency was updated from v1.3.0-rc1 to 4.0.0-dev
  • The version of the pallet-fruniques dependency was updated from 0.1.0-dev
  • The version of the pallet-rbac dependency was updated from 4.0.0-dev
  • The version of the pallet-gated-marketplace dependency was updated from 4.0.0-dev

pallet-uniques = { git = "https://github.com/paritytech/polkadot-sdk", tag = "v1.3.0-rc1", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", tag = "v1.3.0-rc1", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", tag = "v1.3.0-rc1", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", tag = "v1.3.0-rc1", default-features = false, version = "4.0.0-dev" }
pallet-fruniques = { path = "../fruniques", default-features = false, version = "0.1.0-dev" }
pallet-rbac = { path = "../rbac/", default-features = false, version = "4.0.0-dev" }
pallet-gated-marketplace = { path = "../gated-marketplace/", default-features = false, version = "4.0.0-dev" }
Expand Down
43 changes: 27 additions & 16 deletions pallets/afloat/src/functions.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;
Copy link

Choose a reason for hiding this comment

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

GPT summary of d4b906 - 6a0c05:

  • Updated the imports to use the pallet_prelude crate
  • Replaced the usage of the UnixTime trait with the get_timestamp_in_milliseconds method from the pallet_gated_marketplace pallet
  • Added the cid_creator, group, created_by, created_date, last_modified_by, and last_modified_date fields to the UserInfo struct
  • Updated the give_role_to_user method to take in the cid_creator and group fields
  • Updated the cancel_offer method to set the cancellation_date field to the current timestamp and set the status to cancelled

use crate::types::*;
use frame_support::{pallet_prelude::*, traits::UnixTime};
use frame_support::pallet_prelude::*;
use frame_system::{pallet_prelude::*, RawOrigin};
use pallet_fruniques::types::{Attributes, CollectionDescription, FruniqueRole, ParentInfo};
use pallet_gated_marketplace::types::{Marketplace, MarketplaceRole};
Expand Down Expand Up @@ -104,9 +104,10 @@ impl<T: Config> Pallet<T> {
cid_creator: ShortString::try_from(b"HCD:afloat".to_vec()).unwrap(),
group: ShortString::try_from(b"afloat".to_vec()).unwrap(),
created_by: Some(creator.clone()),
created_date: Some(T::TimeProvider::now().as_secs()),
created_date: pallet_gated_marketplace::Pallet::<T>::get_timestamp_in_milliseconds(),
last_modified_by: Some(creator.clone()),
last_modified_date: Some(T::TimeProvider::now().as_secs()),
last_modified_date:
pallet_gated_marketplace::Pallet::<T>::get_timestamp_in_milliseconds(),
};
<UserInfo<T>>::insert(creator.clone(), creator_user);
Self::give_role_to_user(creator.clone(), AfloatRole::Owner)?;
Expand All @@ -117,9 +118,11 @@ impl<T: Config> Pallet<T> {
cid_creator: ShortString::try_from(b"afloat".to_vec()).unwrap(),
group: ShortString::try_from(b"afloat".to_vec()).unwrap(),
created_by: Some(admin.clone()),
created_date: Some(T::TimeProvider::now().as_secs()),
created_date: pallet_gated_marketplace::Pallet::<T>::get_timestamp_in_milliseconds(
),
last_modified_by: Some(admin.clone()),
last_modified_date: Some(T::TimeProvider::now().as_secs()),
last_modified_date:
pallet_gated_marketplace::Pallet::<T>::get_timestamp_in_milliseconds(),
};
<UserInfo<T>>::insert(admin.clone(), admin_user);
Self::give_role_to_user(admin, AfloatRole::Admin)?;
Expand Down Expand Up @@ -161,9 +164,11 @@ impl<T: Config> Pallet<T> {
cid_creator,
group,
created_by: Some(actor.clone()),
created_date: Some(T::TimeProvider::now().as_secs()),
created_date:
pallet_gated_marketplace::Pallet::<T>::get_timestamp_in_milliseconds(),
last_modified_by: Some(actor.clone()),
last_modified_date: Some(T::TimeProvider::now().as_secs()),
last_modified_date:
pallet_gated_marketplace::Pallet::<T>::get_timestamp_in_milliseconds(),
};
<UserInfo<T>>::insert(user_address.clone(), user);
Self::give_role_to_user(user_address.clone(), AfloatRole::BuyerOrSeller)?;
Expand All @@ -175,9 +180,11 @@ impl<T: Config> Pallet<T> {
cid_creator,
group,
created_by: Some(actor.clone()),
created_date: Some(T::TimeProvider::now().as_secs()),
created_date:
pallet_gated_marketplace::Pallet::<T>::get_timestamp_in_milliseconds(),
last_modified_by: Some(actor.clone()),
last_modified_date: Some(T::TimeProvider::now().as_secs()),
last_modified_date:
pallet_gated_marketplace::Pallet::<T>::get_timestamp_in_milliseconds(),
};
<UserInfo<T>>::insert(user_address.clone(), user);
Self::give_role_to_user(user_address.clone(), AfloatRole::CPA)?;
Expand Down Expand Up @@ -225,7 +232,8 @@ impl<T: Config> Pallet<T> {
<UserInfo<T>>::try_mutate::<_, _, DispatchError, _>(user_address.clone(), |user| {
let user = user.as_mut().ok_or(Error::<T>::FailedToEditUserAccount)?;

user.last_modified_date = Some(T::TimeProvider::now().as_secs());
user.last_modified_date =
pallet_gated_marketplace::Pallet::<T>::get_timestamp_in_milliseconds();
user.last_modified_by = Some(actor.clone());
user.cid = cid;
user.cid_creator = cid_creator;
Expand All @@ -246,7 +254,8 @@ impl<T: Config> Pallet<T> {
<UserInfo<T>>::try_mutate::<_, _, DispatchError, _>(user_address.clone(), |user| {
let user = user.as_mut().ok_or(Error::<T>::FailedToEditUserAccount)?;

user.last_modified_date = Some(T::TimeProvider::now().as_secs());
user.last_modified_date =
pallet_gated_marketplace::Pallet::<T>::get_timestamp_in_milliseconds();
user.last_modified_by = Some(actor.clone());
user.cid = cid;
user.cid_creator = cid_creator;
Expand Down Expand Up @@ -339,7 +348,7 @@ impl<T: Config> Pallet<T> {
tax_credit_amount,
tax_credit_amount_remaining: tax_credit_amount.into(),
price_per_credit: price,
creation_date: T::TimeProvider::now().as_secs(),
creation_date: T::Timestamp::now().into(),
expiration_date,
tax_credit_id: item_id,
creator_id: authority.clone(),
Expand Down Expand Up @@ -373,7 +382,7 @@ impl<T: Config> Pallet<T> {
tax_credit_amount,
tax_credit_amount_remaining: tax_credit_amount.into(),
price_per_credit: price,
creation_date: T::TimeProvider::now().as_secs(),
creation_date: T::Timestamp::now().into(),
expiration_date,
tax_credit_id: item_id,
creator_id: authority.clone(),
Expand Down Expand Up @@ -447,7 +456,7 @@ impl<T: Config> Pallet<T> {
//ensure offer is a sell offer
ensure!(offer.offer_type == OfferType::Sell, Error::<T>::WrongOfferType);
//ensure offer is not expired
ensure!(offer.expiration_date > T::TimeProvider::now().as_secs(), Error::<T>::OfferExpired);
ensure!(offer.expiration_date > T::Timestamp::now().into(), Error::<T>::OfferExpired);
//ensure offer is not cancelled
ensure!(offer.cancellation_date.is_none(), Error::<T>::OfferCancelled);
//ensure offer is not taken
Expand Down Expand Up @@ -963,7 +972,8 @@ impl<T: Config> Pallet<T> {
OfferStatus::CREATED => {
<AfloatOffers<T>>::try_mutate(order_id, |offer| -> DispatchResult {
let offer = offer.as_mut().ok_or(Error::<T>::OfferNotFound)?;
offer.cancellation_date = Some(T::TimeProvider::now().as_secs());
offer.cancellation_date =
pallet_gated_marketplace::Pallet::<T>::get_timestamp_in_milliseconds();
offer.status = OfferStatus::CANCELLED;
Ok(())
})?;
Expand All @@ -972,7 +982,8 @@ impl<T: Config> Pallet<T> {
OfferStatus::TF_PENDING_SIGNATURE => {
<AfloatOffers<T>>::try_mutate(order_id, |offer| -> DispatchResult {
let offer = offer.as_mut().ok_or(Error::<T>::OfferNotFound)?;
offer.cancellation_date = Some(T::TimeProvider::now().as_secs());
offer.cancellation_date =
pallet_gated_marketplace::Pallet::<T>::get_timestamp_in_milliseconds();
offer.status = OfferStatus::CANCELLED;
Ok(())
})?;
Expand Down
7 changes: 5 additions & 2 deletions pallets/afloat/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ pub mod types;
pub mod pallet {
Copy link

Choose a reason for hiding this comment

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

GPT summary of 68e901 - 7bbf98:

  • Added Time trait from frame_support::traits
  • Added Scale trait from sp_runtime::traits
  • Added TimestampError event
  • Changed UnixTime trait to Time trait in RuntimeEvent type
  • Added NewUser event
  • Added deposit_event fn for NewUser event
  • Added UserEdited event

use frame_support::{
pallet_prelude::*,
traits::{Currency, UnixTime},
traits::{Currency, Time},
};
use frame_system::{pallet_prelude::*, RawOrigin};
use pallet_fruniques::types::{Attributes, CollectionDescription, FruniqueRole, ParentInfo};
use pallet_gated_marketplace::types::*;
use sp_runtime::traits::Scale;
const STORAGE_VERSION: StorageVersion = StorageVersion::new(0);

use crate::types::*;
Expand All @@ -37,7 +38,7 @@ pub mod pallet {
+ pallet_uniques::Config
{
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
type TimeProvider: UnixTime;

type Rbac: RoleBasedAccessControl<Self::AccountId>;
// type RemoveOrigin: EnsureOrigin<Self::RuntimeOrigin>;
type Currency: Currency<Self::AccountId>;
Expand All @@ -54,6 +55,8 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// Timestamp was not generated correctly
TimestampError,
// New user created
NewUser(T::AccountId),
// User edited
Expand Down
1 change: 0 additions & 1 deletion pallets/afloat/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ impl system::Config for Test {

Copy link

Choose a reason for hiding this comment

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

GPT summary of 8b1eec - b3edb9:

  • Removed type TimeProvider from the pallet_afloat::Config implementation for Test.
  • Added type Currency to the pallet_afloat::Config implementation for Test.
  • Added type Rbac to the pallet_afloat::Config implementation for Test.

impl pallet_afloat::Config for Test {
type RuntimeEvent = RuntimeEvent;
type TimeProvider = pallet_timestamp::Pallet<Self>;
//type RemoveOrigin = frame_system::EnsureSigned<Self::AccountId>;
type Currency = pallet_balances::Pallet<Self>;
type Rbac = RBAC;
Expand Down
1 change: 1 addition & 0 deletions pallets/fruniques/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mod tests;
// mod benchmarking;
Copy link

Choose a reason for hiding this comment

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

GPT summary of 30b1c3 - 9b50e9:

  • Added a new module called migration


mod functions;
pub mod migration;
pub mod types;

#[frame_support::pallet]
Expand Down
68 changes: 68 additions & 0 deletions pallets/fruniques/src/migration.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
use crate::{
Copy link

Choose a reason for hiding this comment

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

GPT summary of None - 032f12:

  • Added use statements for crate, frame_support, and sp_runtime.
  • Added storage aliases for FruniqueCnt, FruniqueParent, and FruniqueChild.
  • Added MigrateToV1 struct and OnRuntimeUpgrade implementation.
  • If version is < 1, clear FruniqueParent and FruniqueChild storage items, set version to 1, and log.
  • Otherwise log that upgrade wasn't run.

types::{CollectionId, ItemId},
*,
};
use frame_support::{pallet_prelude::*, traits::OnRuntimeUpgrade};

#[cfg(feature = "try-runtime")]
use sp_runtime::TryRuntimeError;

/// The log target.
const TARGET: &'static str = "runtime::fruniques::migration";

pub mod v0 {
use super::*;
/// The actual type isn't important, as we only delete the key in the state.
#[frame_support::storage_alias]
pub(super) type FruniqueCnt<T: Config> = StorageValue<Pallet<T>, (), ValueQuery>;

/// The actual type isn't important, as we only delete the key in the state.
#[frame_support::storage_alias]
pub(super) type FruniqueParent<T: Config> = StorageDoubleMap<
Pallet<T>,
Blake2_128Concat,
CollectionId,
Blake2_128Concat,
ItemId, // FruniqueId
(), // ParentId and flag if it inherit attributes
ValueQuery,
>;

/// The actual type isn't important, as we only delete the key in the state.
#[frame_support::storage_alias]
pub(super) type FruniqueChild<T: Config> = StorageDoubleMap<
Pallet<T>,
Blake2_128Concat,
CollectionId,
Blake2_128Concat,
ItemId,
(),
ValueQuery,
>;

pub struct MigrateToV1<T>(sp_runtime::sp_std::marker::PhantomData<T>);

impl<T: Config> OnRuntimeUpgrade for MigrateToV1<T> {
fn on_runtime_upgrade() -> Weight {
let onchain_version = Pallet::<T>::on_chain_storage_version();
let mut writes = 0;
if onchain_version < 1 {
FruniqueCnt::<T>::kill();
let result = FruniqueParent::<T>::clear(1, None); //Assuming that the storage is empty
if result.maybe_cursor.is_some() {
log::info!(target: TARGET, "Failed to kill FruniqueParent storage item");
}
let result = FruniqueChild::<T>::clear(1, None); //Assuming that the storage is empty
if result.maybe_cursor.is_some() {
log::info!(target: TARGET, "Failed to kill FruniqueChild storage item");
}
StorageVersion::new(1).put::<Pallet<T>>();
writes = 4;
log::info!(target: TARGET, "Migrated storage to version 1");
} else {
log::info!(target: TARGET, "Upgrade not run as pallet version is: {:?}", onchain_version);
}
T::DbWeight::get().reads_writes(writes, 1)
}
}
}
2 changes: 1 addition & 1 deletion pallets/gated-marketplace/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@ impl<T: Config> Pallet<T> {
Ok(())
Copy link

Choose a reason for hiding this comment

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

GPT summary of fffca8 - f3ad44:

  • Changed the get_timestamp_in_milliseconds function from private to public.

}

fn get_timestamp_in_milliseconds() -> Option<u64> {
pub fn get_timestamp_in_milliseconds() -> Option<u64> {
let timestamp: u64 = T::Timestamp::now().into();

Some(timestamp)
Expand Down
2 changes: 1 addition & 1 deletion pallets/mapped-assets/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ pub(crate) fn new_test_ext() -> sp_io::TestExternalities {
config.assimilate_storage(&mut storage).unwrap();
Copy link

Choose a reason for hiding this comment

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

GPT summary of 27e096 - f32c52:

  • Changed the link in the comment from https://github.com/paritytech/substrate/issues/10479 to https://github.com/paritytech/polkadot-sdk/issues/10479


let mut ext: sp_io::TestExternalities = storage.into();
// Clear thread local vars for https://github.com/paritytech/substrate/issues/10479.
// Clear thread local vars for https://github.com/paritytech/polkadot-sdk/issues/10479.
ext.execute_with(|| take_hooks());
ext.execute_with(|| System::set_block_number(1));
ext
Expand Down
Loading