File Coverage

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


line stmt bran cond sub pod time code
1 4     4   3671 use v5.26;
  4         18  
2 4     4   25 use Object::Pad;
  4         8  
  4         29  
3              
4             package Blockchain::Ethereum::ABI::Type::Address 0.012;
5             class Blockchain::Ethereum::ABI::Type::Address
6             :isa(Blockchain::Ethereum::ABI::Type)
7             :does(Blockchain::Ethereum::ABI::TypeRole);
8              
9             =encoding utf8
10              
11             =head1 NAME
12              
13             Blockchain::Ethereum::ABI::Address - Interface for solidity address type
14              
15             =head1 SYNOPSIS
16              
17             Allows you to define and instantiate a solidity address type:
18              
19             my $type = Blockchain::Ethereum::ABI::Address->new(
20             signature => $signature,
21             data => $value
22             );
23              
24             $type->encode();
25              
26             In most cases you don't want to use this directly, use instead:
27              
28             =over 4
29              
30             =item * B: L
31              
32             =item * B: L
33              
34             =back
35              
36             =cut
37              
38 22     22   56 method _configure { return }
  22         138  
39              
40             =head2 encode
41              
42             Encodes the given data to the type of the signature
43              
44             Usage:
45              
46             encode() -> encoded string
47              
48             =over 4
49              
50             =back
51              
52             ABI encoded hex string
53              
54             =cut
55              
56 16     16 1 28 method encode {
57              
58 16 100       39 return $self->_encoded if $self->_encoded;
59 8         39 $self->_push_static($self->pad_left(substr($self->data, 2)));
60              
61 8         28 return $self->_encoded;
62             }
63              
64             =head2 decode
65              
66             Decodes the given data to the type of the signature
67              
68             Usage:
69              
70             decoded() -> address
71              
72             =over 4
73              
74             =back
75              
76             String 0x prefixed address
77              
78             =cut
79              
80 8     8 1 17 method decode {
81              
82 8         20 return '0x' . substr $self->data->[0], -40;
83             }
84              
85             1;
86              
87             __END__