cosmos-sdk/x/distribution/client/cli/utils.go
Aaron Craelius 7de8ef75b3
Require proto.Message in client.Context.PrintOutput (#6999)
* Enable proto JSON json for cli tx & query

* WIP on tests

* Test fixes, cleanup

* Cleanup

* Address review comments

* Update client/context.go

Co-authored-by: Anil Kumar Kammari <anil@vitwit.com>

* Fixes

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Anil Kumar Kammari <anil@vitwit.com>
2020-08-11 03:19:49 -04:00

37 lines
1.1 KiB
Go

package cli
import (
"io/ioutil"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
)
type (
// CommunityPoolSpendProposalJSON defines a CommunityPoolSpendProposal with a deposit
CommunityPoolSpendProposalJSON struct {
Title string `json:"title" yaml:"title"`
Description string `json:"description" yaml:"description"`
Recipient sdk.AccAddress `json:"recipient" yaml:"recipient"`
Amount string `json:"amount" yaml:"amount"`
Deposit string `json:"deposit" yaml:"deposit"`
}
)
// ParseCommunityPoolSpendProposalJSON reads and parses a CommunityPoolSpendProposalJSON from a file.
// TODO: migrate this to protobuf
func ParseCommunityPoolSpendProposalJSON(cdc *codec.LegacyAmino, proposalFile string) (CommunityPoolSpendProposalJSON, error) {
proposal := CommunityPoolSpendProposalJSON{}
contents, err := ioutil.ReadFile(proposalFile)
if err != nil {
return proposal, err
}
if err = cdc.UnmarshalJSON(contents, &proposal); err != nil {
return proposal, err
}
return proposal, nil
}