Description:
Smart contract deployed on Ethereum with Factory features.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"src/RSC_EventRouter.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import {IRscSubscriptionRegistry} from "./RSCInterfaces.sol";
import {Ownable} from "./utils/Ownable.sol";
contract RSC_EventRouter is Ownable {
IRscSubscriptionRegistry public subscriptionRegistry;
struct Route {
uint32 destChainId;
address recipient;
bool enabled;
}
// key = keccak256(abi.encode(topic, eventSig))
mapping(bytes32 => Route) public routes;
event EventMatched(address indexed topic, bytes32 indexed eventSig, uint256 logPtr);
event RouteSet(address indexed topic, bytes32 indexed eventSig, uint32 destChainId, address recipient, bool enabled);
event Routed(bytes payload);
constructor(address _subscriptionRegistry) {
subscriptionRegistry = IRscSubscriptionRegistry(_subscriptionRegistry);
}
function setRoute(address topic, bytes32 eventSig, uint32 destChainId, address recipient, bool enabled) external onlyOwner {
bytes32 key = keccak256(abi.encode(topic, eventSig));
routes[key] = Route({destChainId: destChainId, recipient: recipient, enabled: enabled});
emit RouteSet(topic, eventSig, destChainId, recipient, enabled);
}
function route(bytes calldata log) external {
// Parse log data to extract topic and event signature
// eventSig at [0:32], topic at [64:84] (20 bytes) for test payload layout: eventSig | zero32 | topic
address topic = address(bytes20(log[64:84]));
bytes32 eventSig = bytes32(log[0:32]);
bytes32 key = keccak256(abi.encode(topic, eventSig));
// Verify subscription exists
bool isSub = subscriptionRegistry.subscribed(key) || subscriptionRegistry.wildcard(key);
if (!isSub) return;
emit EventMatched(topic, eventSig, uint256(uint160(address(this))));
Route memory r = routes[key];
if (!r.enabled || r.recipient == address(0) || r.destChainId == 0) return;
bytes memory payload = abi.encode(topic, eventSig, log, r.destChainId, r.recipient);
emit Routed(payload);
}
}
"
},
"src/RSCInterfaces.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
interface IRscCallbackProxy {
function remoteExec(bytes32 msgId, bytes calldata payload) external;
}
interface IRscSubscriptionRegistry {
event Subscribed(address indexed topic, bytes32 indexed eventSig, bool wildcard);
event Unsubscribed(address indexed topic, bytes32 indexed eventSig);
function subscribe(address topic, bytes32 eventSig, bool wildcard) external;
function unsubscribe(address topic, bytes32 eventSig) external;
function subscribed(bytes32 key) external view returns (bool);
function wildcard(bytes32 key) external view returns (bool);
}
"
},
"src/utils/Ownable.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
/// @title Minimal Ownable utility
abstract contract Ownable {
error NotOwner();
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
owner = msg.sender;
emit OwnershipTransferred(address(0), msg.sender);
}
modifier onlyOwner() {
if (msg.sender != owner) revert NotOwner();
_;
}
function transferOwnership(address newOwner) external onlyOwner {
require(newOwner != address(0), "Owner=zero");
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
"
}
},
"settings": {
"remappings": [
"forge-std/=lib/forge-std/src/",
"reactive-lib/=lib/reactive-lib/src/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "cancun",
"viaIR": true
}
}}
Submitted on: 2025-09-27 11:50:34
Comments
Log in to comment.
No comments yet.