// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

/// @title IWormhole
/// @author The Wormhole Team
/// @notice A trimmed version of the core Wormhole contract interface
/// @dev https://github.com/wormhole-foundation/wormhole/blob/44273c06417ce858d092d8a007359d5119f44ddb/ethereum/contracts/interfaces/IWormhole.sol#L4
interface IWormhole {
    /// @notice Guardian signature with signer index.
    /// @dev The fields are as follows:
    ///      - r - Signature r value.
    ///      - s - Signature s value.
    ///      - v - Signature v value.
    ///      - guardianIndex - Index of the signer in the guardian set.
    struct Signature {
        bytes32 r;
        bytes32 s;
        uint8 v;
        uint8 guardianIndex;
    }

    /// @notice Contents of a guardian-signed attestation
    /// @dev Consult the Wormhole documentation for the meaning of these fields.
    struct VM {
        uint8 version;
        uint32 timestamp;
        uint32 nonce;
        uint16 emitterChainId;
        bytes32 emitterAddress;
        uint64 sequence;
        uint8 consistencyLevel;
        bytes payload;
        uint32 guardianSetIndex;
        Signature[] signatures;
        bytes32 hash;
    }

    /// @notice Publish a statement for signing by the Guardians.
    /// @param nonce - An application-provided number with no meaning.
    /// @param payload - The payload to be signed.
    /// @param consistencyLevel - The consistency level of the message.
    ///        according to Wormhole Guardian VAA specification.
    /// @return sequence - A sequence number identifying the message. By
    ///         specification this is a strictly increasing integer.
    function publishMessage(uint32 nonce, bytes memory payload, uint8 consistencyLevel)
        external
        payable
        returns (uint64 sequence);

    /// @notice Verify a guardian-signed VAA, extracting the payload.
    /// @param encodedVM - The encoded VAA.
    /// @dev This call will NOT revert if the VAA is invalid. Instead it will
    ///      return a `valid` flag indicating whether the VAA is valid. If the
    ///      VAA is invalid, the `vm` struct content is undefined and
    ///      unreliable. The caller MUST check the `valid` flag before using
    ///      the returns VM.
    /// @return vm - The decoded VAA, if valid. If the VAA is not valid, the
    ///              content of this struct is undefined. It may be empty or
    ///              partially decoded or contain junk. Caller MUST check the
    ///              `valid` return value before using the VAA.
    /// @return valid - Whether the VAA is valid.
    /// @return reason - If the VAA is invalid, a string describing the reason.
    function parseAndVerifyVM(bytes calldata encodedVM)
        external
        view
        returns (VM memory vm, bool valid, string memory reason);

    /// @notice Get the chain ID of the current chain
    function chainId() external view returns (uint16);

    /// @notice Returns true if the stored EVM chain ID does not match the
    ///         current chain ID. This indicates that the chain has forked.
    function isFork() external view returns (bool);

    /// @notice Get next sequence for the emitter.
    /// @param emitter - The address of the sender.
    /// @return sequence - A sequence number identifying the message. By
    ///         specification this is a strictly increasing integer.
    function nextSequence(address emitter) external view returns (uint64);
}
[{"inputs":[{"internalType":"address","name":"attestor","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ATTESTOR","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"core","type":"address"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"deploy","outputs":[],"stateMutability":"nonpayable","type":"function"}]