diff --git a/data/base/acc_address_data.go b/data/base/acc_address_data.go index b1ef5f5ee..70a049549 100644 --- a/data/base/acc_address_data.go +++ b/data/base/acc_address_data.go @@ -5,6 +5,7 @@ package base import ( "bytes" + "cosmossdk.io/math" "strings" sdkTypes "github.com/cosmos/cosmos-sdk/types" @@ -27,7 +28,7 @@ func (accAddressData *AccAddressData) ValidateBasic() error { func (accAddressData *AccAddressData) GetID() ids.DataID { return baseIDs.GenerateDataID(accAddressData) } -func (accAddressData *AccAddressData) GetBondWeight() sdkTypes.Int { +func (accAddressData *AccAddressData) GetBondWeight() math.Int { return dataConstants.AccAddressDataWeight } func (accAddressData *AccAddressData) Compare(listableData data.ListableData) int { diff --git a/data/base/any_data.go b/data/base/any_data.go index 6378d7b2e..47d5a2469 100644 --- a/data/base/any_data.go +++ b/data/base/any_data.go @@ -1,12 +1,12 @@ package base import ( + "cosmossdk.io/math" "fmt" "github.com/AssetMantle/schema/data" dataConstants "github.com/AssetMantle/schema/data/constants" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - sdkTypes "github.com/cosmos/cosmos-sdk/types" "strings" ) @@ -130,7 +130,7 @@ func (x *AnyData) GenerateHashID() ids.HashID { func (x *AnyData) ToAnyData() data.AnyData { return x } -func (x *AnyData) GetBondWeight() sdkTypes.Int { +func (x *AnyData) GetBondWeight() math.Int { return x.Impl.(dataGetter).get().GetBondWeight() } diff --git a/data/base/any_listable_data.go b/data/base/any_listable_data.go index bc73c41c2..6e962c17b 100644 --- a/data/base/any_listable_data.go +++ b/data/base/any_listable_data.go @@ -1,9 +1,9 @@ package base import ( + "cosmossdk.io/math" "github.com/AssetMantle/schema/data" "github.com/AssetMantle/schema/ids" - sdkTypes "github.com/cosmos/cosmos-sdk/types" ) type listableDataGetter interface { @@ -45,7 +45,7 @@ func (anyListableData *AnyListableData) Get() data.Data { func (anyListableData *AnyListableData) GetID() ids.DataID { return anyListableData.Impl.(listableDataGetter).get().GetID() } -func (anyListableData *AnyListableData) GetBondWeight() sdkTypes.Int { +func (anyListableData *AnyListableData) GetBondWeight() math.Int { return anyListableData.Impl.(listableDataGetter).get().GetBondWeight() } func (anyListableData *AnyListableData) ValidateBasic() error { diff --git a/data/base/boolean_data.go b/data/base/boolean_data.go index 958e7f7f5..702c0c574 100644 --- a/data/base/boolean_data.go +++ b/data/base/boolean_data.go @@ -4,11 +4,10 @@ package base import ( + "cosmossdk.io/math" "strconv" "strings" - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/schema/data" dataConstants "github.com/AssetMantle/schema/data/constants" "github.com/AssetMantle/schema/ids" @@ -23,7 +22,7 @@ func (booleanData *BooleanData) ValidateBasic() error { func (booleanData *BooleanData) GetID() ids.DataID { return baseIDs.GenerateDataID(booleanData) } -func (booleanData *BooleanData) GetBondWeight() sdkTypes.Int { +func (booleanData *BooleanData) GetBondWeight() math.Int { return dataConstants.BooleanDataWeight } func (booleanData *BooleanData) Compare(listableData data.ListableData) int { diff --git a/data/base/dec_data.go b/data/base/dec_data.go index 5651f44ee..0ffd3b83f 100644 --- a/data/base/dec_data.go +++ b/data/base/dec_data.go @@ -4,6 +4,7 @@ package base import ( + "cosmossdk.io/math" "fmt" "github.com/AssetMantle/schema/data" dataConstants "github.com/AssetMantle/schema/data/constants" @@ -27,7 +28,7 @@ func (decData *DecData) ValidateBasic() error { func (decData *DecData) GetID() ids.DataID { return baseIDs.GenerateDataID(decData) } -func (decData *DecData) GetBondWeight() sdkTypes.Int { +func (decData *DecData) GetBondWeight() math.Int { return dataConstants.DecDataWeight } func (decData *DecData) Compare(listableData data.ListableData) int { diff --git a/data/base/height_data.go b/data/base/height_data.go index a540a94ba..0f6fb749c 100644 --- a/data/base/height_data.go +++ b/data/base/height_data.go @@ -4,12 +4,11 @@ package base import ( + "cosmossdk.io/math" "encoding/binary" "strconv" "strings" - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/schema/data" dataConstants "github.com/AssetMantle/schema/data/constants" "github.com/AssetMantle/schema/ids" @@ -26,7 +25,7 @@ func (heightData *HeightData) ValidateBasic() error { func (heightData *HeightData) GetID() ids.DataID { return baseIDs.GenerateDataID(heightData) } -func (heightData *HeightData) GetBondWeight() sdkTypes.Int { +func (heightData *HeightData) GetBondWeight() math.Int { return dataConstants.HeightDataWeight } func (heightData *HeightData) AsString() string { diff --git a/data/base/id_data.go b/data/base/id_data.go index d3e171a8c..5c16f64bf 100644 --- a/data/base/id_data.go +++ b/data/base/id_data.go @@ -4,10 +4,9 @@ package base import ( + "cosmossdk.io/math" "strings" - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/schema/data" dataConstants "github.com/AssetMantle/schema/data/constants" "github.com/AssetMantle/schema/ids" @@ -22,7 +21,7 @@ func (idData *IDData) ValidateBasic() error { func (idData *IDData) GetID() ids.DataID { return baseIDs.GenerateDataID(idData) } -func (idData *IDData) GetBondWeight() sdkTypes.Int { +func (idData *IDData) GetBondWeight() math.Int { return dataConstants.IDDataWeight } func (idData *IDData) AsString() string { diff --git a/data/base/linked_data.go b/data/base/linked_data.go index 9f72c9c70..204d4fdfa 100644 --- a/data/base/linked_data.go +++ b/data/base/linked_data.go @@ -2,13 +2,13 @@ package base import ( "bytes" + "cosmossdk.io/math" "fmt" "github.com/AssetMantle/schema/data" dataConstants "github.com/AssetMantle/schema/data/constants" "github.com/AssetMantle/schema/data/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - sdkTypes "github.com/cosmos/cosmos-sdk/types" "net/url" "strings" ) @@ -52,7 +52,7 @@ func (linkedData *LinkedData) Compare(listableData data.ListableData) int { func (linkedData *LinkedData) GetID() ids.DataID { return baseIDs.GenerateDataID(linkedData) } -func (linkedData *LinkedData) GetBondWeight() sdkTypes.Int { +func (linkedData *LinkedData) GetBondWeight() math.Int { return dataConstants.LinkedDataWeight } func (linkedData *LinkedData) AsString() string { diff --git a/data/base/list_data.go b/data/base/list_data.go index 9e04435b7..f490bcebc 100644 --- a/data/base/list_data.go +++ b/data/base/list_data.go @@ -5,13 +5,13 @@ package base import ( "bytes" + "cosmossdk.io/math" "fmt" "github.com/AssetMantle/schema/data" dataConstants "github.com/AssetMantle/schema/data/constants" "github.com/AssetMantle/schema/data/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - sdkTypes "github.com/cosmos/cosmos-sdk/types" "sort" "strings" ) @@ -51,7 +51,7 @@ func (listData *ListData) Get() []data.AnyListableData { return anyListableData } -func (listData *ListData) GetBondWeight() sdkTypes.Int { +func (listData *ListData) GetBondWeight() math.Int { return dataConstants.ListDataWeight } func (listData *ListData) AsString() string { diff --git a/data/base/number_data.go b/data/base/number_data.go index cf539f7ee..5b3a5ac38 100644 --- a/data/base/number_data.go +++ b/data/base/number_data.go @@ -1,6 +1,7 @@ package base import ( + "cosmossdk.io/math" "fmt" "github.com/AssetMantle/schema/data" dataConstants "github.com/AssetMantle/schema/data/constants" @@ -22,7 +23,7 @@ func (numberData *NumberData) ValidateBasic() error { func (numberData *NumberData) GetID() ids.DataID { return baseIDs.GenerateDataID(numberData) } -func (numberData *NumberData) GetBondWeight() sdkTypes.Int { +func (numberData *NumberData) GetBondWeight() math.Int { return dataConstants.NumberDataWeight } func (numberData *NumberData) AsString() string { @@ -84,7 +85,7 @@ func (numberData *NumberData) Compare(listableData data.ListableData) int { } return -1 } -func (numberData *NumberData) Get() sdkTypes.Int { +func (numberData *NumberData) Get() math.Int { if value, ok := sdkTypes.NewIntFromString(numberData.Value); !ok { panic("invalid number data") } else { @@ -96,7 +97,7 @@ func PrototypeNumberData() data.NumberData { return NewNumberData(sdkTypes.ZeroInt()).ZeroValue().(*NumberData) } -func NewNumberData(value sdkTypes.Int) data.NumberData { +func NewNumberData(value math.Int) data.NumberData { return &NumberData{ Value: value.String(), } diff --git a/data/base/number_data_test.go b/data/base/number_data_test.go index f2eafe111..f65e40ed4 100644 --- a/data/base/number_data_test.go +++ b/data/base/number_data_test.go @@ -17,7 +17,7 @@ import ( func Test_NewNumberData(t *testing.T) { tests := []struct { name string - args sdkTypes.Int + args math.Int want data.Data }{ {"+ve", sdkTypes.NewInt(10), &NumberData{"10"}}, @@ -97,7 +97,7 @@ func Test_NumberDataGet(t *testing.T) { tests := []struct { name string args data.NumberData - want sdkTypes.Int + want math.Int }{ {"+ve", NewNumberData(sdkTypes.NewInt(10)), sdkTypes.NewInt(10)}, } diff --git a/data/base/string_data.go b/data/base/string_data.go index 0c5172630..ef2b11c6b 100644 --- a/data/base/string_data.go +++ b/data/base/string_data.go @@ -4,12 +4,12 @@ package base import ( + "cosmossdk.io/math" "fmt" "github.com/AssetMantle/schema/data" dataConstants "github.com/AssetMantle/schema/data/constants" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - sdkTypes "github.com/cosmos/cosmos-sdk/types" "strings" ) @@ -29,7 +29,7 @@ func (stringData *StringData) ValidateBasic() error { func (stringData *StringData) GetID() ids.DataID { return baseIDs.GenerateDataID(stringData) } -func (stringData *StringData) GetBondWeight() sdkTypes.Int { +func (stringData *StringData) GetBondWeight() math.Int { return dataConstants.StringDataWeight } func (stringData *StringData) Compare(listableData data.ListableData) int { diff --git a/data/data.go b/data/data.go index eb2361240..6a8a4a7cc 100644 --- a/data/data.go +++ b/data/data.go @@ -4,14 +4,14 @@ package data import ( + "cosmossdk.io/math" "github.com/AssetMantle/schema/ids" - sdkTypes "github.com/cosmos/cosmos-sdk/types" ) // TODO URI and PropertyID Data type type Data interface { GetID() ids.DataID - GetBondWeight() sdkTypes.Int + GetBondWeight() math.Int ValidateBasic() error Unmarshal([]byte) error diff --git a/data/number_data.go b/data/number_data.go index b1a32ad78..fd0334cf1 100644 --- a/data/number_data.go +++ b/data/number_data.go @@ -1,8 +1,8 @@ package data -import sdkTypes "github.com/cosmos/cosmos-sdk/types" +import "cosmossdk.io/math" type NumberData interface { ListableData - Get() sdkTypes.Int + Get() math.Int } diff --git a/documents/asset.go b/documents/asset.go index 8ee5dd5da..edde058d0 100644 --- a/documents/asset.go +++ b/documents/asset.go @@ -4,14 +4,14 @@ package documents import ( + "cosmossdk.io/math" "github.com/AssetMantle/schema/types" - sdkTypes "github.com/cosmos/cosmos-sdk/types" ) type Asset interface { ValidateAsset() error GetBurnHeight() types.Height GetLockHeight() types.Height - GetSupply() sdkTypes.Int + GetSupply() math.Int Document } diff --git a/documents/base/asset.go b/documents/base/asset.go index b9e9ebe89..ac04d2f43 100644 --- a/documents/base/asset.go +++ b/documents/base/asset.go @@ -1,6 +1,7 @@ package base import ( + "cosmossdk.io/math" "fmt" "github.com/AssetMantle/schema/data" "github.com/AssetMantle/schema/documents" @@ -9,7 +10,6 @@ import ( "github.com/AssetMantle/schema/properties/constants" "github.com/AssetMantle/schema/qualified" "github.com/AssetMantle/schema/types" - sdkTypes "github.com/cosmos/cosmos-sdk/types" ) type asset struct { @@ -51,7 +51,7 @@ func (asset asset) GetLockHeight() types.Height { return constants.LockHeightProperty.GetData().Get().(data.HeightData).Get() } -func (asset asset) GetSupply() sdkTypes.Int { +func (asset asset) GetSupply() math.Int { if property := asset.GetProperty(constants.SupplyProperty.GetID()); property != nil && property.IsMeta() { return property.Get().(properties.MetaProperty).GetData().Get().(data.NumberData).Get() } diff --git a/documents/base/asset_test.go b/documents/base/asset_test.go index 4dec5b9e3..64c954b08 100644 --- a/documents/base/asset_test.go +++ b/documents/base/asset_test.go @@ -103,7 +103,7 @@ func Test_asset_GetSupply(t *testing.T) { tests := []struct { name string fields fields - want sdkTypes.Int + want math.Int }{ {"+ve", fields{testDocument}, sdkTypes.OneInt()}, {"+ve with supply", fields{testDocumentWithSupply}, sdkTypes.NewInt(77)}, diff --git a/documents/base/classification.go b/documents/base/classification.go index 823293fbf..6ee10142e 100644 --- a/documents/base/classification.go +++ b/documents/base/classification.go @@ -1,6 +1,7 @@ package base import ( + "cosmossdk.io/math" "fmt" "github.com/AssetMantle/schema/data" "github.com/AssetMantle/schema/documents" @@ -8,7 +9,6 @@ import ( "github.com/AssetMantle/schema/properties" constantProperties "github.com/AssetMantle/schema/properties/constants" "github.com/AssetMantle/schema/qualified" - sdkTypes "github.com/cosmos/cosmos-sdk/types" ) type classification struct { @@ -28,7 +28,7 @@ func (classification classification) ValidateBasic() error { return nil } -func (classification classification) GetBondAmount() sdkTypes.Int { +func (classification classification) GetBondAmount() math.Int { if property := classification.Document.GetProperty(constantProperties.BondAmountProperty.GetID()); property != nil && property.IsMeta() { return property.Get().(properties.MetaProperty).GetData().Get().(data.NumberData).Get() } diff --git a/documents/base/classification_test.go b/documents/base/classification_test.go index 7f581ceac..e1551bf2f 100644 --- a/documents/base/classification_test.go +++ b/documents/base/classification_test.go @@ -59,7 +59,7 @@ func Test_classifiaction_GetSupply(t *testing.T) { tests := []struct { name string fields fields - want sdkTypes.Int + want math.Int }{ {"+ve", fields{testDocument}, sdkTypes.ZeroInt()}, {"+ve with bondAmount", fields{testDocumentWithSupply}, sdkTypes.NewInt(999)}, diff --git a/documents/base/identity.go b/documents/base/identity.go index 13dba97fc..6ea5fe5e1 100644 --- a/documents/base/identity.go +++ b/documents/base/identity.go @@ -1,6 +1,7 @@ package base import ( + "cosmossdk.io/math" "fmt" "github.com/AssetMantle/schema/data" baseData "github.com/AssetMantle/schema/data/base" @@ -49,7 +50,7 @@ func (identity identity) IsProvisioned(accAddress sdkTypes.AccAddress) bool { _, isProvisioned := identity.GetAuthentication().Search(baseData.NewAccAddressData(accAddress)) return isProvisioned } -func (identity identity) GetProvisionedAddressCount() sdkTypes.Int { +func (identity identity) GetProvisionedAddressCount() math.Int { return sdkTypes.NewInt(int64(len(identity.GetAuthentication().Get()))) } func (identity identity) ProvisionAddress(accAddresses ...sdkTypes.AccAddress) documents.Identity { diff --git a/documents/base/order.go b/documents/base/order.go index 47b574c96..5cd0a9b60 100644 --- a/documents/base/order.go +++ b/documents/base/order.go @@ -1,6 +1,7 @@ package base import ( + "cosmossdk.io/math" "fmt" "github.com/AssetMantle/schema/data" "github.com/AssetMantle/schema/documents" @@ -67,13 +68,13 @@ func (order order) GetTakerAssetID() ids.AssetID { } return constants.TakerAssetIDProperty.GetData().Get().(data.IDData).Get().Get().(ids.AssetID) } -func (order order) GetMakerSplit() sdkTypes.Int { +func (order order) GetMakerSplit() math.Int { if property := order.GetProperty(constants.MakerSplitProperty.GetID()); property != nil && property.IsMeta() { return property.Get().(properties.MetaProperty).GetData().Get().(data.NumberData).Get() } return constants.MakerSplitProperty.GetData().Get().(data.NumberData).Get() } -func (order order) GetTakerSplit() sdkTypes.Int { +func (order order) GetTakerSplit() math.Int { if property := order.GetProperty(constants.TakerSplitProperty.GetID()); property != nil && property.IsMeta() { return property.Get().(properties.MetaProperty).GetData().Get().(data.NumberData).Get() } diff --git a/documents/base/put_order.go b/documents/base/put_order.go index 5674a7fa8..3b43cc640 100644 --- a/documents/base/put_order.go +++ b/documents/base/put_order.go @@ -1,6 +1,7 @@ package base import ( + "cosmossdk.io/math" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/documents" "github.com/AssetMantle/schema/ids" @@ -27,7 +28,7 @@ func PrototypePutOrder() documents.PutOrder { return NewPutOrder(baseIDs.PrototypeIdentityID(), baseIDs.PrototypeAssetID(), baseIDs.PrototypeAssetID(), sdkTypes.ZeroInt(), sdkTypes.ZeroInt(), base.NewHeight(-1)) } -func NewPutOrder(makerID ids.IdentityID, makerAssetID ids.AssetID, takerAssetID ids.AssetID, makerSplit sdkTypes.Int, takerSplit sdkTypes.Int, expiryHeight types.Height) documents.PutOrder { +func NewPutOrder(makerID ids.IdentityID, makerAssetID ids.AssetID, takerAssetID ids.AssetID, makerSplit math.Int, takerSplit math.Int, expiryHeight types.Height) documents.PutOrder { return NewOrder(putOrderClassificationID, baseQualified.NewImmutables(baseLists.NewPropertyList( baseProperties.NewMetaProperty(propertyConstants.MakerIDProperty.GetKey(), baseData.NewIDData(makerID)), baseProperties.NewMetaProperty(propertyConstants.MakerAssetIDProperty.GetKey(), baseData.NewIDData(makerAssetID)), diff --git a/documents/classification.go b/documents/classification.go index 805bfc327..492814cbc 100644 --- a/documents/classification.go +++ b/documents/classification.go @@ -3,9 +3,9 @@ package documents -import sdkTypes "github.com/cosmos/cosmos-sdk/types" +import "cosmossdk.io/math" type Classification interface { - GetBondAmount() sdkTypes.Int + GetBondAmount() math.Int Document } diff --git a/documents/identity.go b/documents/identity.go index 05f4b4e57..d25e8af8a 100644 --- a/documents/identity.go +++ b/documents/identity.go @@ -4,6 +4,7 @@ package documents import ( + "cosmossdk.io/math" "github.com/AssetMantle/schema/data" "github.com/AssetMantle/schema/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" @@ -21,7 +22,7 @@ type Identity interface { GetAuthentication() data.ListData IsProvisioned(sdkTypes.AccAddress) bool - GetProvisionedAddressCount() sdkTypes.Int + GetProvisionedAddressCount() math.Int ProvisionAddress(...sdkTypes.AccAddress) Identity UnprovisionAddress(...sdkTypes.AccAddress) Identity diff --git a/documents/order.go b/documents/order.go index 58a527288..97ed71dec 100644 --- a/documents/order.go +++ b/documents/order.go @@ -4,6 +4,7 @@ package documents import ( + "cosmossdk.io/math" "github.com/AssetMantle/schema/ids" "github.com/AssetMantle/schema/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" @@ -13,8 +14,8 @@ type Order interface { GetMakerID() ids.IdentityID GetMakerAssetID() ids.AssetID GetTakerAssetID() ids.AssetID - GetMakerSplit() sdkTypes.Int - GetTakerSplit() sdkTypes.Int + GetMakerSplit() math.Int + GetTakerSplit() math.Int GetExpiryHeight() types.Height GetTakerID() ids.IdentityID diff --git a/parameters/parameter.go b/parameters/parameter.go index 6700d648a..f60a9321c 100644 --- a/parameters/parameter.go +++ b/parameters/parameter.go @@ -6,11 +6,9 @@ package parameters import ( "github.com/AssetMantle/schema/data" "github.com/AssetMantle/schema/properties" - "github.com/cosmos/gogoproto/proto" ) type Parameter interface { - proto.Message ValidateBasic() error GetMetaProperty() properties.MetaProperty Mutate(data.Data) Parameter diff --git a/properties/base/any_property.go b/properties/base/any_property.go index a54153ffd..16fb861c0 100644 --- a/properties/base/any_property.go +++ b/properties/base/any_property.go @@ -1,10 +1,10 @@ package base import ( + "cosmossdk.io/math" "github.com/AssetMantle/schema/data" "github.com/AssetMantle/schema/ids" "github.com/AssetMantle/schema/properties" - sdkTypes "github.com/cosmos/cosmos-sdk/types" ) type getter interface { @@ -23,37 +23,37 @@ func (m *AnyProperty_MesaProperty) get() properties.Property { var _ properties.AnyProperty = (*AnyProperty)(nil) -func (m *AnyProperty) IsAnyProperty() {} -func (m *AnyProperty) Get() properties.Property { - return m.Impl.(getter).get() +func (anyProperty *AnyProperty) IsAnyProperty() {} +func (anyProperty *AnyProperty) Get() properties.Property { + return anyProperty.Impl.(getter).get() } -func (m *AnyProperty) GetID() ids.PropertyID { - return m.Impl.(getter).get().GetID() +func (anyProperty *AnyProperty) GetID() ids.PropertyID { + return anyProperty.Impl.(getter).get().GetID() } -func (m *AnyProperty) GetDataID() ids.DataID { - return m.Impl.(getter).get().GetDataID() +func (anyProperty *AnyProperty) GetDataID() ids.DataID { + return anyProperty.Impl.(getter).get().GetDataID() } -func (m *AnyProperty) GetKey() ids.StringID { - return m.Impl.(getter).get().GetKey() +func (anyProperty *AnyProperty) GetKey() ids.StringID { + return anyProperty.Impl.(getter).get().GetKey() } -func (m *AnyProperty) GetDataTypeID() ids.StringID { - return m.Impl.(getter).get().GetDataTypeID() +func (anyProperty *AnyProperty) GetDataTypeID() ids.StringID { + return anyProperty.Impl.(getter).get().GetDataTypeID() } -func (m *AnyProperty) GetBondWeight() sdkTypes.Int { - return m.Impl.(getter).get().GetBondWeight() +func (anyProperty *AnyProperty) GetBondWeight() math.Int { + return anyProperty.Impl.(getter).get().GetBondWeight() } -func (m *AnyProperty) IsMeta() bool { - return m.Impl.(getter).get().IsMeta() +func (anyProperty *AnyProperty) IsMeta() bool { + return anyProperty.Impl.(getter).get().IsMeta() } -func (m *AnyProperty) ToAnyProperty() properties.AnyProperty { - return m.Impl.(getter).get().ToAnyProperty() +func (anyProperty *AnyProperty) ToAnyProperty() properties.AnyProperty { + return anyProperty.Impl.(getter).get().ToAnyProperty() } -func (m *AnyProperty) Compare(property properties.Property) int { - return m.Impl.(getter).get().Compare(property) +func (anyProperty *AnyProperty) Compare(property properties.Property) int { + return anyProperty.Impl.(getter).get().Compare(property) } -func (m *AnyProperty) ValidateBasic() error { - return m.Impl.(getter).get().ValidateBasic() +func (anyProperty *AnyProperty) ValidateBasic() error { + return anyProperty.Impl.(getter).get().ValidateBasic() } -func (m *AnyProperty) Mutate(data data.Data) (properties.Property, error) { - return m.Impl.(getter).get().Mutate(data) +func (anyProperty *AnyProperty) Mutate(data data.Data) (properties.Property, error) { + return anyProperty.Impl.(getter).get().Mutate(data) } diff --git a/properties/base/mesa_property.go b/properties/base/mesa_property.go index 98bfb0343..a41fd070f 100644 --- a/properties/base/mesa_property.go +++ b/properties/base/mesa_property.go @@ -4,13 +4,13 @@ package base import ( + "cosmossdk.io/math" "fmt" "github.com/AssetMantle/schema/data" "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/properties" - sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ properties.MesaProperty = (*MesaProperty)(nil) @@ -39,7 +39,7 @@ func (mesaProperty *MesaProperty) GetKey() ids.StringID { func (mesaProperty *MesaProperty) GetDataTypeID() ids.StringID { return mesaProperty.ID.GetDataTypeID() } -func (mesaProperty *MesaProperty) GetBondWeight() sdkTypes.Int { +func (mesaProperty *MesaProperty) GetBondWeight() math.Int { if zeroData, err := base.PrototypeAnyData().FromString(mesaProperty.GetDataTypeID().AsString()); err != nil { panic(err) } else { @@ -86,7 +86,3 @@ func NewMesaProperty(key ids.StringID, data data.Data) properties.MesaProperty { DataID: data.GetID().(*baseIDs.DataID), } } - -func PrototypeMesaProperty() properties.MesaProperty { - return PrototypeMetaProperty().ScrubData() -} diff --git a/properties/base/mesa_property_test.go b/properties/base/mesa_property_test.go index 1a360b51c..0e8b336b9 100644 --- a/properties/base/mesa_property_test.go +++ b/properties/base/mesa_property_test.go @@ -357,7 +357,7 @@ func Test_MesaPropertyGetBondedWeight(t *testing.T) { tests := []struct { name string args properties.MesaProperty - want sdkTypes.Int + want math.Int }{ {"+ve", testMesaProperty, dataConstants.StringDataWeight}, } diff --git a/properties/base/meta_property.go b/properties/base/meta_property.go index dfb17cb79..f2b24d645 100644 --- a/properties/base/meta_property.go +++ b/properties/base/meta_property.go @@ -4,13 +4,13 @@ package base import ( + "cosmossdk.io/math" "fmt" "github.com/AssetMantle/schema/data" "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/properties" - sdkTypes "github.com/cosmos/cosmos-sdk/types" "strings" ) @@ -67,7 +67,7 @@ func (metaProperty *MetaProperty) GetKey() ids.StringID { func (metaProperty *MetaProperty) GetDataTypeID() ids.StringID { return metaProperty.ID.GetDataTypeID() } -func (metaProperty *MetaProperty) GetBondWeight() sdkTypes.Int { +func (metaProperty *MetaProperty) GetBondWeight() math.Int { return metaProperty.Data.GetBondWeight() } func (metaProperty *MetaProperty) IsMeta() bool { diff --git a/properties/property.go b/properties/property.go index 92651ea77..42eaf12f9 100644 --- a/properties/property.go +++ b/properties/property.go @@ -4,9 +4,9 @@ package properties import ( + "cosmossdk.io/math" "github.com/AssetMantle/schema/data" "github.com/AssetMantle/schema/ids" - sdkTypes "github.com/cosmos/cosmos-sdk/types" ) type Property interface { @@ -14,7 +14,7 @@ type Property interface { GetDataID() ids.DataID GetKey() ids.StringID GetDataTypeID() ids.StringID - GetBondWeight() sdkTypes.Int + GetBondWeight() math.Int IsMeta() bool ValidateBasic() error diff --git a/types/base/split.go b/types/base/split.go index 9efb9822a..bca15e4d2 100644 --- a/types/base/split.go +++ b/types/base/split.go @@ -1,39 +1,39 @@ package base import ( + "cosmossdk.io/math" "fmt" "github.com/AssetMantle/schema/types" - sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ types.Split = (*Split)(nil) func (split *Split) ValidateBasic() error { - if _, ok := sdkTypes.NewIntFromString(split.Value); !ok { + if _, ok := math.NewIntFromString(split.Value); !ok { return fmt.Errorf("invalid split value %s", split.Value) } return nil } -func (split *Split) GetValue() sdkTypes.Int { - if value, ok := sdkTypes.NewIntFromString(split.Value); !ok { +func (split *Split) GetValue() math.Int { + if value, ok := math.NewIntFromString(split.Value); !ok { panic("invalid split value") } else { return value } } -func (split *Split) Subtract(outValue sdkTypes.Int) types.Split { +func (split *Split) Subtract(outValue math.Int) types.Split { split.Value = split.GetValue().Sub(outValue).String() return split } -func (split *Split) Add(inValue sdkTypes.Int) types.Split { +func (split *Split) Add(inValue math.Int) types.Split { split.Value = split.GetValue().Add(inValue).String() return split } -func (split *Split) CanSend(outValue sdkTypes.Int) bool { +func (split *Split) CanSend(outValue math.Int) bool { return split.GetValue().GTE(outValue) } -func NewSplit(value sdkTypes.Int) types.Split { +func NewSplit(value math.Int) types.Split { return &Split{ Value: value.String(), } diff --git a/types/split.go b/types/split.go index 194a640ca..6545e3dc2 100644 --- a/types/split.go +++ b/types/split.go @@ -4,14 +4,14 @@ package types import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" + "cosmossdk.io/math" ) type Split interface { - GetValue() sdkTypes.Int - CanSend(sdkTypes.Int) bool + GetValue() math.Int + CanSend(math.Int) bool - Subtract(sdkTypes.Int) Split - Add(sdkTypes.Int) Split + Subtract(math.Int) Split + Add(math.Int) Split ValidateBasic() error }