@lukso/lsp-smart-contracts 0.11.1 → 0.12.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/README.md +10 -2
- package/artifacts/Create2Factory.json +2 -2
- package/artifacts/LSP0ERC725Account.json +68 -47
- package/artifacts/LSP0ERC725AccountInit.json +68 -47
- package/artifacts/LSP11BasicSocialRecovery.json +18 -2
- package/artifacts/LSP11BasicSocialRecoveryInit.json +18 -2
- package/artifacts/LSP16UniversalFactory.json +3 -3
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +27 -46
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +27 -46
- package/artifacts/LSP23LinkedContractsFactory.json +3 -3
- package/artifacts/LSP4DigitalAssetMetadata.json +16 -0
- package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +16 -0
- package/artifacts/LSP6KeyManager.json +34 -6
- package/artifacts/LSP6KeyManagerInit.json +34 -6
- package/artifacts/LSP7CappedSupply.json +64 -4
- package/artifacts/LSP7CappedSupplyInitAbstract.json +64 -4
- package/artifacts/LSP7CompatibleERC20.json +83 -23
- package/artifacts/LSP7CompatibleERC20InitAbstract.json +83 -23
- package/artifacts/LSP7CompatibleERC20Mintable.json +86 -26
- package/artifacts/LSP7CompatibleERC20MintableInit.json +86 -26
- package/artifacts/LSP7DigitalAsset.json +64 -4
- package/artifacts/LSP7DigitalAssetInitAbstract.json +64 -4
- package/artifacts/LSP7Mintable.json +67 -7
- package/artifacts/LSP7MintableInit.json +67 -7
- package/artifacts/LSP8CappedSupply.json +57 -3
- package/artifacts/LSP8CappedSupplyInitAbstract.json +57 -3
- package/artifacts/LSP8CompatibleERC721.json +79 -25
- package/artifacts/LSP8CompatibleERC721InitAbstract.json +79 -25
- package/artifacts/LSP8CompatibleERC721Mintable.json +87 -28
- package/artifacts/LSP8CompatibleERC721MintableInit.json +87 -28
- package/artifacts/LSP8IdentifiableDigitalAsset.json +57 -3
- package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +57 -3
- package/artifacts/LSP8Mintable.json +65 -6
- package/artifacts/LSP8MintableInit.json +65 -6
- package/artifacts/LSP9Vault.json +51 -35
- package/artifacts/LSP9VaultInit.json +51 -35
- package/artifacts/UniversalProfile.json +68 -47
- package/artifacts/UniversalProfileInit.json +68 -47
- package/contracts/Factories/Create2Factory.sol +1 -1
- package/contracts/LSP0ERC725Account/ILSP0ERC725Account.sol +0 -22
- package/contracts/LSP0ERC725Account/LSP0Constants.sol +6 -1
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +12 -2
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +196 -123
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +1 -1
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +11 -2
- package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +5 -3
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +54 -14
- package/contracts/LSP11BasicSocialRecovery/LSP11Constants.sol +1 -1
- package/contracts/LSP11BasicSocialRecovery/LSP11Errors.sol +1 -1
- package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +2 -2
- package/contracts/LSP14Ownable2Step/LSP14Constants.sol +1 -1
- package/contracts/LSP14Ownable2Step/LSP14Errors.sol +9 -3
- package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +16 -12
- package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +65 -96
- package/contracts/LSP17ContractExtension/LSP17Errors.sol +1 -1
- package/contracts/LSP17ContractExtension/LSP17Extendable.sol +22 -15
- package/contracts/LSP17ContractExtension/LSP17Extension.sol +6 -5
- package/contracts/LSP17Extensions/Extension4337.sol +101 -0
- package/contracts/LSP17Extensions/OnERC721ReceivedExtension.sol +15 -0
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +1 -2
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +24 -0
- package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +1 -0
- package/contracts/LSP1UniversalReceiver/LSP1Errors.sol +0 -6
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +49 -33
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +33 -27
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +5 -48
- package/contracts/LSP20CallVerification/ILSP20CallVerifier.sol +13 -9
- package/contracts/LSP20CallVerification/LSP20CallVerification.sol +64 -45
- package/contracts/LSP20CallVerification/LSP20Constants.sol +6 -6
- package/contracts/LSP20CallVerification/LSP20Errors.sol +10 -4
- package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/ILSP23LinkedContractsFactory.sol +1 -1
- package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/IPostDeploymentModule.sol +1 -1
- package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/LSP23Errors.sol +1 -1
- package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/LSP23LinkedContractsFactory.sol +5 -1
- package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/modules/UniversalProfileInitPostDeploymentModule.sol +1 -1
- package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/modules/UniversalProfilePostDeploymentModule.sol +1 -1
- package/contracts/LSP25ExecuteRelayCall/LSP25Constants.sol +1 -1
- package/contracts/LSP25ExecuteRelayCall/LSP25MultiChannelNonce.sol +8 -3
- package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +1 -97
- package/contracts/LSP3ProfileMetadata/LSP3Constants.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +8 -3
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +8 -3
- package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +4 -3
- package/contracts/LSP6KeyManager/LSP6Constants.sol +4 -3
- package/contracts/LSP6KeyManager/LSP6Errors.sol +2 -23
- package/contracts/LSP6KeyManager/LSP6KeyManager.sol +0 -1
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +176 -101
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +0 -1
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +1 -2
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteRelayCallModule.sol +27 -0
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +34 -28
- package/contracts/LSP6KeyManager/LSP6Utils.sol +29 -2
- package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +70 -10
- package/contracts/LSP7DigitalAsset/LSP7Constants.sol +2 -2
- package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +29 -13
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +273 -265
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +28 -12
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +17 -3
- package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +5 -1
- package/contracts/LSP7DigitalAsset/extensions/LSP7BurnableInitAbstract.sol +4 -1
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +7 -7
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +3 -3
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +128 -54
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +129 -54
- package/contracts/LSP7DigitalAsset/presets/ILSP7Mintable.sol +3 -3
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +4 -4
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +2 -2
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +4 -4
- package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +4 -4
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +1 -1
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +4 -4
- package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +16 -11
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +20 -6
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +32 -16
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +67 -16
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +143 -137
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +69 -15
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8BurnableInitAbstract.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +7 -7
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +3 -3
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +172 -80
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +178 -91
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +7 -7
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +7 -7
- package/contracts/LSP8IdentifiableDigitalAsset/presets/ILSP8Mintable.sol +3 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +8 -7
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +5 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +13 -7
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +9 -8
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +9 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +10 -8
- package/contracts/LSP9Vault/ILSP9Vault.sol +0 -21
- package/contracts/LSP9Vault/LSP9Constants.sol +6 -1
- package/contracts/LSP9Vault/LSP9Errors.sol +1 -1
- package/contracts/LSP9Vault/LSP9Vault.sol +11 -2
- package/contracts/LSP9Vault/LSP9VaultCore.sol +119 -66
- package/contracts/LSP9Vault/LSP9VaultInit.sol +1 -1
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +11 -2
- package/contracts/UniversalProfile.sol +1 -1
- package/contracts/UniversalProfileInit.sol +1 -1
- package/contracts/UniversalProfileInitAbstract.sol +1 -1
- package/contracts/Version.sol +16 -0
- package/devdocs/LSP0ERC725Account.json +86 -52
- package/devdocs/LSP0ERC725AccountInit.json +86 -52
- package/devdocs/LSP11BasicSocialRecovery.json +13 -0
- package/devdocs/LSP11BasicSocialRecoveryInit.json +13 -0
- package/devdocs/LSP16UniversalFactory.json +9 -9
- package/devdocs/LSP1UniversalReceiverDelegateUP.json +7 -6
- package/devdocs/LSP1UniversalReceiverDelegateVault.json +7 -6
- package/devdocs/LSP4DigitalAssetMetadata.json +32 -10
- package/devdocs/LSP4DigitalAssetMetadataInitAbstract.json +32 -10
- package/devdocs/LSP6KeyManager.json +27 -13
- package/devdocs/LSP6KeyManagerInit.json +27 -13
- package/devdocs/LSP7CappedSupply.json +61 -28
- package/devdocs/LSP7CappedSupplyInitAbstract.json +61 -28
- package/devdocs/LSP7CompatibleERC20.json +102 -32
- package/devdocs/LSP7CompatibleERC20InitAbstract.json +102 -32
- package/devdocs/LSP7CompatibleERC20Mintable.json +102 -32
- package/devdocs/LSP7CompatibleERC20MintableInit.json +102 -32
- package/devdocs/LSP7DigitalAsset.json +61 -28
- package/devdocs/LSP7DigitalAssetInitAbstract.json +61 -28
- package/devdocs/LSP7Mintable.json +61 -28
- package/devdocs/LSP7MintableInit.json +61 -28
- package/devdocs/LSP8CappedSupply.json +66 -27
- package/devdocs/LSP8CappedSupplyInitAbstract.json +66 -27
- package/devdocs/LSP8CompatibleERC721.json +93 -33
- package/devdocs/LSP8CompatibleERC721InitAbstract.json +93 -33
- package/devdocs/LSP8CompatibleERC721Mintable.json +95 -35
- package/devdocs/LSP8CompatibleERC721MintableInit.json +96 -36
- package/devdocs/LSP8IdentifiableDigitalAsset.json +70 -28
- package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +66 -27
- package/devdocs/LSP8Mintable.json +68 -29
- package/devdocs/LSP8MintableInit.json +69 -30
- package/devdocs/LSP9Vault.json +69 -41
- package/devdocs/LSP9VaultInit.json +69 -41
- package/devdocs/UniversalProfile.json +86 -52
- package/devdocs/UniversalProfileInit.json +86 -52
- package/dist/constants.cjs.js +5565 -2846
- package/dist/constants.d.ts +3996 -1182
- package/dist/constants.es.js +5564 -2846
- package/package.json +8 -8
- package/userdocs/LSP0ERC725Account.json +20 -11
- package/userdocs/LSP0ERC725AccountInit.json +20 -11
- package/userdocs/LSP16UniversalFactory.json +26 -1
- package/userdocs/LSP1UniversalReceiverDelegateUP.json +4 -11
- package/userdocs/LSP1UniversalReceiverDelegateVault.json +4 -11
- package/userdocs/LSP4DigitalAssetMetadata.json +7 -4
- package/userdocs/LSP4DigitalAssetMetadataInitAbstract.json +7 -4
- package/userdocs/LSP6KeyManager.json +3 -5
- package/userdocs/LSP6KeyManagerInit.json +3 -5
- package/userdocs/LSP7CappedSupply.json +17 -6
- package/userdocs/LSP7CappedSupplyInitAbstract.json +16 -5
- package/userdocs/LSP7CompatibleERC20.json +18 -5
- package/userdocs/LSP7CompatibleERC20InitAbstract.json +18 -5
- package/userdocs/LSP7CompatibleERC20Mintable.json +18 -5
- package/userdocs/LSP7CompatibleERC20MintableInit.json +18 -5
- package/userdocs/LSP7DigitalAsset.json +18 -5
- package/userdocs/LSP7DigitalAssetInitAbstract.json +18 -5
- package/userdocs/LSP7Mintable.json +18 -5
- package/userdocs/LSP7MintableInit.json +18 -5
- package/userdocs/LSP8CappedSupply.json +16 -5
- package/userdocs/LSP8CappedSupplyInitAbstract.json +15 -4
- package/userdocs/LSP8CompatibleERC721.json +30 -17
- package/userdocs/LSP8CompatibleERC721InitAbstract.json +30 -17
- package/userdocs/LSP8CompatibleERC721Mintable.json +31 -18
- package/userdocs/LSP8CompatibleERC721MintableInit.json +32 -19
- package/userdocs/LSP8IdentifiableDigitalAsset.json +18 -5
- package/userdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +17 -4
- package/userdocs/LSP8Mintable.json +18 -5
- package/userdocs/LSP8MintableInit.json +19 -6
- package/userdocs/LSP9Vault.json +23 -14
- package/userdocs/LSP9VaultInit.json +23 -14
- package/userdocs/UniversalProfile.json +20 -11
- package/userdocs/UniversalProfileInit.json +20 -11
- package/CONTRIBUTING.md +0 -184
- package/artifacts/LSP4Compatibility.json +0 -216
- package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +0 -25
- package/contracts/LSP4DigitalAssetMetadata/LSP4Compatibility.sol +0 -38
- package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibleERC20.sol +0 -83
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +0 -175
- package/devdocs/LSP4Compatibility.json +0 -79
- package/userdocs/LSP4Compatibility.json +0 -20
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
|
|
3
3
|
pragma solidity ^0.8.4;
|
|
4
4
|
|
|
@@ -25,25 +25,26 @@ contract LSP8Mintable is LSP8IdentifiableDigitalAsset, ILSP8Mintable {
|
|
|
25
25
|
constructor(
|
|
26
26
|
string memory name_,
|
|
27
27
|
string memory symbol_,
|
|
28
|
-
address newOwner_
|
|
29
|
-
|
|
28
|
+
address newOwner_,
|
|
29
|
+
uint256 tokenIdType_
|
|
30
|
+
) LSP8IdentifiableDigitalAsset(name_, symbol_, newOwner_, tokenIdType_) {}
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
|
-
* @notice Minting tokenId `tokenId` for address `to` with the additional data `data` (Note: allow non-LSP1 recipient is set to `
|
|
33
|
+
* @notice Minting tokenId `tokenId` for address `to` with the additional data `data` (Note: allow non-LSP1 recipient is set to `force`).
|
|
33
34
|
*
|
|
34
35
|
* @dev Public {_mint} function only callable by the {owner}.
|
|
35
36
|
*
|
|
36
37
|
* @param to The address that will receive the minted `tokenId`.
|
|
37
38
|
* @param tokenId The tokenId to mint.
|
|
38
|
-
* @param
|
|
39
|
+
* @param force Set to `false` to ensure that you are minting for a recipient that implements LSP1, `false` otherwise for forcing the minting.
|
|
39
40
|
* @param data Any addition data to be sent alongside the minting.
|
|
40
41
|
*/
|
|
41
42
|
function mint(
|
|
42
43
|
address to,
|
|
43
44
|
bytes32 tokenId,
|
|
44
|
-
bool
|
|
45
|
+
bool force,
|
|
45
46
|
bytes memory data
|
|
46
|
-
) public virtual onlyOwner {
|
|
47
|
-
_mint(to, tokenId,
|
|
47
|
+
) public virtual override onlyOwner {
|
|
48
|
+
_mint(to, tokenId, force, data);
|
|
48
49
|
}
|
|
49
50
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
|
|
3
3
|
pragma solidity ^0.8.4;
|
|
4
4
|
|
|
@@ -27,8 +27,14 @@ contract LSP8MintableInit is LSP8MintableInitAbstract {
|
|
|
27
27
|
function initialize(
|
|
28
28
|
string memory name_,
|
|
29
29
|
string memory symbol_,
|
|
30
|
-
address newOwner_
|
|
30
|
+
address newOwner_,
|
|
31
|
+
uint256 tokenIdType_
|
|
31
32
|
) external virtual initializer {
|
|
32
|
-
LSP8MintableInitAbstract._initialize(
|
|
33
|
+
LSP8MintableInitAbstract._initialize(
|
|
34
|
+
name_,
|
|
35
|
+
symbol_,
|
|
36
|
+
newOwner_,
|
|
37
|
+
tokenIdType_
|
|
38
|
+
);
|
|
33
39
|
}
|
|
34
40
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
|
|
3
3
|
pragma solidity ^0.8.4;
|
|
4
4
|
|
|
@@ -27,31 +27,33 @@ abstract contract LSP8MintableInitAbstract is
|
|
|
27
27
|
function _initialize(
|
|
28
28
|
string memory name_,
|
|
29
29
|
string memory symbol_,
|
|
30
|
-
address newOwner_
|
|
30
|
+
address newOwner_,
|
|
31
|
+
uint256 tokenIdType_
|
|
31
32
|
) internal virtual override onlyInitializing {
|
|
32
33
|
LSP8IdentifiableDigitalAssetInitAbstract._initialize(
|
|
33
34
|
name_,
|
|
34
35
|
symbol_,
|
|
35
|
-
newOwner_
|
|
36
|
+
newOwner_,
|
|
37
|
+
tokenIdType_
|
|
36
38
|
);
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
/**
|
|
40
|
-
* @notice Minting tokenId `tokenId` for address `to` with the additional data `data` (Note: allow non-LSP1 recipient is set to `
|
|
42
|
+
* @notice Minting tokenId `tokenId` for address `to` with the additional data `data` (Note: allow non-LSP1 recipient is set to `force`).
|
|
41
43
|
*
|
|
42
44
|
* @dev Public {_mint} function only callable by the {owner}.
|
|
43
45
|
*
|
|
44
46
|
* @param to The address that will receive the minted `tokenId`.
|
|
45
47
|
* @param tokenId The tokenId to mint.
|
|
46
|
-
* @param
|
|
48
|
+
* @param force Set to `false` to ensure that you are minting for a recipient that implements LSP1, `false` otherwise for forcing the minting.
|
|
47
49
|
* @param data Any addition data to be sent alongside the minting.
|
|
48
50
|
*/
|
|
49
51
|
function mint(
|
|
50
52
|
address to,
|
|
51
53
|
bytes32 tokenId,
|
|
52
|
-
bool
|
|
54
|
+
bool force,
|
|
53
55
|
bytes memory data
|
|
54
|
-
) public virtual onlyOwner {
|
|
55
|
-
_mint(to, tokenId,
|
|
56
|
+
) public virtual override onlyOwner {
|
|
57
|
+
_mint(to, tokenId, force, data);
|
|
56
58
|
}
|
|
57
59
|
}
|
|
@@ -1,32 +1,11 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
|
-
// interfaces
|
|
5
|
-
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
6
|
-
import {
|
|
7
|
-
IERC725X
|
|
8
|
-
} from "@erc725/smart-contracts/contracts/interfaces/IERC725X.sol";
|
|
9
|
-
import {
|
|
10
|
-
IERC725Y
|
|
11
|
-
} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
|
|
12
|
-
import {
|
|
13
|
-
ILSP1UniversalReceiver
|
|
14
|
-
} from "../LSP1UniversalReceiver/ILSP1UniversalReceiver.sol";
|
|
15
|
-
import {ILSP14Ownable2Step} from "../LSP14Ownable2Step/ILSP14Ownable2Step.sol";
|
|
16
|
-
|
|
17
4
|
/**
|
|
18
5
|
* @title Interface of LSP9 - Vault standard, a blockchain vault that can hold assets and interact with other smart contracts.
|
|
19
6
|
* @dev Could be owned by an EOA or by a contract and is able to receive and send assets. Also allows for registering received assets by leveraging the key-value storage.
|
|
20
7
|
*/
|
|
21
8
|
interface ILSP9Vault {
|
|
22
|
-
/**
|
|
23
|
-
* @notice `value` native tokens received from `sender`.
|
|
24
|
-
* @dev Emitted when receiving native tokens.
|
|
25
|
-
* @param sender The address that sent some native tokens to this contract.
|
|
26
|
-
* @param value The amount of native tokens received.
|
|
27
|
-
*/
|
|
28
|
-
event ValueReceived(address indexed sender, uint256 indexed value);
|
|
29
|
-
|
|
30
9
|
/**
|
|
31
10
|
* @notice Executing the following batch of abi-encoded function calls on the contract: `data`.
|
|
32
11
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// --- ERC165 interface ids
|
|
@@ -12,6 +12,11 @@ bytes32 constant _LSP9_SUPPORTED_STANDARDS_KEY = 0xeafec4d89fa9619884b600007c033
|
|
|
12
12
|
// bytes4(keccak256('LSP9Vault'))
|
|
13
13
|
bytes constant _LSP9_SUPPORTED_STANDARDS_VALUE = hex"7c0334a1";
|
|
14
14
|
|
|
15
|
+
// --- Native Token Type Id
|
|
16
|
+
|
|
17
|
+
// keccak256('LSP9ValueReceived')
|
|
18
|
+
bytes32 constant _TYPEID_LSP9_VALUE_RECEIVED = 0x468cd1581d7bc001c3b685513d2b929b55437be34700410383d58f3aa1ea0abc;
|
|
19
|
+
|
|
15
20
|
// Ownerhsip Transfer Type IDs
|
|
16
21
|
|
|
17
22
|
// keccak256('LSP9OwnershipTransferStarted')
|
|
@@ -14,6 +14,7 @@ import {LSP1Utils} from "../LSP1UniversalReceiver/LSP1Utils.sol";
|
|
|
14
14
|
import {
|
|
15
15
|
_LSP9_SUPPORTED_STANDARDS_KEY,
|
|
16
16
|
_LSP9_SUPPORTED_STANDARDS_VALUE,
|
|
17
|
+
_TYPEID_LSP9_VALUE_RECEIVED,
|
|
17
18
|
_TYPEID_LSP9_OwnershipTransferred_RecipientNotification
|
|
18
19
|
} from "../LSP9Vault/LSP9Constants.sol";
|
|
19
20
|
|
|
@@ -32,13 +33,21 @@ contract LSP9Vault is LSP9VaultCore {
|
|
|
32
33
|
* @param newOwner The new owner of the contract.
|
|
33
34
|
*
|
|
34
35
|
* @custom:events
|
|
35
|
-
* - {
|
|
36
|
+
* - {UniversalReceiver} event when funding the contract on deployment.
|
|
36
37
|
* - {OwnershipTransferred} event when `initialOwner` is set as the contract {owner}.
|
|
37
38
|
* - {DataChanged} event when setting the {_LSP9_SUPPORTED_STANDARDS_KEY}.
|
|
38
39
|
* - {UniversalReceiver} event when notifying the `initialOwner`.
|
|
39
40
|
*/
|
|
40
41
|
constructor(address newOwner) payable {
|
|
41
|
-
if (msg.value != 0)
|
|
42
|
+
if (msg.value != 0) {
|
|
43
|
+
emit UniversalReceiver(
|
|
44
|
+
msg.sender,
|
|
45
|
+
msg.value,
|
|
46
|
+
_TYPEID_LSP9_VALUE_RECEIVED,
|
|
47
|
+
"",
|
|
48
|
+
""
|
|
49
|
+
);
|
|
50
|
+
}
|
|
42
51
|
|
|
43
52
|
OwnableUnset._setOwner(newOwner);
|
|
44
53
|
|
|
@@ -5,12 +5,14 @@ pragma solidity ^0.8.4;
|
|
|
5
5
|
import {
|
|
6
6
|
ILSP1UniversalReceiver
|
|
7
7
|
} from "../LSP1UniversalReceiver/ILSP1UniversalReceiver.sol";
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
ILSP1UniversalReceiverDelegate
|
|
11
|
+
} from "../LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol";
|
|
8
12
|
import {ILSP9Vault} from "./ILSP9Vault.sol";
|
|
9
13
|
|
|
10
14
|
// libraries
|
|
11
15
|
import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
|
|
12
|
-
|
|
13
|
-
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
|
|
14
16
|
import {
|
|
15
17
|
ERC165Checker
|
|
16
18
|
} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
|
@@ -18,14 +20,9 @@ import {LSP1Utils} from "../LSP1UniversalReceiver/LSP1Utils.sol";
|
|
|
18
20
|
import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol";
|
|
19
21
|
|
|
20
22
|
// modules
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} from "@erc725/smart-contracts/contracts/ERC725XCore.sol";
|
|
25
|
-
import {
|
|
26
|
-
ERC725YCore,
|
|
27
|
-
IERC725Y
|
|
28
|
-
} from "@erc725/smart-contracts/contracts/ERC725YCore.sol";
|
|
23
|
+
import {Version} from "../Version.sol";
|
|
24
|
+
import {ERC725XCore} from "@erc725/smart-contracts/contracts/ERC725XCore.sol";
|
|
25
|
+
import {ERC725YCore} from "@erc725/smart-contracts/contracts/ERC725YCore.sol";
|
|
29
26
|
import {
|
|
30
27
|
OwnableUnset
|
|
31
28
|
} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
|
|
@@ -33,7 +30,14 @@ import {LSP14Ownable2Step} from "../LSP14Ownable2Step/LSP14Ownable2Step.sol";
|
|
|
33
30
|
import {LSP17Extendable} from "../LSP17ContractExtension/LSP17Extendable.sol";
|
|
34
31
|
|
|
35
32
|
// constants
|
|
36
|
-
import
|
|
33
|
+
import {
|
|
34
|
+
ERC725Y_MsgValueDisallowed,
|
|
35
|
+
ERC725Y_DataKeysValuesLengthMismatch,
|
|
36
|
+
ERC725X_CreateOperationsRequireEmptyRecipientAddress,
|
|
37
|
+
ERC725X_CreateOperationsRequireEmptyRecipientAddress,
|
|
38
|
+
ERC725X_MsgValueDisallowedInStaticCall,
|
|
39
|
+
ERC725X_UnknownOperationType
|
|
40
|
+
} from "@erc725/smart-contracts/contracts/errors.sol";
|
|
37
41
|
import {
|
|
38
42
|
OPERATION_0_CALL,
|
|
39
43
|
OPERATION_1_CREATE,
|
|
@@ -42,6 +46,7 @@ import {
|
|
|
42
46
|
} from "@erc725/smart-contracts/contracts/constants.sol";
|
|
43
47
|
import {
|
|
44
48
|
_INTERFACEID_LSP1,
|
|
49
|
+
_INTERFACEID_LSP1_DELEGATE,
|
|
45
50
|
_LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX,
|
|
46
51
|
_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY
|
|
47
52
|
} from "../LSP1UniversalReceiver/LSP1Constants.sol";
|
|
@@ -51,6 +56,7 @@ import {
|
|
|
51
56
|
} from "../LSP6KeyManager/LSP6Constants.sol";
|
|
52
57
|
import {
|
|
53
58
|
_INTERFACEID_LSP9,
|
|
59
|
+
_TYPEID_LSP9_VALUE_RECEIVED,
|
|
54
60
|
_TYPEID_LSP9_OwnershipTransferStarted,
|
|
55
61
|
_TYPEID_LSP9_OwnershipTransferred_SenderNotification,
|
|
56
62
|
_TYPEID_LSP9_OwnershipTransferred_RecipientNotification
|
|
@@ -61,12 +67,11 @@ import {
|
|
|
61
67
|
} from "../LSP17ContractExtension/LSP17Constants.sol";
|
|
62
68
|
|
|
63
69
|
// errors
|
|
64
|
-
import "./LSP9Errors.sol";
|
|
65
|
-
import "../LSP17ContractExtension/LSP17Errors.sol";
|
|
70
|
+
import {LSP1DelegateNotAllowedToSetDataKey} from "./LSP9Errors.sol";
|
|
66
71
|
|
|
67
72
|
import {
|
|
68
|
-
|
|
69
|
-
} from "../
|
|
73
|
+
NoExtensionFoundForFunctionSelector
|
|
74
|
+
} from "../LSP17ContractExtension/LSP17Errors.sol";
|
|
70
75
|
|
|
71
76
|
/**
|
|
72
77
|
* @title Core Implementation of LSP9Vault built on top of [ERC725], [LSP1UniversalReceiver]
|
|
@@ -76,6 +81,7 @@ import {
|
|
|
76
81
|
contract LSP9VaultCore is
|
|
77
82
|
ERC725XCore,
|
|
78
83
|
ERC725YCore,
|
|
84
|
+
Version,
|
|
79
85
|
LSP14Ownable2Step,
|
|
80
86
|
LSP17Extendable,
|
|
81
87
|
ILSP1UniversalReceiver,
|
|
@@ -91,14 +97,14 @@ contract LSP9VaultCore is
|
|
|
91
97
|
* - When receiving some native tokens without any additional data.
|
|
92
98
|
* - On empty calls to the contract.
|
|
93
99
|
*
|
|
94
|
-
* @custom:events {
|
|
100
|
+
* @custom:events {UniversalReceiver} when receiving native tokens.
|
|
95
101
|
*/
|
|
96
102
|
receive() external payable virtual {
|
|
97
|
-
if (msg.value
|
|
103
|
+
if (msg.value != 0) {
|
|
104
|
+
universalReceiver(_TYPEID_LSP9_VALUE_RECEIVED, "");
|
|
105
|
+
}
|
|
98
106
|
}
|
|
99
107
|
|
|
100
|
-
// solhint-disable no-complex-fallback
|
|
101
|
-
|
|
102
108
|
/**
|
|
103
109
|
* @notice The `fallback` function was called with the following amount of native tokens: `msg.value`; and the following calldata: `callData`.
|
|
104
110
|
*
|
|
@@ -118,16 +124,16 @@ contract LSP9VaultCore is
|
|
|
118
124
|
*
|
|
119
125
|
* 2. If the data sent to this function is of length less than 4 bytes (not a function selector), return.
|
|
120
126
|
*
|
|
121
|
-
* @custom:events {
|
|
127
|
+
* @custom:events {UniversalReceiver} event when receiving native tokens and extension function selector is not found or not payable.
|
|
122
128
|
*/
|
|
129
|
+
// solhint-disable-next-line no-complex-fallback
|
|
123
130
|
fallback(
|
|
124
131
|
bytes calldata callData
|
|
125
132
|
) external payable virtual returns (bytes memory) {
|
|
126
|
-
if (msg.value != 0) {
|
|
127
|
-
emit ValueReceived(msg.sender, msg.value);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
133
|
if (msg.data.length < 4) {
|
|
134
|
+
// if value is associated with the extension call, use the universalReceiver
|
|
135
|
+
if (msg.value != 0)
|
|
136
|
+
universalReceiver(_TYPEID_LSP9_VALUE_RECEIVED, callData);
|
|
131
137
|
return "";
|
|
132
138
|
}
|
|
133
139
|
|
|
@@ -141,7 +147,7 @@ contract LSP9VaultCore is
|
|
|
141
147
|
*/
|
|
142
148
|
function batchCalls(
|
|
143
149
|
bytes[] calldata data
|
|
144
|
-
) public virtual returns (bytes[] memory results) {
|
|
150
|
+
) public virtual override returns (bytes[] memory results) {
|
|
145
151
|
results = new bytes[](data.length);
|
|
146
152
|
for (uint256 i; i < data.length; ) {
|
|
147
153
|
(bool success, bytes memory result) = address(this).delegatecall(
|
|
@@ -150,7 +156,7 @@ contract LSP9VaultCore is
|
|
|
150
156
|
|
|
151
157
|
if (!success) {
|
|
152
158
|
// Look for revert reason and bubble it up if present
|
|
153
|
-
if (result.length
|
|
159
|
+
if (result.length != 0) {
|
|
154
160
|
// The easiest way to bubble the revert reason is using memory via assembly
|
|
155
161
|
// solhint-disable no-inline-assembly
|
|
156
162
|
/// @solidity memory-safe-assembly
|
|
@@ -172,7 +178,7 @@ contract LSP9VaultCore is
|
|
|
172
178
|
}
|
|
173
179
|
|
|
174
180
|
/**
|
|
175
|
-
* @inheritdoc
|
|
181
|
+
* @inheritdoc ERC725XCore
|
|
176
182
|
*
|
|
177
183
|
* @custom:requirements
|
|
178
184
|
* - Can be only called by the {owner} or by an authorised address that pass the verification check performed on the owner.
|
|
@@ -183,7 +189,7 @@ contract LSP9VaultCore is
|
|
|
183
189
|
* @custom:events
|
|
184
190
|
* - {Executed} event for each call that uses under `operationType`: `CALL` (0) and `STATICCALL` (3).
|
|
185
191
|
* - {ContractCreated} event, when a contract is created under `operationType`: `CREATE` (1) and `CREATE2` (2).
|
|
186
|
-
* - {
|
|
192
|
+
* - {UniversalReceiver} event when receiving native tokens.
|
|
187
193
|
*
|
|
188
194
|
* @custom:info The `operationType` 4 `DELEGATECALL` is disabled by default in the LSP9 Vault.
|
|
189
195
|
*/
|
|
@@ -193,7 +199,15 @@ contract LSP9VaultCore is
|
|
|
193
199
|
uint256 value,
|
|
194
200
|
bytes memory data
|
|
195
201
|
) public payable virtual override onlyOwner returns (bytes memory) {
|
|
196
|
-
if (msg.value != 0)
|
|
202
|
+
if (msg.value != 0) {
|
|
203
|
+
emit UniversalReceiver(
|
|
204
|
+
msg.sender,
|
|
205
|
+
msg.value,
|
|
206
|
+
_TYPEID_LSP9_VALUE_RECEIVED,
|
|
207
|
+
abi.encodePacked(msg.sig),
|
|
208
|
+
""
|
|
209
|
+
);
|
|
210
|
+
}
|
|
197
211
|
return _execute(operationType, target, value, data);
|
|
198
212
|
}
|
|
199
213
|
|
|
@@ -210,7 +224,7 @@ contract LSP9VaultCore is
|
|
|
210
224
|
* @custom:events
|
|
211
225
|
* - {Executed} event for each call that uses under `operationType`: `CALL` (0) and `STATICCALL` (3). (each iteration)
|
|
212
226
|
* - {ContractCreated} event, when a contract is created under `operationType`: `CREATE` (1) and `CREATE2` (2). (each iteration)
|
|
213
|
-
* - {
|
|
227
|
+
* - {UniversalReceiver} event when receiving native tokens.
|
|
214
228
|
*
|
|
215
229
|
* @custom:info The `operationType` 4 `DELEGATECALL` is disabled by default in the LSP9 Vault.
|
|
216
230
|
*/
|
|
@@ -220,17 +234,24 @@ contract LSP9VaultCore is
|
|
|
220
234
|
uint256[] memory values,
|
|
221
235
|
bytes[] memory datas
|
|
222
236
|
) public payable virtual override onlyOwner returns (bytes[] memory) {
|
|
223
|
-
if (msg.value != 0)
|
|
237
|
+
if (msg.value != 0) {
|
|
238
|
+
emit UniversalReceiver(
|
|
239
|
+
msg.sender,
|
|
240
|
+
msg.value,
|
|
241
|
+
_TYPEID_LSP9_VALUE_RECEIVED,
|
|
242
|
+
abi.encodePacked(msg.sig),
|
|
243
|
+
""
|
|
244
|
+
);
|
|
245
|
+
}
|
|
224
246
|
return _executeBatch(operationsType, targets, values, datas);
|
|
225
247
|
}
|
|
226
248
|
|
|
227
249
|
/**
|
|
228
|
-
* @inheritdoc
|
|
250
|
+
* @inheritdoc ERC725YCore
|
|
229
251
|
*
|
|
230
252
|
* @custom:requirements Can be only called by the {owner} or by an authorised address that pass the verification check performed on the owner.
|
|
231
253
|
*
|
|
232
254
|
* @custom:events
|
|
233
|
-
* - {ValueReceived} event when receiving native tokens.
|
|
234
255
|
* - {DataChanged} event.
|
|
235
256
|
*/
|
|
236
257
|
function setData(
|
|
@@ -253,12 +274,11 @@ contract LSP9VaultCore is
|
|
|
253
274
|
}
|
|
254
275
|
|
|
255
276
|
/**
|
|
256
|
-
* @inheritdoc
|
|
277
|
+
* @inheritdoc ERC725YCore
|
|
257
278
|
*
|
|
258
279
|
* @custom:requirements Can be only called by the {owner} or by an authorised address that pass the verification check performed on the owner.
|
|
259
280
|
*
|
|
260
281
|
* @custom:events
|
|
261
|
-
* - {ValueReceived} event when receiving native tokens.
|
|
262
282
|
* - {DataChanged} event. (on each iteration of setting data)
|
|
263
283
|
*/
|
|
264
284
|
function setDataBatch(
|
|
@@ -318,15 +338,14 @@ contract LSP9VaultCore is
|
|
|
318
338
|
* @return returnedValues The ABI encoded return value of the LSP1UniversalReceiverDelegate call and the LSP1TypeIdDelegate call.
|
|
319
339
|
*
|
|
320
340
|
* @custom:events
|
|
321
|
-
* - {ValueReceived} when receiving native tokens.
|
|
322
341
|
* - {UniversalReceiver} event with the function parameters, call options, and the response of the UniversalReceiverDelegates (URD) contract that was called.
|
|
323
342
|
*/
|
|
324
343
|
function universalReceiver(
|
|
325
344
|
bytes32 typeId,
|
|
326
|
-
bytes
|
|
327
|
-
) public payable virtual returns (bytes memory returnedValues) {
|
|
328
|
-
if (msg.value != 0) {
|
|
329
|
-
|
|
345
|
+
bytes memory receivedData
|
|
346
|
+
) public payable virtual override returns (bytes memory returnedValues) {
|
|
347
|
+
if (msg.value != 0 && (typeId != _TYPEID_LSP9_VALUE_RECEIVED)) {
|
|
348
|
+
universalReceiver(_TYPEID_LSP9_VALUE_RECEIVED, msg.data);
|
|
330
349
|
}
|
|
331
350
|
|
|
332
351
|
bytes memory lsp1DelegateValue = _getData(
|
|
@@ -341,16 +360,17 @@ contract LSP9VaultCore is
|
|
|
341
360
|
|
|
342
361
|
if (
|
|
343
362
|
universalReceiverDelegate.supportsERC165InterfaceUnchecked(
|
|
344
|
-
|
|
363
|
+
_INTERFACEID_LSP1_DELEGATE
|
|
345
364
|
)
|
|
346
365
|
) {
|
|
347
366
|
_reentrantDelegate = universalReceiverDelegate;
|
|
348
|
-
resultDefaultDelegate =
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
receivedData,
|
|
367
|
+
resultDefaultDelegate = ILSP1UniversalReceiverDelegate(
|
|
368
|
+
universalReceiverDelegate
|
|
369
|
+
).universalReceiverDelegate(
|
|
352
370
|
msg.sender,
|
|
353
|
-
msg.value
|
|
371
|
+
msg.value,
|
|
372
|
+
typeId,
|
|
373
|
+
receivedData
|
|
354
374
|
);
|
|
355
375
|
}
|
|
356
376
|
}
|
|
@@ -370,16 +390,17 @@ contract LSP9VaultCore is
|
|
|
370
390
|
|
|
371
391
|
if (
|
|
372
392
|
universalReceiverDelegate.supportsERC165InterfaceUnchecked(
|
|
373
|
-
|
|
393
|
+
_INTERFACEID_LSP1_DELEGATE
|
|
374
394
|
)
|
|
375
395
|
) {
|
|
376
396
|
_reentrantDelegate = universalReceiverDelegate;
|
|
377
|
-
resultTypeIdDelegate =
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
receivedData,
|
|
397
|
+
resultTypeIdDelegate = ILSP1UniversalReceiverDelegate(
|
|
398
|
+
universalReceiverDelegate
|
|
399
|
+
).universalReceiverDelegate(
|
|
381
400
|
msg.sender,
|
|
382
|
-
msg.value
|
|
401
|
+
msg.value,
|
|
402
|
+
typeId,
|
|
403
|
+
receivedData
|
|
383
404
|
);
|
|
384
405
|
}
|
|
385
406
|
}
|
|
@@ -508,17 +529,36 @@ contract LSP9VaultCore is
|
|
|
508
529
|
/**
|
|
509
530
|
* @dev Forwards the call to an extension mapped to a function selector.
|
|
510
531
|
*
|
|
511
|
-
* Calls {
|
|
532
|
+
* Calls {_getExtensionAndForwardValue} to get the address of the extension mapped to the function selector being
|
|
533
|
+
* called on the account. If there is no extension, the `address(0)` will be returned.
|
|
534
|
+
* Forwards the value if the extension is payable.
|
|
535
|
+
*
|
|
536
|
+
* Reverts if there is no extension for the function being called, except for the `bytes4(0)` function selector, which passes even if there is no extension for it.
|
|
512
537
|
*
|
|
513
|
-
*
|
|
538
|
+
* If there is an extension for the function selector being called, it calls the extension with the
|
|
539
|
+
* `CALL` opcode, passing the `msg.data` appended with the 20 bytes of the {msg.sender} and 32 bytes of the `msg.value`.
|
|
514
540
|
*
|
|
515
|
-
*
|
|
541
|
+
* @custom:hint This function does not forward to the extension contract the `msg.value` received by the contract that inherits `LSP17Extendable`.
|
|
542
|
+
* If you would like to forward the `msg.value` to the extension contract, you can override the code of this internal function as follow:
|
|
543
|
+
*
|
|
544
|
+
* ```solidity
|
|
545
|
+
* (bool success, bytes memory result) = extension.call{value: msg.value}(
|
|
546
|
+
* abi.encodePacked(callData, msg.sender, msg.value)
|
|
547
|
+
* );
|
|
548
|
+
* ```
|
|
516
549
|
*/
|
|
517
550
|
function _fallbackLSP17Extendable(
|
|
518
551
|
bytes calldata callData
|
|
519
552
|
) internal virtual override returns (bytes memory) {
|
|
520
553
|
// If there is a function selector
|
|
521
|
-
|
|
554
|
+
(
|
|
555
|
+
address extension,
|
|
556
|
+
bool isForwardingValue
|
|
557
|
+
) = _getExtensionAndForwardValue(msg.sig);
|
|
558
|
+
|
|
559
|
+
// if value is associated with the extension call and function selector is not payable, use the universalReceiver
|
|
560
|
+
if (msg.value != 0 && !isForwardingValue)
|
|
561
|
+
universalReceiver(_TYPEID_LSP9_VALUE_RECEIVED, callData);
|
|
522
562
|
|
|
523
563
|
// if no extension was found for bytes4(0) return don't revert
|
|
524
564
|
if (msg.sig == bytes4(0) && extension == address(0)) return "";
|
|
@@ -527,9 +567,9 @@ contract LSP9VaultCore is
|
|
|
527
567
|
if (extension == address(0))
|
|
528
568
|
revert NoExtensionFoundForFunctionSelector(msg.sig);
|
|
529
569
|
|
|
530
|
-
(bool success, bytes memory result) = extension.call
|
|
531
|
-
|
|
532
|
-
);
|
|
570
|
+
(bool success, bytes memory result) = extension.call{
|
|
571
|
+
value: isForwardingValue ? msg.value : 0
|
|
572
|
+
}(abi.encodePacked(callData, msg.sender, msg.value));
|
|
533
573
|
|
|
534
574
|
if (success) {
|
|
535
575
|
return result;
|
|
@@ -550,18 +590,29 @@ contract LSP9VaultCore is
|
|
|
550
590
|
* - {_LSP17_EXTENSION_PREFIX} + `<bytes4>` (Check [LSP2-ERC725YJSONSchema] for encoding the data key).
|
|
551
591
|
* - If no extension is stored, returns the address(0).
|
|
552
592
|
*/
|
|
553
|
-
function
|
|
593
|
+
function _getExtensionAndForwardValue(
|
|
554
594
|
bytes4 functionSelector
|
|
555
|
-
) internal view virtual override returns (address) {
|
|
595
|
+
) internal view virtual override returns (address, bool) {
|
|
596
|
+
// Generate the data key relevant for the functionSelector being called
|
|
556
597
|
bytes32 mappedExtensionDataKey = LSP2Utils.generateMappingKey(
|
|
557
598
|
_LSP17_EXTENSION_PREFIX,
|
|
558
599
|
functionSelector
|
|
559
600
|
);
|
|
560
601
|
|
|
561
|
-
|
|
562
|
-
|
|
602
|
+
bytes memory extensionData = ERC725YCore._getData(
|
|
603
|
+
mappedExtensionDataKey
|
|
604
|
+
);
|
|
563
605
|
|
|
564
|
-
|
|
606
|
+
// Check if the extensionData is 21 bytes long (20 bytes of address + 1 byte as bool indicator ot forwards the value)
|
|
607
|
+
if (extensionData.length == 21) {
|
|
608
|
+
// Check if the last byte is 1 (true)
|
|
609
|
+
if (extensionData[20] == hex"01") {
|
|
610
|
+
// Return the address of the extension
|
|
611
|
+
return (address(bytes20(extensionData)), true);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
return (address(bytes20(extensionData)), false);
|
|
565
616
|
}
|
|
566
617
|
|
|
567
618
|
/**
|
|
@@ -626,15 +677,17 @@ contract LSP9VaultCore is
|
|
|
626
677
|
|
|
627
678
|
// Deploy with CREATE
|
|
628
679
|
if (operationType == uint256(OPERATION_1_CREATE)) {
|
|
629
|
-
if (target != address(0))
|
|
680
|
+
if (target != address(0)) {
|
|
630
681
|
revert ERC725X_CreateOperationsRequireEmptyRecipientAddress();
|
|
682
|
+
}
|
|
631
683
|
return _deployCreate(value, data);
|
|
632
684
|
}
|
|
633
685
|
|
|
634
686
|
// Deploy with CREATE2
|
|
635
687
|
if (operationType == uint256(OPERATION_2_CREATE2)) {
|
|
636
|
-
if (target != address(0))
|
|
688
|
+
if (target != address(0)) {
|
|
637
689
|
revert ERC725X_CreateOperationsRequireEmptyRecipientAddress();
|
|
690
|
+
}
|
|
638
691
|
return _deployCreate2(value, data);
|
|
639
692
|
}
|
|
640
693
|
|
|
@@ -24,7 +24,7 @@ contract LSP9VaultInit is LSP9VaultInitAbstract {
|
|
|
24
24
|
* @param newOwner The new owner of the contract.
|
|
25
25
|
*
|
|
26
26
|
* @custom:events
|
|
27
|
-
* - {
|
|
27
|
+
* - {UniversalReceiver} event when funding the contract on deployment.
|
|
28
28
|
* - {OwnershipTransferred} event when `initialOwner` is set as the contract {owner}.
|
|
29
29
|
* - {DataChanged} event when updating the {_LSP9_SUPPORTED_STANDARDS_KEY}.
|
|
30
30
|
* - {UniversalReceiver} event when notifying the `initialOwner`.
|
|
@@ -17,6 +17,7 @@ import {LSP1Utils} from "../LSP1UniversalReceiver/LSP1Utils.sol";
|
|
|
17
17
|
import {
|
|
18
18
|
_LSP9_SUPPORTED_STANDARDS_KEY,
|
|
19
19
|
_LSP9_SUPPORTED_STANDARDS_VALUE,
|
|
20
|
+
_TYPEID_LSP9_VALUE_RECEIVED,
|
|
20
21
|
_TYPEID_LSP9_OwnershipTransferred_RecipientNotification
|
|
21
22
|
} from "../LSP9Vault/LSP9Constants.sol";
|
|
22
23
|
|
|
@@ -36,13 +37,21 @@ abstract contract LSP9VaultInitAbstract is Initializable, LSP9VaultCore {
|
|
|
36
37
|
* @custom:warning ERC725X & ERC725Y parent contracts are not initialised as they don't have non-zero initial state. If you decide to add non-zero initial state to any of those contracts, you must initialize them here.
|
|
37
38
|
*
|
|
38
39
|
* @custom:events
|
|
39
|
-
* - {
|
|
40
|
+
* - {UniversalReceiver} event when funding the contract on deployment.
|
|
40
41
|
* - {OwnershipTransferred} event when `initialOwner` is set as the contract {owner}.
|
|
41
42
|
* - {DataChanged} event when updating the {_LSP9_SUPPORTED_STANDARDS_KEY}.
|
|
42
43
|
* - {UniversalReceiver} event when notifying the `initialOwner`.
|
|
43
44
|
*/
|
|
44
45
|
function _initialize(address newOwner) internal virtual onlyInitializing {
|
|
45
|
-
if (msg.value != 0)
|
|
46
|
+
if (msg.value != 0) {
|
|
47
|
+
emit UniversalReceiver(
|
|
48
|
+
msg.sender,
|
|
49
|
+
msg.value,
|
|
50
|
+
_TYPEID_LSP9_VALUE_RECEIVED,
|
|
51
|
+
"",
|
|
52
|
+
""
|
|
53
|
+
);
|
|
54
|
+
}
|
|
46
55
|
OwnableUnset._setOwner(newOwner);
|
|
47
56
|
|
|
48
57
|
// set key SupportedStandards:LSP9Vault
|
|
@@ -24,7 +24,7 @@ contract UniversalProfile is LSP0ERC725Account {
|
|
|
24
24
|
* @param initialOwner the owner of the contract
|
|
25
25
|
*
|
|
26
26
|
* @custom:events
|
|
27
|
-
* - {
|
|
27
|
+
* - {UniversalReceiver} event when funding the contract on deployment.
|
|
28
28
|
* - {OwnershipTransferred} event when `initialOwner` is set as the contract {owner}.
|
|
29
29
|
* - {DataChanged} event when setting the {_LSP3_SUPPORTED_STANDARDS_KEY}.
|
|
30
30
|
*/
|
|
@@ -28,7 +28,7 @@ contract UniversalProfileInit is UniversalProfileInitAbstract {
|
|
|
28
28
|
* @param initialOwner the owner of the contract
|
|
29
29
|
*
|
|
30
30
|
* @custom:events
|
|
31
|
-
* - {
|
|
31
|
+
* - {UniversalReceiver} event when funding the contract on deployment.
|
|
32
32
|
* - {OwnershipTransferred} event when `initialOwner` is set as the contract {owner}.
|
|
33
33
|
*/
|
|
34
34
|
function initialize(
|