From 5d419394005262695d83464a6adfe286e2f0c972 Mon Sep 17 00:00:00 2001 From: amateima Date: Thu, 16 Oct 2025 02:37:22 +0300 Subject: [PATCH 1/4] feat: add metadata event emitter contract Signed-off-by: amateima --- contracts/AcrossEventEmitter.sol | 40 +++++++++++++++++++++++ deploy/114_deploy_across_event_emitter.ts | 15 +++++++++ lib/forge-std | 2 +- 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 contracts/AcrossEventEmitter.sol create mode 100644 deploy/114_deploy_across_event_emitter.ts diff --git a/contracts/AcrossEventEmitter.sol b/contracts/AcrossEventEmitter.sol new file mode 100644 index 000000000..ef2c245b8 --- /dev/null +++ b/contracts/AcrossEventEmitter.sol @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; + +/** + * @title AcrossEventEmitter + * @notice A simple contract that emits events with bytes encoded metadata + */ +contract AcrossEventEmitter is ReentrancyGuard { + /** + * @notice Emitted when metadata is stored + * @param data The metadata bytes emitted + */ + event MetadataEmitted(bytes data); + + /** + * @notice Prevents native token from being sent to this contract + */ + receive() external payable { + revert("Contract does not accept native token"); + } + + /** + * @notice Prevents native token from being sent to this contract via fallback + */ + fallback() external payable { + revert("Contract doesn't accept native token"); + } + + /** + * @notice Emits metadata as an event + * @param data The bytes data to emit + */ + function emitData(bytes calldata data) external nonReentrant { + require(data.length > 0, "Data cannot be empty"); + require(data.length <= 2048, "Data too large"); // Set appropriate limit + emit MetadataEmitted(data); + } +} diff --git a/deploy/114_deploy_across_event_emitter.ts b/deploy/114_deploy_across_event_emitter.ts new file mode 100644 index 000000000..9fe721d2b --- /dev/null +++ b/deploy/114_deploy_across_event_emitter.ts @@ -0,0 +1,15 @@ +import { DeployFunction } from "hardhat-deploy/types"; +import { HardhatRuntimeEnvironment } from "hardhat/types"; + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployer } = await hre.getNamedAccounts(); + const instance = await hre.deployments.deploy("AcrossEventEmitter", { + from: deployer, + log: true, + skipIfAlreadyDeployed: true, + }); + await hre.run("verify:verify", { address: instance.address }); +}; + +module.exports = func; +func.tags = ["AcrossEventEmitter"]; diff --git a/lib/forge-std b/lib/forge-std index 8bbcf6e3f..066ff16c5 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit 8bbcf6e3f8f62f419e5429a0bd89331c85c37824 +Subproject commit 066ff16c5c03e6f931cd041fd366bc4be1fae82a From f88ed47a81008921e6acf0c07727da920c59271c Mon Sep 17 00:00:00 2001 From: amateima Date: Thu, 16 Oct 2025 02:41:10 +0300 Subject: [PATCH 2/4] Remove comment Signed-off-by: amateima --- contracts/AcrossEventEmitter.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/AcrossEventEmitter.sol b/contracts/AcrossEventEmitter.sol index ef2c245b8..f706b7232 100644 --- a/contracts/AcrossEventEmitter.sol +++ b/contracts/AcrossEventEmitter.sol @@ -34,7 +34,7 @@ contract AcrossEventEmitter is ReentrancyGuard { */ function emitData(bytes calldata data) external nonReentrant { require(data.length > 0, "Data cannot be empty"); - require(data.length <= 2048, "Data too large"); // Set appropriate limit + require(data.length <= 2048, "Data too large"); emit MetadataEmitted(data); } } From c7c0175c3dc78b6b00da7454538a9e2db02bd554 Mon Sep 17 00:00:00 2001 From: amateima Date: Mon, 20 Oct 2025 23:53:59 +0300 Subject: [PATCH 3/4] Remove data upper limit Signed-off-by: amateima --- contracts/AcrossEventEmitter.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/contracts/AcrossEventEmitter.sol b/contracts/AcrossEventEmitter.sol index f706b7232..7d6af6aa3 100644 --- a/contracts/AcrossEventEmitter.sol +++ b/contracts/AcrossEventEmitter.sol @@ -34,7 +34,6 @@ contract AcrossEventEmitter is ReentrancyGuard { */ function emitData(bytes calldata data) external nonReentrant { require(data.length > 0, "Data cannot be empty"); - require(data.length <= 2048, "Data too large"); emit MetadataEmitted(data); } } From 0c795d6c3393d9698e2e90f1fc0d8012e383c3cd Mon Sep 17 00:00:00 2001 From: amateima Date: Tue, 21 Oct 2025 18:12:20 +0300 Subject: [PATCH 4/4] Fix Signed-off-by: amateima --- contracts/AcrossEventEmitter.sol | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/contracts/AcrossEventEmitter.sol b/contracts/AcrossEventEmitter.sol index 7d6af6aa3..3ec51b680 100644 --- a/contracts/AcrossEventEmitter.sol +++ b/contracts/AcrossEventEmitter.sol @@ -1,38 +1,22 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; -import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; - /** * @title AcrossEventEmitter * @notice A simple contract that emits events with bytes encoded metadata */ -contract AcrossEventEmitter is ReentrancyGuard { +contract AcrossEventEmitter { /** * @notice Emitted when metadata is stored * @param data The metadata bytes emitted */ event MetadataEmitted(bytes data); - /** - * @notice Prevents native token from being sent to this contract - */ - receive() external payable { - revert("Contract does not accept native token"); - } - - /** - * @notice Prevents native token from being sent to this contract via fallback - */ - fallback() external payable { - revert("Contract doesn't accept native token"); - } - /** * @notice Emits metadata as an event * @param data The bytes data to emit */ - function emitData(bytes calldata data) external nonReentrant { + function emitData(bytes calldata data) external { require(data.length > 0, "Data cannot be empty"); emit MetadataEmitted(data); }