username

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package username provides an NFT implementation for maintaining a list of blockchain addresses for each user. For each user an address can be added or removed at any time.

Index

Constants

View Source
const (
	BucketName            = "usrnft"
	ChainAddressIndexName = "chainaddr"
)
View Source
const ModelName = "username"

ModelName is used to recognize the model provided by this NFT impementation. It can be used by the nft/base extension to register a handler.

Variables

View Source
var (
	ErrInvalidLengthCodec = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowCodec   = fmt.Errorf("proto: integer overflow")
)

Functions

func NewUsernameToken

func NewUsernameToken(key []byte, owner weave.Address, approvals []nft.ActionApprovals) *orm.SimpleObj

func RegisterQuery

func RegisterQuery(qr weave.QueryRouter)

RegisterQuery will register this bucket as "/nft/usernames"

func RegisterRoutes

func RegisterRoutes(r weave.Registry, auth x.Authenticator, issuer weave.Address)

RegisterRoutes will instantiate and register all handlers in this package

Types

type AddChainAddressHandler

type AddChainAddressHandler struct {
	// contains filtered or unexported fields
}

func NewAddChainAddressHandler

func NewAddChainAddressHandler(auth x.Authenticator, issuer weave.Address, bucket Bucket) *AddChainAddressHandler

func (AddChainAddressHandler) Check

func (AddChainAddressHandler) Deliver

type AddChainAddressMsg

type AddChainAddressMsg struct {
	UsernameID   []byte `protobuf:"bytes,1,opt,name=username_id,json=usernameId,proto3" json:"username_id,omitempty"`
	BlockchainID []byte `protobuf:"bytes,2,opt,name=blockchain_id,json=blockchainId,proto3" json:"blockchain_id,omitempty"`
	Address      string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"`
}

func (*AddChainAddressMsg) Descriptor

func (*AddChainAddressMsg) Descriptor() ([]byte, []int)

func (*AddChainAddressMsg) GetAddress

func (m *AddChainAddressMsg) GetAddress() string

func (*AddChainAddressMsg) GetBlockchainID

func (m *AddChainAddressMsg) GetBlockchainID() []byte

func (*AddChainAddressMsg) GetUsernameID

func (m *AddChainAddressMsg) GetUsernameID() []byte

func (*AddChainAddressMsg) Marshal

func (m *AddChainAddressMsg) Marshal() (dAtA []byte, err error)

func (*AddChainAddressMsg) MarshalTo

func (m *AddChainAddressMsg) MarshalTo(dAtA []byte) (int, error)

func (*AddChainAddressMsg) Path

func (*AddChainAddressMsg) Path() string

Path returns the routing path for this message

func (*AddChainAddressMsg) ProtoMessage

func (*AddChainAddressMsg) ProtoMessage()

func (*AddChainAddressMsg) Reset

func (m *AddChainAddressMsg) Reset()

func (*AddChainAddressMsg) Size

func (m *AddChainAddressMsg) Size() (n int)

func (*AddChainAddressMsg) String

func (m *AddChainAddressMsg) String() string

func (*AddChainAddressMsg) Unmarshal

func (m *AddChainAddressMsg) Unmarshal(dAtA []byte) error

func (*AddChainAddressMsg) Validate

func (m *AddChainAddressMsg) Validate() error

func (*AddChainAddressMsg) XXX_DiscardUnknown added in v0.12.0

func (m *AddChainAddressMsg) XXX_DiscardUnknown()

func (*AddChainAddressMsg) XXX_Marshal added in v0.12.0

func (m *AddChainAddressMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*AddChainAddressMsg) XXX_Merge added in v0.12.0

func (m *AddChainAddressMsg) XXX_Merge(src proto.Message)

func (*AddChainAddressMsg) XXX_Size added in v0.12.0

func (m *AddChainAddressMsg) XXX_Size() int

func (*AddChainAddressMsg) XXX_Unmarshal added in v0.12.0

func (m *AddChainAddressMsg) XXX_Unmarshal(b []byte) error

type Bucket

type Bucket struct {
	orm.Bucket
}

func NewBucket

func NewBucket() Bucket

func (Bucket) Create

func (b Bucket) Create(db weave.KVStore, owner weave.Address, id []byte, approvals []nft.ActionApprovals, addresses []ChainAddress) (orm.Object, error)

type ChainAddress

type ChainAddress struct {
	// An arbitrary blockchain ID. Original design was assuming a relation to our
	// internal blockchain ID, but to simplify the implementation, we no longer
	// register blckchain. Instead we allow to pass any value here, withouth
	// validating it.
	BlockchainID []byte `protobuf:"bytes,1,opt,name=blockchain_id,json=blockchainId,proto3" json:"blockchain_id,omitempty"`
	// Address is a unique identifier of an account on the referenced
	// blockchain.
	Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"`
}

ChainAddress is an address bind to a specific blockchain chain.

func (*ChainAddress) Descriptor

func (*ChainAddress) Descriptor() ([]byte, []int)

func (ChainAddress) Equals

func (p ChainAddress) Equals(o ChainAddress) bool

func (*ChainAddress) GetAddress

func (m *ChainAddress) GetAddress() string

func (*ChainAddress) GetBlockchainID

func (m *ChainAddress) GetBlockchainID() []byte

func (*ChainAddress) Marshal

func (m *ChainAddress) Marshal() (dAtA []byte, err error)

func (*ChainAddress) MarshalTo

func (m *ChainAddress) MarshalTo(dAtA []byte) (int, error)

func (*ChainAddress) ProtoMessage

func (*ChainAddress) ProtoMessage()

func (*ChainAddress) Reset

func (m *ChainAddress) Reset()

func (*ChainAddress) Size

func (m *ChainAddress) Size() (n int)

func (*ChainAddress) String

func (m *ChainAddress) String() string

func (*ChainAddress) Unmarshal

func (m *ChainAddress) Unmarshal(dAtA []byte) error

func (*ChainAddress) Validate

func (p *ChainAddress) Validate() error

func (*ChainAddress) XXX_DiscardUnknown added in v0.12.0

func (m *ChainAddress) XXX_DiscardUnknown()

func (*ChainAddress) XXX_Marshal added in v0.12.0

func (m *ChainAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ChainAddress) XXX_Merge added in v0.12.0

func (m *ChainAddress) XXX_Merge(src proto.Message)

func (*ChainAddress) XXX_Size added in v0.12.0

func (m *ChainAddress) XXX_Size() int

func (*ChainAddress) XXX_Unmarshal added in v0.12.0

func (m *ChainAddress) XXX_Unmarshal(b []byte) error

type IssueHandler

type IssueHandler struct {
	// contains filtered or unexported fields
}

func NewIssueHandler

func NewIssueHandler(auth x.Authenticator, issuer weave.Address, bucket Bucket) *IssueHandler

func (IssueHandler) Check

func (h IssueHandler) Check(ctx weave.Context, store weave.KVStore, tx weave.Tx) (weave.CheckResult, error)

func (IssueHandler) Deliver

func (h IssueHandler) Deliver(ctx weave.Context, store weave.KVStore, tx weave.Tx) (weave.DeliverResult, error)

type IssueTokenMsg

type IssueTokenMsg struct {
	ID        []byte                `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	Owner     []byte                `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"`
	Approvals []nft.ActionApprovals `protobuf:"bytes,3,rep,name=approvals,proto3" json:"approvals"`
	Details   TokenDetails          `protobuf:"bytes,4,opt,name=details,proto3" json:"details"`
}

func (*IssueTokenMsg) Descriptor

func (*IssueTokenMsg) Descriptor() ([]byte, []int)

func (*IssueTokenMsg) GetApprovals

func (m *IssueTokenMsg) GetApprovals() []nft.ActionApprovals

func (*IssueTokenMsg) GetDetails

func (m *IssueTokenMsg) GetDetails() TokenDetails

func (*IssueTokenMsg) GetID

func (m *IssueTokenMsg) GetID() []byte

func (*IssueTokenMsg) GetOwner

func (m *IssueTokenMsg) GetOwner() []byte

func (*IssueTokenMsg) Marshal

func (m *IssueTokenMsg) Marshal() (dAtA []byte, err error)

func (*IssueTokenMsg) MarshalTo

func (m *IssueTokenMsg) MarshalTo(dAtA []byte) (int, error)

func (*IssueTokenMsg) Path

func (*IssueTokenMsg) Path() string

Path returns the routing path for this message

func (*IssueTokenMsg) ProtoMessage

func (*IssueTokenMsg) ProtoMessage()

func (*IssueTokenMsg) Reset

func (m *IssueTokenMsg) Reset()

func (*IssueTokenMsg) Size

func (m *IssueTokenMsg) Size() (n int)

func (*IssueTokenMsg) String

func (m *IssueTokenMsg) String() string

func (*IssueTokenMsg) Unmarshal

func (m *IssueTokenMsg) Unmarshal(dAtA []byte) error

func (*IssueTokenMsg) Validate

func (m *IssueTokenMsg) Validate() error

func (*IssueTokenMsg) XXX_DiscardUnknown added in v0.12.0

func (m *IssueTokenMsg) XXX_DiscardUnknown()

func (*IssueTokenMsg) XXX_Marshal added in v0.12.0

func (m *IssueTokenMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*IssueTokenMsg) XXX_Merge added in v0.12.0

func (m *IssueTokenMsg) XXX_Merge(src proto.Message)

func (*IssueTokenMsg) XXX_Size added in v0.12.0

func (m *IssueTokenMsg) XXX_Size() int

func (*IssueTokenMsg) XXX_Unmarshal added in v0.12.0

func (m *IssueTokenMsg) XXX_Unmarshal(b []byte) error

type RemoveChainAddressHandler

type RemoveChainAddressHandler struct {
	// contains filtered or unexported fields
}

func NewRemoveChainAddressHandler

func NewRemoveChainAddressHandler(auth x.Authenticator, issuer weave.Address, bucket Bucket) *RemoveChainAddressHandler

func (RemoveChainAddressHandler) Check

func (RemoveChainAddressHandler) Deliver

type RemoveChainAddressMsg

type RemoveChainAddressMsg struct {
	UsernameID   []byte `protobuf:"bytes,1,opt,name=username_id,json=usernameId,proto3" json:"username_id,omitempty"`
	BlockchainID []byte `protobuf:"bytes,2,opt,name=blockchain_id,json=blockchainId,proto3" json:"blockchain_id,omitempty"`
	Address      string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"`
}

func (*RemoveChainAddressMsg) Descriptor

func (*RemoveChainAddressMsg) Descriptor() ([]byte, []int)

func (*RemoveChainAddressMsg) GetAddress

func (m *RemoveChainAddressMsg) GetAddress() string

func (*RemoveChainAddressMsg) GetBlockchainID

func (m *RemoveChainAddressMsg) GetBlockchainID() []byte

func (*RemoveChainAddressMsg) GetUsernameID

func (m *RemoveChainAddressMsg) GetUsernameID() []byte

func (*RemoveChainAddressMsg) Marshal

func (m *RemoveChainAddressMsg) Marshal() (dAtA []byte, err error)

func (*RemoveChainAddressMsg) MarshalTo

func (m *RemoveChainAddressMsg) MarshalTo(dAtA []byte) (int, error)

func (*RemoveChainAddressMsg) Path

func (*RemoveChainAddressMsg) Path() string

Path returns the routing path for this message

func (*RemoveChainAddressMsg) ProtoMessage

func (*RemoveChainAddressMsg) ProtoMessage()

func (*RemoveChainAddressMsg) Reset

func (m *RemoveChainAddressMsg) Reset()

func (*RemoveChainAddressMsg) Size

func (m *RemoveChainAddressMsg) Size() (n int)

func (*RemoveChainAddressMsg) String

func (m *RemoveChainAddressMsg) String() string

func (*RemoveChainAddressMsg) Unmarshal

func (m *RemoveChainAddressMsg) Unmarshal(dAtA []byte) error

func (*RemoveChainAddressMsg) Validate

func (m *RemoveChainAddressMsg) Validate() error

func (*RemoveChainAddressMsg) XXX_DiscardUnknown added in v0.12.0

func (m *RemoveChainAddressMsg) XXX_DiscardUnknown()

func (*RemoveChainAddressMsg) XXX_Marshal added in v0.12.0

func (m *RemoveChainAddressMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RemoveChainAddressMsg) XXX_Merge added in v0.12.0

func (m *RemoveChainAddressMsg) XXX_Merge(src proto.Message)

func (*RemoveChainAddressMsg) XXX_Size added in v0.12.0

func (m *RemoveChainAddressMsg) XXX_Size() int

func (*RemoveChainAddressMsg) XXX_Unmarshal added in v0.12.0

func (m *RemoveChainAddressMsg) XXX_Unmarshal(b []byte) error

type Token

type Token interface {
	nft.BaseNFT
	GetChainAddresses() []ChainAddress
	SetChainAddresses(actor weave.Address, newKeys []ChainAddress) error
}

func AsUsername

func AsUsername(obj orm.Object) (Token, error)

AsUsername will safely type-cast any value from Bucket

type TokenDetails

type TokenDetails struct {
	Addresses []ChainAddress `protobuf:"bytes,1,rep,name=addresses,proto3" json:"addresses"`
}

func (*TokenDetails) Clone

func (t *TokenDetails) Clone() *TokenDetails

func (*TokenDetails) Descriptor

func (*TokenDetails) Descriptor() ([]byte, []int)

func (*TokenDetails) GetAddresses

func (m *TokenDetails) GetAddresses() []ChainAddress

func (*TokenDetails) Marshal

func (m *TokenDetails) Marshal() (dAtA []byte, err error)

func (*TokenDetails) MarshalTo

func (m *TokenDetails) MarshalTo(dAtA []byte) (int, error)

func (*TokenDetails) ProtoMessage

func (*TokenDetails) ProtoMessage()

func (*TokenDetails) Reset

func (m *TokenDetails) Reset()

func (*TokenDetails) Size

func (m *TokenDetails) Size() (n int)

func (*TokenDetails) String

func (m *TokenDetails) String() string

func (*TokenDetails) Unmarshal

func (m *TokenDetails) Unmarshal(dAtA []byte) error

func (*TokenDetails) Validate

func (t *TokenDetails) Validate() error

func (*TokenDetails) XXX_DiscardUnknown added in v0.12.0

func (m *TokenDetails) XXX_DiscardUnknown()

func (*TokenDetails) XXX_Marshal added in v0.12.0

func (m *TokenDetails) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TokenDetails) XXX_Merge added in v0.12.0

func (m *TokenDetails) XXX_Merge(src proto.Message)

func (*TokenDetails) XXX_Size added in v0.12.0

func (m *TokenDetails) XXX_Size() int

func (*TokenDetails) XXX_Unmarshal added in v0.12.0

func (m *TokenDetails) XXX_Unmarshal(b []byte) error

type UsernameToken

type UsernameToken struct {
	Base    *nft.NonFungibleToken `protobuf:"bytes,1,opt,name=base,proto3" json:"base,omitempty"`
	Details *TokenDetails         `protobuf:"bytes,2,opt,name=details,proto3" json:"details,omitempty"`
}

func (*UsernameToken) Approvals

func (u *UsernameToken) Approvals() *nft.ApprovalOps

func (*UsernameToken) Copy

func (u *UsernameToken) Copy() orm.CloneableData

func (*UsernameToken) Descriptor

func (*UsernameToken) Descriptor() ([]byte, []int)

func (*UsernameToken) GetBase

func (m *UsernameToken) GetBase() *nft.NonFungibleToken

func (*UsernameToken) GetChainAddresses

func (u *UsernameToken) GetChainAddresses() []ChainAddress

func (*UsernameToken) GetDetails

func (m *UsernameToken) GetDetails() *TokenDetails

func (*UsernameToken) Marshal

func (m *UsernameToken) Marshal() (dAtA []byte, err error)

func (*UsernameToken) MarshalTo

func (m *UsernameToken) MarshalTo(dAtA []byte) (int, error)

func (*UsernameToken) OwnerAddress

func (u *UsernameToken) OwnerAddress() weave.Address

func (*UsernameToken) ProtoMessage

func (*UsernameToken) ProtoMessage()

func (*UsernameToken) Reset

func (m *UsernameToken) Reset()

func (*UsernameToken) SetApprovals

func (m *UsernameToken) SetApprovals(a nft.Approvals)

func (*UsernameToken) SetChainAddresses

func (u *UsernameToken) SetChainAddresses(actor weave.Address, newAddresses []ChainAddress) error

func (*UsernameToken) Size

func (m *UsernameToken) Size() (n int)

func (*UsernameToken) String

func (m *UsernameToken) String() string

func (*UsernameToken) Transfer

func (u *UsernameToken) Transfer(newOwner weave.Address) error

func (*UsernameToken) Unmarshal

func (m *UsernameToken) Unmarshal(dAtA []byte) error

func (*UsernameToken) Validate

func (u *UsernameToken) Validate() error

func (*UsernameToken) XXX_DiscardUnknown added in v0.12.0

func (m *UsernameToken) XXX_DiscardUnknown()

func (*UsernameToken) XXX_Marshal added in v0.12.0

func (m *UsernameToken) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UsernameToken) XXX_Merge added in v0.12.0

func (m *UsernameToken) XXX_Merge(src proto.Message)

func (*UsernameToken) XXX_Size added in v0.12.0

func (m *UsernameToken) XXX_Size() int

func (*UsernameToken) XXX_Unmarshal added in v0.12.0

func (m *UsernameToken) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL