-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from MinterTeam/v0.1.0-dev
V0.1.0
- Loading branch information
Showing
23 changed files
with
717 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package utils | ||
|
||
import ( | ||
"io/ioutil" | ||
|
||
"github.com/MinterTeam/mhub2/module/x/mhub2/types" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/rest" | ||
) | ||
|
||
type ( | ||
// TokenInfosChangesJSON defines a slice of TokenInfosChangeJSON objects which can be | ||
// converted to a slice of TokenInfosChange objects. | ||
TokenInfosChangesJSON []TokenInfosChangeJSON | ||
|
||
// TokenInfosChangeJSON defines a parameter change used in JSON input. This | ||
// allows values to be specified in raw JSON instead of being string encoded. | ||
TokenInfosChangeJSON struct { | ||
NewTokenInfos *types.TokenInfos `json:"new_token_infos" yaml:"new_token_infos"` | ||
} | ||
|
||
// TokenInfosChangeProposalJSON defines a ParameterChangeProposal with a deposit used | ||
// to parse parameter change proposals from a JSON file. | ||
TokenInfosChangeProposalJSON struct { | ||
NewTokenInfos *types.TokenInfos `json:"new_token_infos" yaml:"new_token_infos"` | ||
Deposit string `json:"deposit" yaml:"deposit"` | ||
} | ||
|
||
// TokenInfosChangeProposalReq defines a parameter change proposal request body. | ||
TokenInfosChangeProposalReq struct { | ||
BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` | ||
|
||
NewTokenInfos *types.TokenInfos `json:"new_token_infos" yaml:"new_token_infos"` | ||
Proposer sdk.AccAddress `json:"proposer" yaml:"proposer"` | ||
Deposit sdk.Coins `json:"deposit" yaml:"deposit"` | ||
} | ||
) | ||
|
||
func NewTokenInfosChangeJSON(tokenInfos *types.TokenInfos) TokenInfosChangeJSON { | ||
return TokenInfosChangeJSON{tokenInfos} | ||
} | ||
|
||
// ToTokenInfosChange converts a TokenInfosChangeJSON object to TokenInfosChange. | ||
func (pcj TokenInfosChangeJSON) ToTokenInfosChange() types.TokenInfosChangeProposal { | ||
return *types.NewTokenInfosChangeProposal(pcj.NewTokenInfos) | ||
} | ||
|
||
// ToTokenInfosChanges converts a slice of TokenInfosChangeJSON objects to a slice of | ||
// TokenInfosChange. | ||
func (pcj TokenInfosChangesJSON) ToTokenInfosChanges() []types.TokenInfosChangeProposal { | ||
res := make([]types.TokenInfosChangeProposal, len(pcj)) | ||
for i, pc := range pcj { | ||
res[i] = pc.ToTokenInfosChange() | ||
} | ||
return res | ||
} | ||
|
||
// ParseTokenInfosChangeProposalJSON reads and parses a TokenInfosChangeProposalJSON from | ||
// file. | ||
func ParseTokenInfosChangeProposalJSON(cdc *codec.LegacyAmino, proposalFile string) (TokenInfosChangeProposalJSON, error) { | ||
proposal := TokenInfosChangeProposalJSON{} | ||
|
||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.