internal/ethapi: improve error message for blobtx as create

This commit is contained in:
Felix Lange 2024-02-08 17:29:29 +01:00
parent 961ed08586
commit 96b955de23

View file

@ -119,9 +119,6 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error {
} }
// BlobTx fields // 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 { if args.BlobHashes != nil && len(args.BlobHashes) == 0 {
return errors.New(`need at least 1 blob for a blob transaction`) 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 // create check
if args.To == nil && len(args.data()) == 0 { if args.To == nil {
return errors.New(`contract creation without any data provided`) 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. // 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. // Passing blobs is not allowed in all contexts, only in specific methods.
if !args.blobSidecarAllowed { 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) n := len(args.Blobs)