Skip to content

Commit

Permalink
refactorL make PrepareFactory client method public
Browse files Browse the repository at this point in the history
needed to sdk clients that use own tx factory and want to initialize it
  • Loading branch information
kakysha committed Mar 19, 2024
1 parent b4bd99b commit a9ea38c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions client/chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,11 @@ func (c *chainClient) syncTimeoutHeight() {
}
}

// prepareFactory ensures the account defined by ctx.GetFromAddress() exists and
// PrepareFactory ensures the account defined by ctx.GetFromAddress() exists and
// if the account number and/or the account sequence number are zero (not set),
// they will be queried for and set on the provided Factory. A new Factory with
// the updated fields will be returned.
func prepareFactory(clientCtx client.Context, txf tx.Factory) (tx.Factory, error) {
func PrepareFactory(clientCtx client.Context, txf tx.Factory) (tx.Factory, error) {

Check warning on line 426 in client/chain/chain.go

View check run for this annotation

Codecov / codecov/patch

client/chain/chain.go#L426

Added line #L426 was not covered by tests
from := clientCtx.GetFromAddress()

if err := txf.AccountRetriever().EnsureExists(clientCtx, from); err != nil {
Expand Down Expand Up @@ -633,7 +633,7 @@ func (c *chainClient) GetFeeDiscountInfo(ctx context.Context, account string) (*
func (c *chainClient) SimulateMsg(clientCtx client.Context, msgs ...sdk.Msg) (*txtypes.SimulateResponse, error) {
c.txFactory = c.txFactory.WithSequence(c.accSeq)
c.txFactory = c.txFactory.WithAccountNumber(c.accNum)
txf, err := prepareFactory(clientCtx, c.txFactory)
txf, err := PrepareFactory(clientCtx, c.txFactory)

Check warning on line 636 in client/chain/chain.go

View check run for this annotation

Codecov / codecov/patch

client/chain/chain.go#L636

Added line #L636 was not covered by tests
if err != nil {
err = errors.Wrap(err, "failed to prepareFactory")
return nil, err
Expand Down Expand Up @@ -710,7 +710,7 @@ func (c *chainClient) buildSignedTx(clientCtx client.Context, txf tx.Factory, ms
c.gasWanted = adjustedGas
}

txf, err := prepareFactory(clientCtx, txf)
txf, err := PrepareFactory(clientCtx, txf)

Check warning on line 713 in client/chain/chain.go

View check run for this annotation

Codecov / codecov/patch

client/chain/chain.go#L713

Added line #L713 was not covered by tests
if err != nil {
return nil, errors.Wrap(err, "failed to prepareFactory")
}
Expand Down

0 comments on commit a9ea38c

Please sign in to comment.