line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Blockchain::Ethereum::ABI::Type::String; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
1893
|
use v5.26; |
|
3
|
|
|
|
|
19
|
|
4
|
3
|
|
|
3
|
|
17
|
use strict; |
|
3
|
|
|
|
|
16
|
|
|
3
|
|
|
|
|
67
|
|
5
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
115
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
18
|
use parent qw(Blockchain::Ethereum::ABI::Type); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
20
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub encode { |
10
|
11
|
|
|
11
|
1
|
18
|
my $self = shift; |
11
|
11
|
100
|
|
|
|
27
|
return $self->_encoded if $self->_encoded; |
12
|
|
|
|
|
|
|
|
13
|
4
|
|
|
|
|
18
|
my $hex = unpack("H*", $self->_data); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# for dynamic length basic types the length must be included |
16
|
4
|
|
|
|
|
31
|
$self->_push_dynamic($self->_encode_length(length(pack("H*", $hex)))); |
17
|
4
|
|
|
|
|
62
|
$self->_push_dynamic($self->pad_right($hex)); |
18
|
|
|
|
|
|
|
|
19
|
4
|
|
|
|
|
12
|
return $self->_encoded; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub decode { |
23
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
24
|
1
|
|
|
|
|
5
|
my @data = $self->_data->@*; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
4
|
my $size = hex shift @data; |
27
|
1
|
|
|
|
|
4
|
my $string_data = join('', @data); |
28
|
1
|
|
|
|
|
7
|
my $packed_string = pack("H*", $string_data); |
29
|
1
|
|
|
|
|
6
|
return substr($packed_string, 0, $size); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=pod |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=encoding UTF-8 |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 NAME |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Blockchain::Ethereum::ABI::String - Interface for solidity string type |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 SYNOPSIS |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Allows you to define and instantiate a solidity string type: |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $type = Blockchain::Ethereum::ABI::String->new( |
47
|
|
|
|
|
|
|
signature => $signature, |
48
|
|
|
|
|
|
|
data => $value |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$type->encode(); |
52
|
|
|
|
|
|
|
... |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
In most cases you don't want to use this directly, use instead: |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=over 4 |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item * B: L |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=item * B: L |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=back |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 METHODS |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 encode |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Encodes the given data to the type of the signature |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Usage: |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
encode() -> encoded string |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=over 4 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=back |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 decode |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Decodes the given data to the type of the signature |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Usage: |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
decoded() -> string |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=over 4 |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=back |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
String |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 AUTHOR |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Reginaldo Costa, C<< >> |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 BUGS |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Please report any bugs or feature requests to L |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 SUPPORT |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
perldoc Blockchain::Ethereum::ABI::String |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This software is Copyright (c) 2022 by REFECO. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This is free software, licensed under: |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
The MIT License |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |