| 1 | package Net::Async::Blockchain::Client::RPC::ETH; | ||
| 2 | |||
| 3 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 2 | our $VERSION = '0.002'; | |
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | Net::Async::Blockchain::Client::RPC::ETH - Async ETH RPC Client. | ||
| 11 | |||
| 12 | =head1 SYNOPSIS | ||
| 13 | |||
| 14 | my $loop = IO::Async::Loop->new(); | ||
| 15 | |||
| 16 | $loop->add( | ||
| 17 | my $http_client = Net::Async::Blockchain::Client::RPC::ETH->new(endpoint => 'http://127.0.0.1:8545', timeout => 100) | ||
| 18 | ); | ||
| 19 | |||
| 20 | my $response = $http_client->accounts()->get; | ||
| 21 | |||
| 22 | =head1 DESCRIPTION | ||
| 23 | |||
| 24 | ETH RPC calls | ||
| 25 | |||
| 26 | =over 4 | ||
| 27 | |||
| 28 | =back | ||
| 29 | |||
| 30 | =cut | ||
| 31 | |||
| 32 | 2 | ▶ | no indirect; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 33 | |||
| 34 | 2 | ▶ | use parent qw(Net::Async::Blockchain::Client::RPC); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 35 | |||
| 36 | 26 | ▶ | sub jsonrpc { return '2.0' } |
|
Subroutine
jsonrpc: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 37 | |||
| 38 | =head2 call | ||
| 39 | |||
| 40 | https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_call | ||
| 41 | |||
| 42 | =over 4 | ||
| 43 | |||
| 44 | =back | ||
| 45 | |||
| 46 | L<Future> | ||
| 47 | |||
| 48 | =cut | ||
| 49 | |||
| 50 | sub call { | ||
| 51 | 0 | ▶ | my ($self, @params) = @_; |
|
Subroutine
call: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 52 | 0 | return $self->_request('eth_call', @params); | |
| 53 | } | ||
| 54 | |||
| 55 | =head2 get_transaction_receipt | ||
| 56 | |||
| 57 | https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionreceipt | ||
| 58 | |||
| 59 | =over 4 | ||
| 60 | |||
| 61 | =back | ||
| 62 | |||
| 63 | L<Future> | ||
| 64 | |||
| 65 | =cut | ||
| 66 | |||
| 67 | sub get_transaction_receipt { | ||
| 68 | 0 | ▶ | my ($self, @params) = @_; |
|
Subroutine
get_transaction_receipt: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 69 | 0 | return $self->_request('eth_getTransactionReceipt', @params); | |
| 70 | } | ||
| 71 | |||
| 72 | =head2 accounts | ||
| 73 | |||
| 74 | https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_accounts | ||
| 75 | |||
| 76 | =over 4 | ||
| 77 | |||
| 78 | =back | ||
| 79 | |||
| 80 | L<Future> | ||
| 81 | |||
| 82 | =cut | ||
| 83 | |||
| 84 | sub accounts { | ||
| 85 | 13 | ▶ | my ($self) = @_; |
|
Subroutine
accounts: called CC=1 SCAR=0.0
Pod
documented
| |||
| 86 | 13 | return $self->_request('eth_accounts'); | |
| 87 | } | ||
| 88 | |||
| 89 | =head2 get_block_by_hash | ||
| 90 | |||
| 91 | https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getblockbyhash | ||
| 92 | |||
| 93 | =over 4 | ||
| 94 | |||
| 95 | =back | ||
| 96 | |||
| 97 | L<Future> | ||
| 98 | |||
| 99 | =cut | ||
| 100 | |||
| 101 | sub get_block_by_hash { | ||
| 102 | 0 | ▶ | my ($self, @params) = @_; |
|
Subroutine
get_block_by_hash: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 103 | 0 | return $self->_request('eth_getBlockByHash', @params); | |
| 104 | } | ||
| 105 | |||
| 106 | =head2 get_block_by_number | ||
| 107 | |||
| 108 | https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getblockbynumber | ||
| 109 | |||
| 110 | =over 4 | ||
| 111 | |||
| 112 | =back | ||
| 113 | |||
| 114 | L<Future> | ||
| 115 | |||
| 116 | =cut | ||
| 117 | |||
| 118 | sub get_block_by_number { | ||
| 119 | 0 | ▶ | my ($self, @params) = @_; |
|
Subroutine
get_block_by_number: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 120 | 0 | return $self->_request('eth_getBlockByNumber', @params); | |
| 121 | } | ||
| 122 | |||
| 123 | =head2 get_last_block | ||
| 124 | |||
| 125 | https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_blocknumber | ||
| 126 | |||
| 127 | =over 4 | ||
| 128 | |||
| 129 | =back | ||
| 130 | |||
| 131 | L<Future> | ||
| 132 | |||
| 133 | =cut | ||
| 134 | |||
| 135 | sub get_last_block { | ||
| 136 | 0 | ▶ | my ($self) = @_; |
|
Subroutine
get_last_block: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 137 | 0 | return $self->_request('eth_blockNumber'); | |
| 138 | } | ||
| 139 | |||
| 140 | =head2 get_balance | ||
| 141 | |||
| 142 | https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getbalance | ||
| 143 | |||
| 144 | =over 4 | ||
| 145 | |||
| 146 | =back | ||
| 147 | |||
| 148 | L<Future> | ||
| 149 | |||
| 150 | =cut | ||
| 151 | |||
| 152 | sub get_balance { | ||
| 153 | 0 | ▶ | my ($self, $address) = @_; |
|
Subroutine
get_balance: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 154 | 0 | return $self->_request('eth_getBalance', $address, 'latest'); | |
| 155 | } | ||
| 156 | |||
| 157 | 2 | 1; | |
| 158 | |||