Skip to content

Commit 83d3c13

Browse files
committed
Merge branch 'master' into beacon
2 parents 0e2b0d4 + 9f2a3ce commit 83d3c13

34 files changed

+1198
-1186
lines changed

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ describe('CustomToken', () => {
4242
});
4343

4444
describeBehaviorOfERC20Base(
45+
async () => instance,
4546
{
46-
deploy: () => instance,
47-
},
48-
[],
47+
args: ...,
48+
}
4949
);
5050

5151
// custom tests...
@@ -56,8 +56,9 @@ If parts of the base implementation are changed intentionally, tests can be sele
5656

5757
```javascript
5858
describeBehaviorOfERC20Base(
59+
async () => instance,
5960
{
60-
deploy: () => instance,
61+
args: ...
6162
},
6263
['#balanceOf'],
6364
);

abi/CloneFactory.json

-7
This file was deleted.

abi/MetamorphicFactory.json

-20
This file was deleted.

abi/MinimalProxyFactory.json

-7
This file was deleted.

abi/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@solidstate/abi",
3-
"version": "0.0.58",
3+
"version": "0.0.59",
44
"author": "Nick Barry",
55
"license": "MIT",
66
"description": "ABIs for SolidState contracts",

contracts/factory/CloneFactory.sol

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ import { Factory } from './Factory.sol';
88
* @title Factory for contract self-replication
99
* @dev derived from https://github.com/ItsNickBarry/solidity-auto-deployer (MIT license)
1010
*/
11-
abstract contract CloneFactory is Factory {
11+
library CloneFactory {
1212
bytes private constant CLONE_INIT_CODE = hex'58333b90818180333cf3';
1313
bytes32 private constant CLONE_INIT_CODE_HASH = keccak256(CLONE_INIT_CODE);
1414

1515
/**
1616
* @notice deploy a clone of the calling contract using "CREATE" opcode
1717
* @return cloneContract address of deployed contract
1818
*/
19-
function _deployClone() internal returns (address cloneContract) {
20-
return _deploy(CLONE_INIT_CODE);
19+
function deployClone() internal returns (address cloneContract) {
20+
return Factory.deploy(CLONE_INIT_CODE);
2121
}
2222

2323
/**
@@ -26,20 +26,20 @@ abstract contract CloneFactory is Factory {
2626
* @param salt input for deterministic address calculation
2727
* @return cloneContract address of deployed contract
2828
*/
29-
function _deployClone(
29+
function deployClone(
3030
bytes32 salt
3131
) internal returns (address cloneContract) {
32-
return _deploy(CLONE_INIT_CODE, salt);
32+
return Factory.deploy(CLONE_INIT_CODE, salt);
3333
}
3434

3535
/**
3636
* @notice calculate the deployment address for a given salt
3737
* @param salt input for deterministic address calculation
3838
* @return deployment address
3939
*/
40-
function _calculateCloneDeploymentAddress(
40+
function calculateCloneDeploymentAddress(
4141
bytes32 salt
4242
) internal view returns (address) {
43-
return _calculateDeploymentAddress(CLONE_INIT_CODE_HASH, salt);
43+
return Factory.calculateDeploymentAddress(CLONE_INIT_CODE_HASH, salt);
4444
}
4545
}

contracts/factory/CloneFactoryMock.sol

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ pragma solidity ^0.8.18;
44

55
import { CloneFactory } from './CloneFactory.sol';
66

7-
contract CloneFactoryMock is CloneFactory {
8-
function __deployClone() external returns (address cloneContract) {
9-
return _deployClone();
7+
contract CloneFactoryMock {
8+
function deployClone() external returns (address cloneContract) {
9+
return CloneFactory.deployClone();
1010
}
1111

12-
function __deployClone(
12+
function deployClone(
1313
bytes32 salt
1414
) external returns (address cloneContract) {
15-
return _deployClone(salt);
15+
return CloneFactory.deployClone(salt);
1616
}
1717

18-
function __calculateCloneDeploymentAddress(
18+
function calculateCloneDeploymentAddress(
1919
bytes32 salt
2020
) external view returns (address) {
21-
return _calculateCloneDeploymentAddress(salt);
21+
return CloneFactory.calculateCloneDeploymentAddress(salt);
2222
}
2323
}

contracts/factory/Factory.sol

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ pragma solidity ^0.8.18;
55
/**
66
* @title Factory for arbitrary code deployment using the "CREATE" and "CREATE2" opcodes
77
*/
8-
abstract contract Factory {
8+
library Factory {
99
error Factory__FailedDeployment();
1010

1111
/**
1212
* @notice deploy contract code using "CREATE" opcode
1313
* @param initCode contract initialization code
1414
* @return deployment address of deployed contract
1515
*/
16-
function _deploy(
16+
function deploy(
1717
bytes memory initCode
1818
) internal returns (address deployment) {
1919
assembly {
@@ -32,7 +32,7 @@ abstract contract Factory {
3232
* @param salt input for deterministic address calculation
3333
* @return deployment address of deployed contract
3434
*/
35-
function _deploy(
35+
function deploy(
3636
bytes memory initCode,
3737
bytes32 salt
3838
) internal returns (address deployment) {
@@ -51,7 +51,7 @@ abstract contract Factory {
5151
* @param salt input for deterministic address calculation
5252
* @return deployment address
5353
*/
54-
function _calculateDeploymentAddress(
54+
function calculateDeploymentAddress(
5555
bytes32 initCodeHash,
5656
bytes32 salt
5757
) internal view returns (address) {

contracts/factory/FactoryMock.sol

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@ pragma solidity ^0.8.18;
44

55
import { Factory } from './Factory.sol';
66

7-
contract FactoryMock is Factory {
8-
function __deploy(
7+
contract FactoryMock {
8+
function deploy(
99
bytes memory initCode
1010
) external returns (address deployment) {
11-
return _deploy(initCode);
11+
return Factory.deploy(initCode);
1212
}
1313

14-
function __deploy(
14+
function deploy(
1515
bytes memory initCode,
1616
bytes32 salt
1717
) external returns (address deployment) {
18-
return _deploy(initCode, salt);
18+
return Factory.deploy(initCode, salt);
1919
}
2020

21-
function __calculateDeploymentAddress(
21+
function calculateDeploymentAddress(
2222
bytes32 initCodeHash,
2323
bytes32 salt
2424
) external view returns (address) {
25-
return _calculateDeploymentAddress(initCodeHash, salt);
25+
return Factory.calculateDeploymentAddress(initCodeHash, salt);
2626
}
2727
}

contracts/factory/MetamorphicFactory.sol

-64
This file was deleted.

contracts/factory/MetamorphicFactoryMock.sol

-20
This file was deleted.

contracts/factory/MetamorphicFactoryStorage.sol

-19
This file was deleted.

contracts/factory/MinimalProxyFactory.sol

+9-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Factory } from './Factory.sol';
88
* @title Factory for the deployment of EIP1167 minimal proxies
99
* @dev derived from https://github.com/optionality/clone-factory (MIT license)
1010
*/
11-
abstract contract MinimalProxyFactory is Factory {
11+
library MinimalProxyFactory {
1212
bytes private constant MINIMAL_PROXY_INIT_CODE_PREFIX =
1313
hex'3d602d80600a3d3981f3_363d3d373d3d3d363d73';
1414
bytes private constant MINIMAL_PROXY_INIT_CODE_SUFFIX =
@@ -19,10 +19,10 @@ abstract contract MinimalProxyFactory is Factory {
1919
* @param target implementation contract to proxy
2020
* @return minimalProxy address of deployed proxy
2121
*/
22-
function _deployMinimalProxy(
22+
function deployMinimalProxy(
2323
address target
2424
) internal returns (address minimalProxy) {
25-
return _deploy(_generateMinimalProxyInitCode(target));
25+
return Factory.deploy(generateMinimalProxyInitCode(target));
2626
}
2727

2828
/**
@@ -32,11 +32,11 @@ abstract contract MinimalProxyFactory is Factory {
3232
* @param salt input for deterministic address calculation
3333
* @return minimalProxy address of deployed proxy
3434
*/
35-
function _deployMinimalProxy(
35+
function deployMinimalProxy(
3636
address target,
3737
bytes32 salt
3838
) internal returns (address minimalProxy) {
39-
return _deploy(_generateMinimalProxyInitCode(target), salt);
39+
return Factory.deploy(generateMinimalProxyInitCode(target), salt);
4040
}
4141

4242
/**
@@ -45,13 +45,13 @@ abstract contract MinimalProxyFactory is Factory {
4545
* @param salt input for deterministic address calculation
4646
* @return deployment address
4747
*/
48-
function _calculateMinimalProxyDeploymentAddress(
48+
function calculateMinimalProxyDeploymentAddress(
4949
address target,
5050
bytes32 salt
5151
) internal view returns (address) {
5252
return
53-
_calculateDeploymentAddress(
54-
keccak256(_generateMinimalProxyInitCode(target)),
53+
Factory.calculateDeploymentAddress(
54+
keccak256(generateMinimalProxyInitCode(target)),
5555
salt
5656
);
5757
}
@@ -61,7 +61,7 @@ abstract contract MinimalProxyFactory is Factory {
6161
* @param target implementation contract to proxy
6262
* @return bytes memory initialization code
6363
*/
64-
function _generateMinimalProxyInitCode(
64+
function generateMinimalProxyInitCode(
6565
address target
6666
) internal pure returns (bytes memory) {
6767
return

0 commit comments

Comments
 (0)