Skip to content

Commit c6a84d2

Browse files
authored
QueryTransactionsParams: Filter by token type #1117 Open (#1118)
1 parent 76e241e commit c6a84d2

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

token/services/db/driver/common.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ type QueryTransactionsParams struct {
228228
// Statuses is the list of transaction status to accept
229229
// If empty, any status is accepted
230230
Statuses []TxStatus
231+
// TokenTypes is the list of token types to accept
232+
// If empty, any token type is accepted
233+
TokenTypes []token2.Type
231234
}
232235

233236
// QueryValidationRecordsParams defines the parameters for querying validation records.

token/services/db/sql/common/querybuilder_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ func TestTransactionSql(t *testing.T) {
108108
expectedSql: "((tbl.tx_id) IN (($1), ($2), ($3))) AND ((sender_eid = $4) OR (recipient_eid = $5))",
109109
expectedArgs: []common2.Param{"transactionID1", "transactionID2", "transactionID3", "alice", "bob"},
110110
},
111+
{
112+
name: "With Token Types",
113+
params: driver.QueryTransactionsParams{
114+
TokenTypes: []token.Type{"Pineapple"},
115+
},
116+
expectedSql: "(token_type = $1)",
117+
expectedArgs: []common2.Param{"Pineapple"},
118+
},
111119
}
112120

113121
for _, tc := range testCases {

token/services/db/sql/common/tcondition.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ func HasTransactionParams(params driver.QueryTransactionsParams, table common.Ta
106106
cond.In("action_type", params.ActionTypes...),
107107
// Specific transaction status if requested, defaults to all but Deleted
108108
cond.In("status", params.Statuses...),
109+
cond.In("token_type", params.TokenTypes...),
109110
}
110111

111112
if params.ExcludeToSelf {

0 commit comments

Comments
 (0)