Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deepanshu #45

Merged
merged 5 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go/data/base/list_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (listData *ListData) FromString(dataString string) (data.Data, error) {
for i, datumString := range dataStringList {
if datum, err := PrototypeAnyData().FromString(datumString); err != nil {
return PrototypeListData(), err
} else if listableData, ok := datum.(data.ListableData); !ok {
} else if listableData, ok := datum.ToAnyData().Get().(data.ListableData); !ok {
return PrototypeListData(), errorConstants.IncorrectFormat.Wrapf("data type %T is not listable", datum)
} else {
dataList[i] = listableData
Expand Down
3 changes: 3 additions & 0 deletions go/data/base/string_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import (

var _ data.StringData = (*StringData)(nil)

func (stringData *StringData) Get() string {
return stringData.Value
}
func (stringData *StringData) ValidateBasic() error {
if !utilities.IsValidStringData(stringData.Value) {
return errorConstants.IncorrectFormat
Expand Down
2 changes: 1 addition & 1 deletion go/data/string_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ package data

type StringData interface {
ListableData
AsString() string
Get() string
}
34 changes: 34 additions & 0 deletions go/documents/base/coin_asset.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package base

import (
"github.com/AssetMantle/schema/go/data"
baseData "github.com/AssetMantle/schema/go/data/base"
"github.com/AssetMantle/schema/go/documents"
"github.com/AssetMantle/schema/go/ids"
baseIDs "github.com/AssetMantle/schema/go/ids/base"
baseLists "github.com/AssetMantle/schema/go/lists/base"
"github.com/AssetMantle/schema/go/properties"
baseProperties "github.com/AssetMantle/schema/go/properties/base"
constantProperties "github.com/AssetMantle/schema/go/properties/constants"
baseQualified "github.com/AssetMantle/schema/go/qualified/base"
)

var _ documents.CoinAsset = (*asset)(nil)

var coinAssetClassificationID = baseIDs.NewClassificationID(baseQualified.NewImmutables(baseLists.NewPropertyList(constantProperties.DenomIDProperty)), baseQualified.NewMutables(baseLists.NewPropertyList()))

func (asset asset) GetDenomID() ids.StringID {
if property := asset.Document.GetProperty(constantProperties.DenomIDProperty.GetID()); property != nil && property.IsMeta() {
return property.Get().(properties.MetaProperty).GetData().Get().(data.IDData).Get().Get().(ids.StringID)
}

return constantProperties.DenomIDProperty.GetData().Get().(data.IDData).Get().Get().(ids.StringID)
}

func PrototypeCoinAsset() documents.CoinAsset {
return NewCoinAsset(baseIDs.PrototypeStringID())
}

func NewCoinAsset(denomID ids.StringID) documents.CoinAsset {
return NewAsset(coinAssetClassificationID, baseQualified.NewImmutables(baseLists.NewPropertyList(baseProperties.NewMetaProperty(constantProperties.DenomIDProperty.GetKey(), baseData.NewIDData(denomID)))), baseQualified.NewMutables(baseLists.NewPropertyList())).(asset)
}
17 changes: 12 additions & 5 deletions go/documents/base/maintainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"github.com/AssetMantle/schema/go/data"
baseData "github.com/AssetMantle/schema/go/data/base"
"github.com/AssetMantle/schema/go/documents"
"github.com/AssetMantle/schema/go/documents/constants"
"github.com/AssetMantle/schema/go/ids"
baseIDs "github.com/AssetMantle/schema/go/ids/base"
"github.com/AssetMantle/schema/go/lists"
baseLists "github.com/AssetMantle/schema/go/lists/base"
"github.com/AssetMantle/schema/go/properties"
Expand All @@ -20,6 +20,8 @@ type maintainer struct {

var _ documents.Maintainer = (*maintainer)(nil)

var maintainerClassificationID = baseIDs.NewClassificationID(baseQualified.NewImmutables(baseLists.NewPropertyList(constantProperties.IdentityIDProperty, constantProperties.MaintainedClassificationIDProperty)), baseQualified.NewMutables(baseLists.NewPropertyList(constantProperties.MaintainedPropertiesProperty, constantProperties.PermissionsProperty)))

func (maintainer maintainer) GetIdentityID() ids.IdentityID {
if property := maintainer.GetProperty(constantProperties.IdentityIDProperty.GetID()); property != nil && property.IsMeta() {
return property.Get().(properties.MetaProperty).GetData().Get().(data.IDData).Get().Get().(ids.IdentityID)
Expand Down Expand Up @@ -64,9 +66,17 @@ func idListToListData(idList lists.IDList) data.ListData {
return dataList
}

func PrototypeMaintainer() documents.Maintainer {
return NewMaintainer(baseIDs.PrototypeIdentityID(), baseIDs.PrototypeClassificationID(), baseLists.NewIDList(), baseLists.NewIDList())
}

func NewMaintainerFromDocument(document documents.Document) documents.Maintainer {
return maintainer{Document: document}
}

func NewMaintainer(identityID ids.IdentityID, maintainedClassificationID ids.ClassificationID, maintainedPropertyIDList lists.IDList, permissions lists.IDList) documents.Maintainer {
return maintainer{
Document: NewDocument(constants.MaintainerClassificationID,
Document: NewDocument(maintainerClassificationID,
baseQualified.NewImmutables(baseLists.NewPropertyList(
baseProperties.NewMetaProperty(constantProperties.IdentityIDProperty.GetKey(), baseData.NewIDData(identityID)),
baseProperties.NewMetaProperty(constantProperties.MaintainedClassificationIDProperty.GetKey(), baseData.NewIDData(maintainedClassificationID)),
Expand All @@ -78,6 +88,3 @@ func NewMaintainer(identityID ids.IdentityID, maintainedClassificationID ids.Cla
),
}
}
func NewMaintainerFromDocument(document documents.Document) documents.Maintainer {
return maintainer{Document: document}
}
34 changes: 34 additions & 0 deletions go/documents/base/nub_identity.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package base

import (
"github.com/AssetMantle/schema/go/data"
baseData "github.com/AssetMantle/schema/go/data/base"
"github.com/AssetMantle/schema/go/documents"
"github.com/AssetMantle/schema/go/ids"
baseIDs "github.com/AssetMantle/schema/go/ids/base"
baseLists "github.com/AssetMantle/schema/go/lists/base"
"github.com/AssetMantle/schema/go/properties"
baseProperties "github.com/AssetMantle/schema/go/properties/base"
constantProperties "github.com/AssetMantle/schema/go/properties/constants"
baseQualified "github.com/AssetMantle/schema/go/qualified/base"
)

var _ documents.NubIdentity = (*identity)(nil)

var nubIdentityClassificationID = baseIDs.NewClassificationID(baseQualified.NewImmutables(baseLists.NewPropertyList(constantProperties.NubIDProperty)), baseQualified.NewMutables(baseLists.NewPropertyList(constantProperties.AuthenticationProperty)))

func (identity identity) GetNubID() ids.StringID {
if property := identity.Document.GetProperty(constantProperties.NubIDProperty.GetID()); property != nil && property.IsMeta() {
return property.Get().(properties.MetaProperty).GetData().Get().(data.IDData).Get().Get().(ids.StringID)
}

return constantProperties.NubIDProperty.GetData().Get().(data.IDData).Get().Get().(ids.StringID)
}

func PrototypeNubIdentity() documents.NubIdentity {
return NewNubIdentity(baseIDs.PrototypeStringID(), baseData.PrototypeListData())
}

func NewNubIdentity(nubID ids.StringID, authentication data.ListData) documents.NubIdentity {
return NewIdentity(nubIdentityClassificationID, baseQualified.NewImmutables(baseLists.NewPropertyList(baseProperties.NewMetaProperty(constantProperties.NubIDProperty.GetKey(), baseData.NewIDData(nubID)))), baseQualified.NewMutables(baseLists.NewPropertyList(baseProperties.NewMetaProperty(constantProperties.AuthenticationProperty.GetKey(), authentication)))).(identity)
}
8 changes: 8 additions & 0 deletions go/documents/coin_asset.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package documents

import "github.com/AssetMantle/schema/go/ids"

type CoinAsset interface {
Asset
GetDenomID() ids.StringID
}
10 changes: 0 additions & 10 deletions go/documents/constants/maintainer.go

This file was deleted.

8 changes: 8 additions & 0 deletions go/documents/nub_identity.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package documents

import "github.com/AssetMantle/schema/go/ids"

type NubIdentity interface {
Identity
GetNubID() ids.StringID
}
33 changes: 20 additions & 13 deletions go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,46 @@ module github.com/AssetMantle/schema/go
go 1.19

require (
github.com/cosmos/cosmos-sdk v0.45.16
github.com/cosmos/cosmos-sdk v0.45.16-ics
github.com/cosmos/gogoproto v1.4.3
github.com/gogo/protobuf v1.3.3
github.com/stretchr/testify v1.8.1
github.com/stretchr/testify v1.8.2
)

require (
github.com/DataDog/zstd v1.4.5 // indirect
github.com/armon/go-metrics v0.4.0 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/confio/ics23/go v0.9.0 // indirect
github.com/cosmos/btcutil v1.0.4 // indirect
github.com/cosmos/gorocksdb v1.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/dgraph-io/badger/v2 v2.2007.2 // indirect
github.com/dgraph-io/ristretto v0.0.3 // indirect
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
github.com/dgraph-io/ristretto v0.1.0 // indirect
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/felixge/httpsnoop v1.0.2 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/golang/glog v1.0.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/gtank/merlin v0.1.1 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/go-uuid v1.0.1 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/keybase/go-keychain v0.0.0-20230307172405-3e4884637dd1 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
Expand All @@ -63,26 +67,29 @@ require (
github.com/subosito/gotenv v1.4.1 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/tendermint/tendermint v0.34.26 // indirect
github.com/tendermint/tendermint v0.34.27 // indirect
github.com/tendermint/tm-db v0.6.7 // indirect
go.etcd.io/bbolt v1.3.6 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/exp v0.0.0-20221019170559-20944726eadf // indirect
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
google.golang.org/genproto v0.0.0-20230125152338-dcaf20b6aeaa // indirect
google.golang.org/grpc v1.52.3 // indirect
google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace (
github.com/confio/ics23/go => github.com/confio/ics23/go v0.9.0
github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.45.14
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.8.1
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/tendermint/tendermint => github.com/informalsystems/tendermint v0.34.26
github.com/jhump/protoreflect => github.com/jhump/protoreflect v1.9.0
github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.27
google.golang.org/grpc => google.golang.org/grpc v1.33.2
)
Loading
Loading