-
Notifications
You must be signed in to change notification settings - Fork 4
Feature/afloat pallet #427
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…s when deleting users on afloat pallet
The Offer and Transaction structs are added to the codebase to represent offers and transactions in the system. The OfferStatus enum is also added to represent the status of an offer. These additions will allow for better representation of the data in the system and improve the overall functionality of the codebase.
🚀 feat(afloat): add functionality to store offers and transactions This commit adds two new storage maps to the Afloat pallet. The `AfloatOffers` map stores offers made on Afloat's frunique collection, while the `AfloatTransactions` map stores transactions made on Afloat. The `AfloatOffers` map is indexed by the `ItemId` type from the `pallet_uniques` pallet, while the `AfloatTransactions` map is indexed by a new type `StorageId`, which is a 32-byte array. This commit also adds functionality to store offers and transactions in the respective storage maps.
…ruct The OfferType enum is added to the types.rs file, which contains two variants: Sell and Buy. The Offer struct is updated to include the offer_type field, which is of type OfferType. The CreateOfferArgs enum is also added to the file, which contains two variants: Sell and Buy. These variants contain the same fields as the Offer struct. This change allows for more flexibility in creating offers, as it is now possible to specify whether an offer is a buy or sell offer.
This change improves the clarity of the code by using a more descriptive type name. The StorageId type is a custom type alias that is defined elsewhere in the codebase.
…te_buy_order to accept_offer The function names were changed to better reflect their purpose. The create_offer function now takes a CreateOfferArgs struct that contains the necessary arguments for creating a sell or buy order. The accept_offer function now takes an offer_id instead of the item_id, price, and percentage arguments. 🔨 refactor(types.rs): update CreateOfferArgs to use generic types The CreateOfferArgs enum now uses generic types to allow for more flexibility in the types of the arguments. The tax_credit_id field now uses the ItemId type from the pallet_uniques module. The price_per_credit field now uses the Balance type from the Config trait.
…dit_id The types of price_per_credit, fee, and tax_credit_id have been changed to T::Balance and <T as pallet_uniques::Config>::ItemId respectively. This change was made to improve consistency with the types used in the rest of the codebase and to ensure that the types are compatible with the configuration of the pallet_uniques module.
This commit removes unnecessary whitespace in the functions.rs file.
…ubstrate into feature/afloat-pallet
The commented out code in the `Pallet` implementation and the `Offer` struct are removed as they are not being used. The `pallet_uniques::Config` trait is used in the `AfloatOffers` storage map instead of the `ItemId` type. The `price_per_credit` and `fee` fields in the `Offer` struct are changed to use the `T::Balance` type instead of `u32`.
✨ feat(afloat): add cid field to User struct The Offer struct has been refactored to remove the fee field, which is not currently being used. The User struct has been refactored to remove fields that are not currently being used and to add a new cid field. The cid field is a unique identifier for the user.
This commit adds a new file, FruniquesImplementation, which contains an XML diagram of the FruniquesImplementation. The diagram shows the flow of events that occur when a user creates a tax credit with n editions and places a sell order for this tax credit. It also shows the flow of events that occur when a user places a buy offer for a m amount of tax credit. The diagram is intended to help developers understand the implementation of Fruniques. 🔨 refactor(afloat): modify SignUpArgs and UpdateUserArgs structs The SignUpArgs and UpdateUserArgs structs have been modified to include only the necessary fields for the user registration and editing. The cid and group fields have been added to the User struct to improve the user's identification.
This commit adds a new file, fruniquesImplementation.drawio, which contains a diagram of the implementation of the fruniques feature in the afloat pallet. This diagram will be used to help understand the implementation of the feature and to aid in future development. 🔥 chore(FruniquesImplementation): remove FruniquesImplementation file The file FruniquesImplementation was removed from the repository. It contained an XML diagram that was no longer relevant to the project. 🔨 refactor(afloat): rename first_name, last_name, email, cpa_id, and tax_authority_id fields to cid, group, and license_number ✨ feat(afloat): add expiration_date field to Offer struct and CreateOfferArgs enum This commit renames several fields in the User struct to improve consistency with the naming conventions. The fields first_name, last_name, email, cpa_id, and tax_authority_id are now named cid, group, and license_number, respectively. Additionally, the Offer struct now has an expiration_date field, and the CreateOfferArgs enum has been updated to include an expiration_date field for both the Buy and Sell variants.
aeab446
to
6eff77e
Compare
🔧 chore(afloat): increase ShortString size limit to 55 The UserInfo insert was using the wrong variable, admin, instead of creator. This has been fixed to use creator. The ShortString type size limit has been increased to 55 to allow for longer strings to be stored.
The creator and admin user cids and groups have been updated to match the new values in the HCD network. This is a security measure to ensure that the correct users are being used in the pallet.
…lity This commit adds the `do_admin_edit_user` function to the `functions.rs` file, which allows an admin to edit a user's `cid` and `group` fields. The `AdminEdit` variant is added to the `UpdateUserArgs` enum in the `types.rs` file to support this functionality. The `do_admin_edit_user` function is then called in the `pallet` module's `do_update_user` function in the `lib.rs` file when the `AdminEdit` variant is used. This feature allows admins to update a user's `cid` and `group` fields, which can be useful for managing user accounts.
The authorization check for `is_admin_or_owner` was redundant in the `do_admin_edit_user` and `do_delete_user` functions as it was already checked in the `ensure!(who.clone() == address || Self::is_admin_or_owner(who.clone()), Error::<T>::Unauthorized);` statement.
The user authorization logic in UpdateUserArgs was incorrect. The `ensure!` macro was checking for the opposite of what was intended, which resulted in unauthorized users being able to perform actions they shouldn't be able to. This has been fixed by changing the `ensure!` macro to check for the correct condition.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add MP to GM and RBAC to Afloat
Overview
MP to GM
This change enables the use of mapped-assets as the currency for marketplaces and disables the previous use of Currency.
RBAC to Afloat
This change introduces roles into the pallet to have more control over user actions.
Tickets
List the tickets of the PR linked
Implementation notes
When calling create_marketplace() now it is necessary to pass an 'assed_id' as an argument. That assed_id is saved into the Marketplace struct, and it's used on do_take_sell_offer() and do_take_buy_offer() functions to perform the transfer of the given asset.
Test coverage
All unit tests for GM have been updated.