Skip to content

Commit 353e4ed

Browse files
authored
Use callback instead of hooks everywhere (#90)
1 parent af4273c commit 353e4ed

21 files changed

+560
-113
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// SPDX-License-Identifier: Apache 2.0
2+
pragma solidity ^0.8.0;
3+
4+
contract BeforeApproveCallbackERC20 {
5+
/*//////////////////////////////////////////////////////////////
6+
ERRORS
7+
//////////////////////////////////////////////////////////////*/
8+
9+
error BeforeApproveCallbackERC20NotImplemented();
10+
11+
/*//////////////////////////////////////////////////////////////
12+
EXTERNAL FUNCTIONS
13+
//////////////////////////////////////////////////////////////*/
14+
15+
/**
16+
* @notice The beforeApproveERC20 hook that is called by a core token before approving tokens.
17+
* @param _from The address that is approving tokens.
18+
* @param _to The address that is being approved.
19+
* @param _amount The amount of tokens being approved.
20+
* @return result Abi encoded bytes result of the hook.
21+
*/
22+
function beforeApproveERC20(address _from, address _to, uint256 _amount)
23+
external
24+
virtual
25+
returns (bytes memory result)
26+
{
27+
revert BeforeApproveCallbackERC20NotImplemented();
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// SPDX-License-Identifier: Apache 2.0
2+
pragma solidity ^0.8.0;
3+
4+
contract BeforeApproveCallbackERC721 {
5+
/*//////////////////////////////////////////////////////////////
6+
ERRORS
7+
//////////////////////////////////////////////////////////////*/
8+
9+
error BeforeApproveCallbackERC721NotImplemented();
10+
11+
/*//////////////////////////////////////////////////////////////
12+
EXTERNAL FUNCTIONS
13+
//////////////////////////////////////////////////////////////*/
14+
15+
/**
16+
* @notice The beforeApproveERC721 hook that is called by a core token before approving a token.
17+
* @param _from The address that is approving tokens.
18+
* @param _to The address that is being approved.
19+
* @param _tokenId The token ID being approved.
20+
* @param _approve The approval status to set.
21+
* @return result Abi encoded bytes result of the hook.
22+
*/
23+
function beforeApproveERC721(address _from, address _to, uint256 _tokenId, bool _approve)
24+
external
25+
virtual
26+
returns (bytes memory result)
27+
{
28+
revert BeforeApproveCallbackERC721NotImplemented();
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// SPDX-License-Identifier: Apache 2.0
2+
pragma solidity ^0.8.0;
3+
4+
contract BeforeApproveForAllCallback {
5+
/*//////////////////////////////////////////////////////////////
6+
ERRORS
7+
//////////////////////////////////////////////////////////////*/
8+
9+
error BeforeApproveForAllCallbackNotImplemented();
10+
11+
/*//////////////////////////////////////////////////////////////
12+
EXTERNAL FUNCTIONS
13+
//////////////////////////////////////////////////////////////*/
14+
15+
/**
16+
* @notice The beforeApproveForAll hook that is called by a core token before approving an operator to transfer all tokens.
17+
* @param _from The address that is approving tokens.
18+
* @param _to The address that is being approved.
19+
* @param _approved Whether to grant or revoke approval.
20+
*/
21+
function beforeApproveForAll(address _from, address _to, bool _approved)
22+
external
23+
virtual
24+
returns (bytes memory result)
25+
{
26+
revert BeforeApproveForAllCallbackNotImplemented();
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// SPDX-License-Identifier: Apache 2.0
2+
pragma solidity ^0.8.0;
3+
4+
contract BeforeBatchTransferCallbackERC1155 {
5+
/*//////////////////////////////////////////////////////////////
6+
ERRORS
7+
//////////////////////////////////////////////////////////////*/
8+
9+
error BeforeBatchTransferCallbackERC1155NotImplemented();
10+
11+
/*//////////////////////////////////////////////////////////////
12+
EXTERNAL FUNCTIONS
13+
//////////////////////////////////////////////////////////////*/
14+
15+
/**
16+
* @notice The beforeBatchTransferERC1155 hook that is called by a core token before batch transferring tokens.
17+
* @param from The address that is transferring tokens.
18+
* @param to The address that is receiving tokens.
19+
* @param ids The token IDs being transferred.
20+
* @param values The quantities of tokens being transferred.
21+
* @return result Abi encoded bytes result of the hook.
22+
*/
23+
function beforeBatchTransferERC1155(address from, address to, uint256[] calldata ids, uint256[] calldata values)
24+
external
25+
virtual
26+
returns (bytes memory result)
27+
{
28+
revert BeforeBatchTransferCallbackERC1155NotImplemented();
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// SPDX-License-Identifier: Apache 2.0
2+
pragma solidity ^0.8.0;
3+
4+
contract BeforeBurnCallbackERC1155 {
5+
/*//////////////////////////////////////////////////////////////
6+
ERRORS
7+
//////////////////////////////////////////////////////////////*/
8+
9+
error BeforeBurnCallbackERC1155NotImplemented();
10+
11+
/*//////////////////////////////////////////////////////////////
12+
EXTERNAL FUNCTIONS
13+
//////////////////////////////////////////////////////////////*/
14+
15+
/**
16+
* @notice The beforeBurnERC1155 hook that is called by a core token before burning a token.
17+
* @param _operator The address that is burning tokens.
18+
* @param _id The token ID being burned.
19+
* @param _value The quantity of tokens being burned.
20+
* @param _data The encoded arguments for the beforeBurn hook.
21+
* @return result Abi encoded bytes result of the hook.
22+
*/
23+
function beforeBurnERC1155(address _operator, uint256 _id, uint256 _value, bytes memory _data)
24+
external
25+
payable
26+
virtual
27+
returns (bytes memory result)
28+
{
29+
revert BeforeBurnCallbackERC1155NotImplemented();
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// SPDX-License-Identifier: Apache 2.0
2+
pragma solidity ^0.8.0;
3+
4+
contract BeforeBurnCallbackERC20 {
5+
/*//////////////////////////////////////////////////////////////
6+
ERRORS
7+
//////////////////////////////////////////////////////////////*/
8+
9+
error BeforeBurnCallbackERC20NotImplemented();
10+
11+
/*//////////////////////////////////////////////////////////////
12+
EXTERNAL FUNCTIONS
13+
//////////////////////////////////////////////////////////////*/
14+
15+
/**
16+
* @notice The beforeBurnERC20 hook that is called by a core token before burning tokens.
17+
* @param _from The address that is burning tokens.
18+
* @param _amount The amount of tokens being burned.
19+
* @param _data The encoded arguments for the beforeBurn hook.
20+
* @return result Abi encoded bytes result of the hook.
21+
*/
22+
function beforeBurnERC20(address _from, uint256 _amount, bytes memory _data)
23+
external
24+
payable
25+
virtual
26+
returns (bytes memory result)
27+
{
28+
revert BeforeBurnCallbackERC20NotImplemented();
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// SPDX-License-Identifier: Apache 2.0
2+
pragma solidity ^0.8.0;
3+
4+
contract BeforeBurnCallbackERC721 {
5+
/*//////////////////////////////////////////////////////////////
6+
ERRORS
7+
//////////////////////////////////////////////////////////////*/
8+
9+
error BeforeBurnCallbackERC721NotImplemented();
10+
11+
/*//////////////////////////////////////////////////////////////
12+
EXTERNAL FUNCTIONS
13+
//////////////////////////////////////////////////////////////*/
14+
15+
/**
16+
* @notice The beforeBurnERC721 hook that is called by a core token before burning a token.
17+
* @param _operator The address that is burning tokens.
18+
* @param _tokenId The token ID being burned.
19+
* @param _data The encoded arguments for the beforeBurn hook.
20+
* @return result Abi encoded bytes result of the hook.
21+
*/
22+
function beforeBurnERC721(address _operator, uint256 _tokenId, bytes memory _data)
23+
external
24+
payable
25+
virtual
26+
returns (bytes memory result)
27+
{
28+
revert BeforeBurnCallbackERC721NotImplemented();
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// SPDX-License-Identifier: Apache 2.0
2+
pragma solidity ^0.8.0;
3+
4+
contract BeforeMintCallbackERC1155 {
5+
/*//////////////////////////////////////////////////////////////
6+
ERRORS
7+
//////////////////////////////////////////////////////////////*/
8+
9+
error BeforeMintCallbackERC1155NotImplemented();
10+
11+
/*//////////////////////////////////////////////////////////////
12+
EXTERNAL FUNCTIONS
13+
//////////////////////////////////////////////////////////////*/
14+
15+
/**
16+
* @notice The beforeMintERC1155 hook that is called by a core token before minting tokens.
17+
* @param _to The address that is minting tokens.
18+
* @param _id The token ID being minted.
19+
* @param _quantity The quantity of tokens to mint.
20+
* @param _data Optional extra data passed to the hook.
21+
* @return result Abi encoded bytes result of the hook.
22+
*/
23+
function beforeMintERC1155(address _to, uint256 _id, uint256 _quantity, bytes memory _data)
24+
external
25+
payable
26+
virtual
27+
returns (bytes memory result)
28+
{
29+
revert BeforeMintCallbackERC1155NotImplemented();
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// SPDX-License-Identifier: Apache 2.0
2+
pragma solidity ^0.8.0;
3+
4+
contract BeforeMintCallbackERC20 {
5+
/*//////////////////////////////////////////////////////////////
6+
ERRORS
7+
//////////////////////////////////////////////////////////////*/
8+
9+
error BeforeMintCallbackERC20NotImplemented();
10+
11+
/*//////////////////////////////////////////////////////////////
12+
EXTERNAL FUNCTIONS
13+
//////////////////////////////////////////////////////////////*/
14+
15+
/**
16+
* @notice The beforeMintERC20 hook that is called by a core token before minting tokens.
17+
* @param _to The address to mint tokens to.
18+
* @param _amount The amount of tokens to mint.
19+
* @param _data Optional extra data passed to the hook.
20+
* @return result Abi encoded bytes result of the hook.
21+
*/
22+
function beforeMintERC20(address _to, uint256 _amount, bytes memory _data)
23+
external
24+
payable
25+
virtual
26+
returns (bytes memory result)
27+
{
28+
revert BeforeMintCallbackERC20NotImplemented();
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// SPDX-License-Identifier: Apache 2.0
2+
pragma solidity ^0.8.0;
3+
4+
contract BeforeMintCallbackERC721 {
5+
/*//////////////////////////////////////////////////////////////
6+
ERRORS
7+
//////////////////////////////////////////////////////////////*/
8+
9+
error BeforeMintCallbackERC721NotImplemented();
10+
11+
/*//////////////////////////////////////////////////////////////
12+
EXTERNAL FUNCTIONS
13+
//////////////////////////////////////////////////////////////*/
14+
15+
/**
16+
* @notice The beforeMintERC721 hook that is called by a core token before minting tokens.
17+
* @param _to The address that is minting tokens.
18+
* @param _quantity The quantity of tokens to mint.
19+
* @param _data Optional extra data passed to the hook.
20+
* @return result Abi encoded bytes result of the hook.
21+
*/
22+
function beforeMintERC721(address _to, uint256 _quantity, bytes memory _data)
23+
external
24+
payable
25+
virtual
26+
returns (bytes memory result)
27+
{
28+
revert BeforeMintCallbackERC721NotImplemented();
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// SPDX-License-Identifier: Apache 2.0
2+
pragma solidity ^0.8.0;
3+
4+
contract BeforeTransferCallbackERC1155 {
5+
/*//////////////////////////////////////////////////////////////
6+
ERRORS
7+
//////////////////////////////////////////////////////////////*/
8+
9+
error BeforeTransferCallbackERC1155NotImplemented();
10+
11+
/*//////////////////////////////////////////////////////////////
12+
EXTERNAL FUNCTIONS
13+
//////////////////////////////////////////////////////////////*/
14+
15+
/**
16+
* @notice The beforeTransferERC1155 hook that is called by a core token before transferring a token.
17+
* @param _from The address that is transferring tokens.
18+
* @param _to The address that is receiving tokens.
19+
* @param _id The token ID being transferred.
20+
* @param _value The quantity of tokens being transferred.
21+
* @return result Abi encoded bytes result of the hook.
22+
*/
23+
function beforeTransferERC1155(address _from, address _to, uint256 _id, uint256 _value)
24+
external
25+
virtual
26+
returns (bytes memory result)
27+
{
28+
revert BeforeTransferCallbackERC1155NotImplemented();
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// SPDX-License-Identifier: Apache 2.0
2+
pragma solidity ^0.8.0;
3+
4+
contract BeforeTransferCallbackERC20 {
5+
/*//////////////////////////////////////////////////////////////
6+
ERRORS
7+
//////////////////////////////////////////////////////////////*/
8+
9+
error BeforeTransferCallbackERC20NotImplemented();
10+
11+
/*//////////////////////////////////////////////////////////////
12+
EXTERNAL FUNCTIONS
13+
//////////////////////////////////////////////////////////////*/
14+
15+
/**
16+
* @notice The beforeTransferERC20 hook that is called by a core token before transferring tokens.
17+
* @param _from The address that is transferring tokens.
18+
* @param _to The address that is receiving tokens.
19+
* @param _amount The amount of tokens being transferred.
20+
* @return result Abi encoded bytes result of the hook.
21+
*/
22+
function beforeTransferERC20(address _from, address _to, uint256 _amount)
23+
external
24+
virtual
25+
returns (bytes memory result)
26+
{
27+
revert BeforeTransferCallbackERC20NotImplemented();
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// SPDX-License-Identifier: Apache 2.0
2+
pragma solidity ^0.8.0;
3+
4+
contract BeforeTransferCallbackERC721 {
5+
/*//////////////////////////////////////////////////////////////
6+
ERRORS
7+
//////////////////////////////////////////////////////////////*/
8+
9+
error BeforeTransferCallbackERC721NotImplemented();
10+
11+
/*//////////////////////////////////////////////////////////////
12+
EXTERNAL FUNCTIONS
13+
//////////////////////////////////////////////////////////////*/
14+
15+
/**
16+
* @notice The beforeTransferERC721 hook that is called by a core token before transferring a token.
17+
* @param _from The address that is transferring tokens.
18+
* @param _to The address that is receiving tokens.
19+
* @param _tokenId The token ID being transferred.
20+
* @return result Abi encoded bytes result of the hook.
21+
*/
22+
function beforeTransferERC721(address _from, address _to, uint256 _tokenId)
23+
external
24+
virtual
25+
returns (bytes memory result)
26+
{
27+
revert BeforeTransferCallbackERC721NotImplemented();
28+
}
29+
}

0 commit comments

Comments
 (0)