From fd5f201bbde1797e5bc74ae40082437eced8c29c Mon Sep 17 00:00:00 2001 From: prathamesh0 Date: Tue, 4 Oct 2022 16:36:23 +0530 Subject: [PATCH] Update getLogs GQL API to accept multiple addresses --- Makefile | 2 +- pkg/graphql/graphql.go | 11 +++++++---- pkg/graphql/schema.go | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 83f82238..2ca31916 100644 --- a/Makefile +++ b/Makefile @@ -54,7 +54,7 @@ TEST_CONNECT_STRING_LOCAL = postgresql://$(USER)@$(HOST_NAME):$(PORT)/$(TEST_DB) test: go vet ./... go fmt ./... - go run github.com/onsi/ginkgo/ginkgo -r --skipPackage=test + go run github.com/onsi/ginkgo/ginkgo -r --skipPackage=test .PHONY: integrationtest integrationtest: diff --git a/pkg/graphql/graphql.go b/pkg/graphql/graphql.go index b4dc9ffe..97282037 100644 --- a/pkg/graphql/graphql.go +++ b/pkg/graphql/graphql.go @@ -1037,12 +1037,15 @@ func (r *Resolver) GetStorageAt(ctx context.Context, args struct { func (r *Resolver) GetLogs(ctx context.Context, args struct { BlockHash common.Hash - Contract *common.Address + Addresses *[]common.Address }) (*[]*Log, error) { - var filter eth.ReceiptFilter - if args.Contract != nil { - filter.LogAddresses = []string{args.Contract.String()} + + if args.Addresses != nil { + filter.LogAddresses = make([]string, len(*args.Addresses)) + for i, address := range *args.Addresses { + filter.LogAddresses[i] = address.String() + } } // Begin tx diff --git a/pkg/graphql/schema.go b/pkg/graphql/schema.go index eb0d89fc..d07d311b 100644 --- a/pkg/graphql/schema.go +++ b/pkg/graphql/schema.go @@ -343,7 +343,7 @@ const schema string = ` getStorageAt(blockHash: Bytes32!, contract: Address!, slot: Bytes32!): StorageResult # Get contract logs by block hash and contract address. - getLogs(blockHash: Bytes32!, contract: Address): [Log!] + getLogs(blockHash: Bytes32!, addresses: [Address!]): [Log!] # PostGraphile alternative to get headers with transactions using block number or block hash. allEthHeaderCids(condition: EthHeaderCidCondition): EthHeaderCidsConnection