Commit fb8defde authored by liuyuhang's avatar liuyuhang

add show active rule

parent 12851cc2
...@@ -51,6 +51,7 @@ func AutonomyCmd() *cobra.Command { ...@@ -51,6 +51,7 @@ func AutonomyCmd() *cobra.Command {
VoteProposalRuleCmd(), VoteProposalRuleCmd(),
TerminateProposalRuleCmd(), TerminateProposalRuleCmd(),
ShowProposalRuleCmd(), ShowProposalRuleCmd(),
ShowActiveRuleCmd(),
) )
cmd.AddCommand( cmd.AddCommand(
...@@ -264,7 +265,7 @@ func terminateProposalBoard(cmd *cobra.Command, args []string) { ...@@ -264,7 +265,7 @@ func terminateProposalBoard(cmd *cobra.Command, args []string) {
// ShowProposalBoardCmd 显示提案查询信息 // ShowProposalBoardCmd 显示提案查询信息
func ShowProposalBoardCmd() *cobra.Command { func ShowProposalBoardCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "showBoardInfo", Use: "showBoard",
Short: "show proposal board info", Short: "show proposal board info",
Run: showProposalBoard, Run: showProposalBoard,
} }
...@@ -327,8 +328,8 @@ func showProposalBoard(cmd *cobra.Command, args []string) { ...@@ -327,8 +328,8 @@ func showProposalBoard(cmd *cobra.Command, args []string) {
// ShowActiveBoardCmd 显示提案查询信息 // ShowActiveBoardCmd 显示提案查询信息
func ShowActiveBoardCmd() *cobra.Command { func ShowActiveBoardCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "showActiveBoardInfo", Use: "showActiveBoard",
Short: "show active board info", Short: "show active board",
Run: showActiveBoard, Run: showActiveBoard,
} }
return cmd return cmd
......
...@@ -221,7 +221,7 @@ func terminateProposalChange(cmd *cobra.Command, args []string) { ...@@ -221,7 +221,7 @@ func terminateProposalChange(cmd *cobra.Command, args []string) {
// ShowProposalChangeCmd 显示提案查询信息 // ShowProposalChangeCmd 显示提案查询信息
func ShowProposalChangeCmd() *cobra.Command { func ShowProposalChangeCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "showChangeInfo", Use: "showChange",
Short: "show proposal change info", Short: "show proposal change info",
Run: showProposalChange, Run: showProposalChange,
} }
......
...@@ -283,7 +283,7 @@ func terminateProposalProject(cmd *cobra.Command, args []string) { ...@@ -283,7 +283,7 @@ func terminateProposalProject(cmd *cobra.Command, args []string) {
// ShowProposalProjectCmd 显示提案查询信息 // ShowProposalProjectCmd 显示提案查询信息
func ShowProposalProjectCmd() *cobra.Command { func ShowProposalProjectCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "showProjectInfo", Use: "showProject",
Short: "show proposal project info", Short: "show proposal project info",
Run: showProposalProject, Run: showProposalProject,
} }
......
...@@ -221,7 +221,7 @@ func terminateProposalRule(cmd *cobra.Command, args []string) { ...@@ -221,7 +221,7 @@ func terminateProposalRule(cmd *cobra.Command, args []string) {
// ShowProposalRuleCmd 显示提案查询信息 // ShowProposalRuleCmd 显示提案查询信息
func ShowProposalRuleCmd() *cobra.Command { func ShowProposalRuleCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "showRuleInfo", Use: "showRule",
Short: "show proposal rule info", Short: "show proposal rule info",
Run: showProposalRule, Run: showProposalRule,
} }
...@@ -281,6 +281,29 @@ func showProposalRule(cmd *cobra.Command, args []string) { ...@@ -281,6 +281,29 @@ func showProposalRule(cmd *cobra.Command, args []string) {
ctx.Run() ctx.Run()
} }
// ShowActiveRuleCmd 显示提案查询信息
func ShowActiveRuleCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "showActiveRule",
Short: "show active rule",
Run: showActiveRule,
}
return cmd
}
func showActiveRule(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
params := rpctypes.Query4Jrpc{}
params.Execer = auty.AutonomyX
params.FuncName = auty.GetActiveRule
params.Payload = types.MustPBToJSON(&types.ReqString{})
rep := &auty.RuleConfig{}
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, rep)
ctx.Run()
}
// TransferFundCmd 资金转入自治系统合约中 // TransferFundCmd 资金转入自治系统合约中
func TransferFundCmd() *cobra.Command { func TransferFundCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
......
...@@ -44,6 +44,11 @@ func (a *Autonomy) Query_ListProposalRule(in *auty.ReqQueryProposalRule) (types. ...@@ -44,6 +44,11 @@ func (a *Autonomy) Query_ListProposalRule(in *auty.ReqQueryProposalRule) (types.
return a.listProposalRule(in) return a.listProposalRule(in)
} }
// Query_GetActiveRule 查询当前rule
func (a *Autonomy) Query_GetActiveRule(in *types.ReqString) (types.Message, error) {
return a.getActiveRule()
}
// Query_ListProposalComment 批量查询提案评论 // Query_ListProposalComment 批量查询提案评论
func (a *Autonomy) Query_ListProposalComment(in *auty.ReqQueryProposalComment) (types.Message, error) { func (a *Autonomy) Query_ListProposalComment(in *auty.ReqQueryProposalComment) (types.Message, error) {
return a.listProposalComment(in) return a.listProposalComment(in)
......
...@@ -124,6 +124,24 @@ func (a *Autonomy) listProposalRule(req *auty.ReqQueryProposalRule) (types.Messa ...@@ -124,6 +124,24 @@ func (a *Autonomy) listProposalRule(req *auty.ReqQueryProposalRule) (types.Messa
return &rep, nil return &rep, nil
} }
func (a *Autonomy) getActiveRule() (types.Message, error) {
rule := &auty.RuleConfig{}
value, err := a.GetStateDB().Get(activeRuleID())
if err == nil {
err = types.Decode(value, rule)
if err != nil {
return nil, err
}
} else { // 载入系统默认值
rule.BoardApproveRatio = boardApproveRatio
rule.PubOpposeRatio = pubOpposeRatio
rule.ProposalAmount = proposalAmount
rule.LargeProjectAmount = largeProjectAmount
rule.PublicPeriod = publicPeriod
}
return rule, nil
}
func (a *Autonomy) execAutoLocalCommentProp(tx *types.Transaction, receiptData *types.ReceiptData) (*types.LocalDBSet, error) { func (a *Autonomy) execAutoLocalCommentProp(tx *types.Transaction, receiptData *types.ReceiptData) (*types.LocalDBSet, error) {
set, err := a.execLocalCommentProp(receiptData) set, err := a.execLocalCommentProp(receiptData)
if err != nil { if err != nil {
......
...@@ -58,6 +58,7 @@ func TestJRPCChannel(t *testing.T) { ...@@ -58,6 +58,7 @@ func TestJRPCChannel(t *testing.T) {
{fn: testTerminateProposalRuleTxCmd}, {fn: testTerminateProposalRuleTxCmd},
{fn: testGetProposalRuleCmd}, {fn: testGetProposalRuleCmd},
{fn: testListProposalRuleCmd}, {fn: testListProposalRuleCmd},
{fn: testGetActiveRuleCmd},
{fn: testTransferFundTxCmd}, {fn: testTransferFundTxCmd},
{fn: testCommentProposalTxCmd}, {fn: testCommentProposalTxCmd},
......
...@@ -97,6 +97,15 @@ func testListProposalRuleCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { ...@@ -97,6 +97,15 @@ func testListProposalRuleCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
return jrpc.Call("Chain33.Query", params, rep) return jrpc.Call("Chain33.Query", params, rep)
} }
func testGetActiveRuleCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{}
var params rpctypes.Query4Jrpc
params.FuncName = auty.GetActiveRule
params.Payload = types.MustPBToJSON(&types.ReqString{})
rep = &auty.RuleConfig{}
return jrpc.Call("Chain33.Query", params, rep)
}
func testTransferFundTxCmd(t *testing.T, jrpc *jsonclient.JSONClient) error { func testTransferFundTxCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
params := &auty.TransferFund{} params := &auty.TransferFund{}
payLoad, err := json.Marshal(params) payLoad, err := json.Marshal(params)
......
...@@ -103,6 +103,8 @@ const ( ...@@ -103,6 +103,8 @@ const (
GetProposalRule = "GetProposalRule" GetProposalRule = "GetProposalRule"
// ListProposalRule 查询多个 // ListProposalRule 查询多个
ListProposalRule = "ListProposalRule" ListProposalRule = "ListProposalRule"
// GetActiveRule 查询当前的
GetActiveRule = "GetActiveRule"
// ListProposalComment 查询多个 // ListProposalComment 查询多个
ListProposalComment = "ListProposalComment" ListProposalComment = "ListProposalComment"
// GetProposalChange 用于在cmd里面的区分不同的查询 // GetProposalChange 用于在cmd里面的区分不同的查询
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment