token

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (

	// RateDecimal is the number of decimal places in the rate
	RateDecimal = 8
)

Variables

View Source
var ErrFeeAddressNotConfigured = errors.New("fee address is not set in token config")

Functions

This section is empty.

Types

type BaseToken

type BaseToken struct {
	core.BaseContract
	// contains filtered or unexported fields
}

BaseToken represents a chaincode with configurable token-attributes. Implements core.BaseContractInterface by embedding core.BaseContract.

func (*BaseToken) ApplyTokenConfig

func (bt *BaseToken) ApplyTokenConfig(config *proto.TokenConfig) error

func (*BaseToken) CheckLimitsAndPrice

func (bt *BaseToken) CheckLimitsAndPrice(method string, amount *big.Int, currency string) (*big.Int, error)

CheckLimitsAndPrice checks limits and price

func (*BaseToken) EmissionAdd

func (bt *BaseToken) EmissionAdd(amount *big.Int) error

EmissionAdd adds emission

func (*BaseToken) EmissionSub

func (bt *BaseToken) EmissionSub(amount *big.Int) error

EmissionSub subtracts emission

func (*BaseToken) FeeAddressSetter

func (bt *BaseToken) FeeAddressSetter() *types.Address

FeeAddressSetter returns the fee address setter of the token

func (*BaseToken) FeeSetter

func (bt *BaseToken) FeeSetter() *types.Address

FeeSetter returns the fee setter of the token

func (*BaseToken) GetID

func (bt *BaseToken) GetID() string

GetID returns the ID of the token

func (*BaseToken) GetRateAndLimits

func (bt *BaseToken) GetRateAndLimits(dealType string, currency string) (*proto.TokenRate, bool, error)

GetRateAndLimits returns rate and limits for the deal type and currency

func (*BaseToken) Issuer

func (bt *BaseToken) Issuer() *types.Address

Issuer returns the issuer of the token

func (*BaseToken) QueryAllowedBalanceOf

func (bt *BaseToken) QueryAllowedBalanceOf(address *types.Address, token string) (*big.Int, error)

QueryAllowedBalanceOf returns allowed balance

func (*BaseToken) QueryBalanceOf

func (bt *BaseToken) QueryBalanceOf(address *types.Address) (*big.Int, error)

QueryBalanceOf returns balance

func (*BaseToken) QueryDocumentsList

func (bt *BaseToken) QueryDocumentsList() ([]core.Doc, error)

QueryDocumentsList - returns list of emission documents

func (*BaseToken) QueryGetFeeTransfer

func (bt *BaseToken) QueryGetFeeTransfer(req FeeTransferRequestDTO) (*FeeTransferResponseDTO, error)

func (*BaseToken) QueryLockedAllowedBalanceOf added in v0.0.2

func (bt *BaseToken) QueryLockedAllowedBalanceOf(address *types.Address, token string) (*big.Int, error)

func (*BaseToken) QueryLockedBalanceOf added in v0.0.2

func (bt *BaseToken) QueryLockedBalanceOf(address *types.Address) (*big.Int, error)

QueryLockedBalanceOf returns locked balance

func (*BaseToken) QueryMetadata

func (bt *BaseToken) QueryMetadata() (*Metadata, error)

QueryMetadata returns Metadata

func (*BaseToken) QueryPredictFee

func (bt *BaseToken) QueryPredictFee(amount *big.Int) (*Predict, error)

QueryPredictFee returns the predicted fee

func (*BaseToken) TokenConfig

func (bt *BaseToken) TokenConfig() *proto.TokenConfig

func (*BaseToken) TxAddDocs

func (bt *BaseToken) TxAddDocs(sender *types.Sender, rawDocs string) error

TxAddDocs - adds docs to a token

func (*BaseToken) TxAllowedIndustrialBalanceTransfer

func (bt *BaseToken) TxAllowedIndustrialBalanceTransfer(sender *types.Sender, recipient *types.Address, rawAssets string, _ string) error

TxAllowedIndustrialBalanceTransfer transfers tokens from one account to another

func (*BaseToken) TxBuyBack

func (bt *BaseToken) TxBuyBack(sender *types.Sender, amount *big.Int, currency string) error

TxBuyBack buys back tokens for an asset

func (*BaseToken) TxBuyToken

func (bt *BaseToken) TxBuyToken(sender *types.Sender, amount *big.Int, currency string) error

TxBuyToken buys tokens for an asset

func (*BaseToken) TxDeleteDoc

func (bt *BaseToken) TxDeleteDoc(sender *types.Sender, docID string) error

TxDeleteDoc - deletes doc from state

func (*BaseToken) TxDeleteRate

func (bt *BaseToken) TxDeleteRate(sender *types.Sender, dealType string, currency string) error

TxDeleteRate - deletes rate from state

func (*BaseToken) TxSetFee

func (bt *BaseToken) TxSetFee(sender *types.Sender, currency string, fee *big.Int, floor *big.Int, cap *big.Int) error

TxSetFee sets the fee

func (*BaseToken) TxSetFeeAddress

func (bt *BaseToken) TxSetFeeAddress(sender *types.Sender, address *types.Address) error

TxSetFeeAddress sets the fee address

func (*BaseToken) TxSetLimits

func (bt *BaseToken) TxSetLimits(sender *types.Sender, dealType string, currency string, min *big.Int, max *big.Int) error

TxSetLimits sets limits for a deal type and an asset

func (*BaseToken) TxSetRate

func (bt *BaseToken) TxSetRate(sender *types.Sender, dealType string, currency string, rate *big.Int) error

TxSetRate sets token rate to an asset for a type of deal

func (*BaseToken) TxTransfer

func (bt *BaseToken) TxTransfer(
	sender *types.Sender,
	recipient *types.Address,
	amount *big.Int,
	_ string,
) error

TxTransfer transfers tokens from one account to another

func (*BaseToken) ValidateTokenConfig

func (bt *BaseToken) ValidateTokenConfig(config []byte) error

type Fee

type Fee struct {
	Address  string   `json:"address"`
	Currency string   `json:"currency"`
	Fee      *big.Int `json:"fee"`
	Floor    *big.Int `json:"floor"`
	Cap      *big.Int `json:"cap"`
}

Fee is a struct for fee

type FeeTransferRequestDTO

type FeeTransferRequestDTO struct {
	SenderAddress    *types.Address `json:"sender_address,omitempty"`
	RecipientAddress *types.Address `json:"recipient_address,omitempty"`
	Amount           *big.Int       `json:"amount,omitempty"`
}

func (FeeTransferRequestDTO) Validate

func (r FeeTransferRequestDTO) Validate() error

type FeeTransferResponseDTO

type FeeTransferResponseDTO struct {
	FeeAddress *types.Address `json:"fee_address,omitempty"`
	Amount     *big.Int       `json:"amount,omitempty"`
	Currency   string         `json:"currency,omitempty"`
}

type Metadata

type Metadata struct {
	Name            string          `json:"name"`
	Symbol          string          `json:"symbol"`
	Decimals        uint            `json:"decimals"`
	UnderlyingAsset string          `json:"underlying_asset"` //nolint:tagliatelle
	Issuer          string          `json:"issuer"`
	Methods         []string        `json:"methods"`
	TotalEmission   *big.Int        `json:"total_emission"` //nolint:tagliatelle
	Fee             *Fee            `json:"fee"`
	Rates           []*MetadataRate `json:"rates"`
}

Metadata is a struct for metadata

type MetadataRate

type MetadataRate struct {
	DealType string   `json:"deal_type"` //nolint:tagliatelle
	Currency string   `json:"currency"`
	Rate     *big.Int `json:"rate"`
	Min      *big.Int `json:"min"`
	Max      *big.Int `json:"max"`
}

MetadataRate is a struct for rate

type Predict

type Predict struct {
	// Currency is the currency of the fee
	Currency string `json:"currency"`
	// Fee is the predicted fee
	Fee *big.Int `json:"fee"`
}

Predict is a struct for fee prediction

type Tokener

type Tokener interface {
	core.BaseContractInterface
	contract.TokenConfigurator

	EmissionAdd(*big.Int) error
	EmissionSub(*big.Int) error
	GetRateAndLimits(string, string) (*proto.TokenRate, bool, error)
}

Tokener is the interface for tokens

type VT

type VT struct {
	// BaseToken is the base token
	BaseToken
}

VT is a test token

func (*VT) TxEmitToken

func (vt *VT) TxEmitToken(sender *types.Sender, amount *big.Int) error

TxEmitToken emits tokens

Jump to

Keyboard shortcuts

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