mirror of
https://github.com/eosswedenorg/thalos
synced 2026-06-16 04:24:56 +02:00
ship_processor.go: Move decodeAction() to abi/helpers.go
This commit is contained in:
parent
2d369adabf
commit
f589f5c0ed
2 changed files with 21 additions and 15 deletions
19
abi/helpers.go
Normal file
19
abi/helpers.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package abi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
eos "github.com/eoscanada/eos-go"
|
||||
)
|
||||
|
||||
func DecodeAction(eos_ABI *eos.ABI, data []byte, actionName eos.ActionName) (interface{}, error) {
|
||||
var v interface{}
|
||||
|
||||
bytes, err := eos_ABI.DecodeAction(data, actionName)
|
||||
if err != nil {
|
||||
return v, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(bytes, &v)
|
||||
return v, err
|
||||
}
|
||||
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
"eosio-ship-trace-reader/abi"
|
||||
"eosio-ship-trace-reader/transport"
|
||||
"github.com/eoscanada/eos-go"
|
||||
"github.com/eoscanada/eos-go/ship"
|
||||
)
|
||||
|
||||
|
|
@ -18,18 +17,6 @@ type ShipReader struct {
|
|||
publisher transport.Publisher
|
||||
}
|
||||
|
||||
func decodeAction(abi *eos.ABI, data []byte, actionName eos.ActionName) (interface{}, error) {
|
||||
var v interface{}
|
||||
|
||||
bytes, err := abi.DecodeAction(data, actionName)
|
||||
if err != nil {
|
||||
return v, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(bytes, &v)
|
||||
return v, err
|
||||
}
|
||||
|
||||
func encodeMessage(v interface{}) ([]byte, bool) {
|
||||
payload, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
|
|
@ -98,9 +85,9 @@ func (reader *ShipReader) processTraces(traces []*ship.TransactionTraceV0) {
|
|||
HexData: hex.EncodeToString(act_trace.Act.Data),
|
||||
}
|
||||
|
||||
abi, err := reader.abi.GetAbi(act_trace.Act.Account)
|
||||
ABI, err := reader.abi.GetAbi(act_trace.Act.Account)
|
||||
if err == nil {
|
||||
v, err := decodeAction(abi, act_trace.Act.Data, act_trace.Act.Name)
|
||||
v, err := abi.DecodeAction(ABI, act_trace.Act.Data, act_trace.Act.Name)
|
||||
if err != nil {
|
||||
log.WithError(err).Warn("Failed to decode action")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue