@theqrl/qrl-contracts 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/interfaces/ISQRCTN1.hyp +6 -0
- package/interfaces/IZRC165.hyp +6 -0
- package/interfaces/IZRC4906.hyp +20 -0
- package/interfaces/draft-IZRC6093.hyp +161 -0
- package/package.json +26 -0
- package/token/SQRCTB1/ISQRCTB1.hyp +123 -0
- package/token/SQRCTB1/ISQRCTB1Receiver.hyp +59 -0
- package/token/SQRCTB1/SQRCTB1.hyp +389 -0
- package/token/SQRCTB1/extensions/ISQRCTB1MetadataURI.hyp +20 -0
- package/token/SQRCTB1/utils/SQRCTB1Utils.hyp +88 -0
- package/token/SQRCTF1/ISQRCTF1.hyp +79 -0
- package/token/SQRCTF1/SQRCTF1.hyp +305 -0
- package/token/SQRCTF1/extensions/ISQRCTF1Metadata.hyp +26 -0
- package/token/SQRCTN1/ISQRCTN1.hyp +135 -0
- package/token/SQRCTN1/ISQRCTN1Receiver.hyp +28 -0
- package/token/SQRCTN1/SQRCTN1.hyp +430 -0
- package/token/SQRCTN1/extensions/ISQRCTN1Metadata.hyp +27 -0
- package/token/SQRCTN1/extensions/SQRCTN1URIStorage.hyp +58 -0
- package/token/SQRCTN1/utils/SQRCTN1Utils.hyp +50 -0
- package/utils/Arrays.hyp +552 -0
- package/utils/Comparators.hyp +19 -0
- package/utils/Context.hyp +28 -0
- package/utils/Counters.hyp +43 -0
- package/utils/Panic.hyp +57 -0
- package/utils/SlotDerivation.hyp +155 -0
- package/utils/StorageSlot.hyp +143 -0
- package/utils/Strings.hyp +490 -0
- package/utils/introspection/IZRC165.hyp +25 -0
- package/utils/introspection/ZRC165.hyp +25 -0
- package/utils/math/Math.hyp +749 -0
- package/utils/math/SafeCast.hyp +1162 -0
- package/utils/math/SignedMath.hyp +68 -0
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// QRL Contracts (last updated v0.1.0) (token/SQRCTF1/SQRCTF1.hyp)
|
|
3
|
+
|
|
4
|
+
pragma hyperion >=0.0;
|
|
5
|
+
|
|
6
|
+
import {ISQRCTF1} from "./ISQRCTF1.hyp";
|
|
7
|
+
import {ISQRCTF1Metadata} from "./extensions/ISQRCTF1Metadata.hyp";
|
|
8
|
+
import {Context} from "../../utils/Context.hyp";
|
|
9
|
+
import {ISQRCTF1Errors} from "../../interfaces/draft-IZRC6093.hyp";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @dev Implementation of the {ISQRCTF1} interface.
|
|
13
|
+
*
|
|
14
|
+
* This implementation is agnostic to the way tokens are created. This means
|
|
15
|
+
* that a supply mechanism has to be added in a derived contract using {_mint}.
|
|
16
|
+
*
|
|
17
|
+
* TIP: For a detailed writeup see our guide
|
|
18
|
+
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
|
|
19
|
+
* to implement supply mechanisms].
|
|
20
|
+
*
|
|
21
|
+
* The default value of {decimals} is 18. To change this, you should override
|
|
22
|
+
* this function so it returns a different value.
|
|
23
|
+
*
|
|
24
|
+
* We have followed general QRL Contracts guidelines: functions revert
|
|
25
|
+
* instead returning `false` on failure. This behavior is nonetheless
|
|
26
|
+
* conventional and does not conflict with the expectations of SQRC-TF1
|
|
27
|
+
* applications.
|
|
28
|
+
*/
|
|
29
|
+
abstract contract SQRCTF1 is Context, ISQRCTF1, ISQRCTF1Metadata, ISQRCTF1Errors {
|
|
30
|
+
mapping(address account => uint256) private _balances;
|
|
31
|
+
|
|
32
|
+
mapping(address account => mapping(address spender => uint256)) private _allowances;
|
|
33
|
+
|
|
34
|
+
uint256 private _totalSupply;
|
|
35
|
+
|
|
36
|
+
string private _name;
|
|
37
|
+
string private _symbol;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @dev Sets the values for {name} and {symbol}.
|
|
41
|
+
*
|
|
42
|
+
* Both values are immutable: they can only be set once during construction.
|
|
43
|
+
*/
|
|
44
|
+
constructor(string memory name_, string memory symbol_) {
|
|
45
|
+
_name = name_;
|
|
46
|
+
_symbol = symbol_;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @dev Returns the name of the token.
|
|
51
|
+
*/
|
|
52
|
+
function name() public view virtual returns (string memory) {
|
|
53
|
+
return _name;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @dev Returns the symbol of the token, usually a shorter version of the
|
|
58
|
+
* name.
|
|
59
|
+
*/
|
|
60
|
+
function symbol() public view virtual returns (string memory) {
|
|
61
|
+
return _symbol;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @dev Returns the number of decimals used to get its user representation.
|
|
66
|
+
* For example, if `decimals` equals `2`, a balance of `505` tokens should
|
|
67
|
+
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
|
|
68
|
+
*
|
|
69
|
+
* Tokens usually opt for a value of 18, imitating the relationship between
|
|
70
|
+
* Quanta and Planck. This is the default value returned by this function,
|
|
71
|
+
* unless it's overridden.
|
|
72
|
+
*
|
|
73
|
+
* NOTE: This information is only used for _display_ purposes: it in
|
|
74
|
+
* no way affects any of the arithmetic of the contract, including
|
|
75
|
+
* {ISQRCTF1-balanceOf} and {ISQRCTF1-transfer}.
|
|
76
|
+
*/
|
|
77
|
+
function decimals() public view virtual returns (uint8) {
|
|
78
|
+
return 18;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/// @inheritdoc ISQRCTF1
|
|
82
|
+
function totalSupply() public view virtual returns (uint256) {
|
|
83
|
+
return _totalSupply;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/// @inheritdoc ISQRCTF1
|
|
87
|
+
function balanceOf(address account) public view virtual returns (uint256) {
|
|
88
|
+
return _balances[account];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @dev See {ISQRCTF1-transfer}.
|
|
93
|
+
*
|
|
94
|
+
* Requirements:
|
|
95
|
+
*
|
|
96
|
+
* - `to` cannot be the zero address.
|
|
97
|
+
* - the caller must have a balance of at least `value`.
|
|
98
|
+
*/
|
|
99
|
+
function transfer(address to, uint256 value) public virtual returns (bool) {
|
|
100
|
+
address owner = _msgSender();
|
|
101
|
+
_transfer(owner, to, value);
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/// @inheritdoc ISQRCTF1
|
|
106
|
+
function allowance(address owner, address spender) public view virtual returns (uint256) {
|
|
107
|
+
return _allowances[owner][spender];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* @dev See {ISQRCTF1-approve}.
|
|
112
|
+
*
|
|
113
|
+
* NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
|
|
114
|
+
* `transferFrom`. This is semantically equivalent to an infinite approval.
|
|
115
|
+
*
|
|
116
|
+
* Requirements:
|
|
117
|
+
*
|
|
118
|
+
* - `spender` cannot be the zero address.
|
|
119
|
+
*/
|
|
120
|
+
function approve(address spender, uint256 value) public virtual returns (bool) {
|
|
121
|
+
address owner = _msgSender();
|
|
122
|
+
_approve(owner, spender, value);
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @dev See {ISQRCTF1-transferFrom}.
|
|
128
|
+
*
|
|
129
|
+
* Skips emitting an {Approval} event indicating an allowance update. This is not
|
|
130
|
+
* required by the ZRC. See {xref-SQRCTF1-_approve-address-address-uint256-bool-}[_approve].
|
|
131
|
+
*
|
|
132
|
+
* NOTE: Does not update the allowance if the current allowance
|
|
133
|
+
* is the maximum `uint256`.
|
|
134
|
+
*
|
|
135
|
+
* Requirements:
|
|
136
|
+
*
|
|
137
|
+
* - `from` and `to` cannot be the zero address.
|
|
138
|
+
* - `from` must have a balance of at least `value`.
|
|
139
|
+
* - the caller must have allowance for ``from``'s tokens of at least
|
|
140
|
+
* `value`.
|
|
141
|
+
*/
|
|
142
|
+
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
|
|
143
|
+
address spender = _msgSender();
|
|
144
|
+
_spendAllowance(from, spender, value);
|
|
145
|
+
_transfer(from, to, value);
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* @dev Moves a `value` amount of tokens from `from` to `to`.
|
|
151
|
+
*
|
|
152
|
+
* This internal function is equivalent to {transfer}, and can be used to
|
|
153
|
+
* e.g. implement automatic token fees, slashing mechanisms, etc.
|
|
154
|
+
*
|
|
155
|
+
* Emits a {Transfer} event.
|
|
156
|
+
*
|
|
157
|
+
* NOTE: This function is not virtual, {_update} should be overridden instead.
|
|
158
|
+
*/
|
|
159
|
+
function _transfer(address from, address to, uint256 value) internal {
|
|
160
|
+
if (from == address(0)) {
|
|
161
|
+
revert SQRCTF1InvalidSender(address(0));
|
|
162
|
+
}
|
|
163
|
+
if (to == address(0)) {
|
|
164
|
+
revert SQRCTF1InvalidReceiver(address(0));
|
|
165
|
+
}
|
|
166
|
+
_update(from, to, value);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
|
|
171
|
+
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
|
|
172
|
+
* this function.
|
|
173
|
+
*
|
|
174
|
+
* Emits a {Transfer} event.
|
|
175
|
+
*/
|
|
176
|
+
function _update(address from, address to, uint256 value) internal virtual {
|
|
177
|
+
if (from == address(0)) {
|
|
178
|
+
// Overflow check required: The rest of the code assumes that totalSupply never overflows
|
|
179
|
+
_totalSupply += value;
|
|
180
|
+
} else {
|
|
181
|
+
uint256 fromBalance = _balances[from];
|
|
182
|
+
if (fromBalance < value) {
|
|
183
|
+
revert SQRCTF1InsufficientBalance(from, fromBalance, value);
|
|
184
|
+
}
|
|
185
|
+
unchecked {
|
|
186
|
+
// Overflow not possible: value <= fromBalance <= totalSupply.
|
|
187
|
+
_balances[from] = fromBalance - value;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (to == address(0)) {
|
|
192
|
+
unchecked {
|
|
193
|
+
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
|
|
194
|
+
_totalSupply -= value;
|
|
195
|
+
}
|
|
196
|
+
} else {
|
|
197
|
+
unchecked {
|
|
198
|
+
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
|
|
199
|
+
_balances[to] += value;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
emit Transfer(from, to, value);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
|
|
208
|
+
* Relies on the `_update` mechanism
|
|
209
|
+
*
|
|
210
|
+
* Emits a {Transfer} event with `from` set to the zero address.
|
|
211
|
+
*
|
|
212
|
+
* NOTE: This function is not virtual, {_update} should be overridden instead.
|
|
213
|
+
*/
|
|
214
|
+
function _mint(address account, uint256 value) internal {
|
|
215
|
+
if (account == address(0)) {
|
|
216
|
+
revert SQRCTF1InvalidReceiver(address(0));
|
|
217
|
+
}
|
|
218
|
+
_update(address(0), account, value);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
|
|
223
|
+
* Relies on the `_update` mechanism.
|
|
224
|
+
*
|
|
225
|
+
* Emits a {Transfer} event with `to` set to the zero address.
|
|
226
|
+
*
|
|
227
|
+
* NOTE: This function is not virtual, {_update} should be overridden instead
|
|
228
|
+
*/
|
|
229
|
+
function _burn(address account, uint256 value) internal {
|
|
230
|
+
if (account == address(0)) {
|
|
231
|
+
revert SQRCTF1InvalidSender(address(0));
|
|
232
|
+
}
|
|
233
|
+
_update(account, address(0), value);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* @dev Sets `value` as the allowance of `spender` over the `owner`'s tokens.
|
|
238
|
+
*
|
|
239
|
+
* This internal function is equivalent to `approve`, and can be used to
|
|
240
|
+
* e.g. set automatic allowances for certain subsystems, etc.
|
|
241
|
+
*
|
|
242
|
+
* Emits an {Approval} event.
|
|
243
|
+
*
|
|
244
|
+
* Requirements:
|
|
245
|
+
*
|
|
246
|
+
* - `owner` cannot be the zero address.
|
|
247
|
+
* - `spender` cannot be the zero address.
|
|
248
|
+
*
|
|
249
|
+
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
|
|
250
|
+
*/
|
|
251
|
+
function _approve(address owner, address spender, uint256 value) internal {
|
|
252
|
+
_approve(owner, spender, value, true);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
|
|
257
|
+
*
|
|
258
|
+
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
|
|
259
|
+
* `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
|
|
260
|
+
* `Approval` event during `transferFrom` operations.
|
|
261
|
+
*
|
|
262
|
+
* Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
|
|
263
|
+
* true using the following override:
|
|
264
|
+
*
|
|
265
|
+
* ```hyperion
|
|
266
|
+
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
|
|
267
|
+
* super._approve(owner, spender, value, true);
|
|
268
|
+
* }
|
|
269
|
+
* ```
|
|
270
|
+
*
|
|
271
|
+
* Requirements are the same as {_approve}.
|
|
272
|
+
*/
|
|
273
|
+
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
|
|
274
|
+
if (owner == address(0)) {
|
|
275
|
+
revert SQRCTF1InvalidApprover(address(0));
|
|
276
|
+
}
|
|
277
|
+
if (spender == address(0)) {
|
|
278
|
+
revert SQRCTF1InvalidSpender(address(0));
|
|
279
|
+
}
|
|
280
|
+
_allowances[owner][spender] = value;
|
|
281
|
+
if (emitEvent) {
|
|
282
|
+
emit Approval(owner, spender, value);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* @dev Updates `owner`'s allowance for `spender` based on spent `value`.
|
|
288
|
+
*
|
|
289
|
+
* Does not update the allowance value in case of infinite allowance.
|
|
290
|
+
* Revert if not enough allowance is available.
|
|
291
|
+
*
|
|
292
|
+
* Does not emit an {Approval} event.
|
|
293
|
+
*/
|
|
294
|
+
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
|
|
295
|
+
uint256 currentAllowance = allowance(owner, spender);
|
|
296
|
+
if (currentAllowance < type(uint256).max) {
|
|
297
|
+
if (currentAllowance < value) {
|
|
298
|
+
revert SQRCTF1InsufficientAllowance(spender, currentAllowance, value);
|
|
299
|
+
}
|
|
300
|
+
unchecked {
|
|
301
|
+
_approve(owner, spender, currentAllowance - value, false);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// QRL Contracts (last updated v0.1.0) (token/SQRCTF1/extensions/ISQRCTF1Metadata.hyp)
|
|
3
|
+
|
|
4
|
+
pragma hyperion >=0.0;
|
|
5
|
+
|
|
6
|
+
import {ISQRCTF1} from "../ISQRCTF1.hyp";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @dev Interface for the optional metadata functions from the SQRC-TF1 standard.
|
|
10
|
+
*/
|
|
11
|
+
interface ISQRCTF1Metadata is ISQRCTF1 {
|
|
12
|
+
/**
|
|
13
|
+
* @dev Returns the name of the token.
|
|
14
|
+
*/
|
|
15
|
+
function name() external view returns (string memory);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @dev Returns the symbol of the token.
|
|
19
|
+
*/
|
|
20
|
+
function symbol() external view returns (string memory);
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @dev Returns the decimals places of the token.
|
|
24
|
+
*/
|
|
25
|
+
function decimals() external view returns (uint8);
|
|
26
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// QRL Contracts (last updated v0.1.0) (token/SQRCTN1/ISQRCTN1.hyp)
|
|
3
|
+
|
|
4
|
+
pragma hyperion >=0.0;
|
|
5
|
+
|
|
6
|
+
import {IZRC165} from "../../utils/introspection/IZRC165.hyp";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @dev Required interface of an SQRC-TN1 compliant contract.
|
|
10
|
+
*/
|
|
11
|
+
interface ISQRCTN1 is IZRC165 {
|
|
12
|
+
/**
|
|
13
|
+
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
|
|
14
|
+
*/
|
|
15
|
+
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
|
|
19
|
+
*/
|
|
20
|
+
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
|
|
24
|
+
*/
|
|
25
|
+
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @dev Returns the number of tokens in ``owner``'s account.
|
|
29
|
+
*/
|
|
30
|
+
function balanceOf(address owner) external view returns (uint256 balance);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @dev Returns the owner of the `tokenId` token.
|
|
34
|
+
*
|
|
35
|
+
* Requirements:
|
|
36
|
+
*
|
|
37
|
+
* - `tokenId` must exist.
|
|
38
|
+
*/
|
|
39
|
+
function ownerOf(uint256 tokenId) external view returns (address owner);
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @dev Safely transfers `tokenId` token from `from` to `to`.
|
|
43
|
+
*
|
|
44
|
+
* Requirements:
|
|
45
|
+
*
|
|
46
|
+
* - `from` cannot be the zero address.
|
|
47
|
+
* - `to` cannot be the zero address.
|
|
48
|
+
* - `tokenId` token must exist and be owned by `from`.
|
|
49
|
+
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
|
|
50
|
+
* - If `to` refers to a smart contract, it must implement {ISQRCTN1Receiver-onSQRCTN1Received}, which is called upon
|
|
51
|
+
* a safe transfer.
|
|
52
|
+
*
|
|
53
|
+
* Emits a {Transfer} event.
|
|
54
|
+
*/
|
|
55
|
+
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
|
|
59
|
+
* are aware of the SQRC-TN1 protocol to prevent tokens from being forever locked.
|
|
60
|
+
*
|
|
61
|
+
* Requirements:
|
|
62
|
+
*
|
|
63
|
+
* - `from` cannot be the zero address.
|
|
64
|
+
* - `to` cannot be the zero address.
|
|
65
|
+
* - `tokenId` token must exist and be owned by `from`.
|
|
66
|
+
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or
|
|
67
|
+
* {setApprovalForAll}.
|
|
68
|
+
* - If `to` refers to a smart contract, it must implement {ISQRCTN1Receiver-onSQRCTN1Received}, which is called upon
|
|
69
|
+
* a safe transfer.
|
|
70
|
+
*
|
|
71
|
+
* Emits a {Transfer} event.
|
|
72
|
+
*/
|
|
73
|
+
function safeTransferFrom(address from, address to, uint256 tokenId) external;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @dev Transfers `tokenId` token from `from` to `to`.
|
|
77
|
+
*
|
|
78
|
+
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving SQRC-TN1
|
|
79
|
+
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
|
|
80
|
+
* understand this adds an external call which potentially creates a reentrancy vulnerability.
|
|
81
|
+
*
|
|
82
|
+
* Requirements:
|
|
83
|
+
*
|
|
84
|
+
* - `from` cannot be the zero address.
|
|
85
|
+
* - `to` cannot be the zero address.
|
|
86
|
+
* - `tokenId` token must be owned by `from`.
|
|
87
|
+
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
|
|
88
|
+
*
|
|
89
|
+
* Emits a {Transfer} event.
|
|
90
|
+
*/
|
|
91
|
+
function transferFrom(address from, address to, uint256 tokenId) external;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
|
|
95
|
+
* The approval is cleared when the token is transferred.
|
|
96
|
+
*
|
|
97
|
+
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
|
|
98
|
+
*
|
|
99
|
+
* Requirements:
|
|
100
|
+
*
|
|
101
|
+
* - The caller must own the token or be an approved operator.
|
|
102
|
+
* - `tokenId` must exist.
|
|
103
|
+
*
|
|
104
|
+
* Emits an {Approval} event.
|
|
105
|
+
*/
|
|
106
|
+
function approve(address to, uint256 tokenId) external;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @dev Approve or remove `operator` as an operator for the caller.
|
|
110
|
+
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
|
|
111
|
+
*
|
|
112
|
+
* Requirements:
|
|
113
|
+
*
|
|
114
|
+
* - The `operator` cannot be the address zero.
|
|
115
|
+
*
|
|
116
|
+
* Emits an {ApprovalForAll} event.
|
|
117
|
+
*/
|
|
118
|
+
function setApprovalForAll(address operator, bool approved) external;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @dev Returns the account approved for `tokenId` token.
|
|
122
|
+
*
|
|
123
|
+
* Requirements:
|
|
124
|
+
*
|
|
125
|
+
* - `tokenId` must exist.
|
|
126
|
+
*/
|
|
127
|
+
function getApproved(uint256 tokenId) external view returns (address operator);
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
|
|
131
|
+
*
|
|
132
|
+
* See {setApprovalForAll}
|
|
133
|
+
*/
|
|
134
|
+
function isApprovedForAll(address owner, address operator) external view returns (bool);
|
|
135
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// QRL Contracts (last updated v0.1.0) (token/SQRCTN1/ISQRCTN1Receiver.hyp)
|
|
3
|
+
|
|
4
|
+
pragma hyperion >=0.0;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @title SQRC-TN1 token receiver interface
|
|
8
|
+
* @dev Interface for any contract that wants to support safeTransfers
|
|
9
|
+
* from SQRC-TN1 asset contracts.
|
|
10
|
+
*/
|
|
11
|
+
interface ISQRCTN1Receiver {
|
|
12
|
+
/**
|
|
13
|
+
* @dev Whenever an {ISQRCTN1} `tokenId` token is transferred to this contract via {ISQRCTN1-safeTransferFrom}
|
|
14
|
+
* by `operator` from `from`, this function is called.
|
|
15
|
+
*
|
|
16
|
+
* It must return its Hyperion selector to confirm the token transfer.
|
|
17
|
+
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be
|
|
18
|
+
* reverted.
|
|
19
|
+
*
|
|
20
|
+
* The selector can be obtained in Hyperion with `ISQRCTN1Receiver.onSQRCTN1Received.selector`.
|
|
21
|
+
*/
|
|
22
|
+
function onSQRCTN1Received(
|
|
23
|
+
address operator,
|
|
24
|
+
address from,
|
|
25
|
+
uint256 tokenId,
|
|
26
|
+
bytes calldata data
|
|
27
|
+
) external returns (bytes4);
|
|
28
|
+
}
|