From 82773ec740d49f1b781fba85a019adde01be5051 Mon Sep 17 00:00:00 2001 From: Senna46 <29295263+Senna46@users.noreply.github.com> Date: Fri, 31 Jan 2025 23:26:52 +0900 Subject: [PATCH 1/5] fix: cosmos client v0.52 --- ignite/pkg/cosmosclient/cosmosclient.go | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/ignite/pkg/cosmosclient/cosmosclient.go b/ignite/pkg/cosmosclient/cosmosclient.go index 0d65ad754d..5e2d47556d 100644 --- a/ignite/pkg/cosmosclient/cosmosclient.go +++ b/ignite/pkg/cosmosclient/cosmosclient.go @@ -364,8 +364,6 @@ func New(ctx context.Context, options ...Option) (Client, error) { if c.signer == nil { c.signer = signer{} } - // set address prefix in SDK global config - c.SetConfigAddressPrefix() return c, nil } @@ -468,16 +466,6 @@ func (c Client) Context() client.Context { return c.context } -// SetConfigAddressPrefix sets the account prefix in the SDK global config. -func (c Client) SetConfigAddressPrefix() { - // TODO find a better way if possible. - // https://github.com/ignite/cli/issues/2744 - mconf.Lock() - defer mconf.Unlock() - config := sdktypes.GetConfig() - config.SetBech32PrefixForAccount(c.addressPrefix, c.addressPrefix+"pub") -} - // Response of your broadcasted transaction. type Response struct { Codec codec.Codec From 97e42cfd4c9dbf963e48b6dedb041375b142a336 Mon Sep 17 00:00:00 2001 From: Senna46 <29295263+Senna46@users.noreply.github.com> Date: Fri, 31 Jan 2025 23:32:04 +0900 Subject: [PATCH 2/5] feat: with address prefix --- ignite/pkg/cosmosclient/cosmosclient.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ignite/pkg/cosmosclient/cosmosclient.go b/ignite/pkg/cosmosclient/cosmosclient.go index 5e2d47556d..c7d34d600a 100644 --- a/ignite/pkg/cosmosclient/cosmosclient.go +++ b/ignite/pkg/cosmosclient/cosmosclient.go @@ -837,7 +837,8 @@ func (c Client) newContext() client.Context { WithGenerateOnly(c.generateOnly). WithAddressCodec(addressCodec). WithValidatorAddressCodec(validatorAddressCodec). - WithConsensusAddressCodec(consensusAddressCodec) + WithConsensusAddressCodec(consensusAddressCodec). + WithAddressPrefix(c.addressPrefix) } func newFactory(clientCtx client.Context) tx.Factory { From c4960ad6d9638d2856f40a34d9cbd5a9b5e5132f Mon Sep 17 00:00:00 2001 From: Senna46 <29295263+Senna46@users.noreply.github.com> Date: Fri, 31 Jan 2025 23:41:32 +0900 Subject: [PATCH 3/5] feat: changelog --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index 85836e1843..593eab3f6a 100644 --- a/changelog.md +++ b/changelog.md @@ -56,6 +56,7 @@ - [#4402](https://github.com/ignite/cli/pull/4402) Fix gentx parser into the cosmosutil package - [#4474](https://github.com/ignite/cli/pull/4474) Fix issue in `build --release` command - [#4479](https://github.com/ignite/cli/pull/4479) Scaffold an `uint64 type crashs Ignite +- [#4486](https://github.com/ignite/cli/pull/4486) Fix issue when set account prefix with sdk v0.52 ## [`v28.7.0`](https://github.com/ignite/cli/releases/tag/v28.7.0) From bcda14999ab7bd6350e163705e6623a0f7c3f900 Mon Sep 17 00:00:00 2001 From: Senna46 <29295263+Senna46@users.noreply.github.com> Date: Fri, 31 Jan 2025 23:42:32 +0900 Subject: [PATCH 4/5] chore: changes --- changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 593eab3f6a..51431c74b4 100644 --- a/changelog.md +++ b/changelog.md @@ -47,6 +47,7 @@ - [#4361](https://github.com/ignite/cli/pull/4361) Remove unused `KeyPrefix` method - [#4384](https://github.com/ignite/cli/pull/4384) Compare genesis params into chain genesis tests - [#4463](https://github.com/ignite/cli/pull/4463) Run `chain simulation` with any simulation test case +- [#4486](https://github.com/ignite/cli/pull/4486) Fix issue when set account prefix with sdk v0.52 ### Fixes @@ -56,7 +57,6 @@ - [#4402](https://github.com/ignite/cli/pull/4402) Fix gentx parser into the cosmosutil package - [#4474](https://github.com/ignite/cli/pull/4474) Fix issue in `build --release` command - [#4479](https://github.com/ignite/cli/pull/4479) Scaffold an `uint64 type crashs Ignite -- [#4486](https://github.com/ignite/cli/pull/4486) Fix issue when set account prefix with sdk v0.52 ## [`v28.7.0`](https://github.com/ignite/cli/releases/tag/v28.7.0) From 5ce4ed1ed10f020db33b67d2dfca4792c608f0fd Mon Sep 17 00:00:00 2001 From: Senna46 <29295263+Senna46@users.noreply.github.com> Date: Sat, 1 Feb 2025 01:35:51 +0900 Subject: [PATCH 5/5] fix: delete lockBech32Prefix --- ignite/pkg/cosmosclient/cosmosclient.go | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/ignite/pkg/cosmosclient/cosmosclient.go b/ignite/pkg/cosmosclient/cosmosclient.go index c7d34d600a..8317fc1733 100644 --- a/ignite/pkg/cosmosclient/cosmosclient.go +++ b/ignite/pkg/cosmosclient/cosmosclient.go @@ -10,7 +10,6 @@ import ( "path/filepath" "strconv" "strings" - "sync" "time" "github.com/cenkalti/backoff" @@ -443,8 +442,6 @@ func (c Client) WaitForTx(ctx context.Context, hash string) (*ctypes.ResultTx, e // Account returns the account with name or address equal to nameOrAddress. func (c Client) Account(nameOrAddress string) (cosmosaccount.Account, error) { - defer c.lockBech32Prefix()() - acc, err := c.AccountRegistry.GetByName(nameOrAddress) if err == nil { return acc, nil @@ -523,16 +520,6 @@ func (c Client) Status(ctx context.Context) (*ctypes.ResultStatus, error) { return c.RPC.Status(ctx) } -// protects sdktypes.Config. -var mconf sync.Mutex - -func (c Client) lockBech32Prefix() (unlockFn func()) { - mconf.Lock() - config := sdktypes.GetConfig() - config.SetBech32PrefixForAccount(c.addressPrefix, c.addressPrefix+"pub") - return mconf.Unlock -} - func (c Client) BroadcastTx(ctx context.Context, account cosmosaccount.Account, msgs ...transaction.Msg) (Response, error) { txService, err := c.CreateTx(ctx, account, msgs...) if err != nil { @@ -545,8 +532,6 @@ func (c Client) BroadcastTx(ctx context.Context, account cosmosaccount.Account, // CreateTxWithOptions creates a transaction with the given options. // Options override global client options. func (c Client) CreateTxWithOptions(ctx context.Context, account cosmosaccount.Account, options TxOptions, msgs ...transaction.Msg) (TxService, error) { - defer c.lockBech32Prefix()() - if c.useFaucet && !c.generateOnly { addr, err := account.Address(c.addressPrefix) if err != nil {