github.com/status-im/status-go@v1.1.0/services/wallet/decoder.go (about)

     1  package wallet
     2  
     3  import (
     4  	"github.com/status-im/status-go/services/wallet/thirdparty"
     5  	"github.com/status-im/status-go/services/wallet/thirdparty/fourbyte"
     6  	"github.com/status-im/status-go/services/wallet/thirdparty/fourbytegithub"
     7  )
     8  
     9  type Decoder struct {
    10  	Main     *fourbytegithub.Client
    11  	Fallback *fourbyte.Client
    12  }
    13  
    14  func NewDecoder() *Decoder {
    15  	return &Decoder{
    16  		Main:     fourbytegithub.NewClient(),
    17  		Fallback: fourbyte.NewClient(),
    18  	}
    19  }
    20  
    21  func (d *Decoder) Decode(data string) (*thirdparty.DataParsed, error) {
    22  	parsed, err := d.Main.Run(data)
    23  	if err == nil {
    24  		return parsed, nil
    25  	}
    26  
    27  	return d.Fallback.Run(data)
    28  }