line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Blockchain::Ethereum::ABI::Type::String; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
1842
|
use v5.26; |
|
3
|
|
|
|
|
13
|
|
4
|
3
|
|
|
3
|
|
48
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
70
|
|
5
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
113
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
18
|
use parent qw(Blockchain::Ethereum::ABI::Type); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
28
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub encode { |
10
|
11
|
|
|
11
|
1
|
19
|
my $self = shift; |
11
|
11
|
100
|
|
|
|
30
|
return $self->_encoded if $self->_encoded; |
12
|
|
|
|
|
|
|
|
13
|
4
|
|
|
|
|
15
|
my $hex = unpack("H*", $self->_data); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# for dynamic length basic types the length must be included |
16
|
4
|
|
|
|
|
29
|
$self->_push_dynamic($self->_encode_length(length(pack("H*", $hex)))); |
17
|
4
|
|
|
|
|
18
|
$self->_push_dynamic($self->pad_right($hex)); |
18
|
|
|
|
|
|
|
|
19
|
4
|
|
|
|
|
14
|
return $self->_encoded; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub decode { |
23
|
1
|
|
|
1
|
1
|
1
|
my $self = shift; |
24
|
1
|
|
|
|
|
5
|
my @data = $self->_data->@*; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
2
|
my $size = hex shift @data; |
27
|
1
|
|
|
|
|
4
|
my $string_data = join('', @data); |
28
|
1
|
|
|
|
|
10
|
my $packed_string = pack("H*", $string_data); |
29
|
1
|
|
|
|
|
15
|
return substr($packed_string, 0, $size); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
__END__ |