syntax = "proto3";

package protocol;

option java_package = "org.tron.protos.contract"; //Specify the name of the package that generated the Java file
//option java_outer_classname = "CreateSmartContract"; //Specify the class name of the generated Java file
option go_package = "github.com/tronprotocol/grpc-gateway/core";

import "core/Tron.proto";

message SmartContract {
  message ABI {
    message Entry {
      enum EntryType {
        UnknownEntryType = 0;
        Constructor = 1;
        Function = 2;
        Event = 3;
        Fallback = 4;
        Receive = 5;
        Error = 6;
      }
      message Param {
        bool indexed = 1;
        string name = 2;
        string type = 3;
        // SolidityType type = 3;
      }
      enum StateMutabilityType {
        UnknownMutabilityType = 0;
        Pure = 1;
        View = 2;
        Nonpayable = 3;
        Payable = 4;
      }

      bool anonymous = 1;
      bool constant = 2;
      string name = 3;
      repeated Param inputs = 4;
      repeated Param outputs = 5;
      EntryType type = 6;
      bool payable = 7;
      StateMutabilityType stateMutability = 8;
    }
    repeated Entry entrys = 1;
  }
  bytes origin_address = 1;
  bytes contract_address = 2;
  ABI abi = 3;
  bytes bytecode = 4;
  int64 call_value = 5;
  int64 consume_user_resource_percent = 6;
  string name = 7;
  int64 origin_energy_limit = 8;
  bytes code_hash = 9;
  bytes trx_hash = 10;
  int32 version = 11;
}

message ContractState {
  int64 energy_usage = 1;
  int64 energy_factor = 2;
  int64 update_cycle = 3;
}

message CreateSmartContract {
  bytes owner_address = 1;
  SmartContract new_contract = 2;
  int64 call_token_value = 3;
  int64 token_id = 4;
}

message TriggerSmartContract {
  bytes owner_address = 1;
  bytes contract_address = 2;
  int64 call_value = 3;
  bytes data = 4;
  int64 call_token_value = 5;
  int64 token_id = 6;
}

message ClearABIContract {
  bytes owner_address = 1;
  bytes contract_address = 2;
}

message UpdateSettingContract {
  bytes owner_address = 1;
  bytes contract_address = 2;
  int64 consume_user_resource_percent = 3;
}

message UpdateEnergyLimitContract {
  bytes owner_address = 1;
  bytes contract_address = 2;
  int64 origin_energy_limit = 3;
}

message SmartContractDataWrapper {
  SmartContract smart_contract = 1;
  bytes runtimecode = 2;
  ContractState contract_state = 3;
}
