2022-12-13 01:10:36 +00:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
|
|
|
2024-05-01 03:17:24 +00:00
|
|
|
"github.com/0glabs/0g-chain/x/community/types"
|
2022-12-13 01:10:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// ParseCommunityPoolLendDepositProposal reads a JSON file and parses it to a CommunityPoolLendDepositProposal
|
|
|
|
func ParseCommunityPoolLendDepositProposal(
|
|
|
|
cdc codec.JSONCodec,
|
|
|
|
proposalFile string,
|
|
|
|
) (types.CommunityPoolLendDepositProposal, error) {
|
|
|
|
proposal := types.CommunityPoolLendDepositProposal{}
|
|
|
|
contents, err := os.ReadFile(proposalFile)
|
|
|
|
if err != nil {
|
|
|
|
return proposal, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = cdc.UnmarshalJSON(contents, &proposal)
|
|
|
|
return proposal, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// ParseCommunityPoolLendWithdrawProposal reads a JSON file and parses it to a CommunityPoolLendWithdrawProposal
|
|
|
|
func ParseCommunityPoolLendWithdrawProposal(
|
|
|
|
cdc codec.JSONCodec,
|
|
|
|
proposalFile string,
|
|
|
|
) (types.CommunityPoolLendWithdrawProposal, error) {
|
|
|
|
proposal := types.CommunityPoolLendWithdrawProposal{}
|
|
|
|
contents, err := os.ReadFile(proposalFile)
|
|
|
|
if err != nil {
|
|
|
|
return proposal, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = cdc.UnmarshalJSON(contents, &proposal)
|
|
|
|
return proposal, err
|
|
|
|
}
|