-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSecurityProfile.sol
More file actions
63 lines (58 loc) · 1.59 KB
/
Copy pathSecurityProfile.sol
File metadata and controls
63 lines (58 loc) · 1.59 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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
/// @notice Stores each wallet's own approval-safety preferences on-chain.
/// Noryx's frontend reads this to warn a user when a transaction they're
/// about to sign violates a rule they set for themselves.
contract SecurityProfile {
struct Preferences {
bool blockUnlimitedApprovals;
uint256 maxApprovalAmount;
bool warnNewContracts;
bool exists;
}
mapping(address => Preferences) private profiles;
event PreferencesSaved(
address indexed user,
bool blockUnlimitedApprovals,
uint256 maxApprovalAmount,
bool warnNewContracts
);
function savePreferences(
bool blockUnlimitedApprovals,
uint256 maxApprovalAmount,
bool warnNewContracts
) external {
profiles[msg.sender] = Preferences(
blockUnlimitedApprovals,
maxApprovalAmount,
warnNewContracts,
true
);
emit PreferencesSaved(
msg.sender,
blockUnlimitedApprovals,
maxApprovalAmount,
warnNewContracts
);
}
function getPreferences(
address user
)
external
view
returns (
bool blockUnlimitedApprovals,
uint256 maxApprovalAmount,
bool warnNewContracts,
bool exists
)
{
Preferences memory p = profiles[user];
return (
p.blockUnlimitedApprovals,
p.maxApprovalAmount,
p.warnNewContracts,
p.exists
);
}
}