@@ -6,7 +6,7 @@ import {Role} from "../../../Role.sol";
66
77import {CrossChain} from "./CrossChain.sol " ;
88import {IBridgeAndCall} from "@lxly-bridge-and-call/IBridgeAndCall.sol " ;
9- import {console } from "forge-std/console .sol " ;
9+ import {IERC20 } from "src/interface/IERC20 .sol " ;
1010
1111library PolygonAgglayerCrossChainStorage {
1212
@@ -49,7 +49,6 @@ contract PolygonAgglayerCrossChain is Module, CrossChain {
4949 /// @dev Called by a Core into an Module during the installation of the Module.
5050 function onInstall (bytes calldata data ) external {
5151 address router = abi.decode (data, (address ));
52- console.log ("router in onInstall: " , router);
5352 _polygonAgglayerStorage ().router = router;
5453 }
5554
@@ -93,12 +92,7 @@ contract PolygonAgglayerCrossChain is Module, CrossChain {
9392 uint256 _amount ,
9493 bytes memory permitData
9594 ) = 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);
10095
101- // IBridgeAndCall(_polygonAgglayerStorage().router).bridgeAndCall(
10296 _bridgeAndCall (
10397 _token,
10498 _amount,
@@ -109,13 +103,23 @@ contract PolygonAgglayerCrossChain is Module, CrossChain {
109103 _payload,
110104 _forceUpdateGlobalExitRoot
111105 );
112- console.log ("bridgeAndCall called successfully " );
113106
114107 onCrossChainTransactionSent (_destinationChain, _callAddress, _payload, _extraArgs);
115108 }
116109
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+
119123 IBridgeAndCall (_polygonAgglayerStorage ().router).bridgeAndCall (
120124 _token,
121125 _amount,
@@ -127,7 +131,6 @@ contract PolygonAgglayerCrossChain is Module, CrossChain {
127131 _forceUpdateGlobalExitRoot
128132 );
129133 }
130-
131134
132135 /*//////////////////////////////////////////////////////////////
133136 INTERNAL FUNCTIONS
0 commit comments