This repository has been archived by the owner on May 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
/
SignatureController.sol
196 lines (179 loc) · 6 KB
/
SignatureController.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
pragma solidity 0.5.12;
import "./ISignatureController.sol";
import '@openzeppelin/contracts-2.3/cryptography/ECDSA.sol';
import "../CNSRegistry.sol";
import "../util/SignatureUtil.sol";
// solium-disable error-reason
/**
* @title SignatureController
* @dev The SignatureController allows any account to submit select management
* transactions on behalf of a token owner.
*/
contract SignatureController is ISignatureController, SignatureUtil {
constructor (CNSRegistry registry) public SignatureUtil(registry) {}
/*
* 0x23b872dd == bytes4(keccak256('transferFrom(address,address,uint256)'))
*/
function transferFromFor(address from, address to, uint256 tokenId, bytes calldata signature) external {
_validate(
keccak256(abi.encodeWithSelector(0x23b872dd, from, to, tokenId)),
tokenId,
signature
);
_registry.controlledTransferFrom(from, to, tokenId);
}
/*
* 0xb88d4fde == bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)'))
*/
function safeTransferFromFor(
address from,
address to,
uint256 tokenId,
bytes calldata _data,
bytes calldata signature
)
external
{
_validate(
keccak256(abi.encodeWithSelector(0xb88d4fde, from, to, tokenId, _data)),
tokenId,
signature
);
_registry.controlledSafeTransferFrom(from, to, tokenId, _data);
}
/*
* 0x42842e0e == bytes4(keccak256('safeTransferFrom(address,address,uint256)'))
*/
function safeTransferFromFor(address from, address to, uint256 tokenId, bytes calldata signature) external {
_validate(
keccak256(abi.encodeWithSelector(0x42842e0e, from, to, tokenId)),
tokenId,
signature
);
_registry.controlledSafeTransferFrom(from, to, tokenId, "");
}
/*
* 0x42966c68 == bytes4(keccak256('burn(uint256)'))
*/
function burnFor(uint256 tokenId, bytes calldata signature) external {
_validate(
keccak256(abi.encodeWithSelector(0x42966c68, tokenId)),
tokenId,
signature
);
_registry.controlledBurn(tokenId);
}
/*
* 0xd8d3cc6e == bytes4(keccak256('mintChild(address,uint256,string)'))
*/
function mintChildFor(address to, uint256 tokenId, string calldata label, bytes calldata signature) external {
_validate(
keccak256(abi.encodeWithSelector(0xd8d3cc6e, to, tokenId, label)),
tokenId,
signature
);
_registry.controlledMintChild(to, tokenId, label);
}
/*
* 0xce9fb82b == bytes4(keccak256('safeMintChild(address,uint256,string,bytes)'))
*/
function safeMintChildFor(address to, uint256 tokenId, string calldata label, bytes calldata _data, bytes calldata signature) external {
_validate(
keccak256(abi.encodeWithSelector(0xce9fb82b, to, tokenId, label, _data)),
tokenId,
signature
);
_registry.controlledSafeMintChild(to, tokenId, label, _data);
}
/*
* 0x7c69eae2 == bytes4(keccak256('safeMintChild(address,uint256,string)'))
*/
function safeMintChildFor(address to, uint256 tokenId, string calldata label, bytes calldata signature) external {
_validate(
keccak256(abi.encodeWithSelector(0x7c69eae2, to, tokenId, label)),
tokenId,
signature
);
_registry.controlledSafeMintChild(to, tokenId, label, "");
}
/*
* 0x9e5be9a5 == bytes4(keccak256('transferFromChild(address,address,uint256,string)'))
*/
function transferFromChildFor(
address from,
address to,
uint256 tokenId,
string calldata label,
bytes calldata signature
)
external
{
_validate(
keccak256(abi.encodeWithSelector(0x9e5be9a5, from, to, tokenId, label)),
tokenId,
signature
);
_registry.controlledTransferFrom(from, to, _registry.childIdOf(tokenId, label));
}
/*
* 0xc29b52f9 == bytes4(keccak256('safeTransferFromChild(address,address,uint256,string,bytes)'))
*/
function safeTransferFromChildFor(
address from,
address to,
uint256 tokenId,
string calldata label,
bytes calldata _data,
bytes calldata signature
)
external
{
_validate(
keccak256(abi.encodeWithSelector(0xc29b52f9, from, to, tokenId, label, _data)),
tokenId,
signature
);
_registry.controlledSafeTransferFrom(from, to, _registry.childIdOf(tokenId, label), _data);
}
/*
* 0x9d743989 == bytes4(keccak256('safeTransferFromChild(address,address,uint256,string)'))
*/
function safeTransferFromChildFor(
address from,
address to,
uint256 tokenId,
string calldata label,
bytes calldata signature
)
external
{
_validate(
keccak256(abi.encodeWithSelector(0x9d743989, from, to, tokenId, label)),
tokenId,
signature
);
_registry.controlledSafeTransferFrom(from, to, _registry.childIdOf(tokenId, label), "");
}
/*
* 0x5cbe1112 == bytes4(keccak256('burnChild(uint256,string)'))
*/
function burnChildFor(uint256 tokenId, string calldata label, bytes calldata signature) external {
_validate(
keccak256(abi.encodeWithSelector(0x5cbe1112, tokenId, label)),
tokenId,
signature
);
_registry.controlledBurn(_registry.childIdOf(tokenId, label));
}
/*
* 0x2392c189 == bytes4(keccak256('resolveTo(address,uint256)'))
*/
function resolveToFor(address to, uint256 tokenId, bytes calldata signature) external {
_validate(
keccak256(abi.encodeWithSelector(0x2392c189, to, tokenId)),
tokenId,
signature
);
_registry.controlledResolveTo(to, tokenId);
}
}