syntax = "proto3";
package gravity.v1;

import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";


option go_package = "github.com/Gravity-Bridge/Gravity-Bridge/module/x/gravity/types";

// ClaimType is the cosmos type of an event from the counterpart chain that can
// be handled
enum ClaimType {
  option (gogoproto.goproto_enum_prefix) = false;

  // An unspecified claim type
  CLAIM_TYPE_UNSPECIFIED         = 0;
  // A claim for a SendToCosmos transaction
  CLAIM_TYPE_SEND_TO_COSMOS      = 1;
  // A claim for when batches are relayed
  CLAIM_TYPE_BATCH_SEND_TO_ETH   = 2;
  // A claim for when an erc20 contract has been deployed
  CLAIM_TYPE_ERC20_DEPLOYED      = 3;
  // A claim for when a logic call has been executed
  CLAIM_TYPE_LOGIC_CALL_EXECUTED = 4;
  // A claim for when a valset update has happened
  CLAIM_TYPE_VALSET_UPDATED      = 5;
}

// Attestation is an aggregate of `claims` that eventually becomes `observed` by
// all orchestrators
// EVENT_NONCE:
// EventNonce a nonce provided by the gravity contract that is unique per event fired
// These event nonces must be relayed in order. This is a correctness issue,
// if relaying out of order transaction replay attacks become possible
// OBSERVED:
// Observed indicates that >67% of validators have attested to the event,
// and that the event should be executed by the gravity state machine
//
// The actual content of the claims is passed in with the transaction making the claim
// and then passed through the call stack alongside the attestation while it is processed
// the key in which the attestation is stored is keyed on the exact details of the claim
// but there is no reason to store those exact details becuause the next message sender
// will kindly provide you with them.
message Attestation {
  bool                observed = 1;
  repeated string     votes    = 2;
  uint64              height   = 3;
  google.protobuf.Any claim    = 4;
}

// ERC20Token unique identifier for an Ethereum ERC20 token.
// CONTRACT:
// The contract address on ETH of the token, this could be a Cosmos
// originated token, if so it will be the ERC20 address of the representation
// (note: developers should look up the token symbol using the address on ETH to display for UI)
message ERC20Token {
  string contract = 1;
  string amount   = 2 [
    (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
    (gogoproto.nullable)   = false
  ];
}

message EventObservation {
  string attestation_type = 1;
  string bridge_contract  = 2;
  string bridge_chain_id  = 3;
  string attestation_id   = 4;
  string nonce            = 5;
}

message EventInvalidSendToCosmosReceiver {
  string amount = 1;
  string nonce  = 2;
  string token  = 3;
  string sender = 4;
}

message EventSendToCosmos {
  string amount = 1;
  string nonce  = 2;
  string token  = 3;
}

message EventSendToCosmosLocal {
  string nonce = 1;
  string receiver = 2;
  string token = 3;
  string amount = 4;
}

message EventSendToCosmosPendingIbcAutoForward {
  string nonce = 1;
  string receiver = 2;
  string token = 3;
  string amount = 4;
  string channel = 5;
}

message EventSendToCosmosExecutedIbcAutoForward {
  string nonce = 1;
  string receiver = 2;
  string token = 3;
  string amount = 4;
  string channel = 5;
  string timeout_time = 6;
  string timeout_height = 7;
}