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