update evm rpc calc contract address
@@ -7,11 +7,11 @@ package rpc
import (
"context"
"encoding/hex"
+ "errors"
+ chain33Comm "github.com/33cn/chain33/common"
"github.com/33cn/plugin/plugin/dapp/evm/executor/vm/common"
- "github.com/33cn/chain33/common/address"
-
"github.com/33cn/chain33/types"
evm "github.com/33cn/plugin/plugin/dapp/evm/types"
)
@@ -63,6 +63,14 @@ func (c *Jrpc) CalcNewContractAddr(parm *evm.EvmCalcNewContractAddrReq, result *
if parm == nil {
return types.ErrInvalidParam
}
- *result = common.GetEvmAddressDriver().PubKeyToAddr(address.ExecPubKey(parm.Caller + parm.Txhash))
+ callerAddr := common.StringToAddress(parm.Caller)
+ if callerAddr == nil {
+ return errors.New("InvalidCallerAddress")
+ }
+ hashByte, err := chain33Comm.FromHex(parm.Txhash)
+ if err != nil {
+ return errors.New("InvalidHexTxHash")
+ }
+ *result = common.NewContractAddress(*callerAddr, hashByte).String()
return nil
}
