overflow

package module
v1.0.0-rc5 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: MIT Imports: 48 Imported by: 5

README

Coverage Status ci

Overflow

A DSL written in golang to be used in tests or to run a story of interactions against either an local emulator, testnet, mainnet or an in memory instance of the flow-emulator.

Use case scenarios include:

  • demo purposes
  • integration testing of combinations of scripts/transactions
  • batch jobs.

For a standalone example on how overflow can be used look at https://github.com/bjartek/flow-nft-overflow it has both an interactive demo and unit tests for an example NFT contract.

Main features

  • Uses a shared golang builder pattern for almost all interactions.
  • Well documented source code
  • supports all variants of multi-sign, Two authorizers, proposer and payer can be different.
  • when refering to an account/address you can use the logical name for that stakeholder defined in flow json. the same stakeholder IE admin can have different addresses on each network
  • can be run in embedded in memory mode that will start emulator, deploy contracts, create stakeholders and run interactions (scripts/transactions) against this embedded system and then stop it when it ends.
  • has a DSL to fetch Events and optionally store progress in a file. This can be chained into indexers/crawlers/notification services.
  • all interactions can be specified inline as well as from files
  • transform all interactions into a NPM module that can be published for the frontend to use. this json file that is generate has the option to filter out certain interactions and to strip away network suffixes if you have multiple local interactions that should map to the same logical name in the client for each network
  • the interaction (script/tx) dsl has a rich set of assertions
  • arguments to interactions are all named that is the same name in that is in the argument must be used with the Arg("name", "value") builder. The value in this example can be either a primitive go value or a cadence.Value.

Gotchas

  • When specifying extra accounts that are created on emulator they are created in alphabetical order, the addresses the emulator assign is always fixed.
  • tldr; Name your stakeholder accounts in alphabetical order, we suggest admin, bob, charlie, demi, eddie
  • When writing integration tests, tests must be in the same folder as flow.json with contracts and transactions/scripts in subdirectories in order for the path resolver to work correctly

Resources

Usage

First create a project directory, initialize the go module and install overflow:

mkdir test-overflow && cd test-overflow
flow init
go mod init example.com/test-overflow
go get github.com/bjartek/overflow/overflow

Then create a task file:

touch tasks/main.go

In that task file, you can then import overflow and use it to your convenience, for example:

package main

import (
    "fmt"

    //if you imports this with .  you do not have to repeat overflow everywhere 
    . "github.com/bjartek/overflow/overflow"
)

func main() {

	//start an in memory emulator by default
	o := Overflow()
	
	//the Tx DSL runs an transaction
	o.Tx("name_of_transaction", SignProposeAndPayAs("bob"), Arg("name", "bob")).Print()
	
	//Run a script/get interaction against the same in memory chain
	o.Script("name_of_script", Arg("name", "bob")).Print()
}

Then you can run

go run ./tasks/main.go

This is a minimal example that run a transction and a script, but from there you can branch out.

The following env vars are supported

  • OVERFLOW_ENV : set the environment to run against "emulator|embedded|testnet|mainnet|testing" (embedded is standard)
  • OVEFFLOW_CONTINUE: if you do not want overflow to deploy contracts and accounts on emulator you can set this to true
  • OVERFLOW_LOGGING: Set this to 0-4 to get increasing log

Credits

This project is the successor of https://github.com/bjartek/go-with-the-flow The v0 version of the code with a set of apis that is now deprecated is in https://github.com/bjartek/overflow/tree/v0

Documentation

Overview

Overflow is a DSL to help interact with the flow blockchain using go

By bjartek aka Bjarte Karlsen

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CadenceString

func CadenceString(input string) cadence.String

go string to cadence string panic if error

func CadenceValueToInterface

func CadenceValueToInterface(field cadence.Value) interface{}

CadenceValueToInterface convert a candence.Value into interface{}

func CadenceValueToJsonString

func CadenceValueToJsonString(value cadence.Value) (string, error)

CadenceValueToJsonString converts a cadence.Value into a json pretty printed string

func HexToAddress

func HexToAddress(h string) (*cadence.Address, error)

HexToAddress converts a hex string to an Address.

func ParseEvents

func ParseEvents(events []flow.Event) (OverflowEvents, OverflowEvent)

Parse raw flow events into a list of events and a fee event

func PrintEvents deprecated added in v1.0.0

func PrintEvents(events []flow.Event, ignoreFields map[string][]string)

Deprecated: Deprecated in favor of FetchEvent with builder

PrintEvents prints th events, ignoring fields specified for the given event typeID

Types

type CodeWithSpec

type CodeWithSpec struct {
	Code string           `json:"code"`
	Spec *DeclarationInfo `json:"spec"`
}

representing code with specification if parameters

type DeclarationInfo

type DeclarationInfo struct {
	ParameterOrder []string          `json:"order"`
	Parameters     map[string]string `json:"parameters"`
}

a type containing information about paramter types and orders

type EventFetcherBuilder

type EventFetcherBuilder struct {
	OverflowState         *OverflowState
	EventsAndIgnoreFields OverflowEventFilter
	FromIndex             int64
	EndAtCurrentHeight    bool
	EndIndex              uint64
	ProgressFile          string
	NumberOfWorkers       int
	EventBatchSize        uint64
}

EventFetcherBuilder builder to hold info about eventhook context.

func (EventFetcherBuilder) BatchSize deprecated

func (e EventFetcherBuilder) BatchSize(batchSize uint64) EventFetcherBuilder

Deprecated: Deprecated in favor of FetchEvent with builder

BatchSize sets the size of a batch

func (EventFetcherBuilder) End deprecated

func (e EventFetcherBuilder) End(blockHeight uint64) EventFetcherBuilder

Deprecated: Deprecated in favor of FetchEvent with builder

End specify what index to end at

func (EventFetcherBuilder) Event deprecated

func (e EventFetcherBuilder) Event(eventName string) EventFetcherBuilder

Deprecated: Deprecated in favor of FetchEvent with builder

Event fetches and Events and all its fields

func (EventFetcherBuilder) EventIgnoringFields deprecated

func (e EventFetcherBuilder) EventIgnoringFields(eventName string, ignoreFields []string) EventFetcherBuilder

Deprecated: Deprecated in favor of FetchEvent with builder

EventIgnoringFields fetch event and ignore the specified fields

func (EventFetcherBuilder) From deprecated

func (e EventFetcherBuilder) From(blockHeight int64) EventFetcherBuilder

Deprecated: Deprecated in favor of FetchEvent with builder

From specify what blockHeight to fetch from. This can be negative related to end.

func (EventFetcherBuilder) Last deprecated

Deprecated: Deprecated in favor of FetchEvent with builder

Last fetch events from the number last blocks

func (EventFetcherBuilder) Run deprecated

func (e EventFetcherBuilder) Run() ([]*FormatedEvent, error)

Deprecated: Deprecated in favor of FetchEvent with builder

Run runs the eventfetcher returning events or an error

func (EventFetcherBuilder) Start deprecated

func (e EventFetcherBuilder) Start(blockHeight int64) EventFetcherBuilder

Deprecated: Deprecated in favor of FetchEvent with builder

Start specify what blockHeight to fetch starting atm. This can be negative related to end/until

func (EventFetcherBuilder) TrackProgressIn deprecated

func (e EventFetcherBuilder) TrackProgressIn(fileName string) EventFetcherBuilder

Deprecated: Deprecated in favor of FetchEvent with builder

TrackProgressIn Specify a file to store progress in

func (EventFetcherBuilder) Until deprecated

func (e EventFetcherBuilder) Until(blockHeight uint64) EventFetcherBuilder

Deprecated: Deprecated in favor of FetchEvent with builder

Until specify what index to end at

func (EventFetcherBuilder) UntilCurrent deprecated

func (e EventFetcherBuilder) UntilCurrent() EventFetcherBuilder

Deprecated: Deprecated in favor of FetchEvent with builder

UntilCurrent Specify to fetch events until the current Block

func (EventFetcherBuilder) Workers deprecated

func (e EventFetcherBuilder) Workers(workers int) EventFetcherBuilder

Deprecated: Deprecated in favor of FetchEvent with builder

Workers sets the number of workers.

type EventFetcherOption

type EventFetcherOption func(*EventFetcherBuilder)

Event fetching

A function to customize the transaction builder

func TrackProgressIn

func TrackProgressIn(fileName string) EventFetcherOption

track what block we have read since last run in a file

func UntilBlock

func UntilBlock(blockHeight uint64) EventFetcherOption

fetch events until theg given height alias to WithEndHeight

func UntilCurrentBlock

func UntilCurrentBlock() EventFetcherOption

set the end index to the current height

func WithBatchSize

func WithBatchSize(size uint64) EventFetcherOption

Set the batch sice for FetchEvents

func WithEndIndex

func WithEndIndex(blockHeight uint64) EventFetcherOption

set the end index to use

func WithEvent

func WithEvent(eventName string) EventFetcherOption

set that we want to fetch an event and all its fields

func WithEventIgnoringField

func WithEventIgnoringField(eventName string, ignoreFields []string) EventFetcherOption

set that we want the following events and ignoring the fields mentioned

func WithFromIndex

func WithFromIndex(blockHeight int64) EventFetcherOption

set the from index to use alias to WithStartHeight

func WithLastBlocks

func WithLastBlocks(number uint64) EventFetcherOption

set the relative list of blocks to fetch events from

func WithStartHeight

func WithStartHeight(blockHeight int64) EventFetcherOption

set the start height to use

func WithWorkers

func WithWorkers(workers int) EventFetcherOption

Set the Workers size for FetchEvents

type FlowArgumentsBuilder deprecated

type FlowArgumentsBuilder struct {
	Overflow  *OverflowState
	Arguments []cadence.Value
	Error     error
}

FlowArgumentsBuilder

The old way of specifing arguments to interactions

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) Account deprecated

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) AccountArray deprecated

func (a *FlowArgumentsBuilder) AccountArray(value ...string) *FlowArgumentsBuilder

Argument add a RawAddressArray to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) Address deprecated

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) Argument deprecated

Argument add an argument to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) Boolean deprecated

func (a *FlowArgumentsBuilder) Boolean(value bool) *FlowArgumentsBuilder

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) Build deprecated

func (a *FlowArgumentsBuilder) Build() []cadence.Value

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) Bytes deprecated

func (a *FlowArgumentsBuilder) Bytes(value []byte) *FlowArgumentsBuilder

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) DateStringAsUnixTimestamp deprecated

func (a *FlowArgumentsBuilder) DateStringAsUnixTimestamp(dateString string, timezone string) *FlowArgumentsBuilder

DateStringAsUnixTimestamp sends a dateString parsed in the timezone as a unix timeszone ufix

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) Fix64 deprecated

Fix64 add a Fix64 Argument to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) Int deprecated

Int add an Int Argument to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) Int128 deprecated

func (a *FlowArgumentsBuilder) Int128(value int) *FlowArgumentsBuilder

Int128 add an Int128 Argument to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) Int16 deprecated

Int16 add an Int16 Argument to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) Int256 deprecated

func (a *FlowArgumentsBuilder) Int256(value int) *FlowArgumentsBuilder

Int256 add an Int256 Argument to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) Int32 deprecated

Int32 add an Int32 Argument to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) Int64 deprecated

Int64 add an Int64 Argument to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) Int8 deprecated

Int8 add an Int8 Argument to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) PrivatePath deprecated

func (a *FlowArgumentsBuilder) PrivatePath(input string) *FlowArgumentsBuilder

PrivatePath argument

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) PublicPath deprecated

func (a *FlowArgumentsBuilder) PublicPath(input string) *FlowArgumentsBuilder

PublicPath argument

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) RawAccount deprecated

func (a *FlowArgumentsBuilder) RawAccount(address string) *FlowArgumentsBuilder

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) RawAddress deprecated

func (a *FlowArgumentsBuilder) RawAddress(address string) *FlowArgumentsBuilder

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) RawAddressArray deprecated

func (a *FlowArgumentsBuilder) RawAddressArray(value ...string) *FlowArgumentsBuilder

Argument add a RawAddressArray to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) ScalarMap deprecated

func (a *FlowArgumentsBuilder) ScalarMap(input map[string]string) *FlowArgumentsBuilder

Add an {String:UFix64} to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) ScalarMapArray deprecated

func (a *FlowArgumentsBuilder) ScalarMapArray(value ...map[string]string) *FlowArgumentsBuilder

Argument add an StringArray to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) StoragePath deprecated

func (a *FlowArgumentsBuilder) StoragePath(input string) *FlowArgumentsBuilder

StoragePath argument

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) String deprecated

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) StringArray deprecated

func (a *FlowArgumentsBuilder) StringArray(value ...string) *FlowArgumentsBuilder

Argument add an StringArray to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) StringMap deprecated

func (a *FlowArgumentsBuilder) StringMap(input map[string]string) *FlowArgumentsBuilder

Add an {String:String} to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) StringMapArray deprecated

func (a *FlowArgumentsBuilder) StringMapArray(value ...map[string]string) *FlowArgumentsBuilder

Argument add an StringMapArray to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) UFix64 deprecated

UFix64 add a UFix64 Argument to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) UFix64Array deprecated

func (a *FlowArgumentsBuilder) UFix64Array(value ...float64) *FlowArgumentsBuilder

Argument add an argument to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) UInt deprecated

UInt add an UInt Argument to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) UInt128 deprecated

func (a *FlowArgumentsBuilder) UInt128(value uint) *FlowArgumentsBuilder

UInt128 add an UInt128 Argument to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) UInt16 deprecated

UInt16 add an UInt16 Argument to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) UInt256 deprecated

func (a *FlowArgumentsBuilder) UInt256(value uint) *FlowArgumentsBuilder

UInt256 add an UInt256 Argument to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) UInt32 deprecated

UInt32 add an UInt32 Argument to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) UInt64 deprecated

UInt64 add an UInt64 Argument to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) UInt64Array deprecated

func (a *FlowArgumentsBuilder) UInt64Array(value ...uint64) *FlowArgumentsBuilder

Argument add an argument to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) UInt8 deprecated

UInt8 add an UInt8 Argument to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) UInt8Array deprecated

func (a *FlowArgumentsBuilder) UInt8Array(value ...uint8) *FlowArgumentsBuilder

Argument add an argument to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) Word16 deprecated

Word16 add a Word16 Argument to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) Word32 deprecated

Word32 add a Word32 Argument to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) Word64 deprecated

Word64 add a Word64 Argument to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*FlowArgumentsBuilder) Word8 deprecated

Word8 add a Word8 Argument to the transaction

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

type FlowInteractionBuilder

type FlowInteractionBuilder struct {

	//The underlying state of overflow used to fetch some global settings
	Overflow *OverflowState

	//The file name of the interaction
	FileName string

	//The content of the interaction
	Content string

	//The list of raw arguments
	Arguments []cadence.Value

	//TODO: Should this be payer?
	//The main signer used to sign the transaction
	MainSigner *flowkit.Account

	//The propser account
	Proposer *flowkit.Account

	//The payload signers that will sign the payload
	PayloadSigners []*flowkit.Account

	//The gas limit to set for this given interaction
	GasLimit uint64

	//The basepath on where to look for interactions
	BasePath string

	//An error object to store errors that arrive as you configure an interaction
	Error error

	//The code of the tranasction in bytes
	TransactionCode []byte

	//The named arguments
	NamedArgs map[string]interface{}

	//Event filters to apply to the interaction
	EventFilter OverflowEventFilter

	//Wheter to ignore global event filters from OverflowState or not
	IgnoreGlobalEventFilters bool
}

FlowInteractionBuilder used to create a builder pattern for an interaction

func (FlowInteractionBuilder) Args deprecated

Deprecated: Use Arg

Specify arguments to send to transaction using a builder you send in

func (FlowInteractionBuilder) ArgsFn deprecated

Deprecated: Use Arg

Specify arguments to send to transaction using a function that takes a builder where you call the builder

func (FlowInteractionBuilder) ArgsV deprecated

Deprecated: Use Args

Specify arguments to send to transaction using a raw list of values

func (FlowInteractionBuilder) Gas deprecated

Deprecated: Use Tx function

Gas sets the gas limit for this transaction

func (FlowInteractionBuilder) NamedArguments deprecated

func (t FlowInteractionBuilder) NamedArguments(args map[string]string) FlowInteractionBuilder

Deprecated: Use ArgM

func (FlowInteractionBuilder) PayloadSigner deprecated

func (t FlowInteractionBuilder) PayloadSigner(value string) FlowInteractionBuilder

Deprecated: Use Tx function

PayloadSigner set a signer for the payload

func (FlowInteractionBuilder) Run deprecated

func (t FlowInteractionBuilder) Run() []flow.Event

Deprecated: use Send and get entire result

Run run the transaction

func (FlowInteractionBuilder) RunE deprecated

func (t FlowInteractionBuilder) RunE() ([]flow.Event, error)

Deprecated: use Send()

RunE runs returns events and error

func (FlowInteractionBuilder) RunGetEventsWithName deprecated

func (t FlowInteractionBuilder) RunGetEventsWithName(eventName string) []FormatedEvent

Deprecated: Use Send().GetEventsWithName()

func (FlowInteractionBuilder) RunGetEventsWithNameOrError deprecated

func (t FlowInteractionBuilder) RunGetEventsWithNameOrError(eventName string) ([]FormatedEvent, error)

Deprecated: use Tx().GetEventsWithName

func (FlowInteractionBuilder) RunGetIdFromEvent

func (t FlowInteractionBuilder) RunGetIdFromEvent(eventName string, fieldName string) uint64

Deprecated, use Send().GetIdFromEvent

func (FlowInteractionBuilder) RunGetIdFromEventPrintAll deprecated

func (t FlowInteractionBuilder) RunGetIdFromEventPrintAll(eventName string, fieldName string) uint64

Deprecated: Use Tx().Print().GetIdFromEvent

func (FlowInteractionBuilder) RunGetIds deprecated

func (t FlowInteractionBuilder) RunGetIds(eventName string, fieldName string) ([]uint64, error)

Deprecated: Use Tx().Print().GetIdsFromEvent

func (FlowInteractionBuilder) RunPrintEvents deprecated

func (t FlowInteractionBuilder) RunPrintEvents(ignoreFields map[string][]string)

Deprecated: use Send().PrintEventsFiltered()

RunPrintEvents will run a transaction and print all events ignoring some fields

func (FlowInteractionBuilder) RunPrintEventsFull deprecated

func (t FlowInteractionBuilder) RunPrintEventsFull()

Deprecated: use Send().PrintEvents()

RunPrintEventsFull will run a transaction and print all events

func (FlowInteractionBuilder) Send

Send a intereaction builder as a Transaction returning an overflow result

func (FlowInteractionBuilder) SignProposeAndPayAs deprecated

func (t FlowInteractionBuilder) SignProposeAndPayAs(signer string) FlowInteractionBuilder

Deprecated: Use Tx function

SignProposeAndPayAs set the payer, proposer and envelope signer

func (FlowInteractionBuilder) SignProposeAndPayAsService deprecated

func (t FlowInteractionBuilder) SignProposeAndPayAsService() FlowInteractionBuilder

Deprecated: Use Tx function

SignProposeAndPayAsService set the payer, proposer and envelope signer

func (FlowInteractionBuilder) Test deprecated

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (FlowInteractionBuilder) TransactionPath deprecated

func (t FlowInteractionBuilder) TransactionPath(path string) FlowInteractionBuilder

Deprecated: Use Tx function

type FlowScriptBuilder deprecated

type FlowScriptBuilder struct {
	Overflow       *OverflowState
	FileName       string
	Arguments      []cadence.Value
	ScriptAsString string
	BasePath       string
	Error          error
}

FlowScriptBuilder is a struct to hold information for running a script

Deprecated: use FlowInteractionBuilder and the Script method

func (FlowScriptBuilder) Args deprecated

Specify arguments to send to transaction using a builder you send in

Deprecated: use FlowInteractionBuilder and the Script method

func (FlowScriptBuilder) ArgsFn deprecated

Specify arguments to send to transaction using a function that takes a builder where you call the builder

Deprecated: use FlowInteractionBuilder and the Script method

func (FlowScriptBuilder) ArgsV deprecated

Specify arguments to send to transaction using a raw list of values

Deprecated: use FlowInteractionBuilder and the Script method

func (FlowScriptBuilder) NamedArguments deprecated

func (t FlowScriptBuilder) NamedArguments(args map[string]string) FlowScriptBuilder

Deprecated: use FlowInteractionBuilder and the Script method

func (FlowScriptBuilder) Run

func (t FlowScriptBuilder) Run()

Run executes a read only script Deprecated: use FlowInteractionBuilder and the Script method

func (FlowScriptBuilder) RunFailOnError deprecated

func (t FlowScriptBuilder) RunFailOnError() cadence.Value

Deprecated: use FlowInteractionBuilder and the Script method

func (FlowScriptBuilder) RunMarshalAs deprecated

func (t FlowScriptBuilder) RunMarshalAs(value interface{}) error

RunMarshalAs runs the script and marshals the result into the provided value, returning an error if any

Deprecated: use FlowInteractionBuilder and the Script method

func (FlowScriptBuilder) RunReturns deprecated

func (t FlowScriptBuilder) RunReturns() (cadence.Value, error)

RunReturns executes a read only script

Deprecated: use FlowInteractionBuilder and the Script method

func (FlowScriptBuilder) RunReturnsInterface deprecated

func (t FlowScriptBuilder) RunReturnsInterface() interface{}

RunReturnsInterface runs the script and returns interface{}

Deprecated: use FlowInteractionBuilder and the Script method

func (FlowScriptBuilder) RunReturnsJsonString deprecated

func (t FlowScriptBuilder) RunReturnsJsonString() string

RunReturnsJsonString runs the script and returns pretty printed json string

Deprecated: use FlowInteractionBuilder and the Script method

func (FlowScriptBuilder) ScriptPath deprecated

func (t FlowScriptBuilder) ScriptPath(path string) FlowScriptBuilder

Deprecated: use FlowInteractionBuilder and the Script method

type FormatedEvent deprecated

type FormatedEvent struct {
	Name        string                 `json:"name"`
	BlockHeight uint64                 `json:"blockHeight,omitempty"`
	Time        time.Time              `json:"time,omitempty"`
	Fields      map[string]interface{} `json:"fields"`
}

Deprecated: Deprecated in favor of FetchEvent with builder

FormatedEvent event in a more condensed formated form

func FormatEvents added in v1.0.0

func FormatEvents(blockEvents []flow.BlockEvents, ignoreFields map[string][]string) []*FormatedEvent

FormatEvents

func NewTestEvent deprecated added in v1.0.0

func NewTestEvent(name string, fields map[string]interface{}) *FormatedEvent

Deprecated: Deprecated in favor of FetchEvent with builder

func ParseEvent added in v1.0.0

func ParseEvent(event flow.Event, blockHeight uint64, time time.Time, ignoreFields []string) *FormatedEvent

ParseEvent parses a flow event into a more terse representation

func (FormatedEvent) ExistIn deprecated

func (o FormatedEvent) ExistIn(events []*FormatedEvent) bool

Deprecated: Deprecated in favor of FetchEvent with builder

func (FormatedEvent) GetFieldAsUInt64 deprecated

func (e FormatedEvent) GetFieldAsUInt64(field string) uint64

Deprecated: Deprecated in favor of FetchEvent with builder

func (FormatedEvent) ShortName deprecated

func (fe FormatedEvent) ShortName() string

Deprecated: Deprecated in favor of FetchEvent with builder

func (FormatedEvent) String deprecated

func (e FormatedEvent) String() string

Deprecated: Deprecated in favor of FetchEvent with builder

String pretty print an event as a String

type InteractionOption

type InteractionOption func(*FlowInteractionBuilder)

A function to customize the transaction builder

func Addresses

func Addresses(name string, value ...string) InteractionOption

Send in an array of addresses as an argument

func Arg

func Arg(name string, value interface{}) InteractionOption

Send an argument into a transaction

The value is treated in the given way depending on type - cadence.Value is sent as straight argument - string argument are resolved into cadence.Value using flowkit - ofther values are converted to string with %v and resolved into cadence.Value using flowkit - if the type of the paramter is Address and the string you send in is a valid account in flow.json it will resolve

func Args

func Args(args ...interface{}) InteractionOption

set a list of args as key, value in an interaction, see Arg for options you can pass in

func ArgsM

func ArgsM(args map[string]interface{}) InteractionOption

set arguments to the interaction from a map. See Arg for options on what you can pass in

func DateTimeArg

func DateTimeArg(name string, dateString string, timezone string) InteractionOption

sending in a timestamp as an arg is quite complicated, use this method with the name of the arg, the datestring and the given timezone to parse it at

func EventFilter

func EventFilter(filter OverflowEventFilter) InteractionOption

set a filter for events

func Gas

func Gas(gas uint64) InteractionOption

set the gas limit

func IgnoreGlobalEventFilters

func IgnoreGlobalEventFilters() InteractionOption

ignore global events filters defined on OverflowState

func PayloadSigner

func PayloadSigner(signer ...string) InteractionOption

set an aditional authorizer that will sign the payload

func ProposeAs

func ProposeAs(proposer string) InteractionOption

set the proposer

func ProposeAsServiceAccount

func ProposeAsServiceAccount() InteractionOption

set the propser to be the service account

func SignProposeAndPayAs

func SignProposeAndPayAs(signer string) InteractionOption

set payer, proposer authorizer as the signer

func SignProposeAndPayAsServiceAccount

func SignProposeAndPayAsServiceAccount() InteractionOption

set service account as payer, proposer, authorizer

type LogrusMessage

type LogrusMessage struct {
	ComputationUsed int       `json:"computationUsed"`
	Level           string    `json:"level"`
	Msg             string    `json:"msg"`
	Time            time.Time `json:"time"`
	TxID            string    `json:"txID"`
}

LogrusMessage a log message from the logrus implementation used in the flow emulator

type MergedSolution

type MergedSolution struct {
	Networks map[string]MergedSolutionNetwork `json:"networks"`
}

a type representing a merged solution that will be serialized as the json file for the npm module

type MergedSolutionNetwork

type MergedSolutionNetwork struct {
	Scripts      map[string]CodeWithSpec `json:"scripts"`
	Transactions map[string]CodeWithSpec `json:"transactions,omitempty"`
	Contracts    *map[string]string      `json:"contracts,omitempty"`
}

a network in the merged solution

type Meter

type Meter struct {
	LedgerInteractionUsed  int                           `json:"ledgerInteractionUsed"`
	ComputationUsed        int                           `json:"computationUsed"`
	MemoryUsed             int                           `json:"memoryUsed"`
	ComputationIntensities MeteredComputationIntensities `json:"computationIntensities"`
	MemoryIntensities      MeteredMemoryIntensities      `json:"memoryIntensities"`
}

a type representing a meter that contains information about the inner workings of an interaction, only available on local emulator

func (Meter) FunctionInvocations

func (m Meter) FunctionInvocations() int

get the number of functions invocations

func (Meter) Loops

func (m Meter) Loops() int

get the number of loops

func (Meter) Statements

func (m Meter) Statements() int

get the number of statements

type MeteredComputationIntensities

type MeteredComputationIntensities map[common.ComputationKind]uint

type collecting computatationIntensities

type MeteredMemoryIntensities

type MeteredMemoryIntensities map[common.MemoryKind]uint

type collecting memoryIntensities

type OverflowBuilder

type OverflowBuilder struct {
	Network                             string
	InMemory                            bool
	DeployContracts                     bool
	GasLimit                            int
	Path                                string
	LogLevel                            int
	InitializeAccounts                  bool
	PrependNetworkName                  bool
	ServiceSuffix                       string
	ConfigFiles                         []string
	TransactionFolderName               string
	ScriptFolderName                    string
	FilterOutFeeEvents                  bool
	FilterOutEmptyWithDrawDepositEvents bool
	GlobalEventFilter                   OverflowEventFilter
	StopOnError                         bool
	PrintOptions                        *[]PrinterOption
}

OverflowBuilder is the struct used to gather up configuration when building an overflow instance

func NewOverflow deprecated added in v1.0.0

func NewOverflow() *OverflowBuilder

NewOverflow creates a new OverflowBuilder reading some confiuration from ENV var ( OVERFLOW_ENV : sets the environment to use, valid values here are emulator|testnet|mainnet|embedded OVERFLOW_CONTINUE : if set to `true` will not create accounts and deploy contracts even if on embeded/emulator OVERFLOW_LOGGING : set the logging level of flowkit and overflow itself, 0 = No Log, 1 = Errors only, 2 = Debug, 3(default) = Info

Deprecated: use Overflow function with builder

func NewOverflowBuilder deprecated added in v1.0.0

func NewOverflowBuilder(network string, newEmulator bool, logLevel int) *OverflowBuilder

Deprecated: use Overflow function with builder

func NewOverflowEmulator deprecated added in v1.0.0

func NewOverflowEmulator() *OverflowBuilder

NewOverflowEmulator create a new client

Deprecated: use Overflow function with builder

func NewOverflowForNetwork deprecated added in v1.0.0

func NewOverflowForNetwork(network string) *OverflowBuilder

NewOverflowForNetwork creates a new overflow client for the provided network

Deprecated: use Overflow function with builder

func NewOverflowInMemoryEmulator added in v1.0.0

func NewOverflowInMemoryEmulator() *OverflowBuilder

NewOverflowInMemoryEmulator this method is used to create an in memory emulator, deploy all contracts for the emulator and create all accounts Deprecated: use Overflow function with builder

func NewOverflowMainnet deprecated added in v1.0.0

func NewOverflowMainnet() *OverflowBuilder

NewOverflowMainnet creates a new gwft client for mainnet

Deprecated: use Overflow function with builder

func NewOverflowTestnet deprecated added in v1.0.0

func NewOverflowTestnet() *OverflowBuilder

NewOverflowTestnet creates a new overflow client for devnet/testnet

Deprecated: use Overflow function with builder

func NewTestingEmulator deprecated added in v1.0.0

func NewTestingEmulator() *OverflowBuilder

NewTestingEmulator starts an embeded emulator with no log to be used most often in tests

Deprecated: use Overflow function with builder

func (*OverflowBuilder) BasePath deprecated added in v1.0.0

func (o *OverflowBuilder) BasePath(path string) *OverflowBuilder

BasePath set the base path for transactions/scripts/contracts

Deprecated: use Overflow function with builder

func (*OverflowBuilder) Config deprecated added in v1.0.0

func (o *OverflowBuilder) Config(files ...string) *OverflowBuilder

Config sets the file path to the flow.json config files to use

Deprecated: use Overflow function with builder

func (*OverflowBuilder) DefaultGas deprecated added in v1.0.0

func (o *OverflowBuilder) DefaultGas(gas int) *OverflowBuilder

DefaultGas sets the default gas limit to use

Deprecated: use Overflow function with builder

func (*OverflowBuilder) DoNotPrependNetworkToAccountNames deprecated added in v1.0.0

func (o *OverflowBuilder) DoNotPrependNetworkToAccountNames() *OverflowBuilder

DoNotPrependNetworkToAccountNames sets that network names will not be prepends to account names

Deprecated: use Overflow function with builder

func (*OverflowBuilder) ExistingEmulator deprecated added in v1.0.0

func (o *OverflowBuilder) ExistingEmulator() *OverflowBuilder

ExistingEmulator this if you are using an existing emulator and you do not want to create contracts or initializeAccounts

Deprecated: use Overflow function with builder

func (*OverflowBuilder) NoneLog deprecated added in v1.0.0

func (o *OverflowBuilder) NoneLog() *OverflowBuilder

NoneLog will turn of logging, making the script work well in batch jobs

Deprecated: use Overflow function with builder

func (*OverflowBuilder) SetServiceSuffix deprecated added in v1.0.0

func (o *OverflowBuilder) SetServiceSuffix(suffix string) *OverflowBuilder

SetServiceSuffix will set the suffix to use for the service account. The default is `account`

Deprecated: use Overflow function with builder

func (*OverflowBuilder) Start deprecated added in v1.0.0

func (ob *OverflowBuilder) Start() *OverflowState

Start will start the overflow builder and return OverflowState, will panic if there are errors

Deprecated: use Overflow function with builder

func (*OverflowBuilder) StartE deprecated

func (o *OverflowBuilder) StartE() (*OverflowState, error)

StartE will start Overflow and return State and error if any

Deprecated: use Overflow function with builder

type OverflowEvent

type OverflowEvent map[string]interface{}

a type representing the terse output of an raw Flow Event

func (OverflowEvent) ExistIn

func (o OverflowEvent) ExistIn(events []OverflowEvent) bool

Check if an event exist in the other events

type OverflowEventFilter

type OverflowEventFilter map[string][]string

Event parsing

a type alias to an OverflowEventFilter to filter out all events with a given suffix and the fields with given suffixes

type OverflowEvents

type OverflowEvents map[string][]OverflowEvent

a type holding all events that are emitted from a Transaction

func (OverflowEvents) FilterEvents

func (overflowEvents OverflowEvents) FilterEvents(ignoreFields OverflowEventFilter) OverflowEvents

Filter out events given the sent in filter

func (OverflowEvents) FilterFees

func (overflowEvents OverflowEvents) FilterFees(fee float64) OverflowEvents

Filtter out fee events

func (OverflowEvents) FilterTempWithdrawDeposit

func (overflowEvents OverflowEvents) FilterTempWithdrawDeposit() OverflowEvents

Filter out temp withdraw deposit events

type OverflowOption

type OverflowOption func(*OverflowBuilder)

OverflowOption and option function that you can send in to configure Overflow

func DoNotPrependNetworkToAccountNames

func DoNotPrependNetworkToAccountNames() OverflowOption

DoNotPrependNetworkToAccountNames will not prepend the name of the network to account names

func PrintInteractionResults

func PrintInteractionResults(opts ...PrinterOption) OverflowOption

automatically print interactions using the following options

func StopOnError

func StopOnError() OverflowOption

If this option is used a panic will be called if an error occurs after an interaction is run

func WithBasePath

func WithBasePath(path string) OverflowOption

WithBasePath will change the standard basepath `.` to another folder

func WithEmptyDepoitWithdrawEvents

func WithEmptyDepoitWithdrawEvents() OverflowOption

filter out empty deposit and withdraw events

func WithExistingEmulator

func WithExistingEmulator() OverflowOption

WithExistingEmulator will attach to an existing emulator, not deploying contracts and creating accounts

func WithFeesEvents

func WithFeesEvents() OverflowOption

WithTransactionFolderName will overwite the default script subdir for transactions `transactions`

func WithFlowConfig

func WithFlowConfig(files ...string) OverflowOption

WithFlowConfig will set the path to one or more flow.json config files The default is ~/flow.json and ./flow.json.

func WithGas

func WithGas(gas int) OverflowOption

WithGas set the default gas limit, standard is 9999 (max)

func WithGlobalEventFilter

func WithGlobalEventFilter(filter OverflowEventFilter) OverflowOption

set global filters to events

func WithInMemory

func WithInMemory() OverflowOption

WithInMemory will set that this instance is an in memoy instance createing accounts/deploying contracts

func WithNetwork

func WithNetwork(network string) OverflowOption

WithNetwork will start overflow with the given network. This function will also set up other options that are common for a given Network.

embedded: starts in memory, will deploy contracts and create accounts, info log
testing: starts in memory, will deploy contracts and create accounts, no log
testnet|mainnet: will only set network, not deploy contracts or create accounts

func WithNoLog

func WithNoLog() OverflowOption

WithNoLog will start emulator with no output

func WithScriptFolderName

func WithScriptFolderName(name string) OverflowOption

WithScriptFolderName will overwite the default script subdir for scripts `scripts`

func WithServiceAccountSuffix

func WithServiceAccountSuffix(suffix string) OverflowOption

WithServiceAccountSuffix will set the suffix of the service account

func WithTransactionFolderName

func WithTransactionFolderName(name string) OverflowOption

WithTransactionFolderName will overwite the default script subdir for transactions `transactions`

type OverflowPastEvent

type OverflowPastEvent struct {
	Name        string        `json:"name"`
	BlockHeight uint64        `json:"blockHeight,omitempty"`
	Time        time.Time     `json:"time,omitempty"`
	Fields      OverflowEvent `json:"fields"`
}

a type to represent an event that we get from FetchEvents

func (OverflowPastEvent) GetFieldAsUInt64

func (e OverflowPastEvent) GetFieldAsUInt64(field string) uint64

get the given field as an uint64

func (OverflowPastEvent) String

func (e OverflowPastEvent) String() string

String pretty print an event as a String

type OverflowResult

type OverflowResult struct {
	StopOnError bool
	//The error if any
	Err error

	//The id of the transaction
	Id flow.Identifier

	//If running on an emulator
	//the meter that contains useful debug information on memory and interactions
	Meter *Meter
	//The Raw log from the emulator
	RawLog []LogrusMessage
	// The log from the emulator
	EmulatorLog []string

	//The computation used
	ComputationUsed int

	//The raw unfiltered events
	RawEvents []flow.Event

	//Events that are filtered and parsed into a terse format
	Events OverflowEvents

	//The underlying transaction if we need to look into that
	Transaction *flow.Transaction

	//TODO: consider marshalling this as a struct for convenience
	//The fee event if any
	Fee map[string]interface{}

	//The name of the Transaction
	Name string
}

OverflowResult represents the state after running an transaction

func (OverflowResult) AssertComputationLessThenOrEqual

func (o OverflowResult) AssertComputationLessThenOrEqual(t *testing.T, computation int) OverflowResult

Assert that this transaction did not use more then the given amount of computation

func (OverflowResult) AssertComputationUsed

func (o OverflowResult) AssertComputationUsed(t *testing.T, computation int) OverflowResult

Assert that the transaction uses exactly the given computation amount

func (OverflowResult) AssertDebugLog

func (o OverflowResult) AssertDebugLog(t *testing.T, message ...string) OverflowResult

Assert that a Debug.Log event was emitted that contains the given messages

func (OverflowResult) AssertEmitEventName

func (o OverflowResult) AssertEmitEventName(t *testing.T, event ...string) OverflowResult

Assert that events with the given suffixes are present

func (OverflowResult) AssertEmulatorLog

func (o OverflowResult) AssertEmulatorLog(t *testing.T, message string) OverflowResult

Assert that the internal log of the emulator contains the given message

func (OverflowResult) AssertEvent

func (o OverflowResult) AssertEvent(t *testing.T, name string, fields OverflowEvent) OverflowResult

Assert that the event with the given name suffix and fields are present

func (OverflowResult) AssertEventCount

func (o OverflowResult) AssertEventCount(t *testing.T, number int) OverflowResult

Assert that the transaction result contains the amount of events

func (OverflowResult) AssertFailure

func (o OverflowResult) AssertFailure(t *testing.T, msg string) OverflowResult

Assert that this particular transaction was a failure that has a message that contains the sendt in assertion

func (OverflowResult) AssertNoEvents

func (o OverflowResult) AssertNoEvents(t *testing.T) OverflowResult

Assert that this transaction emitted no events

func (OverflowResult) AssertSuccess

func (o OverflowResult) AssertSuccess(t *testing.T) OverflowResult

Assert that this transation was an success

func (OverflowResult) GetEventsWithName

func (o OverflowResult) GetEventsWithName(eventName string) []OverflowEvent

Get all events that end with the given suffix

func (OverflowResult) GetIdFromEvent

func (o OverflowResult) GetIdFromEvent(eventName string, fieldName string) (uint64, error)

Get a uint64 field with the given fieldname(most often an id) from an event with a given suffix

func (OverflowResult) GetIdsFromEvent

func (o OverflowResult) GetIdsFromEvent(eventName string, fieldName string) []uint64

func (OverflowResult) Print

func (o OverflowResult) Print(opts ...PrinterOption) OverflowResult

print out an result

type OverflowScriptResult

type OverflowScriptResult struct {
	Err    error
	Result cadence.Value
	Input  *FlowInteractionBuilder
	Log    []LogrusMessage
	Output interface{}
}

result after running a script

func (*OverflowScriptResult) AssertLengthWithPointer

func (osr *OverflowScriptResult) AssertLengthWithPointer(t *testing.T, pointer string, length int) *OverflowScriptResult

Assert that the length of a jsonPointer is equal to length

func (*OverflowScriptResult) AssertWant

func (osr *OverflowScriptResult) AssertWant(t *testing.T, want autogold.Value) *OverflowScriptResult

Assert that the result is equal to the given autogold.Want

func (*OverflowScriptResult) AssertWithPointer

func (osr *OverflowScriptResult) AssertWithPointer(t *testing.T, pointer string, value interface{}) *OverflowScriptResult

Assert that a jsonPointer into the result is equal to the given value

func (*OverflowScriptResult) AssertWithPointerError

func (osr *OverflowScriptResult) AssertWithPointerError(t *testing.T, pointer string, message string) *OverflowScriptResult

Assert that a jsonPointer into the result is an error

func (*OverflowScriptResult) AssertWithPointerWant

func (osr *OverflowScriptResult) AssertWithPointerWant(t *testing.T, pointer string, want autogold.Value) *OverflowScriptResult

Assert that a jsonPointer into the result is equal to the given autogold Want

func (*OverflowScriptResult) GetAsInterface

func (osr *OverflowScriptResult) GetAsInterface() (interface{}, error)

get the script as interface{}

func (*OverflowScriptResult) GetAsJson

func (osr *OverflowScriptResult) GetAsJson() (string, error)

get the script as json

func (*OverflowScriptResult) GetWithPointer

func (osr *OverflowScriptResult) GetWithPointer(pointer string) (interface{}, error)

get the given jsonPointer as interface{}

func (*OverflowScriptResult) MarshalAs

func (osr *OverflowScriptResult) MarshalAs(marshalTo interface{}) error

Marshal the script output as the given sent in type

func (*OverflowScriptResult) MarshalPointerAs

func (osr *OverflowScriptResult) MarshalPointerAs(pointer string, marshalTo interface{}) error

Marshal the given jsonPointer as the given type

func (*OverflowScriptResult) Print

func (osr *OverflowScriptResult) Print()

Print the result

type OverflowState

type OverflowState struct {

	//State is the current state of the configured overflow instance
	State *flowkit.State

	//the services from flowkit to performed operations on
	Services *services.Services

	//Configured variables that are taken from the builder since we need them in the execution of overflow later on
	Network                      string
	PrependNetworkToAccountNames bool
	ServiceAccountSuffix         string
	Gas                          int

	//flowkit, emulator and emulator debug log uses three different logging technologies so we have them all stored here
	//this flowkit Logger can go away when we can remove deprecations!
	Logger output.Logger
	Log    *bytes.Buffer

	//https://github.com/bjartek/overflow/issues/45
	//This is not populated with anything yet since the emulator version that has this change is not in mainline yet
	EmulatorLog *bytes.Buffer

	//If there was an error starting overflow it is stored here
	Error error

	//Paths that points to where .cdc files are stored and the posibilty to specify something besides the standard `transactions`/`scripts`subdirectories
	BasePath            string
	TransactionBasePath string
	ScriptBasePath      string

	//Filters to events to remove uneeded noise
	FilterOutFeeEvents                  bool
	FilterOutEmptyWithDrawDepositEvents bool
	GlobalEventFilter                   OverflowEventFilter

	//Signal to overflow that if there is an error after running a single interaction we should panic
	StopOnError bool

	//Signal to overflow that if this is not nil we should print events on interaction completion
	PrintOptions *[]PrinterOption
}

OverflowState contains information about how to Overflow is confitured and the current runnig state

func Overflow

func Overflow(opts ...OverflowOption) *OverflowState

Overflow will start an Overflow instance that panics if there are initialization errors

Will read the following ENV vars as default: OVERFLOW_ENV : set to "mainnet|testnet|emulator|embedded", default embedded OVERFLOW_LOGGING: set from 0-3 to get increasing amount of log output, default 3 OVERFLOW_CONTINUE: to continue this overflow on an already running emulator., default false

Starting overflow without env vars will make it start in embedded mode deploying all contracts creating accounts

You can then chose to override this setting with the builder methods example

Overflow(WithNetwork("mainnet"))

Setting the network in this way will reset other builder methods if appropriate so use with care.

func OverflowE

func OverflowE(opts ...OverflowOption) (*OverflowState, error)

OverfloewE will start overflow and return state or an error if there is one

See Overflow doc comment for an better docs

func OverflowTesting

func OverflowTesting(opts ...OverflowOption) (*OverflowState, error)

OverflowTesting starts an overflow emulator that is suitable for testing that will print no logs to stdout

func (*OverflowState) AccountE

func (f *OverflowState) AccountE(key string) (*flowkit.Account, error)

AccountE fetch an account from State Note that if `PrependNetworkToAccountNames` is specified it is prefixed with the network so that you can use the same logical name accross networks

func (*OverflowState) Arguments deprecated added in v1.0.0

func (f *OverflowState) Arguments() *FlowArgumentsBuilder

Deprecated: This builder and all its methods are deprecated. Use the new Tx/Script methods and its argument method

func (*OverflowState) BuildInteraction

func (o *OverflowState) BuildInteraction(filename string, interactionType string, opts ...InteractionOption) *FlowInteractionBuilder

create a flowInteractionBuilder from the sent in options

func (*OverflowState) CreateAccountsE

func (f *OverflowState) CreateAccountsE() (*OverflowState, error)

CreateAccountsE ensures that all accounts present in the deployment block for the given network is present

func (*OverflowState) DownloadAndUploadFile

func (o *OverflowState) DownloadAndUploadFile(url string, accountName string) error

DownloadAndUploadFile reads a file, base64 encodes it and chunk upload to /storage/upload

func (*OverflowState) DownloadImageAndUploadAsDataUrl

func (o *OverflowState) DownloadImageAndUploadAsDataUrl(url, accountName string) error

DownloadImageAndUploadAsDataUrl download an image and upload as data url

func (*OverflowState) EventFetcher deprecated added in v1.0.0

func (o *OverflowState) EventFetcher() EventFetcherBuilder

Deprecated: Deprecated in favor of FetchEvent with builder

EventFetcher create an event fetcher builder.

func (*OverflowState) FetchEvents

func (o *OverflowState) FetchEvents(opts ...EventFetcherOption) ([]OverflowPastEvent, error)

FetchEvents using the given options

func (*OverflowState) FillUpStorage

func (o *OverflowState) FillUpStorage(accountName string) *OverflowState

A method to fill up a users storage, useful when testing

func (*OverflowState) GetAccount

func (f *OverflowState) GetAccount(key string) (*flow.Account, error)

GetAccount takes the account name and returns the state of that account on the given network.

func (*OverflowState) GetBlockAtHeight

func (f *OverflowState) GetBlockAtHeight(height uint64) (*flow.Block, error)

get block at a given height

func (*OverflowState) GetBlockById

func (f *OverflowState) GetBlockById(blockId string) (*flow.Block, error)

blockId should be a hexadecimal string

func (*OverflowState) GetFreeCapacity

func (o *OverflowState) GetFreeCapacity(accountName string) int

Get the free capacity in an account

func (*OverflowState) GetLatestBlock

func (f *OverflowState) GetLatestBlock() (*flow.Block, error)

get the latest block

func (*OverflowState) InitializeContracts

func (o *OverflowState) InitializeContracts() *OverflowState

InitializeContracts installs all contracts in the deployment block for the configured network

func (*OverflowState) InlineScript deprecated added in v1.0.0

func (o *OverflowState) InlineScript(content string) FlowScriptBuilder

Script start a script builder with the inline script as body

Deprecated: use FlowInteractionBuilder and the Script method

func (*OverflowState) Parse

func (o *OverflowState) Parse(codeFileName string, code []byte, network string) (string, error)

Parse a given file into a resolved version

func (*OverflowState) ParseAll

func (o *OverflowState) ParseAll() (*Solution, error)

Parse the given overflow state into a solution/npm-module

func (*OverflowState) ParseAllWithConfig

func (o *OverflowState) ParseAllWithConfig(skipContracts bool, txSkip []string, scriptSkip []string) (*Solution, error)

Parse the gieven overflow state with filters

func (*OverflowState) ParseArgumentsWithoutType deprecated added in v1.0.0

func (f *OverflowState) ParseArgumentsWithoutType(fileName string, code []byte, inputArgs map[string]string) ([]cadence.Value, error)

Deprecated: use the new Tx/Script method and the argument functions

func (*OverflowState) Script

func (o *OverflowState) Script(filename string, opts ...InteractionOption) *OverflowScriptResult

run a script with the given code/filanem an options

func (*OverflowState) ScriptFN

func (o *OverflowState) ScriptFN(outerOpts ...InteractionOption) ScriptFunction

compose interactionOptions into a new Script function

func (*OverflowState) ScriptFileNameFN

func (o *OverflowState) ScriptFileNameFN(filename string, outerOpts ...InteractionOption) ScriptOptsFunction

compose fileName and interactionOptions into a new Script function

func (*OverflowState) ScriptFromFile deprecated added in v1.0.0

func (o *OverflowState) ScriptFromFile(filename string) FlowScriptBuilder

ScriptFromFile will start a flow script builder

Deprecated: use FlowInteractionBuilder and the Script method

func (*OverflowState) ServiceAccountName

func (o *OverflowState) ServiceAccountName() string

ServiceAccountName return the name of the current service account Note that if `PrependNetworkToAccountNames` is specified it is prefixed with the network so that you can use the same logical name accross networks

func (*OverflowState) SignUserMessage

func (f *OverflowState) SignUserMessage(account string, message string) (string, error)

Sign a user message

func (*OverflowState) SimpleTxArgs deprecated added in v1.0.0

func (o *OverflowState) SimpleTxArgs(filename string, signer string, args *FlowArgumentsBuilder)

Deprecated: Use Tx()

func (*OverflowState) Transaction deprecated added in v1.0.0

func (o *OverflowState) Transaction(content string) FlowInteractionBuilder

Deprecated: Use Tx()

Transaction will start a flow transaction builder using the inline transaction

func (*OverflowState) TransactionFromFile deprecated added in v1.0.0

func (o *OverflowState) TransactionFromFile(filename string) FlowInteractionBuilder

Deprecated: Use Tx()

TransactionFromFile will start a flow transaction builder

func (*OverflowState) Tx

func (o *OverflowState) Tx(filename string, opts ...InteractionOption) *OverflowResult

The main function for running an transasction in overflow

func (*OverflowState) TxFN

func (o *OverflowState) TxFN(outerOpts ...InteractionOption) TransactionFunction

If you store this in a struct and add arguments to it it will not reset between calls

func (*OverflowState) TxFileNameFN

func (o *OverflowState) TxFileNameFN(filename string, outerOpts ...InteractionOption) TransactionOptsFunction

func (*OverflowState) UploadFile

func (o *OverflowState) UploadFile(filename string, accountName string) error

UploadFile reads a file, base64 encodes it and chunk upload to /storage/upload

func (*OverflowState) UploadImageAsDataUrl

func (o *OverflowState) UploadImageAsDataUrl(filename string, accountName string) error

UploadImageAsDataUrl will upload a image file from the filesystem into /storage/upload of the given account

func (*OverflowState) UploadString

func (o *OverflowState) UploadString(content string, accountName string) error

UploadString will upload the given string data in 1mb chunkts to /storage/upload of the given account

type PrinterBuilder

type PrinterBuilder struct {
	Events      bool
	EventFilter OverflowEventFilter
	Meter       int
	EmulatorLog bool
}

a type representing the accuumlated state in the builder

the default setting is to print one line for each transaction with meter and all events

type PrinterOption

type PrinterOption func(*PrinterBuilder)

a type represneting seting an option in the printer builder

func WithEmulatorLog

func WithEmulatorLog() PrinterOption

print the emulator log. NB! Verbose

func WithEventFilter

func WithEventFilter(filter OverflowEventFilter) PrinterOption

filter out events that are printed

func WithFullMeter

func WithFullMeter() PrinterOption

print full meter verbose mode

func WithMeter

func WithMeter() PrinterOption

print meters as part of the transaction output line

func WithoutEvents

func WithoutEvents() PrinterOption

do not print events

func WithoutMeter

func WithoutMeter(value int) PrinterOption

do not print meter

type ScriptFunction

type ScriptFunction func(filename string, opts ...InteractionOption) *OverflowScriptResult

a type used for composing scripts

type ScriptOptsFunction

type ScriptOptsFunction func(opts ...InteractionOption) *OverflowScriptResult

a type used for composing scripts

type Solution

type Solution struct {

	//all transactions with name and what paremters they have
	Transactions map[string]*DeclarationInfo `json:"transactions"`

	//all scripts with name and paramters they have
	Scripts map[string]*DeclarationInfo `json:"scripts"`

	//all networks with associated scripts/tranasctions/contracts preresolved
	Networks map[string]*SolutionNetwork `json:"networks"`

	//warnings accumulated during parsing
	Warnings []string `json:"warnings"`
}

a type representing the raw solutions that contains all transactions, scripts, networks and warnings of any

func (*Solution) MergeSpecAndCode

func (s *Solution) MergeSpecAndCode() *MergedSolution

merge the given Solution into a MergedSolution that is suited for exposing as an NPM module

type SolutionNetwork

type SolutionNetwork struct {
	Scripts      map[string]string  `json:"scripts"`
	Transactions map[string]string  `json:"transactions,omitempty"`
	Contracts    *map[string]string `json:"contracts,omitempty"`
}

a type representing one network in a solution, so mainnet/testnet/emulator

type TransactionFunction

type TransactionFunction func(filename string, opts ...InteractionOption) *OverflowResult

a type to define a function used to compose Transaction interactions

type TransactionOptsFunction

type TransactionOptsFunction func(opts ...InteractionOption) *OverflowResult

a type to define a function used to compose Transaction interactions

type TransactionResult deprecated

type TransactionResult struct {
	Err     error
	Events  []*FormatedEvent
	Result  *OverflowResult
	Testing *testing.T
}

TransactionResult

The old result object from an transaction

Deprecated: use the new Tx() method and OverflowResult

func (TransactionResult) AssertComputationLessThenOrEqual deprecated

func (t TransactionResult) AssertComputationLessThenOrEqual(computation int) TransactionResult

Deprecated: use the new Tx() method and Asserts on the result

func (TransactionResult) AssertComputationUsed deprecated

func (t TransactionResult) AssertComputationUsed(computation int) TransactionResult

Deprecated: use the new Tx() method and Asserts on the result

func (TransactionResult) AssertDebugLog deprecated

func (t TransactionResult) AssertDebugLog(message ...string) TransactionResult

Deprecated: use the new Tx() method and Asserts on the result

func (TransactionResult) AssertEmitEvent deprecated

func (t TransactionResult) AssertEmitEvent(event ...*FormatedEvent) TransactionResult

Deprecated: use the new Tx() method and Asserts on the result

func (TransactionResult) AssertEmitEventJson deprecated

func (t TransactionResult) AssertEmitEventJson(event ...string) TransactionResult

Deprecated: use the new Tx() method and Asserts on the result

func (TransactionResult) AssertEmitEventName deprecated

func (t TransactionResult) AssertEmitEventName(event ...string) TransactionResult

Deprecated: use the new Tx() method and Asserts on the result

func (TransactionResult) AssertEmitEventNameShortForm deprecated

func (t TransactionResult) AssertEmitEventNameShortForm(event ...string) TransactionResult

Deprecated: use the new Tx() method and Asserts on the result

func (TransactionResult) AssertEmulatorLog deprecated

func (t TransactionResult) AssertEmulatorLog(message string) TransactionResult

Deprecated: use the new Tx() method and Asserts on the result

func (TransactionResult) AssertEventCount deprecated

func (t TransactionResult) AssertEventCount(number int) TransactionResult

Deprecated: use the new Tx() method and Asserts on the result

func (TransactionResult) AssertFailure deprecated

func (t TransactionResult) AssertFailure(msg string) TransactionResult

Deprecated: use the new Tx() method and Asserts on the result

func (TransactionResult) AssertNoEvents deprecated

func (t TransactionResult) AssertNoEvents() TransactionResult

Deprecated: use the new Tx() method and Asserts on the result

func (TransactionResult) AssertPartialEvent deprecated

func (t TransactionResult) AssertPartialEvent(expected *FormatedEvent) TransactionResult

Deprecated: use the new Tx() method and Asserts on the result

func (TransactionResult) AssertSuccess deprecated

func (t TransactionResult) AssertSuccess() TransactionResult

Deprecated: use the new Tx() method and Asserts on the result

func (TransactionResult) GetIdFromEvent

func (t TransactionResult) GetIdFromEvent(eventName string, fieldName string) uint64

Deprecated use the new Tx() method and Asserts on the result

Jump to

Keyboard shortcuts

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