forked from cerc-io/laconicd-deprecated
rpc, evm: secure tx signing (#20)
* rpc, evm: secure signing * evm, ante: test signer * tests
This commit is contained in:
+2
-2
@@ -63,7 +63,7 @@ func NewAnteHandler(
|
||||
opts := txWithExtensions.GetExtensionOptions()
|
||||
if len(opts) > 0 {
|
||||
switch typeURL := opts[0].GetTypeUrl(); typeURL {
|
||||
case "/ethermint.evm.v1beta1.ExtensionOptionsEthereumTx":
|
||||
case "/ethermint.evm.v1alpha1.ExtensionOptionsEthereumTx":
|
||||
// handle as *evmtypes.MsgEthereumTx
|
||||
|
||||
anteHandler = sdk.ChainAnteDecorators(
|
||||
@@ -79,7 +79,7 @@ func NewAnteHandler(
|
||||
NewEthIncrementSenderSequenceDecorator(ak), // innermost AnteDecorator.
|
||||
)
|
||||
|
||||
case "/ethermint.evm.v1beta1.ExtensionOptionsWeb3Tx":
|
||||
case "/ethermint.evm.v1alpha1.ExtensionOptionsWeb3Tx":
|
||||
// handle as normal Cosmos SDK tx, except signature is checked for EIP712 representation
|
||||
|
||||
switch tx.(type) {
|
||||
|
||||
+1
-1
@@ -290,7 +290,7 @@ func (avd EthAccountVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx
|
||||
if balance.Amount.BigInt().Cmp(msgEthTx.Cost()) < 0 {
|
||||
return ctx, sdkerrors.Wrapf(
|
||||
sdkerrors.ErrInsufficientFunds,
|
||||
"sender balance < tx gas cost (%s%s < %s%s)", balance.String(), evmDenom, msgEthTx.Cost().String(), evmDenom,
|
||||
"sender balance < tx gas cost (%s < %s%s)", balance.String(), msgEthTx.Cost().String(), evmDenom,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,11 @@ import (
|
||||
"github.com/cosmos/ethermint/app"
|
||||
ante "github.com/cosmos/ethermint/app/ante"
|
||||
"github.com/cosmos/ethermint/crypto/ethsecp256k1"
|
||||
"github.com/cosmos/ethermint/tests"
|
||||
ethermint "github.com/cosmos/ethermint/types"
|
||||
evmtypes "github.com/cosmos/ethermint/x/evm/types"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
ethcrypto "github.com/ethereum/go-ethereum/crypto"
|
||||
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
@@ -102,7 +104,10 @@ func newTestSDKTx(
|
||||
func (suite *AnteTestSuite) newTestEthTx(msg *evmtypes.MsgEthereumTx, priv cryptotypes.PrivKey) (sdk.Tx, error) {
|
||||
privkey := ðsecp256k1.PrivKey{Key: priv.Bytes()}
|
||||
|
||||
if err := msg.Sign(suite.chainID, privkey.ToECDSA()); err != nil {
|
||||
signer := tests.NewSigner(privkey)
|
||||
msg.From = common.BytesToAddress(privkey.PubKey().Address().Bytes()).String()
|
||||
|
||||
if err := msg.Sign(suite.chainID, signer); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user