line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
107502
|
use v5.26; |
|
2
|
|
|
|
|
17
|
|
2
|
2
|
|
|
2
|
|
630
|
use Object::Pad ':experimental(init_expr)'; |
|
2
|
|
|
|
|
11630
|
|
|
2
|
|
|
|
|
15
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Blockchain::Ethereum::ABI::Decoder 0.012; |
5
|
|
|
|
|
|
|
class Blockchain::Ethereum::ABI::Decoder; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=encoding utf8 |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Blockchain::Ethereum::ABI::Decoder - Contract ABI response decoder |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Allows you to decode contract ABI response |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $decoder = Blockchain::Ethereum::ABI::Decoder->new(); |
18
|
|
|
|
|
|
|
$decoder |
19
|
|
|
|
|
|
|
->append('uint256') |
20
|
|
|
|
|
|
|
->append('bytes[]') |
21
|
|
|
|
|
|
|
->decode('0x...'); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
24
|
|
|
|
|
|
|
|
25
|
2
|
|
|
2
|
|
824
|
use Carp; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
116
|
|
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
2
|
|
459
|
use Blockchain::Ethereum::ABI::Type; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
78
|
|
28
|
2
|
|
|
2
|
|
440
|
use Blockchain::Ethereum::ABI::Type::Tuple; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1502
|
|
29
|
|
|
|
|
|
|
|
30
|
15
|
|
|
15
|
|
29
|
field $_instances :reader(_instances) :writer(set_instances) = []; |
31
|
|
|
|
|
|
|
|
32
|
15
|
|
|
7
|
0
|
76
|
=head2 append |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
15
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Appends type signature to the decoder. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Usage: |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
append(signature) -> L |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=over 4 |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=item * C<$param> type signature e.g. uint256 |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=back |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Returns C<$self> |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
8
|
|
|
8
|
1
|
25481
|
method append ($param) { |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
12
|
|
51
|
|
|
|
|
|
|
|
52
|
8
|
|
|
|
|
20
|
push $self->_instances->@*, Blockchain::Ethereum::ABI::Type->new(signature => $param); |
53
|
8
|
|
|
|
|
44
|
return $self; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 decode |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Decodes appended signatures |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Usage: |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
decode() -> [] |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=over 4 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=back |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Returns an array reference containing all decoded values |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
7
|
|
|
7
|
1
|
17
|
method decode ($hex_data) { |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
11
|
|
73
|
|
|
|
|
|
|
|
74
|
7
|
50
|
0
|
|
|
60
|
croak 'Invalid hexadecimal value ' . $hex_data // 'undef' |
75
|
|
|
|
|
|
|
unless $hex_data =~ /^(?:0x|0X)?([a-fA-F0-9]+)$/; |
76
|
|
|
|
|
|
|
|
77
|
7
|
|
|
|
|
31
|
my $hex = $1; |
78
|
7
|
|
|
|
|
52
|
my @data = unpack("(A64)*", $hex); |
79
|
|
|
|
|
|
|
|
80
|
7
|
|
|
|
|
63
|
my $tuple = Blockchain::Ethereum::ABI::Type::Tuple->new; |
81
|
7
|
|
|
|
|
18
|
$tuple->set_instances($self->_instances); |
82
|
7
|
|
|
|
|
26
|
$tuple->set_data(\@data); |
83
|
7
|
|
|
|
|
42
|
my $data = $tuple->decode; |
84
|
|
|
|
|
|
|
|
85
|
7
|
|
|
|
|
23
|
$self->_clean; |
86
|
7
|
|
|
|
|
96
|
return $data; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
7
|
|
|
7
|
|
15
|
method _clean { |
90
|
|
|
|
|
|
|
|
91
|
7
|
|
|
|
|
17
|
$self->set_instances([]); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
__END__ |