-
Notifications
You must be signed in to change notification settings - Fork 368
/
utils.go
39 lines (32 loc) · 1.03 KB
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package utils
import (
"os"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/kava-labs/kava/x/community/types"
)
// 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
}