Skip to content

should String.pad(32) right-pad or left-pad strings that aren't hex/numeric? #83

@cdetrio

Description

@cdetrio

In the mutan example line if this.data[0] == "heartbeat" {, the "heartbeat" string is converted by mutan to a left-padded hex value. However, if the data argument is prepared in javascript like this:
var data = "heartbeat".pad(32).unbin();
the value sent with the transaction is right-padded, causing the mutan if conditional (opcode EQ in the debugger) to fail. A simple fix is to prepare a string data argument like this:
var data = "heartbeat".pad(32,0).unbin();
Is String.pad() acting correctly when the 2nd argument is missing?

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