| line | stmt | bran | cond | sub | pod | time | code | 
| 1 | 4 |  |  | 4 |  | 107791 | use v5.26; | 
|  | 4 |  |  |  |  | 14 |  | 
| 2 | 4 |  |  | 4 |  | 774 | use Object::Pad ':experimental(init_expr)'; | 
|  | 4 |  |  |  |  | 12263 |  | 
|  | 4 |  |  |  |  | 33 |  | 
| 3 |  |  |  |  |  |  |  | 
| 4 |  |  |  |  |  |  | package Blockchain::Ethereum::Transaction 0.008; | 
| 5 |  |  |  |  |  |  | role Blockchain::Ethereum::Transaction; | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | =encoding utf8 | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | =head1 NAME | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | Blockchain::Ethereum::Transaction - Ethereum transaction abstraction | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | In most cases you don't want to use this directly, use instead: | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | =over 4 | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | =item * B<Legacy>: L<Blockchain::Ethereum::Transaction::Legacy> | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | =item * B<EIP1559>: L<Blockchain::Ethereum::Transaction::EIP1559> | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | =back | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | =cut | 
| 26 |  |  |  |  |  |  |  | 
| 27 | 4 |  |  | 4 |  | 1886 | use Carp; | 
|  | 4 |  |  |  |  | 24 |  | 
|  | 4 |  |  |  |  | 318 |  | 
| 28 | 4 |  |  | 4 |  | 2202 | use Crypt::Digest::Keccak256 qw(keccak256); | 
|  | 4 |  |  |  |  | 28325 |  | 
|  | 4 |  |  |  |  | 269 |  | 
| 29 |  |  |  |  |  |  |  | 
| 30 | 4 |  |  | 4 |  | 1964 | use Blockchain::Ethereum::RLP; | 
|  | 4 |  |  |  |  | 11999 |  | 
|  | 4 |  |  |  |  | 6229 |  | 
| 31 |  |  |  |  |  |  |  | 
| 32 | 8 |  |  | 8 | 0 | 19 | field $chain_id :reader :writer :param; | 
|  | 8 |  |  | 8 | 0 | 60 |  | 
|  | 0 |  |  | 0 | 0 | 0 |  | 
|  | 0 |  |  | 0 | 0 | 0 |  | 
|  |  |  |  | 0 | 0 |  |  | 
|  |  |  |  | 0 | 0 |  |  | 
| 33 | 8 |  |  | 8 | 0 | 18 | field $nonce :reader :writer :param; | 
|  | 8 |  |  | 8 | 0 | 45 |  | 
|  | 0 |  |  | 0 | 0 | 0 |  | 
|  | 0 |  |  | 0 | 0 | 0 |  | 
|  |  |  |  | 0 | 0 |  |  | 
|  |  |  |  | 0 | 0 |  |  | 
| 34 | 8 |  |  | 8 | 0 | 17 | field $gas_limit :reader :writer :param; | 
|  | 8 |  |  | 8 | 0 | 40 |  | 
|  | 0 |  |  | 0 | 0 | 0 |  | 
|  | 0 |  |  | 0 | 0 | 0 |  | 
|  |  |  |  | 0 | 0 |  |  | 
|  |  |  |  | 0 | 0 |  |  | 
| 35 | 8 |  |  | 8 | 0 | 18 | field $to :reader :writer :param    //= ''; | 
|  |  |  |  | 8 | 0 |  |  | 
|  |  |  |  | 0 | 0 |  |  | 
| 36 | 8 |  |  | 0 | 0 | 38 | field $value :reader :writer :param //= '0x0'; | 
|  | 0 |  |  | 0 | 0 | 0 |  | 
|  | 0 |  |  | 0 | 0 | 0 |  | 
|  | 8 |  |  | 8 | 0 | 22 |  | 
|  |  |  |  | 8 | 0 |  |  | 
|  |  |  |  | 0 | 0 |  |  | 
| 37 | 8 |  |  | 8 | 0 | 38 | field $data :reader :writer :param  //= ''; | 
|  | 8 |  |  | 8 | 0 | 17 |  | 
|  | 0 |  |  | 0 | 0 | 0 |  | 
|  | 0 |  |  | 0 | 0 | 0 |  | 
|  |  |  |  | 0 | 0 |  |  | 
|  |  |  |  | 0 | 0 |  |  | 
| 38 | 8 |  |  | 0 | 0 | 42 | field $v :reader :writer :param = undef; | 
|  | 0 |  |  | 0 | 0 | 0 |  | 
|  | 0 |  |  | 0 | 0 | 0 |  | 
| 39 | 3 |  |  | 3 | 0 | 9 | field $r :reader :writer :param = undef; | 
|  | 3 |  |  | 3 | 0 | 15 |  | 
|  | 11 |  |  | 0 | 0 | 29 |  | 
|  | 11 |  |  | 11 | 0 | 72 |  | 
|  |  |  |  | 11 | 0 |  |  | 
|  |  |  |  | 0 | 0 |  |  | 
| 40 | 6 |  |  | 6 | 0 | 15 | field $s :reader :writer :param = undef; | 
|  | 6 |  |  | 6 | 0 | 44 |  | 
|  | 3 |  |  | 0 | 0 | 4450723 |  | 
|  | 3 |  |  | 3 | 0 | 20 |  | 
|  |  |  |  | 3 | 0 |  |  | 
|  |  |  |  | 0 | 0 |  |  | 
| 41 |  |  |  |  |  |  |  | 
| 42 | 8 |  |  | 8 | 0 | 20 | field $rlp :reader = Blockchain::Ethereum::RLP->new(); | 
|  | 6 |  |  | 8 | 0 | 17 |  | 
|  | 6 |  |  | 0 | 0 | 37 |  | 
|  | 3 |  |  | 6 | 0 | 123 |  | 
|  | 3 |  |  | 6 | 0 | 16 |  | 
|  |  |  |  | 0 | 0 |  |  | 
|  |  |  |  | 3 | 0 |  |  | 
|  |  |  |  | 3 | 0 |  |  | 
|  |  |  |  | 0 | 0 |  |  | 
| 43 |  |  |  |  |  |  |  | 
| 44 | 8 |  |  |  |  | 53 | =head2 serialize | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | To be implemented by the child classes, encodes the given transaction parameters to RLP | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | Usage: | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | serialize() -> RLP encoded transaction bytes | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | =over 4 | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | =back | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | Returns the RLP encoded transaction bytes | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | =cut | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | method serialize; | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | =head2 generate_v | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | Generate the transaction v field using the given y-parity | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | Usage: | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | generate_v($y_parity) -> hexadecimal v | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | =over 4 | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | =item * C<$y_parity> y-parity | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | =back | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | Returns the v hexadecimal value also sets the v fields from transaction | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | =cut | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | method generate_v; | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | =head2 hash | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | SHA3 Hash the serialized transaction object | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | Usage: | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | hash() -> SHA3 transaction hash | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | =over 4 | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | =back | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | Returns the SHA3 transaction hash bytes | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | =cut | 
| 97 |  |  |  |  |  |  |  | 
| 98 | 3 |  |  | 3 | 1 | 136843 | method hash { | 
|  |  |  |  | 3 | 1 |  |  | 
|  |  |  |  | 0 | 0 |  |  | 
| 99 |  |  |  |  |  |  |  | 
| 100 | 3 |  |  |  |  | 19 | return keccak256($self->serialize); | 
| 101 |  |  |  |  |  |  | } | 
| 102 |  |  |  |  |  |  |  | 
| 103 |  |  |  |  |  |  | # In case of Math::BigInt given for any params, get the hex value | 
| 104 | 8 |  |  | 8 |  | 24 | method _equalize_params ($params) { | 
|  | 8 |  |  | 8 |  | 16 |  | 
|  | 8 |  |  | 0 |  | 18 |  | 
|  | 8 |  |  |  |  | 17 |  | 
| 105 |  |  |  |  |  |  |  | 
| 106 | 8 | 100 |  |  |  | 26 | return [map { ref $_ eq 'Math::BigInt' ? $_->as_hex : $_ } $params->@*]; | 
|  | 66 |  |  |  |  | 1572 |  | 
| 107 |  |  |  |  |  |  | } | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | 1; | 
| 110 |  |  |  |  |  |  |  | 
| 111 |  |  |  |  |  |  | __END__ | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | =head1 AUTHOR | 
| 114 |  |  |  |  |  |  |  | 
| 115 |  |  |  |  |  |  | Reginaldo Costa, C<< <refeco at cpan.org> >> | 
| 116 |  |  |  |  |  |  |  | 
| 117 |  |  |  |  |  |  | =head1 BUGS | 
| 118 |  |  |  |  |  |  |  | 
| 119 |  |  |  |  |  |  | Please report any bugs or feature requests to L<https://github.com/refeco/perl-ethereum-transaction> | 
| 120 |  |  |  |  |  |  |  | 
| 121 |  |  |  |  |  |  | =head1 LICENSE AND COPYRIGHT | 
| 122 |  |  |  |  |  |  |  | 
| 123 |  |  |  |  |  |  | This software is Copyright (c) 2023 by REFECO. | 
| 124 |  |  |  |  |  |  |  | 
| 125 |  |  |  |  |  |  | This is free software, licensed under: | 
| 126 |  |  |  |  |  |  |  | 
| 127 |  |  |  |  |  |  | The MIT License | 
| 128 |  |  |  |  |  |  |  | 
| 129 |  |  |  |  |  |  | =cut |