f-o-a-m / purescript-web3

a purescript library for the web3 api
Apache License 2.0
127 stars 24 forks source link

Preserve `BytesN (D3 :& DOne D2)` values #128

Closed IvantheTricourne closed 1 year ago

IvantheTricourne commented 5 years ago

The following is a code snippet taken from minting a SignalToken in a test spec:

let geohash = mkBytesN s32 "42"
    radius = mkUIntN s256 10
    stake = mkUIntN s256 1
    owner = account1
    mintAction = SignalToken.mintSignal (txOpts # _to ?~ signalToken # _gas ?~ embed 8000000)
                                        { owner, stake, geohash, radius }
    -- `Signaltoken.TrackedToken`
    Tuple _ (SignalToken.TrackedToken token) <- assertWeb3 provider $
      takeEvent (Proxy :: Proxy SignalToken.TrackedToken) signalToken mintAction
    liftEffect <<< log $ show geohash
    liftEffect <<< log $ show token.geohash
    token.geohash `shouldEqual` geohash
    token.radius `shouldEqual` radius

This results in two strings being printed for geohash and token.geohash, respectively:

0x42
0x4200000000000000000000000000000000000000000000000000000000000000
safareli commented 5 years ago

Workaround is to use Network.Ethereum.Core.HexString (padLeft) on geohash when making transaction.