Refactor `get_block_timestamp` and `date_to_block_number` implementation
Closed this issue · 1 comments
pandadefi commented
Using get_block_timestamp()
I am getting some errors:
** (BadMapError) expected a map, got: nil
:erlang.map_get("timestamp", nil)
(ethers 0.4.5) lib/ethers/utils.ex:359: Ethers.Utils.get_block_timestamp/2
(ethers 0.4.5) lib/ethers/utils.ex:415: Ethers.Utils.date_to_block_number/3
(home_screen 0.1.0) lib/crypto/chain/polygon.ex:2: HomeScreen.Crypto.Chain.Polygon.date_to_block_number/3
(elixir 1.16.3) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2
(elixir 1.16.3) lib/task/supervised.ex:36: Task.Supervised.reply/4
Getting more information from get_block_timestamp
would be great. I am using date_to_block_number()
and thinking I might be making too many requests to the RPC and I am getting restricted.
alisinabh commented
Sorry for the late reply. I have missed this issue in my inbox.
The date_to_block_number
function is not implemented in a good way. It actually is a candidate for refactoring since it was implemented in the early days of Ethers.