-
Notifications
You must be signed in to change notification settings - Fork 1
/
gas.go
24 lines (21 loc) · 889 Bytes
/
gas.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package depdecorators
import (
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkacltypes "github.com/cosmos/cosmos-sdk/types/accesscontrol"
)
type GasMeterSetterDecorator struct {
}
func (d GasMeterSetterDecorator) AnteDeps(txDeps []sdkacltypes.AccessOperation, tx sdk.Tx, next sdk.AnteDepGenerator) (newTxDeps []sdkacltypes.AccessOperation, err error) {
for _, msg := range tx.GetMsgs() {
if _, ok := msg.(*wasmtypes.MsgExecuteContract); ok {
// if we have a wasm execute message, we need to declare the dependency to read accesscontrol for giving gas discount
txDeps = append(txDeps, sdkacltypes.AccessOperation{
AccessType: sdkacltypes.AccessType_READ,
ResourceType: sdkacltypes.ResourceType_KV_ACCESSCONTROL_WASM_DEPENDENCY_MAPPING,
IdentifierTemplate: "*",
})
}
}
return next(txDeps, tx)
}