gwtf

package
v0.0.0-...-6a90148 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2024 License: Apache-2.0, MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CadenceValueToInterface

func CadenceValueToInterface(field cadence.Value) interface{}

CadenceValueToInterface convert a cadence.Value into interface{}

func CadenceValueToJSONString

func CadenceValueToJSONString(value cadence.Value) string

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

func PrintEvents

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

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

Types

type EventFetcherBuilder

type EventFetcherBuilder struct {
	GoWithTheFlow         *GoWithTheFlow
	EventsAndIgnoreFields map[string][]string
	FromIndex             int64
	EndAtCurrentHeight    bool
	EndIndex              uint64
	ProgressFile          string
	NumberOfWorkers       int
	EventBatchSize        uint64
}

EventFetcherBuilder builder to hold info about eventhook context.

func (EventFetcherBuilder) BatchSize

func (e EventFetcherBuilder) BatchSize(batchSize uint64) EventFetcherBuilder

BatchSize sets the size of a batch

func (EventFetcherBuilder) End

func (e EventFetcherBuilder) End(blockHeight uint64) EventFetcherBuilder

End specify what index to end at

func (EventFetcherBuilder) Event

func (e EventFetcherBuilder) Event(eventName string) EventFetcherBuilder

Event fetches and Events and all its fields

func (EventFetcherBuilder) EventIgnoringFields

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

EventIgnoringFields fetch event and ignore the specified fields

func (EventFetcherBuilder) From

func (e EventFetcherBuilder) From(blockHeight int64) EventFetcherBuilder

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

func (EventFetcherBuilder) Last

Last fetch events from the number last blocks

func (EventFetcherBuilder) Run

Run runs the eventfetcher returning events or an error

func (EventFetcherBuilder) Start

func (e EventFetcherBuilder) Start(blockHeight int64) EventFetcherBuilder

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

func (EventFetcherBuilder) TrackProgressIn

func (e EventFetcherBuilder) TrackProgressIn(fileName string) EventFetcherBuilder

TrackProgressIn Specify a file to store progress in

func (EventFetcherBuilder) Until

func (e EventFetcherBuilder) Until(blockHeight uint64) EventFetcherBuilder

Until specify what index to end at

func (EventFetcherBuilder) UntilCurrent

func (e EventFetcherBuilder) UntilCurrent() EventFetcherBuilder

UntilCurrent Specify to fetch events until the current Block

func (EventFetcherBuilder) Workers

func (e EventFetcherBuilder) Workers(workers int) EventFetcherBuilder

Workers sets the number of workers.

type FlowScriptBuilder

type FlowScriptBuilder struct {
	GoWithTheFlow  *GoWithTheFlow
	FileName       string
	Arguments      []cadence.Value
	ScriptAsString string
}

FlowScriptBuilder is a struct to hold information for running a script

func (FlowScriptBuilder) AccountArgument

func (t FlowScriptBuilder) AccountArgument(key string) FlowScriptBuilder

AccountArgument add an account as an argument

func (FlowScriptBuilder) Argument

Argument add an argument to the transaction

func (FlowScriptBuilder) ArgumentList

func (t FlowScriptBuilder) ArgumentList(values []cadence.Value) FlowScriptBuilder

ArgumentList add a list argument to the transaction

func (FlowScriptBuilder) BooleanArgument

func (t FlowScriptBuilder) BooleanArgument(value bool) FlowScriptBuilder

BooleanArgument add a Boolean Argument to the transaction

func (FlowScriptBuilder) BytesArgument

func (t FlowScriptBuilder) BytesArgument(value []byte) FlowScriptBuilder

BytesArgument add a Bytes Argument to the transaction

func (FlowScriptBuilder) DateStringAsUnixTimestamp

func (t FlowScriptBuilder) DateStringAsUnixTimestamp(dateString, timezone string) FlowScriptBuilder

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

func (FlowScriptBuilder) Fix64Argument

func (t FlowScriptBuilder) Fix64Argument(value string) FlowScriptBuilder

Fix64Argument add a Fix64 Argument to the transaction

func (FlowScriptBuilder) Int128Argument

func (t FlowScriptBuilder) Int128Argument(value int) FlowScriptBuilder

Int128Argument add an Int128 Argument to the transaction

func (FlowScriptBuilder) Int16Argument

func (t FlowScriptBuilder) Int16Argument(value int16) FlowScriptBuilder

Int16Argument add an Int16 Argument to the transaction

func (FlowScriptBuilder) Int256Argument

func (t FlowScriptBuilder) Int256Argument(value int) FlowScriptBuilder

Int256Argument add an Int256 Argument to the transaction

func (FlowScriptBuilder) Int32Argument

func (t FlowScriptBuilder) Int32Argument(value int32) FlowScriptBuilder

Int32Argument add an Int32 Argument to the transaction

func (FlowScriptBuilder) Int64Argument

func (t FlowScriptBuilder) Int64Argument(value int64) FlowScriptBuilder

Int64Argument add an Int64 Argument to the transaction

func (FlowScriptBuilder) Int8Argument

func (t FlowScriptBuilder) Int8Argument(value int8) FlowScriptBuilder

Int8Argument add an Int8 Argument to the transaction

func (FlowScriptBuilder) IntArgument

func (t FlowScriptBuilder) IntArgument(value int) FlowScriptBuilder

IntArgument add an Int Argument to the transaction

func (FlowScriptBuilder) RawAccountArgument

func (t FlowScriptBuilder) RawAccountArgument(key string) FlowScriptBuilder

RawAccountArgument add an account from a string as an argument

func (FlowScriptBuilder) Run

func (t FlowScriptBuilder) Run(ctx context.Context)

Run executes a read only script

func (FlowScriptBuilder) RunFailOnError

func (t FlowScriptBuilder) RunFailOnError(ctx context.Context) cadence.Value

func (FlowScriptBuilder) RunReturns

func (t FlowScriptBuilder) RunReturns(ctx context.Context) (cadence.Value, error)

RunReturns executes a read only script

func (FlowScriptBuilder) RunReturnsInterface

func (t FlowScriptBuilder) RunReturnsInterface(ctx context.Context) interface{}

RunReturnsInterface runs the script and returns interface{}

func (FlowScriptBuilder) RunReturnsJSONString

func (t FlowScriptBuilder) RunReturnsJSONString(ctx context.Context) string

RunReturnsJSONString runs the script and returns pretty printed json string

func (FlowScriptBuilder) StringArgument

func (t FlowScriptBuilder) StringArgument(value string) FlowScriptBuilder

StringArgument add a String Argument to the transaction

func (FlowScriptBuilder) UFix64Argument

func (t FlowScriptBuilder) UFix64Argument(value string) FlowScriptBuilder

UFix64Argument add a UFix64 Argument to the transaction

func (FlowScriptBuilder) UInt128Argument

func (t FlowScriptBuilder) UInt128Argument(value uint) FlowScriptBuilder

UInt128Argument add an UInt128 Argument to the transaction

func (FlowScriptBuilder) UInt16Argument

func (t FlowScriptBuilder) UInt16Argument(value uint16) FlowScriptBuilder

UInt16Argument add an UInt16 Argument to the transaction

func (FlowScriptBuilder) UInt256Argument

func (t FlowScriptBuilder) UInt256Argument(value uint) FlowScriptBuilder

UInt256Argument add an UInt256 Argument to the transaction

func (FlowScriptBuilder) UInt32Argument

func (t FlowScriptBuilder) UInt32Argument(value uint32) FlowScriptBuilder

UInt32Argument add an UInt32 Argument to the transaction

func (FlowScriptBuilder) UInt64Argument

func (t FlowScriptBuilder) UInt64Argument(value uint64) FlowScriptBuilder

UInt64Argument add an UInt64 Argument to the transaction

func (FlowScriptBuilder) UInt8Argument

func (t FlowScriptBuilder) UInt8Argument(value uint8) FlowScriptBuilder

UInt8Argument add an UInt8 Argument to the transaction

func (FlowScriptBuilder) UIntArgument

func (t FlowScriptBuilder) UIntArgument(value uint) FlowScriptBuilder

UIntArgument add an UInt Argument to the transaction

func (FlowScriptBuilder) Word16Argument

func (t FlowScriptBuilder) Word16Argument(value uint16) FlowScriptBuilder

Word16Argument add a Word16 Argument to the transaction

func (FlowScriptBuilder) Word32Argument

func (t FlowScriptBuilder) Word32Argument(value uint32) FlowScriptBuilder

Word32Argument add a Word32 Argument to the transaction

func (FlowScriptBuilder) Word64Argument

func (t FlowScriptBuilder) Word64Argument(value uint64) FlowScriptBuilder

Word64Argument add a Word64 Argument to the transaction

func (FlowScriptBuilder) Word8Argument

func (t FlowScriptBuilder) Word8Argument(value uint8) FlowScriptBuilder

Word8Argument add a Word8 Argument to the transaction

type FlowTransactionBuilder

type FlowTransactionBuilder struct {
	GoWithTheFlow  *GoWithTheFlow
	FileName       string
	Content        string
	Arguments      []cadence.Value
	Proposer       *accounts.Account
	Payer          *accounts.Account
	MainSigner     *accounts.Account
	PayloadSigners []*accounts.Account
	GasLimit       uint64
}

FlowTransactionBuilder used to create a builder pattern for a transaction

func (FlowTransactionBuilder) AccountArgument

func (tb FlowTransactionBuilder) AccountArgument(key string) FlowTransactionBuilder

AccountArgument add an account as an argument

func (FlowTransactionBuilder) Argument

Argument add an argument to the transaction

func (FlowTransactionBuilder) BooleanArgument

func (tb FlowTransactionBuilder) BooleanArgument(value bool) FlowTransactionBuilder

BooleanArgument add a Boolean Argument to the transaction

func (FlowTransactionBuilder) BytesArgument

func (tb FlowTransactionBuilder) BytesArgument(value []byte) FlowTransactionBuilder

BytesArgument add a Bytes Argument to the transaction

func (FlowTransactionBuilder) DateStringAsUnixTimestamp

func (tb FlowTransactionBuilder) DateStringAsUnixTimestamp(dateString string, timezone string) FlowTransactionBuilder

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

func (FlowTransactionBuilder) Fix64Argument

func (tb FlowTransactionBuilder) Fix64Argument(value string) FlowTransactionBuilder

Fix64Argument add a Fix64 Argument to the transaction

func (FlowTransactionBuilder) Gas

Gas sets the gas limit for this transaction

func (FlowTransactionBuilder) Int128Argument

func (tb FlowTransactionBuilder) Int128Argument(value int) FlowTransactionBuilder

Int128Argument add an Int128 Argument to the transaction

func (FlowTransactionBuilder) Int16Argument

func (tb FlowTransactionBuilder) Int16Argument(value int16) FlowTransactionBuilder

Int16Argument add an Int16 Argument to the transaction

func (FlowTransactionBuilder) Int256Argument

func (tb FlowTransactionBuilder) Int256Argument(value int) FlowTransactionBuilder

Int256Argument add an Int256 Argument to the transaction

func (FlowTransactionBuilder) Int32Argument

func (tb FlowTransactionBuilder) Int32Argument(value int32) FlowTransactionBuilder

Int32Argument add an Int32 Argument to the transaction

func (FlowTransactionBuilder) Int64Argument

func (tb FlowTransactionBuilder) Int64Argument(value int64) FlowTransactionBuilder

Int64Argument add an Int64 Argument to the transaction

func (FlowTransactionBuilder) Int8Argument

func (tb FlowTransactionBuilder) Int8Argument(value int8) FlowTransactionBuilder

Int8Argument add an Int8 Argument to the transaction

func (FlowTransactionBuilder) IntArgument

func (tb FlowTransactionBuilder) IntArgument(value int) FlowTransactionBuilder

IntArgument add an Int Argument to the transaction

func (FlowTransactionBuilder) PayAs

PayAs sets the payer

func (FlowTransactionBuilder) PayloadSigner

func (tb FlowTransactionBuilder) PayloadSigner(value string) FlowTransactionBuilder

PayloadSigner set a signer for the payload

func (FlowTransactionBuilder) ProposeAs

func (tb FlowTransactionBuilder) ProposeAs(proposer string) FlowTransactionBuilder

ProposeAs sets the proposer

func (FlowTransactionBuilder) RawAccountArgument

func (tb FlowTransactionBuilder) RawAccountArgument(key string) FlowTransactionBuilder

RawAccountArgument add an account from a string as an argument

func (FlowTransactionBuilder) Run

func (tb FlowTransactionBuilder) Run(ctx context.Context) []flow.Event

Run runs the transaction

func (FlowTransactionBuilder) RunE

func (tb FlowTransactionBuilder) RunE(ctx context.Context) ([]flow.Event, error)

RunE runs returns error

func (FlowTransactionBuilder) RunPrintEvents

func (tb FlowTransactionBuilder) RunPrintEvents(ctx context.Context, ignoreFields map[string][]string)

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

func (FlowTransactionBuilder) RunPrintEventsFull

func (tb FlowTransactionBuilder) RunPrintEventsFull(ctx context.Context)

RunPrintEventsFull will run a transaction and print all events

func (FlowTransactionBuilder) SignAndProposeAs

func (tb FlowTransactionBuilder) SignAndProposeAs(signer string) FlowTransactionBuilder

SignAndProposeAs set the proposer and envelope signer

func (FlowTransactionBuilder) SignProposeAndPayAs

func (tb FlowTransactionBuilder) SignProposeAndPayAs(signer string) FlowTransactionBuilder

SignProposeAndPayAs set the payer, proposer and envelope signer

func (FlowTransactionBuilder) SignProposeAndPayAsService

func (tb FlowTransactionBuilder) SignProposeAndPayAsService() FlowTransactionBuilder

SignProposeAndPayAsService set the payer, proposer and envelope signer

func (FlowTransactionBuilder) StringArgument

func (tb FlowTransactionBuilder) StringArgument(value string) FlowTransactionBuilder

StringArgument add a String Argument to the transaction

func (FlowTransactionBuilder) StringArrayArgument

func (tb FlowTransactionBuilder) StringArrayArgument(value ...string) FlowTransactionBuilder

StringArrayArgument add a string array argument to the transaction

func (FlowTransactionBuilder) Test

func (FlowTransactionBuilder) UFix64Argument

func (tb FlowTransactionBuilder) UFix64Argument(value string) FlowTransactionBuilder

UFix64Argument add a UFix64 Argument to the transaction

func (FlowTransactionBuilder) UInt128Argument

func (tb FlowTransactionBuilder) UInt128Argument(value uint) FlowTransactionBuilder

UInt128Argument add an UInt128 Argument to the transaction

func (FlowTransactionBuilder) UInt16Argument

func (tb FlowTransactionBuilder) UInt16Argument(value uint16) FlowTransactionBuilder

UInt16Argument add an UInt16 Argument to the transaction

func (FlowTransactionBuilder) UInt256Argument

func (tb FlowTransactionBuilder) UInt256Argument(value uint) FlowTransactionBuilder

UInt256Argument add an UInt256 Argument to the transaction

func (FlowTransactionBuilder) UInt32Argument

func (tb FlowTransactionBuilder) UInt32Argument(value uint32) FlowTransactionBuilder

UInt32Argument add an UInt32 Argument to the transaction

func (FlowTransactionBuilder) UInt64Argument

func (tb FlowTransactionBuilder) UInt64Argument(value uint64) FlowTransactionBuilder

UInt64Argument add an UInt64 Argument to the transaction

func (FlowTransactionBuilder) UInt8Argument

func (tb FlowTransactionBuilder) UInt8Argument(value uint8) FlowTransactionBuilder

UInt8Argument add an UInt8 Argument to the transaction

func (FlowTransactionBuilder) UIntArgument

func (tb FlowTransactionBuilder) UIntArgument(value uint) FlowTransactionBuilder

UIntArgument add an UInt Argument to the transaction

func (FlowTransactionBuilder) Word16Argument

func (tb FlowTransactionBuilder) Word16Argument(value uint16) FlowTransactionBuilder

Word16Argument add a Word16 Argument to the transaction

func (FlowTransactionBuilder) Word32Argument

func (tb FlowTransactionBuilder) Word32Argument(value uint32) FlowTransactionBuilder

Word32Argument add a Word32 Argument to the transaction

func (FlowTransactionBuilder) Word64Argument

func (tb FlowTransactionBuilder) Word64Argument(value uint64) FlowTransactionBuilder

Word64Argument add a Word64 Argument to the transaction

func (FlowTransactionBuilder) Word8Argument

func (tb FlowTransactionBuilder) Word8Argument(value uint8) FlowTransactionBuilder

Word8Argument add a Word8 Argument to the transaction

type FormatedEvent

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

FormatedEvent event in a more condensed formated form

func FormatEvents

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

FormatEvents

func NewTestEvent

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

func ParseEvent

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

func (e FormatedEvent) String() string

String pretty print an event as a String

type GoWithTheFlow

type GoWithTheFlow struct {
	State                        *flowkit.State
	Client                       access.Client
	Services                     flowkit.Services
	Logger                       output.Logger
	PrependNetworkToAccountNames bool
}

GoWithTheFlow Entire configuration to work with Go With the Flow

func NewGoWithTheFlow

func NewGoWithTheFlow(filenames []string, network string, inMemory bool, loglevel int) *GoWithTheFlow

NewGoWithTheFlow with custom file panic on error

func NewGoWithTheFlowDevNet

func NewGoWithTheFlowDevNet() *GoWithTheFlow

NewGoWithTheFlowDevNet creates a new gwtf client for devnet/testnet

func NewGoWithTheFlowEmulator

func NewGoWithTheFlowEmulator() *GoWithTheFlow

NewGoWithTheFlowEmulator create a new client

func NewGoWithTheFlowError

func NewGoWithTheFlowError(paths []string, network string, inMemory bool, logLevel int) (*GoWithTheFlow, error)

NewGoWithTheFlowError creates a new local go with the flow client

func NewGoWithTheFlowForNetwork

func NewGoWithTheFlowForNetwork(network string) *GoWithTheFlow

NewGoWithTheFlowForNetwork creates a new gwtf client for the provided network

func NewGoWithTheFlowInMemoryEmulator

func NewGoWithTheFlowInMemoryEmulator() *GoWithTheFlow

NewGoWithTheFlowInMemoryEmulator this method is used to create an in memory emulator, deploy all contracts for the emulator and create all accounts

func NewGoWithTheFlowMainNet

func NewGoWithTheFlowMainNet() *GoWithTheFlow

NewGoWithTheFlowMainNet creates a new gwft client for mainnet

func NewTestingEmulator

func NewTestingEmulator() *GoWithTheFlow

NewTestingEmulator create new emulator that ignore all log messages

func (*GoWithTheFlow) Account

func (f *GoWithTheFlow) Account(key string) *accounts.Account

Account fetch an account from flow.json, prefixing the name with network- as default (can be turned off)

func (*GoWithTheFlow) CreateAccounts

func (f *GoWithTheFlow) CreateAccounts(ctx context.Context, saAccountName string) *GoWithTheFlow

func (*GoWithTheFlow) CreateAccountsE

func (f *GoWithTheFlow) CreateAccountsE(ctx context.Context, saAccountName string) (*GoWithTheFlow, error)

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

func (*GoWithTheFlow) DoNotPrependNetworkToAccountNames

func (f *GoWithTheFlow) DoNotPrependNetworkToAccountNames() *GoWithTheFlow

DoNotPrependNetworkToAccountNames disable the default behavior of prefixing account names with network-

func (*GoWithTheFlow) DownloadAndUploadFile

func (f *GoWithTheFlow) DownloadAndUploadFile(ctx context.Context, url, accountName string) error

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

func (*GoWithTheFlow) DownloadImageAndUploadAsDataURL

func (f *GoWithTheFlow) DownloadImageAndUploadAsDataURL(ctx context.Context, url, accountName string) error

DownloadImageAndUploadAsDataURL download an image and upload as data url

func (*GoWithTheFlow) EventFetcher

func (f *GoWithTheFlow) EventFetcher() EventFetcherBuilder

EventFetcher create an event fetcher builder.

func (*GoWithTheFlow) InitializeContracts

func (f *GoWithTheFlow) InitializeContracts(ctx context.Context) *GoWithTheFlow

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

func (*GoWithTheFlow) InitializeContractsE

func (f *GoWithTheFlow) InitializeContractsE(ctx context.Context) error

InitializeContractsE installs all contracts in the deployment block for the configured network and returns an error if it fails.

func (*GoWithTheFlow) Script

func (f *GoWithTheFlow) Script(content string) FlowScriptBuilder

Script start a script builder with the inline script as body

func (*GoWithTheFlow) ScriptFromFile

func (f *GoWithTheFlow) ScriptFromFile(filename string) FlowScriptBuilder

ScriptFromFile will start a flow script builder

func (*GoWithTheFlow) Transaction

func (f *GoWithTheFlow) Transaction(content string) FlowTransactionBuilder

Transaction will start a flow transaction builder using the inline transaction

func (*GoWithTheFlow) TransactionFromFile

func (f *GoWithTheFlow) TransactionFromFile(filename string) FlowTransactionBuilder

TransactionFromFile will start a flow transaction builder

func (*GoWithTheFlow) UploadFile

func (f *GoWithTheFlow) UploadFile(ctx context.Context, filename, accountName string) error

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

func (*GoWithTheFlow) UploadImageAsDataURL

func (f *GoWithTheFlow) UploadImageAsDataURL(ctx context.Context, filename, accountName string) error

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

func (*GoWithTheFlow) UploadString

func (f *GoWithTheFlow) UploadString(ctx context.Context, content, accountName string) error

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

type TransactionResult

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

func (TransactionResult) AssertDebugLog

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

func (TransactionResult) AssertEmitEvent

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

func (TransactionResult) AssertEmitEventJSON

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

func (TransactionResult) AssertEmitEventName

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

func (TransactionResult) AssertEventCount

func (t TransactionResult) AssertEventCount(number int) TransactionResult

func (TransactionResult) AssertFailure

func (t TransactionResult) AssertFailure(msg string) TransactionResult

func (TransactionResult) AssertNoEvents

func (t TransactionResult) AssertNoEvents() TransactionResult

func (TransactionResult) AssertPartialEvent

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

func (TransactionResult) AssertSuccess

func (t TransactionResult) AssertSuccess() TransactionResult

func (TransactionResult) PrintEvents

func (t TransactionResult) PrintEvents() TransactionResult

Jump to

Keyboard shortcuts

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