Skip to content

Commit f37a90e

Browse files
committed
(feat) Updated proto definitions from the latest chain master branch
1 parent 98020f0 commit f37a90e

34 files changed

+3099
-3236
lines changed

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ clone-injective-indexer:
44
git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.16.69 --depth 1 --single-branch
55

66
clone-injective-core:
7-
git clone https://github.com/InjectiveLabs/injective-core.git -b CP-329/open-interest-cap --depth 1 --single-branch
7+
git clone https://github.com/InjectiveLabs/injective-core.git -b master --depth 1 --single-branch
88

99
copy-exchange-client: clone-injective-indexer
1010
rm -rf exchange/*
@@ -51,6 +51,12 @@ copy-chain-types: clone-injective-core
5151
mkdir -p chain/auction/types && \
5252
cp injective-core/injective-chain/modules/auction/types/*.pb.go chain/auction/types && \
5353
cp injective-core/injective-chain/modules/auction/types/codec.go chain/auction/types
54+
mkdir -p chain/downtime-detector/types && \
55+
cp injective-core/injective-chain/modules/downtime-detector/types/*.pb.go chain/downtime-detector/types && \
56+
cp injective-core/injective-chain/modules/downtime-detector/types/codec.go chain/downtime-detector/types && \
57+
cp injective-core/injective-chain/modules/downtime-detector/types/constants.go chain/downtime-detector/types && \
58+
cp injective-core/injective-chain/modules/downtime-detector/types/genesis.go chain/downtime-detector/types && \
59+
cp injective-core/injective-chain/modules/downtime-detector/types/keys.go chain/downtime-detector/types
5460
mkdir -p chain/erc20/types && \
5561
cp injective-core/injective-chain/modules/erc20/types/*.pb.go chain/erc20/types && \
5662
cp injective-core/injective-chain/modules/erc20/types/codec.go chain/erc20/types
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package types
2+
3+
import (
4+
"github.com/cosmos/cosmos-sdk/codec"
5+
"github.com/cosmos/cosmos-sdk/codec/types"
6+
sdk "github.com/cosmos/cosmos-sdk/types"
7+
authzcdc "github.com/cosmos/cosmos-sdk/x/authz/codec"
8+
)
9+
10+
func RegisterLegacyAminoCodec(*codec.LegacyAmino) {}
11+
12+
func RegisterInterfaces(types.InterfaceRegistry) {}
13+
14+
var (
15+
ModuleCdc = codec.NewLegacyAmino()
16+
)
17+
18+
func init() {
19+
RegisterLegacyAminoCodec(ModuleCdc)
20+
// Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
21+
// used to properly serialize MsgGrant and MsgExec instances
22+
sdk.RegisterLegacyAminoCodec(ModuleCdc)
23+
RegisterLegacyAminoCodec(authzcdc.Amino)
24+
25+
ModuleCdc.Seal()
26+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package types
2+
3+
import (
4+
"fmt"
5+
"strings"
6+
"time"
7+
8+
"github.com/tidwall/btree"
9+
)
10+
11+
const (
12+
// we don't use a `-` as RouterKey must be alphanumeric
13+
ModuleName = "downtimedetector"
14+
StoreKey = ModuleName
15+
RouterKey = ModuleName
16+
17+
QuerierRoute = ModuleName
18+
)
19+
20+
var (
21+
DowntimeToDuration = btree.NewMap[Downtime, time.Duration](16)
22+
DefaultLastDowntime = time.Unix(0, 0)
23+
)
24+
25+
// init initializes the DowntimeToDuration map with mappings
26+
// from the Duration enum values to their corresponding
27+
// time.Duration values.
28+
func init() {
29+
DowntimeToDuration.Set(Downtime_DURATION_30S, 30*time.Second)
30+
DowntimeToDuration.Set(Downtime_DURATION_1M, time.Minute)
31+
DowntimeToDuration.Set(Downtime_DURATION_2M, 2*time.Minute)
32+
DowntimeToDuration.Set(Downtime_DURATION_3M, 3*time.Minute)
33+
DowntimeToDuration.Set(Downtime_DURATION_4M, 4*time.Minute)
34+
DowntimeToDuration.Set(Downtime_DURATION_5M, 5*time.Minute)
35+
DowntimeToDuration.Set(Downtime_DURATION_10M, 10*time.Minute)
36+
DowntimeToDuration.Set(Downtime_DURATION_20M, 20*time.Minute)
37+
DowntimeToDuration.Set(Downtime_DURATION_30M, 30*time.Minute)
38+
DowntimeToDuration.Set(Downtime_DURATION_40M, 40*time.Minute)
39+
DowntimeToDuration.Set(Downtime_DURATION_50M, 50*time.Minute)
40+
DowntimeToDuration.Set(Downtime_DURATION_1H, time.Hour)
41+
DowntimeToDuration.Set(Downtime_DURATION_1_5H, time.Hour+30*time.Minute)
42+
DowntimeToDuration.Set(Downtime_DURATION_2H, 2*time.Hour)
43+
DowntimeToDuration.Set(Downtime_DURATION_2_5H, 2*time.Hour+30*time.Minute)
44+
DowntimeToDuration.Set(Downtime_DURATION_3H, 3*time.Hour)
45+
DowntimeToDuration.Set(Downtime_DURATION_4H, 4*time.Hour)
46+
DowntimeToDuration.Set(Downtime_DURATION_5H, 5*time.Hour)
47+
DowntimeToDuration.Set(Downtime_DURATION_6H, 6*time.Hour)
48+
DowntimeToDuration.Set(Downtime_DURATION_9H, 9*time.Hour)
49+
DowntimeToDuration.Set(Downtime_DURATION_12H, 12*time.Hour)
50+
DowntimeToDuration.Set(Downtime_DURATION_18H, 18*time.Hour)
51+
DowntimeToDuration.Set(Downtime_DURATION_24H, 24*time.Hour)
52+
DowntimeToDuration.Set(Downtime_DURATION_36H, 36*time.Hour)
53+
DowntimeToDuration.Set(Downtime_DURATION_48H, 48*time.Hour)
54+
}
55+
56+
func DowntimeStrings() []string {
57+
arr := []string{}
58+
DowntimeToDuration.Ascend(Downtime(0), func(_ Downtime, v time.Duration) bool {
59+
s := strings.Replace(v.String(), "m0s", "m", 1)
60+
s = strings.Replace(s, "h0m", "h", 1)
61+
arr = append(arr, s)
62+
return true
63+
})
64+
return arr
65+
}
66+
67+
func DowntimeByDuration(duration time.Duration) (Downtime, error) {
68+
var result Downtime
69+
found := false
70+
DowntimeToDuration.Ascend(Downtime(0), func(k Downtime, v time.Duration) bool {
71+
if v == duration {
72+
result = k
73+
found = true
74+
return false
75+
}
76+
return true
77+
})
78+
if found {
79+
return result, nil
80+
}
81+
downtimeOptions := strings.Join(DowntimeStrings(), ", ")
82+
return result, fmt.Errorf("downtime of %s does not exist. Chain-provided downtimes [%s]", duration.String(), downtimeOptions)
83+
}

chain/downtime-detector/types/downtime_duration.pb.go

Lines changed: 149 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package types
2+
3+
import "time"
4+
5+
func DefaultGenesis() *GenesisState {
6+
genDowntimes := []GenesisDowntimeEntry{}
7+
for _, downtime := range DowntimeToDuration.Keys() {
8+
genDowntimes = append(genDowntimes, GenesisDowntimeEntry{
9+
Duration: downtime,
10+
LastDowntime: DefaultLastDowntime,
11+
})
12+
}
13+
return &GenesisState{
14+
Downtimes: genDowntimes,
15+
LastBlockTime: time.Unix(0, 0),
16+
}
17+
}
18+
19+
func (*GenesisState) Validate() error {
20+
return nil
21+
}
22+
23+
func NewGenesisDowntimeEntry(dur Downtime, tm time.Time) GenesisDowntimeEntry {
24+
return GenesisDowntimeEntry{Duration: dur, LastDowntime: tm}
25+
}

0 commit comments

Comments
 (0)