@lukso/lsp7-contracts 0.16.2 → 0.16.4
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 +47 -1
- package/contracts/ILSP7DigitalAsset.sol +3 -0
- package/contracts/LSP7DigitalAsset.sol +8 -40
- package/contracts/LSP7DigitalAssetInitAbstract.sol +15 -45
- package/dist/abi.cjs +4806 -0
- package/dist/abi.d.cts +7104 -0
- package/dist/abi.d.mts +7104 -0
- package/dist/abi.d.ts +7104 -0
- package/dist/abi.mjs +4794 -0
- package/package.json +32 -24
- package/artifacts/ILSP7DigitalAsset.json +0 -391
- package/artifacts/LSP7Burnable.json +0 -817
- package/artifacts/LSP7BurnableInitAbstract.json +0 -825
- package/artifacts/LSP7CappedSupply.json +0 -817
- package/artifacts/LSP7CappedSupplyInitAbstract.json +0 -825
- package/artifacts/LSP7DigitalAsset.json +0 -794
- package/artifacts/LSP7DigitalAssetInitAbstract.json +0 -802
- package/artifacts/LSP7Mintable.json +0 -853
- package/artifacts/LSP7MintableInit.json +0 -873
- package/artifacts/LSP7Votes.json +0 -1154
- package/artifacts/LSP7VotesInitAbstract.json +0 -1146
- package/types/index.ts +0 -9021
- /package/dist/{index.cjs → constants.cjs} +0 -0
- /package/dist/{index.d.cts → constants.d.cts} +0 -0
- /package/dist/{index.d.mts → constants.d.mts} +0 -0
- /package/dist/{index.d.ts → constants.d.ts} +0 -0
- /package/dist/{index.mjs → constants.mjs} +0 -0
package/README.md
CHANGED
|
@@ -10,7 +10,9 @@ npm install @lukso/lsp7-contracts
|
|
|
10
10
|
|
|
11
11
|
## Available Constants & Types
|
|
12
12
|
|
|
13
|
-
The `@lukso/lsp7-contracts` npm package contains useful constants such as interface IDs or ERC725Y data keys related to the LSP7 Standard. You can import and access them as follows
|
|
13
|
+
The `@lukso/lsp7-contracts` npm package contains useful constants such as interface IDs or ERC725Y data keys related to the LSP7 Standard. You can import and access them as follows.
|
|
14
|
+
|
|
15
|
+
In Javascript.
|
|
14
16
|
|
|
15
17
|
```js
|
|
16
18
|
import {
|
|
@@ -19,3 +21,47 @@ import {
|
|
|
19
21
|
LSP7_TYPE_IDS,
|
|
20
22
|
} from "@lukso/lsp7-contracts";
|
|
21
23
|
```
|
|
24
|
+
|
|
25
|
+
In Solidity.
|
|
26
|
+
|
|
27
|
+
<!-- prettier-ignore -->
|
|
28
|
+
```solidity
|
|
29
|
+
import {
|
|
30
|
+
_INTERFACEID_LSP7,
|
|
31
|
+
_INTERFACEID_LSP7_V0_12_0,
|
|
32
|
+
_INTERFACEID_LSP7_V0_14_0,
|
|
33
|
+
_TYPEID_LSP7_DELEGATOR,
|
|
34
|
+
_TYPEID_LSP7_DELEGATEE,
|
|
35
|
+
_TYPEID_LSP7_TOKENSSENDER,
|
|
36
|
+
_TYPEID_LSP7_TOKENSRECIPIENT,
|
|
37
|
+
_TYPEID_LSP7_TOKENOPERATOR
|
|
38
|
+
} from "@lukso/lsp7-contracts/contracts/LSP7Constants.sol";
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The `LSP7_TYPE_IDS` includes type IDs for the following type of notifications:
|
|
42
|
+
|
|
43
|
+
```console
|
|
44
|
+
'LSP7Tokens_SenderNotification';
|
|
45
|
+
'LSP7Tokens_RecipientNotification';
|
|
46
|
+
'LSP7Tokens_OperatorNotification';
|
|
47
|
+
'LSP7Tokens_VotesDelegatorNotification';
|
|
48
|
+
'LSP7Tokens_VotesDelegateeNotification';
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Typescript types
|
|
52
|
+
|
|
53
|
+
You can also import the [type-safe ABI](https://abitype.dev/) from the `/abi` path.
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import {
|
|
57
|
+
// standard version
|
|
58
|
+
lsp7DigitalAssetAbi,
|
|
59
|
+
lsp7CappedSupplyAbi,
|
|
60
|
+
lsp7MintableAbi,
|
|
61
|
+
lsp7VotesAbi
|
|
62
|
+
// proxy version
|
|
63
|
+
lsp7CappedSupplyInitAbstractAbi,
|
|
64
|
+
lsp7DigitalAssetInitAbstractAbi,
|
|
65
|
+
lsp7MintableInitAbi,
|
|
66
|
+
} from '@lukso/lsp7-contracts/abi';
|
|
67
|
+
```
|
|
@@ -250,6 +250,9 @@ interface ILSP7DigitalAsset {
|
|
|
250
250
|
*
|
|
251
251
|
* @custom:info if the `to` address is a contract that implements LSP1, it will always be notified via its `universalReceiver(...)` function, regardless if `force` is set to `true` or `false`.
|
|
252
252
|
*
|
|
253
|
+
* @custom:info Note that token transfers revert when no allowance is given, including when the `amount` is `0`.
|
|
254
|
+
* This is to prevent this function from being used maliciously, such as performing zero-value token transfer phishing attacks.
|
|
255
|
+
*
|
|
253
256
|
* @custom:warning Be aware that when either the sender or the recipient can have logic that revert in their `universalReceiver(...)` function when being notified.
|
|
254
257
|
* This even if the `force` was set to `true`.
|
|
255
258
|
*/
|
|
@@ -602,19 +602,7 @@ abstract contract LSP7DigitalAsset is
|
|
|
602
602
|
|
|
603
603
|
_beforeTokenTransfer(address(0), to, amount, force, data);
|
|
604
604
|
|
|
605
|
-
|
|
606
|
-
_existingTokens += amount;
|
|
607
|
-
|
|
608
|
-
_tokenOwnerBalances[to] += amount;
|
|
609
|
-
|
|
610
|
-
emit Transfer({
|
|
611
|
-
operator: msg.sender,
|
|
612
|
-
from: address(0),
|
|
613
|
-
to: to,
|
|
614
|
-
amount: amount,
|
|
615
|
-
force: force,
|
|
616
|
-
data: data
|
|
617
|
-
});
|
|
605
|
+
_update(address(0), to, amount, force, data);
|
|
618
606
|
|
|
619
607
|
_afterTokenTransfer(address(0), to, amount, force, data);
|
|
620
608
|
|
|
@@ -664,23 +652,7 @@ abstract contract LSP7DigitalAsset is
|
|
|
664
652
|
|
|
665
653
|
_beforeTokenTransfer(from, address(0), amount, false, data);
|
|
666
654
|
|
|
667
|
-
|
|
668
|
-
if (amount > balance) {
|
|
669
|
-
revert LSP7AmountExceedsBalance(balance, from, amount);
|
|
670
|
-
}
|
|
671
|
-
// tokens being burnt
|
|
672
|
-
_existingTokens -= amount;
|
|
673
|
-
|
|
674
|
-
_tokenOwnerBalances[from] -= amount;
|
|
675
|
-
|
|
676
|
-
emit Transfer({
|
|
677
|
-
operator: msg.sender,
|
|
678
|
-
from: from,
|
|
679
|
-
to: address(0),
|
|
680
|
-
amount: amount,
|
|
681
|
-
force: false,
|
|
682
|
-
data: data
|
|
683
|
-
});
|
|
655
|
+
_update(from, address(0), amount, false, data);
|
|
684
656
|
|
|
685
657
|
_afterTokenTransfer(from, address(0), amount, false, data);
|
|
686
658
|
|
|
@@ -786,9 +758,10 @@ abstract contract LSP7DigitalAsset is
|
|
|
786
758
|
}
|
|
787
759
|
|
|
788
760
|
/**
|
|
789
|
-
* @dev Transfers `amount` of tokens from `from` to `to
|
|
790
|
-
*
|
|
791
|
-
*
|
|
761
|
+
* @dev Transfers `amount` of tokens from `from` to `to`.
|
|
762
|
+
* Alternatively mints or burns if `from` or `to` is the zero address.
|
|
763
|
+
*
|
|
764
|
+
* @custom:info All customizations to transfers, mints, and burns should be done by overriding this function.
|
|
792
765
|
*
|
|
793
766
|
* @custom:events {Transfer} event.
|
|
794
767
|
*/
|
|
@@ -804,9 +777,11 @@ abstract contract LSP7DigitalAsset is
|
|
|
804
777
|
_existingTokens += amount;
|
|
805
778
|
} else {
|
|
806
779
|
uint256 fromBalance = _tokenOwnerBalances[from];
|
|
780
|
+
|
|
807
781
|
if (fromBalance < amount) {
|
|
808
782
|
revert LSP7AmountExceedsBalance(fromBalance, from, amount);
|
|
809
783
|
}
|
|
784
|
+
|
|
810
785
|
unchecked {
|
|
811
786
|
// Overflow not possible: amount <= fromBalance <= totalSupply.
|
|
812
787
|
_tokenOwnerBalances[from] = fromBalance - amount;
|
|
@@ -833,13 +808,6 @@ abstract contract LSP7DigitalAsset is
|
|
|
833
808
|
force: force,
|
|
834
809
|
data: data
|
|
835
810
|
});
|
|
836
|
-
|
|
837
|
-
_afterTokenTransfer(from, to, amount, force, data);
|
|
838
|
-
|
|
839
|
-
bytes memory lsp1Data = abi.encode(msg.sender, from, to, amount, data);
|
|
840
|
-
|
|
841
|
-
_notifyTokenSender(from, lsp1Data);
|
|
842
|
-
_notifyTokenReceiver(to, force, lsp1Data);
|
|
843
811
|
}
|
|
844
812
|
|
|
845
813
|
/**
|
|
@@ -19,8 +19,8 @@ import {
|
|
|
19
19
|
ERC725YInitAbstract
|
|
20
20
|
} from "@lukso/lsp4-contracts/contracts/LSP4DigitalAssetMetadataInitAbstract.sol";
|
|
21
21
|
import {
|
|
22
|
-
|
|
23
|
-
} from "@lukso/lsp17contractextension-contracts/contracts/
|
|
22
|
+
LSP17ExtendableInitAbstract
|
|
23
|
+
} from "@lukso/lsp17contractextension-contracts/contracts/LSP17ExtendableInitAbstract.sol";
|
|
24
24
|
|
|
25
25
|
// libraries
|
|
26
26
|
import {LSP1Utils} from "@lukso/lsp1-contracts/contracts/LSP1Utils.sol";
|
|
@@ -77,7 +77,7 @@ import {
|
|
|
77
77
|
abstract contract LSP7DigitalAssetInitAbstract is
|
|
78
78
|
ILSP7DigitalAsset,
|
|
79
79
|
LSP4DigitalAssetMetadataInitAbstract,
|
|
80
|
-
|
|
80
|
+
LSP17ExtendableInitAbstract
|
|
81
81
|
{
|
|
82
82
|
using EnumerableSet for EnumerableSet.AddressSet;
|
|
83
83
|
|
|
@@ -236,13 +236,15 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
236
236
|
public
|
|
237
237
|
view
|
|
238
238
|
virtual
|
|
239
|
-
override(ERC725YInitAbstract,
|
|
239
|
+
override(ERC725YInitAbstract, LSP17ExtendableInitAbstract)
|
|
240
240
|
returns (bool)
|
|
241
241
|
{
|
|
242
242
|
return
|
|
243
243
|
interfaceId == _INTERFACEID_LSP7 ||
|
|
244
244
|
super.supportsInterface(interfaceId) ||
|
|
245
|
-
|
|
245
|
+
LSP17ExtendableInitAbstract._supportsInterfaceInERC165Extension(
|
|
246
|
+
interfaceId
|
|
247
|
+
);
|
|
246
248
|
}
|
|
247
249
|
|
|
248
250
|
// --- Token queries
|
|
@@ -615,19 +617,7 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
615
617
|
|
|
616
618
|
_beforeTokenTransfer(address(0), to, amount, force, data);
|
|
617
619
|
|
|
618
|
-
|
|
619
|
-
_existingTokens += amount;
|
|
620
|
-
|
|
621
|
-
_tokenOwnerBalances[to] += amount;
|
|
622
|
-
|
|
623
|
-
emit Transfer({
|
|
624
|
-
operator: msg.sender,
|
|
625
|
-
from: address(0),
|
|
626
|
-
to: to,
|
|
627
|
-
amount: amount,
|
|
628
|
-
force: force,
|
|
629
|
-
data: data
|
|
630
|
-
});
|
|
620
|
+
_update(address(0), to, amount, force, data);
|
|
631
621
|
|
|
632
622
|
_afterTokenTransfer(address(0), to, amount, force, data);
|
|
633
623
|
|
|
@@ -677,23 +667,7 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
677
667
|
|
|
678
668
|
_beforeTokenTransfer(from, address(0), amount, false, data);
|
|
679
669
|
|
|
680
|
-
|
|
681
|
-
if (amount > balance) {
|
|
682
|
-
revert LSP7AmountExceedsBalance(balance, from, amount);
|
|
683
|
-
}
|
|
684
|
-
// tokens being burnt
|
|
685
|
-
_existingTokens -= amount;
|
|
686
|
-
|
|
687
|
-
_tokenOwnerBalances[from] -= amount;
|
|
688
|
-
|
|
689
|
-
emit Transfer({
|
|
690
|
-
operator: msg.sender,
|
|
691
|
-
from: from,
|
|
692
|
-
to: address(0),
|
|
693
|
-
amount: amount,
|
|
694
|
-
force: false,
|
|
695
|
-
data: data
|
|
696
|
-
});
|
|
670
|
+
_update(from, address(0), amount, false, data);
|
|
697
671
|
|
|
698
672
|
_afterTokenTransfer(from, address(0), amount, false, data);
|
|
699
673
|
|
|
@@ -799,9 +773,10 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
799
773
|
}
|
|
800
774
|
|
|
801
775
|
/**
|
|
802
|
-
* @dev Transfers `amount` of tokens from `from` to `to
|
|
803
|
-
*
|
|
804
|
-
*
|
|
776
|
+
* @dev Transfers `amount` of tokens from `from` to `to`.
|
|
777
|
+
* Alternatively mints or burns `amount` of tokens if `from` or `to` is the zero address.
|
|
778
|
+
*
|
|
779
|
+
* @custom:info All customizations to transfers, mints, and burns should be done by overriding this function.
|
|
805
780
|
*
|
|
806
781
|
* @custom:events {Transfer} event.
|
|
807
782
|
*/
|
|
@@ -817,9 +792,11 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
817
792
|
_existingTokens += amount;
|
|
818
793
|
} else {
|
|
819
794
|
uint256 fromBalance = _tokenOwnerBalances[from];
|
|
795
|
+
|
|
820
796
|
if (fromBalance < amount) {
|
|
821
797
|
revert LSP7AmountExceedsBalance(fromBalance, from, amount);
|
|
822
798
|
}
|
|
799
|
+
|
|
823
800
|
unchecked {
|
|
824
801
|
// Overflow not possible: amount <= fromBalance <= totalSupply.
|
|
825
802
|
_tokenOwnerBalances[from] = fromBalance - amount;
|
|
@@ -846,13 +823,6 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
846
823
|
force: force,
|
|
847
824
|
data: data
|
|
848
825
|
});
|
|
849
|
-
|
|
850
|
-
_afterTokenTransfer(from, to, amount, force, data);
|
|
851
|
-
|
|
852
|
-
bytes memory lsp1Data = abi.encode(msg.sender, from, to, amount, data);
|
|
853
|
-
|
|
854
|
-
_notifyTokenSender(from, lsp1Data);
|
|
855
|
-
_notifyTokenReceiver(to, force, lsp1Data);
|
|
856
826
|
}
|
|
857
827
|
|
|
858
828
|
/**
|