MoonSHRD / UniversalNFTMarketplace

Universal NFT Marketplace
Other
9 stars 0 forks source link

Feat/tokensale as singleton #72

Closed JackBekket closed 2 years ago

JackBekket commented 2 years ago

MAJOR CHANGES

Now tokensale is a singleton, every sale of every token is hold on this single contract

You should now create sale from factory using createItemSale721(address payable organizer, uint price, MSNFT token,uint sale_limit, CurrenciesERC20.CurrencyERC20 currency_, uint master_id_)

It will create new struct SaleInfo tethered to master_id as MSaleInfo[master_id]

SaleInfo struct look like

 struct SaleInfo
    {
        bool initialized;
        uint256  _master_id;            // master id of token being sold (possible duplicate)
        MSNFT.RarityType _rarity_type;  // rarity of token being sold
        mapping (CurrenciesERC20.CurrencyERC20 => uint256) _price;      // map from currency to price
        mapping (CurrenciesERC20.CurrencyERC20 => uint256) currency_balances;   // map from currency to balance

        uint _sale_limit;
        uint _sold_count;
        // Address where funds are collected (author wallet)
        address payable _wallet;
    }
All global variables tethered to master_id now is in this struct (and has been removed from global state)
todo[bot] commented 2 years ago

-- delete this

https://github.com/MoonSHRD/UniversalNFTMarketplace/blob/84d7d6b37585e5ae57455a09e246e0d1075df61d/contracts/721/singleton/TokenSaleSingleton.sol#L61-L66


This comment was generated by todo based on a TODO comment in 84d7d6b37585e5ae57455a09e246e0d1075df61d in #72. cc @MoonSHRD.
todo[bot] commented 2 years ago

used to buy tokens for ether (deprecated)

https://github.com/MoonSHRD/UniversalNFTMarketplace/blob/84d7d6b37585e5ae57455a09e246e0d1075df61d/contracts/721/singleton/TokenSaleSingleton.sol#L119-L124


This comment was generated by todo based on a todo comment in 84d7d6b37585e5ae57455a09e246e0d1075df61d in #72. cc @MoonSHRD.
todo[bot] commented 2 years ago

WARNING -- it can be 0 if buyer mismatch currency, but such transaction will fail at pre-validate purchase check!

https://github.com/MoonSHRD/UniversalNFTMarketplace/blob/84d7d6b37585e5ae57455a09e246e0d1075df61d/contracts/721/singleton/TokenSaleSingleton.sol#L405-L410


This comment was generated by todo based on a todo comment in 84d7d6b37585e5ae57455a09e246e0d1075df61d in #72. cc @MoonSHRD.
JackBekket commented 2 years ago

@JackBekket @aislot

Переделал tokensale как сингл-тон, в процессе там довольно сильные изменения, надо написать тесты и замерить газ теперь