| 1 | package Finance::Dogechain::Transaction; | ||
| 2 | $Finance::Dogechain::Transaction::VERSION = '1.20210418.2306'; | ||
| 3 | use Mojo::Base -base, -signatures, 'Finance::Dogechain::Base'; | ||
| 4 | use Finance::Dogechain::Address; | ||
| 5 | |||
| 6 | has 'tx_id'; | ||
| 7 | |||
| 8 | sub transaction($self) { | ||
| 9 | my $tx = $self->return_field_if_success( '/transaction/' . $self->tx_id, 'transaction' ); | ||
| 10 | |||
| 11 | if ($tx) { | ||
| 12 | $self->convert_addresses_in_place( $tx->{inputs}, $tx->{outputs} ); | ||
| 13 | } | ||
| 14 | |||
| 15 | return $tx; | ||
| 16 | } | ||
| 17 | |||
| 18 | sub convert_addresses_in_place($self, @items) { | ||
| 19 | while (my $items = shift @items) { | ||
| 20 | for my $item (@$items) { | ||
| 21 | $item->{address} = Finance::Dogechain::Address->new( address => $item->{address} ); | ||
| 22 | } | ||
| 23 | } | ||
| 24 | } | ||
| 25 | |||
| 26 | sub TO_JSON($self) { | ||
| 27 | return '[Finance::Dogechain::Transaction](tx_id => ' . $self->tx_id . ')'; | ||
| 28 | } | ||
| 29 | |||
| 30 | 'to the moon'; | ||
| 31 | __END__ |