/
MarketHandlerLib.sol
75 lines (54 loc) · 2.16 KB
/
MarketHandlerLib.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../../interfaces/IMarketController.sol";
import "../../domain/SeenTypes.sol";
import "../diamond/DiamondLib.sol";
/**
* @title MarketHandlerLib
*
* @dev Provides access to the the MarketHandler Storage and Intitializer slots for MarketHandler facets
*
* @author Cliff Hall <cliff@futurescale.com> (https://twitter.com/seaofarrows)
*/
library MarketHandlerLib {
bytes32 constant MARKET_HANDLER_STORAGE_POSITION = keccak256("seen.haus.market.handler.storage");
bytes32 constant MARKET_HANDLER_INITIALIZERS_POSITION = keccak256("seen.haus.market.handler.initializers");
struct MarketHandlerStorage {
// map a consignment id to an audience
mapping(uint256 => SeenTypes.Audience) audiences;
//s map a consignment id to a sale
mapping(uint256 => SeenTypes.Sale) sales;
// @dev map a consignment id to an auction
mapping(uint256 => SeenTypes.Auction) auctions;
// map an address to ETH credit available to withdraw
mapping(address => uint256) addressToEthCredit;
}
struct MarketHandlerInitializers {
// AuctionBuilderFacet initialization state
bool auctionBuilderFacet;
// AuctionRunnerFacet initialization state
bool auctionRunnerFacet;
// AuctionEnderFacet initialization state
bool auctionEnderFacet;
// SaleBuilderFacet initialization state
bool saleBuilderFacet;
// SaleRunnerFacet initialization state
bool saleRunnerFacet;
// SaleRunnerFacet initialization state
bool saleEnderFacet;
// EthCreditFacet initialization state
bool ethCreditRecoveryFacet;
}
function marketHandlerStorage() internal pure returns (MarketHandlerStorage storage mhs) {
bytes32 position = MARKET_HANDLER_STORAGE_POSITION;
assembly {
mhs.slot := position
}
}
function marketHandlerInitializers() internal pure returns (MarketHandlerInitializers storage mhi) {
bytes32 position = MARKET_HANDLER_INITIALIZERS_POSITION;
assembly {
mhi.slot := position
}
}
}