Repository navigation
Expand file tree
/
Copy pathBase.sol
More file actions
73 lines (63 loc) · 2.24 KB
/
Copy pathBase.sol
File metadata and controls
73 lines (63 loc) · 2.24 KB
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
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "hardhat/console.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
struct User {
// The user's current wallet; mutable
address wallet;
// The IPFS address of the user's video.
string video;
// The IPFS address of the user's photo.
string photo;
// The name the user chose when signing up.
string name;
// The amount of collateral added to the account, in wei.
uint256 bond;
// The date the user was added to the database.
uint32 createdAt;
// The last time the user redeemed their FIN tokens.
uint32 lastRedeemedAt;
// Whether FIN redemption is locked for this account.
bool locked;
}
/* Contains the base data structures and functions used by other parts of the FixedID contract. */
contract Base is Ownable {
// The minimum account collateral required. 0.01ETH by default.
uint256 public minBond = 0.01 ether;
/* Begin code related to issuing FixedIDs */
// FixedID->User map. This is the central data structure for storing active users.
// Keep in sync with `currentOwnerToFixedId`.
mapping(uint40 => User) fixedIds;
// Address->FixedID map. Keep in sync with `fixedIds`.
mapping(address => uint40) currentOwnerToFixedId;
// The most recently issued FixedID.
uint40 public lastIssuedId = 0;
// The number of currently-active FixedIDs. Used to calculate the FIN streaming rate.
uint40 public activeFixedIds = 0;
function applyForFixedId(
string calldata video,
string calldata photo,
string calldata name
) external payable {
require(msg.value >= minBond);
lastIssuedId++;
fixedIds[lastIssuedId] = User(
msg.sender,
video,
photo,
name,
msg.value,
uint32(block.timestamp),
uint32(block.timestamp),
false
);
currentOwnerToFixedId[msg.sender] = lastIssuedId;
activeFixedIds++;
}
/* End code related to issuing FixedIDs */
/* Helper functions */
function requireOwnFixedId(uint40 fixedId) internal view {
require(fixedIds[fixedId].wallet == msg.sender, "FID001");
}
/* End helper functions */
}