v039

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccessMint     = "mint"
	AccessBurn     = "burn"
	AccessDeposit  = "deposit"
	AccessWithdraw = "withdraw"
	AccessDelete   = "delete"
	AccessAdmin    = "grant"

	AllPermissions    = "mint,burn,deposit,withdraw,delete,grant"
	SupplyPermissions = "mint,burn"
	AssetPermissions  = "deposit,withdraw"
	ModuleName        = "marker"
)

Variables

This section is empty.

Functions

func MarkerAddress

func MarkerAddress(denom string) (sdk.AccAddress, error)

MarkerAddress returns the module account address for the given denomination

func MustGetMarkerAddress

func MustGetMarkerAddress(denom string) sdk.AccAddress

func RegisterLegacyAminoCodec added in v0.1.5

func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)

func ValidMarkerStatus

func ValidMarkerStatus(markerStatus MarkerStatus) bool

ValidMarkerStatus returns true if the marker status is valid and false otherwise.

func ValidateGrants

func ValidateGrants(grants ...AccessGrant) error

ValidateGrants checks a collection of grants and returns any errors encountered or nil

Types

type AccessGrant

type AccessGrant struct {
	Permissions []string       `json:"permissions" yaml:"permissions"`
	Address     sdk.AccAddress `json:"address" yaml:"address"`
}

AccessGrant is a structure for assigning a set of marker management permissions to an address

func GrantsForAddress

func GrantsForAddress(account sdk.AccAddress, grants ...AccessGrant) AccessGrant

GrantsForAddress return

func NewAccessGrant

func NewAccessGrant(address sdk.AccAddress, permissions []string) *AccessGrant

NewAccessGrant creates a new AccessGrant object

func (*AccessGrant) AddPermission

func (ag *AccessGrant) AddPermission(permission string) error

AddPermission adds the given permission to this grant if not included

func (AccessGrant) Equals

func (ag AccessGrant) Equals(other AccessGrant) bool

Equals returns true if both AccessGrants has the same address and list of permissions.

func (AccessGrant) GetAddress

func (ag AccessGrant) GetAddress() sdk.AccAddress

GetAddress returns the address the AccessGrant is for

func (AccessGrant) GetPermissions

func (ag AccessGrant) GetPermissions() []string

GetPermissions returns the permissions granted to the address

func (AccessGrant) HasPermission

func (ag AccessGrant) HasPermission(permission string) bool

HasPermission returns true if the AccessGrant allows the given permission

func (*AccessGrant) MergeAdd

func (ag *AccessGrant) MergeAdd(other AccessGrant) error

MergeAdd looks for any missing permissions in the given grant and adds them to this instance.

func (*AccessGrant) MergeRemove

func (ag *AccessGrant) MergeRemove(other AccessGrant) error

MergeRemove looks for permissions in this instance that exist in the given grant and removes them.

func (*AccessGrant) RemovePermission

func (ag *AccessGrant) RemovePermission(permission string) error

RemovePermission removes the given permission from this grant (if included)

func (AccessGrant) Validate

func (ag AccessGrant) Validate() error

Validate performs checks to ensure this acccess grant is properly formed.

type AccessGrantI added in v0.1.5

type AccessGrantI interface {
	Validate() error
	GetAddress() sdk.AccAddress

	HasPermission(string) bool
	GetPermissions() []string

	AddPermission(string) error
	RemovePermission(string) error

	MergeAdd(AccessGrant) error
	MergeRemove(AccessGrant) error
}

AccessGrant defines an interface for interacting with roles assigned to a given address.

type GenesisState

type GenesisState struct {
	Markers []MarkerAccount `json:"markers"`
}

GenesisState is the initial marker module state.

type MarkerAccount

type MarkerAccount struct {
	*authtypes.BaseAccount

	// Address that owns the marker configuration.  This account must sign any requests
	// to change marker config (only valid for statuses prior to finalization)
	Manager sdk.AccAddress `json:"manager,omitempty" yaml:"manager"`
	// Access control lists
	AccessControls []AccessGrant `json:"accesscontrol,omitempty" yaml:"accesscontrol"`

	// Indicates the current status of this marker record.
	Status MarkerStatus `json:"status" yaml:"status"`

	// value denomination and total supply for the token.
	Denom  string  `json:"denom" yaml:"denom"`
	Supply sdk.Int `json:"total_supply" yaml:"total_supply"`
	// Marker type information
	MarkerType string `json:"type,omitempty" yaml:"type"`
}

MarkerAccount is a configuration structure that defines a Token and the resulting supply of coins.

func NewEmptyMarkerAccount

func NewEmptyMarkerAccount(denom string, grants []AccessGrant) *MarkerAccount

NewEmptyMarkerAccount creates a new empty marker account in a Proposed state

func NewMarkerAccount

func NewMarkerAccount(
	baseAcc *authtypes.BaseAccount,
	totalSupply sdk.Coin,
	accessControls []AccessGrant,
	status MarkerStatus,
	markerType string,
) *MarkerAccount

NewMarkerAccount creates a marker account initialized over a given base account.

func (*MarkerAccount) AddressHasPermission

func (ma *MarkerAccount) AddressHasPermission(addr sdk.AccAddress, role string) bool

AddressHasPermission returns true if the provided address has been assigned the provided role within the current MarkerAccount AccessControls

func (*MarkerAccount) AddressListForPermission

func (ma *MarkerAccount) AddressListForPermission(role string) []sdk.AccAddress

AddressListForPermission returns a list of all addresses with the provided rule within the current MarkerAccount AccessControls list

func (MarkerAccount) Equals

func (ma MarkerAccount) Equals(other MarkerAccount) bool

Equals returns true if this MarkerAccount is equal to other MarkerAccount in all properties

func (MarkerAccount) GetDenom

func (ma MarkerAccount) GetDenom() string

GetDenom the denomination of the coin associated with this marker

func (MarkerAccount) GetManager

func (ma MarkerAccount) GetManager() sdk.AccAddress

GetManager returns the address of the account that is responsible for the proposed marker.

func (MarkerAccount) GetMarkerType

func (ma MarkerAccount) GetMarkerType() string

GetMarkerType returns the type of the marker account.

func (MarkerAccount) GetStatus

func (ma MarkerAccount) GetStatus() string

GetStatus returns the status of the marker account.

func (MarkerAccount) GetSupply

func (ma MarkerAccount) GetSupply() sdk.Coin

GetSupply implements authtypes.Account

func (*MarkerAccount) GrantAccess

func (ma *MarkerAccount) GrantAccess(access AccessGrant) error

GrantAccess appends the access grant to the marker account.

func (MarkerAccount) MarshalJSON

func (ma MarkerAccount) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON representation of a MarkerAccount.

func (MarkerAccount) MarshalYAML

func (ma MarkerAccount) MarshalYAML() (interface{}, error)

MarshalYAML returns the YAML representation of a MarkerAccount.

func (*MarkerAccount) RevokeAccess

func (ma *MarkerAccount) RevokeAccess(addr sdk.AccAddress) error

RevokeAccess removes any AccessGrant for the given address on this marker.

func (*MarkerAccount) SetManager

func (ma *MarkerAccount) SetManager(manager sdk.AccAddress) error

SetManager sets the manager/owner address for proposed marker accounts

func (*MarkerAccount) SetPubKey

func (ma *MarkerAccount) SetPubKey(pubKey cryptotypes.PubKey) error

SetPubKey implements authtypes.Account (but there are no public keys associated with the account for signing)

func (*MarkerAccount) SetSequence

func (ma *MarkerAccount) SetSequence(seq uint64) error

SetSequence implements authtypes.Account (but you can't set a sequence as you can't sign tx for this account)

func (*MarkerAccount) SetStatus

func (ma *MarkerAccount) SetStatus(newStatus string) error

SetStatus sets the status of the marker to the provided value.

func (*MarkerAccount) SetSupply

func (ma *MarkerAccount) SetSupply(total sdk.Coin) error

SetSupply sets the total supply amount to track

func (MarkerAccount) String

func (ma MarkerAccount) String() string

func (*MarkerAccount) UnmarshalJSON

func (ma *MarkerAccount) UnmarshalJSON(bz []byte) error

UnmarshalJSON un-marshals raw JSON bytes into a MarkerAccount.

func (MarkerAccount) Validate

func (ma MarkerAccount) Validate() error

Validate performs minimal sanity checking over the current MarkerAccount instance

type MarkerAccountI added in v0.1.5

type MarkerAccountI interface {
	v038auth.Account

	Validate() error

	GetDenom() string
	GetManager() sdk.AccAddress
	GetMarkerType() string

	GetStatus() string
	SetStatus(string) error

	GetSupply() sdk.Coin
	SetSupply(sdk.Coin) error

	GrantAccess(AccessGrant) error
	RevokeAccess(sdk.AccAddress) error

	AddressHasPermission(sdk.AccAddress, string) bool
	AddressListForPermission(string) []sdk.AccAddress
}

MarkerAccount defines a marker account interface for modules that interact with markers

type MarkerAssets

type MarkerAssets struct {
	// Address of the marker
	Address sdk.AccAddress `json:"address" yaml:"address"`
	// List of scope uuids that have the marker as a party member
	ScopeID []string `json:"scope_id" yaml:"scope_id"`
}

MarkerAssets is a list of scope ids that a given address (of a marker) is associated with

type MarkerStatus

type MarkerStatus byte

MarkerStatus defines the status type of the marker record

const (
	// Invalid/uninitialized
	StatusUndefined MarkerStatus = 0x00

	// Initial configuration period, updates allowed, token supply not created.
	StatusProposed MarkerStatus = 0x01

	// Configuration finalized, ready for supply creation
	StatusFinalized MarkerStatus = 0x02

	// Supply is created, rules are in force.
	StatusActive MarkerStatus = 0x03

	// Marker has been cancelled, pending destroy
	StatusCancelled MarkerStatus = 0x04

	// Marker supply has all been recalled, marker is considered destroyed and no further actions allowed.
	StatusDestroyed MarkerStatus = 0x05
)

Marker state types

func MarkerStatusFromString

func MarkerStatusFromString(str string) (MarkerStatus, error)

MarkerStatusFromString returns a MarkerStatus from a string. It returns an error if the string is invalid.

func MustGetMarkerStatus

func MustGetMarkerStatus(str string) MarkerStatus

MustGetMarkerStatus turns the string into a MarkerStatus typed value ... panics if invalid.

func (MarkerStatus) Format

func (rt MarkerStatus) Format(s fmt.State, verb rune)

Format implements the fmt.Formatter interface.

func (MarkerStatus) Marshal

func (rt MarkerStatus) Marshal() ([]byte, error)

Marshal needed for protobuf compatibility.

func (MarkerStatus) MarshalJSON

func (rt MarkerStatus) MarshalJSON() ([]byte, error)

MarshalJSON using string.

func (MarkerStatus) String

func (rt MarkerStatus) String() string

String implements the Stringer interface.

func (*MarkerStatus) Unmarshal

func (rt *MarkerStatus) Unmarshal(data []byte) error

Unmarshal needed for protobuf compatibility.

func (*MarkerStatus) UnmarshalJSON

func (rt *MarkerStatus) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes from JSON string version of this status

Jump to

Keyboard shortcuts

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