Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fee granter #36

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions cosmosclient/cosmosclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,24 @@ import (
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
sdktypes "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/bech32"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
staking "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/dymensionxyz/cosmosclient/client/tx"
ethcodec "github.com/evmos/evmos/v12/crypto/codec"
"github.com/evmos/evmos/v12/crypto/hd"
"github.com/gogo/protobuf/proto"
prototypes "github.com/gogo/protobuf/types"
"github.com/ignite/cli/ignite/pkg/cosmosaccount"
"github.com/ignite/cli/ignite/pkg/cosmosfaucet"
"github.com/pkg/errors"
rpcclient "github.com/tendermint/tendermint/rpc/client"
rpchttp "github.com/tendermint/tendermint/rpc/client/http"

ctypes "github.com/tendermint/tendermint/rpc/core/types"

"github.com/ignite/cli/ignite/pkg/cosmosaccount"
"github.com/ignite/cli/ignite/pkg/cosmosfaucet"

ethcodec "github.com/evmos/evmos/v12/crypto/codec"
"github.com/evmos/evmos/v12/crypto/hd"
"github.com/dymensionxyz/cosmosclient/client/tx"
)

var (
Expand Down Expand Up @@ -89,6 +88,7 @@ type Client struct {
useFaucet bool
faucetAddress string
faucetDenom string
feeGranter string
faucetMinAmount uint64

homePath string
Expand Down Expand Up @@ -165,6 +165,12 @@ func WithUseFaucet(faucetAddress, denom string, minAmount uint64) Option {
}
}

func WithFeeGranter(feeGranter string) Option {
return func(c *Client) {
c.feeGranter = feeGranter
}
}

// WithGas sets an explicit gas-limit on transactions.
// Set to "auto" to calculate automatically.
func WithGas(gas string) Option {
Expand Down Expand Up @@ -268,6 +274,15 @@ func New(options ...Option) (Client, error) {
}

c.context = c.newContext()

if c.feeGranter != "" {
_, bytes, err := bech32.DecodeAndConvert(c.feeGranter)
if err != nil {
return Client{}, errors.Wrap(err, "invalid fee granter address")
}
c.context = c.context.WithFeeGranterAddress(bytes)
}

c.TxFactory = newFactory(c.context)

return c, nil
Expand Down Expand Up @@ -558,7 +573,7 @@ func (c Client) newContext() client.Context {
marshaler = codec.NewProtoCodec(interfaceRegistry)
txConfig = authtx.NewTxConfig(marshaler, authtx.DefaultSignModes)
)
//Register ethermint interfaces
// Register ethermint interfaces
ethcodec.RegisterInterfaces(interfaceRegistry)
authtypes.RegisterInterfaces(interfaceRegistry)
cryptocodec.RegisterInterfaces(interfaceRegistry)
Expand Down