From fb9868eb4156b88deb8eeff980df4eec47ef8f9a Mon Sep 17 00:00:00 2001 From: Devon Bear Date: Fri, 6 Oct 2023 15:26:10 -0400 Subject: [PATCH] signers --- cosmos/lib/signing/signers.go | 19 +++++++++++++++++++ cosmos/x/evm/types/tx.go | 29 ----------------------------- e2e/testapp/app.go | 6 ++++-- e2e/testapp/polard/cmd/root.go | 7 +++++-- 4 files changed, 28 insertions(+), 33 deletions(-) create mode 100644 cosmos/lib/signing/signers.go diff --git a/cosmos/lib/signing/signers.go b/cosmos/lib/signing/signers.go new file mode 100644 index 000000000..25de1ec4c --- /dev/null +++ b/cosmos/lib/signing/signers.go @@ -0,0 +1,19 @@ +package signing + +import ( + "google.golang.org/protobuf/proto" + + "cosmossdk.io/x/tx/signing" +) + +// ProvideNoopGetSigners returns a CustomGetSigner that always returns 0x0. +func ProvideNoopGetSigners[T proto.Message]() signing.CustomGetSigner { + var t T + return signing.CustomGetSigner{ + MsgType: proto.MessageName(t), + Fn: func(msg proto.Message) ([][]byte, error) { + // Return the signer in the required format. + return [][]byte{{0x0}}, nil + }, + } +} diff --git a/cosmos/x/evm/types/tx.go b/cosmos/x/evm/types/tx.go index 1c1be99d9..7e39cae96 100644 --- a/cosmos/x/evm/types/tx.go +++ b/cosmos/x/evm/types/tx.go @@ -23,13 +23,8 @@ package types import ( "fmt" - "google.golang.org/protobuf/proto" - - "cosmossdk.io/x/tx/signing" - sdk "github.com/cosmos/cosmos-sdk/types" - v1alpha1evm "pkg.berachain.dev/polaris/cosmos/api/polaris/evm/v1alpha1" coretypes "pkg.berachain.dev/polaris/eth/core/types" ) @@ -56,27 +51,3 @@ func (etr *WrappedEthereumTransaction) UnwrapTx() *coretypes.Transaction { } return tx } - -// ProvideEthereumTransactionGetSigners defines a custom function for -// utilizing custom signer handling for `WrappedEthereumTransaction`s. -func ProvideWrappedPayloadGetSigners() signing.CustomGetSigner { - return signing.CustomGetSigner{ - MsgType: proto.MessageName(&v1alpha1evm.WrappedPayloadEnvelope{}), - Fn: func(msg proto.Message) ([][]byte, error) { - // Return the signer in the required format. - return [][]byte{{0x0}}, nil - }, - } -} - -// ProvideEthereumTransactionGetSigners defines a custom function for -// utilizing custom signer handling for `WrappedEthereumTransaction`s. -func ProvideEthereumTransactionGetSigners() signing.CustomGetSigner { - return signing.CustomGetSigner{ - MsgType: proto.MessageName(&v1alpha1evm.WrappedEthereumTransaction{}), - Fn: func(msg proto.Message) ([][]byte, error) { - // Return the signer in the required format. - return [][]byte{{0x0}}, nil - }, - } -} diff --git a/e2e/testapp/app.go b/e2e/testapp/app.go index c510e0e56..308708210 100644 --- a/e2e/testapp/app.go +++ b/e2e/testapp/app.go @@ -57,8 +57,10 @@ import ( "github.com/ethereum/go-ethereum/node" + evmv1alpha1 "pkg.berachain.dev/polaris/cosmos/api/polaris/evm/v1alpha1" evmconfig "pkg.berachain.dev/polaris/cosmos/config" ethcryptocodec "pkg.berachain.dev/polaris/cosmos/crypto/codec" + signinglib "pkg.berachain.dev/polaris/cosmos/lib/signing" "pkg.berachain.dev/polaris/cosmos/miner" "pkg.berachain.dev/polaris/cosmos/txpool" evmante "pkg.berachain.dev/polaris/cosmos/x/evm/ante" @@ -134,8 +136,8 @@ func NewPolarisApp( appConfig = depinject.Configs( MakeAppConfig(bech32Prefix), depinject.Provide( - evmtypes.ProvideEthereumTransactionGetSigners, - evmtypes.ProvideWrappedPayloadGetSigners), + signinglib.ProvideNoopGetSigners[*evmv1alpha1.WrappedEthereumTransaction], + signinglib.ProvideNoopGetSigners[*evmv1alpha1.WrappedPayloadEnvelope]), depinject.Supply( // supply the application options appOpts, diff --git a/e2e/testapp/polard/cmd/root.go b/e2e/testapp/polard/cmd/root.go index ff92d14ed..6b2b5f7a6 100644 --- a/e2e/testapp/polard/cmd/root.go +++ b/e2e/testapp/polard/cmd/root.go @@ -61,10 +61,11 @@ import ( "github.com/cosmos/cosmos-sdk/x/crisis" genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" + evmv1alpha1 "pkg.berachain.dev/polaris/cosmos/api/polaris/evm/v1alpha1" evmconfig "pkg.berachain.dev/polaris/cosmos/config" ethcryptocodec "pkg.berachain.dev/polaris/cosmos/crypto/codec" "pkg.berachain.dev/polaris/cosmos/crypto/keyring" - evmtypes "pkg.berachain.dev/polaris/cosmos/x/evm/types" + signinglib "pkg.berachain.dev/polaris/cosmos/lib/signing" testapp "pkg.berachain.dev/polaris/e2e/testapp" ) @@ -89,7 +90,9 @@ func NewRootCmd() *cobra.Command { log.NewNopLogger(), simtestutil.NewAppOptionsWithFlagHome(tempDir()), ), - depinject.Provide(evmtypes.ProvideEthereumTransactionGetSigners, evmtypes.ProvideWrappedPayloadGetSigners)), + depinject.Provide( + signinglib.ProvideNoopGetSigners[*evmv1alpha1.WrappedEthereumTransaction], + signinglib.ProvideNoopGetSigners[*evmv1alpha1.WrappedPayloadEnvelope])), &interfaceRegistry, &appCodec, &txConfig,