-
Notifications
You must be signed in to change notification settings - Fork 10
/
keeper.go
143 lines (113 loc) · 4.45 KB
/
keeper.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
package stakingadapter
import (
"context"
"errors"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/distribution/types"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
abci "github.com/tendermint/tendermint/abci/types"
)
// StakingAdapter connect to POE contract
var (
_ wasmtypes.StakingKeeper = &StakingAdapter{}
_ wasmtypes.DistributionKeeper = &StakingAdapter{}
_ wasmkeeper.ValidatorSetSource = &StakingAdapter{}
_ evidencetypes.StakingKeeper = &StakingAdapter{}
_ minttypes.StakingKeeper = &StakingAdapter{}
_ govtypes.StakingKeeper = &StakingAdapter{}
)
var ErrNotImplemented = errors.New("not implemented")
type poeKeeper interface{}
type StakingAdapter struct {
k poeKeeper
contractKeeper wasmtypes.ContractOpsKeeper
}
func NewStakingAdapter(k poeKeeper, contractKeeper wasmtypes.ContractOpsKeeper) StakingAdapter {
return StakingAdapter{k: k, contractKeeper: contractKeeper}
}
func (s StakingAdapter) BondDenom(ctx sdk.Context) (res string) {
log(ctx, "BondDenom")
return "utgd"
}
func (s StakingAdapter) GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool) {
log(ctx, "GetValidator")
return validator, false
}
func (s StakingAdapter) GetBondedValidatorsByPower(ctx sdk.Context) []stakingtypes.Validator {
log(ctx, "GetBondedValidatorsByPower")
return nil
}
func (s StakingAdapter) GetAllDelegatorDelegations(ctx sdk.Context, delegator sdk.AccAddress) []stakingtypes.Delegation {
log(ctx, "GetAllDelegatorDelegations")
return nil
}
func (s StakingAdapter) GetDelegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (delegation stakingtypes.Delegation, found bool) {
log(ctx, "GetDelegation")
return
}
func (s StakingAdapter) HasReceivingRedelegation(ctx sdk.Context, delAddr sdk.AccAddress, valDstAddr sdk.ValAddress) bool {
// not supported
return false
}
func (s StakingAdapter) DelegationRewards(stdlibCtx context.Context, req *types.QueryDelegationRewardsRequest) (*types.QueryDelegationRewardsResponse, error) {
log(sdk.UnwrapSDKContext(stdlibCtx), "DelegationRewards")
return nil, nil
}
func (s StakingAdapter) ValidatorByConsAddr(ctx sdk.Context, address sdk.ConsAddress) stakingtypes.ValidatorI {
log(ctx, "ValidatorByConsAddr")
return nil
}
func (s StakingAdapter) ApplyAndReturnValidatorSetUpdates(ctx sdk.Context) (updates []abci.ValidatorUpdate, err error) {
log(ctx, "ApplyAndReturnValidatorSetUpdates")
return nil, nil
}
func (s StakingAdapter) IterateValidators(ctx sdk.Context, f func(index int64, validator stakingtypes.ValidatorI) (stop bool)) {
log(ctx, "IterateValidators")
}
func (s StakingAdapter) Validator(ctx sdk.Context, address sdk.ValAddress) stakingtypes.ValidatorI {
log(ctx, "Validator")
return nil
}
func (s StakingAdapter) Slash(ctx sdk.Context, address sdk.ConsAddress, i int64, i2 int64, dec sdk.Dec) {
log(ctx, "Slash")
}
func (s StakingAdapter) Jail(ctx sdk.Context, address sdk.ConsAddress) {
log(ctx, "Jail")
}
func (s StakingAdapter) Unjail(ctx sdk.Context, address sdk.ConsAddress) {
log(ctx, "Unjail")
}
func (s StakingAdapter) Delegation(ctx sdk.Context, address sdk.AccAddress, address2 sdk.ValAddress) stakingtypes.DelegationI {
log(ctx, "Delegation")
return nil
}
func (s StakingAdapter) MaxValidators(ctx sdk.Context) uint32 {
log(ctx, "MaxValidators")
return 100
}
func (s StakingAdapter) StakingTokenSupply(ctx sdk.Context) sdk.Int {
log(ctx, "StakingTokenSupply")
return sdk.NewInt(1000000)
}
func (s StakingAdapter) BondedRatio(ctx sdk.Context) sdk.Dec {
log(ctx, "BondedRatio")
return sdk.ZeroDec()
}
func (s StakingAdapter) IterateBondedValidatorsByPower(ctx sdk.Context, f func(index int64, validator stakingtypes.ValidatorI) (stop bool)) {
log(ctx, "IterateBondedValidatorsByPower")
}
func (s StakingAdapter) TotalBondedTokens(ctx sdk.Context) sdk.Int {
log(ctx, "TotalBondedTokens")
return sdk.NewInt(0)
}
func (s StakingAdapter) IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress, fn func(index int64, delegation stakingtypes.DelegationI) (stop bool)) {
log(ctx, "IterateDelegations")
}
func log(ctx sdk.Context, msg string) {
ctx.Logger().Error("NOT IMPLEMENTED: ", "fn", msg)
}