Skip to content

Commit

Permalink
Remove transaction_hash from getBlockWithReceipts (#2294)
Browse files Browse the repository at this point in the history
`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`.
  • Loading branch information
IronGauntlets authored Nov 29, 2024
1 parent 93803e9 commit c3170e1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rpc/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
2 changes: 2 additions & 0 deletions rpc/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit c3170e1

Please sign in to comment.