1
1
// SPDX-License-Identifier: Apache-2.0
2
2
pragma solidity ^ 0.8.20 ;
3
3
4
- import {ModularExtension } from "../../../ModularExtension .sol " ;
4
+ import {ModularModule } from "../../../ModularModule .sol " ;
5
5
import {Role} from "../../../Role.sol " ;
6
6
import {BeforeTransferCallbackERC721} from "../../../callback/BeforeTransferCallbackERC721.sol " ;
7
7
import {IBridgeAndCall} from "@lxly-bridge-and-call/IBridgeAndCall.sol " ;
8
8
9
9
library BridgeAndCallStorage {
10
+
10
11
/// @custom:storage-location erc7201:token.bridgeAndCall
11
12
bytes32 public constant BRIDGE_AND_CALL_STORAGE_POSITION =
12
- keccak256 (abi.encode (uint256 (keccak256 ("token.bridgeAndCall " )) - 1 )) &
13
- ~ bytes32 (uint256 (0xff ));
13
+ keccak256 (abi.encode (uint256 (keccak256 ("token.bridgeAndCall " )) - 1 )) & ~ bytes32 (uint256 (0xff ));
14
14
15
15
struct Data {
16
- address bridgeExtension ;
16
+ address bridgeModule ;
17
17
}
18
18
19
19
function data () internal pure returns (Data storage data_ ) {
@@ -22,69 +22,58 @@ library BridgeAndCallStorage {
22
22
data_.slot := position
23
23
}
24
24
}
25
+
25
26
}
26
27
27
- contract BridgeAndCallERC721 is ModularExtension , BeforeTransferCallbackERC721 {
28
+ contract BridgeAndCallERC721 is ModularModule , BeforeTransferCallbackERC721 {
29
+
28
30
/*//////////////////////////////////////////////////////////////
29
31
ERRORS
30
32
//////////////////////////////////////////////////////////////*/
31
33
32
34
/// @notice Emitted on attempt to transfer a token when the bridge extension is not set.
33
- error bridgeExtensionNotSet ();
35
+ error bridgeModuleNotSet ();
34
36
35
37
/*//////////////////////////////////////////////////////////////
36
38
EXTENSION CONFIG
37
39
//////////////////////////////////////////////////////////////*/
38
40
39
41
/// @notice Returns all implemented callback and extension functions.
40
- function getExtensionConfig ()
41
- external
42
- pure
43
- override
44
- returns (ExtensionConfig memory config )
45
- {
42
+ function getModuleConfig () external pure override returns (ModuleConfig memory config ) {
46
43
config.fallbackFunctions = new FallbackFunction [](4 );
47
44
48
- config.fallbackFunctions[0 ] = FallbackFunction ({
49
- selector: this .getBridgeExtension.selector ,
50
- permissionBits: 0
51
- });
52
- config.fallbackFunctions[1 ] = FallbackFunction ({
53
- selector: this .setBridgeExtension.selector ,
54
- permissionBits: Role._MANAGER_ROLE
55
- });
56
- config.fallbackFunctions[2 ] = FallbackFunction ({
57
- selector: this .bridgeAndCall.selector ,
58
- permissionBits: 0
59
- });
45
+ config.fallbackFunctions[0 ] = FallbackFunction ({selector: this .getBridgeModule.selector , permissionBits: 0 });
46
+ config.fallbackFunctions[1 ] =
47
+ FallbackFunction ({selector: this .setBridgeModule.selector , permissionBits: Role._MANAGER_ROLE});
48
+ config.fallbackFunctions[2 ] = FallbackFunction ({selector: this .bridgeAndCall.selector , permissionBits: 0 });
60
49
61
50
config.requiredInterfaces = new bytes4 [](1 );
62
51
config.requiredInterfaces[0 ] = 0x80ac58cd ; // ERC721.
63
52
64
53
config.registerInstallationCallback = true ;
65
54
}
66
55
67
- /// @dev Called by a Core into an Extension during the installation of the Extension .
56
+ /// @dev Called by a Core into an Module during the installation of the Module .
68
57
function onInstall (bytes calldata data ) external {
69
- address bridgeExtension = abi.decode (data, (address ));
70
- _bridgeAndCallStorage ().bridgeExtension = bridgeExtension ;
58
+ address bridgeModule = abi.decode (data, (address ));
59
+ _bridgeAndCallStorage ().bridgeModule = bridgeModule ;
71
60
}
72
61
73
- /// @dev Called by a Core into an Extension during the uninstallation of the Extension .
62
+ /// @dev Called by a Core into an Module during the uninstallation of the Module .
74
63
function onUninstall (bytes calldata data ) external {}
75
64
76
65
/*//////////////////////////////////////////////////////////////
77
66
FALLBACK FUNCTIONS
78
67
//////////////////////////////////////////////////////////////*/
79
68
80
69
/// @notice Returns whether transfers is enabled for the token.
81
- function getBridgeExtension () external view returns (address ) {
82
- return _bridgeAndCallStorage ().bridgeExtension ;
70
+ function getBridgeModule () external view returns (address ) {
71
+ return _bridgeAndCallStorage ().bridgeModule ;
83
72
}
84
73
85
74
/// @notice Set transferability for a token.
86
- function setBridgeExtension (address enableTransfer ) external {
87
- _bridgeAndCallStorage ().bridgeExtension = enableTransfer;
75
+ function setBridgeModule (address enableTransfer ) external {
76
+ _bridgeAndCallStorage ().bridgeModule = enableTransfer;
88
77
}
89
78
90
79
/// @notice Set transferability for a token.
@@ -96,31 +85,22 @@ contract BridgeAndCallERC721 is ModularExtension, BeforeTransferCallbackERC721 {
96
85
bytes calldata callData ,
97
86
bool forceUpdateGlobalExitRoot
98
87
) external {
99
- address bridgeExtension = _bridgeAndCallStorage ().bridgeExtension ;
100
- if (bridgeExtension == address (0 )) {
101
- revert bridgeExtensionNotSet ();
88
+ address bridgeModule = _bridgeAndCallStorage ().bridgeModule ;
89
+ if (bridgeModule == address (0 )) {
90
+ revert bridgeModuleNotSet ();
102
91
}
103
92
104
- IBridgeAndCall (bridgeExtension).bridgeAndCall (
105
- address (this ),
106
- amount,
107
- destinationNetwork,
108
- callAddress,
109
- fallbackAddress,
110
- callData,
111
- forceUpdateGlobalExitRoot
93
+ IBridgeAndCall (bridgeModule).bridgeAndCall (
94
+ address (this ), amount, destinationNetwork, callAddress, fallbackAddress, callData, forceUpdateGlobalExitRoot
112
95
);
113
96
}
114
97
115
98
/*//////////////////////////////////////////////////////////////
116
99
INTERNAL FUNCTIONS
117
100
//////////////////////////////////////////////////////////////*/
118
101
119
- function _bridgeAndCallStorage ()
120
- internal
121
- pure
122
- returns (BridgeAndCallStorage.Data storage )
123
- {
102
+ function _bridgeAndCallStorage () internal pure returns (BridgeAndCallStorage.Data storage ) {
124
103
return BridgeAndCallStorage.data ();
125
104
}
105
+
126
106
}
0 commit comments