-
Notifications
You must be signed in to change notification settings - Fork 11.7k
/
EnumerableSetMock.sol
111 lines (82 loc) · 2.67 KB
/
EnumerableSetMock.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// SPDX-License-Identifier: MIT
// This file was procedurally generated from scripts/generate/templates/EnumerableSetMock.js.
pragma solidity ^0.8.0;
import "../utils/structs/EnumerableSet.sol";
// Bytes32Set
contract EnumerableBytes32SetMock {
using EnumerableSet for EnumerableSet.Bytes32Set;
event OperationResult(bool result);
EnumerableSet.Bytes32Set private _set;
function contains(bytes32 value) public view returns (bool) {
return _set.contains(value);
}
function add(bytes32 value) public {
bool result = _set.add(value);
emit OperationResult(result);
}
function remove(bytes32 value) public {
bool result = _set.remove(value);
emit OperationResult(result);
}
function length() public view returns (uint256) {
return _set.length();
}
function at(uint256 index) public view returns (bytes32) {
return _set.at(index);
}
function values() public view returns (bytes32[] memory) {
return _set.values();
}
}
// AddressSet
contract EnumerableAddressSetMock {
using EnumerableSet for EnumerableSet.AddressSet;
event OperationResult(bool result);
EnumerableSet.AddressSet private _set;
function contains(address value) public view returns (bool) {
return _set.contains(value);
}
function add(address value) public {
bool result = _set.add(value);
emit OperationResult(result);
}
function remove(address value) public {
bool result = _set.remove(value);
emit OperationResult(result);
}
function length() public view returns (uint256) {
return _set.length();
}
function at(uint256 index) public view returns (address) {
return _set.at(index);
}
function values() public view returns (address[] memory) {
return _set.values();
}
}
// UintSet
contract EnumerableUintSetMock {
using EnumerableSet for EnumerableSet.UintSet;
event OperationResult(bool result);
EnumerableSet.UintSet private _set;
function contains(uint256 value) public view returns (bool) {
return _set.contains(value);
}
function add(uint256 value) public {
bool result = _set.add(value);
emit OperationResult(result);
}
function remove(uint256 value) public {
bool result = _set.remove(value);
emit OperationResult(result);
}
function length() public view returns (uint256) {
return _set.length();
}
function at(uint256 index) public view returns (uint256) {
return _set.at(index);
}
function values() public view returns (uint256[] memory) {
return _set.values();
}
}