syntax = "proto3";
package provenance.ledger.v1;

import "gogoproto/gogo.proto";

option go_package          = "github.com/provenance-io/provenance/x/ledger/types";
option java_package        = "io.provenance.ledger.v1";
option java_multiple_files = true;

// EventLedgerCreated is emitted when a new ledger is created for an asset.
// This event is triggered by the MsgCreateLedger message handler when a
// ledger is successfully created for a specific NFT or scope.
message EventLedgerCreated {
  // asset class of the ledger.
  string asset_class_id = 1;

  // nft id of the ledger (scope id or nft id).
  string nft_id = 2;
}

// EventLedgerUpdated is emitted when a ledger's configuration is updated.
// This event is triggered by various update message handlers such as
// MsgUpdateLedgerStatus, MsgUpdateLedgerInterestRate, MsgUpdateLedgerPayment,
// and MsgUpdateLedgerMaturityDate when a ledger's configuration is
// successfully modified.
message EventLedgerUpdated {
  // asset class of the ledger.
  string asset_class_id = 1;

  // nft id of the ledger (scope id or nft id).
  string nft_id = 2;

  // What type of data update caused this event to be emitted.
  UpdateType update_type = 3;
}

// UpdateType is the type of data update that caused the EventLedgerUpdated event to be emitted.
// This is used to identify the specific update that caused the event to be emitted.
enum UpdateType {
  option (gogoproto.goproto_enum_prefix)   = false;
  option (gogoproto.goproto_enum_stringer) = true;

  // The update type is unspecified.
  UPDATE_TYPE_UNSPECIFIED = 0;

  // The status of the ledger was updated.
  UPDATE_TYPE_STATUS = 1;

  // The interest rate of the ledger was updated.
  UPDATE_TYPE_INTEREST_RATE = 2;

  // The payment of the ledger was updated.
  UPDATE_TYPE_PAYMENT = 3;

  // The maturity date of the ledger was updated.
  UPDATE_TYPE_MATURITY_DATE = 4;
}

// EventLedgerEntryAdded is emitted when a new entry is added to a ledger.
// This event is triggered by the MsgAppendLedgerEntry message handler when
// one or more ledger entries are successfully added to an existing ledger.
message EventLedgerEntryAdded {
  // asset class of the ledger.
  string asset_class_id = 1;

  // nft id of the ledger (scope id or nft id).
  string nft_id = 2;

  // correlation id of the ledger entry.
  string correlation_id = 3;
}

// EventLedgerEntryUpdated is emitted when an existing ledger entry is updated.
// This event is triggered by the UpdateBalances message handler when a ledger
// entry is successfully updated.
message EventLedgerEntryUpdated {
  // asset class of the ledger.
  string asset_class_id = 1;

  // nft id of the ledger (scope id or nft id).
  string nft_id = 2;

  // correlation id of the ledger entry.
  string correlation_id = 3;
}

// EventFundTransferWithSettlement is emitted when funds are transferred with
// settlement instructions. This event is triggered by the
// MsgTransferFundsWithSettlement message handler when a fund transfer with
// settlement instructions is successfully processed.
message EventFundTransferWithSettlement {
  // asset class of the ledger.
  string asset_class_id = 1;

  // nft id of the ledger (scope id or nft id).
  string nft_id = 2;

  // correlation id of the ledger entry.
  string correlation_id = 3;
}

// EventLedgerDestroyed is emitted when a ledger is destroyed.
// This event is triggered by the MsgDestroyLedger message handler when
// a ledger and all its associated data are successfully removed.
message EventLedgerDestroyed {
  // asset class of the ledger.
  string asset_class_id = 1;

  // nft id of the ledger (scope id or nft id).
  string nft_id = 2;
}

// EventLedgerClassCreated is emitted when a ledger class is created.
// This event is triggered by the MsgCreateLedgerClassRequest message handler
// when a new ledger class is created.
message EventLedgerClassCreated {
  // The id of the ledger class that was created.
  string ledger_class_id = 1;
  // The id of the asset class that the ledger class was created for.
  string asset_class_id = 2;
  // The denom that this ledger class uses.
  string denom = 3;
}

// EventLedgerClassTypeCreated is emitted when any type for a ledger class is created.
// This event is triggered by the MsgAddLedgerClassStatusTypeRequest, MsgAddLedgerClassEntryTypeRequest,
// and MsgAddLedgerClassBucketTypeRequest message handlers when they create their respective types.
message EventLedgerClassTypeCreated {
  // The id of the ledger class that the type was created.
  string ledger_class_id = 1;
  // The specific type of thing that was created.
  ClassTypeCreated type_created = 2;
  // The id of the created type.
  string id = 3;
  // The code of the created type.
  string code = 4;
}

// ClassTypeCreated is the type of data that caused the EventLedgerClassTypeCreated event to be emitted.
// This is used to identify the specific type that was just created.
enum ClassTypeCreated {
  option (gogoproto.goproto_enum_prefix)   = false;
  option (gogoproto.goproto_enum_stringer) = true;

  // CLASS_TYPE_CREATED_UNSPECIFIED indicates that the class type is unspecified.
  CLASS_TYPE_CREATED_UNSPECIFIED = 0;
  // CLASS_TYPE_CREATED_STATUS is for when a LedgerClassStatusType is created.
  CLASS_TYPE_CREATED_STATUS = 1;
  // CLASS_TYPE_CREATED_ENTRY is for when a LedgerClassEntryType is created.
  CLASS_TYPE_CREATED_ENTRY = 2;
  // CLASS_TYPE_CREATED_BUCKET is for when a LedgerClassBucketType is created.
  CLASS_TYPE_CREATED_BUCKET = 3;
}
