Skip to content

Commit 8b14002

Browse files
committed
Add MaxFeePerDataGas to transaction JSON
1 parent b38efe1 commit 8b14002

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

core/types/transaction_marshalling.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ type txJSON struct {
5050
AccessList *AccessList `json:"accessList,omitempty"`
5151

5252
// Blob transaction fields:
53+
MaxFeePerDataGas *hexutil.Big `json:"maxFeePerDataGas,omitempty"`
5354
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
5455
Blobs Blobs `json:"blobs,omitempty"`
5556
BlobKzgs BlobKzgs `json:"blobKzgs,omitempty"`
@@ -117,6 +118,7 @@ func (t *Transaction) MarshalJSON() ([]byte, error) {
117118
enc.V = (*hexutil.Big)(v)
118119
enc.R = (*hexutil.Big)(r)
119120
enc.S = (*hexutil.Big)(s)
121+
enc.MaxFeePerDataGas = (*hexutil.Big)(u256ToBig(&tx.Message.MaxFeePerDataGas))
120122
enc.BlobVersionedHashes = tx.Message.BlobVersionedHashes
121123
if t.wrapData != nil {
122124
enc.Blobs = t.wrapData.blobs()
@@ -347,6 +349,10 @@ func (t *Transaction) UnmarshalJSON(input []byte) error {
347349
return err
348350
}
349351
}
352+
itx.Message.MaxFeePerDataGas.SetFromBig((*big.Int)(dec.MaxFeePerDataGas))
353+
if dec.MaxFeePerDataGas == nil {
354+
return errors.New("missing required field 'maxFeePerDataGas' for txdata")
355+
}
350356
itx.Message.BlobVersionedHashes = dec.BlobVersionedHashes
351357
// A BlobTx may not contain data
352358
if len(dec.Blobs) != 0 || len(dec.BlobKzgs) != 0 {

core/types/transaction_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ func TestBlobTransactionMinimalCodec(t *testing.T) {
544544
GasFeeCap: view.Uint256View(*uint256.NewInt(10)),
545545
AccessList: AccessListView(accesses),
546546
BlobVersionedHashes: VersionedHashesView{common.HexToHash("0x01624652859a6e98ffc1608e2af0147ca4e86e1ce27672d8d3f3c9d4ffd6ef7e")},
547+
MaxFeePerDataGas: view.Uint256View(*uint256.NewInt(10000000)),
547548
},
548549
}
549550
tx, err := SignNewTx(key, signer, txdata)

0 commit comments

Comments
 (0)