Skip to content

Commit

Permalink
accounts/abi: unpack error
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusVanDerWijden committed Jul 6, 2021
1 parent 0883718 commit 2389599
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions accounts/abi/error.go
Expand Up @@ -17,6 +17,8 @@
package abi

import (
"bytes"
"errors"
"fmt"
"strings"

Expand Down Expand Up @@ -74,6 +76,16 @@ func NewError(name string, inputs Arguments) Error {
}
}

func (err *Error) String() string {
return err.str
func (e *Error) String() string {
return e.str
}

func (e *Error) Unpack(data []byte) (interface{}, error) {
if len(data) < 4 {
return "", errors.New("invalid data for unpacking")
}
if !bytes.Equal(data[:4], e.ID[:4]) {
return "", errors.New("invalid data for unpacking")
}
return e.Inputs.Unpack(data[4:])
}

0 comments on commit 2389599

Please sign in to comment.