-
Notifications
You must be signed in to change notification settings - Fork 1
/
aspect_state_api.go
38 lines (35 loc) · 1.08 KB
/
aspect_state_api.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package api
import (
"github.com/artela-network/aspect-core/types"
types2 "github.com/artela-network/aspect-runtime/types"
)
func (r *Registry) aspectStateAPIs() map[string]*types2.HostFuncWithGasRule {
return map[string]*types2.HostFuncWithGasRule{
"get": {
Func: func(key string) ([]byte, error) {
hook, err := types.GetAspectStateHostHook(r.runnerContext.Ctx)
if err != nil {
panic("failed to init aspect runtime context host api: " + err.Error())
}
if hook == nil {
panic("aspect runtime context host api not found")
}
return wrapNilByte(hook.Get(r.runnerContext, key)), nil
},
GasRule: types2.NewDynamicGasRule(0, 2500),
},
"set": {
Func: func(key string, val []byte) error {
hook, err := types.GetAspectStateHostHook(r.runnerContext.Ctx)
if err != nil {
panic("failed to init aspect runtime context host api: " + err.Error())
}
if hook == nil {
panic("aspect runtime context host api not found")
}
return hook.Set(r.runnerContext, key, val)
},
GasRule: types2.NewDynamicGasRule(0, 62500),
},
}
}