services

package
v0.33.1-sc-m5 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: Apache-2.0 Imports: 17 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Accounts

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

Accounts is a service that handles all account-related interactions.

func NewAccounts

func NewAccounts(
	gateway gateway.Gateway,
	state *flowkit.State,
	logger output.Logger,
) *Accounts

NewAccounts returns a new accounts service.

func (*Accounts) AddContract

func (a *Accounts) AddContract(
	account *flowkit.Account,
	contractName string,
	contractSource []byte,
	updateExisting bool,
) (*flow.Account, error)

AddContract deploys a contract code to the account provided with possible update flag.

func (*Accounts) Create

func (a *Accounts) Create(
	signer *flowkit.Account,
	pubKeys []crypto.PublicKey,
	keyWeights []int,
	sigAlgo []crypto.SignatureAlgorithm,
	hashAlgo []crypto.HashAlgorithm,
	contractArgs []string,
) (*flow.Account, error)

Create creates and returns a new account.

The new account is created with the given public keys and contracts.

The account creation transaction is signed by the specified signer.

func (*Accounts) Get

func (a *Accounts) Get(address flow.Address) (*flow.Account, error)

Get returns an account by on address.

func (*Accounts) NodeTotalStake added in v0.30.3

func (a *Accounts) NodeTotalStake(nodeId string, chain flow.ChainID) (*cadence.Value, error)

NodeTotalStake returns the total stake including delegations of a node.

func (*Accounts) RemoveContract

func (a *Accounts) RemoveContract(
	account *flowkit.Account,
	contractName string,
) (*flow.Account, error)

RemoveContract removes a contract from an account and returns the updated account.

func (*Accounts) StakingInfo

func (a *Accounts) StakingInfo(address flow.Address) ([]map[string]interface{}, []map[string]interface{}, error)

StakingInfo returns the staking and delegation information for an account.

type Blocks

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

Blocks is a service that handles all block-related interactions.

func NewBlocks

func NewBlocks(
	gateway gateway.Gateway,
	state *flowkit.State,
	logger output.Logger,
) *Blocks

NewBlocks returns a new blocks service.

func (*Blocks) GetBlock

func (e *Blocks) GetBlock(
	query string,
	eventType string,
	verbose bool,
) (*flow.Block, []client.BlockEvents, []*flow.Collection, error)

GetBlock returns a block based on the provided query string.

Query string options: - "latest" : return the latest block - height (e.g. 123456789) : return block at this height - ID : return block with this ID

func (*Blocks) GetLatestBlockHeight added in v0.27.0

func (e *Blocks) GetLatestBlockHeight() (uint64, error)

GetLatestBlockHeight returns the latest block height

type Collections

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

Collections is aa service that handles all collection-related interactions.

func NewCollections

func NewCollections(
	gateway gateway.Gateway,
	state *flowkit.State,
	logger output.Logger,
) *Collections

NewCollections returns a new collections service.

func (*Collections) Get

func (c *Collections) Get(id flow.Identifier) (*flow.Collection, error)

Get returns a collection by ID.

type EventWorkerResult added in v0.27.0

type EventWorkerResult struct {
	Events []client.BlockEvents
	Error  error
}

type Events

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

Events is a service that handles all event-related interactions.

func NewEvents

func NewEvents(
	gateway gateway.Gateway,
	state *flowkit.State,
	logger output.Logger,
) *Events

NewEvents returns a new events service.

func (*Events) Get

func (e *Events) Get(events []string, startHeight uint64, endHeight uint64, blockCount uint64, workerCount int) ([]client.BlockEvents, error)

type Keys

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

Keys is a service that handles all key-related interactions.

func NewKeys

func NewKeys(
	gateway gateway.Gateway,
	state *flowkit.State,
	logger output.Logger,
) *Keys

NewKeys returns a new keys service.

func (*Keys) DecodePEM

func (k *Keys) DecodePEM(key string, sigAlgo crypto.SignatureAlgorithm) (*flow.AccountKey, error)

DecodePEM decodes a PEM encoded public key with specified signature algorithm.

func (*Keys) DecodeRLP

func (k *Keys) DecodeRLP(publicKey string) (*flow.AccountKey, error)

DecodeRLP decodes an RLP encoded public key

func (*Keys) Generate

func (k *Keys) Generate(inputSeed string, sigAlgo crypto.SignatureAlgorithm) (crypto.PrivateKey, error)

Generate generates a new private key from the given seed and signature algorithm.

type Project

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

Project is a service that handles all interactions for a state.

func NewProject

func NewProject(
	gateway gateway.Gateway,
	state *flowkit.State,
	logger output.Logger,
) *Project

NewProject returns a new state service.

func (*Project) Deploy

func (p *Project) Deploy(network string, update bool) ([]*contracts.Contract, error)

Deploy the project for the provided network.

Retrieve all the contracts for specified network, sort them for deployment deploy one by one and replace the imports in the contract source so it corresponds to the account address the contract was deployed to.

func (*Project) Init

func (p *Project) Init(
	readerWriter flowkit.ReaderWriter,
	reset bool,
	global bool,
	sigAlgo crypto.SignatureAlgorithm,
	hashAlgo crypto.HashAlgorithm,
	serviceKey crypto.PrivateKey,
) (*flowkit.State, error)

Init initializes a new project using the properties provided.

type Scripts

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

Scripts is a service that handles all script-related interactions.

func NewScripts

func NewScripts(
	gateway gateway.Gateway,
	state *flowkit.State,
	logger output.Logger,
) *Scripts

NewScripts returns a new scripts service.

func (*Scripts) Execute

func (s *Scripts) Execute(code []byte, args []cadence.Value, scriptPath string, network string) (cadence.Value, error)

Execute script code with passed arguments on the selected network.

type Services

type Services struct {
	Accounts     *Accounts
	Scripts      *Scripts
	Transactions *Transactions
	Keys         *Keys
	Events       *Events
	Collections  *Collections
	Project      *Project
	Blocks       *Blocks
	Status       *Status
	Snapshot     *Snapshot
}

Services is a collection of services that provide domain-specific functionality for the different components of a Flow state.

func NewServices

func NewServices(
	gateway gateway.Gateway,
	state *flowkit.State,
	logger output.Logger,
) *Services

NewServices returns a new services collection for a state, initialized with a gateway and logger.

type Snapshot added in v0.30.3

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

Snapshot is a service that handles downloading the latest finalized root protocol snapshot from the gateway.

func NewSnapshot added in v0.30.3

func NewSnapshot(
	gateway gateway.Gateway,
	state *flowkit.State,
	logger output.Logger,
) *Snapshot

NewSnapshot returns a new snapshot service.

func (*Snapshot) GetLatestProtocolStateSnapshot added in v0.30.3

func (s *Snapshot) GetLatestProtocolStateSnapshot() ([]byte, error)

GetLatestProtocolStateSnapshot returns the latest finalized protocol snapshot

type Status

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

Status is a service that handles status of access node.

func NewStatus

func NewStatus(
	gateway gateway.Gateway,
	state *flowkit.State,
	logger output.Logger,
) *Status

NewStatus returns a new status service.

func (*Status) Ping

func (s *Status) Ping(network string) (string, error)

Ping sends Ping request to network.

type Transactions

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

Transactions is a service that handles all transaction-related interactions.

func NewTransactions

func NewTransactions(
	gateway gateway.Gateway,
	state *flowkit.State,
	logger output.Logger,
) *Transactions

NewTransactions returns a new transactions service.

func (*Transactions) Build

func (t *Transactions) Build(
	proposer flow.Address,
	authorizers []flow.Address,
	payer flow.Address,
	proposerKeyIndex int,
	code []byte,
	codeFilename string,
	gasLimit uint64,
	args []cadence.Value,
	network string,
	approveBuild bool,
) (*flowkit.Transaction, error)

Build builds a transaction with specified payer, proposer and authorizer.

func (*Transactions) GetStatus

func (t *Transactions) GetStatus(
	id flow.Identifier,
	waitSeal bool,
) (*flow.Transaction, *flow.TransactionResult, error)

GetStatus of transaction.

func (*Transactions) Send

func (t *Transactions) Send(
	signer *flowkit.Account,
	code []byte,
	codeFilename string,
	gasLimit uint64,
	args []cadence.Value,
	network string,
) (*flow.Transaction, *flow.TransactionResult, error)

Send a transaction code using the signer account and arguments for the specified network.

func (*Transactions) SendSigned

func (t *Transactions) SendSigned(
	payload []byte,
	approveSend bool,
) (*flow.Transaction, *flow.TransactionResult, error)

SendSigned sends the transaction that is already signed.

func (*Transactions) Sign

func (t *Transactions) Sign(
	signer *flowkit.Account,
	payload []byte,
	approveSigning bool,
) (*flowkit.Transaction, error)

Sign transaction payload using the signer account.

Jump to

Keyboard shortcuts

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