Skip to content

Commit b6a525d

Browse files
authored
Merge pull request #848 from neutron-org/feat/metamask
feat: eip 191 signing #NTRN-454
2 parents 5571c83 + 8213f3a commit b6a525d

File tree

19 files changed

+1773
-12
lines changed

19 files changed

+1773
-12
lines changed

app/ante_handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func NewAnteHandler(options HandlerOptions, _ log.Logger) (sdk.AnteHandler, erro
7878
ante.NewSetPubKeyDecorator(options.AccountKeeper),
7979
ante.NewValidateSigCountDecorator(options.AccountKeeper),
8080
ante.NewSigGasConsumeDecorator(options.AccountKeeper, sigGasConsumer),
81-
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
81+
NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
8282
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
8383
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
8484
}

app/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ func New(
11861186
HandlerOptions: ante.HandlerOptions{
11871187
FeegrantKeeper: app.FeeGrantKeeper,
11881188
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
1189-
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
1189+
SigGasConsumer: DefaultSigVerificationGasConsumer,
11901190
},
11911191
BankKeeper: app.BankKeeper,
11921192
AccountKeeper: app.AccountKeeper,

app/encoding.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package app
33
import (
44
"github.com/cosmos/cosmos-sdk/std"
55

6+
ethcryptocodec "github.com/neutron-org/neutron/v6/x/crypto/codec"
7+
68
"github.com/neutron-org/neutron/v6/app/params"
79
)
810

@@ -11,6 +13,8 @@ func MakeEncodingConfig() params.EncodingConfig {
1113
encodingConfig := params.MakeEncodingConfig()
1214
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
1315
std.RegisterInterfaces(encodingConfig.InterfaceRegistry)
16+
ethcryptocodec.RegisterLegacyAminoCodec(encodingConfig.Amino)
17+
ethcryptocodec.RegisterInterfaces(encodingConfig.InterfaceRegistry)
1418
ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino)
1519
ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry)
1620
return encodingConfig

app/params/encoding.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ package params
22

33
import (
44
"cosmossdk.io/x/tx/signing"
5+
"cosmossdk.io/x/tx/signing/aminojson"
56
"github.com/cosmos/cosmos-sdk/client"
67
"github.com/cosmos/cosmos-sdk/codec"
78
"github.com/cosmos/cosmos-sdk/codec/address"
89
"github.com/cosmos/cosmos-sdk/codec/types"
910
sdk "github.com/cosmos/cosmos-sdk/types"
1011
"github.com/cosmos/cosmos-sdk/x/auth/tx"
1112
"github.com/cosmos/gogoproto/proto"
13+
14+
neutrontx "github.com/neutron-org/neutron/v6/tx"
1215
)
1316

1417
// EncodingConfig specifies the concrete encoding types to use for a given app.
@@ -38,7 +41,18 @@ func MakeEncodingConfig() EncodingConfig {
3841
panic(err)
3942
}
4043
marshaler := codec.NewProtoCodec(reg)
41-
txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes)
44+
45+
signingOptions, err := tx.NewDefaultSigningOptions()
46+
if err != nil {
47+
panic(err)
48+
}
49+
txCfg := tx.NewTxConfig(
50+
marshaler,
51+
tx.DefaultSignModes,
52+
neutrontx.NewSignModeEIP191Handler(aminojson.SignModeHandlerOptions{
53+
FileResolver: signingOptions.FileResolver,
54+
TypeResolver: signingOptions.TypeResolver,
55+
}))
4256

4357
return EncodingConfig{
4458
InterfaceRegistry: reg,

0 commit comments

Comments
 (0)