New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infinite recursion warning #667 #668
Infinite recursion warning #667 #668
Conversation
nevermind, I found the doc https://github.com/web3swift-team/web3swift#development |
@albertopeam just started the ci/cd pipeline that will check it also |
I have checked locally and the local test suite runs(I also saw the CI @yaroslavyaroslav, thanks for sharing), unfortunately this function that triggers the recursion doesn't have an associated test. function signature static func formatToEthereumUnits(_ bigNumber: BigInt, toUnits: Utilities.Units = .eth, decimals: Int = 4, decimalSeparator: String = ".") -> String? |
I think that we've discussion within Discord just right about that. @janndriessen @JeneaVranceanu folks are more involved in this one, so I guess they could say more. |
@albertopeam
No, as that is not a scope of this issue and there were no requests to make it public so let's leave it internal.
Looks like it indeed can be dropped as eventually the But I'd like to keep the extension Utilities {
/// Various units used in Ethereum ecosystem
public enum Units {
case eth
case wei
case Kwei
case Mwei
case Gwei
case Microether
case Finney
case custom(Int)
public var decimals: Int {
get {
switch self {
case .eth:
return 18
case .wei:
return 0
case .Kwei:
return 3
case .Mwei:
return 6
case .Gwei:
return 9
case .Microether:
return 12
case .Finney:
return 15
case .custom(let value):
return value
}
}
}
}
} Update: I'd even use this example and update names + add new cases -> https://github.com/ethereum/eth-utils/blob/master/eth_utils/units.py |
I have updated the PR with the comments received, if I misunderstood something feel free to comment :) |
I'm just really not into this. But folks have both expertise and rights to handle that appropriately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for the changes. 🚀
Waiting for CI and merging. |
@janndriessen I pushed a few commits to this branch. Please, take a look at the as they are small and re-approve this PR if you have no questions. |
good catch with the type! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢 it.
I have read the issue and it seems that the function in Utilities line 149 was commented but the code inside it was not copied to the function that now causes the recursion
Solution: I only forwarded the call from
formatToEthereumUnits
toformatToPrecision
, which was the same as before introducing the recursion.Could you take a look? I ran the unit tests but they crashed as it seems that I need a node running locally and I didn't read the doc yet. If you forward me to the doc I will install the env and I will ran the tests properly before submit the PR