-
Notifications
You must be signed in to change notification settings - Fork 73
/
aspect.go
51 lines (42 loc) · 1.53 KB
/
aspect.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
39
40
41
42
43
44
45
46
47
48
49
50
51
package keeper
import (
"context"
"errors"
artvmtype "github.com/artela-network/artela/x/evm/artela/types"
"github.com/ethereum/go-ethereum/common"
)
func (k Keeper) GetAspectRuntimeContext() *artvmtype.AspectRuntimeContext {
return k.aspectRuntimeContext
}
func (k Keeper) JITSenderAspectByContext(ctx context.Context, userOpHash common.Hash) (common.Address, error) {
aspectCtx, ok := ctx.(*artvmtype.AspectRuntimeContext)
if !ok {
return common.Address{}, errors.New("JITSenderAspectByContext: unwrap AspectRuntimeContext failed")
}
return aspectCtx.JITManager().SenderAspect(userOpHash), nil
}
func (k Keeper) IsCommit(ctx context.Context) bool {
aspectCtx, ok := ctx.(*artvmtype.AspectRuntimeContext)
if !ok || aspectCtx.EthTxContext() == nil {
return false
}
return aspectCtx.EthTxContext().Commit()
}
func (k Keeper) GetAspectContext(ctx context.Context, address common.Address, key string) ([]byte, error) {
aspectCtx, ok := ctx.(*artvmtype.AspectRuntimeContext)
if !ok {
return nil, errors.New("GetAspectContext: unwrap AspectRuntimeContext failed")
}
return aspectCtx.AspectContext().Get(address, key), nil
}
func (k Keeper) SetAspectContext(ctx context.Context, address common.Address, key string, value []byte) error {
aspectCtx, ok := ctx.(*artvmtype.AspectRuntimeContext)
if !ok {
return errors.New("SetAspectContext: unwrap AspectRuntimeContext failed")
}
aspectCtx.AspectContext().Add(address, key, value)
return nil
}
func (k Keeper) GetBlockContext() *artvmtype.EthBlockContext {
return k.BlockContext
}