Web3.swift icon indicating copy to clipboard operation
Web3.swift copied to clipboard

Add Type Safety to "chainId"

Open rogerluan opened this issue 6 years ago β€’ 8 comments

Overview

This PR adds an enum, EthereumChain, that is a type-safe wrapper for the chainId, as described in EIP155.

Detailed

This PR also makes the chainId parameters mandatory, instead of providing a default value (which was originally 0), review the documentation and update the README file accordingly.

Note

Pardon the extra verbosity on the enum declaration, but in order to implement the .custom case with an associated value, the enum could not inherit directly from Int as those don't allow values to be associated with them. So I had to implement the enum, manually conforming to RawRepresentable.

I'm not too fussed if you guys decide to drop support for the lesser known networks in order to keep the API clean, I just threw in all the chainIds I found browsing Stack Overflow πŸ˜‡

Resolves https://github.com/Boilertalk/Web3.swift/issues/53

rogerluan avatar Aug 14 '18 05:08 rogerluan

@pixelmatrix @Ybrin, I just implemented the requested changes πŸ‘

rogerluan avatar Aug 15 '18 03:08 rogerluan

Looks good to me. Have you looked into the failing tests?

pixelmatrix avatar Aug 15 '18 20:08 pixelmatrix

I'll take a look at those issues soon, sorry for the wait guys.

rogerluan avatar Aug 16 '18 20:08 rogerluan

@rogerluan Have you had a chance to look into these issues yet?

koraykoska avatar Sep 04 '18 12:09 koraykoska

@Ybrin Sorry, not yet. I definitely didn't forget it! πŸ˜… If anyone else wanna address the changes, by all means! Otherwise I'll be checking this later πŸ‘ Sorry for the wait 😞

rogerluan avatar Sep 04 '18 17:09 rogerluan

I apologize for the really long wait, but I finally took some time to look into the failing tests πŸ˜… Let me know if there are any other pending issues here @Ybrin @pixelmatrix ! πŸ˜ƒ

rogerluan avatar Nov 05 '18 06:11 rogerluan

Codecov Report

Merging #62 into master will increase coverage by 0.23%. The diff coverage is 55.26%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #62      +/-   ##
==========================================
+ Coverage   75.14%   75.38%   +0.23%     
==========================================
  Files          64       64              
  Lines        4152     4164      +12     
==========================================
+ Hits         3120     3139      +19     
+ Misses       1032     1025       -7
Impacted Files Coverage Ξ”
...Classes/Core/Transaction/EthereumTransaction.swift 73.46% <55.26%> (+5.53%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data Powered by Codecov. Last update 229c67c...b626e78. Read the comment docs.

codecov[bot] avatar Nov 05 '18 07:11 codecov[bot]

@rogerluan Thanks. Looks good now. Gonna merge it soon for the next version jump.

koraykoska avatar Nov 12 '18 00:11 koraykoska