@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.
@@ -1,51 +1,116 @@
1
1
  {
2
- "details": "UniversalFactory contract can be used to deploy normal or minimal proxy contracts (EIP-1167) using CREATE2. This gives the ability to deploy the same contract at the same address on different chains. If the contract has a constructor, the arguments will be part of the bytecode If the contract has an `initialize` function, the parameters of this function will be included in the salt to ensure that the parameters of the contract should be the same on each chain. When initializeCallData or the constructor includes non-crosschain parameters, the deployed contract will not be recreated at the same address on another network, thus defeating the purpose of LSP16UniversalFactory. Therefore, the initializeCallData and the constructor must not include any network-specific parameters, such as a local non-crosschain token contract address, chain-id, etc .. 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. This contract should be deployed using Nick's Method. More information: https://weka.medium.com/how-to-send-ether-to-11-440-people-187e332566b7",
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
- "CannotInitializeContract()": [
4
+ "ContractInitializationFailed()": [
5
5
  {
6
- "details": "reverts with this error when there is no revert reason bubbled up by the target contract when initializing"
6
+ "details": "Reverts when there is no revert reason bubbled up by the contract created when initializing"
7
7
  }
8
8
  ],
9
- "InvalidMsgValueDistribution()": [
9
+ "InvalidValueSum()": [
10
10
  {
11
- "details": "reverts when msg.value sent to {deployCreate2Init} function is not equal to the sum of the `initializeCalldataMsgValue` and `constructorMsgValue`"
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
- "initializable": "The Boolean that specifies if the contract is a initializable or not",
21
- "initializeCalldata": "The bytes provided as initializeCalldata",
22
- "providedSalt": "The bytes32 salt provided by the deployer"
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
- "calculateAddress(bytes32,bytes32,bool,bytes)": {
29
- "details": "Returns the address where a contract will be stored if deployed via `CREATE2`. The address is constructed using the parameters below. Any change in one of them will result in a new destination address."
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
- "calculateProxyAddress(address,bytes32,bool,bytes)": {
32
- "details": "Returns the address of an EIP1167 proxy contract. The address is constructed using the parameters below. Any change in one of them will result in a new destination address."
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 `CREATE2`. The address where the contract will be deployed can be known in advance via {calculateAddress}. The salt is a hash of the `providedSalt` together with an empty byte, to prevent mimicing the `deployCreate2Init()` and other functions. This method allow users to have the same contracts at the same address across different chains with the same parameters. Using the same `byteCode` and salt multiple time will revert, since the contract cannot be deployed twice at the same address."
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
- "deployCreate2Init(bytes,bytes32,bytes,uint256,uint256)": {
38
- "details": "Deploys a contract using `CREATE2`. The address where the contract will be deployed can be known in advance via {calculateAddress}. The salt is a hash of the `providedSalt` and and the `initializeCallData`. This method allow users to have the same contracts at the same address across different chains with the same parameters. The msg.value is split according to the parameters of the function The msg.value sent to this contract MUST be the sum of the two parameters: `constructorMsgValue` and `initializeCalldataMsgValue` Using the same `byteCode` and salt multiple time will revert, since the contract cannot be deployed twice at the same address."
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
- "deployCreate2Proxy(address,bytes32)": {
41
- "details": "Deploys and returns the address of a clone that mimics the behaviour of `baseContract`. The address where the contract will be deployed can be known in advance via {calculateProxyAddress}. This function uses the CREATE2 opcode and a salt to deterministically deploy the clone. The salt is a hash of the `providedSalt` toegther with an empty byte, to prevent mimicing the `deployCreate2ProxyInit()` and other functions. This method allow users to have the same contracts at the same address across different chains with the same parameters. Using the same `baseContract` and salt multiple time will revert, since the clones cannot be deployed twice at the same address."
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
- "deployCreate2ProxyInit(address,bytes32,bytes)": {
44
- "details": "Deploys and returns the address of a clone that mimics the behaviour of `baseContract`. The address where the contract will be deployed can be known in advance via {calculateProxyAddress}. This function uses the CREATE2 opcode and a salt to deterministically deploy the clone. The salt is a hash of the `providedSalt` and and the `initializeCallData`. This method allow users to have the same contracts at the same address across different chains with the same parameters. Using the same `baseContract` and salt multiple time will revert, since the clones cannot be deployed twice at the same address."
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,bytes32)": {
47
- "details": "Calculates the salt used to deploy the contract by hashing (Keccak256) the following parameters as packed encoded respectively: an initializable boolean, the initializeCallData if and only if the contract is initializable, and the salt provided by the deployer. The initializable boolean was added before the provided arguments as if it was not used, and we are deploying proxies on another chain, people can use the `deployCreate2(..)` function to deploy the same bytecode + the same salt to get the same address of the contract on another chain without applying the effect of initializing."
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
- "newOwner": "the owner of the contract"
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": "initialize (= lock) base implementation contract on deployment"
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
- "newOwner": "the owner of the contract"
145
+ "initialOwner": "the owner of the contract"
145
146
  }
146
147
  },
147
148
  "isValidSignature(bytes32,bytes)": {