From 3f1b1b38ed677b652866c9af2313f2524bbc4a2e Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 21 Dec 2023 10:33:10 +0000 Subject: [PATCH] feat(client): add `WithFromName` to tx factory (backport #18852) (#18854) Co-authored-by: gsai967 <153279976+gsai967@users.noreply.github.com> Co-authored-by: Julien Robert --- CHANGELOG.md | 4 ++++ client/tx/factory.go | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c86ba3ed774a..36714ae7cc2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Improvements + +* (client/tx) [#18852](https://github.com/cosmos/cosmos-sdk/pull/18852) Add `WithFromName` to tx factory. + ## [v0.47.7](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.7) - 2023-12-20 ### Improvements diff --git a/client/tx/factory.go b/client/tx/factory.go index 6eee79894117..d6ae20a0e11d 100644 --- a/client/tx/factory.go +++ b/client/tx/factory.go @@ -130,6 +130,7 @@ func (f Factory) Fees() sdk.Coins { return f.fees } func (f Factory) GasPrices() sdk.DecCoins { return f.gasPrices } func (f Factory) AccountRetriever() client.AccountRetriever { return f.accountRetriever } func (f Factory) TimeoutHeight() uint64 { return f.timeoutHeight } +func (f Factory) FromName() string { return f.fromName } // SimulateAndExecute returns the option to simulate and then execute the transaction // using the gas from the simulation results @@ -201,6 +202,13 @@ func (f Factory) WithKeybase(keybase keyring.Keyring) Factory { return f } +// WithFromName returns a copy of the Factory with updated fromName +// fromName will be use for building a simulation tx. +func (f Factory) WithFromName(fromName string) Factory { + f.fromName = fromName + return f +} + // WithSequence returns a copy of the Factory with an updated sequence number. func (f Factory) WithSequence(sequence uint64) Factory { f.sequence = sequence