Skip to content

Commit 5c3043e

Browse files
committed
add boilerplates
1 parent d594fff commit 5c3043e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

precompiles/bank2/bank.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (p Precompile) Decimals(ctx sdk.Context, input []byte) ([]byte, error) {
131131
return nil, vm.ErrExecutionReverted
132132
}
133133

134-
return []byte{uint8(exponent)}, nil //nolint:gosec // G115: range is checked above
134+
return []byte{uint8(exponent)}, nil
135135
}
136136

137137
// TotalSupply
@@ -201,6 +201,18 @@ func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readonly bool) ([]by
201201
return nil, vm.ErrExecutionReverted
202202
}
203203

204+
// take a snapshot of the current state before any changes
205+
// to be able to revert the changes
206+
snapshot := stateDB.MultiStoreSnapshot()
207+
events := ctx.EventManager().Events()
208+
209+
// add precompileCall entry on the stateDB journal
210+
// this allows to revert the changes within an evm tx
211+
err = stateDB.AddPrecompileFn(p.Address(), snapshot, events)
212+
if err != nil {
213+
return nil, vm.ErrExecutionReverted
214+
}
215+
204216
// 1 byte method selector
205217
if len(contract.Input) == 0 {
206218
return nil, vm.ErrExecutionReverted

0 commit comments

Comments
 (0)