syntax = "proto3";

package fetch.aea.LedgerApi;

message LedgerApiMessage{

    // Custom Types
    message RawTransaction{
        bytes raw_transaction = 1;
    }

    message SignedTransaction{
        bytes signed_transaction = 1;
    }

    message Terms{
        bytes terms = 1;
    }

    message TransactionDigest{
        bytes transaction_digest = 1;
    }

    message TransactionReceipt{
        bytes transaction_receipt = 1;
    }


    // Performatives and contents
    message Get_Balance_Performative{
        string ledger_id = 1;
        string address = 2;
    }

    message Get_Raw_Transaction_Performative{
        Terms terms = 1;
    }

    message Send_Signed_Transaction_Performative{
        SignedTransaction signed_transaction = 1;
    }

    message Get_Transaction_Receipt_Performative{
        TransactionDigest transaction_digest = 1;
    }

    message Balance_Performative{
        string ledger_id = 1;
        int32 balance = 2;
    }

    message Raw_Transaction_Performative{
        RawTransaction raw_transaction = 1;
    }

    message Transaction_Digest_Performative{
        TransactionDigest transaction_digest = 1;
    }

    message Transaction_Receipt_Performative{
        TransactionReceipt transaction_receipt = 1;
    }

    message Error_Performative{
        int32 code = 1;
        string message = 2;
        bool message_is_set = 3;
        bytes data = 4;
        bool data_is_set = 5;
    }


    // Standard LedgerApiMessage fields
    int32 message_id = 1;
    string dialogue_starter_reference = 2;
    string dialogue_responder_reference = 3;
    int32 target = 4;
    oneof performative{
        Balance_Performative balance = 5;
        Error_Performative error = 6;
        Get_Balance_Performative get_balance = 7;
        Get_Raw_Transaction_Performative get_raw_transaction = 8;
        Get_Transaction_Receipt_Performative get_transaction_receipt = 9;
        Raw_Transaction_Performative raw_transaction = 10;
        Send_Signed_Transaction_Performative send_signed_transaction = 11;
        Transaction_Digest_Performative transaction_digest = 12;
        Transaction_Receipt_Performative transaction_receipt = 13;
    }
}
