S Price: $0.5417 (-6.73%)

Contract Diff Checker

Contract Name:
SonicUI

Contract Source Code:

File 1 of 1 : SonicUI

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0;

interface IERC20 {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external view returns (string memory);
    function symbol() external view returns (string memory);
    function decimals() external view returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);
}
interface Iui{
    function newPlayerAndHero(uint numberOfPlayers, string memory baseName, uint groupId) external;
    function newPlayers(uint numberOfPlayers, uint groupId) external;
    function newHeroes(uint fromId, uint toId, string calldata baseName) external;
    function runCommand (bytes calldata command) external;
    function runCommands(uint[] calldata ids) external;
    function runSavedCommand(uint id) external;
    function saveCommand(uint id, bytes calldata command, bool overwrite) external;
    function deleteCommand(uint id) external;
    function execute(address to, bytes calldata data) external;
    function helperExecute(address to, bytes calldata data) external;
    function processGroup(uint id, bytes4 playerSig, bytes calldata data)external;
    function processGroupAction(uint id)external;
    function process(bytes4 s, bytes calldata data)external;
    function updateHelper(address h) external;
    function updateSig(uint i, bytes4 s) external;
    function addSig(bytes4 s) external ;
    function addAction(bytes calldata action) external;
    function updateAction(uint index, bytes calldata action) external;
    function setGroupAction(uint groupId, uint actionId) external ;
    function setGroupsAction(uint[] calldata groupIds, uint[] calldata actionIds) external;
    function transferOwner(address newOwner) external;
    function setHelperOwner(address newOwner) external;
    function setOffsetHero(uint value) external;
    function offsetMultiHero(uint from, uint to, uint value, bool subtract) external;
    function totalSupply() external view returns(uint);
    function getPlayer(uint id) external view returns(address);
    function getPlayerId(address player) external view returns(uint);
    function getGroup(uint idx) external view returns(uint[] memory);
    function getNumberOfGroups() external view returns(uint);
    function withdrawFromGroup(address to, uint groupId, uint tokenId) external;
    function withdrawBatchFromGroup(address to, uint groupId, uint[] calldata tokenIds) external;
    function withdrawERC20(address to, address token, uint amount) external;
    function withdrawEth(address to, uint value, bytes calldata data) external;
}

contract SonicUI{
    Iui private controller;
    address private owner;
    mapping(uint=>uint) public actionTime;
    modifier onlyOwner() {
        require(owner == msg.sender, "Ownable: caller is not the owner");
        _;
    }
    constructor(address _controller) {
        owner = msg.sender;
        controller = Iui(_controller);     
    }
    receive() external payable {}

    /*
        Internal functions
    */
    
    /*
        Main functions
    */
    function newPlayerAndHero(uint numberOfPlayers, string memory baseName, uint groupId) external onlyOwner{   
       controller.newPlayerAndHero(numberOfPlayers, baseName, groupId);
    }
    function newPlayers(uint numberOfPlayers, uint groupId) external onlyOwner{
       controller.newPlayers(numberOfPlayers, groupId);
    }
    function newHeroes(uint fromId, uint toId, string calldata baseName) external onlyOwner {
       controller.newHeroes(fromId, toId, baseName);
    }
    function runCommand (bytes calldata command) external onlyOwner{
        controller.runCommand(command);
    }
    function runCommands(uint[] calldata ids) external onlyOwner{
        controller.runCommands(ids); 
    }
    function runSavedCommand(uint id) external onlyOwner{
        controller.runSavedCommand(id);
    }
    function saveCommand(uint id, bytes calldata command, bool overwrite) external onlyOwner{
       controller.saveCommand(id,command,overwrite);
    }
    function deleteCommand(uint id) external onlyOwner{
        controller.deleteCommand(id);
    }
    function execute(address to, bytes calldata data) external onlyOwner{
        controller.execute(to,data);
    }
    function helperExecute(address to, bytes calldata data) external onlyOwner{
        controller.helperExecute(to,data);
    }
    function processGroup(uint id, bytes4 playerSig, bytes calldata data)external onlyOwner{
       controller.processGroup(id,playerSig,data);
    }
    function processGroupAction(uint id)external onlyOwner{
        controller.processGroupAction(id);
        actionTime[id]=block.timestamp;
    }
    function processGroupsAction(uint[] calldata groupIds)external onlyOwner{
        for (uint i=0; i<groupIds.length; i++){
            controller.processGroupAction(groupIds[i]);
        }
    }
    function process(bytes4 s, bytes calldata data)external onlyOwner{
        controller.process(s,data);
    }
    /*
        Setting functions
    */
    function setController(address c) external onlyOwner{
        controller = Iui(c);
    }
    function updateHelper(address h) external onlyOwner{
        controller.updateHelper(h);
    }
    function updateSig(uint i, bytes4 s) external onlyOwner{
        controller.updateSig(i,s);
    }
    function addSig(bytes4 s) external onlyOwner{
        controller.addSig(s);
    }
    function addAction(bytes calldata action) external onlyOwner{
        controller.addAction(action);
    }
    function updateAction(uint index, bytes calldata action) external onlyOwner{
        controller.updateAction(index,action);
    }
    function setGroupAction(uint groupId, uint actionId) external onlyOwner{
        controller.setGroupAction(groupId,actionId);
    }
    function setGroupsAction(uint[] calldata groupIds, uint[] calldata actionIds) external onlyOwner{
        controller.setGroupsAction(groupIds,actionIds);
    }
    function setGroupsAction(uint[] calldata groupIds, uint actionId) external onlyOwner{
        for (uint i=0; i<groupIds.length; i++){
            controller.setGroupAction(groupIds[i],actionId);
        }
    }
    /*
        Ownership functions
    */
    function transferOwner(address newOwner) external onlyOwner{
        owner = newOwner;
    }
    function transferControlOwner(address newOwner) external onlyOwner{
        controller.transferOwner(newOwner);
    }
    function setHelperOwner(address newOwner) external onlyOwner{
        controller.setHelperOwner(newOwner);
    }
    /*
        Misc functions
    */
    function setOffsetHero(uint value) external  onlyOwner{
        controller.setOffsetHero(value);
    }
    function offsetMultiHero(uint from, uint to, uint value, bool subtract) external  onlyOwner{
        controller.offsetMultiHero(from,to,value,subtract);
    }
    
     /*
    View functions
    */
    function totalSupply() public view returns(uint){
        return controller.totalSupply();
    }
    function groupAge(uint id) public view returns(uint){
        return block.timestamp - actionTime[id];
    }
    function oneDayleft(uint id) public view returns(uint){
        uint timeleft=0;
        if(24 hours > block.timestamp - actionTime[id]){
            timeleft = 24 hours - (block.timestamp - actionTime[id]); 
        }
        return timeleft;
    }
    function getPlayer(uint id) public view returns(address){
        return controller.getPlayer(id);
    }
    function getHeroId(address player) public view returns(uint){
       return controller.getPlayerId(player);
    }
    function getHeroId(uint playerId) public view returns(uint){
       return controller.getPlayerId(getPlayer(playerId));
    }
    function getGroup(uint idx) public view returns(uint[] memory){
        return controller.getGroup(idx);
    }
    function getNumberOfGroups() public view returns(uint){
        return controller.getNumberOfGroups();
    }
     /*
        Misc functions
    */
    function withdrawFromGroup(address to, uint groupId, uint tokenId) external onlyOwner{
        controller.withdrawFromGroup(to,groupId,tokenId);
    }
    function withdrawBatchFromGroup(address to, uint groupId, uint[] calldata tokenIds) external onlyOwner{
        controller.withdrawBatchFromGroup(to,groupId,tokenIds);
    }
    function withdrawControlERC20(address to, address token, uint amount) external onlyOwner {
        controller.withdrawERC20(to,token,amount);
    }
    function withdrawControlEth(address to, uint value, bytes calldata data) external payable onlyOwner{
        controller.withdrawEth(to,value,data);
    }
    function withdrawERC20(address to, address token, uint amount) external onlyOwner {
       IERC20(token).transferFrom(address(this),to,amount);
    }
    function withdrawEth(address to, uint value, bytes calldata data) external payable onlyOwner{
        (bool success,) = to.call{value:value}(data);
        require(success, 'TransferHelper: ETH_TRANSFER_FAILED');
    }

}

Please enter a contract address above to load the contract details and source code.

Context size (optional):