services

package
v0.0.0-...-a3dd185 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: Apache-2.0 Imports: 30 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSingleTransactionAccount

func NewSingleTransactionAccount(account *flowkit.Account) *transactionAccountRoles

NewSingleTransactionAccount creates transaction accounts from a single provided account fulfilling all the roles (proposer, payer, authorizer).

func NewTransactionAccountRoles

func NewTransactionAccountRoles(
	proposer *flowkit.Account,
	payer *flowkit.Account,
	authorizers []*flowkit.Account,
) (*transactionAccountRoles, error)

NewTransactionAccountRoles defines transaction roles by accounts.

You can read more about roles here: https://developers.flow.com/learn/concepts/accounts-and-keys

func NewTransactionAddresses

func NewTransactionAddresses(
	proposer flow.Address,
	payer flow.Address,
	authorizers []flow.Address,
) *transactionAddresses

NewTransactionAddresses defines transaction roles by account addresses.

You can read more about roles here: https://developers.flow.com/learn/concepts/accounts-and-keys

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,
	contract *flowkit.Script,
	network string,
	update Update,
) (flow.Identifier, bool, 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

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.Identifier, 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, []flow.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

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

type EventWorkerResult struct {
	Events []flow.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) ([]flow.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) DerivePrivateKeyFromMnemonic

func (k *Keys) DerivePrivateKeyFromMnemonic(mnemonic string, sigAlgo crypto.SignatureAlgorithm, derivationPath string) (crypto.PrivateKey, error)

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.

func (*Keys) GetMnemonic

func (k *Keys) GetMnemonic() (string, error)

func (*Keys) ParsePrivateKey

func (k *Keys) ParsePrivateKey(inputPrivateKey string, sigAlgo crypto.SignatureAlgorithm) (crypto.PrivateKey, error)

Parses private key

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) CheckForStandardContractUsageOnMainnet

func (p *Project) CheckForStandardContractUsageOnMainnet() error

func (*Project) Deploy

func (p *Project) Deploy(network string, update Update) ([]*project.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 name 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.

func (*Project) ReplaceStandardContractReferenceToAlias

func (p *Project) ReplaceStandardContractReferenceToAlias(standardContract StandardContract) error

type ProjectDeploymentError

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

func (*ProjectDeploymentError) Contracts

func (d *ProjectDeploymentError) Contracts() map[string]error

func (*ProjectDeploymentError) Error

func (d *ProjectDeploymentError) Error() string

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(script *flowkit.Script, network string, query *util.ScriptQuery) (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
	Tests        *Tests
}

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.

func (*Services) SetLogger

func (s *Services) SetLogger(logger output.Logger)

type Snapshot

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

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

NewSnapshot returns a new snapshot service.

func (*Snapshot) GetLatestProtocolStateSnapshot

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

GetLatestProtocolStateSnapshot returns the latest finalized protocol snapshot

type StandardContract

type StandardContract struct {
	Name     string
	Address  flow.Address
	InfoLink string
}

Defines a Mainnet Standard Contract ( e.g Core Deployments, FungibleToken, NonFungibleToken )

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 Tests

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

Tests is a service that handles all tests-related interactions.

func NewTests

func NewTests(
	state *flowkit.State,
	logger output.Logger,
) *Tests

NewTests returns a new tests service.

func (*Tests) Execute

func (t *Tests) Execute(
	testFiles map[string][]byte,
	readerWriter flowkit.ReaderWriter,
	coverageEnabled bool,
) (map[string]cdcTests.Results, *runtime.CoverageReport, error)

Execute test scripts.

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(
	addresses *transactionAddresses,
	proposerKeyIndex int,
	script *flowkit.Script,
	gasLimit uint64,
	network string,
) (*flowkit.Transaction, error)

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

func (*Transactions) GetRLP

func (t *Transactions) GetRLP(rlpUrl string) ([]byte, error)

func (*Transactions) GetStatus

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

GetStatus of transaction.

func (*Transactions) GetTransactionResultsByBlockID

func (t *Transactions) GetTransactionResultsByBlockID(id flow.Identifier) ([]*flow.TransactionResult, error)

func (*Transactions) GetTransactionsByBlockID

func (t *Transactions) GetTransactionsByBlockID(id flow.Identifier) ([]*flow.Transaction, error)

func (*Transactions) PostRLP

func (t *Transactions) PostRLP(rlpUrl string, tx *flow.Transaction) error

func (*Transactions) Send

func (t *Transactions) Send(
	accounts *transactionAccountRoles,
	script *flowkit.Script,
	gasLimit uint64,
	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(tx *flowkit.Transaction) (*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,
) (*flowkit.Transaction, error)

Sign transaction payload using the signer account.

type Update

type Update func(existing []byte, new []byte) bool

func UpdateExisting

func UpdateExisting(updateExisting bool) Update

Jump to

Keyboard shortcuts

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