-
Notifications
You must be signed in to change notification settings - Fork 4
/
context.go
33 lines (30 loc) · 1 KB
/
context.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
package main
import (
sdkerrors "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// Context defines the structure of faucet context.
type Context struct {
chainID string
nodeURI string
port string
gasPrices sdk.DecCoins
coins sdk.Coins
maxPerPeriodWithdrawal sdk.Coins
keys chan keyring.Record
}
// initCtx parses config string literals.
func (ctx *Context) initCtx() error {
var err error
ctx.gasPrices, err = sdk.ParseDecCoins(faucet.config.GasPrices)
if err != nil {
return sdkerrors.Wrap(err, "failed to parse gas prices")
}
ctx.coins, err = sdk.ParseCoinsNormalized(faucet.config.Coins)
if err != nil {
return sdkerrors.Wrap(err, "failed to parse coins to withdraw")
}
ctx.maxPerPeriodWithdrawal, err = sdk.ParseCoinsNormalized(faucet.config.MaxPerPeriodWithdrawal)
return sdkerrors.Wrap(err, "failed to parse max withdrawal per period")
}