templates

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var KnownAddresses = templateVariables{
	"FungibleToken.cdc": knownAddresses{
		flow.Emulator: "0xee82856bf20e2aa6",
		flow.Testnet:  "0x9a0766d93b6608b7",
		flow.Mainnet:  "0xf233dcee88fe0abe",
	},
	"NonFungibleToken.cdc": knownAddresses{
		flow.Emulator: "0xf8d6e0586b0a20c7",
		flow.Testnet:  "0x631e88ae7f1d7c20",
		flow.Mainnet:  "0x1d7e57aa55817448",
	},
}

Functions

func CreateAccountAndInitFungibleTokenVaultsCode added in v0.11.0

func CreateAccountAndInitFungibleTokenVaultsCode(chainId flow.ChainID, tokens []template_strings.FungibleTokenInfo) (string, 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, error)

func FungibleSetupCode

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

func FungibleTransferCode

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

func GetTokenPaths added in v0.11.0

func GetTokenPaths(
	token *Token,
) (
	vaultPath string,
	receiverPath string,
	balancePath string,
	err error,
)

func InitFungibleTokenVaultsCode added in v0.11.0

func InitFungibleTokenVaultsCode(chainId flow.ChainID, tokens []template_strings.FungibleTokenInfo) (string, error)

func NewFungibleTokenInfo added in v0.11.0

func NewFungibleTokenInfo(t Token) template_strings.FungibleTokenInfo

func TokenCode

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

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 (*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) ListFull added in v0.11.0

func (s *GormStore) ListFull(tType TokenType) ([]Token, error)

func (*GormStore) Remove

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

type Service

type Service interface {
	AddToken(t *Token) error
	ListTokens(tType TokenType) ([]BasicToken, error)
	ListTokensFull(tType TokenType) ([]Token, error)
	GetTokenById(id uint64) (*Token, error)
	GetTokenByName(name string) (*Token, error)
	RemoveToken(id uint64) error
	TokenFromEvent(e flow.Event) (*Token, error)
}

func NewService

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

type ServiceImpl added in v0.10.0

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

func (*ServiceImpl) AddToken added in v0.10.0

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

func (*ServiceImpl) GetTokenById added in v0.10.0

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

func (*ServiceImpl) GetTokenByName added in v0.10.0

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

func (*ServiceImpl) ListTokens added in v0.10.0

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

func (*ServiceImpl) ListTokensFull added in v0.11.0

func (s *ServiceImpl) ListTokensFull(tType TokenType) ([]Token, error)

func (*ServiceImpl) RemoveToken added in v0.10.0

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

func (*ServiceImpl) TokenFromEvent added in v0.10.0

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

type Store

type Store interface {
	Insert(*Token) error
	List(TokenType) ([]BasicToken, error)
	ListFull(TokenType) ([]Token, 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.

func NewGormStore

func NewGormStore(db *gorm.DB) Store

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"`          // (deprecated) For generic fungible token transaction templates
	ReceiverPublicPath string    `json:"receiverPublicPath,omitempty"`
	BalancePublicPath  string    `json:"balancePublicPath,omitempty"`
	VaultStoragePath   string    `json:"vaultStoragePath,omitempty"`
	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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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