@lukso/lsp7-contracts 0.15.0 → 0.16.3
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/README.md +12 -2
- package/artifacts/ILSP7DigitalAsset.json +0 -112
- package/artifacts/LSP7Burnable.json +0 -11
- package/artifacts/LSP7BurnableInitAbstract.json +0 -16
- package/artifacts/LSP7CappedSupply.json +0 -11
- package/artifacts/LSP7CappedSupplyInitAbstract.json +0 -16
- package/artifacts/LSP7DigitalAsset.json +0 -11
- package/artifacts/LSP7DigitalAssetInitAbstract.json +0 -16
- package/artifacts/LSP7Mintable.json +2 -13
- package/artifacts/LSP7MintableInit.json +2 -13
- package/artifacts/LSP7Votes.json +1154 -0
- package/artifacts/LSP7VotesInitAbstract.json +1146 -0
- package/contracts/ILSP7DigitalAsset.sol +2 -9
- package/contracts/LSP7Constants.sol +10 -0
- package/contracts/LSP7DigitalAsset.sol +748 -27
- package/contracts/LSP7DigitalAssetInitAbstract.sol +752 -14
- package/contracts/extensions/LSP7CappedSupply.sol +1 -1
- package/contracts/extensions/LSP7CappedSupplyInitAbstract.sol +1 -1
- package/contracts/extensions/LSP7Votes.sol +416 -0
- package/contracts/extensions/LSP7VotesConstants.sol +8 -0
- package/contracts/extensions/LSP7VotesInitAbstract.sol +443 -0
- package/dist/index.cjs +5 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.mts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.mjs +5 -1
- package/package.json +5 -6
- package/types/index.ts +3488 -1480
- package/contracts/LSP7DigitalAssetCore.sol +0 -744
- package/types/common.ts +0 -131
- package/types/contracts/ILSP7DigitalAsset.ts +0 -626
- package/types/contracts/LSP7DigitalAsset.ts +0 -698
- package/types/contracts/LSP7DigitalAssetInitAbstract.ts +0 -729
- package/types/contracts/extensions/LSP7Burnable.ts +0 -717
- package/types/contracts/extensions/LSP7BurnableInitAbstract.ts +0 -748
- package/types/contracts/extensions/LSP7CappedSupply.ts +0 -712
- package/types/contracts/extensions/LSP7CappedSupplyInitAbstract.ts +0 -743
- package/types/contracts/presets/LSP7Mintable.ts +0 -717
- package/types/contracts/presets/LSP7MintableInit.ts +0 -779
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
LSP7DigitalAssetInitAbstract
|
|
6
|
+
} from "../LSP7DigitalAssetInitAbstract.sol";
|
|
7
|
+
import {
|
|
8
|
+
_TYPEID_LSP7_VOTESDELEGATOR,
|
|
9
|
+
_TYPEID_LSP7_VOTESDELEGATEE
|
|
10
|
+
} from "./LSP7VotesConstants.sol";
|
|
11
|
+
|
|
12
|
+
import {LSP1Utils} from "@lukso/lsp1-contracts/contracts/LSP1Utils.sol";
|
|
13
|
+
import {IERC5805} from "@openzeppelin/contracts/interfaces/IERC5805.sol";
|
|
14
|
+
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
|
|
15
|
+
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";
|
|
16
|
+
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
|
|
17
|
+
import {
|
|
18
|
+
EIP712Upgradeable
|
|
19
|
+
} from "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol";
|
|
20
|
+
import {Counters} from "@openzeppelin/contracts/utils/Counters.sol";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @dev Extension of LSP7 to support Compound-like voting and delegation. This version is more generic than Compound's,
|
|
24
|
+
* and supports token supply up to 2^224^ - 1, while COMP is limited to 2^96^ - 1.
|
|
25
|
+
*
|
|
26
|
+
* This extension keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either
|
|
27
|
+
* by calling the {delegate} function directly, or by providing a signature to be used with {delegateBySig}. Voting
|
|
28
|
+
* power can be queried through the public accessors {getVotes} and {getPastVotes}.
|
|
29
|
+
*
|
|
30
|
+
* By default, token balance does not account for voting power. This makes transfers cheaper. The downside is that it
|
|
31
|
+
* requires users to delegate to themselves in order to activate checkpoints and have their voting power tracked.
|
|
32
|
+
*/
|
|
33
|
+
abstract contract LSP7VotesInitAbstract is
|
|
34
|
+
LSP7DigitalAssetInitAbstract,
|
|
35
|
+
EIP712Upgradeable,
|
|
36
|
+
IERC5805
|
|
37
|
+
{
|
|
38
|
+
using Counters for Counters.Counter;
|
|
39
|
+
mapping(address => Counters.Counter) private _nonces;
|
|
40
|
+
|
|
41
|
+
struct Checkpoint {
|
|
42
|
+
uint32 fromBlock;
|
|
43
|
+
uint224 votes;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
bytes32 internal constant _DELEGATION_TYPEHASH =
|
|
47
|
+
keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
|
|
48
|
+
|
|
49
|
+
mapping(address => address) private _delegates;
|
|
50
|
+
mapping(address => Checkpoint[]) private _checkpoints;
|
|
51
|
+
Checkpoint[] private _totalSupplyCheckpoints;
|
|
52
|
+
|
|
53
|
+
function _initialize(
|
|
54
|
+
string memory name_,
|
|
55
|
+
string memory symbol_,
|
|
56
|
+
address newOwner_,
|
|
57
|
+
uint256 lsp4TokenType_,
|
|
58
|
+
bool isNonDivisible_,
|
|
59
|
+
string memory version_
|
|
60
|
+
) internal virtual onlyInitializing {
|
|
61
|
+
LSP7DigitalAssetInitAbstract._initialize(
|
|
62
|
+
name_,
|
|
63
|
+
symbol_,
|
|
64
|
+
newOwner_,
|
|
65
|
+
lsp4TokenType_,
|
|
66
|
+
isNonDivisible_
|
|
67
|
+
);
|
|
68
|
+
__EIP712_init(name_, version_);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @dev Clock used for flagging checkpoints. Can be overridden to implement timestamp based checkpoints (and voting).
|
|
73
|
+
*/
|
|
74
|
+
function clock() public view virtual override returns (uint48) {
|
|
75
|
+
return SafeCast.toUint48(block.number);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @dev Description of the clock
|
|
80
|
+
*/
|
|
81
|
+
// solhint-disable-next-line func-name-mixedcase
|
|
82
|
+
function CLOCK_MODE() public view virtual override returns (string memory) {
|
|
83
|
+
// Check that the clock was not modified
|
|
84
|
+
require(clock() == block.number, "LSP7Votes: broken clock mode");
|
|
85
|
+
return "mode=blocknumber&from=default";
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// solhint-disable-next-line func-name-mixedcase
|
|
89
|
+
function DOMAIN_SEPARATOR() external view returns (bytes32) {
|
|
90
|
+
return _domainSeparatorV4();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @dev Get the `pos`-th checkpoint for `account`.
|
|
95
|
+
*/
|
|
96
|
+
function checkpoints(
|
|
97
|
+
address account,
|
|
98
|
+
uint32 pos
|
|
99
|
+
) public view virtual returns (Checkpoint memory) {
|
|
100
|
+
return _checkpoints[account][pos];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @dev Get number of checkpoints for `account`.
|
|
105
|
+
*/
|
|
106
|
+
function numCheckpoints(
|
|
107
|
+
address account
|
|
108
|
+
) public view virtual returns (uint32) {
|
|
109
|
+
return SafeCast.toUint32(_checkpoints[account].length);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @dev Get the address `account` is currently delegating to.
|
|
114
|
+
*/
|
|
115
|
+
function delegates(
|
|
116
|
+
address account
|
|
117
|
+
) public view virtual override returns (address) {
|
|
118
|
+
return _delegates[account];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @dev Gets the current votes balance for `account`
|
|
123
|
+
*/
|
|
124
|
+
function getVotes(
|
|
125
|
+
address account
|
|
126
|
+
) public view virtual override returns (uint256) {
|
|
127
|
+
uint256 pos = _checkpoints[account].length;
|
|
128
|
+
unchecked {
|
|
129
|
+
return pos == 0 ? 0 : _checkpoints[account][pos - 1].votes;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @dev Retrieve the number of votes for `account` at the end of `timepoint`.
|
|
135
|
+
*
|
|
136
|
+
* @custom:requirements
|
|
137
|
+
* - `timepoint` must be in the past
|
|
138
|
+
*/
|
|
139
|
+
function getPastVotes(
|
|
140
|
+
address account,
|
|
141
|
+
uint256 timepoint
|
|
142
|
+
) public view virtual override returns (uint256) {
|
|
143
|
+
require(timepoint < clock(), "LSP7Votes: future lookup");
|
|
144
|
+
return _checkpointsLookup(_checkpoints[account], timepoint);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @dev Retrieve the `totalSupply` at the end of `timepoint`. Note, this value is the sum of all balances.
|
|
149
|
+
* It is NOT the sum of all the delegated votes!
|
|
150
|
+
*
|
|
151
|
+
* @custom:requirements
|
|
152
|
+
* - `timepoint` must be in the past
|
|
153
|
+
*/
|
|
154
|
+
function getPastTotalSupply(
|
|
155
|
+
uint256 timepoint
|
|
156
|
+
) public view virtual override returns (uint256) {
|
|
157
|
+
require(timepoint < clock(), "LSP7Votes: future lookup");
|
|
158
|
+
return _checkpointsLookup(_totalSupplyCheckpoints, timepoint);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @dev Lookup a value in a list of (sorted) checkpoints.
|
|
163
|
+
*/
|
|
164
|
+
function _checkpointsLookup(
|
|
165
|
+
Checkpoint[] storage ckpts,
|
|
166
|
+
uint256 timepoint
|
|
167
|
+
) private view returns (uint256) {
|
|
168
|
+
// We run a binary search to look for the last (most recent) checkpoint taken before (or at) `timepoint`.
|
|
169
|
+
//
|
|
170
|
+
// Initially we check if the block is recent to narrow the search range.
|
|
171
|
+
// During the loop, the index of the wanted checkpoint remains in the range [low-1, high).
|
|
172
|
+
// With each iteration, either `low` or `high` is moved towards the middle of the range to maintain the invariant.
|
|
173
|
+
// - If the middle checkpoint is after `timepoint`, we look in [low, mid)
|
|
174
|
+
// - If the middle checkpoint is before or equal to `timepoint`, we look in [mid+1, high)
|
|
175
|
+
// Once we reach a single value (when low == high), we've found the right checkpoint at the index high-1, if not
|
|
176
|
+
// out of bounds (in which case we're looking too far in the past and the result is 0).
|
|
177
|
+
// Note that if the latest checkpoint available is exactly for `timepoint`, we end up with an index that is
|
|
178
|
+
// past the end of the array, so we technically don't find a checkpoint after `timepoint`, but it works out
|
|
179
|
+
// the same.
|
|
180
|
+
uint256 length = ckpts.length;
|
|
181
|
+
|
|
182
|
+
uint256 low = 0;
|
|
183
|
+
uint256 high = length;
|
|
184
|
+
|
|
185
|
+
if (length > 5) {
|
|
186
|
+
uint256 mid = length - Math.sqrt(length);
|
|
187
|
+
if (_unsafeAccess(ckpts, mid).fromBlock > timepoint) {
|
|
188
|
+
high = mid;
|
|
189
|
+
} else {
|
|
190
|
+
low = mid + 1;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
while (low < high) {
|
|
195
|
+
uint256 mid = Math.average(low, high);
|
|
196
|
+
if (_unsafeAccess(ckpts, mid).fromBlock > timepoint) {
|
|
197
|
+
high = mid;
|
|
198
|
+
} else {
|
|
199
|
+
low = mid + 1;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
unchecked {
|
|
204
|
+
return high == 0 ? 0 : _unsafeAccess(ckpts, high - 1).votes;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* @dev Delegate votes from the sender to `delegatee`.
|
|
210
|
+
*/
|
|
211
|
+
function delegate(address delegatee) public virtual override {
|
|
212
|
+
_delegate(msg.sender, delegatee);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* @dev Delegates votes from signer to `delegatee`
|
|
217
|
+
*/
|
|
218
|
+
function delegateBySig(
|
|
219
|
+
address delegatee,
|
|
220
|
+
uint256 nonce,
|
|
221
|
+
uint256 expiry,
|
|
222
|
+
uint8 v,
|
|
223
|
+
bytes32 r,
|
|
224
|
+
bytes32 s
|
|
225
|
+
) public virtual override {
|
|
226
|
+
// solhint-disable-next-line not-rely-on-time
|
|
227
|
+
require(block.timestamp <= expiry, "LSP7Votes: signature expired");
|
|
228
|
+
address signer = ECDSA.recover(
|
|
229
|
+
_hashTypedDataV4(
|
|
230
|
+
keccak256(
|
|
231
|
+
abi.encode(_DELEGATION_TYPEHASH, delegatee, nonce, expiry)
|
|
232
|
+
)
|
|
233
|
+
),
|
|
234
|
+
v,
|
|
235
|
+
r,
|
|
236
|
+
s
|
|
237
|
+
);
|
|
238
|
+
require(nonce == _useNonce(signer), "LSP7Votes: invalid nonce");
|
|
239
|
+
_delegate(signer, delegatee);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* @dev Maximum token supply. Defaults to `type(uint224).max` (2^224^ - 1).
|
|
244
|
+
*/
|
|
245
|
+
function _maxSupply() internal view virtual returns (uint224) {
|
|
246
|
+
return type(uint224).max;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* @dev Transfers, mints, or burns voting units. To register a mint, `from` should be zero. To register a burn, `to`
|
|
251
|
+
* should be zero. Total supply of voting units will be adjusted with mints and burns.
|
|
252
|
+
*/
|
|
253
|
+
function _transferVotingUnits(
|
|
254
|
+
address from,
|
|
255
|
+
address to,
|
|
256
|
+
uint256 amount
|
|
257
|
+
) internal virtual {
|
|
258
|
+
if (from == address(0)) {
|
|
259
|
+
_writeCheckpoint(_totalSupplyCheckpoints, _add, amount);
|
|
260
|
+
}
|
|
261
|
+
if (to == address(0)) {
|
|
262
|
+
_writeCheckpoint(_totalSupplyCheckpoints, _subtract, amount);
|
|
263
|
+
}
|
|
264
|
+
_moveVotingPower(delegates(from), delegates(to), amount);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* @dev Move voting power when tokens are transferred.
|
|
269
|
+
*
|
|
270
|
+
* @custom:events
|
|
271
|
+
* - {DelegateVotesChanged} when voting power is removed from source address
|
|
272
|
+
* - {DelegateVotesChanged} when voting power is added to destination address
|
|
273
|
+
*/
|
|
274
|
+
function _update(
|
|
275
|
+
address from,
|
|
276
|
+
address to,
|
|
277
|
+
uint256 value,
|
|
278
|
+
bool force,
|
|
279
|
+
bytes memory data
|
|
280
|
+
) internal virtual override {
|
|
281
|
+
super._update(from, to, value, force, data);
|
|
282
|
+
if (from == address(0)) {
|
|
283
|
+
uint256 supply = totalSupply();
|
|
284
|
+
uint256 cap = _maxSupply();
|
|
285
|
+
require(
|
|
286
|
+
supply <= cap,
|
|
287
|
+
"LSP7Votes: total supply risks overflowing votes"
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
_transferVotingUnits(from, to, value);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* @dev Change delegation for `delegator` to `delegatee`.
|
|
295
|
+
*
|
|
296
|
+
* @custom:events
|
|
297
|
+
* - {DelegateChanged}
|
|
298
|
+
* - {DelegateVotesChanged}
|
|
299
|
+
*/
|
|
300
|
+
function _delegate(address delegator, address delegatee) internal virtual {
|
|
301
|
+
address currentDelegate = delegates(delegator);
|
|
302
|
+
uint256 delegatorBalance = balanceOf(delegator);
|
|
303
|
+
_delegates[delegator] = delegatee;
|
|
304
|
+
|
|
305
|
+
emit DelegateChanged(delegator, currentDelegate, delegatee);
|
|
306
|
+
|
|
307
|
+
_moveVotingPower(currentDelegate, delegatee, delegatorBalance);
|
|
308
|
+
|
|
309
|
+
// Notify the delegator if it's not address(0)
|
|
310
|
+
if (delegator != address(0)) {
|
|
311
|
+
bytes memory delegatorNotificationData = abi.encode(
|
|
312
|
+
msg.sender,
|
|
313
|
+
delegatee,
|
|
314
|
+
delegatorBalance
|
|
315
|
+
);
|
|
316
|
+
LSP1Utils.notifyUniversalReceiver(
|
|
317
|
+
delegator,
|
|
318
|
+
_TYPEID_LSP7_VOTESDELEGATOR,
|
|
319
|
+
delegatorNotificationData
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// Only notify the new delegatee if it's not address(0) and if there's actual voting power
|
|
324
|
+
if (delegatee != address(0) && delegatorBalance > 0) {
|
|
325
|
+
bytes memory delegateeNotificationData = abi.encode(
|
|
326
|
+
msg.sender,
|
|
327
|
+
delegator,
|
|
328
|
+
delegatorBalance
|
|
329
|
+
);
|
|
330
|
+
|
|
331
|
+
LSP1Utils.notifyUniversalReceiver(
|
|
332
|
+
delegatee,
|
|
333
|
+
_TYPEID_LSP7_VOTESDELEGATEE,
|
|
334
|
+
delegateeNotificationData
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* @dev Moves voting power from one address to another.
|
|
341
|
+
*
|
|
342
|
+
* @custom:events
|
|
343
|
+
* - {DelegateVotesChanged} when voting power is removed from source address
|
|
344
|
+
* - {DelegateVotesChanged} when voting power is added to destination address
|
|
345
|
+
*/
|
|
346
|
+
function _moveVotingPower(
|
|
347
|
+
address src,
|
|
348
|
+
address dst,
|
|
349
|
+
uint256 amount
|
|
350
|
+
) private {
|
|
351
|
+
if (src != dst && amount > 0) {
|
|
352
|
+
if (src != address(0)) {
|
|
353
|
+
(uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(
|
|
354
|
+
_checkpoints[src],
|
|
355
|
+
_subtract,
|
|
356
|
+
amount
|
|
357
|
+
);
|
|
358
|
+
emit DelegateVotesChanged(src, oldWeight, newWeight);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
if (dst != address(0)) {
|
|
362
|
+
(uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(
|
|
363
|
+
_checkpoints[dst],
|
|
364
|
+
_add,
|
|
365
|
+
amount
|
|
366
|
+
);
|
|
367
|
+
emit DelegateVotesChanged(dst, oldWeight, newWeight);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function _writeCheckpoint(
|
|
373
|
+
Checkpoint[] storage ckpts,
|
|
374
|
+
function(uint256, uint256) view returns (uint256) op,
|
|
375
|
+
uint256 delta
|
|
376
|
+
) private returns (uint256 oldWeight, uint256 newWeight) {
|
|
377
|
+
uint256 pos = ckpts.length;
|
|
378
|
+
|
|
379
|
+
unchecked {
|
|
380
|
+
Checkpoint memory oldCkpt = pos == 0
|
|
381
|
+
? Checkpoint(0, 0)
|
|
382
|
+
: _unsafeAccess(ckpts, pos - 1);
|
|
383
|
+
|
|
384
|
+
oldWeight = oldCkpt.votes;
|
|
385
|
+
newWeight = op(oldWeight, delta);
|
|
386
|
+
|
|
387
|
+
if (pos > 0 && oldCkpt.fromBlock == clock()) {
|
|
388
|
+
_unsafeAccess(ckpts, pos - 1).votes = SafeCast.toUint224(
|
|
389
|
+
newWeight
|
|
390
|
+
);
|
|
391
|
+
} else {
|
|
392
|
+
ckpts.push(
|
|
393
|
+
Checkpoint({
|
|
394
|
+
fromBlock: SafeCast.toUint32(clock()),
|
|
395
|
+
votes: SafeCast.toUint224(newWeight)
|
|
396
|
+
})
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
function _add(uint256 a, uint256 b) private pure returns (uint256) {
|
|
403
|
+
return a + b;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function _subtract(uint256 a, uint256 b) private pure returns (uint256) {
|
|
407
|
+
return a - b;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.
|
|
412
|
+
*/
|
|
413
|
+
function _unsafeAccess(
|
|
414
|
+
Checkpoint[] storage ckpts,
|
|
415
|
+
uint256 pos
|
|
416
|
+
) private pure returns (Checkpoint storage result) {
|
|
417
|
+
// solhint-disable-next-line no-inline-assembly
|
|
418
|
+
assembly {
|
|
419
|
+
mstore(0, ckpts.slot)
|
|
420
|
+
result.slot := add(keccak256(0, 0x20), pos)
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* @dev Consumes a nonce.
|
|
426
|
+
*
|
|
427
|
+
* Returns the current value and increments nonce.
|
|
428
|
+
*/
|
|
429
|
+
function _useNonce(
|
|
430
|
+
address owner
|
|
431
|
+
) internal virtual returns (uint256 current) {
|
|
432
|
+
Counters.Counter storage nonce = _nonces[owner];
|
|
433
|
+
current = nonce.current();
|
|
434
|
+
nonce.increment();
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* @dev Reads the current nonce
|
|
439
|
+
*/
|
|
440
|
+
function nonces(address owner) public view virtual returns (uint256) {
|
|
441
|
+
return _nonces[owner].current();
|
|
442
|
+
}
|
|
443
|
+
}
|
package/dist/index.cjs
CHANGED
|
@@ -11,7 +11,11 @@ const LSP7_TYPE_IDS = {
|
|
|
11
11
|
// keccak256('LSP7Tokens_RecipientNotification')
|
|
12
12
|
LSP7Tokens_RecipientNotification: "0x20804611b3e2ea21c480dc465142210acf4a2485947541770ec1fb87dee4a55c",
|
|
13
13
|
// keccak256('LSP7Tokens_OperatorNotification')
|
|
14
|
-
LSP7Tokens_OperatorNotification: "0x386072cc5a58e61263b434c722725f21031cd06e7c552cfaa06db5de8a320dbc"
|
|
14
|
+
LSP7Tokens_OperatorNotification: "0x386072cc5a58e61263b434c722725f21031cd06e7c552cfaa06db5de8a320dbc",
|
|
15
|
+
// keccak256('LSP7Tokens_VotesDelegatorNotification')
|
|
16
|
+
LSP7Tokens_VotesDelegatorNotification: "0x6117a486162c4ba8e38d646ef52b1e0e1be6bef05a980c041e232eba8c95e16f",
|
|
17
|
+
// keccak256('LSP7Tokens_VotesDelegateeNotification')
|
|
18
|
+
LSP7Tokens_VotesDelegateeNotification: "0x72cad372b29cde295ff0839b7b194597766b88f5fad4f7d6aef013e0c55dc492"
|
|
15
19
|
};
|
|
16
20
|
|
|
17
21
|
exports.INTERFACE_ID_LSP7 = INTERFACE_ID_LSP7;
|
package/dist/index.d.cts
CHANGED
|
@@ -4,9 +4,11 @@ declare const INTERFACE_ID_LSP7_PREVIOUS: {
|
|
|
4
4
|
'v0.12.0': string;
|
|
5
5
|
};
|
|
6
6
|
declare const LSP7_TYPE_IDS: {
|
|
7
|
-
LSP7Tokens_SenderNotification:
|
|
8
|
-
LSP7Tokens_RecipientNotification:
|
|
9
|
-
LSP7Tokens_OperatorNotification:
|
|
7
|
+
readonly LSP7Tokens_SenderNotification: "0x429ac7a06903dbc9c13dfcb3c9d11df8194581fa047c96d7a4171fc7402958ea";
|
|
8
|
+
readonly LSP7Tokens_RecipientNotification: "0x20804611b3e2ea21c480dc465142210acf4a2485947541770ec1fb87dee4a55c";
|
|
9
|
+
readonly LSP7Tokens_OperatorNotification: "0x386072cc5a58e61263b434c722725f21031cd06e7c552cfaa06db5de8a320dbc";
|
|
10
|
+
readonly LSP7Tokens_VotesDelegatorNotification: "0x6117a486162c4ba8e38d646ef52b1e0e1be6bef05a980c041e232eba8c95e16f";
|
|
11
|
+
readonly LSP7Tokens_VotesDelegateeNotification: "0x72cad372b29cde295ff0839b7b194597766b88f5fad4f7d6aef013e0c55dc492";
|
|
10
12
|
};
|
|
11
13
|
|
|
12
14
|
export { INTERFACE_ID_LSP7, INTERFACE_ID_LSP7_PREVIOUS, LSP7_TYPE_IDS };
|
package/dist/index.d.mts
CHANGED
|
@@ -4,9 +4,11 @@ declare const INTERFACE_ID_LSP7_PREVIOUS: {
|
|
|
4
4
|
'v0.12.0': string;
|
|
5
5
|
};
|
|
6
6
|
declare const LSP7_TYPE_IDS: {
|
|
7
|
-
LSP7Tokens_SenderNotification:
|
|
8
|
-
LSP7Tokens_RecipientNotification:
|
|
9
|
-
LSP7Tokens_OperatorNotification:
|
|
7
|
+
readonly LSP7Tokens_SenderNotification: "0x429ac7a06903dbc9c13dfcb3c9d11df8194581fa047c96d7a4171fc7402958ea";
|
|
8
|
+
readonly LSP7Tokens_RecipientNotification: "0x20804611b3e2ea21c480dc465142210acf4a2485947541770ec1fb87dee4a55c";
|
|
9
|
+
readonly LSP7Tokens_OperatorNotification: "0x386072cc5a58e61263b434c722725f21031cd06e7c552cfaa06db5de8a320dbc";
|
|
10
|
+
readonly LSP7Tokens_VotesDelegatorNotification: "0x6117a486162c4ba8e38d646ef52b1e0e1be6bef05a980c041e232eba8c95e16f";
|
|
11
|
+
readonly LSP7Tokens_VotesDelegateeNotification: "0x72cad372b29cde295ff0839b7b194597766b88f5fad4f7d6aef013e0c55dc492";
|
|
10
12
|
};
|
|
11
13
|
|
|
12
14
|
export { INTERFACE_ID_LSP7, INTERFACE_ID_LSP7_PREVIOUS, LSP7_TYPE_IDS };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,9 +4,11 @@ declare const INTERFACE_ID_LSP7_PREVIOUS: {
|
|
|
4
4
|
'v0.12.0': string;
|
|
5
5
|
};
|
|
6
6
|
declare const LSP7_TYPE_IDS: {
|
|
7
|
-
LSP7Tokens_SenderNotification:
|
|
8
|
-
LSP7Tokens_RecipientNotification:
|
|
9
|
-
LSP7Tokens_OperatorNotification:
|
|
7
|
+
readonly LSP7Tokens_SenderNotification: "0x429ac7a06903dbc9c13dfcb3c9d11df8194581fa047c96d7a4171fc7402958ea";
|
|
8
|
+
readonly LSP7Tokens_RecipientNotification: "0x20804611b3e2ea21c480dc465142210acf4a2485947541770ec1fb87dee4a55c";
|
|
9
|
+
readonly LSP7Tokens_OperatorNotification: "0x386072cc5a58e61263b434c722725f21031cd06e7c552cfaa06db5de8a320dbc";
|
|
10
|
+
readonly LSP7Tokens_VotesDelegatorNotification: "0x6117a486162c4ba8e38d646ef52b1e0e1be6bef05a980c041e232eba8c95e16f";
|
|
11
|
+
readonly LSP7Tokens_VotesDelegateeNotification: "0x72cad372b29cde295ff0839b7b194597766b88f5fad4f7d6aef013e0c55dc492";
|
|
10
12
|
};
|
|
11
13
|
|
|
12
14
|
export { INTERFACE_ID_LSP7, INTERFACE_ID_LSP7_PREVIOUS, LSP7_TYPE_IDS };
|
package/dist/index.mjs
CHANGED
|
@@ -9,7 +9,11 @@ const LSP7_TYPE_IDS = {
|
|
|
9
9
|
// keccak256('LSP7Tokens_RecipientNotification')
|
|
10
10
|
LSP7Tokens_RecipientNotification: "0x20804611b3e2ea21c480dc465142210acf4a2485947541770ec1fb87dee4a55c",
|
|
11
11
|
// keccak256('LSP7Tokens_OperatorNotification')
|
|
12
|
-
LSP7Tokens_OperatorNotification: "0x386072cc5a58e61263b434c722725f21031cd06e7c552cfaa06db5de8a320dbc"
|
|
12
|
+
LSP7Tokens_OperatorNotification: "0x386072cc5a58e61263b434c722725f21031cd06e7c552cfaa06db5de8a320dbc",
|
|
13
|
+
// keccak256('LSP7Tokens_VotesDelegatorNotification')
|
|
14
|
+
LSP7Tokens_VotesDelegatorNotification: "0x6117a486162c4ba8e38d646ef52b1e0e1be6bef05a980c041e232eba8c95e16f",
|
|
15
|
+
// keccak256('LSP7Tokens_VotesDelegateeNotification')
|
|
16
|
+
LSP7Tokens_VotesDelegateeNotification: "0x72cad372b29cde295ff0839b7b194597766b88f5fad4f7d6aef013e0c55dc492"
|
|
13
17
|
};
|
|
14
18
|
|
|
15
19
|
export { INTERFACE_ID_LSP7, INTERFACE_ID_LSP7_PREVIOUS, LSP7_TYPE_IDS };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lukso/lsp7-contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.3",
|
|
4
4
|
"description": "Package for the LSP7 Digital Asset standard",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "",
|
|
@@ -40,18 +40,17 @@
|
|
|
40
40
|
"build": "hardhat compile --show-stack-traces",
|
|
41
41
|
"build:js": "unbuild",
|
|
42
42
|
"build:types": "npx wagmi generate",
|
|
43
|
-
"clean": "hardhat clean && rm -Rf dist/",
|
|
43
|
+
"clean": "hardhat clean && rm -Rf dist/ cache/ node_modules/ .turbo/ types/ typechain/ build/ artifacts/",
|
|
44
44
|
"format": "prettier --write .",
|
|
45
45
|
"lint": "eslint . --ext .ts,.js",
|
|
46
46
|
"lint:solidity": "solhint 'contracts/**/*.sol' && prettier --check 'contracts/**/*.sol'",
|
|
47
47
|
"package": "hardhat prepare-package"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@
|
|
51
|
-
"@openzeppelin/contracts": "^4.9.3",
|
|
50
|
+
"@openzeppelin/contracts": "^4.9.6",
|
|
52
51
|
"@lukso/lsp1-contracts": "~0.15.0",
|
|
53
52
|
"@lukso/lsp2-contracts": "~0.15.0",
|
|
54
|
-
"@lukso/lsp4-contracts": "~0.
|
|
55
|
-
"@lukso/lsp17contractextension-contracts": "~0.
|
|
53
|
+
"@lukso/lsp4-contracts": "~0.16.0",
|
|
54
|
+
"@lukso/lsp17contractextension-contracts": "~0.16.0"
|
|
56
55
|
}
|
|
57
56
|
}
|