make checks more strict

This commit is contained in:
Sina Mahmoodi 2024-01-11 15:19:34 +03:30
parent b5c2db7368
commit 3503dde3c7
2 changed files with 11 additions and 6 deletions

View file

@ -470,7 +470,7 @@ func (s *PersonalAccountAPI) SendTransaction(ctx context.Context, args Transacti
s.nonceLock.LockAddr(args.from()) s.nonceLock.LockAddr(args.from())
defer s.nonceLock.UnlockAddr(args.from()) defer s.nonceLock.UnlockAddr(args.from())
} }
if args.BlobVersionedHashes != nil { if args.IsEIP4844() {
return common.Hash{}, errBlobTxNotSupported return common.Hash{}, errBlobTxNotSupported
} }
signed, err := s.signTransaction(ctx, &args, passwd) signed, err := s.signTransaction(ctx, &args, passwd)
@ -498,8 +498,8 @@ func (s *PersonalAccountAPI) SignTransaction(ctx context.Context, args Transacti
if args.GasPrice == nil && (args.MaxFeePerGas == nil || args.MaxPriorityFeePerGas == nil) { if args.GasPrice == nil && (args.MaxFeePerGas == nil || args.MaxPriorityFeePerGas == nil) {
return nil, errors.New("missing gasPrice or maxFeePerGas/maxPriorityFeePerGas") return nil, errors.New("missing gasPrice or maxFeePerGas/maxPriorityFeePerGas")
} }
if args.BlobVersionedHashes != nil && args.MaxFeePerBlobGas == nil { if args.IsEIP4844() && (args.BlobVersionedHashes == nil || args.MaxFeePerBlobGas == nil) {
return nil, errors.New("missing maxFeePerBlobGas") return nil, errors.New("missing maxFeePerBlobGas or blobVersionedHashes")
} }
if args.Nonce == nil { if args.Nonce == nil {
return nil, errors.New("nonce not specified") return nil, errors.New("nonce not specified")
@ -1819,7 +1819,7 @@ func (s *TransactionAPI) SendTransaction(ctx context.Context, args TransactionAr
s.nonceLock.LockAddr(args.from()) s.nonceLock.LockAddr(args.from())
defer s.nonceLock.UnlockAddr(args.from()) defer s.nonceLock.UnlockAddr(args.from())
} }
if args.BlobVersionedHashes != nil { if args.IsEIP4844() {
return common.Hash{}, errBlobTxNotSupported return common.Hash{}, errBlobTxNotSupported
} }
@ -1906,8 +1906,8 @@ func (s *TransactionAPI) SignTransaction(ctx context.Context, args TransactionAr
if args.GasPrice == nil && (args.MaxPriorityFeePerGas == nil || args.MaxFeePerGas == nil) { if args.GasPrice == nil && (args.MaxPriorityFeePerGas == nil || args.MaxFeePerGas == nil) {
return nil, errors.New("missing gasPrice or maxFeePerGas/maxPriorityFeePerGas") return nil, errors.New("missing gasPrice or maxFeePerGas/maxPriorityFeePerGas")
} }
if args.BlobVersionedHashes != nil && args.MaxFeePerBlobGas == nil { if args.IsEIP4844() && (args.BlobVersionedHashes == nil || args.MaxFeePerBlobGas == nil) {
return nil, errors.New("missing maxFeePerBlobGas") return nil, errors.New("missing maxFeePerBlobGas or blobVersionedHashes")
} }
if args.Nonce == nil { if args.Nonce == nil {
return nil, errors.New("nonce not specified") return nil, errors.New("nonce not specified")

View file

@ -408,3 +408,8 @@ func (args *TransactionArgs) toTransaction() *types.Transaction {
func (args *TransactionArgs) ToTransaction() *types.Transaction { func (args *TransactionArgs) ToTransaction() *types.Transaction {
return args.toTransaction() return args.toTransaction()
} }
// IsEIP4844 returns an indicator if the args contains EIP4844 fields.
func (args *TransactionArgs) IsEIP4844() bool {
return args.BlobVersionedHashes != nil || args.MaxFeePerBlobGas != nil
}