Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Missing convenient constructor for EthNumber #212

Open
rockfridrich opened this issue Apr 25, 2019 · 3 comments
Open

Missing convenient constructor for EthNumber #212

rockfridrich opened this issue Apr 25, 2019 · 3 comments

Comments

@rockfridrich
Copy link
Member

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

 try EthNumber(
            hex: SimpleBytes(
                bytes: DecodedABINumber(
                    abiMessage: message,
                    index: index
                ).value()
            )
        )
@abdulowork
Copy link
Contributor

abdulowork commented Apr 25, 2019

In your example initialization can be simplified to:

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

as hex and DecodedABINumber are both BytesScalar

@rockfridrich
Copy link
Member Author

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
Copy link
Member Author

@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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants