accounts

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: 24 Imported by: 0

Documentation

Overview

Package account provides functions for account management on Flow blockhain.

Index

Constants

View Source
const AccountCreateJobType = "account_create"
View Source
const AccountTypeCustodial = "custodial"
View Source
const AccountTypeNonCustodial = "non-custodial"
View Source
const SyncAccountKeyCountJobType = "sync_account_key_count"

Variables

View Source
var AccountAdded accountAdded // singleton of type accountAdded

Functions

func AddContract

func AddContract(
	ctx context.Context,
	fc flow_helpers.FlowClient,
	km keys.Manager,
	accountAddress string,
	contract flow_templates.Contract,
	transactionTimeout time.Duration) error

AddContract is used only in tests

Types

type Account

type Account struct {
	Address   string          `json:"address" gorm:"primaryKey"`
	Keys      []keys.Storable `json:"keys" gorm:"foreignKey:AccountAddress;references:Address;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
	Type      AccountType     `json:"type" gorm:"default:custodial"`
	CreatedAt time.Time       `json:"createdAt" `
	UpdatedAt time.Time       `json:"updatedAt"`
	DeletedAt gorm.DeletedAt  `json:"-" gorm:"index"`
}

Account struct represents a storable account.

type AccountAddedPayload

type AccountAddedPayload struct {
	Address                   flow.Address
	InitializedFungibleTokens []templates.Token
}

type AccountType added in v0.7.0

type AccountType string

type GormStore

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

func (*GormStore) Account

func (s *GormStore) Account(address string) (a Account, err error)

func (*GormStore) Accounts

func (s *GormStore) Accounts(o datastore.ListOptions) (aa []Account, err error)

func (*GormStore) HardDeleteAccount added in v0.7.0

func (s *GormStore) HardDeleteAccount(a *Account) error

func (*GormStore) InsertAccount

func (s *GormStore) InsertAccount(a *Account) error

func (*GormStore) SaveAccount added in v0.10.0

func (s *GormStore) SaveAccount(a *Account) error

type Service

type Service interface {
	List(limit, offset int) (result []Account, err error)
	Create(ctx context.Context, sync bool) (*jobs.Job, *Account, error)
	AddNonCustodialAccount(address string) (*Account, error)
	DeleteNonCustodialAccount(address string) error
	SyncAccountKeyCount(ctx context.Context, address flow.Address) (*jobs.Job, error)
	Details(address string) (Account, error)
	InitAdminAccount(ctx context.Context) error
}

func NewService

func NewService(
	cfg *configs.Config,
	store Store,
	km keys.Manager,
	fc flow_helpers.FlowClient,
	wp jobs.WorkerPool,
	txs transactions.Service,
	temps templates.Service,
	opts ...ServiceOption,
) Service

NewService initiates a new account service.

type ServiceImpl added in v0.10.0

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

ServiceImpl defines the API for account management.

func (*ServiceImpl) AddNonCustodialAccount added in v0.10.0

func (s *ServiceImpl) AddNonCustodialAccount(address string) (*Account, error)

func (*ServiceImpl) Create added in v0.10.0

func (s *ServiceImpl) Create(ctx context.Context, sync bool) (*jobs.Job, *Account, error)

Create calls account.New to generate a new account. It receives a new account with a corresponding private key or resource ID and stores both in datastore. It returns a job, the new account and a possible error.

func (*ServiceImpl) DeleteNonCustodialAccount added in v0.10.0

func (s *ServiceImpl) DeleteNonCustodialAccount(address string) error

func (*ServiceImpl) Details added in v0.10.0

func (s *ServiceImpl) Details(address string) (Account, error)

Details returns a specific account, does not include private keys

func (*ServiceImpl) InitAdminAccount added in v0.10.0

func (s *ServiceImpl) InitAdminAccount(ctx context.Context) error

func (*ServiceImpl) List added in v0.10.0

func (s *ServiceImpl) List(limit, offset int) (result []Account, err error)

List returns all accounts in the datastore.

func (*ServiceImpl) SyncAccountKeyCount added in v0.10.0

func (s *ServiceImpl) SyncAccountKeyCount(ctx context.Context, address flow.Address) (*jobs.Job, error)

SyncKeyCount syncs number of keys for given account

type ServiceOption added in v0.9.0

type ServiceOption func(*ServiceImpl)

func WithTxRatelimiter added in v0.9.0

func WithTxRatelimiter(limiter ratelimit.Limiter) ServiceOption

type Store

type Store interface {
	// List all accounts.
	Accounts(datastore.ListOptions) ([]Account, error)

	// Get account details.
	Account(address string) (Account, error)

	// Insert a new account.
	InsertAccount(a *Account) error

	// Update an existing account.
	SaveAccount(a *Account) error

	// Permanently delete an account, despite of `DeletedAt` field.
	HardDeleteAccount(a *Account) error
}

Store manages data regarding accounts.

func NewGormStore

func NewGormStore(db *gorm.DB) Store

Jump to

Keyboard shortcuts

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