// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

syntax = "proto3";

import "lcommon.proto";

package types;
option go_package = "../types";

message AutonomyProposalRule {
    ProposalRule propRule = 1;
    RuleConfig   curRule  = 2;
    // 全体持票人投票结果
    VoteResult voteResult = 3;
    // 状态
    int32  status     = 4;
    string address    = 5;
    int64  height     = 6;
    int32  index      = 7;
    string proposalID = 8;
}

message ProposalRule {
    // 提案时间
    int32 year  = 1;
    int32 month = 2;
    int32 day   = 3;

    // 规则可修改项,如果某项不修改则置为-1
    RuleConfig ruleCfg = 4;
    // 投票相关
    int64 startBlockHeight   = 5; // 提案开始投票高度
    int64 endBlockHeight     = 6; // 提案结束投票高度
    int64 realEndBlockHeight = 7; // 实际提案结束投票高度
}

message RevokeProposalRule {
    string proposalID = 1;
}

message VoteProposalRule {
    string   proposalID        = 1;
    bool     approve           = 2;
    repeated string originAddr = 3;
    AutonomyVoteOption vote            = 4;
}

message TerminateProposalRule {
    string proposalID = 1;
}

// receipt
message ReceiptProposalRule {
    AutonomyProposalRule prev    = 1;
    AutonomyProposalRule current = 2;
}

message LocalProposalRule {
    AutonomyProposalRule propRule = 1;
    repeated string comments      = 2;
}

// query
message ReqQueryProposalRule {
    int32  status    = 1;
    string addr      = 2;
    int32  count     = 3;
    int32  direction = 4;
    int64  height    = 5;
    int32  index     = 6;
}

message ReplyQueryProposalRule {
    repeated AutonomyProposalRule propRules = 1;
}

// TransferFund action
message TransferFund {
    int64  amount = 1;
    string note   = 2;
}

// Comment action
message Comment {
    string proposalID = 1;
    string repHash    = 2;
    string comment    = 3;
}

message ReceiptProposalComment {
    Comment cmt    = 1;
    int64   height = 2;
    int32   index  = 3;
    string  hash   = 4;
}

// query
message ReqQueryProposalComment {
    string proposalID = 1;
    int32  count      = 2;
    int32  direction  = 3;
    int64  height     = 4;
    int32  index      = 5;
}

message RelationCmt {
    string repHash = 1;
    string comment = 2;
    int64  height  = 3;
    int32  index   = 4;
    string hash    = 5;
}

message ReplyQueryProposalComment {
    repeated RelationCmt rltCmt = 1;
}
