commit
7fab7fc458
30
go.mod
30
go.mod
|
@ -1,20 +1,32 @@
|
||||||
module github.com/changtong1996/djzh
|
module github.com/changtong1996/djzh
|
||||||
go 1.13
|
|
||||||
|
go 1.14
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/99designs/keyring v1.1.4 // indirect
|
||||||
github.com/btcsuite/btcd v0.0.0-20190807005414-4063feeff79a // indirect
|
github.com/btcsuite/btcd v0.0.0-20190807005414-4063feeff79a // indirect
|
||||||
github.com/cosmos/cosmos-sdk v0.38.0
|
github.com/cosmos/cosmos-sdk v0.38.3
|
||||||
github.com/golang/mock v1.3.1 // indirect
|
github.com/gibson042/canonicaljson-go v1.0.3 // indirect
|
||||||
|
github.com/golang/mock v1.4.3 // indirect
|
||||||
|
github.com/gorilla/handlers v1.4.2 // indirect
|
||||||
|
github.com/gorilla/mux v1.7.4
|
||||||
github.com/onsi/ginkgo v1.8.0 // indirect
|
github.com/onsi/ginkgo v1.8.0 // indirect
|
||||||
github.com/onsi/gomega v1.5.0 // indirect
|
github.com/onsi/gomega v1.5.0 // indirect
|
||||||
github.com/prometheus/client_golang v1.1.0 // indirect
|
github.com/otiai10/copy v1.1.1
|
||||||
|
github.com/pelletier/go-toml v1.7.0 // indirect
|
||||||
|
github.com/pkg/errors v0.9.1
|
||||||
|
github.com/rakyll/statik v0.1.7 // indirect
|
||||||
github.com/rcrowley/go-metrics v0.0.0-20190706150252-9beb055b7962 // indirect
|
github.com/rcrowley/go-metrics v0.0.0-20190706150252-9beb055b7962 // indirect
|
||||||
|
github.com/regen-network/cosmos-proto v0.1.1-0.20200213154359-02baa11ea7c2 // indirect
|
||||||
|
github.com/snikch/goodman v0.0.0-20171125024755-10e37e294daa
|
||||||
github.com/spf13/afero v1.2.2 // indirect
|
github.com/spf13/afero v1.2.2 // indirect
|
||||||
github.com/spf13/cobra v0.0.5
|
github.com/spf13/cobra v0.0.7
|
||||||
github.com/spf13/viper v1.6.2
|
github.com/spf13/viper v1.6.3
|
||||||
|
github.com/stretchr/testify v1.5.1
|
||||||
github.com/tendermint/go-amino v0.15.1
|
github.com/tendermint/go-amino v0.15.1
|
||||||
github.com/tendermint/tendermint v0.33.0
|
github.com/tendermint/iavl v0.13.3 // indirect
|
||||||
github.com/tendermint/tm-db v0.4.0
|
github.com/tendermint/tendermint v0.33.3
|
||||||
|
github.com/tendermint/tm-db v0.5.1
|
||||||
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 // indirect
|
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 // indirect
|
||||||
golang.org/x/text v0.3.2 // indirect
|
google.golang.org/protobuf v1.20.1 // indirect
|
||||||
)
|
)
|
|
@ -26,7 +26,7 @@ type CreateArticleReq struct {
|
||||||
Tid string `json:"tid"`
|
Tid string `json:"tid"`
|
||||||
Uid string `json:"uid"`
|
Uid string `json:"uid"`
|
||||||
A_timestamp string `json:"a_timestamp"`
|
A_timestamp string `json:"a_timestamp"`
|
||||||
Reward sdk.Coins `json:"reward"` // reward of the article
|
Reward string `json:"reward"` // reward of the article
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateArticleHandler(cliCtx context.CLIContext) http.HandlerFunc{
|
func CreateArticleHandler(cliCtx context.CLIContext) http.HandlerFunc{
|
||||||
|
@ -49,8 +49,13 @@ func CreateArticleHandler(cliCtx context.CLIContext) http.HandlerFunc{
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
coins, err := sdk.ParseCoins(req.Reward)
|
||||||
|
if err != nil {
|
||||||
|
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
// create the message
|
// create the message
|
||||||
msg := types.NewMsgCreateArticle(addr, req.A_text, req.A_title, req.Tag, req.Article_id, req.Tid, req.Uid, req.A_timestamp, req.Reward)
|
msg := types.NewMsgCreateArticle(addr, req.A_text, req.A_title, req.Tag, req.Article_id, req.Tid, req.Uid, req.A_timestamp, coins)
|
||||||
err = msg.ValidateBasic()
|
err = msg.ValidateBasic()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
||||||
|
@ -72,7 +77,7 @@ type CreateCommentReq struct {
|
||||||
Uid string `json:"uid"` // id of the user
|
Uid string `json:"uid"` // id of the user
|
||||||
C_timestamp string `json:"c_timestamp"` // timestamp of the comment
|
C_timestamp string `json:"c_timestamp"` // timestamp of the comment
|
||||||
C_text string `json:"c_text"` // context of the comment
|
C_text string `json:"c_text"` // context of the comment
|
||||||
Reward sdk.Coins `json:"reward"`
|
Reward string `json:"reward"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateCommentHandler(cliCtx context.CLIContext) http.HandlerFunc {
|
func CreateCommentHandler(cliCtx context.CLIContext) http.HandlerFunc {
|
||||||
|
@ -95,8 +100,14 @@ func CreateCommentHandler(cliCtx context.CLIContext) http.HandlerFunc {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
coins, err := sdk.ParseCoins(req.Reward)
|
||||||
|
if err != nil {
|
||||||
|
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// create the message
|
// create the message
|
||||||
msg := types.NewMsgCreateComment(addr, req.Comment_id, req.Article_id, req.Tid, req.Uid, req.C_timestamp, req.C_text, req.Reward)
|
msg := types.NewMsgCreateComment(addr, req.Comment_id, req.Article_id, req.Tid, req.Uid, req.C_timestamp, req.C_text, coins)
|
||||||
err = msg.ValidateBasic()
|
err = msg.ValidateBasic()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
||||||
|
@ -119,8 +130,7 @@ type CreateReturnVisitReq struct {
|
||||||
Rv_timestamp string `json:"rv_timestamp"`
|
Rv_timestamp string `json:"rv_timestamp"`
|
||||||
Rv_text string `json:"rv_text"`
|
Rv_text string `json:"rv_text"`
|
||||||
Flag string `json:"flag"`
|
Flag string `json:"flag"`
|
||||||
Reward sdk.Coins `json:"reward"` // reward of the article
|
Reward string `json:"reward"` // reward of the article
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -144,8 +154,14 @@ func CreateReturnVisitHandler(cliCtx context.CLIContext) http.HandlerFunc {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
coins, err := sdk.ParseCoins(req.Reward)
|
||||||
|
if err != nil {
|
||||||
|
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// create the message
|
// create the message
|
||||||
msg := types.NewMsgCreateReturnVisit(addr, req.Return_visit_id, req.Article_id, req.Tid, req.Uid, req.Rv_timestamp, req.Rv_text, req.Flag, req.Reward)
|
msg := types.NewMsgCreateReturnVisit(addr, req.Return_visit_id, req.Article_id, req.Tid, req.Uid, req.Rv_timestamp, req.Rv_text, req.Flag, coins)
|
||||||
err = msg.ValidateBasic()
|
err = msg.ValidateBasic()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
||||||
|
|
|
@ -100,6 +100,7 @@ func handleMsgCreateComment(ctx sdk.Context, k Keeper, msg MsgCreateComment) (*s
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return nil, sdkerrors.Wrap(err, "Comment with that id already exists")
|
return nil, sdkerrors.Wrap(err, "Comment with that id already exists")
|
||||||
}
|
}
|
||||||
|
//need to modify
|
||||||
moduleAcct := sdk.AccAddress(crypto.AddressHash([]byte(types.ModuleName)))
|
moduleAcct := sdk.AccAddress(crypto.AddressHash([]byte(types.ModuleName)))
|
||||||
sdkError := k.CoinKeeper.SendCoins(ctx, comment.Creator, moduleAcct, comment.Reward)
|
sdkError := k.CoinKeeper.SendCoins(ctx, comment.Creator, moduleAcct, comment.Reward)
|
||||||
if sdkError != nil {
|
if sdkError != nil {
|
||||||
|
|
Loading…
Reference in New Issue