Closed kejace closed 6 years ago
I can verify that this happens from fromJust $ mkHexString "0xAbBa"
:
/Users/kejace/devel/purescript-web3/output/Data.Maybe/index.js:127
throw new Error("Failed pattern match at Data.Maybe line 270, column 1 - line 270, column 46: " + [ v.constructor.name ]);
^
I think it is important we allow mixed-case strings, because often users copy-paste addresses from websites that follow the EIP55
.
I propose we
mkAddress
that follows EIP55 that fails on wrong check-sum implied by the mixed-case encoded hexstring.@kejace
there actually isn't a hex string parser anymore because i still had problems with stack overflow, we're just basically running through the text input and making sure that it "is a valid hex string"
so for (1) you can just supplement the character set in this function https://github.com/f-o-a-m/purescript-web3/blob/master/src/Network/Ethereum/Web3/Types/Types.purs#L139
for (2) i don't know if i understand exactly what you are proposing, can you just write the pr?
@kejace
Regarding (2) @XertroV actually helped implement this in elm-web3, this might help for reference https://github.com/cmditch/elm-web3/pull/44/files#diff-5dcf14483310ac06f8844a6458d78110R133
@kejace - I think it was introduced here: https://github.com/f-o-a-m/purescript-web3/commit/328a47b6c20943a604e87406618db1c3108d6966#diff-ededbfc84072116829037439fdc1c254L136
(You can see that only lower case chars are used), sounds like the soln is just to include ABCDEF in the list..
We should probably check the length % 2 == 0
also
We used to be able to parse hex-strings such as
0xAbCd
, now we're failing on this. My suspicion is that this was maybe introduced with #36 but I haven't verified that.Why do we want to be able to parse mixed case strings? See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md
Of course, we should likely implement this feature in the in the
Address
constructor and throw there instead.