Web3Swift icon indicating copy to clipboard operation
Web3Swift copied to clipboard

Missing convenient constructor for EthNumber

Open rockfridrich opened this issue 6 years ago • 3 comments

It is often needed to construct primitives like EthNumber with pure bytes.

 try EthNumber(
            hex: SimpleBytes(
                bytes: DecodedABINumber(
                    abiMessage: message,
                    index: index
                ).value()
            )
        )

rockfridrich avatar Apr 25 '19 01:04 rockfridrich

In your example initialization can be simplified to:

try EthNumber(
    hex: DecodedABINumber(
        abiMessage: message,
        index: index
    )
)

as hex and DecodedABINumber are both BytesScalar

abdulowork avatar Apr 25 '19 09:04 abdulowork

For ABIMessage it is right but if we get it remotely then the call will be executed only when we check EthNumber.value(). Also I don't want to parse ABIMessage each time I need EthNumber value.

rockfridrich avatar Apr 26 '19 03:04 rockfridrich

@biboran so what is the best way to precompute the value of DecodeABINumber to pass into EthNumber in your opinion? There are also cases when we don't want lazy computations or overuse of CachedBytes

rockfridrich avatar May 06 '19 17:05 rockfridrich