fix: internalize `ethers` functionality and remove dependency
Closes https://github.com/FuelLabs/fuels-ts/issues/2153
ethers is now removed from:
-
account -
crypto
As a result there are more ethers functions being internalized:
-
ripemd160 -
pbkdf2 -
hmac -
dataSlice -
encodeBase58 -
decodeBase58 -
getBytes
This can be merged as a follow up to https://github.com/FuelLabs/fuels-ts/pull/2152
✨ A PR has been created under the rc-2130 tag on fuels-wallet repo.
https://github.com/FuelLabs/fuels-wallet/pull/1242
The
getNetwork()work here appears to be small compared to the rest, making the PR title slightly misleading.Should we split the PR into two, dealing with the
getNetwork()in a subsequent PR while re-shaping this one to be concerned only with replacing ethers utilities?
That's a good point @arboleya I'll do that.
I've converted this to draft until https://github.com/FuelLabs/fuels-ts/pull/2152 is merged, but it can still be reviewed, the tests will fail as I have removed the ethers dep in accounts.
Great work @maschad, another good step towards decoupling from
ethers.What was the reasoning behind implementing
getBytes? As it looks exactly the same as our ownarrayify?
Thanks! There are some additional parameters included in the function signature for getBytes that I would need for some use cases I opted not to modify the arrayify to reduce the surface of these changes, but if that's acceptable I can include them in this PR.
IMO that is acceptable here, I'd rather have one point of entry for byte array conversion. I probably would have done the same when we initially internalised ethers if it didn't work with all the use cases.
As discussed, amalgamate the functionality of
getBytesandarrayify.
Thanks @danielbate I've updated in 69bf67a
Nice work 💪🏻
Jw, what
ethersdeps are left after this?
Thanks 😄
Looks like just doc-snippets and abi-coder now
Coverage Report:
| Lines | Branches | Functions | Statements |
|---|---|---|---|
| 79.53%(-0.13%) | 69.79%(+0%) | 77.12%(-0.48%) | 79.64%(-0.12%) |
Changed Files:
| Ok | File (✨=New File) | Lines | Branches | Functions | Statements |
|---|---|---|---|---|---|
| 🔴 | ✨ packages/crypto/src/browser/hmac.ts | 0% (+0%) |
0% (+0%) |
0% (+0%) |
0% (+0%) |
| 🔴 | ✨ packages/crypto/src/browser/pbkdf2.ts | 0% (+0%) |
100% (+100%) |
0% (+0%) |
0% (+0%) |
| 🔴 | ✨ packages/crypto/src/node/hmac.ts | 46.66% (+46.66%) |
0% (+0%) |
0% (+0%) |
46.66% (+46.66%) |
| 🔴 | ✨ packages/crypto/src/node/pbkdf2.ts | 46.66% (+46.66%) |
0% (+0%) |
0% (+0%) |
46.66% (+46.66%) |
| 🔴 | ✨ packages/crypto/src/shared/ripemd160.ts | 69.23% (+69.23%) |
0% (+0%) |
50% (+50%) |
71.42% (+71.42%) |
| ✅ | ✨ packages/utils/src/utils/base58.ts | 100% (+100%) |
100% (+100%) |
100% (+100%) |
100% (+100%) |
| ✅ | ✨ packages/utils/src/utils/dataSlice.ts | 100% (+100%) |
100% (+100%) |
100% (+100%) |
100% (+100%) |