Commit adfce3ad authored by linj's avatar linj Committed by vipwzw

fix create token asset tx in main chain

parent fc84138c
...@@ -5,11 +5,16 @@ ...@@ -5,11 +5,16 @@
package types package types
import ( import (
"encoding/json"
"reflect" "reflect"
log "github.com/33cn/chain33/common/log/log15"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
) )
var tokenlog = log.New("module", "execs.token.types")
func init() { func init() {
types.AllowUserExec = append(types.AllowUserExec, []byte(TokenX)) types.AllowUserExec = append(types.AllowUserExec, []byte(TokenX))
types.RegistorExecutor(TokenX, NewType()) types.RegistorExecutor(TokenX, NewType())
...@@ -92,3 +97,28 @@ func (t *TokenType) RPC_Default_Process(action string, msg interface{}) (*types. ...@@ -92,3 +97,28 @@ func (t *TokenType) RPC_Default_Process(action string, msg interface{}) (*types.
} }
return tx, err return tx, err
} }
func (t *TokenType) CreateTx(action string, msg json.RawMessage) (*types.Transaction, error) {
tx, err := t.ExecTypeBase.CreateTx(action, msg)
if err != nil {
tokenlog.Error("token CreateTx failed", "err", err, "action", action, "msg", string(msg))
return nil, err
}
if !types.IsPara() {
var transfer TokenAction
err = types.Decode(tx.Payload, &transfer)
if err != nil {
tokenlog.Error("token CreateTx failed", "decode payload err", err, "action", action, "msg", string(msg))
return nil, err
}
if action == "Transfer" {
tx.To = transfer.GetTransfer().To
} else if action == "Withdraw" {
tx.To = transfer.GetWithdraw().To
} else if action == "TransferToExec" {
tx.To = transfer.GetTransferToExec().To
}
}
return tx, nil
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment