Skip to content

Commit c854241

Browse files
authored
fix: add verification on accounts into x/foundation Grants cli (#732)
* Add verification on accounts * Add unit tests on query cli * Update CHANGELOG.md
1 parent 5ed82db commit c854241

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
107107
* (baseapp) [\#724](https://github.com/line/lbm-sdk/pull/724) add checking pubkey type from validator params
108108
* (x/staking) [\#726](https://github.com/line/lbm-sdk/pull/726) check allowedList size in StakeAuthorization.Accept()
109109
* (x/staking) [\#728](https://github.com/line/lbm-sdk/pull/728) fix typo in unbondingToUnbonded() panic
110+
* (x/foundation) [\#732](https://github.com/line/lbm-sdk/pull/732) add verification on accounts into x/foundation Grants cli
110111

111112
### Breaking Changes
112113
* (proto) [\#564](https://github.com/line/lbm-sdk/pull/564) change gRPC path to original cosmos path

x/foundation/client/cli/query.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,18 @@ func NewQueryCmdGrants() *cobra.Command {
377377
return err
378378
}
379379

380+
grantee, err := sdk.AccAddressFromBech32(args[0])
381+
if err != nil {
382+
return err
383+
}
384+
380385
msgTypeURL := ""
381386
if len(args) >= 2 {
382387
msgTypeURL = args[1]
383388
}
389+
384390
params := foundation.QueryGrantsRequest{
385-
Grantee: args[0],
391+
Grantee: grantee.String(),
386392
MsgTypeUrl: msgTypeURL,
387393
Pagination: pageReq,
388394
}

x/foundation/client/testutil/query.go

+47
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@ func (s *IntegrationTestSuite) TestNewQueryCmdMember() {
179179
false,
180180
nil,
181181
},
182+
"invalid member": {
183+
[]string{
184+
"",
185+
},
186+
false,
187+
nil,
188+
},
182189
}
183190

184191
for name, tc := range testCases {
@@ -265,6 +272,12 @@ func (s *IntegrationTestSuite) TestNewQueryCmdProposal() {
265272
},
266273
false,
267274
},
275+
"invalid id": {
276+
[]string{
277+
fmt.Sprintf("%d", -1),
278+
},
279+
false,
280+
},
268281
}
269282

270283
for name, tc := range testCases {
@@ -352,6 +365,20 @@ func (s *IntegrationTestSuite) TestNewQueryCmdVote() {
352365
},
353366
false,
354367
},
368+
"invalid proposal id": {
369+
[]string{
370+
fmt.Sprintf("%d", -1),
371+
s.permanentMember.String(),
372+
},
373+
false,
374+
},
375+
"invalid voter": {
376+
[]string{
377+
fmt.Sprintf("%d", s.proposalID),
378+
"",
379+
},
380+
false,
381+
},
355382
}
356383

357384
for name, tc := range testCases {
@@ -396,6 +423,12 @@ func (s *IntegrationTestSuite) TestNewQueryCmdVotes() {
396423
},
397424
false,
398425
},
426+
"invalid proposal id": {
427+
[]string{
428+
fmt.Sprintf("%d", -1),
429+
},
430+
false,
431+
},
399432
}
400433

401434
for name, tc := range testCases {
@@ -440,6 +473,12 @@ func (s *IntegrationTestSuite) TestNewQueryCmdTallyResult() {
440473
},
441474
false,
442475
},
476+
"invalid proposal id": {
477+
[]string{
478+
fmt.Sprintf("%d", -1),
479+
},
480+
false,
481+
},
443482
}
444483

445484
for name, tc := range testCases {
@@ -496,6 +535,14 @@ func (s *IntegrationTestSuite) TestNewQueryCmdGrants() {
496535
false,
497536
0,
498537
},
538+
"invalid grantee": {
539+
[]string{
540+
"",
541+
foundation.ReceiveFromTreasuryAuthorization{}.MsgTypeURL(),
542+
},
543+
false,
544+
0,
545+
},
499546
}
500547

501548
for name, tc := range testCases {

0 commit comments

Comments
 (0)