Skip to content

Commit b296565

Browse files
committed
cleanup
1 parent 1be3ee7 commit b296565

File tree

11 files changed

+14
-27
lines changed

11 files changed

+14
-27
lines changed

precompiles/bank/bank.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (p Precompile) RequiredGas(input []byte) uint64 {
112112
}
113113

114114
// Execute executes the precompiled contract bank query methods defined in the ABI.
115-
func (p Precompile) Execute(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract, readOnly bool) ([]byte, error) {
115+
func (p Precompile) Execute(ctx sdk.Context, _ vm.StateDB, contract *vm.Contract, readOnly bool) ([]byte, error) {
116116
method, args, err := cmn.SetupABI(p.ABI, contract, readOnly, p.IsTransaction)
117117
if err != nil {
118118
return nil, err
@@ -122,11 +122,11 @@ func (p Precompile) Execute(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract,
122122
switch method.Name {
123123
// Bank queries
124124
case BalancesMethod:
125-
bz, err = p.Balances(ctx, contract, method, args)
125+
bz, err = p.Balances(ctx, method, args)
126126
case TotalSupplyMethod:
127-
bz, err = p.TotalSupply(ctx, contract, method, args)
127+
bz, err = p.TotalSupply(ctx, method, args)
128128
case SupplyOfMethod:
129-
bz, err = p.SupplyOf(ctx, contract, method, args)
129+
bz, err = p.SupplyOf(ctx, method, args)
130130
default:
131131
return nil, fmt.Errorf(cmn.ErrUnknownMethod, method.Name)
132132
}

precompiles/bank/query.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"math/big"
66

77
"github.com/ethereum/go-ethereum/accounts/abi"
8-
"github.com/ethereum/go-ethereum/core/vm"
98

109
sdk "github.com/cosmos/cosmos-sdk/types"
1110
)
@@ -29,7 +28,6 @@ const (
2928
// balanceOf call for each token returned.
3029
func (p Precompile) Balances(
3130
ctx sdk.Context,
32-
_ *vm.Contract,
3331
method *abi.Method,
3432
args []interface{},
3533
) ([]byte, error) {
@@ -73,7 +71,6 @@ func (p Precompile) Balances(
7371
// call for each token returned.
7472
func (p Precompile) TotalSupply(
7573
ctx sdk.Context,
76-
_ *vm.Contract,
7774
method *abi.Method,
7875
_ []interface{},
7976
) ([]byte, error) {
@@ -112,7 +109,6 @@ func (p Precompile) TotalSupply(
112109
// stored in the x/bank.
113110
func (p Precompile) SupplyOf(
114111
ctx sdk.Context,
115-
_ *vm.Contract,
116112
method *abi.Method,
117113
args []interface{},
118114
) ([]byte, error) {

precompiles/common/precompile.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
//
2222
// It's usually implemented by the precompile itself.
2323
type NativeExecutor interface {
24-
Execute(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract, readOnly bool) ([]byte, error)
24+
Execute(ctx sdk.Context, stateDB vm.StateDB, contract *vm.Contract, readOnly bool) ([]byte, error)
2525
}
2626

2727
// Precompile is the base struct for precompiles that requires to access cosmos native storage.
@@ -104,7 +104,7 @@ func (p Precompile) run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz [
104104
p.BalanceHandler.BeforeBalanceChange(ctx)
105105
}
106106

107-
bz, err = p.Executor.Execute(ctx, evm, contract, readOnly)
107+
bz, err = p.Executor.Execute(ctx, stateDB, contract, readOnly)
108108
if err != nil {
109109
return bz, err
110110
}

precompiles/distribution/distribution.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,12 @@ func (p Precompile) RequiredGas(input []byte) uint64 {
9999
return p.Precompile.RequiredGas(input, p.IsTransaction(method))
100100
}
101101

102-
func (p Precompile) Execute(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract, readOnly bool) ([]byte, error) {
102+
func (p Precompile) Execute(ctx sdk.Context, stateDB vm.StateDB, contract *vm.Contract, readOnly bool) ([]byte, error) {
103103
method, args, err := cmn.SetupABI(p.ABI, contract, readOnly, p.IsTransaction)
104104
if err != nil {
105105
return nil, err
106106
}
107107

108-
stateDB := evm.StateDB
109108
var bz []byte
110109

111110
switch method.Name {

precompiles/erc20/erc20.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func (p Precompile) RequiredGas(input []byte) uint64 {
138138
}
139139
}
140140

141-
func (p Precompile) Execute(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract, readOnly bool) ([]byte, error) {
141+
func (p Precompile) Execute(ctx sdk.Context, stateDB vm.StateDB, contract *vm.Contract, readOnly bool) ([]byte, error) {
142142
// ERC20 precompiles cannot receive funds because they are not managed by an
143143
// EOA and will not be possible to recover funds sent to an instance of
144144
// them.This check is a safety measure because currently funds cannot be
@@ -152,7 +152,7 @@ func (p Precompile) Execute(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract,
152152
return nil, err
153153
}
154154

155-
return p.HandleMethod(ctx, contract, evm.StateDB, method, args)
155+
return p.HandleMethod(ctx, contract, stateDB, method, args)
156156
}
157157

158158
// IsTransaction checks if the given method name corresponds to a transaction or query.

precompiles/gov/gov.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,12 @@ func (p Precompile) RequiredGas(input []byte) uint64 {
9494
return p.Precompile.RequiredGas(input, p.IsTransaction(method))
9595
}
9696

97-
func (p Precompile) Execute(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract, readOnly bool) ([]byte, error) {
97+
func (p Precompile) Execute(ctx sdk.Context, stateDB vm.StateDB, contract *vm.Contract, readOnly bool) ([]byte, error) {
9898
method, args, err := cmn.SetupABI(p.ABI, contract, readOnly, p.IsTransaction)
9999
if err != nil {
100100
return nil, err
101101
}
102102

103-
stateDB := evm.StateDB
104103
var bz []byte
105104

106105
switch method.Name {

precompiles/ics20/ics20.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,12 @@ func (p Precompile) RequiredGas(input []byte) uint64 {
9393
return p.Precompile.RequiredGas(input, p.IsTransaction(method))
9494
}
9595

96-
func (p Precompile) Execute(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract, readOnly bool) ([]byte, error) {
96+
func (p Precompile) Execute(ctx sdk.Context, stateDB vm.StateDB, contract *vm.Contract, readOnly bool) ([]byte, error) {
9797
method, args, err := cmn.SetupABI(p.ABI, contract, readOnly, p.IsTransaction)
9898
if err != nil {
9999
return nil, err
100100
}
101101

102-
stateDB := evm.StateDB
103102
var bz []byte
104103

105104
switch method.Name {

precompiles/slashing/slashing.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,12 @@ func (p Precompile) RequiredGas(input []byte) uint64 {
9494
return p.Precompile.RequiredGas(input, p.IsTransaction(method))
9595
}
9696

97-
func (p Precompile) Execute(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract, readOnly bool) ([]byte, error) {
97+
func (p Precompile) Execute(ctx sdk.Context, stateDB vm.StateDB, contract *vm.Contract, readOnly bool) ([]byte, error) {
9898
method, args, err := cmn.SetupABI(p.ABI, contract, readOnly, p.IsTransaction)
9999
if err != nil {
100100
return nil, err
101101
}
102102

103-
stateDB := evm.StateDB
104103
var bz []byte
105104

106105
switch method.Name {

precompiles/staking/staking.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,12 @@ func (p Precompile) RequiredGas(input []byte) uint64 {
9595
return p.Precompile.RequiredGas(input, p.IsTransaction(method))
9696
}
9797

98-
func (p Precompile) Execute(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract, readOnly bool) ([]byte, error) {
98+
func (p Precompile) Execute(ctx sdk.Context, stateDB vm.StateDB, contract *vm.Contract, readOnly bool) ([]byte, error) {
9999
method, args, err := cmn.SetupABI(p.ABI, contract, readOnly, p.IsTransaction)
100100
if err != nil {
101101
return nil, err
102102
}
103103

104-
stateDB := evm.StateDB
105104
var bz []byte
106105

107106
switch method.Name {

precompiles/werc20/werc20.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,12 @@ func (p Precompile) RequiredGas(input []byte) uint64 {
9999
}
100100
}
101101

102-
func (p Precompile) Execute(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract, readOnly bool) ([]byte, error) {
102+
func (p Precompile) Execute(ctx sdk.Context, stateDB vm.StateDB, contract *vm.Contract, readOnly bool) ([]byte, error) {
103103
method, args, err := cmn.SetupABI(p.ABI, contract, readOnly, p.IsTransaction)
104104
if err != nil {
105105
return nil, err
106106
}
107107

108-
stateDB := evm.StateDB
109108
var bz []byte
110109

111110
switch {

0 commit comments

Comments
 (0)