File Coverage

blib/lib/Blockchain/Ethereum/Transaction/EIP4844.pm
Criterion Covered Total %
statement 30 30 100.0
branch 3 4 75.0
condition 7 10 70.0
subroutine 12 12 100.0
pod 1 7 14.2
total 53 63 84.1


line stmt bran cond sub pod time code
1             package Blockchain::Ethereum::Transaction::EIP4844;
2              
3 2     2   250953 use v5.26;
  2         7  
4 2     2   12 use strict;
  2         4  
  2         69  
5 2     2   10 use warnings;
  2         5  
  2         209  
6              
7             # ABSTRACT: Ethereum Blob transaction abstraction (EIP-4844)
8             our $AUTHORITY = 'cpan:REFECO'; # AUTHORITY
9             our $VERSION = '0.021'; # VERSION
10              
11 2     2   396 use parent 'Blockchain::Ethereum::Transaction';
  2         255  
  2         14  
12              
13 2     2   166 use constant TRANSACTION_PREFIX => pack("H*", '03');
  2         5  
  2         871  
14              
15             sub new {
16 2     2 0 195537 my ($class, %args) = @_;
17 2         17 my $self = $class->SUPER::new(%args);
18              
19 2         8 foreach (qw( max_priority_fee_per_gas max_fee_per_gas max_fee_per_blob_gas blob_versioned_hashes access_list )) {
20 10 100       23 $self->{$_} = $args{$_} if exists $args{$_};
21             }
22              
23 2         5 bless $self, $class;
24 2         6 return $self;
25             }
26              
27             sub max_fee_per_blob_gas {
28 6     6 0 10 return shift->{max_fee_per_blob_gas};
29             }
30              
31             sub max_priority_fee_per_gas {
32 6     6 0 12 return shift->{max_priority_fee_per_gas};
33             }
34              
35             sub max_fee_per_gas {
36 6     6 0 15 return shift->{max_fee_per_gas};
37             }
38              
39             sub blob_versioned_hashes {
40 6   50 6 0 16 return shift->{blob_versioned_hashes} // [];
41             }
42              
43             sub access_list {
44 6   100 6 0 18 return shift->{access_list} // [];
45             }
46              
47             sub serialize {
48 6     6 1 10 my $self = shift;
49              
50 6         18 my @params = (
51             $self->chain_id, $self->nonce, $self->max_priority_fee_per_gas, $self->max_fee_per_gas,
52             $self->gas_limit, $self->to, $self->value, $self->data,
53             $self->_encode_access_list, $self->max_fee_per_blob_gas, $self->blob_versioned_hashes,
54             );
55              
56 6         31 @params = $self->_normalize_params(\@params)->@*;
57              
58 6 50 66     18 push(@params, $self->v, $self->r, $self->s)
      66        
59             if $self->v && $self->r && $self->s;
60              
61 6         15 return TRANSACTION_PREFIX . $self->rlp->encode(\@params);
62             }
63              
64             1;
65              
66             __END__