Add reciept status in log for graphql.

This commit is contained in:
Arijit Das 2021-08-30 20:59:54 +05:30
parent a28892f1d3
commit d0c3241730
9 changed files with 25 additions and 11 deletions

View File

@ -151,7 +151,7 @@ var (
"contractAddress": nil, "contractAddress": nil,
"logs": test_helpers.MockReceipts[0].Logs, "logs": test_helpers.MockReceipts[0].Logs,
"logsBloom": test_helpers.MockReceipts[0].Bloom, "logsBloom": test_helpers.MockReceipts[0].Bloom,
"root": hexutil.Bytes(test_helpers.MockReceipts[0].PostState), "status": hexutil.Uint(test_helpers.MockReceipts[0].Status),
} }
expectedReceipt2 = map[string]interface{}{ expectedReceipt2 = map[string]interface{}{
"blockHash": blockHash, "blockHash": blockHash,

View File

@ -317,7 +317,7 @@ func (ecr *CIDRetriever) RetrieveFilteredGQLLogs(tx *sqlx.Tx, rctFilter ReceiptF
id := 1 id := 1
pgStr := `SELECT eth.log_cids.index, eth.log_cids.receipt_id, pgStr := `SELECT eth.log_cids.index, eth.log_cids.receipt_id,
eth.log_cids.address, eth.log_cids.topic0, eth.log_cids.topic1, eth.log_cids.topic2, eth.log_cids.topic3, eth.log_cids.address, eth.log_cids.topic0, eth.log_cids.topic1, eth.log_cids.topic2, eth.log_cids.topic3,
eth.log_cids.log_data, eth.transaction_cids.tx_hash, data, eth.receipt_cids.cid eth.log_cids.log_data, eth.transaction_cids.tx_hash, data, eth.receipt_cids.cid, eth.receipt_cids.post_status
FROM eth.log_cids, eth.receipt_cids, eth.transaction_cids, eth.header_cids, public.blocks FROM eth.log_cids, eth.receipt_cids, eth.transaction_cids, eth.header_cids, public.blocks
WHERE eth.log_cids.receipt_id = receipt_cids.id WHERE eth.log_cids.receipt_id = receipt_cids.id
AND receipt_cids.tx_id = transaction_cids.id AND receipt_cids.tx_id = transaction_cids.id

View File

@ -203,7 +203,6 @@ func (f *IPLDFetcher) FetchLogs(logCIDs []customLog) ([]*types.Log, error) {
TxIndex: uint(l.TxnIndex), TxIndex: uint(l.TxnIndex),
BlockHash: common.HexToHash(l.BlockHash), BlockHash: common.HexToHash(l.BlockHash),
Index: uint(l.Index), Index: uint(l.Index),
Removed: false, // TODO: check where to get this value
} }
} }
@ -215,6 +214,7 @@ type logsCID struct {
CID string CID string
RctCID string RctCID string
RctData []byte RctData []byte
RctStatus uint64
} }
// FetchGQLLogs fetches logs for graphql. // FetchGQLLogs fetches logs for graphql.
@ -248,6 +248,7 @@ func (f *IPLDFetcher) FetchGQLLogs(logCIDs []customLog) ([]logsCID, error) {
CID: l.LeafCID, CID: l.LeafCID,
RctCID: l.RctCID, RctCID: l.RctCID,
RctData: l.RctData, RctData: l.RctData,
RctStatus: l.RctStatus,
} }
} }

View File

@ -608,7 +608,7 @@ func createLegacyTransactionsAndReceipts() (types.Transactions, types.Receipts,
log.Fatal(err) log.Fatal(err)
} }
// make receipts // make receipts
mockReceipt1 := types.NewReceipt(common.HexToHash("0x0").Bytes(), false, 50) mockReceipt1 := types.NewReceipt(nil, false, 50)
hash1 := signedTrx1.Hash() hash1 := signedTrx1.Hash()
MockLog1.TxHash = hash1 MockLog1.TxHash = hash1

View File

@ -183,6 +183,7 @@ type customLog struct {
Topic3 string `db:"topic3"` Topic3 string `db:"topic3"`
RctData []byte `db:"data"` RctData []byte `db:"data"`
RctCID string `db:"cid"` RctCID string `db:"cid"`
RctStatus uint64 `db:"post_status"`
BlockNumber string `db:"block_number"` BlockNumber string `db:"block_number"`
BlockHash string `db:"block_hash"` BlockHash string `db:"block_hash"`
TxnIndex int64 `db:"txn_index"` TxnIndex int64 `db:"txn_index"`

View File

@ -24,6 +24,7 @@ type LogResponse struct {
Topics []common.Hash `json:"topics"` Topics []common.Hash `json:"topics"`
Data hexutil.Bytes `json:"data"` Data hexutil.Bytes `json:"data"`
Transaction TransactionResp `json:"transaction"` Transaction TransactionResp `json:"transaction"`
Status int32 `json:"status"`
} }
type TransactionResp struct { type TransactionResp struct {
@ -52,6 +53,7 @@ func (c *Client) GetLogs(ctx context.Context, hash common.Hash, address common.A
transaction { transaction {
hash hash
} }
status
} }
} }
`, hash.String(), address.String()) `, hash.String(), address.String())

View File

@ -95,6 +95,7 @@ type Log struct {
cid string cid string
receiptCID string receiptCID string
ipldBlock []byte ipldBlock []byte
status uint64
} }
func (l *Log) Transaction(ctx context.Context) *Transaction { func (l *Log) Transaction(ctx context.Context) *Transaction {
@ -129,6 +130,10 @@ func (l *Log) IpldBlock(ctx context.Context) hexutil.Bytes {
return hexutil.Bytes(l.ipldBlock) return hexutil.Bytes(l.ipldBlock)
} }
func (l *Log) Status(ctx context.Context) int32 {
return int32(l.status)
}
// Transaction represents an Ethereum transaction. // Transaction represents an Ethereum transaction.
// backend and hash are mandatory; all others will be fetched when required. // backend and hash are mandatory; all others will be fetched when required.
type Transaction struct { type Transaction struct {
@ -1039,6 +1044,7 @@ func (r *Resolver) GetLogs(ctx context.Context, args struct {
transaction: &Transaction{ transaction: &Transaction{
hash: l.Log.TxHash, hash: l.Log.TxHash,
}, },
status: l.RctStatus,
}) })
} }

View File

@ -191,6 +191,7 @@ var _ = Describe("GraphQL", func() {
Topics: test_helpers.MockLog1.Topics, Topics: test_helpers.MockLog1.Topics,
Data: hexutil.Bytes(test_helpers.MockLog1.Data), Data: hexutil.Bytes(test_helpers.MockLog1.Data),
Transaction: graphql.TransactionResp{Hash: test_helpers.MockTransactions[0].Hash()}, Transaction: graphql.TransactionResp{Hash: test_helpers.MockTransactions[0].Hash()},
Status: int32(test_helpers.MockReceipts[0].Status),
}, },
} }
Expect(logs).To(Equal(expectedLogs)) Expect(logs).To(Equal(expectedLogs))

View File

@ -72,6 +72,9 @@ const schema string = `
# IPLD block data for the Receipt this Log exists in. # IPLD block data for the Receipt this Log exists in.
ipldBlock: Bytes! ipldBlock: Bytes!
# Status of the Receipt IPLD block this Log exists in.
status: Int!
} }
# Transaction is an Ethereum transaction. # Transaction is an Ethereum transaction.