Skip to content

Commit

Permalink
feat(pkg/cosmosclient): request more tokens from faucet as needed (ig…
Browse files Browse the repository at this point in the history
…nite#2125)

* ask token from faucet if don't have enough balance

* fix import sort
  • Loading branch information
Pantani authored Mar 2, 2022
1 parent c6ff7f8 commit 8794fcb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion starport/pkg/cosmosclient/cosmosclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdktypes "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"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"
proto "github.com/gogo/protobuf/proto"
"github.com/gogo/protobuf/proto"
prototypes "github.com/gogo/protobuf/types"
"github.com/pkg/errors"
rpchttp "github.com/tendermint/tendermint/rpc/client/http"
Expand Down Expand Up @@ -305,6 +306,14 @@ func (c Client) BroadcastTxWithProvision(accountName string, msgs ...sdktypes.Ms
}

resp, err := ctx.BroadcastTx(txBytes)
if err == sdkerrors.ErrInsufficientFunds {
err = c.makeSureAccountHasTokens(context.Background(), accountAddress.String())
if err != nil {
return Response{}, err
}
resp, err = ctx.BroadcastTx(txBytes)
}

return Response{
codec: ctx.Codec,
TxResponse: resp,
Expand Down

0 comments on commit 8794fcb

Please sign in to comment.