gwtf

package
v2.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2021 License: MIT Imports: 29 Imported by: 22

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CadenceValueToInterface

func CadenceValueToInterface(field cadence.Value) interface{}

CadenceValueToInterface convert a candence.Value into interface{}

func CadenceValueToJsonString

func CadenceValueToJsonString(value cadence.Value) string

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

func EventsToWebhookParams

func EventsToWebhookParams(events []*FormatedEvent) *discordgo.WebhookParams

EventsToWebhookParams convert events to rich webhook

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 DiscordWebhook

type DiscordWebhook struct {
	ID    string `json:"id"`
	Token string `json:"token"`
	Wait  bool   `json:"wait"`
}

DiscordWebhook stores information about a webhook

func NewDiscordWebhook

func NewDiscordWebhook(url string) DiscordWebhook

NewDiscordWebhook create a new discord webhook from an discord url on the form ofhttps://discord.com/api/webhooks/<id>/<token>

func (DiscordWebhook) SendEventsToWebhook

func (dw DiscordWebhook) SendEventsToWebhook(events []*FormatedEvent) (*discordgo.Message, error)

SendEventsToWebhook Sends events to a webhook

type EventFetcherBuilder

type EventFetcherBuilder struct {
	GoWithTheFlow         *GoWithTheFlow
	EventsAndIgnoreFields map[string][]string
	FromIndex             int64
	EndAtCurrentHeight    bool
	EndIndex              uint64
	ProgressFile          string
	context.Context
	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

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

Run runs the eventfetcher returning events or an error

func (EventFetcherBuilder) RunAndSendToWebhook

func (e EventFetcherBuilder) RunAndSendToWebhook(url string) (*discordgo.Message, error)

RunAndSendToWebhook runs the eventFetcher and sends the event to a webhook with the provided url

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) 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 string, 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()

Run executes a read only script

func (FlowScriptBuilder) RunFailOnError added in v2.1.1

func (t FlowScriptBuilder) RunFailOnError() cadence.Value

func (FlowScriptBuilder) RunReturns

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

RunReturns executes a read only script

func (FlowScriptBuilder) RunReturnsInterface

func (t FlowScriptBuilder) RunReturnsInterface() interface{}

RunReturnsInterface runs the script and returns interface{}

func (FlowScriptBuilder) RunReturnsJsonString

func (t FlowScriptBuilder) RunReturnsJsonString() 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
	MainSigner     *flowkit.Account
	PayloadSigners []*flowkit.Account
	GasLimit       uint64
}

FlowTransactionBuilder used to create a builder pattern for a transaction

func (FlowTransactionBuilder) AccountArgument

func (t 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 (t FlowTransactionBuilder) BooleanArgument(value bool) FlowTransactionBuilder

BooleanArgument add a Boolean Argument to the transaction

func (FlowTransactionBuilder) BytesArgument

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

BytesArgument add a Bytes Argument to the transaction

func (FlowTransactionBuilder) DateStringAsUnixTimestamp

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

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

func (FlowTransactionBuilder) Fix64Argument

func (t 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 (t FlowTransactionBuilder) Int128Argument(value int) FlowTransactionBuilder

Int128Argument add an Int128 Argument to the transaction

func (FlowTransactionBuilder) Int16Argument

func (t FlowTransactionBuilder) Int16Argument(value int16) FlowTransactionBuilder

Int16Argument add an Int16 Argument to the transaction

func (FlowTransactionBuilder) Int256Argument

func (t FlowTransactionBuilder) Int256Argument(value int) FlowTransactionBuilder

Int256Argument add an Int256 Argument to the transaction

func (FlowTransactionBuilder) Int32Argument

func (t FlowTransactionBuilder) Int32Argument(value int32) FlowTransactionBuilder

Int32Argument add an Int32 Argument to the transaction

func (FlowTransactionBuilder) Int64Argument

func (t FlowTransactionBuilder) Int64Argument(value int64) FlowTransactionBuilder

Int64Argument add an Int64 Argument to the transaction

func (FlowTransactionBuilder) Int8Argument

func (t FlowTransactionBuilder) Int8Argument(value int8) FlowTransactionBuilder

Int8Argument add an Int8 Argument to the transaction

func (FlowTransactionBuilder) IntArgument

func (t FlowTransactionBuilder) IntArgument(value int) FlowTransactionBuilder

IntArgument add an Int Argument to the transaction

func (FlowTransactionBuilder) PayloadSigner

func (t FlowTransactionBuilder) PayloadSigner(value string) FlowTransactionBuilder

PayloadSigner set a signer for the payload

func (FlowTransactionBuilder) RawAccountArgument

func (t FlowTransactionBuilder) RawAccountArgument(key string) FlowTransactionBuilder

RawAccountArgument add an account from a string as an argument

func (FlowTransactionBuilder) Run

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

Run run the transaction

func (FlowTransactionBuilder) RunE

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

RunE runs returns error

func (FlowTransactionBuilder) RunPrintEvents

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

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

func (FlowTransactionBuilder) RunPrintEventsFull

func (t FlowTransactionBuilder) RunPrintEventsFull()

RunPrintEventsFull will run a transaction and print all events

func (FlowTransactionBuilder) SignProposeAndPayAs

func (t FlowTransactionBuilder) SignProposeAndPayAs(signer string) FlowTransactionBuilder

SignProposeAndPayAs set the payer, proposer and envelope signer

func (FlowTransactionBuilder) SignProposeAndPayAsService

func (t FlowTransactionBuilder) SignProposeAndPayAsService() FlowTransactionBuilder

SignProposeAndPayAsService set the payer, proposer and envelope signer

func (FlowTransactionBuilder) StringArgument

func (t FlowTransactionBuilder) StringArgument(value string) FlowTransactionBuilder

StringArgument add a String Argument to the transaction

func (FlowTransactionBuilder) StringArrayArgument added in v2.3.1

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

Argument add an argument to the transaction

func (FlowTransactionBuilder) Test

func (FlowTransactionBuilder) UFix64Argument

func (t FlowTransactionBuilder) UFix64Argument(value string) FlowTransactionBuilder

UFix64Argument add a UFix64 Argument to the transaction

func (FlowTransactionBuilder) UInt128Argument

func (t FlowTransactionBuilder) UInt128Argument(value uint) FlowTransactionBuilder

UInt128Argument add an UInt128 Argument to the transaction

func (FlowTransactionBuilder) UInt16Argument

func (t FlowTransactionBuilder) UInt16Argument(value uint16) FlowTransactionBuilder

UInt16Argument add an UInt16 Argument to the transaction

func (FlowTransactionBuilder) UInt256Argument

func (t FlowTransactionBuilder) UInt256Argument(value uint) FlowTransactionBuilder

UInt256Argument add an UInt256 Argument to the transaction

func (FlowTransactionBuilder) UInt32Argument

func (t FlowTransactionBuilder) UInt32Argument(value uint32) FlowTransactionBuilder

UInt32Argument add an UInt32 Argument to the transaction

func (FlowTransactionBuilder) UInt64Argument

func (t FlowTransactionBuilder) UInt64Argument(value uint64) FlowTransactionBuilder

UInt64Argument add an UInt64 Argument to the transaction

func (FlowTransactionBuilder) UInt8Argument

func (t FlowTransactionBuilder) UInt8Argument(value uint8) FlowTransactionBuilder

UInt8Argument add an UInt8 Argument to the transaction

func (FlowTransactionBuilder) UIntArgument

func (t FlowTransactionBuilder) UIntArgument(value uint) FlowTransactionBuilder

UIntArgument add an UInt Argument to the transaction

func (FlowTransactionBuilder) Word16Argument

func (t FlowTransactionBuilder) Word16Argument(value uint16) FlowTransactionBuilder

Word16Argument add a Word16 Argument to the transaction

func (FlowTransactionBuilder) Word32Argument

func (t FlowTransactionBuilder) Word32Argument(value uint32) FlowTransactionBuilder

Word32Argument add a Word32 Argument to the transaction

func (FlowTransactionBuilder) Word64Argument

func (t FlowTransactionBuilder) Word64Argument(value uint64) FlowTransactionBuilder

Word64Argument add a Word64 Argument to the transaction

func (FlowTransactionBuilder) Word8Argument

func (t 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 []client.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
	Services                     *services.Services
	Network                      string
	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 added in v2.1.1

func NewTestingEmulator() *GoWithTheFlow

NewTEstingEmulator create new emulator that ignore all log messages

func (*GoWithTheFlow) Account

func (f *GoWithTheFlow) Account(key string) *flowkit.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(saAccountName string) *GoWithTheFlow

func (*GoWithTheFlow) CreateAccountsE added in v2.1.2

func (f *GoWithTheFlow) CreateAccountsE(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(url string, accountName string) error

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

func (*GoWithTheFlow) DownloadImageAndUploadAsDataUrl

func (f *GoWithTheFlow) DownloadImageAndUploadAsDataUrl(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() *GoWithTheFlow

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

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(filename string, accountName string) error

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

func (*GoWithTheFlow) UploadImageAsDataUrl

func (f *GoWithTheFlow) UploadImageAsDataUrl(filename string, 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(content string, accountName string) error

UploadString will upload the given string data in 1mb chunkts 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 added in v2.1.2

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 added in v2.1.2

func (t TransactionResult) AssertFailure(msg string) TransactionResult

func (TransactionResult) AssertNoEvents

func (t TransactionResult) AssertNoEvents() TransactionResult

func (TransactionResult) AssertPartialEvent added in v2.3.0

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

func (TransactionResult) AssertSuccess

func (t TransactionResult) AssertSuccess() TransactionResult

Jump to

Keyboard shortcuts

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