Documentation ¶
Index ¶
- Constants
- type AccountAddedHandler
- type AccountToken
- type Balance
- type ChainEventHandler
- type Details
- type GormStore
- func (s *GormStore) AccountTokens(address string, tokenType templates.TokenType) (att []AccountToken, err error)
- func (s *GormStore) InsertAccountToken(at *AccountToken) error
- func (s *GormStore) InsertTokenTransfer(t *TokenTransfer) error
- func (s *GormStore) TokenDeposit(address, transactionId string, token *templates.Token) (t *TokenTransfer, err error)
- func (s *GormStore) TokenDeposits(address string, token *templates.Token) (tt []*TokenTransfer, err error)
- func (s *GormStore) TokenWithdrawal(address, transactionId string, token *templates.Token) (t *TokenTransfer, err error)
- func (s *GormStore) TokenWithdrawals(address string, token *templates.Token) (tt []*TokenTransfer, err error)
- type Service
- type ServiceImpl
- func (s *ServiceImpl) AccountTokens(address string, tType templates.TokenType) ([]AccountToken, error)
- func (s *ServiceImpl) AddAccountToken(tokenName, address string) error
- func (s *ServiceImpl) CreateWithdrawal(ctx context.Context, sync bool, sender string, request WithdrawalRequest) (*jobs.Job, *transactions.Transaction, error)
- func (s *ServiceImpl) DeployTokenContractForAccount(ctx context.Context, runSync bool, tokenName, address string) error
- func (s *ServiceImpl) Details(ctx context.Context, tokenName, address string) (*Details, error)
- func (s *ServiceImpl) GetDeposit(address, tokenName, transactionId string) (*TokenDeposit, error)
- func (s *ServiceImpl) GetWithdrawal(address, tokenName, transactionId string) (*TokenWithdrawal, error)
- func (s *ServiceImpl) ListDeposits(address, tokenName string) ([]*TokenDeposit, error)
- func (s *ServiceImpl) ListWithdrawals(address, tokenName string) ([]*TokenWithdrawal, error)
- func (s *ServiceImpl) RegisterDeposit(ctx context.Context, token *templates.Token, transactionId flow.Identifier, ...) error
- func (s *ServiceImpl) Setup(ctx context.Context, sync bool, tokenName, address string) (*jobs.Job, *transactions.Transaction, error)
- type Store
- type TokenDeposit
- type TokenTransfer
- type TokenTransferBase
- type TokenWithdrawal
- type WithdrawalRequest
Constants ¶
View Source
const WithdrawalCreateJobType = "withdrawal_create"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountAddedHandler ¶
func (*AccountAddedHandler) Handle ¶
func (h *AccountAddedHandler) Handle(payload accounts.AccountAddedPayload)
type AccountToken ¶
type AccountToken struct { ID uint64 `json:"-" gorm:"column:id;primaryKey"` AccountAddress string `json:"-" gorm:"column:account_address;uniqueIndex:addressname;index;not null"` Account accounts.Account `json:"-" gorm:"foreignKey:AccountAddress;references:Address;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"` TokenName string `json:"name" gorm:"column:token_name;uniqueIndex:addressname;index;not null"` TokenAddress string `json:"address" gorm:"column:token_address;uniqueIndex:addressname;index;not null"` TokenType templates.TokenType `json:"-" gorm:"column:token_type"` CreatedAt time.Time `json:"-" gorm:"column:created_at"` UpdatedAt time.Time `json:"-" gorm:"column:updated_at"` DeletedAt gorm.DeletedAt `json:"-" gorm:"column:deleted_at;index"` }
AccountToken represents a token that is enabled on an account.
func (AccountToken) TableName ¶ added in v0.6.0
func (AccountToken) TableName() string
type Balance ¶
func (*Balance) MarshalJSON ¶
type ChainEventHandler ¶
type ChainEventHandler struct { AccountService accounts.Service ChainListener chain_events.Listener TemplateService templates.Service TokenService Service }
func (*ChainEventHandler) Handle ¶
func (h *ChainEventHandler) Handle(ctx context.Context, event flow.Event)
type GormStore ¶
type GormStore struct {
// contains filtered or unexported fields
}
func (*GormStore) AccountTokens ¶
func (*GormStore) InsertAccountToken ¶
func (s *GormStore) InsertAccountToken(at *AccountToken) error
func (*GormStore) InsertTokenTransfer ¶
func (s *GormStore) InsertTokenTransfer(t *TokenTransfer) error
func (*GormStore) TokenDeposit ¶
func (*GormStore) TokenDeposits ¶
func (*GormStore) TokenWithdrawal ¶
func (*GormStore) TokenWithdrawals ¶
type Service ¶
type Service interface { Setup(ctx context.Context, sync bool, tokenName, address string) (*jobs.Job, *transactions.Transaction, error) AddAccountToken(tokenName, address string) error AccountTokens(address string, tType templates.TokenType) ([]AccountToken, error) Details(ctx context.Context, tokenName, address string) (*Details, error) CreateWithdrawal(ctx context.Context, sync bool, sender string, request WithdrawalRequest) (*jobs.Job, *transactions.Transaction, error) ListWithdrawals(address, tokenName string) ([]*TokenWithdrawal, error) ListDeposits(address, tokenName string) ([]*TokenDeposit, error) GetWithdrawal(address, tokenName, transactionId string) (*TokenWithdrawal, error) GetDeposit(address, tokenName, transactionId string) (*TokenDeposit, error) RegisterDeposit(ctx context.Context, token *templates.Token, transactionId flow.Identifier, recipient accounts.Account, amountOrNftID string) error // DeployTokenContractForAccount is only used in tests DeployTokenContractForAccount(ctx context.Context, runSync bool, tokenName, address string) error }
func NewService ¶
func NewService( cfg *configs.Config, store Store, km keys.Manager, fc flow_helpers.FlowClient, wp jobs.WorkerPool, txs transactions.Service, tes templates.Service, acs accounts.Service, ) Service
type ServiceImpl ¶ added in v0.10.0
type ServiceImpl struct {
// contains filtered or unexported fields
}
func (*ServiceImpl) AccountTokens ¶ added in v0.10.0
func (s *ServiceImpl) AccountTokens(address string, tType templates.TokenType) ([]AccountToken, error)
func (*ServiceImpl) AddAccountToken ¶ added in v0.10.0
func (s *ServiceImpl) AddAccountToken(tokenName, address string) error
func (*ServiceImpl) CreateWithdrawal ¶ added in v0.10.0
func (s *ServiceImpl) CreateWithdrawal(ctx context.Context, sync bool, sender string, request WithdrawalRequest) (*jobs.Job, *transactions.Transaction, error)
func (*ServiceImpl) DeployTokenContractForAccount ¶ added in v0.10.0
func (s *ServiceImpl) DeployTokenContractForAccount(ctx context.Context, runSync bool, tokenName, address string) error
DeployTokenContractForAccount is used for testing purposes.
func (*ServiceImpl) Details ¶ added in v0.10.0
Details is used to get the accounts balance (or similar for NFTs) for a token.
func (*ServiceImpl) GetDeposit ¶ added in v0.10.0
func (s *ServiceImpl) GetDeposit(address, tokenName, transactionId string) (*TokenDeposit, error)
func (*ServiceImpl) GetWithdrawal ¶ added in v0.10.0
func (s *ServiceImpl) GetWithdrawal(address, tokenName, transactionId string) (*TokenWithdrawal, error)
func (*ServiceImpl) ListDeposits ¶ added in v0.10.0
func (s *ServiceImpl) ListDeposits(address, tokenName string) ([]*TokenDeposit, error)
func (*ServiceImpl) ListWithdrawals ¶ added in v0.10.0
func (s *ServiceImpl) ListWithdrawals(address, tokenName string) ([]*TokenWithdrawal, error)
func (*ServiceImpl) RegisterDeposit ¶ added in v0.10.0
func (s *ServiceImpl) RegisterDeposit(ctx context.Context, token *templates.Token, transactionId flow.Identifier, recipient accounts.Account, amountOrNftID string) error
RegisterDeposit is an internal API for registering token deposits from on-chain events.
func (*ServiceImpl) Setup ¶ added in v0.10.0
func (s *ServiceImpl) Setup(ctx context.Context, sync bool, tokenName, address string) (*jobs.Job, *transactions.Transaction, error)
type Store ¶
type Store interface { // List an accounts enabled tokens AccountTokens(address string, tokenType templates.TokenType) ([]AccountToken, error) // Enable a token for an account InsertAccountToken(at *AccountToken) error InsertTokenTransfer(*TokenTransfer) error TokenWithdrawals(address string, token *templates.Token) ([]*TokenTransfer, error) TokenWithdrawal(address, transactionId string, token *templates.Token) (*TokenTransfer, error) TokenDeposits(address string, token *templates.Token) ([]*TokenTransfer, error) TokenDeposit(address, transactionId string, token *templates.Token) (*TokenTransfer, error) }
Store manages data regarding tokens.
func NewGormStore ¶
type TokenDeposit ¶
type TokenDeposit struct { TokenTransferBase SenderAddress string `json:"sender"` }
TokenDeposit is used for JSON interfacing
type TokenTransfer ¶
type TokenTransfer struct { ID uint64 `gorm:"column:id;primaryKey"` TransactionId string `gorm:"column:transaction_id"` // TODO (latenssi): should propably be unique over this column Transaction transactions.Transaction `gorm:"foreignKey:TransactionId;references:TransactionId;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"` RecipientAddress string `gorm:"column:recipient_address;index"` SenderAddress string `gorm:"column:sender_address;index"` FtAmount string `gorm:"column:ft_amount"` NftID uint64 `gorm:"column:nft_id"` TokenName string `gorm:"column:token_name"` CreatedAt time.Time `gorm:"column:created_at"` UpdatedAt time.Time `gorm:"column:updated_at"` DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index"` }
TokenTransfer is used for database interfacing
func (*TokenTransfer) Deposit ¶
func (t *TokenTransfer) Deposit() TokenDeposit
func (TokenTransfer) TableName ¶ added in v0.6.0
func (TokenTransfer) TableName() string
func (*TokenTransfer) Withdrawal ¶
func (t *TokenTransfer) Withdrawal() TokenWithdrawal
type TokenTransferBase ¶
type TokenTransferBase struct { TransactionId string `json:"transactionId"` FtAmount string `json:"amount"` NftID uint64 `json:"nftId"` TokenName string `json:"token"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` }
TokenTransferBase is used for JSON interfacing
type TokenWithdrawal ¶
type TokenWithdrawal struct { TokenTransferBase RecipientAddress string `json:"recipient"` }
TokenWithdrawal is used for JSON interfacing
Click to show internal directories.
Click to hide internal directories.