Skip to content

Better Debug encoding for Binary #1199

Closed
@ethanfrey

Description

When debugging message calls, I get hard to read output like:

Execute { contract_addr: "Contract #1", msg: Binary([123, 34, 101, 120, 101, 99, 117, 116, 101, 34, 58, 123, 34, 99, 111, 110, 116, 114, 97, 99, 116, 95, 97, 100, 100, 114, 34, 58, 34, 67, 111, 110, 116, 114, 97, 99, 116, 32, 35, 50, 34, 44, 34, 109, 115, 103, 34, 58, 34, 101, 51, 48, 61, 34, 44, 34, 102, 117, 110, 100, 115, 34, 58, 91, 93, 125, 125]), funds: [] }

This is the Debug encoding of Binary and it should be improved from default. I have two ideas:

  1. Always hex-encode it (which is more debug friendly than base64... some of us can read ascii bytes in hex)
  2. If ASCII printable, encode it as a string. Otherwise prefix 0x and hex-encode (as 1)

Approach 2 is not very stable for any APIs you would depend on, but debug is only meant for test output for developers, so let's make this nice.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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