@lukso/lsp-smart-contracts 0.10.0 → 0.10.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 +14 -0
- package/artifacts/LSP0ERC725Account.json +3 -3
- package/artifacts/LSP0ERC725AccountInit.json +3 -3
- package/artifacts/LSP16UniversalFactory.json +27 -21
- package/artifacts/UniversalProfile.json +3 -3
- package/artifacts/UniversalProfileInit.json +3 -3
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +10 -5
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +15 -5
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +11 -6
- package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +262 -115
- package/contracts/UniversalProfile.sol +10 -4
- package/contracts/UniversalProfileInit.sol +15 -5
- package/contracts/UniversalProfileInitAbstract.sol +5 -6
- package/devdocs/LSP0ERC725Account.json +2 -2
- package/devdocs/LSP0ERC725AccountInit.json +3 -3
- package/devdocs/LSP16UniversalFactory.json +87 -22
- package/devdocs/UniversalProfile.json +2 -1
- package/devdocs/UniversalProfileInit.json +3 -2
- package/dist/constants.cjs.js +168 -80
- package/dist/constants.d.ts +116 -38
- package/dist/constants.es.js +168 -80
- package/package.json +3 -2
- package/userdocs/LSP0ERC725Account.json +3 -0
- package/userdocs/LSP0ERC725AccountInit.json +6 -0
- package/userdocs/UniversalProfile.json +1 -1
- package/userdocs/UniversalProfileInit.json +4 -1
|
@@ -1,51 +1,116 @@
|
|
|
1
1
|
{
|
|
2
|
-
"details": "
|
|
2
|
+
"details": "Factory contract to deploy different types of contracts using the CREATE2 opcode standardized as LSP16 - UniversalFactory: https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-16-UniversalFactory.md The UniversalFactory will be deployed using Nick's Factory (0x4e59b44847b379578588920ca78fbf26c0b4956c) The deployed address can be found in the LSP16 specification. Please refer to the LSP16 Specification to obtain the exact bytecode and salt that should be used to produce the address of the UniversalFactory on different chains. This factory contract is designed to deploy contracts at the same address on multiple chains. The UniversalFactory can deploy 2 types of contracts: - non-initializable (normal deployment) - initializable (external call after deployment, e.g: proxy contracts) The `providedSalt` parameter given by the deployer is not used directly as the salt by the CREATE2 opcode. Instead, it is used along with these parameters: - `initializable` boolean - `initializeCalldata` (when the contract is initializable and `initializable` is set to `true`). These three parameters are concatenated together and hashed to generate the final salt for CREATE2. See {generateSalt} function for more details. The constructor and `initializeCalldata` SHOULD NOT include any network-specific parameters (e.g: chain-id, a local token contract address), otherwise the deployed contract will not be recreated at the same address across different networks, thus defeating the purpose of the UniversalFactory. One way to solve this problem is to set an EOA owner in the `initializeCalldata`/constructor that can later call functions that set these parameters as variables in the contract. The UniversalFactory must be deployed at the same address on different chains to successfully deploy contracts at the same address across different chains.",
|
|
3
3
|
"errors": {
|
|
4
|
-
"
|
|
4
|
+
"ContractInitializationFailed()": [
|
|
5
5
|
{
|
|
6
|
-
"details": "
|
|
6
|
+
"details": "Reverts when there is no revert reason bubbled up by the contract created when initializing"
|
|
7
7
|
}
|
|
8
8
|
],
|
|
9
|
-
"
|
|
9
|
+
"InvalidValueSum()": [
|
|
10
10
|
{
|
|
11
|
-
"details": "
|
|
11
|
+
"details": "Reverts when msg.value sent to {deployCreate2AndInitialize} function is not equal to the sum of the `initializeCalldataMsgValue` and `constructorMsgValue`"
|
|
12
12
|
}
|
|
13
13
|
]
|
|
14
14
|
},
|
|
15
15
|
"events": {
|
|
16
|
-
"ContractCreated(address,bytes32,bool,bytes)": {
|
|
16
|
+
"ContractCreated(address,bytes32,bytes32,bool,bytes)": {
|
|
17
17
|
"details": "Emitted whenever a contract is created",
|
|
18
18
|
"params": {
|
|
19
19
|
"contractCreated": "The address of the contract created",
|
|
20
|
-
"
|
|
21
|
-
"initializeCalldata": "The bytes provided as initializeCalldata",
|
|
22
|
-
"
|
|
20
|
+
"generatedSalt": "The salt used by the `CREATE2` opcode for contract deployment",
|
|
21
|
+
"initializeCalldata": "The bytes provided as initializeCalldata (Empty string when `initialized` is set to false)",
|
|
22
|
+
"initialized": "The Boolean that specifies if the contract must be initialized or not",
|
|
23
|
+
"providedSalt": "The salt provided by the deployer, which will be used to generate the final salt that will be used by the `CREATE2` opcode for contract deployment"
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
},
|
|
26
27
|
"kind": "dev",
|
|
27
28
|
"methods": {
|
|
28
|
-
"
|
|
29
|
-
"details": "
|
|
29
|
+
"computeAddress(bytes32,bytes32,bool,bytes)": {
|
|
30
|
+
"details": "Computes the address of a contract to be deployed using CREATE2, based on the input parameters. Any change in one of these parameters will result in a different address. When the `initializable` boolean is set to `false`, `initializeCalldata` will not affect the function output.",
|
|
31
|
+
"params": {
|
|
32
|
+
"byteCodeHash": "The keccak256 hash of the bytecode to be deployed",
|
|
33
|
+
"initializable": "A boolean that indicates whether an external call should be made to initialize the contract after deployment",
|
|
34
|
+
"initializeCalldata": "The calldata to be executed on the created contract if `initializable` is set to `true`",
|
|
35
|
+
"providedSalt": "The salt provided by the deployer, which will be used to generate the final salt that will be used by the `CREATE2` opcode for contract deployment"
|
|
36
|
+
},
|
|
37
|
+
"returns": {
|
|
38
|
+
"_0": "The address where the contract will be deployed"
|
|
39
|
+
}
|
|
30
40
|
},
|
|
31
|
-
"
|
|
32
|
-
"details": "
|
|
41
|
+
"computeERC1167Address(address,bytes32,bool,bytes)": {
|
|
42
|
+
"details": "Computes the address of an ERC1167 proxy contract based on the input parameters. Any change in one of these parameters will result in a different address. When the `initializable` boolean is set to `false`, `initializeCalldata` will not affect the function output.",
|
|
43
|
+
"params": {
|
|
44
|
+
"implementationContract": "The contract to create a clone of according to ERC1167",
|
|
45
|
+
"initializable": "A boolean that indicates whether an external call should be made to initialize the proxy contract after deployment",
|
|
46
|
+
"initializeCalldata": "The calldata to be executed on the created contract if `initializable` is set to `true`",
|
|
47
|
+
"providedSalt": "The salt provided by the deployer, which will be used to generate the final salt that will be used by the `CREATE2` opcode for contract deployment"
|
|
48
|
+
},
|
|
49
|
+
"returns": {
|
|
50
|
+
"_0": "The address where the ERC1167 proxy contract will be deployed"
|
|
51
|
+
}
|
|
33
52
|
},
|
|
34
53
|
"deployCreate2(bytes,bytes32)": {
|
|
35
|
-
"details": "Deploys a contract using
|
|
54
|
+
"details": "Deploys a contract using the CREATE2 opcode. The address where the contract will be deployed can be known in advance via the {computeAddress} function. This function deploys contracts without initialization (external call after deployment). The `providedSalt` parameter is not used directly as the salt by the CREATE2 opcode. Instead, it is hashed with keccak256: `keccak256(abi.encodePacked(false, providedSalt))`. See {generateSalt} function for more details. Using the same `byteCode` and `providedSalt` multiple times will revert, as the contract cannot be deployed twice at the same address. If the constructor of the contract to deploy is payable, value can be sent to this function to fund the created contract. However, sending value to this function while the constructor is not payable will result in a revert.",
|
|
55
|
+
"params": {
|
|
56
|
+
"byteCode": "The bytecode of the contract to be deployed",
|
|
57
|
+
"providedSalt": "The salt provided by the deployer, which will be used to generate the final salt that will be used by the `CREATE2` opcode for contract deployment"
|
|
58
|
+
},
|
|
59
|
+
"returns": {
|
|
60
|
+
"_0": "The address of the deployed contract"
|
|
61
|
+
}
|
|
36
62
|
},
|
|
37
|
-
"
|
|
38
|
-
"details": "Deploys a contract using
|
|
63
|
+
"deployCreate2AndInitialize(bytes,bytes32,bytes,uint256,uint256)": {
|
|
64
|
+
"details": "Deploys a contract using the CREATE2 opcode. The address where the contract will be deployed can be known in advance via the {computeAddress} function. This function deploys contracts with initialization (external call after deployment). The `providedSalt` parameter is not used directly as the salt by the CREATE2 opcode. Instead, it is hashed with keccak256: `keccak256(abi.encodePacked(true, initializeCalldata, providedSalt))`. See {generateSalt} function for more details. Using the same `byteCode`, `providedSalt` and `initializeCalldata` multiple times will revert, as the contract cannot be deployed twice at the same address. If the constructor or the initialize function of the contract to deploy is payable, value can be sent along with the deployment/initialization to fund the created contract. However, sending value to this function while the constructor/initialize function is not payable will result in a revert. Will revert if the `msg.value` sent to the function is not equal to the sum of `constructorMsgValue` and `initializeCalldataMsgValue`.",
|
|
65
|
+
"params": {
|
|
66
|
+
"byteCode": "The bytecode of the contract to be deployed",
|
|
67
|
+
"constructorMsgValue": "The value sent to the contract during deployment",
|
|
68
|
+
"initializeCalldata": "The calldata to be executed on the created contract",
|
|
69
|
+
"initializeCalldataMsgValue": "The value sent to the contract during initialization",
|
|
70
|
+
"providedSalt": "The salt provided by the deployer, which will be used to generate the final salt that will be used by the `CREATE2` opcode for contract deployment"
|
|
71
|
+
},
|
|
72
|
+
"returns": {
|
|
73
|
+
"_0": "The address of the deployed contract"
|
|
74
|
+
}
|
|
39
75
|
},
|
|
40
|
-
"
|
|
41
|
-
"details": "Deploys
|
|
76
|
+
"deployERC1167Proxy(address,bytes32)": {
|
|
77
|
+
"details": "Deploys an ERC1167 minimal proxy contract using the CREATE2 opcode. The address where the contract will be deployed can be known in advance via the {computeERC1167Address} function. This function deploys contracts without initialization (external call after deployment). The `providedSalt` parameter is not used directly as the salt by the CREATE2 opcode. Instead, it is hashed with keccak256: `keccak256(abi.encodePacked(false, providedSalt))`. See {generateSalt} function for more details. See {generateSalt} function for more details. Using the same `implementationContract` and `providedSalt` multiple times will revert, as the contract cannot be deployed twice at the same address. Sending value to the contract created is not possible since the constructor of the ERC1167 minimal proxy is not payable.",
|
|
78
|
+
"params": {
|
|
79
|
+
"implementationContract": "The contract address to use as the base implementation behind the proxy that will be deployed",
|
|
80
|
+
"providedSalt": "The salt provided by the deployer, which will be used to generate the final salt that will be used by the `CREATE2` opcode for contract deployment"
|
|
81
|
+
},
|
|
82
|
+
"returns": {
|
|
83
|
+
"_0": "The address of the minimal proxy deployed"
|
|
84
|
+
}
|
|
42
85
|
},
|
|
43
|
-
"
|
|
44
|
-
"details": "Deploys
|
|
86
|
+
"deployERC1167ProxyAndInitialize(address,bytes32,bytes)": {
|
|
87
|
+
"details": "Deploys an ERC1167 minimal proxy contract using the CREATE2 opcode. The address where the contract will be deployed can be known in advance via the {computeERC1167Address} function. This function deploys contracts with initialization (external call after deployment). The `providedSalt` parameter is not used directly as the salt by the CREATE2 opcode. Instead, it is hashed with keccak256: `keccak256(abi.encodePacked(true, initializeCalldata, providedSalt))`. See {generateSalt} function for more details. Using the same `implementationContract`, `providedSalt` and `initializeCalldata` multiple times will revert, as the contract cannot be deployed twice at the same address. If the initialize function of the contract to deploy is payable, value can be sent along to fund the created contract while initializing. However, sending value to this function while the initialize function is not payable will result in a revert.",
|
|
88
|
+
"params": {
|
|
89
|
+
"implementationContract": "The contract address to use as the base implementation behind the proxy that will be deployed",
|
|
90
|
+
"initializeCalldata": "The calldata to be executed on the created contract",
|
|
91
|
+
"providedSalt": "The salt provided by the deployer, which will be used to generate the final salt that will be used by the `CREATE2` opcode for contract deployment"
|
|
92
|
+
},
|
|
93
|
+
"returns": {
|
|
94
|
+
"_0": "The address of the minimal proxy deployed"
|
|
95
|
+
}
|
|
45
96
|
},
|
|
46
|
-
"generateSalt(bool,bytes
|
|
47
|
-
"details": "
|
|
97
|
+
"generateSalt(bytes32,bool,bytes)": {
|
|
98
|
+
"details": "Generates the salt used to deploy the contract by hashing the following parameters (concatenated together) with keccak256: - the `providedSalt` - the `initializable` boolean - the `initializeCalldata`, only if the contract is initializable (the `initializable` boolean is set to `true`) The `providedSalt` parameter is not used directly as the salt by the CREATE2 opcode. Instead, it is used along with these parameters: - `initializable` boolean - `initializeCalldata` (when the contract is initializable and `initializable` is set to `true`). These three parameters are concatenated together and hashed to generate the final salt for CREATE2. This approach ensures that in order to reproduce an initializable contract at the same address on another chain, not only the `providedSalt` is required to be the same, but also the initialize parameters within the `initializeCalldata` must also be the same. This maintains consistent deployment behaviour. Users are required to initialize contracts with the same parameters across different chains to ensure contracts are deployed at the same address across different chains. ----------- Example (for initializable contracts) For an existing contract A on chain 1 owned by X, to replicate the same contract at the same address with the same owner X on chain 2, the salt used to generate the address should include the initializeCalldata that assigns X as the owner of contract A. For instance, if another user, Y, tries to deploy the contract at the same address on chain 2 using the same providedSalt, but with a different initializeCalldata to make Y the owner instead of X, the generated address would be different, preventing Y from deploying the contract with different ownership at the same address. ----------- However, for non-initializable contracts, if the constructor has arguments that specify the deployment behavior, they will be included in the bytecode. Any change in the constructor arguments will lead to a different contract's bytecode which will result in a different address on other chains. ----------- Example (for non-initializable contracts) If a contract is deployed with specific constructor arguments on chain 1, these arguments are embedded within the bytecode. For instance, if contract B is deployed with a specific `tokenName` and `tokenSymbol` on chain 1, and a user wants to deploy the same contract with the same `tokenName` and `tokenSymbol` on chain 2, they must use the same constructor arguments to produce the same bytecode. This ensures that the same deployment behaviour is maintained across different chains, as long as the same bytecode is used. If another user Z, tries to deploy the same contract B at the same address on chain 2 using the same `providedSalt` but different constructor arguments (a different `tokenName` and/or `tokenSymbol`), the generated address will be different. This prevents user Z from deploying the contract with different constructor arguments at the same address on chain 2. ----------- The providedSalt was hashed to produce the salt used by CREATE2 opcode to prevent users from deploying initializable contracts using non-initializable functions such as {deployCreate2} without having the initialization call. In other words, if the providedSalt was not hashed and was used as it is as the salt by the CREATE2 opcode, malicious users can check the generated salt used for the already deployed initializable contract on chain 1, and deploy the contract from {deployCreate2} function on chain 2, with passing the generated salt of the deployed contract as providedSalt that will produce the same address but without the initialization, where the malicious user can initialize after.",
|
|
99
|
+
"params": {
|
|
100
|
+
"initializable": "The Boolean that specifies if the contract must be initialized or not",
|
|
101
|
+
"initializeCalldata": "The calldata to be executed on the created contract if `initializable` is set to `true`",
|
|
102
|
+
"providedSalt": "The salt provided by the deployer, which will be used to generate the final salt that will be used by the `CREATE2` opcode for contract deployment"
|
|
103
|
+
},
|
|
104
|
+
"returns": {
|
|
105
|
+
"_0": "The generated salt which will be used for CREATE2 deployment"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"stateVariables": {
|
|
110
|
+
"_EMPTY_BYTE": {
|
|
111
|
+
"details": "placeholder for the `initializeCallData` param when the `initializable` boolean is set to `false`."
|
|
48
112
|
}
|
|
49
113
|
},
|
|
114
|
+
"title": "LSP16 Universal Factory",
|
|
50
115
|
"version": 1
|
|
51
116
|
}
|
|
@@ -103,8 +103,9 @@
|
|
|
103
103
|
}
|
|
104
104
|
},
|
|
105
105
|
"constructor": {
|
|
106
|
+
"details": "Set `initialOwner` as the contract owner and set the `SupportedStandards:LSP3UniversalProfile` data key in the ERC725Y data key/value store. The `constructor` also allows funding the contract on deployment. Emitted Events: - ValueReceived: when the contract is funded on deployment.",
|
|
106
107
|
"params": {
|
|
107
|
-
"
|
|
108
|
+
"initialOwner": "the owner of the contract"
|
|
108
109
|
}
|
|
109
110
|
},
|
|
110
111
|
"execute(uint256,address,uint256,bytes)": {
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
}
|
|
104
104
|
},
|
|
105
105
|
"constructor": {
|
|
106
|
-
"details": "
|
|
106
|
+
"details": "Locks the base contract on deployment, so that it cannot be initialized, owned and controlled by anyone after it has been deployed. This is intended so that the sole purpose of this contract is to be used as a base contract behind a proxy."
|
|
107
107
|
},
|
|
108
108
|
"execute(uint256,address,uint256,bytes)": {
|
|
109
109
|
"details": "Executes any call on other addresses.",
|
|
@@ -140,8 +140,9 @@
|
|
|
140
140
|
}
|
|
141
141
|
},
|
|
142
142
|
"initialize(address)": {
|
|
143
|
+
"details": "Set `initialOwner` as the contract owner and set the `SupportedStandards:LSP3UniversalProfile` data key in the ERC725Y data key/value store. The `initialOwner` will then be allowed to call protected functions marked with the `onlyOwner` modifier. The `initialize(address)` function also allows funding the contract on initialization. Emitted Events: - ValueReceived: when the contract is funded on initialization.",
|
|
143
144
|
"params": {
|
|
144
|
-
"
|
|
145
|
+
"initialOwner": "the owner of the contract"
|
|
145
146
|
}
|
|
146
147
|
},
|
|
147
148
|
"isValidSignature(bytes32,bytes)": {
|