This commit is contained in:
0xmuralik 2022-10-17 11:55:19 +05:30
parent d35d3c0716
commit ec3e8f7ce3
5 changed files with 14 additions and 12 deletions

View File

@ -31,19 +31,19 @@ type HandlerOptions struct {
} }
func (options HandlerOptions) validate() error { func (options HandlerOptions) validate() error {
if options.AccountKeeper == nil { if options.AccountKeeper == evmtypes.AccountKeeper(nil) {
return sdkerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler") return sdkerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler")
} }
if options.BankKeeper == nil { if options.BankKeeper == evmtypes.BankKeeper(nil) {
return sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for AnteHandler") return sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for AnteHandler")
} }
if options.SignModeHandler == nil { if options.SignModeHandler == authsigning.SignModeHandler(nil) {
return sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder") return sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")
} }
if options.FeeMarketKeeper == nil { if options.FeeMarketKeeper == evmtypes.FeeMarketKeeper(nil) {
return sdkerrors.Wrap(sdkerrors.ErrLogic, "fee market keeper is required for AnteHandler") return sdkerrors.Wrap(sdkerrors.ErrLogic, "fee market keeper is required for AnteHandler")
} }
if options.EvmKeeper == nil { if options.EvmKeeper == EVMKeeper(nil) {
return sdkerrors.Wrap(sdkerrors.ErrLogic, "evm keeper is required for AnteHandler") return sdkerrors.Wrap(sdkerrors.ErrLogic, "evm keeper is required for AnteHandler")
} }
return nil return nil

View File

@ -36,7 +36,6 @@ func GenerateHash(json map[string]interface{}) (string, []byte, error) {
return "", nil, err return "", nil, err
} }
//cid, err := CIDFromJSONBytes(content)
cidString, err := CIDFromJSONBytesUsingIpldPrime(content) cidString, err := CIDFromJSONBytesUsingIpldPrime(content)
if err != nil { if err != nil {
return "", nil, err return "", nil, err
@ -81,7 +80,7 @@ func CIDFromJSONBytesUsingIpldPrime(content []byte) (string, error) {
// This gathers together any parameters that might be needed when making a link. // This gathers together any parameters that might be needed when making a link.
// (For CIDs, the version, the codec, and the multihash type are all parameters we'll need.) // (For CIDs, the version, the codec, and the multihash type are all parameters we'll need.)
// Often, you can probably make this a constant for your whole application. // Often, you can probably make this a constant for your whole application.
lp := cidlink.LinkPrototype{Prefix: cid.Prefix{ lp := cidlink.LinkPrototype{Prefix: cid.Prefix{ //nolint:golint
Version: 1, // Usually '1'. Version: 1, // Usually '1'.
Codec: 0x71, // 0x71 means "dag-cbor" -- See the multicodecs table: https://github.com/multiformats/multicodec/ Codec: 0x71, // 0x71 means "dag-cbor" -- See the multicodecs table: https://github.com/multiformats/multicodec/
MhType: 0x12, // 0x12 means "sha2-256" -- See the multicodecs table: https://github.com/multiformats/multicodec/ MhType: 0x12, // 0x12 means "sha2-256" -- See the multicodecs table: https://github.com/multiformats/multicodec/

View File

@ -16,7 +16,7 @@ func GenerateMnemonic() (string, error) {
return "", err return "", err
} }
mnemonic, err := bip39.NewMnemonic(entropySeed[:]) mnemonic, err := bip39.NewMnemonic(entropySeed)
if err != nil { if err != nil {
return "", err return "", err
} }

View File

@ -12,10 +12,13 @@ import (
set "github.com/deckarep/golang-set" set "github.com/deckarep/golang-set"
) )
func Int64ToBytes(num int64) []byte { func Int64ToBytes(num int64) ([]byte, error) {
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
binary.Write(buf, binary.BigEndian, num) if err := binary.Write(buf, binary.BigEndian, num); err != nil {
return buf.Bytes() return nil, err
}
return buf.Bytes(), nil
} }
func SetToSlice(set set.Set) []string { func SetToSlice(set set.Set) []string {

View File

@ -215,7 +215,7 @@ func (k *Keeper) ApplyTransaction(ctx sdk.Context, tx *ethtypes.Transaction) (*t
// snapshot to contain the tx processing and post processing in same scope // snapshot to contain the tx processing and post processing in same scope
var commit func() var commit func()
tmpCtx := ctx tmpCtx := ctx
if k.hooks != nil { if k.hooks != types.EvmHooks(nil) {
// Create a cache context to revert state when tx hooks fails, // Create a cache context to revert state when tx hooks fails,
// the cache context is only committed when both tx and hooks executed successfully. // the cache context is only committed when both tx and hooks executed successfully.
// Didn't use `Snapshot` because the context stack has exponential complexity on certain operations, // Didn't use `Snapshot` because the context stack has exponential complexity on certain operations,