Commit fb2fd411 authored by whisker's avatar whisker

fix to addr bug

parent 339cc15b
package types package types
import ( import (
"encoding/json"
"reflect" "reflect"
log "github.com/33cn/chain33/common/log/log15" log "github.com/33cn/chain33/common/log/log15"
...@@ -134,3 +135,29 @@ func (action *X2EthereumAction) GetActionName() string { ...@@ -134,3 +135,29 @@ func (action *X2EthereumAction) GetActionName() string {
} }
return "unknown-x2ethereum" return "unknown-x2ethereum"
} }
// CreateTx token 创建合约
func (x *x2ethereumType) CreateTx(action string, msg json.RawMessage) (*types.Transaction, error) {
tx, err := x.ExecTypeBase.CreateTx(action, msg)
if err != nil {
tlog.Error("token CreateTx failed", "err", err, "action", action, "msg", string(msg))
return nil, err
}
cfg := x.GetConfig()
if !cfg.IsPara() {
var transfer X2EthereumAction
err = types.Decode(tx.Payload, &transfer)
if err != nil {
tlog.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.GetWithdrawFromExec().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