Skip to content

Commit

Permalink
Merge pull request maticnetwork#71 from maticnetwork/feat/state-commi…
Browse files Browse the repository at this point in the history
…tted-event

add StateCommitted event
  • Loading branch information
gretzke committed Sep 14, 2023
2 parents d1b6fa5 + 5fabcfb commit ac8ad22
Show file tree
Hide file tree
Showing 5 changed files with 3,039 additions and 1,677 deletions.
7 changes: 5 additions & 2 deletions contracts/StateReceiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ pragma solidity ^0.5.11;
import { RLPReader } from "solidity-rlp/contracts/RLPReader.sol";

import { System } from "./System.sol";
import { IStateReceiver } from "./IStateReceiver.sol";

contract StateReceiver is System {
using RLPReader for bytes;
using RLPReader for RLPReader.RLPItem;

uint256 public lastStateId;

function commitState(uint256 syncTime, bytes calldata recordBytes) onlySystem external returns(bool success) {
event StateCommitted(uint256 indexed stateId, bool success);

function commitState(uint256 syncTime, bytes calldata recordBytes) external onlySystem returns(bool success) {
// parse state data
RLPReader.RLPItem[] memory dataList = recordBytes.toRlpItem().toList();
uint256 stateId = dataList[0].toUint();
Expand All @@ -31,12 +32,14 @@ contract StateReceiver is System {
assembly {
success := call(txGas, receiver, 0, add(data, 0x20), mload(data), 0, 0)
}
emit StateCommitted(stateId, success);
}
}

// check if address is contract
function isContract(address _addr) private view returns (bool){
uint32 size;
// solium-disable-next-line security/no-inline-assembly
assembly {
size := extcodesize(_addr)
}
Expand Down
Loading

0 comments on commit ac8ad22

Please sign in to comment.