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

functions selling any item at a fix price #98

Merged
merged 8 commits into from
Sep 4, 2024

Conversation

mubarak23
Copy link
Contributor

@mubarak23 mubarak23 commented Aug 26, 2024

PR for issue: #83

The function implements a Cairo contract named StrategySaleAnyItemAtFixedPrice This contract manages the sale of items (identified by token_id) at a fixed price, with specific features such as setting prices, handling bids, and upgrading the contract.

Key functionalities:

  1. Initialization (constructor):

    • Initializes the contract with the owner's address and a protocol fee.
  2. Updating Protocol Fee (update_protocol_fee):

    • Allows the owner to update the protocol fee, which is the fee applied to transactions.
  3. Getting Protocol Fee (protocol_fee):

    • Retrieves the current protocol fee.
  4. Setting an Item for Sale (set_item_sale):

    • Allows the owner of a specific token_id to list it for sale. It checks if the caller is the token owner and emits an event once the item is listed.
  5. Setting Price for an Item (set_price_for_item):

    • Allows a buyer to set a price for a listed item. It verifies that the buyer is not the token owner, checks if the bid price is different from any existing bids by the buyer, and then records the bid, emitting an event for the action.
  6. Executing Buyer Bids (can_execute_buyer_bid):

    • Checks if a buyer's bid can be executed. It verifies that the token has been listed by the seller and compares the buyer's bid price against the existing bid to determine if the bid is executable.
  7. Contract Upgrading (upgrade):

    • Allows the contract owner to upgrade the contract implementation using a new ClassHash, ensuring only the owner can perform this action.

Events:

  • ItemForSaleAdded: Emitted when a new item is listed for sale.
  • SetPriceForItemByBuyer: Emitted when a buyer sets a price for a listed item.

This contract integrates with StarkNet's components for ownership (OwnableComponent) and upgradability (UpgradeableComponent), ensuring that only authorized users can perform sensitive operations like updating the protocol fee and upgrading the contract.

@mubarak23
Copy link
Contributor Author

@0xandee This PR is available for Review

@0xandee
Copy link
Collaborator

0xandee commented Aug 28, 2024

Can you adding comments or quick docs so I can have better understanding how it works @mubarak23

@mubarak23
Copy link
Contributor Author

sure, i will add it

@mubarak23
Copy link
Contributor Author

Can you adding comments or quick docs so I can have better understanding how it works @mubarak23

i added description on how the contract work

@mubarak23 mubarak23 requested a review from 0xandee September 3, 2024 16:59
@mubarak23 mubarak23 requested a review from 0xandee September 4, 2024 09:49
@0xandee 0xandee merged commit 6e8e9cc into Flex-NFT-Marketplace:main Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants