-
Notifications
You must be signed in to change notification settings - Fork 0
/
Userprofile.sol
63 lines (53 loc) · 1.83 KB
/
Userprofile.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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {TablelandController} from "@tableland/evm/contracts/TablelandController.sol";
import {TablelandPolicy} from "@tableland/evm/contracts/TablelandPolicy.sol";
import {Policies} from "@tableland/evm/contracts/policies/Policies.sol";
contract UserProfileManager is TablelandController{
// Struct to represent a user profile
struct UserProfile {
string uri; // URI for off-chain data
bool isValue;
}
// Mapping to associate Ethereum addresses with user profiles
mapping(address => UserProfile) public profiles;
// Event to log profile creation or update
event UserProfileUpdated(address indexed user, string uri);
// Function to create or update a user profile
function createOrUpdateProfile(string memory _uri) public {
profiles[msg.sender].uri = _uri;
profiles[msg.sender].isValue = true;
emit UserProfileUpdated(msg.sender, _uri);
}
// Function to get the URI of a user's profile
function getProfileURI(address _user) public view returns (string memory) {
return profiles[_user].uri;
}
function getPolicy(
address caller,
uint256
) public payable override returns (TablelandPolicy memory) {
// Return allow-all policy
if( profiles[caller].isValue == true)
return
TablelandPolicy({
allowInsert: true,
allowUpdate: true,
allowDelete: true,
whereClause: "",
withCheck: "",
updatableColumns: new string[](0)
});
else
return
TablelandPolicy({
allowInsert: false,
allowUpdate: false,
allowDelete: false,
whereClause: "",
withCheck: "",
updatableColumns: new string[](0)
});
}
}