Contract/Helper/UnitConversion.pm

filter: Statementstmt 45.8% 11 / 24 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 20.0% 3 / 15 Podpod 0.0% 0 / 12 totaltotal 27.4% 14 / 51 CC 1 SCAR 5.9
CC
1
Cov
46%
to_wei
2.0
to_kwei
2.0
to_mwei
2.0
CRAP 1.8
« Client.pm ↑ Summary Contract/Helper/ImportHelper.pm »
1 package Ethereum::RPC::Contract::Helper::UnitConversion;
2  
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use Math::BigInt;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 7 our $VERSION = '0.03';
8  
9 =head1 NAME
10  
11 Ethereum::RPC::Contract::Helper::UnitConversion - Ethereum Unit Converter
12  
13 wei: '1'
14 kwei: '1E3'
15 mwei: '1E6'
16 gwei: '1E9'
17 szabo: '1E12'
18 finney: '1E15'
19 ether: '1E18'
20 kether: '1E21'
21 mether: '1E24'
22 gether: '1E27'
23 tether: '1E30'
24  
25 =cut
26  
27 sub to_wei {
28 0 ▶ return to_hex(shift, 1);
Subroutine to_wei: not called CC=1 SCAR=6.9
Pod undocumented
29 }
30  
31 sub to_kwei {
32 0 ▶ return to_hex(shift, 1E3);
Subroutine to_kwei: not called CC=1 SCAR=6.9
Pod undocumented
33 }
34  
35 sub to_mwei {
36 0 ▶ return to_hex(shift, 1E6);
Subroutine to_mwei: not called CC=1 SCAR=6.9
Pod undocumented
37 }
38  
39 sub to_gwei {
40 0 ▶ return to_hex(shift, 1E9);
Subroutine to_gwei: not called CC=1 SCAR=6.9
Pod undocumented
41 }
42  
43 sub to_szabo {
44 0 ▶ return to_hex(shift, 1E12);
Subroutine to_szabo: not called CC=1 SCAR=6.9
Pod undocumented
45 }
46  
47 sub to_finney {
48 0 ▶ return to_hex(shift, 1E15);
Subroutine to_finney: not called CC=1 SCAR=6.9
Pod undocumented
49 }
50  
51 sub to_ether {
52 0 ▶ return to_hex(shift, 1E18);
Subroutine to_ether: not called CC=1 SCAR=6.9
Pod undocumented
53 }
54  
55 sub to_kether {
56 0 ▶ return to_hex(shift, 1E21);
Subroutine to_kether: not called CC=1 SCAR=6.9
Pod undocumented
57 }
58  
59 sub to_mether {
60 0 ▶ return to_hex(shift, 1E24);
Subroutine to_mether: not called CC=1 SCAR=6.9
Pod undocumented
61 }
62  
63 sub to_gether {
64 0 ▶ return to_hex(shift, 1E27);
Subroutine to_gether: not called CC=1 SCAR=6.9
Pod undocumented
65 }
66  
67 sub to_tether {
68 0 ▶ return to_hex(shift, 1E30);
Subroutine to_tether: not called CC=1 SCAR=6.9
Pod undocumented
69 }
70  
71 sub to_hex {
72 0 ▶ my ($number, $precision) = @_;
Subroutine to_hex: not called CC=1 SCAR=6.9
Pod undocumented
73 0 return "0x" . Math::BigFloat->new($number)->bmul($precision)->to_hex;
74 }
75  
76 7 1;
« Client.pm ↑ Summary Contract/Helper/ImportHelper.pm »