From c3170e1fce255c802ccb1d13992008e87f60cb55 Mon Sep 17 00:00:00 2001 From: Aneeque Date: Fri, 29 Nov 2024 09:42:20 +0000 Subject: [PATCH] Remove `transaction_hash` from `getBlockWithReceipts` (#2294) `starknet_getBlockWithReceipts` was added in 0.7.x rpc spec, and its array of `transaction` doesn't contain `transaction_hash` instead its receipt contains the `transaction_hash`. --- rpc/block.go | 4 +++- rpc/block_test.go | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/rpc/block.go b/rpc/block.go index 2902978078..302ccdac42 100644 --- a/rpc/block.go +++ b/rpc/block.go @@ -226,8 +226,10 @@ func (h *Handler) BlockWithReceipts(id BlockID) (*BlockWithReceipts, *jsonrpc.Er for index, txn := range block.Transactions { r := block.Receipts[index] + t := AdaptTransaction(txn) + t.Hash = nil txsWithReceipts[index] = TransactionWithReceipt{ - Transaction: AdaptTransaction(txn), + Transaction: t, // block_hash, block_number are optional in BlockWithReceipts response Receipt: AdaptReceipt(r, txn, finalityStatus, nil, 0), } diff --git a/rpc/block_test.go b/rpc/block_test.go index a6fa1d28ac..99af2bf3d9 100644 --- a/rpc/block_test.go +++ b/rpc/block_test.go @@ -606,6 +606,7 @@ func TestBlockWithReceipts(t *testing.T) { for i, tx := range block0.Transactions { receipt := block0.Receipts[i] adaptedTx := rpc.AdaptTransaction(tx) + adaptedTx.Hash = nil txsWithReceipt = append(txsWithReceipt, rpc.TransactionWithReceipt{ Transaction: adaptedTx, @@ -650,6 +651,7 @@ func TestBlockWithReceipts(t *testing.T) { for i, tx := range block1.Transactions { receipt := block1.Receipts[i] adaptedTx := rpc.AdaptTransaction(tx) + adaptedTx.Hash = nil transactions = append(transactions, rpc.TransactionWithReceipt{ Transaction: adaptedTx,