line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Blockchain::Ethereum::ABI::Type::Int; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
2708
|
use v5.26; |
|
5
|
|
|
|
|
19
|
|
4
|
5
|
|
|
5
|
|
27
|
use strict; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
111
|
|
5
|
5
|
|
|
5
|
|
24
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
119
|
|
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
24
|
use Carp; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
302
|
|
8
|
5
|
|
|
5
|
|
7247
|
use Math::BigInt; |
|
5
|
|
|
|
|
177247
|
|
|
5
|
|
|
|
|
26
|
|
9
|
5
|
|
|
5
|
|
144944
|
use parent qw(Blockchain::Ethereum::ABI::Type); |
|
5
|
|
|
|
|
16
|
|
|
5
|
|
|
|
|
49
|
|
10
|
|
|
|
|
|
|
|
11
|
5
|
|
|
5
|
|
420
|
use constant DEFAULT_INT_SIZE => 256; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
2149
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub encode { |
14
|
87
|
|
|
87
|
1
|
132
|
my $self = shift; |
15
|
87
|
100
|
|
|
|
211
|
return $self->_encoded if $self->_encoded; |
16
|
|
|
|
|
|
|
|
17
|
39
|
|
|
|
|
108
|
my $bdata = Math::BigInt->new($self->_data); |
18
|
|
|
|
|
|
|
|
19
|
39
|
100
|
|
|
|
3641
|
croak "Invalid numeric data @{[$self->_data]}" if $bdata->is_nan; |
|
1
|
|
|
|
|
49
|
|
20
|
|
|
|
|
|
|
|
21
|
38
|
100
|
66
|
|
|
326
|
croak "Invalid data length, signature: @{[$self->fixed_length]}, data length: @{[$bdata->length]}" |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
4
|
|
22
|
|
|
|
|
|
|
if $self->fixed_length && $bdata->length > $self->fixed_length; |
23
|
|
|
|
|
|
|
|
24
|
37
|
100
|
66
|
|
|
156
|
croak "Invalid negative numeric data @{[$self->_data]}" |
|
2
|
|
|
|
|
6
|
|
25
|
|
|
|
|
|
|
if $bdata->is_neg && $self->_signature =~ /^uint|bool/; |
26
|
|
|
|
|
|
|
|
27
|
35
|
100
|
100
|
|
|
286
|
croak "Invalid bool data it must be 1 or 0 but given @{[$self->_data]}" |
|
1
|
|
100
|
|
|
6
|
|
28
|
|
|
|
|
|
|
if !$bdata->is_zero && !$bdata->is_one && $self->_signature =~ /^bool/; |
29
|
|
|
|
|
|
|
|
30
|
34
|
|
|
|
|
361
|
$self->_push_static($self->pad_left($bdata->to_hex)); |
31
|
|
|
|
|
|
|
|
32
|
34
|
|
|
|
|
107
|
return $self->_encoded; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub decode { |
36
|
14
|
|
|
14
|
1
|
30
|
my $self = shift; |
37
|
14
|
|
|
|
|
40
|
return Math::BigInt->from_hex($self->_data->[0]); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub fixed_length { |
41
|
77
|
|
|
77
|
1
|
804
|
my $self = shift; |
42
|
77
|
100
|
|
|
|
182
|
if ($self->_signature =~ /[a-z](\d+)/) { |
43
|
59
|
|
|
|
|
301
|
return $1; |
44
|
|
|
|
|
|
|
} |
45
|
18
|
|
|
|
|
84
|
return DEFAULT_INT_SIZE; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=pod |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=encoding UTF-8 |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 NAME |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Blockchain::Ethereum::ABI::Int - Interface for solidity uint/int/bool type |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 SYNOPSIS |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Allows you to define and instantiate a solidity address type: |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my $type = Blockchain::Ethereum::ABI::Int->new( |
63
|
|
|
|
|
|
|
signature => $signature, |
64
|
|
|
|
|
|
|
data => $value |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
$type->encode(); |
68
|
|
|
|
|
|
|
... |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
In most cases you don't want to use this directly, use instead: |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=over 4 |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item * B: L |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item * B: L |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=back |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 METHODS |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 encode |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Encodes the given data to the type of the signature |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Usage: |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
encode() -> encoded string |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=over 4 |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=back |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 decode |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Decodes the given data to the type of the signature |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Usage: |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
decoded() -> L |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=over 4 |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=back |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
L |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 AUTHOR |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Reginaldo Costa, C<< >> |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 BUGS |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Please report any bugs or feature requests to L |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 SUPPORT |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
perldoc Blockchain::Ethereum::ABI::Int |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This software is Copyright (c) 2022 by REFECO. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This is free software, licensed under: |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
The MIT License |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |