{
    "Function": "_execute",
    "File": "src/AxelarGatewaySinglesig.sol",
    "Parent Contracts": [
        "src/AxelarGateway.sol",
        "src/AdminMultisigBase.sol",
        "src/EternalStorage.sol",
        "src/interfaces/IAxelarGatewaySinglesig.sol",
        "src/interfaces/IAxelarGateway.sol"
    ],
    "High-Level Calls": [
        "ECDSA",
        "ECDSA"
    ],
    "Internal Calls": [
        "abi.decode()",
        "keccak256(bytes)",
        "owner",
        "isCommandExecuted",
        "keccak256(bytes)",
        "_isValidPreviousOwner",
        "_setCommandExecuted",
        "_isValidRecentOperator",
        "abi.encodePacked()",
        "_setCommandExecuted",
        "revert InvalidCommands()",
        "abi.encodeWithSelector()",
        "revert InvalidChainId()"
    ],
    "Library Calls": [
        "recover",
        "toEthSignedMessageHash"
    ],
    "Low-Level Calls": [
        "call"
    ],
    "Code": "function _execute(bytes memory data, bytes memory sig) internal {\n        address signer = ECDSA.recover(ECDSA.toEthSignedMessageHash(keccak256(data)), sig);\n\n        (\n            uint256 chainId,\n            Role signerRole,\n            bytes32[] memory commandIds,\n            string[] memory commands,\n            bytes[] memory params\n        ) = abi.decode(data, (uint256, Role, bytes32[], string[], bytes[]));\n\n        if (chainId != block.chainid) revert InvalidChainId();\n\n        uint256 commandsLength = commandIds.length;\n\n        if (commandsLength != commands.length || commandsLength != params.length) revert InvalidCommands();\n\n        bool isCurrentOwner;\n        bool isValidRecentOwner;\n        bool isValidRecentOperator;\n\n        if (signerRole == Role.Owner) {\n            isCurrentOwner = signer == owner();\n            isValidRecentOwner = isCurrentOwner || _isValidPreviousOwner(signer);\n        } else if (signerRole == Role.Operator) {\n            isValidRecentOperator = _isValidRecentOperator(signer);\n        }\n\n        for (uint256 i; i < commandsLength; i++) {\n            bytes32 commandId = commandIds[i];\n\n            if (isCommandExecuted(commandId)) continue; /* Ignore if duplicate commandId received */\n\n            bytes4 commandSelector;\n            bytes32 commandHash = keccak256(abi.encodePacked(commands[i]));\n\n            if (commandHash == SELECTOR_DEPLOY_TOKEN) {\n                if (!isValidRecentOwner) continue;\n\n                commandSelector = AxelarGatewaySinglesig.deployToken.selector;\n            } else if (commandHash == SELECTOR_MINT_TOKEN) {\n                if (!isValidRecentOperator && !isValidRecentOwner) continue;\n\n                commandSelector = AxelarGatewaySinglesig.mintToken.selector;\n            } else if (commandHash == SELECTOR_APPROVE_CONTRACT_CALL) {\n                if (!isValidRecentOperator && !isValidRecentOwner) continue;\n\n                commandSelector = AxelarGatewaySinglesig.approveContractCall.selector;\n            } else if (commandHash == SELECTOR_APPROVE_CONTRACT_CALL_WITH_MINT) {\n                if (!isValidRecentOperator && !isValidRecentOwner) continue;\n\n                commandSelector = AxelarGatewaySinglesig.approveContractCallWithMint.selector;\n            } else if (commandHash == SELECTOR_BURN_TOKEN) {\n                if (!isValidRecentOperator && !isValidRecentOwner) continue;\n\n                commandSelector = AxelarGatewaySinglesig.burnToken.selector;\n            } else if (commandHash == SELECTOR_TRANSFER_OWNERSHIP) {\n                if (!isCurrentOwner) continue;\n\n                commandSelector = AxelarGatewaySinglesig.transferOwnership.selector;\n            } else if (commandHash == SELECTOR_TRANSFER_OPERATORSHIP) {\n                if (!isCurrentOwner) continue;\n\n                commandSelector = AxelarGatewaySinglesig.transferOperatorship.selector;\n            } else {\n                continue; /* Ignore if unknown command received */\n            }\n\n            // Prevent a re-entrancy from executing this command before it can be marked as successful.\n            _setCommandExecuted(commandId, true);\n            (bool success, ) = address(this).call(abi.encodeWithSelector(commandSelector, params[i], commandId));\n            _setCommandExecuted(commandId, success);\n\n            if (success) {\n                emit Executed(commandId);\n            }\n        }\n    }"
}