Skip to content

Commit

Permalink
fix: use %q instead of manual \"%s\"
Browse files Browse the repository at this point in the history
Noticed in a post-codereview of PR quicksilver-zone#1704 that there
was a manual value quoting usinq `\"%s\"` instead
of the format specifier `%q`. Manual quoting doesn't
work correctly. One can find vestiges of it by

    git grep '\\"%s'

Updates quicksilver-zone#1704
  • Loading branch information
odeke-em committed Oct 3, 2024
1 parent 03a2194 commit 282d564
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
16 changes: 8 additions & 8 deletions x/interchainstaking/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ func (k msgServer) CancelRedemption(goCtx context.Context, msg *types.MsgCancelR
// check for errored unbond in UNBONDING status
record, found = k.GetWithdrawalRecord(ctx, msg.ChainId, msg.Hash, types.WithdrawStatusUnbond)
if !found {
return nil, fmt.Errorf("no queued record with hash \"%s\" found", msg.Hash)
return nil, fmt.Errorf("no queued record with hash %q found", msg.Hash)
}
if record.SendErrors == 0 {
return nil, fmt.Errorf("cannot cancel unbond \"%s\" with no errors", msg.Hash)
return nil, fmt.Errorf("cannot cancel unbond %q with no errors", msg.Hash)
}
}

if record.Delegator != msg.FromAddress && k.Keeper.GetGovAuthority(ctx) != msg.FromAddress {
return nil, fmt.Errorf("incorrect user for record with hash \"%s\"", msg.Hash)
return nil, fmt.Errorf("incorrect user for record with hash %q", msg.Hash)
}

// all good. delete!
Expand Down Expand Up @@ -145,14 +145,14 @@ func (k msgServer) RequeueRedemption(goCtx context.Context, msg *types.MsgRequeu
// check for errored unbond in UNBONDING status
record, found := k.GetWithdrawalRecord(ctx, msg.ChainId, msg.Hash, types.WithdrawStatusUnbond)
if !found {
return nil, fmt.Errorf("no unbonding record with hash \"%s\" found", msg.Hash)
return nil, fmt.Errorf("no unbonding record with hash %q found", msg.Hash)
}
if record.SendErrors == 0 {
return nil, fmt.Errorf("cannot requeue unbond \"%s\" with no errors", msg.Hash)
return nil, fmt.Errorf("cannot requeue unbond %q with no errors", msg.Hash)
}

if record.Delegator != msg.FromAddress && k.Keeper.GetGovAuthority(ctx) != msg.FromAddress {
return nil, fmt.Errorf("incorrect user for record with hash \"%s\"", msg.Hash)
return nil, fmt.Errorf("incorrect user for record with hash %q", msg.Hash)
}

// all good. update sendErrors to zero, nil the distributions and amount (as this we be recalculated when processed), and update the state to queued.
Expand Down Expand Up @@ -208,7 +208,7 @@ func (k msgServer) UpdateRedemption(goCtx context.Context, msg *types.MsgUpdateR
})

if r == nil {
return nil, fmt.Errorf("no unbonding record with hash \"%s\" found", msg.Hash)
return nil, fmt.Errorf("no unbonding record with hash %q found", msg.Hash)
}

if msg.NewStatus == types.WithdrawStatusQueued {
Expand Down Expand Up @@ -244,7 +244,7 @@ func (k msgServer) SignalIntent(goCtx context.Context, msg *types.MsgSignalInten
// get zone
zone, ok := k.GetZone(ctx, msg.ChainId)
if !ok {
return nil, fmt.Errorf("invalid chain id \"%s\"", msg.ChainId)
return nil, fmt.Errorf("invalid chain id %q", msg.ChainId)
}

// validate intents (aggregated errors)
Expand Down
22 changes: 11 additions & 11 deletions x/interchainstaking/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ func (suite *KeeperTestSuite) TestGovReopenChannel() {
Authority: "",
}
},
expecErr: fmt.Errorf("unable to obtain chain id: invalid connection id, \"%s\" not found", ""),
expecErr: fmt.Errorf("unable to obtain chain id: invalid connection id, %q not found", ""),
},
{
name: "chainID / connectsionID mismatch",
Expand Down Expand Up @@ -817,7 +817,7 @@ func (suite *KeeperTestSuite) TestMsgCancelRedemeption() {
FromAddress: addressutils.GenerateAddressForTestWithPrefix("quick"),
}
},
fmt.Sprintf("no queued record with hash \"%s\" found", hash),
fmt.Sprintf("no queued record with hash %q found", hash),
},
{
"no hash exists",
Expand All @@ -828,7 +828,7 @@ func (suite *KeeperTestSuite) TestMsgCancelRedemeption() {
FromAddress: addressutils.GenerateAddressForTestWithPrefix("quick"),
}
},
fmt.Sprintf("no queued record with hash \"%s\" found", hash),
fmt.Sprintf("no queued record with hash %q found", hash),
},
{
"hash exists but in unbond status, no errors",
Expand All @@ -851,7 +851,7 @@ func (suite *KeeperTestSuite) TestMsgCancelRedemeption() {
FromAddress: address,
}
},
fmt.Sprintf("cannot cancel unbond \"%s\" with no errors", hash),
fmt.Sprintf("cannot cancel unbond %q with no errors", hash),
},
{
"hash exists in queued status, with errors",
Expand Down Expand Up @@ -903,7 +903,7 @@ func (suite *KeeperTestSuite) TestMsgCancelRedemeption() {
FromAddress: address,
}
},
fmt.Sprintf("incorrect user for record with hash \"%s\"", hash),
fmt.Sprintf("incorrect user for record with hash %q", hash),
},
{
"valid",
Expand Down Expand Up @@ -1002,7 +1002,7 @@ func (suite *KeeperTestSuite) TestMsgRequeueRedemeption() {
FromAddress: addressutils.GenerateAddressForTestWithPrefix("quick"),
}
},
fmt.Sprintf("no unbonding record with hash \"%s\" found", hash),
fmt.Sprintf("no unbonding record with hash %q found", hash),
},
{
"no hash exists",
Expand All @@ -1013,7 +1013,7 @@ func (suite *KeeperTestSuite) TestMsgRequeueRedemeption() {
FromAddress: addressutils.GenerateAddressForTestWithPrefix("quick"),
}
},
fmt.Sprintf("no unbonding record with hash \"%s\" found", hash),
fmt.Sprintf("no unbonding record with hash %q found", hash),
},
{
"hash exists but in unbond status, no errors",
Expand All @@ -1036,7 +1036,7 @@ func (suite *KeeperTestSuite) TestMsgRequeueRedemeption() {
FromAddress: address,
}
},
fmt.Sprintf("cannot requeue unbond \"%s\" with no errors", hash),
fmt.Sprintf("cannot requeue unbond %q with no errors", hash),
},
{
"hash exists in queued status, with errors",
Expand Down Expand Up @@ -1086,7 +1086,7 @@ func (suite *KeeperTestSuite) TestMsgRequeueRedemeption() {
FromAddress: address,
}
},
fmt.Sprintf("incorrect user for record with hash \"%s\"", hash),
fmt.Sprintf("incorrect user for record with hash %q", hash),
},
{
"valid - governance",
Expand Down Expand Up @@ -1161,7 +1161,7 @@ func (suite *KeeperTestSuite) TestMsgUpdateRedemption() {
FromAddress: k.GetGovAuthority(ctx),
}
},
fmt.Sprintf("no unbonding record with hash \"%s\" found", hash),
fmt.Sprintf("no unbonding record with hash %q found", hash),
nil,
},
{
Expand All @@ -1176,7 +1176,7 @@ func (suite *KeeperTestSuite) TestMsgUpdateRedemption() {
FromAddress: k.GetGovAuthority(ctx),
}
},
fmt.Sprintf("no unbonding record with hash \"%s\" found", hash),
fmt.Sprintf("no unbonding record with hash %q found", hash),
nil,
},
{
Expand Down
2 changes: 1 addition & 1 deletion x/interchainstaking/keeper/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (k *Keeper) HandleRegisterZoneProposal(ctx sdk.Context, p *types.RegisterZo
// get zone
_, found := k.GetZone(ctx, chainID)
if found {
return fmt.Errorf("invalid chain id, zone for \"%s\" already registered", chainID)
return fmt.Errorf("invalid chain id, zone for %q already registered", chainID)
}

connection, found := k.IBCKeeper.ConnectionKeeper.GetConnection(ctx, p.ConnectionId)
Expand Down
2 changes: 1 addition & 1 deletion x/participationrewards/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (k msgServer) SubmitClaim(goCtx context.Context, msg *types.MsgSubmitClaim)
// fetch zone
zone, ok := k.icsKeeper.GetZone(ctx, msg.Zone)
if !ok {
return nil, fmt.Errorf("invalid zone, chain id \"%s\" not found", msg.Zone)
return nil, fmt.Errorf("invalid zone, chain id %q not found", msg.Zone)
}
var pd types.ProtocolData
pd, ok = k.GetProtocolData(ctx, types.ProtocolDataTypeConnection, msg.SrcZone)
Expand Down

0 comments on commit 282d564

Please sign in to comment.