@lukso/lsp-smart-contracts 0.4.3 → 0.6.1
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 +38 -9
- package/artifacts/LSP0ERC725Account.json +398 -0
- package/artifacts/LSP0ERC725AccountInit.json +439 -0
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +7 -7
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +7 -7
- package/artifacts/LSP4Compatibility.json +195 -0
- package/artifacts/LSP4DigitalAssetMetadata.json +169 -0
- package/artifacts/LSP4DigitalAssetMetadataInit.json +231 -0
- package/artifacts/LSP6KeyManager.json +50 -28
- package/artifacts/LSP6KeyManagerInit.json +58 -23
- package/artifacts/LSP7CappedSupply.json +136 -11
- package/artifacts/LSP7CappedSupplyInit.json +163 -35
- package/artifacts/LSP7CompatibilityForERC20.json +204 -13
- package/artifacts/LSP7CompatibilityForERC20Init.json +727 -0
- package/artifacts/LSP7DigitalAsset.json +128 -13
- package/artifacts/LSP7DigitalAssetInit.json +152 -34
- package/artifacts/LSP7Mintable.json +129 -14
- package/artifacts/LSP7MintableInit.json +153 -35
- package/artifacts/LSP8CappedSupply.json +137 -11
- package/artifacts/LSP8CappedSupplyInit.json +172 -20
- package/artifacts/LSP8CompatibilityForERC721.json +138 -17
- package/artifacts/LSP8CompatibilityForERC721Init.json +873 -0
- package/artifacts/LSP8IdentifiableDigitalAsset.json +129 -13
- package/artifacts/LSP8IdentifiableDigitalAssetInit.json +161 -19
- package/artifacts/LSP8Mintable.json +141 -14
- package/artifacts/LSP8MintableInit.json +173 -20
- package/artifacts/LSP9Vault.json +374 -0
- package/artifacts/LSP9VaultInit.json +415 -0
- package/artifacts/UniversalFactory.json +127 -0
- package/artifacts/UniversalProfile.json +78 -53
- package/artifacts/UniversalProfileInit.json +117 -53
- package/artifacts/UniversalReceiverAddressStore.json +209 -0
- package/constants.js +500 -0
- package/contracts/Custom/ClaimOwnership.sol +31 -0
- package/contracts/Custom/ERC165Checker.sol +130 -0
- package/contracts/Custom/IClaimOwnership.sol +10 -0
- package/contracts/Factories/UniversalFactory.sol +155 -0
- package/contracts/LSP0ERC725Account/LSP0Constants.sol +5 -9
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +6 -8
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +92 -48
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +5 -5
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +6 -21
- package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +10 -0
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +3 -0
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +4 -2
- package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +3 -9
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/Handling/TokenAndVaultHandling.sol +61 -165
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +49 -6
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/Handling/TokenHandling.sol +50 -90
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +40 -6
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +48 -0
- package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +205 -0
- package/contracts/LSP3UniversalProfile/LSP3Constants.sol +11 -0
- package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4Compatibility.sol +6 -15
- package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +10 -4
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +11 -8
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInit.sol +9 -13
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +14 -20
- package/contracts/LSP5ReceivedAssets/LSP5Constants.sol +10 -0
- package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +205 -0
- package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +21 -18
- package/contracts/LSP6KeyManager/LSP6Constants.sol +61 -24
- package/contracts/LSP6KeyManager/LSP6Errors.sol +37 -0
- package/contracts/LSP6KeyManager/LSP6KeyManager.sol +3 -4
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +475 -260
- package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +6 -5
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +7 -15
- package/contracts/LSP6KeyManager/LSP6Utils.sol +111 -0
- package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +3 -8
- package/contracts/LSP7DigitalAsset/LSP7Constants.sol +5 -4
- package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +22 -8
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +70 -96
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInit.sol +8 -9
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +23 -21
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +23 -0
- package/contracts/LSP7DigitalAsset/extensions/ILSP7CappedSupply.sol +1 -1
- package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibilityForERC20.sol +22 -6
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +7 -6
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyCore.sol +14 -12
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInit.sol +3 -8
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +9 -17
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20.sol +37 -45
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20Core.sol +107 -0
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20Init.sol +22 -0
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20InitAbstract.sol +66 -0
- package/contracts/LSP7DigitalAsset/{extensions → presets}/ILSP7Mintable.sol +1 -1
- package/contracts/LSP7DigitalAsset/{extensions → presets}/LSP7Mintable.sol +4 -3
- package/contracts/LSP7DigitalAsset/{extensions → presets}/LSP7MintableCore.sol +5 -5
- package/contracts/LSP7DigitalAsset/{extensions → presets}/LSP7MintableInit.sol +3 -2
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +34 -0
- package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +5 -16
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +6 -3
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +22 -0
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +21 -8
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +102 -135
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInit.sol +8 -11
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +22 -19
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CappedSupply.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibilityForERC721.sol +17 -22
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +9 -15
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyCore.sol +14 -12
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInit.sol +3 -8
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +9 -18
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721.sol +37 -189
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721Core.sol +187 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721Init.sol +25 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721InitAbstract.sol +89 -0
- package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/ILSP8Mintable.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/LSP8Mintable.sol +4 -3
- package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/LSP8MintableCore.sol +5 -8
- package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/LSP8MintableInit.sol +4 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +35 -0
- package/contracts/LSP9Vault/LSP9Constants.sol +14 -5
- package/contracts/LSP9Vault/LSP9Vault.sol +15 -37
- package/contracts/LSP9Vault/LSP9VaultCore.sol +105 -85
- package/contracts/LSP9Vault/LSP9VaultInit.sol +5 -4
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +15 -45
- package/contracts/Legacy/Registries/AddressRegistry.sol +43 -0
- package/contracts/Legacy/Registries/AddressRegistryRequiresERC725.sol +33 -0
- package/contracts/Legacy/UniversalReceiverAddressStore.sol +60 -0
- package/contracts/UniversalProfile.sol +11 -20
- package/contracts/UniversalProfileInit.sol +5 -4
- package/contracts/UniversalProfileInitAbstract.sol +14 -35
- package/contracts/Utils/UtilsLib.sol +47 -11
- package/package.json +23 -9
- package/artifacts/LSP1UniversalReceiverDelegateUPInit.json +0 -66
- package/artifacts/LSP1UniversalReceiverDelegateVaultInit.json +0 -66
- package/constants.ts +0 -350
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPCore.sol +0 -52
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPInit.sol +0 -26
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPInitAbstract.sol +0 -28
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultCore.sol +0 -41
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultInit.sol +0 -23
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultInitAbstract.sol +0 -25
- package/contracts/LSP7DigitalAsset/extensions/LSP7MintableInitAbstract.sol +0 -47
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8MintableInitAbstract.sol +0 -44
- package/contracts/UniversalProfileCore.sol +0 -56
- package/contracts/Utils/ERC725Utils.sol +0 -169
- package/contracts/Utils/LSP2Utils.sol +0 -127
- package/contracts/Utils/LSP6Utils.sol +0 -77
package/constants.js
ADDED
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Set of constants values as defined in each LUKSO Standards Proposals (LSPs).
|
|
3
|
+
* @see https://github.com/lukso-network/LIPs/tree/main/LSPs
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// ERC165
|
|
7
|
+
// ----------
|
|
8
|
+
|
|
9
|
+
const INTERFACE_IDS = {
|
|
10
|
+
ERC165: '0x01ffc9a7',
|
|
11
|
+
ERC1271: '0x1626ba7e',
|
|
12
|
+
ERC20: '0x36372b07',
|
|
13
|
+
ERC223: '0x87d43052',
|
|
14
|
+
ERC721: '0x80ac58cd',
|
|
15
|
+
ERC721Metadata: '0x5b5e139f',
|
|
16
|
+
ERC777: '0xe58e113c',
|
|
17
|
+
ERC1155: '0xd9b67a26',
|
|
18
|
+
ERC725X: '0x44c028fe',
|
|
19
|
+
ERC725Y: '0x714df77c',
|
|
20
|
+
LSP0ERC725Account: '0x9a3bfe88',
|
|
21
|
+
LSP1UniversalReceiver: '0x6bb56a14',
|
|
22
|
+
LSP1UniversalReceiverDelegate: '0xa245bbda',
|
|
23
|
+
LSP6KeyManager: '0xc403d48f',
|
|
24
|
+
LSP7DigitalAsset: '0xe33f65c3',
|
|
25
|
+
LSP8IdentifiableDigitalAsset: '0x49399145',
|
|
26
|
+
LSP9Vault: '0x8c1d44f6',
|
|
27
|
+
ClaimOwnership: '0xad7dd9b0',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// ERC1271
|
|
31
|
+
// ----------
|
|
32
|
+
|
|
33
|
+
const ERC1271_VALUES = {
|
|
34
|
+
MAGIC_VALUE: '0x1626ba7e',
|
|
35
|
+
FAIL_VALUE: '0xffffffff',
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// ERC725X
|
|
39
|
+
// ----------
|
|
40
|
+
|
|
41
|
+
const OPERATION_TYPES = {
|
|
42
|
+
CALL: 0,
|
|
43
|
+
CREATE: 1,
|
|
44
|
+
CREATE2: 2,
|
|
45
|
+
STATICCALL: 3,
|
|
46
|
+
DELEGATECALL: 4,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// ERC725Y
|
|
50
|
+
// ----------
|
|
51
|
+
|
|
52
|
+
const SupportedStandards = {
|
|
53
|
+
LSP3UniversalProfile: {
|
|
54
|
+
key: '0xeafec4d89fa9619884b60000abe425d64acd861a49b8ddf5c0b6962110481f38',
|
|
55
|
+
value: '0xabe425d6',
|
|
56
|
+
},
|
|
57
|
+
LSP4DigitalAsset: {
|
|
58
|
+
key: '0xeafec4d89fa9619884b60000a4d96624a38f7ac2d8d9a604ecf07c12c77e480c',
|
|
59
|
+
value: '0xa4d96624',
|
|
60
|
+
},
|
|
61
|
+
LSP9Vault: {
|
|
62
|
+
key: '0xeafec4d89fa9619884b600007c0334a14085fefa8b51ae5a40895018882bdb90',
|
|
63
|
+
value: '0x7c0334a1',
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* For more infos on the type of each keys
|
|
69
|
+
* @see https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-2-ERC725YJSONSchema.md
|
|
70
|
+
*/
|
|
71
|
+
const ERC725YKeys = {
|
|
72
|
+
LSP0: {
|
|
73
|
+
// keccak256('LSP1UniversalReceiverDelegate')
|
|
74
|
+
LSP1UniversalReceiverDelegate:
|
|
75
|
+
'0x0cfc51aec37c55a4d0b1a65c6255c4bf2fbdf6277f3cc0730c45b828b6db8b47',
|
|
76
|
+
},
|
|
77
|
+
LSP3: {
|
|
78
|
+
// keccak256('LSP3Profile')
|
|
79
|
+
LSP3Profile: '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5',
|
|
80
|
+
},
|
|
81
|
+
LSP4: {
|
|
82
|
+
// keccak256('LSP4TokenName')
|
|
83
|
+
LSP4TokenName: '0xdeba1e292f8ba88238e10ab3c7f88bd4be4fac56cad5194b6ecceaf653468af1',
|
|
84
|
+
// keccak256('LSP4TokenSymbol')
|
|
85
|
+
LSP4TokenSymbol: '0x2f0a68ab07768e01943a599e73362a0e17a63a72e94dd2e384d2c1d4db932756',
|
|
86
|
+
// keccak256('LSP4Metadata')
|
|
87
|
+
LSP4Metadata: '0x9afb95cacc9f95858ec44aa8c3b685511002e30ae54415823f406128b85b238e',
|
|
88
|
+
// keccak256('"LSP4Creators[]')
|
|
89
|
+
'LSP4Creators[]': {
|
|
90
|
+
// use this key to get the number of elements in the array
|
|
91
|
+
length: '0x114bd03b3a46d48759680d81ebb2b414fda7d030a7105a851867accf1c2352e7',
|
|
92
|
+
// use this key + bytes16(index) to access an index in the array
|
|
93
|
+
index: '0x114bd03b3a46d48759680d81ebb2b414',
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
LSP5: {
|
|
97
|
+
// LSP5ReceivedAssetsMap:<address>
|
|
98
|
+
LSP5ReceivedAssetsMap: '0x812c4334633eb816c80d0000',
|
|
99
|
+
// keccak256('LSP5ReceivedAssets[]')
|
|
100
|
+
'LSP5ReceivedAssets[]': {
|
|
101
|
+
length: '0x6460ee3c0aac563ccbf76d6e1d07bada78e3a9514e6382b736ed3f478ab7b90b',
|
|
102
|
+
index: '0x6460ee3c0aac563ccbf76d6e1d07bada',
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
LSP6: {
|
|
106
|
+
// keccak256('AddressPermissions[]')
|
|
107
|
+
'AddressPermissions[]': {
|
|
108
|
+
length: '0xdf30dba06db6a30e65354d9a64c609861f089545ca58c6b4dbe31a5f338cb0e3',
|
|
109
|
+
index: '0xdf30dba06db6a30e65354d9a64c60986',
|
|
110
|
+
},
|
|
111
|
+
// AddressPermissions:Permissions:<address>
|
|
112
|
+
'AddressPermissions:Permissions': '0x4b80742de2bf82acb3630000',
|
|
113
|
+
// AddressPermissions:AllowedAddresses:<address>
|
|
114
|
+
'AddressPermissions:AllowedAddresses': '0x4b80742de2bfc6dd6b3c0000',
|
|
115
|
+
// AddressPermissions:AllowedFunctions:<address>
|
|
116
|
+
'AddressPermissions:AllowedFunctions': '0x4b80742de2bf8efea1e80000',
|
|
117
|
+
// AddressPermissions:AllowedStandards:<address>
|
|
118
|
+
'AddressPermissions:AllowedStandards': '0x4b80742de2bf3efa94a30000',
|
|
119
|
+
// AddressPermissions:AllowedERC725YKeys:<address>
|
|
120
|
+
'AddressPermissions:AllowedERC725YKeys': '0x4b80742de2bf90b8b4850000',
|
|
121
|
+
},
|
|
122
|
+
LSP10: {
|
|
123
|
+
// keccak256('LSP10VaultsMap')
|
|
124
|
+
LSP10VaultsMap: '0x192448c3c0f88c7f238c0000',
|
|
125
|
+
// keccak256('LSP10Vaults[]')
|
|
126
|
+
'LSP10Vaults[]': {
|
|
127
|
+
length: '0x55482936e01da86729a45d2b87a6b1d3bc582bea0ec00e38bdb340e3af6f9f06',
|
|
128
|
+
index: '0x55482936e01da86729a45d2b87a6b1d3',
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
LSP12: {
|
|
132
|
+
// LSP12IssuedAssetsMap:<address>
|
|
133
|
+
LSP12IssuedAssetsMap: '0x74ac2555c10b9349e78f0000',
|
|
134
|
+
// keccak256('LSP12IssuedAssets[]')
|
|
135
|
+
'LSP12IssuedAssets[]': {
|
|
136
|
+
length: '0x7c8c3416d6cda87cd42c71ea1843df28ac4850354f988d55ee2eaa47b6dc05cd',
|
|
137
|
+
index: '0x7c8c3416d6cda87cd42c71ea1843df28',
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const BasicUPSetup_Schema = [
|
|
143
|
+
{
|
|
144
|
+
name: 'LSP3Profile',
|
|
145
|
+
key: ERC725YKeys.LSP3['LSP3Profile'],
|
|
146
|
+
keyType: 'Singleton',
|
|
147
|
+
valueContent: 'JSONURL',
|
|
148
|
+
valueType: 'bytes',
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: 'LSP1UniversalReceiverDelegate',
|
|
152
|
+
key: ERC725YKeys.LSP0['LSP1UniversalReceiverDelegate'],
|
|
153
|
+
keyType: 'Singleton',
|
|
154
|
+
valueContent: 'Address',
|
|
155
|
+
valueType: 'address',
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
name: 'LSP12IssuedAssets[]',
|
|
159
|
+
key: ERC725YKeys.LSP12['LSP12IssuedAssets[]'].length,
|
|
160
|
+
keyType: 'Array',
|
|
161
|
+
valueContent: 'Number',
|
|
162
|
+
valueType: 'uint256',
|
|
163
|
+
},
|
|
164
|
+
];
|
|
165
|
+
|
|
166
|
+
// LSP6
|
|
167
|
+
// ----------
|
|
168
|
+
|
|
169
|
+
// All Permissions currently exclude DELEGATECALL for security
|
|
170
|
+
const ALL_PERMISSIONS = '0x0000000000000000000000000000000000000000000000000000000000007fbf';
|
|
171
|
+
|
|
172
|
+
// prettier-ignore
|
|
173
|
+
const PERMISSIONS = {
|
|
174
|
+
CHANGEOWNER: "0x0000000000000000000000000000000000000000000000000000000000000001", // .... .... .... 0001
|
|
175
|
+
CHANGEPERMISSIONS: "0x0000000000000000000000000000000000000000000000000000000000000002", // .... .... .... 0010
|
|
176
|
+
ADDPERMISSIONS: "0x0000000000000000000000000000000000000000000000000000000000000004", // .... .... .... 0100
|
|
177
|
+
SETDATA: "0x0000000000000000000000000000000000000000000000000000000000000008", // .... .... .... 1000
|
|
178
|
+
CALL: "0x0000000000000000000000000000000000000000000000000000000000000010", // .... .... 0001 ....
|
|
179
|
+
STATICCALL: "0x0000000000000000000000000000000000000000000000000000000000000020", // .... .... 0010 ....
|
|
180
|
+
DELEGATECALL: "0x0000000000000000000000000000000000000000000000000000000000000040", // .... .... 0100 ....
|
|
181
|
+
DEPLOY: "0x0000000000000000000000000000000000000000000000000000000000000080", // .... .... 1000 ....
|
|
182
|
+
TRANSFERVALUE: "0x0000000000000000000000000000000000000000000000000000000000000100", // .... 0001 .... ....
|
|
183
|
+
SIGN: "0x0000000000000000000000000000000000000000000000000000000000000200", // .... 0010 .... ....
|
|
184
|
+
SUPER_SETDATA: "0x0000000000000000000000000000000000000000000000000000000000000400", // .... 0100 .... ....
|
|
185
|
+
SUPER_TRANSFERVALUE: "0x0000000000000000000000000000000000000000000000000000000000000800", // .... 1000 .... ....
|
|
186
|
+
SUPER_CALL: "0x0000000000000000000000000000000000000000000000000000000000001000", // 0001 .... .... ....
|
|
187
|
+
SUPER_STATICCALL: "0x0000000000000000000000000000000000000000000000000000000000002000", // 0010 .... .... ....
|
|
188
|
+
SUPER_DELEGATECALL: "0x0000000000000000000000000000000000000000000000000000000000004000", // 0100 .... .... ....
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const LSP1_TYPE_IDS = {
|
|
192
|
+
// keccak256('LSP7TokensSender')
|
|
193
|
+
LSP7_TOKENSENDER: "0x40b8bec57d7b5ff0dbd9e9acd0a47dfeb0101e1a203766f5ccab00445fbf39e9",
|
|
194
|
+
// keccak256('LSP7TokensRecipient')
|
|
195
|
+
LSP7_TOKENRECIPIENT: "0xdbe2c314e1aee2970c72666f2ebe8933a8575263ea71e5ff6a9178e95d47a26f",
|
|
196
|
+
// keccak256('LSP8TokensSender')
|
|
197
|
+
LSP8_TOKENSENDER: "0x3724c94f0815e936299cca424da4140752198e0beb7931a6e0925d11bc97544c",
|
|
198
|
+
// keccak256('LSP8TokensRecipient')
|
|
199
|
+
LSP8_TOKENRECIPIENT: "0xc7a120a42b6057a0cbed111fbbfbd52fcd96748c04394f77fc2c3adbe0391e01",
|
|
200
|
+
// keccak256("LSP9VaultSender")
|
|
201
|
+
LSP9_VAULTSENDER: "0x3ca9f769340018257ac15b3a00e502e8fb730d66086f774210f84d0205af31e7",
|
|
202
|
+
// keccak256("LSP9VaultRecipient")
|
|
203
|
+
LSP9_VAULTRECIPIENT: "0x09aaf55960715d8d86b57af40be36b0bfd469c9a3643445d8c65d39e27b4c56f"
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// ----------
|
|
207
|
+
|
|
208
|
+
const Errors = {
|
|
209
|
+
LSP6: {
|
|
210
|
+
'0xf292052a': {
|
|
211
|
+
error: 'NoPermissionsSet(address)',
|
|
212
|
+
message: 'LSP6: No permissions are set for this address.',
|
|
213
|
+
},
|
|
214
|
+
'0x3bdad6e6': {
|
|
215
|
+
error: 'NotAuthorised(address,string)',
|
|
216
|
+
message: 'LSP6: Not authorized (missing permission).',
|
|
217
|
+
},
|
|
218
|
+
'0x2879b128': {
|
|
219
|
+
error: 'NotAllowedAddress(address,address)',
|
|
220
|
+
message: 'LSP6: not allowed to interact with address.',
|
|
221
|
+
},
|
|
222
|
+
'0x84135110': {
|
|
223
|
+
error: 'NotAllowedFunction(address,bytes4)',
|
|
224
|
+
message: 'LSP6: not allowed to run the function.',
|
|
225
|
+
},
|
|
226
|
+
'0x3003e7ae': {
|
|
227
|
+
error: 'NotAllowedERC725YKey(address,bytes32)',
|
|
228
|
+
message: 'LSP6: not allowed to set the ERC725Y data key.',
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
LSP7: {
|
|
232
|
+
'0xc5e194ab': {
|
|
233
|
+
error: 'LSP7AmountExceedsBalance(address,address,uint256)',
|
|
234
|
+
message: "LSP7: token amount exceeds sender's balance.",
|
|
235
|
+
},
|
|
236
|
+
'0xf3a6b691': {
|
|
237
|
+
error: 'LSP7AmountExceedsAuthorizedAmount(address,uint256,address,uint256)',
|
|
238
|
+
message: "LSP7: token amount exceeds operator's allowance.",
|
|
239
|
+
},
|
|
240
|
+
'0x6355e766': {
|
|
241
|
+
error: 'LSP7CannotUseAddressZeroAsOperator()',
|
|
242
|
+
message: 'LSP7: cannot authorize address(0) as operator for LSP7 token.',
|
|
243
|
+
},
|
|
244
|
+
'0xd2d5ec30': {
|
|
245
|
+
error: 'LSP7CannotSendWithAddressZero()',
|
|
246
|
+
message: 'LSP7: cannot send token with address(0).',
|
|
247
|
+
},
|
|
248
|
+
'0x263eee8d': {
|
|
249
|
+
error: 'LSP7InvalidTransferBatch()',
|
|
250
|
+
message: 'LSP7: invalid transfer batch.',
|
|
251
|
+
},
|
|
252
|
+
'0xa608fbb6': {
|
|
253
|
+
error: 'LSP7NotifyTokenReceiverContractMissingLSP1Interface(address)',
|
|
254
|
+
message: 'LSP7: token recipient does not implement LSP1 standard.',
|
|
255
|
+
},
|
|
256
|
+
'0x26c247f4': {
|
|
257
|
+
error: 'LSP7NotifyTokenReceiverIsEOA(address)',
|
|
258
|
+
message: 'LSP7: token recipient is an Externally Owned Account.',
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
LSP7CappedSupply: {
|
|
262
|
+
'0xacf1d8c5': {
|
|
263
|
+
error: 'LSP7CappedSupplyRequired()',
|
|
264
|
+
message: 'LSP7CappedSupply: cap supply number required',
|
|
265
|
+
},
|
|
266
|
+
'0xeacbf0d1': {
|
|
267
|
+
error: 'LSP7CappedSupplyCannotMintOverCap()',
|
|
268
|
+
message: 'LSP7CappedSupply: cannot mint over the max cap supply',
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
LSP8: {
|
|
272
|
+
'0xae8f9a36': {
|
|
273
|
+
error: 'LSP8NonExistentTokenId(bytes32)',
|
|
274
|
+
message: 'LSP8: token id does not exist.',
|
|
275
|
+
},
|
|
276
|
+
'0x5b271ea2': {
|
|
277
|
+
error: 'LSP8NotTokenOwner(address,bytes32,address)',
|
|
278
|
+
message: 'LSP8: tokenOwner given as parameter does not own this token id.',
|
|
279
|
+
},
|
|
280
|
+
'0x1294d2a9': {
|
|
281
|
+
error: 'LSP8NotTokenOperator(bytes32,address)',
|
|
282
|
+
message: 'LSP8: caller is not an operator for this token id.',
|
|
283
|
+
},
|
|
284
|
+
'0x9577b8b3': {
|
|
285
|
+
error: 'LSP8CannotUseAddressZeroAsOperator()',
|
|
286
|
+
message: 'LSP8: cannot use address(0) as an operator for token id.',
|
|
287
|
+
},
|
|
288
|
+
'0x24ecef4d': {
|
|
289
|
+
error: 'LSP8CannotSendToAddressZero()',
|
|
290
|
+
message: 'LSP8: cannot send to address(0).',
|
|
291
|
+
},
|
|
292
|
+
'0x34c7b511': {
|
|
293
|
+
error: 'LSP8TokenIdAlreadyMinted(bytes32)',
|
|
294
|
+
message: 'LSP8: tokenId already exist (= already minted).',
|
|
295
|
+
},
|
|
296
|
+
'0x93a83119': {
|
|
297
|
+
error: 'LSP8InvalidTransferBatch()',
|
|
298
|
+
message: 'LSP8: invalid transfer batch.',
|
|
299
|
+
},
|
|
300
|
+
'0x4349776d': {
|
|
301
|
+
error: 'LSP8NotifyTokenReceiverContractMissingLSP1Interface(address)',
|
|
302
|
+
message: 'LSP8: token recipient does not implement LSP1 standard.',
|
|
303
|
+
},
|
|
304
|
+
'0x03173137': {
|
|
305
|
+
error: 'LSP8NotifyTokenReceiverIsEOA(address)',
|
|
306
|
+
message: 'LSP8: token recipient is an Externally Owned Account.',
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
LSP8CappedSupply: {
|
|
310
|
+
'0x38d9fc30': {
|
|
311
|
+
error: 'LSP8CappedSupplyRequired()',
|
|
312
|
+
message: 'LSP8CappedSupply: cap supply number required',
|
|
313
|
+
},
|
|
314
|
+
'0xe8ba2291': {
|
|
315
|
+
error: 'LSP8CappedSupplyCannotMintOverCap()',
|
|
316
|
+
message: 'LSP8CappedSupply: cannot mint over the max cap supply',
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
// ----------
|
|
322
|
+
|
|
323
|
+
const EventSignatures = {
|
|
324
|
+
ERC173: {
|
|
325
|
+
/**
|
|
326
|
+
* event OwnershipTransferred(
|
|
327
|
+
* address indexed previousOwner,
|
|
328
|
+
* address indexed newOwner,
|
|
329
|
+
* );
|
|
330
|
+
*
|
|
331
|
+
* signature = keccak256('OwnershipTransferred(address,address)')
|
|
332
|
+
*/
|
|
333
|
+
OwnershipTransfered: '0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0',
|
|
334
|
+
},
|
|
335
|
+
ERC725X: {
|
|
336
|
+
/**
|
|
337
|
+
* event ContractCreated(
|
|
338
|
+
* uint256 indexed _operation,
|
|
339
|
+
* address indexed _contractAddress,
|
|
340
|
+
* uint256 indexed _value
|
|
341
|
+
* );
|
|
342
|
+
*
|
|
343
|
+
* signature = keccak256('ContractCreated(uint256,address,uint256)')
|
|
344
|
+
*/
|
|
345
|
+
ContractCreated: '0x01c42bd7e97a66166063b02fce6924e6656b6c2c61966630165095c4fb0b7b2f',
|
|
346
|
+
/**
|
|
347
|
+
* event Executed(
|
|
348
|
+
* uint256 indexed _operation,
|
|
349
|
+
* address indexed _to,
|
|
350
|
+
* uint256 indexed _value,
|
|
351
|
+
* bytes _data
|
|
352
|
+
* );
|
|
353
|
+
*
|
|
354
|
+
* signature = keccak256('Executed(uint256,address,uint256,bytes)')
|
|
355
|
+
*/
|
|
356
|
+
Executed: '0x1f920dbda597d7bf95035464170fa58d0a4b57f13a1c315ace6793b9f63688b8',
|
|
357
|
+
},
|
|
358
|
+
ERC725Y: {
|
|
359
|
+
/**
|
|
360
|
+
* event DataChanged(bytes32 indexed key);
|
|
361
|
+
*
|
|
362
|
+
* signature = keccak256('DataChanged(bytes32)')
|
|
363
|
+
*/
|
|
364
|
+
DataChanged: '0xcdf4e344c0d23d4cdd0474039d176c55b19d531070dbe17856bfb993a5b5720b',
|
|
365
|
+
},
|
|
366
|
+
// ERC725Account
|
|
367
|
+
LSP0: {
|
|
368
|
+
/**
|
|
369
|
+
* event ValueReceived(
|
|
370
|
+
* address indexed sender,
|
|
371
|
+
* uint256 indexed value
|
|
372
|
+
* );
|
|
373
|
+
*
|
|
374
|
+
* signature = keccak256('ValueReceived(address,uint256)')
|
|
375
|
+
*/
|
|
376
|
+
ValueReceived: '0x7e71433ddf847725166244795048ecf3e3f9f35628254ecbf736056664233493',
|
|
377
|
+
},
|
|
378
|
+
LSP1: {
|
|
379
|
+
/**
|
|
380
|
+
* event UniversalReceiver(
|
|
381
|
+
* address indexed from,
|
|
382
|
+
* uint256 value,
|
|
383
|
+
* bytes32 indexed typeId,
|
|
384
|
+
* bytes indexed returnedValue,
|
|
385
|
+
* bytes receivedData
|
|
386
|
+
* );
|
|
387
|
+
*
|
|
388
|
+
* signature = keccak256('UniversalReceiver(address,uint256,bytes32,bytes,bytes)')
|
|
389
|
+
*/
|
|
390
|
+
UniversalReceiver: '0x9c3ba68eb5742b8e3961aea0afc7371a71bf433c8a67a831803b64c064a178c2',
|
|
391
|
+
},
|
|
392
|
+
LSP6: {
|
|
393
|
+
/**
|
|
394
|
+
* event Executed(
|
|
395
|
+
* uint256 indexed _value,
|
|
396
|
+
* bytes _data
|
|
397
|
+
* );
|
|
398
|
+
*
|
|
399
|
+
* signature = keccak256('Executed(uint256,bytes)')
|
|
400
|
+
*/
|
|
401
|
+
Executed: '0x2e733a17851169f232b3859260eb3ad2a086afd54e999eb4ea9afb7791702e41',
|
|
402
|
+
},
|
|
403
|
+
LSP7: {
|
|
404
|
+
/**
|
|
405
|
+
* event Transfer(
|
|
406
|
+
* address indexed operator,
|
|
407
|
+
* address indexed from,
|
|
408
|
+
* address indexed to,
|
|
409
|
+
* uint256 amount,
|
|
410
|
+
* bool force,
|
|
411
|
+
* bytes data
|
|
412
|
+
* );
|
|
413
|
+
*
|
|
414
|
+
* signature = keccak256('Transfer(address,address,address,uint256,bool,bytes)')
|
|
415
|
+
*/
|
|
416
|
+
Transfer: '0x3997e418d2cef0b3b0e907b1e39605c3f7d32dbd061e82ea5b4a770d46a160a6',
|
|
417
|
+
/**
|
|
418
|
+
* event AuthorizedOperator(
|
|
419
|
+
* address indexed operator,
|
|
420
|
+
* address indexed tokenOwner,
|
|
421
|
+
* uint256 indexed amount
|
|
422
|
+
* );
|
|
423
|
+
*
|
|
424
|
+
* signature = keccak256('AuthorizedOperator(address,address,uint256)')
|
|
425
|
+
*/
|
|
426
|
+
AuthorizedOperator: '0xd66aff874162a96578e919097b6f6d153dfd89a5cec41bb331fdb0c4aec16e2c',
|
|
427
|
+
/**
|
|
428
|
+
* event RevokedOperator(
|
|
429
|
+
* address indexed operator,
|
|
430
|
+
* address indexed tokenOwner
|
|
431
|
+
* );
|
|
432
|
+
*
|
|
433
|
+
* signature = keccak256('RevokedOperator(address,address)')
|
|
434
|
+
*/
|
|
435
|
+
RevokedOperator: '0x50546e66e5f44d728365dc3908c63bc5cfeeab470722c1677e3073a6ac294aa1',
|
|
436
|
+
},
|
|
437
|
+
LSP8: {
|
|
438
|
+
/**
|
|
439
|
+
* event Transfer(
|
|
440
|
+
* address operator,
|
|
441
|
+
* address indexed from,
|
|
442
|
+
* address indexed to,
|
|
443
|
+
* bytes32 indexed tokenId,
|
|
444
|
+
* bool force,
|
|
445
|
+
* bytes data
|
|
446
|
+
* );
|
|
447
|
+
*
|
|
448
|
+
* signature = keccak256('Transfer(address,address,address,bytes32,bool,bytes)')
|
|
449
|
+
*/
|
|
450
|
+
Transfer: 'b333c813a7426a7a11e2b190cad52c44119421594b47f6f32ace6d8c7207b2bf',
|
|
451
|
+
/**
|
|
452
|
+
* event AuthorizedOperator(
|
|
453
|
+
* address indexed operator,
|
|
454
|
+
* address indexed tokenOwner,
|
|
455
|
+
* bytes32 indexed tokenId
|
|
456
|
+
* );
|
|
457
|
+
*
|
|
458
|
+
* signature = keccak256('AuthorizedOperator(address,address,bytes32)')
|
|
459
|
+
*/
|
|
460
|
+
AuthorizedOperator: '34b797fc5a526f7bf1d2b5de25f6564fd85ae364e3ee939aee7c1ac27871a988',
|
|
461
|
+
/**
|
|
462
|
+
* event RevokedOperator(
|
|
463
|
+
* address indexed operator,
|
|
464
|
+
* address indexed tokenOwner,
|
|
465
|
+
* bytes32 indexed tokenId
|
|
466
|
+
* );
|
|
467
|
+
*
|
|
468
|
+
* signature = keccak256('RevokedOperator(address,address,bytes32)')
|
|
469
|
+
*/
|
|
470
|
+
RevokedOperator: '17d5389f6ab6adb2647dfa0aa365c323d37adacc30b33a65310b6158ce1373d5',
|
|
471
|
+
},
|
|
472
|
+
Helpers: {
|
|
473
|
+
/**
|
|
474
|
+
* event ReceivedERC777(
|
|
475
|
+
* address indexed token,
|
|
476
|
+
* address indexed _operator,
|
|
477
|
+
* address indexed _from,
|
|
478
|
+
* address _to,
|
|
479
|
+
* uint256 _amount
|
|
480
|
+
* );
|
|
481
|
+
*
|
|
482
|
+
* signature = keccak256('ReceivedERC777(address,address,address,address,uint256)')
|
|
483
|
+
*/
|
|
484
|
+
ReceivedERC777: '0xdc38539587ea4d67f9f649ad9269646bab26927bad175bdcdfdab5dd297d5e1c',
|
|
485
|
+
},
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
module.exports = {
|
|
489
|
+
INTERFACE_IDS,
|
|
490
|
+
ERC1271_VALUES,
|
|
491
|
+
OPERATION_TYPES,
|
|
492
|
+
SupportedStandards,
|
|
493
|
+
ERC725YKeys,
|
|
494
|
+
BasicUPSetup_Schema,
|
|
495
|
+
ALL_PERMISSIONS,
|
|
496
|
+
PERMISSIONS,
|
|
497
|
+
LSP1_TYPE_IDS,
|
|
498
|
+
Errors,
|
|
499
|
+
EventSignatures,
|
|
500
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
// This contract is a modified version of the OwnableUnset implementation, where we transfer Ownership as a 2 step
|
|
5
|
+
// process, this allows to prevent for mistakes during ownership transfer,and so prevent control of a contract from
|
|
6
|
+
// potentially being lost forever.
|
|
7
|
+
|
|
8
|
+
// interfaces
|
|
9
|
+
import {IClaimOwnership} from "./IClaimOwnership.sol";
|
|
10
|
+
|
|
11
|
+
// modules
|
|
12
|
+
import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
|
|
13
|
+
|
|
14
|
+
abstract contract ClaimOwnership is IClaimOwnership, OwnableUnset {
|
|
15
|
+
address public override pendingOwner;
|
|
16
|
+
|
|
17
|
+
function claimOwnership() public virtual override {
|
|
18
|
+
require(msg.sender == pendingOwner, "OwnableClaim: caller is not the pendingOwner");
|
|
19
|
+
|
|
20
|
+
_setOwner(pendingOwner);
|
|
21
|
+
pendingOwner = address(0);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function transferOwnership(address _newOwner) public virtual override onlyOwner {
|
|
25
|
+
_transferOwnership(_newOwner);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _transferOwnership(address _newOwner) internal virtual {
|
|
29
|
+
pendingOwner = _newOwner;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165Checker.sol)
|
|
3
|
+
|
|
4
|
+
pragma solidity ^0.8.0;
|
|
5
|
+
|
|
6
|
+
// This contract is a modified version of OpenZeppelin implementation, where we modify the visibility of
|
|
7
|
+
// `supportsERC165Interface`, which check the given interfaceId, to internal and to be used in contract implementations,
|
|
8
|
+
// instead of `supportsInterface` to save gas, as the latter check for 3 interfaceIds; InterfaceId of ERC165, 0xffffffff
|
|
9
|
+
// and the given interfaceId.
|
|
10
|
+
|
|
11
|
+
// interfaces
|
|
12
|
+
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @dev Library used to query support of an interface declared via {IERC165}.
|
|
16
|
+
*
|
|
17
|
+
* Note that these functions return the actual result of the query: they do not
|
|
18
|
+
* `revert` if an interface is not supported. It is up to the caller to decide
|
|
19
|
+
* what to do in these cases.
|
|
20
|
+
*/
|
|
21
|
+
library ERC165Checker {
|
|
22
|
+
// As per the EIP-165 spec, no interface should ever match 0xffffffff
|
|
23
|
+
bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @dev Returns true if `account` supports the {IERC165} interface,
|
|
27
|
+
*/
|
|
28
|
+
function supportsERC165(address account) internal view returns (bool) {
|
|
29
|
+
// Any contract that implements ERC165 must explicitly indicate support of
|
|
30
|
+
// InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
|
|
31
|
+
return
|
|
32
|
+
supportsERC165Interface(account, type(IERC165).interfaceId) &&
|
|
33
|
+
!supportsERC165Interface(account, _INTERFACE_ID_INVALID);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @dev Returns true if `account` supports the interface defined by
|
|
38
|
+
* `interfaceId`. Support for {IERC165} itself is queried automatically.
|
|
39
|
+
*
|
|
40
|
+
* See {IERC165-supportsInterface}.
|
|
41
|
+
*/
|
|
42
|
+
function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
|
|
43
|
+
// query support of both ERC165 as per the spec and support of _interfaceId
|
|
44
|
+
return supportsERC165(account) && supportsERC165Interface(account, interfaceId);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @dev Returns a boolean array where each value corresponds to the
|
|
49
|
+
* interfaces passed in and whether they're supported or not. This allows
|
|
50
|
+
* you to batch check interfaces for a contract where your expectation
|
|
51
|
+
* is that some interfaces may not be supported.
|
|
52
|
+
*
|
|
53
|
+
* See {IERC165-supportsInterface}.
|
|
54
|
+
*
|
|
55
|
+
* _Available since v3.4._
|
|
56
|
+
*/
|
|
57
|
+
function getSupportedInterfaces(address account, bytes4[] memory interfaceIds)
|
|
58
|
+
internal
|
|
59
|
+
view
|
|
60
|
+
returns (bool[] memory)
|
|
61
|
+
{
|
|
62
|
+
// an array of booleans corresponding to interfaceIds and whether they're supported or not
|
|
63
|
+
bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);
|
|
64
|
+
|
|
65
|
+
// query support of ERC165 itself
|
|
66
|
+
if (supportsERC165(account)) {
|
|
67
|
+
// query support of each interface in interfaceIds
|
|
68
|
+
for (uint256 i = 0; i < interfaceIds.length; i++) {
|
|
69
|
+
interfaceIdsSupported[i] = supportsERC165Interface(account, interfaceIds[i]);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return interfaceIdsSupported;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @dev Returns true if `account` supports all the interfaces defined in
|
|
78
|
+
* `interfaceIds`. Support for {IERC165} itself is queried automatically.
|
|
79
|
+
*
|
|
80
|
+
* Batch-querying can lead to gas savings by skipping repeated checks for
|
|
81
|
+
* {IERC165} support.
|
|
82
|
+
*
|
|
83
|
+
* See {IERC165-supportsInterface}.
|
|
84
|
+
*/
|
|
85
|
+
function supportsAllInterfaces(address account, bytes4[] memory interfaceIds)
|
|
86
|
+
internal
|
|
87
|
+
view
|
|
88
|
+
returns (bool)
|
|
89
|
+
{
|
|
90
|
+
// query support of ERC165 itself
|
|
91
|
+
if (!supportsERC165(account)) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// query support of each interface in _interfaceIds
|
|
96
|
+
for (uint256 i = 0; i < interfaceIds.length; i++) {
|
|
97
|
+
if (!supportsERC165Interface(account, interfaceIds[i])) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// all interfaces supported
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @notice Query if a contract implements an interface, does not check ERC165 support
|
|
108
|
+
* @param account The address of the contract to query for support of an interface
|
|
109
|
+
* @param interfaceId The interface identifier, as specified in ERC-165
|
|
110
|
+
* @return true if the contract at account indicates support of the interface with
|
|
111
|
+
* identifier interfaceId, false otherwise
|
|
112
|
+
* @dev Assumes that account contains a contract that supports ERC165, otherwise
|
|
113
|
+
* the behavior of this method is undefined. This precondition can be checked
|
|
114
|
+
* with {supportsERC165}.
|
|
115
|
+
* Interface identification is specified in ERC-165.
|
|
116
|
+
*/
|
|
117
|
+
function supportsERC165Interface(address account, bytes4 interfaceId)
|
|
118
|
+
internal
|
|
119
|
+
view
|
|
120
|
+
returns (bool)
|
|
121
|
+
{
|
|
122
|
+
bytes memory encodedParams = abi.encodeWithSelector(
|
|
123
|
+
IERC165.supportsInterface.selector,
|
|
124
|
+
interfaceId
|
|
125
|
+
);
|
|
126
|
+
(bool success, bytes memory result) = account.staticcall{gas: 30000}(encodedParams);
|
|
127
|
+
if (result.length < 32) return false;
|
|
128
|
+
return success && abi.decode(result, (bool));
|
|
129
|
+
}
|
|
130
|
+
}
|