You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
I have a program that needs to interact with multiple chains. I've given each chain-specific sub-module its own ChainClient & ChainClientConfig to work with, but any time I want to interact with two chains or more (either via query or tx), the second one to get executed uses the Bech32 prefix of the module that was executed first.
The calls to the SDK config did not panic, so it can't be sealed. AFAICS the calls are made each time AccAddress.String() or ValAddress.String() are called, so I tried the following:
done:=ChainClient.SetSDKContext()
// Get string representation of the account in the keyring and cache it.accAddr:=key.String()
done()
// Use the 'accAddr' variable from here on instead of calling the String() method each time.
But that didn't work either. I'm not sure how much further down this rabbit hole goes, so maybe someone can enlighten me here.
How To Reproduce
Create two accounts in your local keyring, e.g. one for Cosmos and one for Osmosis.
Was just talking about this today with some folks and happened to see this issue.
This behavior is a known issue with the Cosmos SDK. When you call SetSDKContext, that setting is global within the SDK. I recommend that you avoid the AccAddress's .String() function and call EncodeBech32AccAddr in Lens client/address.go instead.
As a second option, you could call a function that holds the lock on the SDK context until its finished generating the address. For example, your function could be something like this:
I have a program that needs to interact with multiple chains. I've given each chain-specific sub-module its own
ChainClient
&ChainClientConfig
to work with, but any time I want to interact with two chains or more (either via query or tx), the second one to get executed uses the Bech32 prefix of the module that was executed first.The calls to the SDK config did not panic, so it can't be sealed. AFAICS the calls are made each time
AccAddress.String()
orValAddress.String()
are called, so I tried the following:But that didn't work either. I'm not sure how much further down this rabbit hole goes, so maybe someone can enlighten me here.
How To Reproduce
Create two accounts in your local keyring, e.g. one for Cosmos and one for Osmosis.
Then, run this program.
This code example is intentionally racy as to show that the results are different each time you run the thing.
The text was updated successfully, but these errors were encountered: