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