Review changes

This commit is contained in:
nikugogoi
2022-06-06 15:54:06 +05:30
parent c19cc5c44d
commit 31e9a7dc5e
4 changed files with 64 additions and 58 deletions
+36 -36
View File
@@ -21,14 +21,14 @@ type GetStorageAt struct {
}
type LogResponse struct {
Topics []common.Hash `json:"topics"`
Data hexutil.Bytes `json:"data"`
Transaction TransactionResp `json:"transaction"`
ReceiptCID string `json:"receiptCID"`
Status int32 `json:"status"`
Topics []common.Hash `json:"topics"`
Data hexutil.Bytes `json:"data"`
Transaction TransactionResponse `json:"transaction"`
ReceiptCID string `json:"receiptCID"`
Status int32 `json:"status"`
}
type TransactionResp struct {
type TransactionResponse struct {
Hash common.Hash `json:"hash"`
}
@@ -36,50 +36,50 @@ type GetLogs struct {
Responses []LogResponse `json:"getLogs"`
}
type IPFSBlockResp struct {
type IPFSBlockResponse struct {
Key string `json:"key"`
Data string `json:"data"`
}
type EthTransactionCidResp struct {
Cid string `json:"cid"`
TxHash string `json:"txHash"`
Index int32 `json:"index"`
Src string `json:"src"`
Dst string `json:"dst"`
BlockByMhKey IPFSBlockResp `json:"blockByMhKey"`
type EthTransactionCidResponse struct {
Cid string `json:"cid"`
TxHash string `json:"txHash"`
Index int32 `json:"index"`
Src string `json:"src"`
Dst string `json:"dst"`
BlockByMhKey IPFSBlockResponse `json:"blockByMhKey"`
}
type EthTransactionCidByTxHash struct {
Response EthTransactionCidResp `json:"ethTransactionCidByTxHash"`
Response EthTransactionCidResponse `json:"ethTransactionCidByTxHash"`
}
type EthTransactionCidsByHeaderIdResp struct {
Nodes []EthTransactionCidResp `json:"nodes"`
type EthTransactionCidsByHeaderIdResponse struct {
Nodes []EthTransactionCidResponse `json:"nodes"`
}
type EthHeaderCidResp struct {
Cid string `json:"cid"`
BlockNumber BigInt `json:"blockNumber"`
BlockHash string `json:"blockHash"`
ParentHash string `json:"parentHash"`
Timestamp BigInt `json:"timestamp"`
StateRoot string `json:"stateRoot"`
Td BigInt `json:"td"`
TxRoot string `json:"txRoot"`
ReceiptRoot string `json:"receiptRoot"`
UncleRoot string `json:"uncleRoot"`
Bloom string `json:"bloom"`
EthTransactionCidsByHeaderId EthTransactionCidsByHeaderIdResp `json:"ethTransactionCidsByHeaderId"`
BlockByMhKey IPFSBlockResp `json:"blockByMhKey"`
type EthHeaderCidResponse struct {
Cid string `json:"cid"`
BlockNumber BigInt `json:"blockNumber"`
BlockHash string `json:"blockHash"`
ParentHash string `json:"parentHash"`
Timestamp BigInt `json:"timestamp"`
StateRoot string `json:"stateRoot"`
Td BigInt `json:"td"`
TxRoot string `json:"txRoot"`
ReceiptRoot string `json:"receiptRoot"`
UncleRoot string `json:"uncleRoot"`
Bloom string `json:"bloom"`
EthTransactionCidsByHeaderId EthTransactionCidsByHeaderIdResponse `json:"ethTransactionCidsByHeaderId"`
BlockByMhKey IPFSBlockResponse `json:"blockByMhKey"`
}
type AllEthHeaderCidsResp struct {
Nodes []EthHeaderCidResp `json:"nodes"`
type AllEthHeaderCidsResponse struct {
Nodes []EthHeaderCidResponse `json:"nodes"`
}
type AllEthHeaderCids struct {
Response AllEthHeaderCidsResp `json:"allEthHeaderCids"`
Response AllEthHeaderCidsResponse `json:"allEthHeaderCids"`
}
type Client struct {
@@ -164,7 +164,7 @@ func (c *Client) GetStorageAt(ctx context.Context, hash common.Hash, address com
return &storageAt.Response, nil
}
func (c *Client) AllEthHeaderCids(ctx context.Context, condition EthHeaderCidCondition) (*AllEthHeaderCidsResp, error) {
func (c *Client) AllEthHeaderCids(ctx context.Context, condition EthHeaderCidCondition) (*AllEthHeaderCidsResponse, error) {
var params string
if condition.BlockHash != nil {
params = fmt.Sprintf(`blockHash: "%s"`, *condition.BlockHash)
@@ -228,7 +228,7 @@ func (c *Client) AllEthHeaderCids(ctx context.Context, condition EthHeaderCidCon
return &allEthHeaderCids.Response, nil
}
func (c *Client) EthTransactionCidByTxHash(ctx context.Context, txHash string) (*EthTransactionCidResp, error) {
func (c *Client) EthTransactionCidByTxHash(ctx context.Context, txHash string) (*EthTransactionCidResponse, error) {
getTxQuery := fmt.Sprintf(`
query{
ethTransactionCidByTxHash(txHash: "%s") {
+1 -1
View File
@@ -1263,7 +1263,7 @@ type EthHeaderCidCondition struct {
func (r *Resolver) AllEthHeaderCids(ctx context.Context, args struct {
Condition *EthHeaderCidCondition
}) (*EthHeaderCidsConnection, error) {
var headerCIDs []eth.HeaderCid
var headerCIDs []eth.HeaderCidRecord
var err error
if args.Condition.BlockHash != nil {
headerCID, err := r.backend.Retriever.RetrieveHeaderAndTxCIDsByBlockHash(common.HexToHash(*args.Condition.BlockHash))
+4 -4
View File
@@ -181,7 +181,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()},
Transaction: graphql.TransactionResponse{Hash: test_helpers.MockTransactions[0].Hash()},
ReceiptCID: test_helpers.Rct1CID.String(),
Status: int32(test_helpers.MockReceipts[0].Status),
},
@@ -198,7 +198,7 @@ var _ = Describe("GraphQL", func() {
{
Topics: test_helpers.MockLog6.Topics,
Data: hexutil.Bytes(test_helpers.MockLog6.Data),
Transaction: graphql.TransactionResp{Hash: test_helpers.MockTransactions[3].Hash()},
Transaction: graphql.TransactionResponse{Hash: test_helpers.MockTransactions[3].Hash()},
ReceiptCID: test_helpers.Rct4CID.String(),
Status: int32(test_helpers.MockReceipts[3].Status),
},
@@ -297,7 +297,7 @@ var _ = Describe("GraphQL", func() {
})
})
func compareEthHeaderCid(ethHeaderCid graphql.EthHeaderCidResp, headerCID eth.HeaderCid) {
func compareEthHeaderCid(ethHeaderCid graphql.EthHeaderCidResponse, headerCID eth.HeaderCidRecord) {
blockNumber, err := strconv.ParseInt(headerCID.BlockNumber, 10, 64)
Expect(err).ToNot(HaveOccurred())
@@ -325,7 +325,7 @@ func compareEthHeaderCid(ethHeaderCid graphql.EthHeaderCidResp, headerCID eth.He
Expect(ethHeaderCid.BlockByMhKey.Key).To(Equal(headerCID.IPLD.Key))
}
func compareEthTxCid(ethTxCid graphql.EthTransactionCidResp, txCID eth.TransactionCid) {
func compareEthTxCid(ethTxCid graphql.EthTransactionCidResponse, txCID eth.TransactionCidRecord) {
Expect(ethTxCid.Cid).To(Equal(txCID.CID))
Expect(ethTxCid.TxHash).To(Equal(txCID.TxHash))
Expect(ethTxCid.Index).To(Equal(int32(txCID.Index)))