Skip to content

Commit 3d914b7

Browse files
authored
Initialize extensions in onInstall (#114)
* Initialize extensions in onInstall * Remove caller/sender args since delegateCall is used everywhere * Initialize primary sale recipient as msg.sender without decoding data
1 parent e400553 commit 3d914b7

37 files changed

+220
-148
lines changed

src/ModularCore.sol

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ abstract contract ModularCore is IModularCore, OwnableRoles {
3636
//////////////////////////////////////////////////////////////*/
3737

3838
/// @notice Emitted when an extension is installed.
39-
event ExtensionInstalled(address sender, address implementation, address installedExtension);
39+
event ExtensionInstalled(address caller, address implementation, address installedExtension);
4040

4141
/// @notice Emitted when an extension is uninstalled.
42-
event ExtensionUninstalled(address sender, address implementation, address installedExtension);
42+
event ExtensionUninstalled(address caller, address implementation, address installedExtension);
4343

4444
/*//////////////////////////////////////////////////////////////
4545
STORAGE
@@ -233,7 +233,7 @@ abstract contract ModularCore is IModularCore, OwnableRoles {
233233
// Call `onInstall` callback function if extension has registered installation callback.
234234
if (config.registerInstallationCallback) {
235235
(bool success, bytes memory returndata) =
236-
_extension.call{value: msg.value}(abi.encodeCall(IInstallationCallback.onInstall, (msg.sender, _data)));
236+
_extension.delegatecall(abi.encodeCall(IInstallationCallback.onInstall, (_data)));
237237
if (!success) {
238238
_revert(returndata, CallbackExecutionReverted.selector);
239239
}
@@ -271,9 +271,8 @@ abstract contract ModularCore is IModularCore, OwnableRoles {
271271
}
272272

273273
if (config.registerInstallationCallback) {
274-
(bool success, bytes memory returndata) = _extension.call{value: msg.value}(
275-
abi.encodeCall(IInstallationCallback.onUninstall, (msg.sender, _data))
276-
);
274+
(bool success, bytes memory returndata) =
275+
_extension.delegatecall(abi.encodeCall(IInstallationCallback.onUninstall, (_data)));
277276
if (!success) {
278277
_revert(returndata, CallbackExecutionReverted.selector);
279278
}

src/callback/BeforeApproveCallbackERC20.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ contract BeforeApproveCallbackERC20 {
1414

1515
/**
1616
* @notice The beforeApproveERC20 hook that is called by a core token before approving tokens.
17-
* @param _caller The address of the caller.
17+
*
1818
* @param _from The address that is approving tokens.
1919
* @param _to The address that is being approved.
2020
* @param _amount The amount of tokens being approved.
2121
* @return result Abi encoded bytes result of the hook.
2222
*/
23-
function beforeApproveERC20(address _caller, address _from, address _to, uint256 _amount)
23+
function beforeApproveERC20(address _from, address _to, uint256 _amount)
2424
external
2525
virtual
2626
returns (bytes memory result)

src/callback/BeforeApproveCallbackERC721.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ contract BeforeApproveCallbackERC721 {
1414

1515
/**
1616
* @notice The beforeApproveERC721 hook that is called by a core token before approving a token.
17-
* @param _caller The address of the caller.
17+
*
1818
* @param _from The address that is approving tokens.
1919
* @param _to The address that is being approved.
2020
* @param _tokenId The token ID being approved.
2121
* @param _approve The approval status to set.
2222
* @return result Abi encoded bytes result of the hook.
2323
*/
24-
function beforeApproveERC721(address _caller, address _from, address _to, uint256 _tokenId, bool _approve)
24+
function beforeApproveERC721(address _from, address _to, uint256 _tokenId, bool _approve)
2525
external
2626
virtual
2727
returns (bytes memory result)

src/callback/BeforeApproveForAllCallback.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ contract BeforeApproveForAllCallback {
1414

1515
/**
1616
* @notice The beforeApproveForAll hook that is called by a core token before approving an operator to transfer all tokens.
17-
* @param _caller The address of the caller.
17+
*
1818
* @param _from The address that is approving tokens.
1919
* @param _to The address that is being approved.
2020
* @param _approved Whether to grant or revoke approval.
2121
*/
22-
function beforeApproveForAll(address _caller, address _from, address _to, bool _approved)
22+
function beforeApproveForAll(address _from, address _to, bool _approved)
2323
external
2424
virtual
2525
returns (bytes memory result)

src/callback/BeforeBatchTransferCallbackERC1155.sol

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,18 @@ contract BeforeBatchTransferCallbackERC1155 {
1414

1515
/**
1616
* @notice The beforeBatchTransferERC1155 hook that is called by a core token before batch transferring tokens.
17-
* @param _caller The address of the caller.
17+
*
1818
* @param from The address that is transferring tokens.
1919
* @param to The address that is receiving tokens.
2020
* @param ids The token IDs being transferred.
2121
* @param values The quantities of tokens being transferred.
2222
* @return result Abi encoded bytes result of the hook.
2323
*/
24-
function beforeBatchTransferERC1155(
25-
address _caller,
26-
address from,
27-
address to,
28-
uint256[] calldata ids,
29-
uint256[] calldata values
30-
) external virtual returns (bytes memory result) {
24+
function beforeBatchTransferERC1155(address from, address to, uint256[] calldata ids, uint256[] calldata values)
25+
external
26+
virtual
27+
returns (bytes memory result)
28+
{
3129
revert BeforeBatchTransferCallbackERC1155NotImplemented();
3230
}
3331
}

src/callback/BeforeBurnCallbackERC1155.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ contract BeforeBurnCallbackERC1155 {
1414

1515
/**
1616
* @notice The beforeBurnERC1155 hook that is called by a core token before burning a token.
17-
* @param _caller The address of the caller.
17+
*
1818
* @param _from The address whose tokens are being burned.
1919
* @param _id The token ID being burned.
2020
* @param _value The quantity of tokens being burned.
2121
* @param _data The encoded arguments for the beforeBurn hook.
2222
* @return result Abi encoded bytes result of the hook.
2323
*/
24-
function beforeBurnERC1155(address _caller, address _from, uint256 _id, uint256 _value, bytes memory _data)
24+
function beforeBurnERC1155(address _from, uint256 _id, uint256 _value, bytes memory _data)
2525
external
2626
payable
2727
virtual

src/callback/BeforeBurnCallbackERC20.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ contract BeforeBurnCallbackERC20 {
1414

1515
/**
1616
* @notice The beforeBurnERC20 hook that is called by a core token before burning tokens.
17-
* @param _caller The address of the caller.
17+
*
1818
* @param _from The address whose tokens are being burned.
1919
* @param _amount The amount of tokens being burned.
2020
* @param _data The encoded arguments for the beforeBurn hook.
2121
* @return result Abi encoded bytes result of the hook.
2222
*/
23-
function beforeBurnERC20(address _caller, address _from, uint256 _amount, bytes memory _data)
23+
function beforeBurnERC20(address _from, uint256 _amount, bytes memory _data)
2424
external
2525
payable
2626
virtual

src/callback/BeforeBurnCallbackERC721.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ contract BeforeBurnCallbackERC721 {
1414

1515
/**
1616
* @notice The beforeBurnERC721 hook that is called by a core token before burning a token.
17-
* @param _caller The address of the caller.
17+
*
1818
* @param _tokenId The token ID being burned.
1919
* @param _data The encoded arguments for the beforeBurn hook.
2020
* @return result Abi encoded bytes result of the hook.
2121
*/
22-
function beforeBurnERC721(address _caller, uint256 _tokenId, bytes memory _data)
22+
function beforeBurnERC721(uint256 _tokenId, bytes memory _data)
2323
external
2424
payable
2525
virtual

src/callback/BeforeMintCallbackERC1155.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ contract BeforeMintCallbackERC1155 {
1414

1515
/**
1616
* @notice The beforeMintERC1155 hook that is called by a core token before minting tokens.
17-
* @param _caller The address of the caller.
17+
*
1818
* @param _to The address that is minting tokens.
1919
* @param _id The token ID being minted.
2020
* @param _quantity The quantity of tokens to mint.
2121
* @param _data Optional extra data passed to the hook.
2222
* @return result Abi encoded bytes result of the hook.
2323
*/
24-
function beforeMintERC1155(address _caller, address _to, uint256 _id, uint256 _quantity, bytes memory _data)
24+
function beforeMintERC1155(address _to, uint256 _id, uint256 _quantity, bytes memory _data)
2525
external
2626
payable
2727
virtual

src/callback/BeforeMintCallbackERC20.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ contract BeforeMintCallbackERC20 {
1414

1515
/**
1616
* @notice The beforeMintERC20 hook that is called by a core token before minting tokens.
17-
* @param _caller The address of the caller.
17+
*
1818
* @param _to The address to mint tokens to.
1919
* @param _amount The amount of tokens to mint.
2020
* @param _data Optional extra data passed to the hook.
2121
* @return result Abi encoded bytes result of the hook.
2222
*/
23-
function beforeMintERC20(address _caller, address _to, uint256 _amount, bytes memory _data)
23+
function beforeMintERC20(address _to, uint256 _amount, bytes memory _data)
2424
external
2525
payable
2626
virtual

0 commit comments

Comments
 (0)