-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from BootNodeDev/last-block-processed
Add a way to process events from blocks in the past
- Loading branch information
Showing
19 changed files
with
2,834 additions
and
2,268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity >=0.8.25 <0.9.0; | ||
|
||
import { Script } from "forge-std/Script.sol"; | ||
import { console2 } from "forge-std/console2.sol"; | ||
|
||
import { TypeCasts } from "@hyperlane-xyz/libs/TypeCasts.sol"; | ||
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
|
||
import { Hyperlane7683 } from "../src/Hyperlane7683.sol"; | ||
import { OrderData, OrderEncoder } from "../src/libs/OrderEncoder.sol"; | ||
|
||
import { | ||
OnchainCrossChainOrder | ||
} from "../src/ERC7683/IERC7683.sol"; | ||
|
||
contract BatchOpen { | ||
Hyperlane7683 public router; | ||
constructor(address _router) { | ||
router = Hyperlane7683(_router); | ||
} | ||
|
||
function openOrders(OnchainCrossChainOrder[] memory orders, address token, uint256 total) external { | ||
ERC20(token).transferFrom(msg.sender, address(this), total); | ||
ERC20(token).approve(address(router), total); | ||
for (uint256 i = 0; i < orders.length; i++) { | ||
router.open(orders[i]); | ||
} | ||
} | ||
} | ||
|
||
/// @dev See the Solidity Scripting tutorial: https://book.getfoundry.sh/tutorials/solidity-scripting | ||
contract DeployBatchOpen is Script { | ||
function run() public { | ||
uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PK"); | ||
address router = vm.envAddress("ROUTER_ADDRESS"); | ||
|
||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
new BatchOpen(router); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity >=0.8.25 <0.9.0; | ||
|
||
import { Script } from "forge-std/Script.sol"; | ||
import { console2 } from "forge-std/console2.sol"; | ||
|
||
import { TypeCasts } from "@hyperlane-xyz/libs/TypeCasts.sol"; | ||
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
|
||
import { Hyperlane7683 } from "../src/Hyperlane7683.sol"; | ||
import { OrderData, OrderEncoder } from "../src/libs/OrderEncoder.sol"; | ||
import { BatchOpen } from "./DeployBatchOpen.s.sol"; | ||
|
||
import { | ||
OnchainCrossChainOrder | ||
} from "../src/ERC7683/IERC7683.sol"; | ||
|
||
/// @dev See the Solidity Scripting tutorial: https://book.getfoundry.sh/tutorials/solidity-scripting | ||
contract OpenBatchOrder is Script { | ||
function run() public { | ||
uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PK"); | ||
|
||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
address localRouter = vm.envAddress("ROUTER_ADDRESS"); | ||
address sender = vm.envAddress("ORDER_SENDER"); | ||
address recipient = vm.envAddress("ORDER_RECIPIENT"); | ||
address inputToken = vm.envAddress("ITT_INPUT"); | ||
address outputToken = vm.envAddress("ITT_OUTPUT"); | ||
uint256 amountIn = vm.envUint("AMOUNT_IN"); | ||
uint256 amountOut = vm.envUint("AMOUNT_OUT"); | ||
uint256 senderNonce = vm.envUint("SENDER_NONCE"); | ||
uint32 originDomain = Hyperlane7683(localRouter).localDomain(); | ||
uint256 destinationDomain = vm.envUint("DESTINATION_DOMAIN"); | ||
uint32 fillDeadline = type(uint32).max; | ||
address batchOpen = vm.envAddress("BATCH_OPEN"); | ||
|
||
ERC20(inputToken).approve(batchOpen, amountIn * 3); | ||
|
||
OrderData memory order = OrderData( | ||
TypeCasts.addressToBytes32(sender), | ||
TypeCasts.addressToBytes32(recipient), | ||
TypeCasts.addressToBytes32(inputToken), | ||
TypeCasts.addressToBytes32(outputToken), | ||
amountIn, | ||
amountOut, | ||
senderNonce, | ||
originDomain, | ||
uint32(destinationDomain), | ||
TypeCasts.addressToBytes32(localRouter), | ||
fillDeadline, | ||
new bytes(0) | ||
); | ||
|
||
OnchainCrossChainOrder[] memory onchainOrders = new OnchainCrossChainOrder[](3); | ||
|
||
onchainOrders[0] = OnchainCrossChainOrder( | ||
fillDeadline, | ||
OrderEncoder.orderDataType(), | ||
OrderEncoder.encode(order) | ||
); | ||
|
||
order.senderNonce = senderNonce + 1; | ||
onchainOrders[1] = OnchainCrossChainOrder( | ||
fillDeadline, | ||
OrderEncoder.orderDataType(), | ||
OrderEncoder.encode(order) | ||
); | ||
|
||
order.senderNonce = senderNonce + 2; | ||
onchainOrders[2] = OnchainCrossChainOrder( | ||
fillDeadline, | ||
OrderEncoder.orderDataType(), | ||
OrderEncoder.encode(order) | ||
); | ||
|
||
BatchOpen(batchOpen).openOrders(onchainOrders, inputToken, amountIn * 3); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
typechain | ||
local.db | ||
**/local.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.