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,
"logs": test_helpers.MockReceipts[0].Logs,
"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{}{
"blockHash": blockHash,

View File

@ -317,7 +317,7 @@ func (ecr *CIDRetriever) RetrieveFilteredGQLLogs(tx *sqlx.Tx, rctFilter ReceiptF
id := 1
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.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
WHERE eth.log_cids.receipt_id = receipt_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),
BlockHash: common.HexToHash(l.BlockHash),
Index: uint(l.Index),
Removed: false, // TODO: check where to get this value
}
}
@ -211,10 +210,11 @@ func (f *IPLDFetcher) FetchLogs(logCIDs []customLog) ([]*types.Log, error) {
}
type logsCID struct {
Log *types.Log
CID string
RctCID string
RctData []byte
Log *types.Log
CID string
RctCID string
RctData []byte
RctStatus uint64
}
// FetchGQLLogs fetches logs for graphql.
@ -245,9 +245,10 @@ func (f *IPLDFetcher) FetchGQLLogs(logCIDs []customLog) ([]logsCID, error) {
Index: uint(l.Index),
TxHash: common.HexToHash(l.TxHash),
},
CID: l.LeafCID,
RctCID: l.RctCID,
RctData: l.RctData,
CID: l.LeafCID,
RctCID: l.RctCID,
RctData: l.RctData,
RctStatus: l.RctStatus,
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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