5afe / contract-proxy-kit

Enable batched transactions and contract account interactions using a unique deterministic Gnosis Safe.
103 stars 37 forks source link

Fix EthersAdapter.getBalance #150

Closed santteegt closed 3 years ago

santteegt commented 3 years ago

This PR fixes a NaN error when calling CPK.getBalance() using EthersJS (EthersAdapter) provider

Reason: the signer.provider.getBalance method already returns a BigNumber

github-actions[bot] commented 3 years ago

CLA Assistant Lite All Contributors have signed the CLA.

santteegt commented 3 years ago

I have read the CLA Document and I hereby sign the CLA

germartinez commented 3 years ago

Hello @santteegt, I had issues adding commits to this PR. I copied your commit and created this new one: https://github.com/gnosis/contract-proxy-kit/pull/152

I'm keeping the new BigNumber() even if a BigNumber is already returned, because the CPK is using the library https://github.com/MikeMcl/bignumber.js/, (supported on Web3Adapter and EthersAdapter) and the BigNumber returned from signer.provider.getBalance is not using that library, where some things are different (methods like .add() vs .plus(), etc.

I fixed the NaN issue and added some tests.

Thank you for this PR. Good catch!