Skip to content

Commit

Permalink
Salt is a hash of input params
Browse files Browse the repository at this point in the history
  • Loading branch information
ScreamingHawk authored and acrylix committed Nov 9, 2023
1 parent bbbc213 commit ea1b8c6
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ contract ERC1155TokenMinterFactory is IERC1155TokenMinterFactory, SequenceProxyF
* @param baseURI The base URI of the ERC-1155 Token Minter proxy
* @param royaltyReceiver Address of who should be sent the royalty payment
* @param royaltyFeeNumerator The royalty fee numerator in basis points (e.g. 15% would be 1500)
* @param salt The deployment salt
* @return proxyAddr The address of the ERC-1155 Token Minter Proxy
* @dev The provided `salt` is hashed with the caller address for security.
* @dev As `proxyOwner` owns the proxy, it will be unable to call the ERC-1155 Token Minter functions.
*/
function deploy(
Expand All @@ -38,12 +36,12 @@ contract ERC1155TokenMinterFactory is IERC1155TokenMinterFactory, SequenceProxyF
string memory name,
string memory baseURI,
address royaltyReceiver,
uint96 royaltyFeeNumerator,
bytes32 salt
uint96 royaltyFeeNumerator
)
external
returns (address proxyAddr)
{
bytes32 salt = keccak256(abi.encodePacked(tokenOwner, name, baseURI, royaltyReceiver, royaltyFeeNumerator));
proxyAddr = _createProxy(salt, proxyOwner, "");
ERC1155TokenMinter(proxyAddr).initialize(tokenOwner, name, baseURI, royaltyReceiver, royaltyFeeNumerator);
emit ERC1155TokenMinterDeployed(proxyAddr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ interface IERC1155TokenMinterFactoryFunctions {
* @param baseURI The base URI of the ERC-1155 Token Minter proxy
* @param royaltyReceiver Address of who should be sent the royalty payment
* @param royaltyFeeNumerator The royalty fee numerator in basis points (e.g. 15% would be 1500)
* @param salt The deployment salt
* @return proxyAddr The address of the ERC-1155 Token Minter Proxy
* @dev The provided `salt` is hashed with the caller address for security.
* @dev As `proxyOwner` owns the proxy, it will be unable to call the ERC-1155 Token Minter functions.
*/
function deploy(
Expand All @@ -21,8 +19,7 @@ interface IERC1155TokenMinterFactoryFunctions {
string memory name,
string memory baseURI,
address royaltyReceiver,
uint96 royaltyFeeNumerator,
bytes32 salt
uint96 royaltyFeeNumerator
)
external
returns (address proxyAddr);
Expand Down
5 changes: 2 additions & 3 deletions src/tokens/ERC1155/presets/sale/ERC1155SaleFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ contract ERC1155SaleFactory is IERC1155SaleFactory, SequenceProxyFactory {
* @param baseURI The base URI of the ERC-1155 Sale token
* @param royaltyReceiver Address of who should be sent the royalty payment
* @param royaltyFeeNumerator The royalty fee numerator in basis points (e.g. 15% would be 1500)
* @param salt The deployment salt
* @return proxyAddr The address of the ERC-1155 Sale Proxy
* @dev As `proxyOwner` owns the proxy, it will be unable to call the ERC-1155 Sale Minter functions.
*/
Expand All @@ -36,12 +35,12 @@ contract ERC1155SaleFactory is IERC1155SaleFactory, SequenceProxyFactory {
string memory name,
string memory baseURI,
address royaltyReceiver,
uint96 royaltyFeeNumerator,
bytes32 salt
uint96 royaltyFeeNumerator
)
external
returns (address proxyAddr)
{
bytes32 salt = keccak256(abi.encodePacked(tokenOwner, name, baseURI, royaltyReceiver, royaltyFeeNumerator));
proxyAddr = _createProxy(salt, proxyOwner, "");
ERC1155Sale(proxyAddr).initialize(tokenOwner, name, baseURI, royaltyReceiver, royaltyFeeNumerator);
emit ERC1155SaleDeployed(proxyAddr);
Expand Down
4 changes: 1 addition & 3 deletions src/tokens/ERC1155/presets/sale/IERC1155SaleFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ interface IERC1155SaleFactoryFunctions {
* @param baseURI The base URI of the ERC-1155 Sale token
* @param royaltyReceiver Address of who should be sent the royalty payment
* @param royaltyFeeNumerator The royalty fee numerator in basis points (e.g. 15% would be 1500)
* @param salt The deployment salt
* @return proxyAddr The address of the ERC-1155 Sale Proxy
* @dev As `proxyOwner` owns the proxy, it will be unable to call the ERC-1155 Token Sale functions.
*/
Expand All @@ -20,8 +19,7 @@ interface IERC1155SaleFactoryFunctions {
string memory name,
string memory baseURI,
address royaltyReceiver,
uint96 royaltyFeeNumerator,
bytes32 salt
uint96 royaltyFeeNumerator
)
external
returns (address proxyAddr);
Expand Down
12 changes: 2 additions & 10 deletions src/tokens/ERC20/presets/minter/ERC20TokenMinterFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,14 @@ contract ERC20TokenMinterFactory is IERC20TokenMinterFactory, SequenceProxyFacto
* @param name The name of the ERC-20 Token Minter proxy
* @param symbol The symbol of the ERC-20 Token Minter proxy
* @param decimals The decimals of the ERC-20 Token Minter proxy
* @param salt The deployment salt
* @return proxyAddr The address of the ERC-20 Token Minter Proxy
* @dev The provided `salt` is hashed with the caller address for security.
* @dev As `proxyOwner` owns the proxy, it will be unable to call the ERC-20 Token Minter functions.
*/
function deploy(
address proxyOwner,
address tokenOwner,
string memory name,
string memory symbol,
uint8 decimals,
bytes32 salt
)
function deploy(address proxyOwner, address tokenOwner, string memory name, string memory symbol, uint8 decimals)
external
returns (address proxyAddr)
{
bytes32 salt = keccak256(abi.encodePacked(tokenOwner, name, symbol, decimals));
proxyAddr = _createProxy(salt, proxyOwner, "");
ERC20TokenMinter(proxyAddr).initialize(tokenOwner, name, symbol, decimals);
emit ERC20TokenMinterDeployed(proxyAddr);
Expand Down
11 changes: 1 addition & 10 deletions src/tokens/ERC20/presets/minter/IERC20TokenMinterFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,10 @@ interface IERC20TokenMinterFactoryFunctions {
* @param name The name of the ERC-20 Token Minter proxy
* @param symbol The symbol of the ERC-20 Token Minter proxy
* @param decimals The decimals of the ERC-20 Token Minter proxy
* @param salt The deployment salt
* @return proxyAddr The address of the ERC-20 Token Minter Proxy
* @dev The provided `salt` is hashed with the caller address for security.
* @dev As `proxyOwner` owns the proxy, it will be unable to call the ERC-20 Token Minter functions.
*/
function deploy(
address proxyOwner,
address tokenOwner,
string memory name,
string memory symbol,
uint8 decimals,
bytes32 salt
)
function deploy(address proxyOwner, address tokenOwner, string memory name, string memory symbol, uint8 decimals)
external
returns (address proxyAddr);
}
Expand Down
8 changes: 3 additions & 5 deletions src/tokens/ERC721/presets/minter/ERC721TokenMinterFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {SequenceProxyFactory} from "@0xsequence/contracts-library/proxies/Sequen
* Deployer of ERC-721 Token Minter proxies.
*/
contract ERC721TokenMinterFactory is IERC721TokenMinterFactory, SequenceProxyFactory {

/**
* Creates an ERC-721 Token Minter Factory.
* @param factoryOwner The owner of the ERC-721 Token Minter Factory
Expand All @@ -29,9 +28,7 @@ contract ERC721TokenMinterFactory is IERC721TokenMinterFactory, SequenceProxyFac
* @param baseURI The base URI of the ERC-721 Token Minter proxy
* @param royaltyReceiver Address of who should be sent the royalty payment
* @param royaltyFeeNumerator The royalty fee numerator in basis points (e.g. 15% would be 1500)
* @param salt The deployment salt
* @return proxyAddr The address of the ERC-721 Token Minter Proxy
* @dev The provided `salt` is hashed with the caller address for security.
* @dev As `proxyOwner` owns the proxy, it will be unable to call the ERC-721 Token Minter functions.
*/
function deploy(
Expand All @@ -41,12 +38,13 @@ contract ERC721TokenMinterFactory is IERC721TokenMinterFactory, SequenceProxyFac
string memory symbol,
string memory baseURI,
address royaltyReceiver,
uint96 royaltyFeeNumerator,
bytes32 salt
uint96 royaltyFeeNumerator
)
external
returns (address proxyAddr)
{
bytes32 salt =
keccak256(abi.encodePacked(tokenOwner, name, symbol, baseURI, royaltyReceiver, royaltyFeeNumerator));
proxyAddr = _createProxy(salt, proxyOwner, "");
ERC721TokenMinter(proxyAddr).initialize(tokenOwner, name, symbol, baseURI, royaltyReceiver, royaltyFeeNumerator);
emit ERC721TokenMinterDeployed(proxyAddr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity ^0.8.17;

interface IERC721TokenMinterFactoryFunctions {

/**
* Creates an ERC-721 Token Minter proxy.
* @param proxyOwner The owner of the ERC-721 Token Minter proxy
Expand All @@ -12,9 +11,7 @@ interface IERC721TokenMinterFactoryFunctions {
* @param baseURI The base URI of the ERC-721 Token Minter proxy
* @param royaltyReceiver Address of who should be sent the royalty payment
* @param royaltyFeeNumerator The royalty fee numerator in basis points (e.g. 15% would be 1500)
* @param salt The deployment salt
* @return proxyAddr The address of the ERC-721 Token Minter Proxy
* @dev The provided `salt` is hashed with the caller address for security.
* @dev As `proxyOwner` owns the proxy, it will be unable to call the ERC-721 Token Minter functions.
*/
function deploy(
Expand All @@ -24,8 +21,7 @@ interface IERC721TokenMinterFactoryFunctions {
string memory symbol,
string memory baseURI,
address royaltyReceiver,
uint96 royaltyFeeNumerator,
bytes32 salt
uint96 royaltyFeeNumerator
)
external
returns (address proxyAddr);
Expand Down
7 changes: 3 additions & 4 deletions src/tokens/ERC721/presets/sale/ERC721SaleFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {SequenceProxyFactory} from "@0xsequence/contracts-library/proxies/Sequen
* Deployer of ERC-721 Sale proxies.
*/
contract ERC721SaleFactory is IERC721SaleFactory, SequenceProxyFactory {

/**
* Creates an ERC-721 Sale Factory.
* @param factoryOwner The owner of the ERC-721 Sale Factory
Expand All @@ -28,7 +27,6 @@ contract ERC721SaleFactory is IERC721SaleFactory, SequenceProxyFactory {
* @param baseURI The base URI of the ERC-721 Sale token
* @param royaltyReceiver Address of who should be sent the royalty payment
* @param royaltyFeeNumerator The royalty fee numerator in basis points (e.g. 15% would be 1500)
* @param salt The deployment salt
* @return proxyAddr The address of the ERC-721 Sale Proxy
* @dev As `proxyOwner` owns the proxy, it will be unable to call the ERC-721 Sale functions.
*/
Expand All @@ -39,12 +37,13 @@ contract ERC721SaleFactory is IERC721SaleFactory, SequenceProxyFactory {
string memory symbol,
string memory baseURI,
address royaltyReceiver,
uint96 royaltyFeeNumerator,
bytes32 salt
uint96 royaltyFeeNumerator
)
external
returns (address proxyAddr)
{
bytes32 salt =
keccak256(abi.encodePacked(tokenOwner, name, symbol, baseURI, royaltyReceiver, royaltyFeeNumerator));
proxyAddr = _createProxy(salt, proxyOwner, "");
ERC721Sale(proxyAddr).initialize(tokenOwner, name, symbol, baseURI, royaltyReceiver, royaltyFeeNumerator);
emit ERC721SaleDeployed(proxyAddr);
Expand Down
6 changes: 1 addition & 5 deletions src/tokens/ERC721/presets/sale/IERC721SaleFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity ^0.8.17;

interface IERC721SaleFactoryFunctions {

/**
* Creates an ERC-721 Sale for given token contract
* @param proxyOwner The owner of the ERC-721 Sale proxy
Expand All @@ -12,7 +11,6 @@ interface IERC721SaleFactoryFunctions {
* @param baseURI The base URI of the ERC-721 Sale token
* @param royaltyReceiver Address of who should be sent the royalty payment
* @param royaltyFeeNumerator The royalty fee numerator in basis points (e.g. 15% would be 1500)
* @param salt The deployment salt
* @return proxyAddr The address of the ERC-721 Sale Proxy
* @dev As `proxyOwner` owns the proxy, it will be unable to call the ERC-721 Sale functions.
*/
Expand All @@ -23,15 +21,13 @@ interface IERC721SaleFactoryFunctions {
string memory symbol,
string memory baseURI,
address royaltyReceiver,
uint96 royaltyFeeNumerator,
bytes32 salt
uint96 royaltyFeeNumerator
)
external
returns (address proxyAddr);
}

interface IERC721SaleFactorySignals {

/**
* Event emitted when a new ERC-721 Sale proxy contract is deployed.
* @param proxyAddr The address of the deployed proxy.
Expand Down
2 changes: 1 addition & 1 deletion test/tokens/ERC1155/presets/ERC1155Sale.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ contract ERC1155SaleTest is Test, Merkle, IERC1155SaleSignals, IERC1155SupplySig

function setUpFromFactory() public {
ERC1155SaleFactory factory = new ERC1155SaleFactory(address(this));
token = ERC1155Sale(factory.deploy(proxyOwner, address(this), "test", "ipfs://", address(this), 0, ""));
token = ERC1155Sale(factory.deploy(proxyOwner, address(this), "test", "ipfs://", address(this), 0));
}

function testSupportsInterface() public {
Expand Down
2 changes: 1 addition & 1 deletion test/tokens/ERC1155/presets/ERC1155TokenMinter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ contract ERC1155TokenMinterTest is Test, IERC1155TokenMinterSignals {
vm.deal(owner, 100 ether);

ERC1155TokenMinterFactory factory = new ERC1155TokenMinterFactory(address(this));
token = ERC1155TokenMinter(factory.deploy(proxyOwner, owner, "name", "baseURI", address(this), 0, 0x0));
token = ERC1155TokenMinter(factory.deploy(proxyOwner, owner, "name", "baseURI", address(this), 0));
}

function testReinitializeFails() public {
Expand Down
2 changes: 1 addition & 1 deletion test/tokens/ERC20/ERC20TokenMinter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ contract ERC20TokenMinterTest is Test, IERC20TokenMinterSignals {
vm.deal(owner, 100 ether);

ERC20TokenMinterFactory factory = new ERC20TokenMinterFactory(address(this));
token = ERC20TokenMinter(factory.deploy(proxyOwner, owner, "name", "symbol", DECIMALS, 0x0));
token = ERC20TokenMinter(factory.deploy(proxyOwner, owner, "name", "symbol", DECIMALS));
}

function testReinitializeFails() public {
Expand Down
2 changes: 1 addition & 1 deletion test/tokens/ERC721/presets/ERC721Sale.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ contract ERC721SaleTest is Test, Merkle, IERC721SaleSignals, IMerkleProofSingleU

function setUpFromFactory() public {
ERC721SaleFactory factory = new ERC721SaleFactory(address(this));
token = ERC721Sale(factory.deploy(proxyOwner, address(this), "test", "test", "ipfs://", address(this), 0, ""));
token = ERC721Sale(factory.deploy(proxyOwner, address(this), "test", "test", "ipfs://", address(this), 0));
}

function testSupportsInterface() public {
Expand Down
2 changes: 1 addition & 1 deletion test/tokens/ERC721/presets/ERC721TokenMinter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ contract ERC721TokenMinterTest is Test, IERC721TokenMinterSignals {
vm.deal(owner, 100 ether);

ERC721TokenMinterFactory factory = new ERC721TokenMinterFactory(address(this));
token = ERC721TokenMinter(factory.deploy(proxyOwner, owner, "name", "symbol", "baseURI", address(this), 0, 0x0));
token = ERC721TokenMinter(factory.deploy(proxyOwner, owner, "name", "symbol", "baseURI", address(this), 0));
}

function testReinitializeFails() public {
Expand Down

0 comments on commit ea1b8c6

Please sign in to comment.