Skip to content

Commit

Permalink
Get receipt CID and block data for logs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwinphatak authored and arijitAD committed Jun 28, 2021
1 parent 42f0667 commit 18266c4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/trie"

"github.com/vulcanize/ipfs-ethdb"
ipfsethdb "github.com/vulcanize/ipfs-ethdb"
"github.com/vulcanize/ipld-eth-indexer/pkg/ipfs"
"github.com/vulcanize/ipld-eth-indexer/pkg/postgres"
shared2 "github.com/vulcanize/ipld-eth-indexer/pkg/shared"
Expand All @@ -59,10 +59,10 @@ var (
const (
RetrieveCanonicalBlockHashByNumber = `SELECT block_hash FROM eth.header_cids
INNER JOIN public.blocks ON (header_cids.mh_key = blocks.key)
WHERE id = (SELECT canonical_header_id($1))`
WHERE id = (SELECT public.canonical_header($1))`
RetrieveCanonicalHeaderByNumber = `SELECT cid, data FROM eth.header_cids
INNER JOIN public.blocks ON (header_cids.mh_key = blocks.key)
WHERE id = (SELECT canonical_header_id($1))`
WHERE id = (SELECT public.canonical_header($1))`
RetrieveTD = `SELECT td FROM eth.header_cids
WHERE header_cids.block_hash = $1`
RetrieveRPCTransaction = `SELECT blocks.data, block_hash, block_number, index FROM public.blocks, eth.transaction_cids, eth.header_cids
Expand All @@ -76,7 +76,7 @@ const (
AND block_number <= (SELECT block_number
FROM eth.header_cids
WHERE block_hash = $2)
AND header_cids.id = (SELECT canonical_header_id(block_number))
AND header_cids.id = (SELECT public.canonical_header(block_number))
ORDER BY block_number DESC
LIMIT 1`
RetrieveCodeByMhKey = `SELECT data FROM public.blocks WHERE key = $1`
Expand Down Expand Up @@ -509,6 +509,7 @@ func (b *Backend) GetLogs(ctx context.Context, hash common.Hash) ([][]*types.Log
if err := rlp.DecodeBytes(rctBytes, &rct); err != nil {
return nil, err
}

logs[i] = rct.Logs
}
return logs, nil
Expand Down
10 changes: 10 additions & 0 deletions pkg/graphql/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ type Log struct {
backend *eth.Backend
transaction *Transaction
log *types.Log
cid string
ipldBlock []byte
}

func (l *Log) Transaction(ctx context.Context) *Transaction {
Expand All @@ -117,6 +119,14 @@ func (l *Log) Data(ctx context.Context) hexutil.Bytes {
return hexutil.Bytes(l.log.Data)
}

func (l *Log) Cid(ctx context.Context) string {
return l.cid
}

func (l *Log) IpldBlock(ctx context.Context) hexutil.Bytes {
return hexutil.Bytes(l.ipldBlock)
}

// Transaction represents an Ethereum transaction.
// backend and hash are mandatory; all others will be fetched when required.
type Transaction struct {
Expand Down
6 changes: 6 additions & 0 deletions pkg/graphql/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ const schema string = `
data: Bytes!
# Transaction is the transaction that generated this log entry.
transaction: Transaction!
# CID for the Receipt IPLD block this Log exists in.
cid: String!
# IPLD block data for the Receipt this Log exists in.
ipldBlock: Bytes!
}
# Transaction is an Ethereum transaction.
Expand Down

0 comments on commit 18266c4

Please sign in to comment.