syntax = "proto3";

package spy.v1;

option go_package = "github.com/certusone/wormhole/node/pkg/proto/spy/v1;spyv1";

import "google/api/annotations.proto";
import "gossip/v1/gossip.proto";
import "publicrpc/v1/publicrpc.proto";

// SpyRPCService exposes a gossip introspection service, allowing sniffing of gossip messages.
service SpyRPCService {
  // SubscribeSignedVAA returns a stream of signed VAA messages received on the network.
  rpc SubscribeSignedVAA (SubscribeSignedVAARequest) returns (stream SubscribeSignedVAAResponse) {
    option (google.api.http) = {
      post: "/v1:subscribe_signed_vaa"
      body: "*"
    };
  }
}

// A MessageFilter represents an exact match for an emitter.
message EmitterFilter {
  // Source chain
  publicrpc.v1.ChainID chain_id = 1;
  // Hex-encoded (without leading 0x) emitter address.
  string emitter_address = 2;
}


message BatchFilter {
  // Source chain
  publicrpc.v1.ChainID chain_id = 1;
  // Native transaction identifier bytes.
  bytes tx_id = 2;
  // Nonce of the messages in the batch.
  uint32 nonce = 3;
}

message BatchTransactionFilter {
  // Source chain
  publicrpc.v1.ChainID chain_id = 1;
  // Native transaction identifier bytes.
  bytes tx_id = 2;
}

message FilterEntry {
  oneof filter {
    EmitterFilter emitter_filter = 1;
    BatchFilter batch_filter = 2;
    BatchTransactionFilter batch_transaction_filter = 3;
  }
}

message SubscribeSignedVAARequest {
  // List of filters to apply to the stream (OR).
  // If empty, all messages are streamed.
  repeated FilterEntry filters = 1;
}

message SubscribeSignedVAAResponse {
  // Raw VAA bytes
  bytes vaa_bytes = 1;
}
