-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: apply types/address.go from cosmos-sdk@v0.45.1 #603
Conversation
Fix the bug that should be used `operator` address when `to` address is nil on CreateFTClass
Codecov Report
@@ Coverage Diff @@
## main #603 +/- ##
==========================================
- Coverage 60.60% 59.41% -1.19%
==========================================
Files 814 814
Lines 94798 95390 +592
==========================================
- Hits 57448 56680 -768
- Misses 34097 35158 +1061
- Partials 3253 3552 +299
|
Please add this changes to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
||
toAddr, err := sdk.AccAddressFromBech32(req.To) | ||
if err != nil { | ||
toAddr = operatorAddr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memo: Bugfix of lbm-sdk
if !valOk { | ||
_, file, no, ok := runtime.Caller(1) | ||
if ok { | ||
fmt.Printf("CollectTxs-2, called from %s#%d - %s\n", file, no, sdk.BytesToAccAddress(valAddr).String()) | ||
fmt.Printf("CollectTxs-2, called from %s#%d - %s\n", file, no, valAddr.String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memo: Bugfix of cosmos-sdk
signingInfo, found := k.GetValidatorSigningInfo(ctx, sdk.ConsAddress(params.ConsAddress)) | ||
// https://github.com/cosmos/cosmos-sdk/issues/12573 | ||
// Will be removed, but fix this | ||
addr, err := sdk.ConsAddressFromBech32(params.ConsAddress) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memo: Bugfix of cosmos-sdk
_, _, addr3 := testdata.KeyTestPubAddr() | ||
consAddr := sdk.AccAddress(addr3).ToConsAddress() | ||
consAddr := sdk.ConsAddress(addr3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memo: Bugfix of cosmos-sdk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove AddressDelimiter
of staking
and distribution
module if we don't need anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I have submitted a relevant PR to your repository.
x/token/keeper/msg_server.go
Outdated
if _, err := s.keeper.GetGrant(ctx, req.ContractId, granter, req.Permission); err != nil { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x/token/keeper/msg_server.go
Outdated
if _, err := s.keeper.GetGrant(ctx, req.ContractId, grantee, req.Permission); err != nil { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x/stakingplus/authz.go
Outdated
@@ -27,7 +27,7 @@ func (a CreateValidatorAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (foun | |||
} | |||
|
|||
func (a CreateValidatorAuthorization) ValidateBasic() error { | |||
if err := sdk.ValidateValAddress(a.ValidatorAddress); err != nil { | |||
if _, err := sdk.AccAddressFromBech32(a.ValidatorAddress); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if _, err := sdk.AccAddressFromBech32(a.ValidatorAddress); err != nil { | |
if _, err := sdk.ValAddressFromBech32(a.ValidatorAddress); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which means, the logic is not covered by unit tests. I should revisit x/stakingplus later and add the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will that tests be included in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it would be added on another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, It might be better to submit an issue about it.
x/wasm/keeper/api.go
Outdated
@@ -30,14 +28,14 @@ func (a cosmwasmAPIImpl) humanAddress(canon []byte) (string, uint64, error) { | |||
gas := a.gasMultiplier.FromWasmVMGas(5) | |||
if err := sdk.VerifyAddressFormat(canon); err != nil { | |||
//nolint:stylecheck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very small thing. Does this nolint
need?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to delete it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think AddressDenomDelimiter
also isn't used. and AddressToPrefixKey
function of bank module also.
Fix validation in the tests to avoid modifying test cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approval, with some minor comments.
@@ -249,15 +249,15 @@ func TestEncoding(t *testing.T) { | |||
srcMsg: wasmvmtypes.CosmosMsg{ | |||
Staking: &wasmvmtypes.StakingMsg{ | |||
Delegate: &wasmvmtypes.DelegateMsg{ | |||
Validator: sdk.BytesToAccAddress(valAddr).String(), | |||
Validator: valAddr.String(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type of valAddr
is sdk.ValAddress
, so technically, it should be converted to sdk.AccAddress
first.
However, from the background, it seems that it should have been sdk.ValAddress
. Is it a bug-fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is changed from CosmWasm/wasmd-v0.27.0
. Yes, it's our bug fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this bug fix to description.
bz, err := keeper.QuerySmart(ctx, contractAddr, msg) | ||
return bz, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bz, err := keeper.QuerySmart(ctx, contractAddr, msg) | |
return bz, err | |
return keeper.QuerySmart(ctx, contractAddr, msg) |
I would like to know the reason for this change. By the linter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is changed from CosmWasm/wasmd-v0.27.0
. We should be the same since we continue to merge from CosmWasm/wasmd
.
@@ -293,7 +291,7 @@ func TestLegacyQueryContractHistory(t *testing.T) { | |||
var defaultQueryGasLimit sdk.Gas = 3000000 | |||
q := NewLegacyQuerier(keeper, defaultQueryGasLimit) | |||
queryContractAddr := spec.srcQueryAddr | |||
if queryContractAddr.Empty() { | |||
if queryContractAddr == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if queryContractAddr == nil { | |
if len(queryContractAddr) == 0 { |
It will cover both of nil
and an empty array. Is the comparison with nil
intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is changed from CosmWasm/wasmd-v0.27.0
. We should be the same since we continue to merge from CosmWasm/wasmd
.
I found a minor diff.
|
Description
This PR enable to apply types/address.go from cosmos-sdk@v0.45.1.
Major changes:
types.AccAddress
,types.ValAddress
andtypes.ConsAddress
have changed from string type to byte array type.types.ValidateAccAddress(STRING) + types.AccAddress(STRING)
→types.AccAddressFromBech32(STRING)
types.ValidateValAddress(STRING) + types.ValAddress(STRING)
→types.ValAddressFromBech32(STRING)
types.ValidateConsAddress(STRING) + types.ConsAddress(STRING)
→types.ConsAddressFromBech32(STRING)
types.AccAddress(STRING)
→types.AccAddressFromBech32(STRING)
types.ValAddress(STRING)
→types.ValAddressFromBech32(STRING)
types.ConsAddress(STRING)
→types.ConsAddressFromBech32(STRING)
types.BytesToAccAddress(BYTES)
→types.AccAddress(BYTES)
types.BytesToValAddress(BYTES)
→types.ValAddress(BYTES)
types.BytesToConsAddress(BYTES)
→types.ConsAddress(BYTES)
Additional changes:
closes: #578
Motivation and context
How has this been tested?
Screenshots (if appropriate):
Checklist:
CHANGELOG.md
client/docs/swagger-ui/swagger.yaml