erigon-pulse/cmd/devnet/contracts/childreceiver.sol
Mark Holt 751f62615d
Devnet sync events (#7911)
This request implements an end to end Polygon state sync in the devnet.

It does this by deploying smart contracts ont the L2 & L2 chain which
follow the polygon fx portal model with security checks removed to
simplify the code. The sync events generated are routed through a local
mock heimdal - to avoid the consensus process for testing purposes.

The commit also includes support code to help the delivery of additional
contract based scenratios.
2023-07-20 23:10:18 +01:00

22 lines
597 B
Solidity

// SPDX-License-Identifier: LGPL-3.0
pragma solidity ^0.8.6;
interface IStateReceiver {
function onStateReceive(uint256 stateId, bytes calldata data) external;
}
contract ChildReceiver is IStateReceiver {
mapping(address => uint) public received;
constructor() {
}
function onStateReceive(uint, bytes calldata data) external override {
require(msg.sender == address(0x0000000000000000000000000000000000001001), "Invalid sender");
(address from, uint amount) = abi.decode(data, (address, uint));
uint total = received[from];
received[from] = total + amount;
}
}