diff --git a/precompiles/pointer/Pointer.sol b/precompiles/pointer/Pointer.sol index d85893949c..a9575b5d53 100644 --- a/precompiles/pointer/Pointer.sol +++ b/precompiles/pointer/Pointer.sol @@ -8,13 +8,13 @@ IPointer constant POINTER_CONTRACT = IPointer(POINTER_PRECOMPILE_ADDRESS); interface IPointer { function addNativePointer( string memory token - ) payable external returns (address ret); + ) external returns (address ret); function addCW20Pointer( string memory cwAddr - ) payable external returns (address ret); + ) external returns (address ret); function addCW721Pointer( string memory cwAddr - ) payable external returns (address ret); + ) external returns (address ret); } diff --git a/precompiles/pointer/pointer.go b/precompiles/pointer/pointer.go index 790e9b7629..35d17f8bb3 100644 --- a/precompiles/pointer/pointer.go +++ b/precompiles/pointer/pointer.go @@ -133,6 +133,9 @@ func (p Precompile) Run(*vm.EVM, common.Address, common.Address, []byte, *big.In } func (p Precompile) AddNative(ctx sdk.Context, method *ethabi.Method, caller common.Address, args []interface{}, value *big.Int, evm *vm.EVM, suppliedGas uint64) (ret []byte, remainingGas uint64, err error) { + if err := pcommon.ValidateNonPayable(value); err != nil { + return nil, 0, err + } if err := pcommon.ValidateArgsLength(args, 1); err != nil { return nil, 0, err } @@ -187,6 +190,9 @@ func (p Precompile) AddNative(ctx sdk.Context, method *ethabi.Method, caller com } func (p Precompile) AddCW20(ctx sdk.Context, method *ethabi.Method, caller common.Address, args []interface{}, value *big.Int, evm *vm.EVM, suppliedGas uint64) (ret []byte, remainingGas uint64, err error) { + if err := pcommon.ValidateNonPayable(value); err != nil { + return nil, 0, err + } if err := pcommon.ValidateArgsLength(args, 1); err != nil { return nil, 0, err } @@ -238,6 +244,9 @@ func (p Precompile) AddCW20(ctx sdk.Context, method *ethabi.Method, caller commo } func (p Precompile) AddCW721(ctx sdk.Context, method *ethabi.Method, caller common.Address, args []interface{}, value *big.Int, evm *vm.EVM, suppliedGas uint64) (ret []byte, remainingGas uint64, err error) { + if err := pcommon.ValidateNonPayable(value); err != nil { + return nil, 0, err + } if err := pcommon.ValidateArgsLength(args, 1); err != nil { return nil, 0, err } diff --git a/precompiles/wasmd/wasmd.go b/precompiles/wasmd/wasmd.go index e1487883d9..e38cd6cfd0 100644 --- a/precompiles/wasmd/wasmd.go +++ b/precompiles/wasmd/wasmd.go @@ -152,7 +152,7 @@ func (p Precompile) RunAndCalculateGas(evm *vm.EVM, caller common.Address, calli case ExecuteMethod: return p.execute(ctx, method, caller, callingContract, args, value, readOnly) case ExecuteBatchMethod: - return p.execute_batch(ctx, method, caller, callingContract, args, value, readOnly) + return p.executeBatch(ctx, method, caller, callingContract, args, value, readOnly) case QueryMethod: return p.query(ctx, method, args, value) } @@ -256,7 +256,7 @@ func (p Precompile) instantiate(ctx sdk.Context, method *abi.Method, caller comm return } -func (p Precompile) execute_batch(ctx sdk.Context, method *abi.Method, caller common.Address, callingContract common.Address, args []interface{}, value *big.Int, readOnly bool) (ret []byte, remainingGas uint64, rerr error) { +func (p Precompile) executeBatch(ctx sdk.Context, method *abi.Method, caller common.Address, callingContract common.Address, args []interface{}, value *big.Int, readOnly bool) (ret []byte, remainingGas uint64, rerr error) { defer func() { if err := recover(); err != nil { ret = nil @@ -319,7 +319,11 @@ func (p Precompile) execute_batch(ctx sdk.Context, method *abi.Method, caller co rerr = err return } - senderAddr := p.evmKeeper.GetSeiAddressOrDefault(ctx, caller) + senderAddr, senderAssociated := p.evmKeeper.GetSeiAddress(ctx, caller) + if !senderAssociated { + rerr = fmt.Errorf("sender %s is not associated", caller.Hex()) + return + } msg := executeMsg.Msg coinsBz := executeMsg.Coins coins := sdk.NewCoins() diff --git a/x/evm/client/cli/query.go b/x/evm/client/cli/query.go index 10120bac32..6209125b71 100644 --- a/x/evm/client/cli/query.go +++ b/x/evm/client/cli/query.go @@ -212,14 +212,23 @@ func CmdQueryERC20Payload() *cobra.Command { var bz []byte switch args[0] { case "transfer": + if len(args) != 3 { + return errors.New("expected usage: `seid tx evm erc20-payload transfer [to] [amount]`") + } to := common.HexToAddress(args[1]) amt, _ := sdk.NewIntFromString(args[2]) bz, err = abi.Pack(args[0], to, amt.BigInt()) case "approve": + if len(args) != 3 { + return errors.New("expected usage: `seid tx evm erc20-payload approve [spender] [amount]`") + } spender := common.HexToAddress(args[1]) amt, _ := sdk.NewIntFromString(args[2]) bz, err = abi.Pack(args[0], spender, amt.BigInt()) case "transferFrom": + if len(args) != 4 { + return errors.New("expected usage: `seid tx evm erc20-payload transferFrom [from] [to] [amount]`") + } from := common.HexToAddress(args[1]) to := common.HexToAddress(args[2]) amt, _ := sdk.NewIntFromString(args[3]) diff --git a/x/evm/handler.go b/x/evm/handler.go index f610540ec0..9cff2a1d2a 100644 --- a/x/evm/handler.go +++ b/x/evm/handler.go @@ -24,6 +24,9 @@ func NewHandler(k *keeper.Keeper) sdk.Handler { case *types.MsgSend: res, err := msgServer.Send(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgRegisterPointer: + res, err := msgServer.RegisterPointer(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) default: errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) diff --git a/x/evm/keeper/msg_server.go b/x/evm/keeper/msg_server.go index 5d70331499..43059ba739 100644 --- a/x/evm/keeper/msg_server.go +++ b/x/evm/keeper/msg_server.go @@ -84,8 +84,9 @@ func (server msgServer) EVMTransaction(goCtx context.Context, msg *types.MsgEVMT ) return } - receipt, err := server.writeReceipt(ctx, msg, tx, emsg, serverRes, stateDB) - if err != nil { + receipt, rerr := server.writeReceipt(ctx, msg, tx, emsg, serverRes, stateDB) + if rerr != nil { + err = rerr ctx.Logger().Error(fmt.Sprintf("failed to write EVM receipt: %s", err)) telemetry.IncrCounterWithLabels( diff --git a/x/evm/keeper/precompile.go b/x/evm/keeper/precompile.go index c2a8b51191..24a5714935 100644 --- a/x/evm/keeper/precompile.go +++ b/x/evm/keeper/precompile.go @@ -5,6 +5,7 @@ import ( "github.com/sei-protocol/sei-chain/precompiles/bank" "github.com/sei-protocol/sei-chain/precompiles/gov" "github.com/sei-protocol/sei-chain/precompiles/staking" + "github.com/sei-protocol/sei-chain/precompiles/wasmd" ) // add any payable precompiles here @@ -13,6 +14,7 @@ var payablePrecompiles = map[string]struct{}{ bank.BankAddress: {}, staking.StakingAddress: {}, gov.GovAddress: {}, + wasmd.WasmdAddress: {}, } func IsPayablePrecompile(addr *common.Address) bool {