@ -8,25 +8,29 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/core/types"
)
)
var _ = ( * stTransactionMarshaling ) ( nil )
var _ = ( * stTransactionMarshaling ) ( nil )
// MarshalJSON marshals as JSON.
func ( s stTransaction ) MarshalJSON ( ) ( [ ] byte , error ) {
func ( s stTransaction ) MarshalJSON ( ) ( [ ] byte , error ) {
type stTransaction struct {
type stTransaction struct {
GasPrice * math . HexOrDecimal256 ` json:"gasPrice" `
GasPrice * math . HexOrDecimal256 ` json:"gasPrice" `
Nonce math . HexOrDecimal64 ` json:"nonce" `
Nonce math . HexOrDecimal64 ` json:"nonce" `
To string ` json:"to" `
To string ` json:"to" `
Data [ ] string ` json:"data" `
Data [ ] string ` json:"data" `
GasLimit [ ] math . HexOrDecimal64 ` json:"gasLimit" `
AccessLists [ ] * types . AccessList ` json:"accessLists,omitempty" `
Value [ ] string ` json:"value" `
GasLimit [ ] math . HexOrDecimal64 ` json:"gasLimit" `
PrivateKey hexutil . Bytes ` json:"secretKey" `
Value [ ] string ` json:"value" `
PrivateKey hexutil . Bytes ` json:"secretKey" `
}
}
var enc stTransaction
var enc stTransaction
enc . GasPrice = ( * math . HexOrDecimal256 ) ( s . GasPrice )
enc . GasPrice = ( * math . HexOrDecimal256 ) ( s . GasPrice )
enc . Nonce = math . HexOrDecimal64 ( s . Nonce )
enc . Nonce = math . HexOrDecimal64 ( s . Nonce )
enc . To = s . To
enc . To = s . To
enc . Data = s . Data
enc . Data = s . Data
enc . AccessLists = s . AccessLists
if s . GasLimit != nil {
if s . GasLimit != nil {
enc . GasLimit = make ( [ ] math . HexOrDecimal64 , len ( s . GasLimit ) )
enc . GasLimit = make ( [ ] math . HexOrDecimal64 , len ( s . GasLimit ) )
for k , v := range s . GasLimit {
for k , v := range s . GasLimit {
@ -38,15 +42,17 @@ func (s stTransaction) MarshalJSON() ([]byte, error) {
return json . Marshal ( & enc )
return json . Marshal ( & enc )
}
}
// UnmarshalJSON unmarshals from JSON.
func ( s * stTransaction ) UnmarshalJSON ( input [ ] byte ) error {
func ( s * stTransaction ) UnmarshalJSON ( input [ ] byte ) error {
type stTransaction struct {
type stTransaction struct {
GasPrice * math . HexOrDecimal256 ` json:"gasPrice" `
GasPrice * math . HexOrDecimal256 ` json:"gasPrice" `
Nonce * math . HexOrDecimal64 ` json:"nonce" `
Nonce * math . HexOrDecimal64 ` json:"nonce" `
To * string ` json:"to" `
To * string ` json:"to" `
Data [ ] string ` json:"data" `
Data [ ] string ` json:"data" `
GasLimit [ ] math . HexOrDecimal64 ` json:"gasLimit" `
AccessLists [ ] * types . AccessList ` json:"accessLists,omitempty" `
Value [ ] string ` json:"value" `
GasLimit [ ] math . HexOrDecimal64 ` json:"gasLimit" `
PrivateKey * hexutil . Bytes ` json:"secretKey" `
Value [ ] string ` json:"value" `
PrivateKey * hexutil . Bytes ` json:"secretKey" `
}
}
var dec stTransaction
var dec stTransaction
if err := json . Unmarshal ( input , & dec ) ; err != nil {
if err := json . Unmarshal ( input , & dec ) ; err != nil {
@ -64,6 +70,9 @@ func (s *stTransaction) UnmarshalJSON(input []byte) error {
if dec . Data != nil {
if dec . Data != nil {
s . Data = dec . Data
s . Data = dec . Data
}
}
if dec . AccessLists != nil {
s . AccessLists = dec . AccessLists
}
if dec . GasLimit != nil {
if dec . GasLimit != nil {
s . GasLimit = make ( [ ] uint64 , len ( dec . GasLimit ) )
s . GasLimit = make ( [ ] uint64 , len ( dec . GasLimit ) )
for k , v := range dec . GasLimit {
for k , v := range dec . GasLimit {