Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Commit

Permalink
signers
Browse files Browse the repository at this point in the history
  • Loading branch information
Devon Bear committed Oct 6, 2023
1 parent f319842 commit fb9868e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 33 deletions.
19 changes: 19 additions & 0 deletions cosmos/lib/signing/signers.go
Original file line number Diff line number Diff line change
@@ -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
},
}
}
29 changes: 0 additions & 29 deletions cosmos/x/evm/types/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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
},
}
}
6 changes: 4 additions & 2 deletions e2e/testapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions e2e/testapp/polard/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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,
Expand Down

0 comments on commit fb9868e

Please sign in to comment.