Skip to content

Commit 1430b67

Browse files
committed
Add BlobVersionedHashes to JSON-RPC Transaction result
1 parent 42c8071 commit 1430b67

File tree

2 files changed

+38
-33
lines changed

2 files changed

+38
-33
lines changed

core/types/transaction.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,12 @@ func (tx *Transaction) encodeTypedMinimal(w io.Writer) error {
156156
if _, err := w.Write([]byte{tx.Type()}); err != nil {
157157
return err
158158
}
159-
// TODO(inphi): clean
160159
if tx.Type() == BlobTxType {
161-
return EncodeSSZ(w, tx.inner.(*SignedBlobTx))
160+
blobTx, ok := tx.inner.(*SignedBlobTx)
161+
if !ok {
162+
return ErrInvalidTxType
163+
}
164+
return EncodeSSZ(w, blobTx)
162165
} else {
163166
return rlp.Encode(w, tx.inner)
164167
}

internal/ethapi/api.go

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,25 +1244,26 @@ func (s *PublicBlockChainAPI) rpcMarshalBlock(ctx context.Context, b *types.Bloc
12441244

12451245
// RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction
12461246
type RPCTransaction struct {
1247-
BlockHash *common.Hash `json:"blockHash"`
1248-
BlockNumber *hexutil.Big `json:"blockNumber"`
1249-
From common.Address `json:"from"`
1250-
Gas hexutil.Uint64 `json:"gas"`
1251-
GasPrice *hexutil.Big `json:"gasPrice"`
1252-
GasFeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"`
1253-
GasTipCap *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"`
1254-
Hash common.Hash `json:"hash"`
1255-
Input hexutil.Bytes `json:"input"`
1256-
Nonce hexutil.Uint64 `json:"nonce"`
1257-
To *common.Address `json:"to"`
1258-
TransactionIndex *hexutil.Uint64 `json:"transactionIndex"`
1259-
Value *hexutil.Big `json:"value"`
1260-
Type hexutil.Uint64 `json:"type"`
1261-
Accesses *types.AccessList `json:"accessList,omitempty"`
1262-
ChainID *hexutil.Big `json:"chainId,omitempty"`
1263-
V *hexutil.Big `json:"v"`
1264-
R *hexutil.Big `json:"r"`
1265-
S *hexutil.Big `json:"s"`
1247+
BlockHash *common.Hash `json:"blockHash"`
1248+
BlockNumber *hexutil.Big `json:"blockNumber"`
1249+
From common.Address `json:"from"`
1250+
Gas hexutil.Uint64 `json:"gas"`
1251+
GasPrice *hexutil.Big `json:"gasPrice"`
1252+
GasFeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"`
1253+
GasTipCap *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"`
1254+
Hash common.Hash `json:"hash"`
1255+
Input hexutil.Bytes `json:"input"`
1256+
Nonce hexutil.Uint64 `json:"nonce"`
1257+
To *common.Address `json:"to"`
1258+
TransactionIndex *hexutil.Uint64 `json:"transactionIndex"`
1259+
Value *hexutil.Big `json:"value"`
1260+
Type hexutil.Uint64 `json:"type"`
1261+
Accesses *types.AccessList `json:"accessList,omitempty"`
1262+
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
1263+
ChainID *hexutil.Big `json:"chainId,omitempty"`
1264+
V *hexutil.Big `json:"v"`
1265+
R *hexutil.Big `json:"r"`
1266+
S *hexutil.Big `json:"s"`
12661267
}
12671268

12681269
// newRPCTransaction returns a transaction that will serialize to the RPC
@@ -1272,18 +1273,19 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
12721273
from, _ := types.Sender(signer, tx)
12731274
v, r, s := tx.RawSignatureValues()
12741275
result := &RPCTransaction{
1275-
Type: hexutil.Uint64(tx.Type()),
1276-
From: from,
1277-
Gas: hexutil.Uint64(tx.Gas()),
1278-
GasPrice: (*hexutil.Big)(tx.GasPrice()),
1279-
Hash: tx.Hash(),
1280-
Input: hexutil.Bytes(tx.Data()),
1281-
Nonce: hexutil.Uint64(tx.Nonce()),
1282-
To: tx.To(),
1283-
Value: (*hexutil.Big)(tx.Value()),
1284-
V: (*hexutil.Big)(v),
1285-
R: (*hexutil.Big)(r),
1286-
S: (*hexutil.Big)(s),
1276+
Type: hexutil.Uint64(tx.Type()),
1277+
From: from,
1278+
Gas: hexutil.Uint64(tx.Gas()),
1279+
GasPrice: (*hexutil.Big)(tx.GasPrice()),
1280+
Hash: tx.Hash(),
1281+
Input: hexutil.Bytes(tx.Data()),
1282+
Nonce: hexutil.Uint64(tx.Nonce()),
1283+
To: tx.To(),
1284+
BlobVersionedHashes: tx.BlobVersionedHashes(),
1285+
Value: (*hexutil.Big)(tx.Value()),
1286+
V: (*hexutil.Big)(v),
1287+
R: (*hexutil.Big)(r),
1288+
S: (*hexutil.Big)(s),
12871289
}
12881290
if blockHash != (common.Hash{}) {
12891291
result.BlockHash = &blockHash

0 commit comments

Comments
 (0)