| 1 | package Net::Async::Blockchain::Transaction; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | our $VERSION = '0.001'; | |||||||||
| 7 | |||||||||||
| 8 | =head1 NAME | ||||||||||
| 9 | |||||||||||
| 10 | Net::Async::Blockchain::Transaction - Transaction abstraction. | ||||||||||
| 11 | |||||||||||
| 12 | =head1 SYNOPSIS | ||||||||||
| 13 | |||||||||||
| 14 | Objects of this type would not normally be constructed directly. | ||||||||||
| 15 | |||||||||||
| 16 | =head1 DESCRIPTION | ||||||||||
| 17 | |||||||||||
| 18 | Transaction abstraction | ||||||||||
| 19 | |||||||||||
| 20 | =over 4 | ||||||||||
| 21 | |||||||||||
| 22 | =back | ||||||||||
| 23 | |||||||||||
| 24 | =cut | ||||||||||
| 25 | |||||||||||
| 26 | 1 | ▶ | no indirect; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | |||||||||||
| 28 | 0 | ▶ | sub message_type : method { shift->{message_type} } | ||||||||
|
Subroutine
message_type: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 29 | 0 | ▶ | sub currency : method { shift->{currency} } | ||||||||
|
Subroutine
currency: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 30 | 0 | ▶ | sub hash : method { shift->{hash} } | ||||||||
|
Subroutine
hash: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 31 | 0 | ▶ | sub block : method { shift->{block} } | ||||||||
|
Subroutine
block: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 32 | 0 | ▶ | sub from : method { shift->{from} } | ||||||||
|
Subroutine
from: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 33 | 0 | ▶ | sub to : method { shift->{to} } | ||||||||
|
Subroutine
to: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 34 | 0 | ▶ | sub contract : method { shift->{contract} } | ||||||||
|
Subroutine
contract: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 35 | 0 | ▶ | sub amount : method { shift->{amount} } | ||||||||
|
Subroutine
amount: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 36 | 0 | ▶ | sub fee : method { shift->{fee} } | ||||||||
|
Subroutine
fee: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 37 | 0 | ▶ | sub fee_currency : method { shift->{fee_currency} } | ||||||||
|
Subroutine
fee_currency: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 38 | 0 | ▶ | sub type : method { shift->{type} } | ||||||||
|
Subroutine
type: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 39 | 0 | ▶ | sub data : method { shift->{data} } | ||||||||
|
Subroutine
data: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 40 | 0 | ▶ | sub property_id : method { shift->{property_id} } | ||||||||
|
Subroutine
property_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 41 | 0 | ▶ | sub timestamp : method { shift->{timestamp} } | ||||||||
|
Subroutine
timestamp: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 42 | |||||||||||
| 43 | =head2 new | ||||||||||
| 44 | |||||||||||
| 45 | Create a new L<Net::Async::Blockchain::Transaction> instance | ||||||||||
| 46 | |||||||||||
| 47 | =over 4 | ||||||||||
| 48 | |||||||||||
| 49 | =item * C<message_type> Message Type (Default: transaction) | ||||||||||
| 50 | =item * C<currency> Currency symbol | ||||||||||
| 51 | =item * C<hash> Transaction hash | ||||||||||
| 52 | =item * C<block> Block where the transaction is included | ||||||||||
| 53 | =item * C<from> Transaction sender | ||||||||||
| 54 | =item * C<to> Transaction receiver | ||||||||||
| 55 | =item * C<contract> Contract address (when it's a contract transaction) | ||||||||||
| 56 | =item * C<amount> The transaction value | ||||||||||
| 57 | =item * C<fee> The transaction value | ||||||||||
| 58 | =item * C<fee_currency> The currency of the fee paid for this transaction | ||||||||||
| 59 | =item * C<type> String transaction type it can be (receive, sent, internal) | ||||||||||
| 60 | =item * C<data> contract instructions | ||||||||||
| 61 | =item * C<property_id> omnicore property id | ||||||||||
| 62 | =item * C<timestamp> block timestamp | ||||||||||
| 63 | |||||||||||
| 64 | =back | ||||||||||
| 65 | |||||||||||
| 66 | L<Net::Async::Blockchain::Transaction> | ||||||||||
| 67 | |||||||||||
| 68 | =cut | ||||||||||
| 69 | |||||||||||
| 70 | sub new { | ||||||||||
| 71 | 0 | ▶ | my ($class, %params) = @_; | ||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 72 | 0 | my $self = bless {}, $class; | |||||||||
| 73 | |||||||||||
| 74 | 0 | $self->{message_type} = 'transaction'; | |||||||||
| 75 | |||||||||||
| 76 | 0 | foreach (qw(message_type currency hash block from to contract amount fee fee_currency type data property_id timestamp)) { | |||||||||
| 77 | 0 | ▶ | $self->{$_} = delete $params{$_} if exists $params{$_}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | 0 | ▶ | die "Invalid transaction parameters" if keys %params; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 81 | 0 | return $self; | |||||||||
| 82 | } | ||||||||||
| 83 | |||||||||||
| 84 | =head2 clone | ||||||||||
| 85 | |||||||||||
| 86 | Clone the self object and the attribute values | ||||||||||
| 87 | |||||||||||
| 88 | =over 4 | ||||||||||
| 89 | |||||||||||
| 90 | =back | ||||||||||
| 91 | |||||||||||
| 92 | new L<Net::Async::Blockchain::Transaction> based on self | ||||||||||
| 93 | |||||||||||
| 94 | =cut | ||||||||||
| 95 | |||||||||||
| 96 | sub clone { | ||||||||||
| 97 | 0 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
clone: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 98 | 0 | return Net::Async::Blockchain::Transaction->new(%$self); | |||||||||
| 99 | } | ||||||||||
| 100 | |||||||||||
| 101 | 1 | 1; | |||||||||