refactor: optimize oracle genesis proto
This commit is contained in:
1 parent
92ff87cc2c
commit
d06dfb5a93
25 files changed
+421
-441
No files matched your search
@@ -1,8 +1,6 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
@@ -46,16 +44,9 @@ func MsgUpdateParams() *cobra.Command {
|
||||
|
||||
senderAddress := cliCtx.GetFromAddress()
|
||||
|
||||
someValue, err := strconv.ParseBool(args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
msg := &types.MsgUpdateParams{
|
||||
Authority: senderAddress.String(),
|
||||
Params: types.Params{
|
||||
SomeValue: someValue,
|
||||
},
|
||||
Params: types.Params{},
|
||||
}
|
||||
|
||||
if err := msg.Validate(); err != nil {
|
||||
|
||||
@@ -10,22 +10,13 @@ import (
|
||||
func TestORM(t *testing.T) {
|
||||
f := SetupTest(t)
|
||||
|
||||
dt := f.k.OrmDB.ExampleDataTable()
|
||||
acc := []byte("test_acc")
|
||||
dt := f.k.OrmDB.BalanceTable()
|
||||
amt := uint64(7)
|
||||
|
||||
err := dt.Insert(f.ctx, &apiv1.ExampleData{
|
||||
Account: acc,
|
||||
Amount: amt,
|
||||
err := dt.Insert(f.ctx, &apiv1.Balance{
|
||||
Amount: amt,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
d, err := dt.Has(f.ctx, []byte("test_acc"))
|
||||
require.NoError(t, err)
|
||||
require.True(t, d)
|
||||
|
||||
res, err := dt.Get(f.ctx, []byte("test_acc"))
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, res)
|
||||
require.EqualValues(t, amt, res.Amount)
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"github.com/onsonr/sonr/x/did/types/orm/assettype"
|
||||
)
|
||||
|
||||
// this line is used by starport scaffolding # genesis/types/import
|
||||
|
||||
// DefaultIndex is the default global index
|
||||
@@ -20,3 +24,33 @@ func (gs GenesisState) Validate() error {
|
||||
|
||||
return gs.Params.Validate()
|
||||
}
|
||||
|
||||
// DefaultAssets returns the default asset infos: BTC, ETH, SNR, and USDC
|
||||
func DefaultAssets() []*AssetInfo {
|
||||
return []*AssetInfo{
|
||||
{
|
||||
Name: "Bitcoin",
|
||||
Symbol: "BTC",
|
||||
Hrp: "bc",
|
||||
Index: 0,
|
||||
AssetType: assettype.Native.String(),
|
||||
IconUrl: "https://cdn.sonr.land/BTC.svg",
|
||||
},
|
||||
{
|
||||
Name: "Ethereum",
|
||||
Symbol: "ETH",
|
||||
Hrp: "eth",
|
||||
Index: 64,
|
||||
AssetType: assettype.Native.String(),
|
||||
IconUrl: "https://cdn.sonr.land/ETH.svg",
|
||||
},
|
||||
{
|
||||
Name: "Sonr",
|
||||
Symbol: "SNR",
|
||||
Hrp: "idx",
|
||||
Index: 703,
|
||||
AssetType: assettype.Native.String(),
|
||||
IconUrl: "https://cdn.sonr.land/SNR.svg",
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -118,8 +118,9 @@ type Assets struct {
|
||||
Assets []*AssetInfo `protobuf:"bytes,1,rep,name=assets,proto3" json:"assets,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Assets) Reset() { *m = Assets{} }
|
||||
func (*Assets) ProtoMessage() {}
|
||||
func (m *Assets) Reset() { *m = Assets{} }
|
||||
func (m *Assets) String() string { return proto.CompactTextString(m) }
|
||||
func (*Assets) ProtoMessage() {}
|
||||
func (*Assets) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_14b982a0a6345d1d, []int{2}
|
||||
}
|
||||
@@ -258,30 +259,31 @@ func init() {
|
||||
func init() { proto.RegisterFile("oracle/v1/genesis.proto", fileDescriptor_14b982a0a6345d1d) }
|
||||
|
||||
var fileDescriptor_14b982a0a6345d1d = []byte{
|
||||
// 366 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 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x01, 0x00, 0x00, 0xff, 0xff, 0xdf, 0xd4, 0x42, 0x19, 0x18, 0x02, 0x00, 0x00,
|
||||
// 380 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xc1, 0x4e, 0xea, 0x40,
|
||||
0x18, 0x85, 0x3b, 0xb7, 0xd0, 0x7b, 0x3b, 0x5c, 0x13, 0x99, 0x10, 0xac, 0x4d, 0x2c, 0x84, 0xc4,
|
||||
0x04, 0x8d, 0xe9, 0x04, 0xdc, 0xb1, 0x21, 0xb2, 0x31, 0x6e, 0xd4, 0x54, 0xdd, 0xb8, 0x21, 0x05,
|
||||
0x87, 0xd2, 0xa4, 0x9d, 0x69, 0x3a, 0x85, 0xc0, 0x2b, 0xb8, 0x72, 0xe9, 0x92, 0x47, 0x70, 0xe3,
|
||||
0x3b, 0xb0, 0x64, 0xe9, 0xca, 0x18, 0x58, 0xe8, 0x63, 0x98, 0xce, 0x54, 0x42, 0x88, 0x9b, 0x3f,
|
||||
0xff, 0x7f, 0xce, 0xe9, 0x97, 0xd3, 0x0c, 0xdc, 0x63, 0xb1, 0xdb, 0x0f, 0x08, 0x1e, 0x37, 0xb0,
|
||||
0x47, 0x28, 0xe1, 0x3e, 0xb7, 0xa3, 0x98, 0x25, 0x0c, 0xe9, 0xd2, 0xb0, 0xc7, 0x0d, 0xb3, 0xe8,
|
||||
0x86, 0x3e, 0x65, 0x58, 0x4c, 0xe9, 0x9a, 0x25, 0x8f, 0x79, 0x4c, 0xac, 0x38, 0xdd, 0xa4, 0x5a,
|
||||
0x6b, 0xc3, 0xff, 0xe7, 0x12, 0x72, 0x93, 0xb8, 0x09, 0x41, 0x18, 0x6a, 0x91, 0x1b, 0xbb, 0x21,
|
||||
0x37, 0x40, 0x15, 0xd4, 0x0b, 0xcd, 0xa2, 0xbd, 0x86, 0xda, 0xd7, 0xc2, 0xe8, 0xe4, 0xe6,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0xca, 0x62, 0x65, 0x29,
|
||||
0x6f, 0x2b, 0x4b, 0xb9, 0x3f, 0xf4, 0xfc, 0x64, 0x38, 0xea, 0xd9, 0x7d, 0x16, 0x62, 0x46, 0x39,
|
||||
0xa3, 0x31, 0x16, 0x63, 0x82, 0x33, 0x4a, 0xda, 0x8d, 0xf7, 0x34, 0xf1, 0xc2, 0xa7, 0xdf, 0x01,
|
||||
0x00, 0x00, 0xff, 0xff, 0xbd, 0x2b, 0xce, 0x32, 0x30, 0x02, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (this *Params) Equal(that interface{}) bool {
|
||||
@@ -337,6 +339,45 @@ func (this *Assets) Equal(that interface{}) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (this *AssetInfo) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*AssetInfo)
|
||||
if !ok {
|
||||
that2, ok := that.(AssetInfo)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if this.Index != that1.Index {
|
||||
return false
|
||||
}
|
||||
if this.Hrp != that1.Hrp {
|
||||
return false
|
||||
}
|
||||
if this.Symbol != that1.Symbol {
|
||||
return false
|
||||
}
|
||||
if this.AssetType != that1.AssetType {
|
||||
return false
|
||||
}
|
||||
if this.Name != that1.Name {
|
||||
return false
|
||||
}
|
||||
if this.IconUrl != that1.IconUrl {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
|
||||
@@ -5,9 +5,7 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
var (
|
||||
_ sdk.Msg = &MsgUpdateParams{}
|
||||
)
|
||||
var _ sdk.Msg = &MsgUpdateParams{}
|
||||
|
||||
// NewMsgUpdateParams creates new instance of MsgUpdateParams
|
||||
func NewMsgUpdateParams(
|
||||
@@ -16,9 +14,7 @@ func NewMsgUpdateParams(
|
||||
) *MsgUpdateParams {
|
||||
return &MsgUpdateParams{
|
||||
Authority: sender.String(),
|
||||
Params: Params{
|
||||
SomeValue: someValue,
|
||||
},
|
||||
Params: Params{},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,7 @@ import (
|
||||
// DefaultParams returns default module parameters.
|
||||
func DefaultParams() Params {
|
||||
// TODO:
|
||||
return Params{
|
||||
SomeValue: true,
|
||||
}
|
||||
return Params{}
|
||||
}
|
||||
|
||||
// Stringer method for Params.
|
||||
|
||||
Reference in new issue
Block a user