From 41e0fbcd0d6fd23b6d378b07aafff62069302315 Mon Sep 17 00:00:00 2001 From: Andrew Richardson Date: Thu, 20 Jan 2022 18:53:59 -0500 Subject: [PATCH] Fix querying transfers by tx or type, batches by tx Signed-off-by: Andrew Richardson --- docs/swagger/swagger.yaml | 30 +++++++++++++++++++ internal/database/sqlcommon/batch_sql.go | 14 ++++----- .../database/sqlcommon/tokentransfer_sql.go | 22 +++++++------- pkg/database/plugin.go | 5 +++- 4 files changed, 52 insertions(+), 19 deletions(-) diff --git a/docs/swagger/swagger.yaml b/docs/swagger/swagger.yaml index 5f37b50525..e52eef542a 100644 --- a/docs/swagger/swagger.yaml +++ b/docs/swagger/swagger.yaml @@ -5581,6 +5581,21 @@ paths: name: tokenindex schema: type: string + - description: 'Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^' + in: query + name: tx.id + schema: + type: string + - description: 'Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^' + in: query + name: tx.type + schema: + type: string + - description: 'Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^' + in: query + name: type + schema: + type: string - description: 'Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^' in: query name: uri @@ -6954,6 +6969,21 @@ paths: name: tokenindex schema: type: string + - description: 'Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^' + in: query + name: tx.id + schema: + type: string + - description: 'Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^' + in: query + name: tx.type + schema: + type: string + - description: 'Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^' + in: query + name: type + schema: + type: string - description: 'Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^' in: query name: uri diff --git a/internal/database/sqlcommon/batch_sql.go b/internal/database/sqlcommon/batch_sql.go index 8acb6da7d9..af25ee9174 100644 --- a/internal/database/sqlcommon/batch_sql.go +++ b/internal/database/sqlcommon/batch_sql.go @@ -1,4 +1,4 @@ -// Copyright © 2021 Kaleido, Inc. +// Copyright © 2022 Kaleido, Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -45,12 +45,12 @@ var ( "node_id", } batchFilterFieldMap = map[string]string{ - "type": "btype", - "payloadref": "payload_ref", - "transaction.type": "tx_type", - "transaction.id": "tx_id", - "group": "group_hash", - "node": "node_id", + "type": "btype", + "payloadref": "payload_ref", + "tx.type": "tx_type", + "tx.id": "tx_id", + "group": "group_hash", + "node": "node_id", } ) diff --git a/internal/database/sqlcommon/tokentransfer_sql.go b/internal/database/sqlcommon/tokentransfer_sql.go index 6f2724f63a..f63731545f 100644 --- a/internal/database/sqlcommon/tokentransfer_sql.go +++ b/internal/database/sqlcommon/tokentransfer_sql.go @@ -1,4 +1,4 @@ -// Copyright © 2021 Kaleido, Inc. +// Copyright © 2022 Kaleido, Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -48,16 +48,16 @@ var ( "created", } tokenTransferFilterFieldMap = map[string]string{ - "localid": "local_id", - "pool": "pool_id", - "tokenindex": "token_index", - "from": "from_key", - "to": "to_key", - "protocolid": "protocol_id", - "message": "message_id", - "messagehash": "message_hash", - "transaction.type": "tx_type", - "transaction.id": "tx_id", + "localid": "local_id", + "pool": "pool_id", + "tokenindex": "token_index", + "from": "from_key", + "to": "to_key", + "protocolid": "protocol_id", + "message": "message_id", + "messagehash": "message_hash", + "tx.type": "tx_type", + "tx.id": "tx_id", } ) diff --git a/pkg/database/plugin.go b/pkg/database/plugin.go index 3439339f33..a6d2d4ae27 100644 --- a/pkg/database/plugin.go +++ b/pkg/database/plugin.go @@ -1,4 +1,4 @@ -// Copyright © 2021 Kaleido, Inc. +// Copyright © 2022 Kaleido, Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -808,6 +808,7 @@ var TokenBalanceQueryFactory = &queryFields{ // TokenTransferQueryFactory filter fields for token transfers var TokenTransferQueryFactory = &queryFields{ + "type": &StringField{}, "localid": &StringField{}, "pool": &UUIDField{}, "tokenindex": &StringField{}, @@ -822,4 +823,6 @@ var TokenTransferQueryFactory = &queryFields{ "message": &UUIDField{}, "messagehash": &Bytes32Field{}, "created": &TimeField{}, + "tx.type": &StringField{}, + "tx.id": &UUIDField{}, }