/
ProShopBase.sol
97 lines (74 loc) · 2.19 KB
/
ProShopBase.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
pragma solidity ^0.4.24;
import "openzeppelin-solidity/contracts/token/ERC721/ERC721Token.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "./AccessControl.sol";
import "./StockRoomInterface.sol";
/**
* @title ProShopBase
* @notice Defines collections, mappings, and structs for the sales side of the In-game Pro Shop System
*/
contract ProShopBase is ERC721Token, AccessControl {
using SafeMath for uint256;
constructor() public ERC721Token(TOKEN_NAME, TOKEN_SYMBOL) {}
StockRoomInterface internal stockRoom;
/**
* @dev modifier to scope access to owner of given shop
*/
modifier onlyShopOwner(uint256 _shopId) {
address owner = stockRoom.getShopOwner(_shopId);
require(msg.sender == owner);
_;
}
/**
* @notice Name of the non fungible token
*/
string public constant TOKEN_NAME = "InAppProShopItem";
/**
* @notice Symbol of the non fungible token
*/
string public constant TOKEN_SYMBOL = "IAPS";
/**
* @notice All of the Items
*/
Item[] public items;
/**
* @dev Mapping of SKU id to Item list
*/
mapping (uint256 => uint256[]) public skuItems;
/**
* @dev Mapping of Shop ID to SKU list
*/
mapping (uint256 => uint256[]) public shopItems;
/**
* @dev Mapping of Owner Address to list of owned Items
*/
mapping (address => uint256[]) public ownedItems;
/**
* @dev Mapping of Shop ID to its available Ether balance
*/
mapping (uint256 => uint256) public shopBalances;
/**
* @notice The franchise owner's available balance
*/
uint256 public franchiseBalance;
/**
* @notice The percentage of each transaction taken by the franchise
* Must be between 0 and 100
*/
uint256 public franchiseFeePercent;
/**
* @notice Structure of a Pro Shop Item
*/
struct Item {
// Owner of the item
address owner;
// The shop this item belongs to
uint256 shopId;
// The id of this item
uint256 itemId;
// Id of SKU of this item
uint256 skuId;
// Has the item been consumed?
bool consumed;
}
}