mirror of
https://github.com/eosswedenorg/thalos
synced 2026-06-16 04:24:56 +02:00
api/message/types.go: remove ActionTrace.HexData
This commit is contained in:
parent
f7bf1da56f
commit
ba05d3d7de
5 changed files with 26 additions and 68 deletions
|
|
@ -1,7 +1,6 @@
|
|||
package json
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
"time"
|
||||
|
|
@ -27,7 +26,7 @@ func TestJson_EncodeActionTrace(t *testing.T) {
|
|||
Contract: "eosio",
|
||||
Receiver: "account2",
|
||||
Data: dataJson,
|
||||
HexData: hex.EncodeToString(dataJson),
|
||||
|
||||
Authorization: []message.PermissionLevel{
|
||||
{Actor: "account1", Permission: "active"},
|
||||
},
|
||||
|
|
@ -36,7 +35,7 @@ func TestJson_EncodeActionTrace(t *testing.T) {
|
|||
Return: []byte{0xde, 0xad, 0xbe, 0xef},
|
||||
}
|
||||
|
||||
expected := `{"tx_id":"ed3b8e853647971cf8296f004c3a1aeac255f082b2cb3c12cc3222e2d7c174ab","blocknum":267372365,"blocktimestamp":"2003-03-21T17:23:09.500","name":"transfer","contract":"eosio","receiver":"account2","data":"eyJmcm9tIjoiYWNjb3VudDEiLCJxdWFudGl0eSI6IjEwMDAuMDAwMCBXQVgiLCJ0byI6ImFjY291bnQyIn0=","hex_data":"7b2266726f6d223a226163636f756e7431222c227175616e74697479223a22313030302e3030303020574158222c22746f223a226163636f756e7432227d","authorization":[{"actor":"account1","permission":"active"}],"except":"errstr","error":2,"return":"3q2+7w=="}`
|
||||
expected := `{"tx_id":"ed3b8e853647971cf8296f004c3a1aeac255f082b2cb3c12cc3222e2d7c174ab","blocknum":267372365,"blocktimestamp":"2003-03-21T17:23:09.500","name":"transfer","contract":"eosio","receiver":"account2","data":"eyJmcm9tIjoiYWNjb3VudDEiLCJxdWFudGl0eSI6IjEwMDAuMDAwMCBXQVgiLCJ0byI6ImFjY291bnQyIn0=","authorization":[{"actor":"account1","permission":"active"}],"except":"errstr","error":2,"return":"3q2+7w=="}`
|
||||
|
||||
data, err := json_codec.Marshal(msg)
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -60,7 +59,6 @@ func TestJson_DecodeActionTrace(t *testing.T) {
|
|||
Contract: "eosio",
|
||||
Receiver: "account2",
|
||||
Data: dataJson,
|
||||
HexData: hex.EncodeToString(dataJson),
|
||||
Authorization: []message.PermissionLevel{
|
||||
{Actor: "account1", Permission: "active"},
|
||||
},
|
||||
|
|
@ -69,7 +67,7 @@ func TestJson_DecodeActionTrace(t *testing.T) {
|
|||
Return: []byte{0xde, 0xad, 0xbe, 0xef},
|
||||
}
|
||||
|
||||
input := `{"tx_id":"952989f7464237b6cf9926e533ecd331df6794ed07564bd052bc368cbd65b4bc","blocknum":8723971,"blocktimestamp":"2024-06-21T08:08:26.500","name":"transfer","contract":"eosio","receiver":"account2","data":"eyJmcm9tIjoiYWNjb3VudDEiLCJxdWFudGl0eSI6IjEwMDAuMDAwMCBXQVgiLCJ0byI6ImFjY291bnQyIn0=","hex_data":"7b2266726f6d223a226163636f756e7431222c227175616e74697479223a22313030302e3030303020574158222c22746f223a226163636f756e7432227d","authorization":[{"actor":"account1","permission":"active"}],"except":"errstr","error":2,"return":"3q2+7w=="}`
|
||||
input := `{"tx_id":"952989f7464237b6cf9926e533ecd331df6794ed07564bd052bc368cbd65b4bc","blocknum":8723971,"blocktimestamp":"2024-06-21T08:08:26.500","name":"transfer","contract":"eosio","receiver":"account2","data":"eyJmcm9tIjoiYWNjb3VudDEiLCJxdWFudGl0eSI6IjEwMDAuMDAwMCBXQVgiLCJ0byI6ImFjY291bnQyIn0=","authorization":[{"actor":"account1","permission":"active"}],"except":"errstr","error":2,"return":"3q2+7w=="}`
|
||||
|
||||
msg := message.ActionTrace{}
|
||||
err = json_codec.Unmarshal([]byte(input), &msg)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package msgpack
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
"time"
|
||||
|
|
@ -38,7 +37,6 @@ func TestMsgpack_EncodeActionTrace(t *testing.T) {
|
|||
Contract: "mygame",
|
||||
Receiver: "eosio",
|
||||
Data: dataJson,
|
||||
HexData: "d0fa1b2ab8a6fd0d1b0173df91aa9ffd277642d05780cf750",
|
||||
Authorization: []message.PermissionLevel{
|
||||
{Actor: "mygame", Permission: "active"},
|
||||
},
|
||||
|
|
@ -51,7 +49,7 @@ func TestMsgpack_EncodeActionTrace(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
|
||||
expected := []byte{
|
||||
0x8c, 0xa5, 0x74, 0x78, 0x5f, 0x69, 0x64, 0xd9,
|
||||
0x8b, 0xa5, 0x74, 0x78, 0x5f, 0x69, 0x64, 0xd9,
|
||||
0x40, 0x65, 0x64, 0x63, 0x30, 0x36, 0x64, 0x63,
|
||||
0x65, 0x36, 0x33, 0x32, 0x30, 0x34, 0x35, 0x39,
|
||||
0x66, 0x64, 0x36, 0x34, 0x34, 0x37, 0x35, 0x36,
|
||||
|
|
@ -90,25 +88,17 @@ func TestMsgpack_EncodeActionTrace(t *testing.T) {
|
|||
0x22, 0x73, 0x74, 0x72, 0x22, 0x3a, 0x22, 0x31,
|
||||
0x30, 0x30, 0x22, 0x7d, 0x2c, 0x22, 0x74, 0x6f,
|
||||
0x22, 0x3a, 0x22, 0x61, 0x63, 0x63, 0x6f, 0x75,
|
||||
0x6e, 0x74, 0x32, 0x22, 0x7d, 0xa8, 0x68, 0x65,
|
||||
0x78, 0x5f, 0x64, 0x61, 0x74, 0x61, 0xd9, 0x31,
|
||||
0x64, 0x30, 0x66, 0x61, 0x31, 0x62, 0x32, 0x61,
|
||||
0x62, 0x38, 0x61, 0x36, 0x66, 0x64, 0x30, 0x64,
|
||||
0x31, 0x62, 0x30, 0x31, 0x37, 0x33, 0x64, 0x66,
|
||||
0x39, 0x31, 0x61, 0x61, 0x39, 0x66, 0x66, 0x64,
|
||||
0x32, 0x37, 0x37, 0x36, 0x34, 0x32, 0x64, 0x30,
|
||||
0x35, 0x37, 0x38, 0x30, 0x63, 0x66, 0x37, 0x35,
|
||||
0x30, 0xad, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72,
|
||||
0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x91,
|
||||
0x82, 0xa5, 0x61, 0x63, 0x74, 0x6f, 0x72, 0xa6,
|
||||
0x6d, 0x79, 0x67, 0x61, 0x6d, 0x65, 0xaa, 0x70,
|
||||
0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f,
|
||||
0x6e, 0xa6, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65,
|
||||
0xa6, 0x65, 0x78, 0x63, 0x65, 0x70, 0x74, 0xa6,
|
||||
0x65, 0x72, 0x72, 0x73, 0x74, 0x72, 0xa5, 0x65,
|
||||
0x72, 0x72, 0x6f, 0x72, 0x02, 0xa6, 0x72, 0x65,
|
||||
0x74, 0x75, 0x72, 0x6e, 0xc4, 0x04, 0xde, 0xad,
|
||||
0xbe, 0xef,
|
||||
0x6e, 0x74, 0x32, 0x22, 0x7d, 0xad, 0x61, 0x75,
|
||||
0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x91, 0x82, 0xa5, 0x61, 0x63,
|
||||
0x74, 0x6f, 0x72, 0xa6, 0x6d, 0x79, 0x67, 0x61,
|
||||
0x6d, 0x65, 0xaa, 0x70, 0x65, 0x72, 0x6d, 0x69,
|
||||
0x73, 0x73, 0x69, 0x6f, 0x6e, 0xa6, 0x61, 0x63,
|
||||
0x74, 0x69, 0x76, 0x65, 0xa6, 0x65, 0x78, 0x63,
|
||||
0x65, 0x70, 0x74, 0xa6, 0x65, 0x72, 0x72, 0x73,
|
||||
0x74, 0x72, 0xa5, 0x65, 0x72, 0x72, 0x6f, 0x72,
|
||||
0x02, 0xa6, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
|
||||
0xc4, 0x04, 0xde, 0xad, 0xbe, 0xef,
|
||||
}
|
||||
|
||||
assert.Equal(t, expected, data)
|
||||
|
|
@ -117,7 +107,7 @@ func TestMsgpack_EncodeActionTrace(t *testing.T) {
|
|||
func TestMsgpack_Decode(t *testing.T) {
|
||||
RegisterGeneratedResolver()
|
||||
|
||||
data := []byte("\x8c\xa5tx_id\xd9@edc06dce6320459fd644756972048da453b2816b0a434c37ddffde36778dcab3\xa8blocknum\xce\x00\x85F7\xaeblocktimestamp\xd6\xffH\xf1U\x1f\xa4name\xa4drop\xa8contract\xa6mygame\xa8receiver\xa8account1\xa4dataċ{\"dropped_from_id\":674562,\"item\":{\"dur\":145,\"id\":49623,\"name\":\"Shadowmourne\",\"qual\":\"legendary\",\"sta\":198,\"str\":223},\"receiver\":\"account1\"}\xa8hex_data\xda\x01\x167b2264726f707065645f66726f6d5f6964223a3637343536322c226974656d223a7b22647572223a3134352c226964223a34393632332c226e616d65223a22536861646f776d6f75726e65222c227175616c223a226c6567656e64617279222c22737461223a3139382c22737472223a3232337d2c227265636569766572223a226163636f756e7431227d\xadauthorization\x91\x82\xa5actor\xa6mygame\xaapermission\xa6active\xa6except\xa6errstr\xa5error\x02\xa6return\xc4\x04ޭ\xbe\xef")
|
||||
data := []byte("\x8b\xa5tx_id\xd9@edc06dce6320459fd644756972048da453b2816b0a434c37ddffde36778dcab3\xa8blocknum\xce\x00\x85F7\xaeblocktimestamp\xd6\xffH\xf1U\x1f\xa4name\xa4drop\xa8contract\xa6mygame\xa8receiver\xa8account1\xa4dataċ{\"dropped_from_id\":674562,\"item\":{\"dur\":145,\"id\":49623,\"name\":\"Shadowmourne\",\"qual\":\"legendary\",\"sta\":198,\"str\":223},\"receiver\":\"account1\"}\xadauthorization\x91\x82\xa5actor\xa6mygame\xaapermission\xa6active\xa6except\xa6errstr\xa5error\x02\xa6return\xc4\x04ޭ\xbe\xef")
|
||||
|
||||
dataJson, err := json.Marshal(map[string]interface{}{
|
||||
"item": map[string]interface{}{
|
||||
|
|
@ -142,7 +132,6 @@ func TestMsgpack_Decode(t *testing.T) {
|
|||
Contract: "mygame",
|
||||
Receiver: "account1",
|
||||
Data: dataJson,
|
||||
HexData: hex.EncodeToString(dataJson),
|
||||
Authorization: []message.PermissionLevel{
|
||||
{Actor: "mygame", Permission: "active"},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -606,7 +606,7 @@ func ___decodeMapPermissionLevel_27424f445a2085e7723342fb0df638c626b43c59240988b
|
|||
// calculate size from github.com/eosswedenorg/thalos/api/message.ActionTrace
|
||||
func ___calcArraySizeActionTrace_27424f445a2085e7723342fb0df638c626b43c59240988bc64f2d60167ee4080(v message.ActionTrace, encoder *enc.Encoder) (int, error) {
|
||||
size := 0
|
||||
size += encoder.CalcStructHeaderFix(12)
|
||||
size += encoder.CalcStructHeaderFix(11)
|
||||
size += encoder.CalcString(v.TxID)
|
||||
size += encoder.CalcUint32(v.BlockNum)
|
||||
size += encoder.CalcTime(v.Timestamp)
|
||||
|
|
@ -625,7 +625,6 @@ func ___calcArraySizeActionTrace_27424f445a2085e7723342fb0df638c626b43c59240988b
|
|||
} else {
|
||||
size += encoder.CalcNil()
|
||||
}
|
||||
size += encoder.CalcString(v.HexData)
|
||||
if v.Authorization != nil {
|
||||
s, err := encoder.CalcSliceLength(len(v.Authorization), false)
|
||||
if err != nil {
|
||||
|
|
@ -662,7 +661,7 @@ func ___calcArraySizeActionTrace_27424f445a2085e7723342fb0df638c626b43c59240988b
|
|||
// calculate size from github.com/eosswedenorg/thalos/api/message.ActionTrace
|
||||
func ___calcMapSizeActionTrace_27424f445a2085e7723342fb0df638c626b43c59240988bc64f2d60167ee4080(v message.ActionTrace, encoder *enc.Encoder) (int, error) {
|
||||
size := 0
|
||||
size += encoder.CalcStructHeaderFix(12)
|
||||
size += encoder.CalcStructHeaderFix(11)
|
||||
size += encoder.CalcStringFix(5)
|
||||
size += encoder.CalcString(v.TxID)
|
||||
size += encoder.CalcStringFix(8)
|
||||
|
|
@ -688,8 +687,6 @@ func ___calcMapSizeActionTrace_27424f445a2085e7723342fb0df638c626b43c59240988bc6
|
|||
} else {
|
||||
size += encoder.CalcNil()
|
||||
}
|
||||
size += encoder.CalcStringFix(8)
|
||||
size += encoder.CalcString(v.HexData)
|
||||
size += encoder.CalcStringFix(13)
|
||||
if v.Authorization != nil {
|
||||
s, err := encoder.CalcSliceLength(len(v.Authorization), false)
|
||||
|
|
@ -730,7 +727,7 @@ func ___calcMapSizeActionTrace_27424f445a2085e7723342fb0df638c626b43c59240988bc6
|
|||
// encode from github.com/eosswedenorg/thalos/api/message.ActionTrace
|
||||
func ___encodeArrayActionTrace_27424f445a2085e7723342fb0df638c626b43c59240988bc64f2d60167ee4080(v message.ActionTrace, encoder *enc.Encoder, offset int) ([]byte, int, error) {
|
||||
var err error
|
||||
offset = encoder.WriteStructHeaderFixAsArray(12, offset)
|
||||
offset = encoder.WriteStructHeaderFixAsArray(11, offset)
|
||||
offset = encoder.WriteString(v.TxID, offset)
|
||||
offset = encoder.WriteUint32(v.BlockNum, offset)
|
||||
offset = encoder.WriteTime(v.Timestamp, offset)
|
||||
|
|
@ -745,7 +742,6 @@ func ___encodeArrayActionTrace_27424f445a2085e7723342fb0df638c626b43c59240988bc6
|
|||
} else {
|
||||
offset = encoder.WriteNil(offset)
|
||||
}
|
||||
offset = encoder.WriteString(v.HexData, offset)
|
||||
if v.Authorization != nil {
|
||||
offset = encoder.WriteSliceLength(len(v.Authorization), offset, false)
|
||||
for _, vv := range v.Authorization {
|
||||
|
|
@ -773,7 +769,7 @@ func ___encodeArrayActionTrace_27424f445a2085e7723342fb0df638c626b43c59240988bc6
|
|||
// encode from github.com/eosswedenorg/thalos/api/message.ActionTrace
|
||||
func ___encodeMapActionTrace_27424f445a2085e7723342fb0df638c626b43c59240988bc64f2d60167ee4080(v message.ActionTrace, encoder *enc.Encoder, offset int) ([]byte, int, error) {
|
||||
var err error
|
||||
offset = encoder.WriteStructHeaderFixAsMap(12, offset)
|
||||
offset = encoder.WriteStructHeaderFixAsMap(11, offset)
|
||||
offset = encoder.WriteStringFix("tx_id", 5, offset)
|
||||
offset = encoder.WriteString(v.TxID, offset)
|
||||
offset = encoder.WriteStringFix("blocknum", 8, offset)
|
||||
|
|
@ -795,8 +791,6 @@ func ___encodeMapActionTrace_27424f445a2085e7723342fb0df638c626b43c59240988bc64f
|
|||
} else {
|
||||
offset = encoder.WriteNil(offset)
|
||||
}
|
||||
offset = encoder.WriteStringFix("hex_data", 8, offset)
|
||||
offset = encoder.WriteString(v.HexData, offset)
|
||||
offset = encoder.WriteStringFix("authorization", 13, offset)
|
||||
if v.Authorization != nil {
|
||||
offset = encoder.WriteSliceLength(len(v.Authorization), offset, false)
|
||||
|
|
@ -827,7 +821,7 @@ func ___encodeMapActionTrace_27424f445a2085e7723342fb0df638c626b43c59240988bc64f
|
|||
|
||||
// decode to github.com/eosswedenorg/thalos/api/message.ActionTrace
|
||||
func ___decodeArrayActionTrace_27424f445a2085e7723342fb0df638c626b43c59240988bc64f2d60167ee4080(v *message.ActionTrace, decoder *dec.Decoder, offset int) (int, error) {
|
||||
offset, err := decoder.CheckStructHeader(12, offset)
|
||||
offset, err := decoder.CheckStructHeader(11, offset)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
|
@ -899,14 +893,6 @@ func ___decodeArrayActionTrace_27424f445a2085e7723342fb0df638c626b43c59240988bc6
|
|||
} else {
|
||||
offset++
|
||||
}
|
||||
{
|
||||
var vv string
|
||||
vv, offset, err = decoder.AsString(offset)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
v.HexData = vv
|
||||
}
|
||||
if !decoder.IsCodeNil(offset) {
|
||||
var vv []message.PermissionLevel
|
||||
var vvl int
|
||||
|
|
@ -976,18 +962,17 @@ func ___decodeMapActionTrace_27424f445a2085e7723342fb0df638c626b43c59240988bc64f
|
|||
{uint8(0x63), uint8(0x6f), uint8(0x6e), uint8(0x74), uint8(0x72), uint8(0x61), uint8(0x63), uint8(0x74)}, // contract
|
||||
{uint8(0x72), uint8(0x65), uint8(0x63), uint8(0x65), uint8(0x69), uint8(0x76), uint8(0x65), uint8(0x72)}, // receiver
|
||||
{uint8(0x64), uint8(0x61), uint8(0x74), uint8(0x61)}, // data
|
||||
{uint8(0x68), uint8(0x65), uint8(0x78), uint8(0x5f), uint8(0x64), uint8(0x61), uint8(0x74), uint8(0x61)}, // hex_data
|
||||
{uint8(0x61), uint8(0x75), uint8(0x74), uint8(0x68), uint8(0x6f), uint8(0x72), uint8(0x69), uint8(0x7a), uint8(0x61), uint8(0x74), uint8(0x69), uint8(0x6f), uint8(0x6e)}, // authorization
|
||||
{uint8(0x65), uint8(0x78), uint8(0x63), uint8(0x65), uint8(0x70), uint8(0x74)}, // except
|
||||
{uint8(0x65), uint8(0x72), uint8(0x72), uint8(0x6f), uint8(0x72)}, // error
|
||||
{uint8(0x72), uint8(0x65), uint8(0x74), uint8(0x75), uint8(0x72), uint8(0x6e)}, // return
|
||||
}
|
||||
offset, err := decoder.CheckStructHeader(12, offset)
|
||||
offset, err := decoder.CheckStructHeader(11, offset)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
count := 0
|
||||
for count < 12 {
|
||||
for count < 11 {
|
||||
var dataKey []byte
|
||||
dataKey, offset, err = decoder.AsStringBytes(offset)
|
||||
if err != nil {
|
||||
|
|
@ -1093,16 +1078,6 @@ func ___decodeMapActionTrace_27424f445a2085e7723342fb0df638c626b43c59240988bc64f
|
|||
}
|
||||
count++
|
||||
case 7:
|
||||
{
|
||||
var vv string
|
||||
vv, offset, err = decoder.AsString(offset)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
v.HexData = vv
|
||||
}
|
||||
count++
|
||||
case 8:
|
||||
if !decoder.IsCodeNil(offset) {
|
||||
var vv []message.PermissionLevel
|
||||
var vvl int
|
||||
|
|
@ -1124,7 +1099,7 @@ func ___decodeMapActionTrace_27424f445a2085e7723342fb0df638c626b43c59240988bc64f
|
|||
offset++
|
||||
}
|
||||
count++
|
||||
case 9:
|
||||
case 8:
|
||||
{
|
||||
var vv string
|
||||
vv, offset, err = decoder.AsString(offset)
|
||||
|
|
@ -1134,7 +1109,7 @@ func ___decodeMapActionTrace_27424f445a2085e7723342fb0df638c626b43c59240988bc64f
|
|||
v.Except = vv
|
||||
}
|
||||
count++
|
||||
case 10:
|
||||
case 9:
|
||||
{
|
||||
var vv uint64
|
||||
vv, offset, err = decoder.AsUint64(offset)
|
||||
|
|
@ -1144,7 +1119,7 @@ func ___decodeMapActionTrace_27424f445a2085e7723342fb0df638c626b43c59240988bc64f
|
|||
v.Error = vv
|
||||
}
|
||||
count++
|
||||
case 11:
|
||||
case 10:
|
||||
if !decoder.IsCodeNil(offset) {
|
||||
var vv []byte
|
||||
var vvl int
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ type ActionTrace struct {
|
|||
|
||||
Receiver string `json:"receiver" msgpack:"receiver"`
|
||||
Data []byte `json:"data" msgpack:"data"`
|
||||
HexData string `json:"hex_data" msgpack:"hex_data"`
|
||||
|
||||
Authorization []PermissionLevel `json:"authorization" msgpack:"authorization"`
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue