@@ -6,7 +6,7 @@ import {Role} from "../../../Role.sol";
6
6
7
7
import {CrossChain} from "./CrossChain.sol " ;
8
8
import {IBridgeAndCall} from "@lxly-bridge-and-call/IBridgeAndCall.sol " ;
9
- import {console } from "forge-std/console .sol " ;
9
+ import {IERC20 } from "src/interface/IERC20 .sol " ;
10
10
11
11
library PolygonAgglayerCrossChainStorage {
12
12
@@ -49,7 +49,6 @@ contract PolygonAgglayerCrossChain is Module, CrossChain {
49
49
/// @dev Called by a Core into an Module during the installation of the Module.
50
50
function onInstall (bytes calldata data ) external {
51
51
address router = abi.decode (data, (address ));
52
- console.log ("router in onInstall: " , router);
53
52
_polygonAgglayerStorage ().router = router;
54
53
}
55
54
@@ -93,12 +92,7 @@ contract PolygonAgglayerCrossChain is Module, CrossChain {
93
92
uint256 _amount ,
94
93
bytes memory permitData
95
94
) = abi.decode (_extraArgs, (address , bool , address , uint256 , bytes ));
96
- console.log ("token address " , _token);
97
- console.log ("amount " , _amount);
98
- console.log ("destinationChain " , _destinationChain);
99
- console.log ("callAddress " , _callAddress);
100
95
101
- // IBridgeAndCall(_polygonAgglayerStorage().router).bridgeAndCall(
102
96
_bridgeAndCall (
103
97
_token,
104
98
_amount,
@@ -109,13 +103,23 @@ contract PolygonAgglayerCrossChain is Module, CrossChain {
109
103
_payload,
110
104
_forceUpdateGlobalExitRoot
111
105
);
112
- console.log ("bridgeAndCall called successfully " );
113
106
114
107
onCrossChainTransactionSent (_destinationChain, _callAddress, _payload, _extraArgs);
115
108
}
116
109
117
- function _bridgeAndCall (address _token , uint256 _amount , bytes memory permitData , uint32 _destinationChain , address _callAddress , address _fallbackAddress , bytes memory _payload , bool _forceUpdateGlobalExitRoot ) internal {
118
- console.log ("router: " , _polygonAgglayerStorage ().router);
110
+ function _bridgeAndCall (
111
+ address _token ,
112
+ uint256 _amount ,
113
+ bytes memory permitData ,
114
+ uint32 _destinationChain ,
115
+ address _callAddress ,
116
+ address _fallbackAddress ,
117
+ bytes memory _payload ,
118
+ bool _forceUpdateGlobalExitRoot
119
+ ) internal {
120
+ IERC20 (_token).transferFrom (msg .sender , address (this ), _amount);
121
+ IERC20 (_token).approve (_polygonAgglayerStorage ().router, _amount);
122
+
119
123
IBridgeAndCall (_polygonAgglayerStorage ().router).bridgeAndCall (
120
124
_token,
121
125
_amount,
@@ -127,7 +131,6 @@ contract PolygonAgglayerCrossChain is Module, CrossChain {
127
131
_forceUpdateGlobalExitRoot
128
132
);
129
133
}
130
-
131
134
132
135
/*//////////////////////////////////////////////////////////////
133
136
INTERNAL FUNCTIONS
0 commit comments