2023-07-20 22:10:18 +00:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0
|
2023-07-18 08:47:04 +00:00
|
|
|
|
|
|
|
pragma solidity ^0.8.6;
|
|
|
|
|
|
|
|
interface IStateReceiver {
|
|
|
|
function onStateReceive(uint256 stateId, bytes calldata data) external;
|
|
|
|
}
|
|
|
|
|
|
|
|
contract ChildReceiver is IStateReceiver {
|
2023-07-28 13:03:32 +00:00
|
|
|
mapping(address => uint) public senders;
|
2023-07-18 08:47:04 +00:00
|
|
|
|
|
|
|
constructor() {
|
|
|
|
}
|
|
|
|
|
2023-07-28 13:03:32 +00:00
|
|
|
event received(address _source, uint256 _amount);
|
|
|
|
|
2023-07-18 08:47:04 +00:00
|
|
|
function onStateReceive(uint, bytes calldata data) external override {
|
2023-07-20 22:10:18 +00:00
|
|
|
require(msg.sender == address(0x0000000000000000000000000000000000001001), "Invalid sender");
|
2023-07-18 08:47:04 +00:00
|
|
|
(address from, uint amount) = abi.decode(data, (address, uint));
|
2023-07-28 13:03:32 +00:00
|
|
|
uint total = senders[from];
|
|
|
|
senders[from] = total + amount;
|
|
|
|
|
|
|
|
emit received(from, amount);
|
2023-07-18 08:47:04 +00:00
|
|
|
}
|
|
|
|
}
|