File Coverage

blib/lib/Ethereum/RPC/Contract/Helper/ImportHelper.pm
Criterion Covered Total %
statement 12 16 75.0
branch n/a
condition n/a
subroutine 4 5 80.0
pod 0 1 0.0
total 16 22 72.7


line stmt bran cond sub pod time code
1             package Ethereum::RPC::Contract::Helper::ImportHelper;
2              
3 2     2   1030 use strict;
  2         6  
  2         61  
4 2     2   12 use warnings;
  2         5  
  2         50  
5              
6 2     2   1840 use Path::Tiny;
  2         26082  
  2         162  
7              
8             our $VERSION = '0.04';
9              
10             =head1 NAME
11              
12             Ethereum::RPC::Contract::Helper::ImportHelper - ImportHelper
13              
14             =cut
15              
16 2     2   17 use JSON::MaybeXS;
  2         43  
  2         311  
17              
18             =head2 to_hex
19              
20             Auxiliar to get bytecode and the ABI from the compiled truffle json.
21              
22             Parameters:
23             file path
24              
25             Return:
26             {abi, bytecode}
27              
28             =cut
29              
30             sub from_truffle_build {
31 0     0 0   my $file = shift;
32              
33 0           my $document = path($file)->slurp_utf8;
34              
35 0           my $decoded_json = decode_json($document);
36              
37             return {
38             abi => encode_json($decoded_json->{abi}),
39 0           bytecode => $decoded_json->{bytecode}};
40             }
41              
42             1;