@lukso/lsp-smart-contracts 0.6.0 → 0.7.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 +13 -12
- package/artifacts/Create2Factory.json +2 -2
- package/artifacts/LSP0ERC725Account.json +66 -27
- package/artifacts/LSP0ERC725AccountInit.json +71 -53
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +23 -2
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +23 -2
- package/artifacts/LSP4Compatibility.json +15 -9
- package/artifacts/LSP4DigitalAssetMetadata.json +25 -9
- package/artifacts/{LSP4DigitalAssetMetadataInit.json → LSP4DigitalAssetMetadataInitAbstract.json} +27 -60
- package/artifacts/LSP6KeyManager.json +93 -13
- package/artifacts/LSP6KeyManagerInit.json +98 -13
- package/artifacts/LSP7CappedSupply.json +56 -35
- package/artifacts/{LSP7CappedSupplyInit.json → LSP7CappedSupplyInitAbstract.json} +58 -104
- package/artifacts/LSP7CompatibleERC20.json +704 -0
- package/artifacts/LSP7CompatibleERC20InitAbstract.json +717 -0
- package/artifacts/LSP7CompatibleERC20Mintable.json +753 -0
- package/artifacts/LSP7CompatibleERC20MintableInit.json +773 -0
- package/artifacts/LSP7DigitalAsset.json +56 -61
- package/artifacts/LSP7DigitalAssetInitAbstract.json +540 -0
- package/artifacts/LSP7Mintable.json +59 -38
- package/artifacts/LSP7MintableInit.json +64 -64
- package/artifacts/LSP8CappedSupply.json +62 -9
- package/artifacts/{LSP8CappedSupplyInit.json → LSP8CappedSupplyInitAbstract.json} +64 -73
- package/artifacts/LSP8CompatibleERC721.json +907 -0
- package/artifacts/LSP8CompatibleERC721InitAbstract.json +920 -0
- package/artifacts/LSP8CompatibleERC721Mintable.json +967 -0
- package/artifacts/LSP8CompatibleERC721MintableInit.json +987 -0
- package/artifacts/LSP8IdentifiableDigitalAsset.json +62 -30
- package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +628 -0
- package/artifacts/LSP8Mintable.json +64 -11
- package/artifacts/LSP8MintableInit.json +69 -37
- package/artifacts/LSP9Vault.json +63 -24
- package/artifacts/LSP9VaultInit.json +68 -50
- package/artifacts/UniversalFactory.json +2 -2
- package/artifacts/UniversalProfile.json +66 -27
- package/artifacts/UniversalProfileInit.json +71 -53
- package/artifacts/UniversalReceiverAddressStore.json +7 -2
- package/constants.js +273 -31
- package/contracts/Custom/ClaimOwnership.sol +74 -9
- package/contracts/Custom/ERC165Checker.sol +1 -1
- package/contracts/Custom/IClaimOwnership.sol +3 -1
- package/contracts/Factories/Create2Factory.sol +3 -13
- package/contracts/Factories/UniversalFactory.sol +20 -16
- package/contracts/LSP0ERC725Account/LSP0Constants.sol +1 -1
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +3 -3
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +49 -37
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +10 -3
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +3 -3
- package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +2 -2
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +3 -0
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +4 -2
- package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +1 -1
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/Handling/TokenAndVaultHandling.sol +22 -16
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +14 -10
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/Handling/TokenHandling.sol +35 -29
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +10 -3
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +24 -9
- package/contracts/LSP2ERC725YJSONSchema/LSP2Errors.sol +9 -0
- package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +157 -75
- package/contracts/LSP3UniversalProfile/LSP3Constants.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +24 -4
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +26 -5
- package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +16 -0
- package/contracts/LSP5ReceivedAssets/LSP5Constants.sol +2 -2
- package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +151 -77
- package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +16 -16
- package/contracts/LSP6KeyManager/LSP6Constants.sol +16 -21
- package/contracts/LSP6KeyManager/LSP6Errors.sol +42 -5
- package/contracts/LSP6KeyManager/LSP6KeyManager.sol +6 -4
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +293 -284
- package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +11 -4
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +5 -3
- package/contracts/LSP6KeyManager/LSP6Utils.sol +24 -27
- package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +18 -5
- package/contracts/LSP7DigitalAsset/LSP7Constants.sol +1 -1
- package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +8 -4
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +35 -24
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +5 -3
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +2 -0
- package/contracts/LSP7DigitalAsset/extensions/{ILSP7CompatibilityForERC20.sol → ILSP7CompatibleERC20.sol} +6 -6
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyCore.sol +1 -1
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +5 -2
- package/contracts/LSP7DigitalAsset/extensions/{LSP7CompatibilityForERC20.sol → LSP7CompatibleERC20.sol} +6 -7
- package/contracts/LSP7DigitalAsset/extensions/{LSP7CompatibilityForERC20Core.sol → LSP7CompatibleERC20Core.sol} +23 -19
- package/contracts/LSP7DigitalAsset/extensions/{LSP7CompatibilityForERC20InitAbstract.sol → LSP7CompatibleERC20InitAbstract.sol} +11 -10
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +22 -0
- package/contracts/{LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721Init.sol → LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol} +12 -7
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +27 -0
- package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +9 -7
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +11 -4
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +8 -7
- package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +3 -1
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +4 -4
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +6 -0
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +31 -30
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +3 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/{ILSP8CompatibilityForERC721.sol → ILSP8CompatibleERC721.sol} +16 -2
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8Enumerable.sol +17 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyCore.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +4 -2
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityConstants.sol → LSP8CompatibleConstants.sol} +0 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityForERC721.sol → LSP8CompatibleERC721.sol} +12 -11
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityForERC721Core.sol → LSP8CompatibleERC721Core.sol} +61 -37
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityForERC721InitAbstract.sol → LSP8CompatibleERC721InitAbstract.sol} +13 -9
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +21 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableCore.sol +50 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +24 -0
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +22 -0
- package/contracts/{LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20Init.sol → LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol} +12 -4
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +27 -0
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +6 -4
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +7 -0
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +8 -5
- package/contracts/LSP9Vault/LSP9Constants.sol +6 -3
- package/contracts/LSP9Vault/LSP9Vault.sol +9 -5
- package/contracts/LSP9Vault/LSP9VaultCore.sol +152 -69
- package/contracts/LSP9Vault/LSP9VaultInit.sol +10 -3
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +9 -5
- package/contracts/Legacy/UniversalReceiverAddressStore.sol +6 -2
- package/contracts/UniversalProfile.sol +3 -4
- package/contracts/UniversalProfileInit.sol +10 -3
- package/contracts/UniversalProfileInitAbstract.sol +3 -5
- package/contracts/Utils/GasLib.sol +17 -0
- package/contracts/Utils/UtilsLib.sol +6 -34
- package/package.json +27 -30
- package/artifacts/LSP7CompatibilityForERC20.json +0 -686
- package/artifacts/LSP7CompatibilityForERC20Init.json +0 -727
- package/artifacts/LSP7DigitalAssetInit.json +0 -573
- package/artifacts/LSP8CompatibilityForERC721.json +0 -832
- package/artifacts/LSP8CompatibilityForERC721Init.json +0 -873
- package/artifacts/LSP8IdentifiableDigitalAssetInit.json +0 -624
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInit.sol +0 -26
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInit.sol +0 -28
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInit.sol +0 -19
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableCore.sol +0 -26
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInit.sol +0 -26
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInit.sol +0 -19
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableCore.sol +0 -26
|
@@ -2,16 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
pragma solidity ^0.8.0;
|
|
4
4
|
|
|
5
|
+
// interfaces
|
|
6
|
+
import {ILSP8Mintable} from "./ILSP8Mintable.sol";
|
|
5
7
|
// modules
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
+
import {
|
|
9
|
+
LSP8IdentifiableDigitalAssetInitAbstract
|
|
10
|
+
} from "../LSP8IdentifiableDigitalAssetInitAbstract.sol";
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
* @dev LSP8 extension.
|
|
11
14
|
*/
|
|
12
15
|
abstract contract LSP8MintableInitAbstract is
|
|
13
16
|
LSP8IdentifiableDigitalAssetInitAbstract,
|
|
14
|
-
|
|
17
|
+
ILSP8Mintable
|
|
15
18
|
{
|
|
16
19
|
function _initialize(
|
|
17
20
|
string memory name_,
|
|
@@ -22,14 +25,14 @@ abstract contract LSP8MintableInitAbstract is
|
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
/**
|
|
25
|
-
* @inheritdoc
|
|
28
|
+
* @inheritdoc ILSP8Mintable
|
|
26
29
|
*/
|
|
27
30
|
function mint(
|
|
28
31
|
address to,
|
|
29
32
|
bytes32 tokenId,
|
|
30
33
|
bool force,
|
|
31
34
|
bytes memory data
|
|
32
|
-
) public virtual
|
|
35
|
+
) public virtual onlyOwner {
|
|
33
36
|
_mint(to, tokenId, force, data);
|
|
34
37
|
}
|
|
35
38
|
}
|
|
@@ -2,20 +2,23 @@
|
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
4
|
// --- ERC165 interface ids
|
|
5
|
-
bytes4 constant _INTERFACEID_LSP9 =
|
|
5
|
+
bytes4 constant _INTERFACEID_LSP9 = 0xfd4d5c50;
|
|
6
6
|
|
|
7
7
|
// --- ERC725Y Keys
|
|
8
8
|
|
|
9
|
-
// bytes10(keccak256('
|
|
9
|
+
// bytes10(keccak256('SupportedStandards')) + bytes2(0) + bytes20(keccak256('LSP9Vault'))
|
|
10
10
|
bytes32 constant _LSP9_SUPPORTED_STANDARDS_KEY = 0xeafec4d89fa9619884b600007c0334a14085fefa8b51ae5a40895018882bdb90;
|
|
11
11
|
|
|
12
12
|
// bytes4(keccak256('LSP9Vault'))
|
|
13
13
|
bytes constant _LSP9_SUPPORTED_STANDARDS_VALUE = hex"7c0334a1";
|
|
14
14
|
|
|
15
|
-
// ---
|
|
15
|
+
// --- Vault Hooks
|
|
16
16
|
|
|
17
17
|
// keccak256("LSP9VaultSender")
|
|
18
18
|
bytes32 constant _TYPEID_LSP9_VAULTSENDER = 0x3ca9f769340018257ac15b3a00e502e8fb730d66086f774210f84d0205af31e7;
|
|
19
19
|
|
|
20
20
|
// keccak256("LSP9VaultRecipient")
|
|
21
21
|
bytes32 constant _TYPEID_LSP9_VAULTRECIPIENT = 0x09aaf55960715d8d86b57af40be36b0bfd469c9a3643445d8c65d39e27b4c56f;
|
|
22
|
+
|
|
23
|
+
// keccak256("LSP9VaultPendingOwner")
|
|
24
|
+
bytes32 constant _TYPEID_LSP9_VAULTPENDINGOWNER = 0x50d401f7017708f51f2a7a1c24146f786926c831079107140037b8ebef9fd326;
|
|
@@ -11,7 +11,11 @@ import {LSP9VaultCore, ClaimOwnership} from "./LSP9VaultCore.sol";
|
|
|
11
11
|
|
|
12
12
|
// constants
|
|
13
13
|
import {_INTERFACEID_LSP1} from "../LSP1UniversalReceiver/LSP1Constants.sol";
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
_INTERFACEID_LSP9,
|
|
16
|
+
_LSP9_SUPPORTED_STANDARDS_KEY,
|
|
17
|
+
_LSP9_SUPPORTED_STANDARDS_VALUE
|
|
18
|
+
} from "../LSP9Vault/LSP9Constants.sol";
|
|
15
19
|
|
|
16
20
|
/**
|
|
17
21
|
* @title Implementation of LSP9Vault built on top of ERC725, LSP1UniversalReceiver
|
|
@@ -21,14 +25,14 @@ import {_INTERFACEID_LSP9, _LSP9_SUPPORTED_STANDARDS_KEY, _LSP9_SUPPORTED_STANDA
|
|
|
21
25
|
contract LSP9Vault is LSP9VaultCore {
|
|
22
26
|
/**
|
|
23
27
|
* @notice Sets the owner of the contract and sets the SupportedStandards:LSP9Vault key
|
|
24
|
-
* @param
|
|
28
|
+
* @param newOwner the owner of the contract
|
|
25
29
|
*/
|
|
26
|
-
constructor(address
|
|
27
|
-
OwnableUnset._setOwner(
|
|
30
|
+
constructor(address newOwner) {
|
|
31
|
+
OwnableUnset._setOwner(newOwner);
|
|
28
32
|
|
|
29
33
|
// set key SupportedStandards:LSP9Vault
|
|
30
34
|
_setData(_LSP9_SUPPORTED_STANDARDS_KEY, _LSP9_SUPPORTED_STANDARDS_VALUE);
|
|
31
35
|
|
|
32
|
-
_notifyVaultReceiver(
|
|
36
|
+
_notifyVaultReceiver(newOwner);
|
|
33
37
|
}
|
|
34
38
|
}
|
|
@@ -2,23 +2,42 @@
|
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
|
-
import {IERC725Y} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
|
|
6
5
|
import {ILSP1UniversalReceiver} from "../LSP1UniversalReceiver/ILSP1UniversalReceiver.sol";
|
|
7
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
ILSP1UniversalReceiverDelegate
|
|
8
|
+
} from "../LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol";
|
|
8
9
|
|
|
9
10
|
// libraries
|
|
11
|
+
import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
|
|
12
|
+
import {GasLib} from "../Utils/GasLib.sol";
|
|
10
13
|
import {ERC165Checker} from "../Custom/ERC165Checker.sol";
|
|
11
14
|
|
|
12
15
|
// modules
|
|
13
|
-
import {ERC725XCore} from "@erc725/smart-contracts/contracts/ERC725XCore.sol";
|
|
14
|
-
import {ERC725YCore} from "@erc725/smart-contracts/contracts/ERC725YCore.sol";
|
|
16
|
+
import {ERC725XCore, IERC725X} from "@erc725/smart-contracts/contracts/ERC725XCore.sol";
|
|
17
|
+
import {ERC725YCore, IERC725Y} from "@erc725/smart-contracts/contracts/ERC725YCore.sol";
|
|
15
18
|
import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
|
|
16
19
|
import {ClaimOwnership} from "../Custom/ClaimOwnership.sol";
|
|
17
20
|
|
|
18
21
|
// constants
|
|
19
22
|
import {_INTERFACEID_CLAIM_OWNERSHIP} from "../Custom/IClaimOwnership.sol";
|
|
20
|
-
|
|
21
|
-
import {
|
|
23
|
+
|
|
24
|
+
import {
|
|
25
|
+
OPERATION_CALL,
|
|
26
|
+
OPERATION_STATICCALL,
|
|
27
|
+
OPERATION_CREATE,
|
|
28
|
+
OPERATION_CREATE2
|
|
29
|
+
} from "@erc725/smart-contracts/contracts/constants.sol";
|
|
30
|
+
import {
|
|
31
|
+
_INTERFACEID_LSP1,
|
|
32
|
+
_INTERFACEID_LSP1_DELEGATE,
|
|
33
|
+
_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY
|
|
34
|
+
} from "../LSP1UniversalReceiver/LSP1Constants.sol";
|
|
35
|
+
import {
|
|
36
|
+
_INTERFACEID_LSP9,
|
|
37
|
+
_TYPEID_LSP9_VAULTRECIPIENT,
|
|
38
|
+
_TYPEID_LSP9_VAULTSENDER,
|
|
39
|
+
_TYPEID_LSP9_VAULTPENDINGOWNER
|
|
40
|
+
} from "./LSP9Constants.sol";
|
|
22
41
|
|
|
23
42
|
/**
|
|
24
43
|
* @title Core Implementation of LSP9Vault built on top of ERC725, LSP1UniversalReceiver
|
|
@@ -57,55 +76,43 @@ contract LSP9VaultCore is ERC725XCore, ERC725YCore, ClaimOwnership, ILSP1Univers
|
|
|
57
76
|
/**
|
|
58
77
|
* @dev Emits an event when receiving native tokens
|
|
59
78
|
*/
|
|
60
|
-
|
|
61
|
-
emit ValueReceived(
|
|
79
|
+
fallback() external payable virtual {
|
|
80
|
+
if (msg.value != 0) emit ValueReceived(msg.sender, msg.value);
|
|
62
81
|
}
|
|
63
82
|
|
|
64
|
-
//
|
|
83
|
+
// ERC725
|
|
65
84
|
|
|
66
85
|
/**
|
|
67
|
-
* @
|
|
86
|
+
* @inheritdoc IERC725X
|
|
87
|
+
* @param operation The operation to execute: CALL = 0 CREATE = 1 CREATE2 = 2 STATICCALL = 3
|
|
88
|
+
* @dev Executes any other smart contract.
|
|
89
|
+
* SHOULD only be callable by the owner of the contract set via ERC173
|
|
90
|
+
*
|
|
91
|
+
* Emits a {Executed} event, when a call is executed under `operationType` 0 and 3
|
|
92
|
+
* Emits a {ContractCreated} event, when a contract is created under `operationType` 1 and 2
|
|
68
93
|
*/
|
|
69
|
-
function
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return
|
|
77
|
-
interfaceId == _INTERFACEID_LSP9 ||
|
|
78
|
-
interfaceId == _INTERFACEID_LSP1 ||
|
|
79
|
-
interfaceId == _INTERFACEID_CLAIM_OWNERSHIP ||
|
|
80
|
-
super.supportsInterface(interfaceId);
|
|
81
|
-
}
|
|
94
|
+
function execute(
|
|
95
|
+
uint256 operation,
|
|
96
|
+
address to,
|
|
97
|
+
uint256 value,
|
|
98
|
+
bytes memory data
|
|
99
|
+
) public payable virtual override onlyOwner returns (bytes memory) {
|
|
100
|
+
require(address(this).balance >= value, "ERC725X: insufficient balance");
|
|
82
101
|
|
|
83
|
-
|
|
102
|
+
// CALL
|
|
103
|
+
if (operation == OPERATION_CALL) return _executeCall(to, value, data);
|
|
84
104
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
*/
|
|
88
|
-
function transferOwnership(address newOwner)
|
|
89
|
-
public
|
|
90
|
-
virtual
|
|
91
|
-
override(ClaimOwnership, OwnableUnset)
|
|
92
|
-
onlyOwner
|
|
93
|
-
{
|
|
94
|
-
ClaimOwnership._transferOwnership(newOwner);
|
|
95
|
-
}
|
|
105
|
+
// Deploy with CREATE
|
|
106
|
+
if (operation == OPERATION_CREATE) return _deployCreate(to, value, data);
|
|
96
107
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
*/
|
|
100
|
-
function claimOwnership() public virtual override {
|
|
101
|
-
address previousOwner = owner();
|
|
102
|
-
super.claimOwnership();
|
|
108
|
+
// Deploy with CREATE2
|
|
109
|
+
if (operation == OPERATION_CREATE2) return _deployCreate2(to, value, data);
|
|
103
110
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
111
|
+
// STATICCALL
|
|
112
|
+
if (operation == OPERATION_STATICCALL) return _executeStaticCall(to, value, data);
|
|
107
113
|
|
|
108
|
-
|
|
114
|
+
revert("ERC725X: Unknown operation type");
|
|
115
|
+
}
|
|
109
116
|
|
|
110
117
|
/**
|
|
111
118
|
* @inheritdoc IERC725Y
|
|
@@ -115,8 +122,8 @@ contract LSP9VaultCore is ERC725XCore, ERC725YCore, ClaimOwnership, ILSP1Univers
|
|
|
115
122
|
*
|
|
116
123
|
* Emits a {DataChanged} event.
|
|
117
124
|
*/
|
|
118
|
-
function setData(bytes32
|
|
119
|
-
_setData(
|
|
125
|
+
function setData(bytes32 dataKey, bytes memory dataValue) public virtual override onlyAllowed {
|
|
126
|
+
_setData(dataKey, dataValue);
|
|
120
127
|
}
|
|
121
128
|
|
|
122
129
|
/**
|
|
@@ -127,15 +134,15 @@ contract LSP9VaultCore is ERC725XCore, ERC725YCore, ClaimOwnership, ILSP1Univers
|
|
|
127
134
|
*
|
|
128
135
|
* Emits a {DataChanged} event.
|
|
129
136
|
*/
|
|
130
|
-
function setData(bytes32[] memory
|
|
137
|
+
function setData(bytes32[] memory dataKeys, bytes[] memory dataValues)
|
|
131
138
|
public
|
|
132
139
|
virtual
|
|
133
140
|
override
|
|
134
141
|
onlyAllowed
|
|
135
142
|
{
|
|
136
|
-
require(
|
|
137
|
-
for (uint256 i = 0; i <
|
|
138
|
-
_setData(
|
|
143
|
+
require(dataKeys.length == dataValues.length, "Keys length not equal to values length");
|
|
144
|
+
for (uint256 i = 0; i < dataKeys.length; i = GasLib.uncheckedIncrement(i)) {
|
|
145
|
+
_setData(dataKeys[i], dataValues[i]);
|
|
139
146
|
}
|
|
140
147
|
}
|
|
141
148
|
|
|
@@ -144,19 +151,19 @@ contract LSP9VaultCore is ERC725XCore, ERC725YCore, ClaimOwnership, ILSP1Univers
|
|
|
144
151
|
/**
|
|
145
152
|
* @notice Triggers the UniversalReceiver event when this function gets executed successfully.
|
|
146
153
|
* @dev Forwards the call to the UniversalReceiverDelegate if set.
|
|
147
|
-
* @param
|
|
148
|
-
* @param
|
|
154
|
+
* @param typeId The type of call received.
|
|
155
|
+
* @param data The data received.
|
|
149
156
|
*/
|
|
150
|
-
function universalReceiver(bytes32
|
|
151
|
-
|
|
157
|
+
function universalReceiver(bytes32 typeId, bytes calldata data)
|
|
158
|
+
public
|
|
159
|
+
payable
|
|
152
160
|
virtual
|
|
153
|
-
override
|
|
154
161
|
returns (bytes memory returnValue)
|
|
155
162
|
{
|
|
156
|
-
bytes memory
|
|
163
|
+
bytes memory lsp1DelegateValue = _getData(_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY);
|
|
157
164
|
|
|
158
|
-
if (
|
|
159
|
-
address universalReceiverDelegate = address(bytes20(
|
|
165
|
+
if (lsp1DelegateValue.length >= 20) {
|
|
166
|
+
address universalReceiverDelegate = address(bytes20(lsp1DelegateValue));
|
|
160
167
|
|
|
161
168
|
if (
|
|
162
169
|
ERC165Checker.supportsERC165Interface(
|
|
@@ -165,29 +172,105 @@ contract LSP9VaultCore is ERC725XCore, ERC725YCore, ClaimOwnership, ILSP1Univers
|
|
|
165
172
|
)
|
|
166
173
|
) {
|
|
167
174
|
returnValue = ILSP1UniversalReceiverDelegate(universalReceiverDelegate)
|
|
168
|
-
.universalReceiverDelegate(
|
|
175
|
+
.universalReceiverDelegate(msg.sender, msg.value, typeId, data);
|
|
169
176
|
}
|
|
170
177
|
}
|
|
171
|
-
emit UniversalReceiver(
|
|
178
|
+
emit UniversalReceiver(msg.sender, msg.value, typeId, returnValue, data);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// ERC173 - Modified ClaimOwnership
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* @dev Sets the pending owner and notify the pending owner
|
|
185
|
+
*/
|
|
186
|
+
function transferOwnership(address newOwner)
|
|
187
|
+
public
|
|
188
|
+
virtual
|
|
189
|
+
override(ClaimOwnership, OwnableUnset)
|
|
190
|
+
onlyOwner
|
|
191
|
+
{
|
|
192
|
+
ClaimOwnership._transferOwnership(newOwner);
|
|
193
|
+
_notifyVaultPendingOwner(newOwner);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @dev Transfer the ownership and notify the previous and the new owner.
|
|
198
|
+
*/
|
|
199
|
+
function claimOwnership() public virtual override {
|
|
200
|
+
address previousOwner = owner();
|
|
201
|
+
|
|
202
|
+
_claimOwnership();
|
|
203
|
+
|
|
204
|
+
_notifyVaultSender(previousOwner);
|
|
205
|
+
_notifyVaultReceiver(msg.sender);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* @dev Renounce ownership of the contract in a 2-step process
|
|
210
|
+
*/
|
|
211
|
+
function renounceOwnership() public virtual override(ClaimOwnership, OwnableUnset) onlyOwner {
|
|
212
|
+
ClaimOwnership._renounceOwnership();
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// ERC165
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* @dev See {IERC165-supportsInterface}.
|
|
219
|
+
*/
|
|
220
|
+
function supportsInterface(bytes4 interfaceId)
|
|
221
|
+
public
|
|
222
|
+
view
|
|
223
|
+
virtual
|
|
224
|
+
override(ERC725XCore, ERC725YCore)
|
|
225
|
+
returns (bool)
|
|
226
|
+
{
|
|
227
|
+
return
|
|
228
|
+
interfaceId == _INTERFACEID_LSP9 ||
|
|
229
|
+
interfaceId == _INTERFACEID_LSP1 ||
|
|
230
|
+
interfaceId == _INTERFACEID_CLAIM_OWNERSHIP ||
|
|
231
|
+
super.supportsInterface(interfaceId);
|
|
172
232
|
}
|
|
173
233
|
|
|
174
234
|
// internal functions
|
|
175
235
|
|
|
176
236
|
/**
|
|
177
|
-
* @dev
|
|
237
|
+
* @dev SAVE GAS by emitting the DataChanged event with only the first 256 bytes of dataValue
|
|
238
|
+
*/
|
|
239
|
+
function _setData(bytes32 dataKey, bytes memory dataValue) internal virtual override {
|
|
240
|
+
store[dataKey] = dataValue;
|
|
241
|
+
emit DataChanged(
|
|
242
|
+
dataKey,
|
|
243
|
+
dataValue.length <= 256 ? dataValue : BytesLib.slice(dataValue, 0, 256)
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* @dev Calls the universalReceiver function of the vault sender if supports LSP1 InterfaceId
|
|
178
249
|
*/
|
|
179
|
-
function _notifyVaultSender(address
|
|
180
|
-
if (ERC165Checker.supportsERC165Interface(
|
|
181
|
-
ILSP1UniversalReceiver(
|
|
250
|
+
function _notifyVaultSender(address sender) internal virtual {
|
|
251
|
+
if (ERC165Checker.supportsERC165Interface(sender, _INTERFACEID_LSP1)) {
|
|
252
|
+
ILSP1UniversalReceiver(sender).universalReceiver(_TYPEID_LSP9_VAULTSENDER, "");
|
|
182
253
|
}
|
|
183
254
|
}
|
|
184
255
|
|
|
185
256
|
/**
|
|
186
|
-
* @dev Calls the universalReceiver function of the
|
|
257
|
+
* @dev Calls the universalReceiver function of the vault owner if supports LSP1 InterfaceId
|
|
187
258
|
*/
|
|
188
|
-
function _notifyVaultReceiver(address
|
|
189
|
-
if (ERC165Checker.supportsERC165Interface(
|
|
190
|
-
ILSP1UniversalReceiver(
|
|
259
|
+
function _notifyVaultReceiver(address receiver) internal virtual {
|
|
260
|
+
if (ERC165Checker.supportsERC165Interface(receiver, _INTERFACEID_LSP1)) {
|
|
261
|
+
ILSP1UniversalReceiver(receiver).universalReceiver(_TYPEID_LSP9_VAULTRECIPIENT, "");
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* @dev Calls the universalReceiver function of the pending owner if supports LSP1 InterfaceId
|
|
267
|
+
*/
|
|
268
|
+
function _notifyVaultPendingOwner(address newPendingOwner) internal virtual {
|
|
269
|
+
if (ERC165Checker.supportsERC165Interface(newPendingOwner, _INTERFACEID_LSP1)) {
|
|
270
|
+
ILSP1UniversalReceiver(newPendingOwner).universalReceiver(
|
|
271
|
+
_TYPEID_LSP9_VAULTPENDINGOWNER,
|
|
272
|
+
""
|
|
273
|
+
);
|
|
191
274
|
}
|
|
192
275
|
}
|
|
193
276
|
}
|
|
@@ -10,11 +10,18 @@ import {LSP9VaultInitAbstract} from "./LSP9VaultInitAbstract.sol";
|
|
|
10
10
|
* @dev Could be owned by a UniversalProfile and able to register received asset with UniversalReceiverDelegateVault
|
|
11
11
|
*/
|
|
12
12
|
contract LSP9VaultInit is LSP9VaultInitAbstract {
|
|
13
|
+
/**
|
|
14
|
+
* @dev initialize (= lock) base implementation contract on deployment
|
|
15
|
+
*/
|
|
16
|
+
constructor() {
|
|
17
|
+
_disableInitializers();
|
|
18
|
+
}
|
|
19
|
+
|
|
13
20
|
/**
|
|
14
21
|
* @notice Sets the owner of the contract and sets the SupportedStandards:LSP9Vault key
|
|
15
|
-
* @param
|
|
22
|
+
* @param newOwner the owner of the contract
|
|
16
23
|
*/
|
|
17
|
-
function initialize(address
|
|
18
|
-
LSP9VaultInitAbstract._initialize(
|
|
24
|
+
function initialize(address newOwner) public virtual initializer {
|
|
25
|
+
LSP9VaultInitAbstract._initialize(newOwner);
|
|
19
26
|
}
|
|
20
27
|
}
|
|
@@ -6,12 +6,16 @@ import {IERC725Y} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.so
|
|
|
6
6
|
|
|
7
7
|
// modules
|
|
8
8
|
import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
|
|
9
|
-
import {Initializable} from "@
|
|
9
|
+
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
10
10
|
import {LSP9VaultCore, ClaimOwnership} from "./LSP9VaultCore.sol";
|
|
11
11
|
|
|
12
12
|
// constants
|
|
13
13
|
import {_INTERFACEID_LSP1} from "../LSP1UniversalReceiver/LSP1Constants.sol";
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
_INTERFACEID_LSP9,
|
|
16
|
+
_LSP9_SUPPORTED_STANDARDS_KEY,
|
|
17
|
+
_LSP9_SUPPORTED_STANDARDS_VALUE
|
|
18
|
+
} from "../LSP9Vault/LSP9Constants.sol";
|
|
15
19
|
|
|
16
20
|
/**
|
|
17
21
|
* @title Inheritable Proxy Implementation of LSP9Vault built on top of ERC725, LSP1UniversalReceiver
|
|
@@ -19,12 +23,12 @@ import {_INTERFACEID_LSP9, _LSP9_SUPPORTED_STANDARDS_KEY, _LSP9_SUPPORTED_STANDA
|
|
|
19
23
|
* @dev Could be owned by a UniversalProfile and able to register received asset with UniversalReceiverDelegateVault
|
|
20
24
|
*/
|
|
21
25
|
abstract contract LSP9VaultInitAbstract is Initializable, LSP9VaultCore {
|
|
22
|
-
function _initialize(address
|
|
23
|
-
OwnableUnset._setOwner(
|
|
26
|
+
function _initialize(address newOwner) internal virtual onlyInitializing {
|
|
27
|
+
OwnableUnset._setOwner(newOwner);
|
|
24
28
|
|
|
25
29
|
// set key SupportedStandards:LSP9Vault
|
|
26
30
|
_setData(_LSP9_SUPPORTED_STANDARDS_KEY, _LSP9_SUPPORTED_STANDARDS_VALUE);
|
|
27
31
|
|
|
28
|
-
_notifyVaultReceiver(
|
|
32
|
+
_notifyVaultReceiver(newOwner);
|
|
29
33
|
}
|
|
30
34
|
}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
ILSP1UniversalReceiverDelegate
|
|
7
|
+
} from "../LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol";
|
|
6
8
|
|
|
7
9
|
// libraries
|
|
8
10
|
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
@@ -18,7 +20,7 @@ contract UniversalReceiverAddressStore is
|
|
|
18
20
|
{
|
|
19
21
|
using EnumerableSet for EnumerableSet.AddressSet;
|
|
20
22
|
|
|
21
|
-
bytes4 internal constant _INTERFACE_ID_LSP1DELEGATE =
|
|
23
|
+
bytes4 internal constant _INTERFACE_ID_LSP1DELEGATE = 0xa245bbda;
|
|
22
24
|
|
|
23
25
|
bytes32 internal constant _TOKENS_RECIPIENT_INTERFACE_HASH =
|
|
24
26
|
0xb281fc8c12954d22544db45de3159a39272895b169a852b314f9cc762e44c53b; // keccak256("ERC777TokensRecipient")
|
|
@@ -38,8 +40,10 @@ contract UniversalReceiverAddressStore is
|
|
|
38
40
|
return _addressStore.remove(_address);
|
|
39
41
|
}
|
|
40
42
|
|
|
43
|
+
// solhint-disable no-unused-vars
|
|
41
44
|
function universalReceiverDelegate(
|
|
42
45
|
address sender,
|
|
46
|
+
uint256 value,
|
|
43
47
|
bytes32 typeId,
|
|
44
48
|
bytes memory
|
|
45
49
|
) external override onlyAccount returns (bytes memory) {
|
|
@@ -5,9 +5,8 @@ pragma solidity ^0.8.0;
|
|
|
5
5
|
import {LSP0ERC725Account} from "./LSP0ERC725Account/LSP0ERC725Account.sol";
|
|
6
6
|
|
|
7
7
|
// constants
|
|
8
|
-
// prettier-ignore
|
|
9
8
|
import {
|
|
10
|
-
_LSP3_SUPPORTED_STANDARDS_KEY,
|
|
9
|
+
_LSP3_SUPPORTED_STANDARDS_KEY,
|
|
11
10
|
_LSP3_SUPPORTED_STANDARDS_VALUE
|
|
12
11
|
} from "./LSP3UniversalProfile/LSP3Constants.sol";
|
|
13
12
|
|
|
@@ -19,9 +18,9 @@ import {
|
|
|
19
18
|
contract UniversalProfile is LSP0ERC725Account {
|
|
20
19
|
/**
|
|
21
20
|
* @notice Sets the owner of the contract and sets the SupportedStandards:LSP3UniversalProfile key
|
|
22
|
-
* @param
|
|
21
|
+
* @param newOwner the owner of the contract
|
|
23
22
|
*/
|
|
24
|
-
constructor(address
|
|
23
|
+
constructor(address newOwner) LSP0ERC725Account(newOwner) payable {
|
|
25
24
|
// set key SupportedStandards:LSP3UniversalProfile
|
|
26
25
|
_setData(_LSP3_SUPPORTED_STANDARDS_KEY, _LSP3_SUPPORTED_STANDARDS_VALUE);
|
|
27
26
|
}
|
|
@@ -10,11 +10,18 @@ import {UniversalProfileInitAbstract} from "./UniversalProfileInitAbstract.sol";
|
|
|
10
10
|
* @dev Implementation of the ERC725Account + LSP1 universalReceiver
|
|
11
11
|
*/
|
|
12
12
|
contract UniversalProfileInit is UniversalProfileInitAbstract {
|
|
13
|
+
/**
|
|
14
|
+
* @dev initialize (= lock) base implementation contract on deployment
|
|
15
|
+
*/
|
|
16
|
+
constructor() {
|
|
17
|
+
_disableInitializers();
|
|
18
|
+
}
|
|
19
|
+
|
|
13
20
|
/**
|
|
14
21
|
* @notice Sets the owner of the contract and sets the SupportedStandards:LSP3UniversalProfile key
|
|
15
|
-
* @param
|
|
22
|
+
* @param newOwner the owner of the contract
|
|
16
23
|
*/
|
|
17
|
-
function initialize(address
|
|
18
|
-
UniversalProfileInitAbstract._initialize(
|
|
24
|
+
function initialize(address newOwner) public payable virtual initializer {
|
|
25
|
+
UniversalProfileInitAbstract._initialize(newOwner);
|
|
19
26
|
}
|
|
20
27
|
}
|
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
|
-
import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
|
|
6
5
|
import {LSP0ERC725AccountInitAbstract} from "./LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol";
|
|
7
6
|
|
|
8
7
|
// constants
|
|
9
|
-
// prettier-ignore
|
|
10
8
|
import {
|
|
11
|
-
_LSP3_SUPPORTED_STANDARDS_KEY,
|
|
9
|
+
_LSP3_SUPPORTED_STANDARDS_KEY,
|
|
12
10
|
_LSP3_SUPPORTED_STANDARDS_VALUE
|
|
13
11
|
} from "./LSP3UniversalProfile/LSP3Constants.sol";
|
|
14
12
|
|
|
@@ -18,8 +16,8 @@ import {
|
|
|
18
16
|
* @dev Implementation of the ERC725Account + LSP1 universalReceiver
|
|
19
17
|
*/
|
|
20
18
|
abstract contract UniversalProfileInitAbstract is LSP0ERC725AccountInitAbstract {
|
|
21
|
-
function _initialize(address
|
|
22
|
-
LSP0ERC725AccountInitAbstract._initialize(
|
|
19
|
+
function _initialize(address newOwner) internal virtual override onlyInitializing {
|
|
20
|
+
LSP0ERC725AccountInitAbstract._initialize(newOwner);
|
|
23
21
|
|
|
24
22
|
// set key SupportedStandards:LSP3UniversalProfile
|
|
25
23
|
_setData(_LSP3_SUPPORTED_STANDARDS_KEY, _LSP3_SUPPORTED_STANDARDS_VALUE);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @dev Library to add all efficient functions that could get repeated.
|
|
6
|
+
*/
|
|
7
|
+
library GasLib {
|
|
8
|
+
/**
|
|
9
|
+
* @dev Will return unchecked incremented uint256
|
|
10
|
+
* can be used to save gas when iterating over loops
|
|
11
|
+
*/
|
|
12
|
+
function uncheckedIncrement(uint256 i) internal pure returns (uint256) {
|
|
13
|
+
unchecked {
|
|
14
|
+
return i + 1;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -11,49 +11,21 @@ library UtilsLib {
|
|
|
11
11
|
/**
|
|
12
12
|
* @dev concatenate two bytes16
|
|
13
13
|
*/
|
|
14
|
-
function concatTwoBytes16(bytes16 b1, bytes16 b2)
|
|
15
|
-
|
|
16
|
-
pure
|
|
17
|
-
returns (bytes memory result)
|
|
18
|
-
{
|
|
19
|
-
result = new bytes(32);
|
|
20
|
-
assembly {
|
|
21
|
-
mstore(add(result, 32), b1)
|
|
22
|
-
mstore(add(result, 48), b2)
|
|
23
|
-
}
|
|
14
|
+
function concatTwoBytes16(bytes16 b1, bytes16 b2) internal pure returns (bytes memory result) {
|
|
15
|
+
result = bytes.concat(b1, b2);
|
|
24
16
|
}
|
|
25
17
|
|
|
26
18
|
/**
|
|
27
19
|
* @dev cast uint256 to bytes
|
|
28
20
|
*/
|
|
29
|
-
function uint256ToBytes(uint256 num)
|
|
30
|
-
|
|
31
|
-
pure
|
|
32
|
-
returns (bytes memory bytes_)
|
|
33
|
-
{
|
|
34
|
-
bytes_ = new bytes(32);
|
|
35
|
-
assembly {
|
|
36
|
-
mstore(add(bytes_, 32), num)
|
|
37
|
-
}
|
|
21
|
+
function uint256ToBytes(uint256 num) internal pure returns (bytes memory bytes_) {
|
|
22
|
+
bytes_ = bytes.concat(bytes32(num));
|
|
38
23
|
}
|
|
39
24
|
|
|
40
25
|
/**
|
|
41
26
|
* @dev cast address to bytes
|
|
42
27
|
*/
|
|
43
|
-
function addressToBytes(address addr)
|
|
44
|
-
|
|
45
|
-
pure
|
|
46
|
-
returns (bytes memory bytes_)
|
|
47
|
-
{
|
|
48
|
-
assembly {
|
|
49
|
-
let m := mload(0x40)
|
|
50
|
-
addr := and(addr, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
|
|
51
|
-
mstore(
|
|
52
|
-
add(m, 20),
|
|
53
|
-
xor(0x140000000000000000000000000000000000000000, addr)
|
|
54
|
-
)
|
|
55
|
-
mstore(0x40, add(m, 52))
|
|
56
|
-
bytes_ := m
|
|
57
|
-
}
|
|
28
|
+
function addressToBytes(address addr) internal pure returns (bytes memory bytes_) {
|
|
29
|
+
bytes_ = bytes.concat(bytes20(addr));
|
|
58
30
|
}
|
|
59
31
|
}
|