refactor(schema)!: rename ObjectType -> StateObjectType (#21691)
Co-authored-by: cool-developer <51834436+cool-develope@users.noreply.github.com>
This commit is contained in:
co-authored by
cool-developer
parent
397ff0bd22
commit
ae40e809b9
@@ -29,7 +29,7 @@ func TestMiddleware(t *testing.T) {
|
||||
|
||||
tl.oneMod.SetValue("abc")
|
||||
|
||||
expectedBank := []schema.ObjectUpdate{
|
||||
expectedBank := []schema.StateObjectUpdate{
|
||||
{
|
||||
TypeName: "supply",
|
||||
Key: []interface{}{"foo"},
|
||||
@@ -56,7 +56,7 @@ func TestMiddleware(t *testing.T) {
|
||||
t.Fatalf("expected %v, got %v", expectedBank, tl.bankUpdates)
|
||||
}
|
||||
|
||||
expectedOne := []schema.ObjectUpdate{
|
||||
expectedOne := []schema.StateObjectUpdate{
|
||||
{TypeName: "item", Value: "abc"},
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ func TestMiddleware_filtered(t *testing.T) {
|
||||
t.Fatalf("expected no bank updates")
|
||||
}
|
||||
|
||||
expectedOne := []schema.ObjectUpdate{
|
||||
expectedOne := []schema.StateObjectUpdate{
|
||||
{TypeName: "item", Value: "abc"},
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ func TestSync(t *testing.T) {
|
||||
t.Fatal("unexpected error", err)
|
||||
}
|
||||
|
||||
expected := []schema.ObjectUpdate{
|
||||
expected := []schema.StateObjectUpdate{
|
||||
{
|
||||
TypeName: "balances",
|
||||
Key: []interface{}{"alice", "foo"},
|
||||
@@ -130,7 +130,7 @@ func TestSync(t *testing.T) {
|
||||
t.Fatalf("expected %v, got %v", expected, tl.bankUpdates)
|
||||
}
|
||||
|
||||
expectedOne := []schema.ObjectUpdate{
|
||||
expectedOne := []schema.StateObjectUpdate{
|
||||
{TypeName: "item", Value: "def"},
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ func TestSync_filtered(t *testing.T) {
|
||||
t.Fatalf("expected no bank updates")
|
||||
}
|
||||
|
||||
expectedOne := []schema.ObjectUpdate{
|
||||
expectedOne := []schema.StateObjectUpdate{
|
||||
{TypeName: "item", Value: "def"},
|
||||
}
|
||||
|
||||
@@ -168,8 +168,8 @@ func TestSync_filtered(t *testing.T) {
|
||||
|
||||
type testFixture struct {
|
||||
appdata.Listener
|
||||
bankUpdates []schema.ObjectUpdate
|
||||
oneValueUpdates []schema.ObjectUpdate
|
||||
bankUpdates []schema.StateObjectUpdate
|
||||
oneValueUpdates []schema.StateObjectUpdate
|
||||
resolver DecoderResolver
|
||||
multiStore *testMultiStore
|
||||
bankMod *exampleBankModule
|
||||
@@ -371,7 +371,7 @@ func (e exampleBankModule) subBalance(acct, denom string, amount uint64) error {
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
exampleBankSchema, err = schema.CompileModuleSchema(schema.ObjectType{
|
||||
exampleBankSchema, err = schema.CompileModuleSchema(schema.StateObjectType{
|
||||
Name: "balances",
|
||||
KeyFields: []schema.Field{
|
||||
{
|
||||
@@ -400,7 +400,7 @@ var exampleBankSchema schema.ModuleSchema
|
||||
func (e exampleBankModule) ModuleCodec() (schema.ModuleCodec, error) {
|
||||
return schema.ModuleCodec{
|
||||
Schema: exampleBankSchema,
|
||||
KVDecoder: func(update schema.KVPairUpdate) ([]schema.ObjectUpdate, error) {
|
||||
KVDecoder: func(update schema.KVPairUpdate) ([]schema.StateObjectUpdate, error) {
|
||||
key := string(update.Key)
|
||||
value, err := strconv.ParseUint(string(update.Value), 10, 64)
|
||||
if err != nil {
|
||||
@@ -408,14 +408,14 @@ func (e exampleBankModule) ModuleCodec() (schema.ModuleCodec, error) {
|
||||
}
|
||||
if strings.HasPrefix(key, "balance/") {
|
||||
parts := strings.Split(key, "/")
|
||||
return []schema.ObjectUpdate{{
|
||||
return []schema.StateObjectUpdate{{
|
||||
TypeName: "balances",
|
||||
Key: []interface{}{parts[1], parts[2]},
|
||||
Value: value,
|
||||
}}, nil
|
||||
} else if strings.HasPrefix(key, "supply/") {
|
||||
parts := strings.Split(key, "/")
|
||||
return []schema.ObjectUpdate{{
|
||||
return []schema.StateObjectUpdate{{
|
||||
TypeName: "supply",
|
||||
Key: []interface{}{parts[1]},
|
||||
Value: value,
|
||||
@@ -435,7 +435,7 @@ type oneValueModule struct {
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
oneValueModSchema, err = schema.CompileModuleSchema(schema.ObjectType{
|
||||
oneValueModSchema, err = schema.CompileModuleSchema(schema.StateObjectType{
|
||||
Name: "item",
|
||||
ValueFields: []schema.Field{
|
||||
{Name: "value", Kind: schema.StringKind},
|
||||
@@ -451,11 +451,11 @@ var oneValueModSchema schema.ModuleSchema
|
||||
func (i oneValueModule) ModuleCodec() (schema.ModuleCodec, error) {
|
||||
return schema.ModuleCodec{
|
||||
Schema: oneValueModSchema,
|
||||
KVDecoder: func(update schema.KVPairUpdate) ([]schema.ObjectUpdate, error) {
|
||||
KVDecoder: func(update schema.KVPairUpdate) ([]schema.StateObjectUpdate, error) {
|
||||
if string(update.Key) != "key" {
|
||||
return nil, fmt.Errorf("unexpected key: %v", update.Key)
|
||||
}
|
||||
return []schema.ObjectUpdate{
|
||||
return []schema.StateObjectUpdate{
|
||||
{TypeName: "item", Value: string(update.Value)},
|
||||
}, nil
|
||||
},
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
type modA struct{}
|
||||
|
||||
func (m modA) ModuleCodec() (schema.ModuleCodec, error) {
|
||||
modSchema, err := schema.CompileModuleSchema(schema.ObjectType{Name: "A", KeyFields: []schema.Field{{Name: "field1", Kind: schema.StringKind}}})
|
||||
modSchema, err := schema.CompileModuleSchema(schema.StateObjectType{Name: "A", KeyFields: []schema.Field{{Name: "field1", Kind: schema.StringKind}}})
|
||||
if err != nil {
|
||||
return schema.ModuleCodec{}, err
|
||||
}
|
||||
@@ -22,7 +22,7 @@ func (m modA) ModuleCodec() (schema.ModuleCodec, error) {
|
||||
type modB struct{}
|
||||
|
||||
func (m modB) ModuleCodec() (schema.ModuleCodec, error) {
|
||||
modSchema, err := schema.CompileModuleSchema(schema.ObjectType{Name: "B", KeyFields: []schema.Field{{Name: "field2", Kind: schema.StringKind}}})
|
||||
modSchema, err := schema.CompileModuleSchema(schema.StateObjectType{Name: "B", KeyFields: []schema.Field{{Name: "field2", Kind: schema.StringKind}}})
|
||||
if err != nil {
|
||||
return schema.ModuleCodec{}, err
|
||||
}
|
||||
@@ -45,7 +45,7 @@ func TestModuleSetDecoderResolver_IterateAll(t *testing.T) {
|
||||
objectTypes := map[string]bool{}
|
||||
err := testResolver.IterateAll(func(moduleName string, cdc schema.ModuleCodec) error {
|
||||
cdc.Schema.AllTypes(func(t schema.Type) bool {
|
||||
objTyp, ok := t.(schema.ObjectType)
|
||||
objTyp, ok := t.(schema.StateObjectType)
|
||||
if ok {
|
||||
objectTypes[objTyp.Name] = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user