Skip to content

Commit

Permalink
Encode internal wrapped object as JSON child (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
ferranbt authored Sep 21, 2023
1 parent 4d3e6fa commit 5352786
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
40 changes: 20 additions & 20 deletions core/types/transaction_marshalling.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@ import (
type txJSON struct {
Type hexutil.Uint64 `json:"type"`

ChainID *hexutil.Big `json:"chainId,omitempty"`
Nonce *hexutil.Uint64 `json:"nonce"`
To *common.Address `json:"to"`
Gas *hexutil.Uint64 `json:"gas"`
GasPrice *hexutil.Big `json:"gasPrice"`
MaxPriorityFeePerGas *hexutil.Big `json:"maxPriorityFeePerGas"`
MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"`
MaxFeePerDataGas *hexutil.Big `json:"maxFeePerDataGas,omitempty"`
Value *hexutil.Big `json:"value"`
Input *hexutil.Bytes `json:"input"`
AccessList *AccessList `json:"accessList,omitempty"`
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
ExecutionNode *common.Address `json:"executionNode,omitempty"`
Wrapped *hexutil.Bytes `json:"wrapped,omitempty"`
ConfidentialComputeResult *hexutil.Bytes `json:"confidentialComputeResult,omitempty"`
V *hexutil.Big `json:"v"`
R *hexutil.Big `json:"r"`
S *hexutil.Big `json:"s"`
ChainID *hexutil.Big `json:"chainId,omitempty"`
Nonce *hexutil.Uint64 `json:"nonce"`
To *common.Address `json:"to"`
Gas *hexutil.Uint64 `json:"gas"`
GasPrice *hexutil.Big `json:"gasPrice"`
MaxPriorityFeePerGas *hexutil.Big `json:"maxPriorityFeePerGas"`
MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"`
MaxFeePerDataGas *hexutil.Big `json:"maxFeePerDataGas,omitempty"`
Value *hexutil.Big `json:"value"`
Input *hexutil.Bytes `json:"input"`
AccessList *AccessList `json:"accessList,omitempty"`
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
ExecutionNode *common.Address `json:"executionNode,omitempty"`
Wrapped *json.RawMessage `json:"wrapped,omitempty"`
ConfidentialComputeResult *hexutil.Bytes `json:"confidentialComputeResult,omitempty"`
V *hexutil.Big `json:"v"`
R *hexutil.Big `json:"r"`
S *hexutil.Big `json:"s"`

// Only used for encoding:
Hash common.Hash `json:"hash"`
Expand Down Expand Up @@ -124,7 +124,7 @@ func (tx *Transaction) MarshalJSON() ([]byte, error) {
return nil, err
}

enc.Wrapped = (*hexutil.Bytes)(&wrapped)
enc.Wrapped = (*json.RawMessage)(&wrapped)
enc.ChainID = (*hexutil.Big)(itx.ChainID)

case *SuaveTransaction:
Expand All @@ -135,7 +135,7 @@ func (tx *Transaction) MarshalJSON() ([]byte, error) {
return nil, err
}

enc.Wrapped = (*hexutil.Bytes)(&wrapped)
enc.Wrapped = (*json.RawMessage)(&wrapped)

enc.ChainID = (*hexutil.Big)(itx.ChainID)
enc.ConfidentialComputeResult = (*hexutil.Bytes)(&itx.ConfidentialComputeResult)
Expand Down
7 changes: 4 additions & 3 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package ethapi
import (
"context"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"math/big"
Expand Down Expand Up @@ -1376,7 +1377,7 @@ type RPCTransaction struct {
Accesses *types.AccessList `json:"accessList,omitempty"`
ChainID *hexutil.Big `json:"chainId,omitempty"`
ExecutionNode *common.Address `json:"executionNode,omitempty"`
Wrapped *hexutil.Bytes `json:"wrapped,omitempty"`
Wrapped *json.RawMessage `json:"wrapped,omitempty"`
ConfidentialComputeResult *hexutil.Bytes `json:"confidentialComputeResult,omitempty"`
V *hexutil.Big `json:"v"`
R *hexutil.Big `json:"r"`
Expand Down Expand Up @@ -1449,7 +1450,7 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
return nil
}

result.Wrapped = (*hexutil.Bytes)(&wrappedBytes)
result.Wrapped = (*json.RawMessage)(&wrappedBytes)
result.ChainID = (*hexutil.Big)(tx.ChainId())
case types.SuaveTxType:
inner, ok := types.CastTxInner[*types.SuaveTransaction](tx)
Expand All @@ -1467,7 +1468,7 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
return nil
}

result.Wrapped = (*hexutil.Bytes)(&wrappedBytes)
result.Wrapped = (*json.RawMessage)(&wrappedBytes)
result.ConfidentialComputeResult = (*hexutil.Bytes)(&inner.ConfidentialComputeResult)
result.ChainID = (*hexutil.Big)(tx.ChainId())
}
Expand Down

0 comments on commit 5352786

Please sign in to comment.