From 96b955de230ba969a72944cfdfe85b2d4d550648 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 8 Feb 2024 17:29:29 +0100 Subject: [PATCH] internal/ethapi: improve error message for blobtx as create --- internal/ethapi/transaction_args.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/internal/ethapi/transaction_args.go b/internal/ethapi/transaction_args.go index 1d4d51b5a6..a2508c192c 100644 --- a/internal/ethapi/transaction_args.go +++ b/internal/ethapi/transaction_args.go @@ -119,9 +119,6 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error { } // BlobTx fields - if args.BlobHashes != nil && args.To == nil { - return errors.New(`blob transactions cannot have the form of a create transaction`) - } if args.BlobHashes != nil && len(args.BlobHashes) == 0 { return errors.New(`need at least 1 blob for a blob transaction`) } @@ -130,8 +127,13 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error { } // create check - if args.To == nil && len(args.data()) == 0 { - return errors.New(`contract creation without any data provided`) + if args.To == nil { + if args.BlobHashes != nil { + return errors.New(`missing "to" in blob transaction`) + } + if len(args.data()) == 0 { + return errors.New(`contract creation without any data provided`) + } } // Estimate the gas usage if necessary. @@ -289,7 +291,7 @@ func (args *TransactionArgs) setBlobTxSidecar(ctx context.Context, b Backend) er // Passing blobs is not allowed in all contexts, only in specific methods. if !args.blobSidecarAllowed { - return errors.New("'blobs' is not supported for this RPC method") + return errors.New(`"blobs" is not supported for this RPC method`) } n := len(args.Blobs)