mirror of
https://github.com/eosswedenorg/thalos
synced 2026-06-16 04:24:56 +02:00
abi.go: move DecodeAction to ship_processor.
This commit is contained in:
parent
9c3bd1e879
commit
0ded3ee6fe
2 changed files with 14 additions and 13 deletions
12
abi.go
12
abi.go
|
|
@ -41,15 +41,3 @@ func GetAbi(account eos.AccountName) (*eos.ABI, error) {
|
|||
}
|
||||
return abi, nil
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,22 @@ import (
|
|||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"eosio-ship-trace-reader/internal/redis"
|
||||
"github.com/eoscanada/eos-go"
|
||||
"github.com/eoscanada/eos-go/ship"
|
||||
)
|
||||
|
||||
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 {
|
||||
|
|
@ -80,7 +93,7 @@ func processTraces(traces []*ship.TransactionTraceV0) {
|
|||
|
||||
abi, err := GetAbi(act_trace.Act.Account)
|
||||
if err == nil {
|
||||
v, err := DecodeAction(abi, act_trace.Act.Data, act_trace.Act.Name)
|
||||
v, err := 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