Skip to content

Remove encode_abi and decode_abi and remove _single suffix from other coding functions #84

@davesque

Description

@davesque

What was wrong?

The encode_abi and decode_abi functions (found here and here) do not really serve a useful purpose any more. For example, the following invocations are equivalent:

In [1]: from eth_abi import *

In [2]: encode_single('(int,int)', (1, 2))
Out[2]: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02'

In [3]: encode_abi(('int', 'int'), (1, 2))
Out[3]: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02'

How can it be fixed?

Perhaps we should remove encode_abi and decode_abi and rename encode_single and decode_single to encode and decode respectively?

This could also match Solidity's own API better: https://solidity.readthedocs.io/en/v0.4.24/units-and-global-variables.html?highlight=abi#abi-encoding-functions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions