File Coverage

blib/lib/Blockchain/Ethereum/ABI/Type/Address.pm
Criterion Covered Total %
statement 20 20 100.0
branch 2 2 100.0
condition n/a
subroutine 7 7 100.0
pod 2 2 100.0
total 31 31 100.0


line stmt bran cond sub pod time code
1             package Blockchain::Ethereum::ABI::Type::Address;
2              
3 3     3   1761 use v5.26;
  3         13  
4 3     3   17 use strict;
  3         5  
  3         61  
5 3     3   15 use warnings;
  3         8  
  3         86  
6              
7 3     3   17 use Carp;
  3         7  
  3         229  
8 3     3   21 use parent qw(Blockchain::Ethereum::ABI::Type);
  3         7  
  3         35  
9              
10             sub encode {
11 16     16 1 31 my $self = shift;
12 16 100       38 return $self->_encoded if $self->_encoded;
13 8         33 $self->_push_static($self->pad_left(substr($self->_data, 2)));
14              
15 8         924 return $self->_encoded;
16             }
17              
18             sub decode {
19 8     8 1 16 my $self = shift;
20 8         19 return '0x' . substr $self->_data->[0], -40;
21             }
22              
23             =pod
24              
25             =encoding UTF-8
26              
27             =head1 NAME
28              
29             Blockchain::Ethereum::ABI::Address - Interface for solidity address type
30              
31             =head1 SYNOPSIS
32              
33             Allows you to define and instantiate a solidity address type:
34              
35             my $type = Blockchain::Ethereum::ABI::Address->new(
36             signature => $signature,
37             data => $value
38             );
39              
40             $type->encode();
41             ...
42              
43             In most cases you don't want to use this directly, use instead:
44              
45             =over 4
46              
47             =item * B: L
48              
49             =item * B: L
50              
51             =back
52              
53             =head1 METHODS
54              
55             =head2 encode
56              
57             Encodes the given data to the type of the signature
58              
59             Usage:
60              
61             encode() -> encoded string
62              
63             =over 4
64              
65             =back
66              
67             =head2 decode
68              
69             Decodes the given data to the type of the signature
70              
71             Usage:
72              
73             decoded() -> address
74              
75             =over 4
76              
77             =back
78              
79             String 0x prefixed address
80              
81             =head1 AUTHOR
82              
83             Reginaldo Costa, C<< >>
84              
85             =head1 BUGS
86              
87             Please report any bugs or feature requests to L
88              
89             =head1 SUPPORT
90              
91             You can find documentation for this module with the perldoc command.
92              
93             perldoc Blockchain::Ethereum::ABI::Address
94              
95             =head1 LICENSE AND COPYRIGHT
96              
97             This software is Copyright (c) 2022 by REFECO.
98              
99             This is free software, licensed under:
100              
101             The MIT License
102              
103             =cut
104              
105             1;