From 3e174214ee866709afe9c86bbc846d57828f9736 Mon Sep 17 00:00:00 2001 From: Tony Stark Date: Thu, 21 Nov 2024 00:42:52 +0530 Subject: [PATCH] feat: add params to oracle genesis --- proto/sentinel/oracle/v1/genesis.proto | 4 +- x/oracle/keeper/genesis.go | 1 + x/oracle/types/v1/genesis.go | 6 ++- x/oracle/types/v1/genesis.pb.go | 74 +++++++++++++++++++++----- 4 files changed, 70 insertions(+), 15 deletions(-) diff --git a/proto/sentinel/oracle/v1/genesis.proto b/proto/sentinel/oracle/v1/genesis.proto index c5a162ab..bb4296e9 100644 --- a/proto/sentinel/oracle/v1/genesis.proto +++ b/proto/sentinel/oracle/v1/genesis.proto @@ -3,11 +3,13 @@ package sentinel.oracle.v1; import "gogoproto/gogo.proto"; import "sentinel/oracle/v1/asset.proto"; +import "sentinel/oracle/v1/params.proto"; option go_package = "github.com/sentinel-official/hub/v12/x/oracle/types/v1"; option (gogoproto.equal_all) = false; option (gogoproto.goproto_getters_all) = false; message GenesisState { - repeated sentinel.oracle.v1.Asset assets = 1; + repeated sentinel.oracle.v1.Asset assets = 1 [(gogoproto.nullable) = false]; + Params params = 2 [(gogoproto.nullable) = false]; } diff --git a/x/oracle/keeper/genesis.go b/x/oracle/keeper/genesis.go index 8ee5c558..811de50c 100644 --- a/x/oracle/keeper/genesis.go +++ b/x/oracle/keeper/genesis.go @@ -7,6 +7,7 @@ import ( ) func (k *Keeper) InitGenesis(ctx sdk.Context, state *v1.GenesisState) { + k.SetParams(ctx, state.Params) } func (k *Keeper) ExportGenesis(ctx sdk.Context) *v1.GenesisState { diff --git a/x/oracle/types/v1/genesis.go b/x/oracle/types/v1/genesis.go index ed4cc7af..5790f3c1 100644 --- a/x/oracle/types/v1/genesis.go +++ b/x/oracle/types/v1/genesis.go @@ -1,7 +1,11 @@ package v1 func NewGenesisState() *GenesisState { - return &GenesisState{} + return &GenesisState{ + Params: Params{ + BlockInterval: 50, + }, + } } func DefaultGenesisState() *GenesisState { diff --git a/x/oracle/types/v1/genesis.pb.go b/x/oracle/types/v1/genesis.pb.go index 7fc56686..aabefedb 100644 --- a/x/oracle/types/v1/genesis.pb.go +++ b/x/oracle/types/v1/genesis.pb.go @@ -24,7 +24,8 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { - Assets []*Asset `protobuf:"bytes,1,rep,name=assets,proto3" json:"assets,omitempty"` + Assets []Asset `protobuf:"bytes,1,rep,name=assets,proto3" json:"assets"` + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -67,21 +68,23 @@ func init() { func init() { proto.RegisterFile("sentinel/oracle/v1/genesis.proto", fileDescriptor_e2f42d4788d814ce) } var fileDescriptor_e2f42d4788d814ce = []byte{ - // 215 bytes of a gzipped FileDescriptorProto + // 256 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x28, 0x4e, 0xcd, 0x2b, 0xc9, 0xcc, 0x4b, 0xcd, 0xd1, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x82, 0xa9, 0xd0, 0x83, 0xa8, 0xd0, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x4b, 0xeb, 0x83, - 0x58, 0x10, 0x95, 0x52, 0x72, 0x58, 0xcc, 0x4a, 0x2c, 0x2e, 0x4e, 0x2d, 0x81, 0xc8, 0x2b, 0x39, - 0x72, 0xf1, 0xb8, 0x43, 0x8c, 0x0e, 0x2e, 0x49, 0x2c, 0x49, 0x15, 0x32, 0xe4, 0x62, 0x03, 0x4b, - 0x17, 0x4b, 0x30, 0x2a, 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2a, 0x17, 0xb2, 0xe0, 0x62, 0x83, 0x98, 0x2c, 0xc1, 0xa4, 0xc0, 0xa8, + 0xc1, 0x6d, 0x24, 0x85, 0x4d, 0x63, 0x00, 0x58, 0x05, 0x4c, 0x27, 0x44, 0xbd, 0x53, 0xc4, 0x89, + 0x87, 0x72, 0x0c, 0x2b, 0x1e, 0xc9, 0x31, 0x9c, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, + 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, + 0x43, 0x94, 0x59, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xcc, 0x54, + 0xdd, 0xfc, 0xb4, 0xb4, 0xcc, 0xe4, 0xcc, 0xc4, 0x1c, 0xfd, 0x8c, 0xd2, 0x24, 0xfd, 0x32, 0x43, + 0x23, 0xfd, 0x0a, 0x98, 0x27, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0xf5, 0xcb, 0x0c, 0x93, 0xd8, 0xc0, + 0x9e, 0x34, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x01, 0x81, 0x56, 0x23, 0x73, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -104,6 +107,16 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 if len(m.Assets) > 0 { for iNdEx := len(m.Assets) - 1; iNdEx >= 0; iNdEx-- { { @@ -144,6 +157,8 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) return n } @@ -211,11 +226,44 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Assets = append(m.Assets, &Asset{}) + m.Assets = append(m.Assets, Asset{}) if err := m.Assets[len(m.Assets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:])