| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Blockchain::Ethereum::ABI::Decoder; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
68222
|
use v5.26; |
|
|
1
|
|
|
|
|
14
|
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
23
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
35
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
73
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
493
|
use Blockchain::Ethereum::ABI::Type; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
31
|
|
|
10
|
1
|
|
|
1
|
|
430
|
use Blockchain::Ethereum::ABI::Type::Tuple; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
308
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
|
13
|
1
|
|
|
1
|
0
|
92
|
return bless {}, shift; |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _instances { |
|
17
|
15
|
|
|
15
|
|
22
|
my $self = shift; |
|
18
|
15
|
|
100
|
|
|
83
|
return $self->{instances} //= []; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub append { |
|
22
|
8
|
|
|
8
|
1
|
17677
|
my ($self, $param) = @_; |
|
23
|
|
|
|
|
|
|
|
|
24
|
8
|
|
|
|
|
22
|
state $type = Blockchain::Ethereum::ABI::Type->new; |
|
25
|
|
|
|
|
|
|
|
|
26
|
8
|
|
|
|
|
24
|
push $self->_instances->@*, $type->new_type(signature => $param); |
|
27
|
8
|
|
|
|
|
49
|
return $self; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub decode { |
|
31
|
7
|
|
|
7
|
1
|
19
|
my ($self, $hex_data) = @_; |
|
32
|
|
|
|
|
|
|
|
|
33
|
7
|
50
|
0
|
|
|
66
|
croak 'Invalid hexadecimal value ' . $hex_data // 'undef' |
|
34
|
|
|
|
|
|
|
unless $hex_data =~ /^(?:0x|0X)?([a-fA-F0-9]+)$/; |
|
35
|
|
|
|
|
|
|
|
|
36
|
7
|
|
|
|
|
41
|
my $hex = $1; |
|
37
|
7
|
|
|
|
|
55
|
my @data = unpack("(A64)*", $hex); |
|
38
|
|
|
|
|
|
|
|
|
39
|
7
|
|
|
|
|
40
|
my $tuple = Blockchain::Ethereum::ABI::Type::Tuple->new; |
|
40
|
7
|
|
|
|
|
20
|
$tuple->{instances} = $self->_instances; |
|
41
|
7
|
|
|
|
|
13
|
$tuple->{data} = \@data; |
|
42
|
7
|
|
|
|
|
21
|
my $data = $tuple->decode; |
|
43
|
|
|
|
|
|
|
|
|
44
|
7
|
|
|
|
|
25
|
$self->_clean; |
|
45
|
7
|
|
|
|
|
87
|
return $data; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _clean { |
|
49
|
7
|
|
|
7
|
|
9
|
my $self = shift; |
|
50
|
7
|
|
|
|
|
15
|
delete $self->{instances}; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=pod |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=encoding UTF-8 |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Blockchain::Ethereum::ABI::Decoder - Contract ABI response decoder |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Allows you to decode contract ABI response |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my $decoder = Blockchain::Ethereum::ABI::Decoder->new(); |
|
66
|
|
|
|
|
|
|
$decoder |
|
67
|
|
|
|
|
|
|
->append('uint256') |
|
68
|
|
|
|
|
|
|
->append('bytes[]') |
|
69
|
|
|
|
|
|
|
->decode('0x...'); |
|
70
|
|
|
|
|
|
|
... |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 METHODS |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 append |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Appends type signature to the decoder. |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Usage: |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
append(signature) -> L |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=over 4 |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item * C<$param> type signature e.g. uint256 |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=back |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Returns C<$self> |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 decode |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Decodes appended signatures |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Usage: |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
decode() -> [] |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=over 4 |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=back |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Returns an array reference containing all decoded values |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 AUTHOR |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Reginaldo Costa, C<< >> |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 BUGS |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Please report any bugs or feature requests to L |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 SUPPORT |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
perldoc Blockchain::Ethereum::ABI::Encoder |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This software is Copyright (c) 2022 by REFECO. |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This is free software, licensed under: |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
The MIT License |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
1; |