templates

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventTokensDeposited = "TokensDeposited" // FungibleToken
	EventDeposit         = "Deposit"         // NonFungibleToken
)

Variables

This section is empty.

Functions

func AsCadence

func AsCadence(a *Argument) (cadence.Value, error)

func DepositEventTypeFromToken

func DepositEventTypeFromToken(token BasicToken) string

func DepositNameFromTokenType

func DepositNameFromTokenType(tokenType string) string

func EventType

func EventType(address, tokenName, eventName string) string

func FungibleBalanceCode

func FungibleBalanceCode(chainId flow.ChainID, token *Token) string

func FungibleSetupCode

func FungibleSetupCode(chainId flow.ChainID, token *Token) string

func FungibleTransferCode

func FungibleTransferCode(chainId flow.ChainID, token *Token) string

func MustDecodeArgs

func MustDecodeArgs(aa []Argument) []cadence.Value

func TokenCode

func TokenCode(chainId flow.ChainID, token *Token, tmplStr string) string

Types

type BasicToken

type BasicToken struct {
	ID      uint64    `json:"id,omitempty"`
	Name    string    `json:"name"`
	Address string    `json:"address"`
	Type    TokenType `json:"type"`
}

BasicToken is a simplifed representation of a Token used in listings

type GormStore

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

func NewGormStore

func NewGormStore(db *gorm.DB) *GormStore

func (*GormStore) GetById

func (s *GormStore) GetById(id uint64) (*Token, error)

func (*GormStore) GetByName

func (s *GormStore) GetByName(name string) (*Token, error)

func (*GormStore) Insert

func (s *GormStore) Insert(q *Token) error

func (*GormStore) InsertTemp

func (s *GormStore) InsertTemp(token *Token)

func (*GormStore) List

func (s *GormStore) List(tType TokenType) (*[]BasicToken, error)

func (*GormStore) Remove

func (s *GormStore) Remove(id uint64) error

type Raw

type Raw struct {
	Code      string     `json:"code" gorm:"-"`
	Arguments []Argument `json:"arguments" gorm:"-"`
}

TODO: should this actually be called Transaction or something similar?

type Service

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

func NewService

func NewService(cfg *configs.Config, store Store) *Service

func (*Service) AddToken

func (s *Service) AddToken(t *Token) error

func (*Service) GetTokenById

func (s *Service) GetTokenById(id uint64) (*Token, error)

func (*Service) GetTokenByName

func (s *Service) GetTokenByName(name string) (*Token, error)

func (*Service) ListTokens

func (s *Service) ListTokens(tType TokenType) (*[]BasicToken, error)

func (*Service) RemoveToken

func (s *Service) RemoveToken(id uint64) error

func (*Service) TokenFromEvent

func (s *Service) TokenFromEvent(e flow.Event) (*Token, error)

type Store

type Store interface {
	Insert(*Token) error
	List(TokenType) (*[]BasicToken, error)
	GetById(id uint64) (*Token, error)
	GetByName(name string) (*Token, error)
	Remove(id uint64) error
	// Insert a token that is available only for this instances runtime (in-memory)
	// Used when enabling a token via environment variables
	InsertTemp(*Token)
}

Store manages data regarding templates.

type Token

type Token struct {
	ID            uint64    `json:"id,omitempty"`
	Name          string    `json:"name" gorm:"uniqueIndex;not null"` // Declaration name
	NameLowerCase string    `json:"nameLowerCase,omitempty"`          // For generic fungible token transaction templates
	Address       string    `json:"address" gorm:"not null"`
	Setup         string    `json:"setup,omitempty"`    // Setup cadence code
	Transfer      string    `json:"transfer,omitempty"` // Transfer cadence code
	Balance       string    `json:"balance,omitempty"`  // Balance cadence code
	Type          TokenType `json:"type"`
}

func (Token) BasicToken

func (token Token) BasicToken() BasicToken

type TokenType

type TokenType int
const (
	NotSpecified TokenType = iota
	FT
	NFT
)

func TypeFromText

func TypeFromText(text string) TokenType

func (TokenType) MarshalText

func (s TokenType) MarshalText() ([]byte, error)

func (TokenType) String

func (i TokenType) String() string

func (*TokenType) UnmarshalText

func (s *TokenType) UnmarshalText(text []byte) error

type TransactionBuilder

type TransactionBuilder struct {
	Tx *flow.Transaction
}

func NewBuilderFromRaw

func NewBuilderFromRaw(raw Raw) (*TransactionBuilder, error)

func NewBuilderFromTx

func NewBuilderFromTx(tx *flow.Transaction) *TransactionBuilder

func (*TransactionBuilder) AddArgument

func (b *TransactionBuilder) AddArgument(a Argument) error

func (*TransactionBuilder) GetArgument

func (b *TransactionBuilder) GetArgument(index int) (cadence.Value, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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