| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Ethereum::RPC::Contract::ContractResponse; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
31
|
use strict; |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
139
|
|
|
4
|
4
|
|
|
4
|
|
34
|
use warnings; |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
196
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Ethereum::Contract::RPC::ContractResponse - Centralize contract response |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=cut |
|
13
|
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
|
49
|
use Moo; |
|
|
4
|
|
|
|
|
14
|
|
|
|
4
|
|
|
|
|
27
|
|
|
15
|
4
|
|
|
4
|
|
1486
|
use Encode; |
|
|
4
|
|
|
|
|
12
|
|
|
|
4
|
|
|
|
|
377
|
|
|
16
|
4
|
|
|
4
|
|
27
|
use Math::BigInt; |
|
|
4
|
|
|
|
|
21
|
|
|
|
4
|
|
|
|
|
26
|
|
|
17
|
4
|
|
|
4
|
|
5324
|
use Math::BigFloat; |
|
|
4
|
|
|
|
|
141166
|
|
|
|
4
|
|
|
|
|
25
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has response => (is => 'ro'); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 to_big_int |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Convert response to a Math::BigInt if not undef |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Parameters: |
|
26
|
|
|
|
|
|
|
hexadecimal response |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Return: |
|
29
|
|
|
|
|
|
|
new Math::BigInt |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub to_big_int { |
|
34
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
35
|
0
|
0
|
|
|
|
|
return Math::BigInt->from_hex($self->response) if $self->response; |
|
36
|
0
|
|
|
|
|
|
return undef; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 to_big_float |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Convert response to a Math::BigFloat if not undef |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Parameters: |
|
44
|
|
|
|
|
|
|
hexadecimal response |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Return: |
|
47
|
|
|
|
|
|
|
new Math::BigFloat |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub to_big_float { |
|
52
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
53
|
0
|
0
|
|
|
|
|
return Math::BigFloat->from_hex($self->response) if $self->response; |
|
54
|
0
|
|
|
|
|
|
return undef; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 to_string |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Convert response to a string if not undef |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Parameters: |
|
62
|
|
|
|
|
|
|
hexadecimal response |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Return: |
|
65
|
|
|
|
|
|
|
string |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub to_string { |
|
70
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
0
|
|
|
|
|
return undef unless $self->response; |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
my $packed_response = pack('H*', substr($self->response, -64)); |
|
75
|
0
|
|
|
|
|
|
$packed_response =~ s/\0+$//; |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
return $packed_response; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 to_hex |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Convert response to a hexadecimal if not undef and is not already a hex |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Parameters: |
|
85
|
|
|
|
|
|
|
hexadecimal response |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Return: |
|
88
|
|
|
|
|
|
|
hexadecimal string |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub to_hex { |
|
93
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
94
|
|
|
|
|
|
|
|
|
95
|
0
|
0
|
|
|
|
|
return undef unless $self->response; |
|
96
|
|
|
|
|
|
|
|
|
97
|
0
|
0
|
|
|
|
|
if ($self->response =~ /^0x[0-9A-F]+$/i) { |
|
98
|
0
|
|
|
|
|
|
return $self->response; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
return undef; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |