gwtf

package
v1.18.1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2021 License: MIT Imports: 23 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAccountContractWitwhAuthInit added in v1.0.1

func AddAccountContractWitwhAuthInit(address flow.Address, contract templates.Contract) *flow.Transaction

AddAccountContractWitwhAuthInit generates a transaction that deploys a contract to an account.

func CadenceValueToInterface added in v1.16.0

func CadenceValueToInterface(field cadence.Value) interface{}

func CadenceValueToJsonString added in v1.16.0

func CadenceValueToJsonString(value cadence.Value) string

func EventsToWebhookParams added in v1.0.1

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

EventsToWebhookParams convert events to rich webhook

func PrintEvents added in v1.0.1

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

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

Types

type DiscordWebhook added in v1.0.1

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

DiscordWebhook stores information about a webhook

func (DiscordWebhook) SendEventsToWebhook added in v1.0.1

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

SendEventsToWebhook Sends events to the webhook with the given name from flow.json

type EventFetcherBuilder added in v1.15.0

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

EventFetcherBuilder builder to hold info about eventhook context

func (EventFetcherBuilder) BatchSize added in v1.15.0

func (e EventFetcherBuilder) BatchSize(batchSize uint64) EventFetcherBuilder

func (EventFetcherBuilder) Context added in v1.15.0

func (EventFetcherBuilder) End added in v1.15.0

func (e EventFetcherBuilder) End(blockHeight uint64) EventFetcherBuilder

End specify what index to end at

func (EventFetcherBuilder) Event added in v1.15.0

func (e EventFetcherBuilder) Event(eventName string) EventFetcherBuilder

Event fetches and Events and all its fields

func (EventFetcherBuilder) EventIgnoringFields added in v1.15.0

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

EventIgnoringFields fetch event and ignore the specified fields

func (EventFetcherBuilder) From added in v1.15.0

func (e EventFetcherBuilder) From(blockHeight int64) EventFetcherBuilder

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

func (EventFetcherBuilder) Last added in v1.15.0

Last fetch events from the number last blocks

func (EventFetcherBuilder) Run added in v1.15.0

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

func (EventFetcherBuilder) SendEventsToWebhook added in v1.15.0

func (e EventFetcherBuilder) SendEventsToWebhook(webhook string) (*discordgo.Message, error)

func (EventFetcherBuilder) Start added in v1.15.0

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 added in v1.15.0

func (e EventFetcherBuilder) TrackProgressIn(fileName string) EventFetcherBuilder

TrackProgressIn Specify a file to store progress in

func (EventFetcherBuilder) Until added in v1.15.0

func (e EventFetcherBuilder) Until(blockHeight uint64) EventFetcherBuilder

Until specify what index to end at

func (EventFetcherBuilder) UntilCurrent added in v1.15.0

func (e EventFetcherBuilder) UntilCurrent() EventFetcherBuilder

UntilCurrent Specify to fetch events until the current Block

func (EventFetcherBuilder) Workers added in v1.15.0

func (e EventFetcherBuilder) Workers(workers int) EventFetcherBuilder

type EventRangeQueryWithIngnorefields added in v1.15.0

type EventRangeQueryWithIngnorefields struct {
	Query        client.EventRangeQuery
	IgnoreFields []string
}

type EventWorkerResult added in v1.15.0

type EventWorkerResult struct {
	Events []*FormatedEvent
	Error  error
}

type FlowScriptBuilder

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

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 added in v1.0.1

func (t FlowScriptBuilder) BooleanArgument(value bool) FlowScriptBuilder

BooleanArgument add a Boolean Argument to the transaction

func (FlowScriptBuilder) BytesArgument added in v1.0.1

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

BytesArgument add a Bytes Argument to the transaction

func (FlowScriptBuilder) Fix64Argument added in v1.0.1

func (t FlowScriptBuilder) Fix64Argument(value string) FlowScriptBuilder

Fix64Argument add a Fix64 Argument to the transaction

func (FlowScriptBuilder) Int128Argument added in v1.0.1

func (t FlowScriptBuilder) Int128Argument(value int) FlowScriptBuilder

Int128Argument add an Int128 Argument to the transaction

func (FlowScriptBuilder) Int16Argument added in v1.0.1

func (t FlowScriptBuilder) Int16Argument(value int16) FlowScriptBuilder

Int16Argument add an Int16 Argument to the transaction

func (FlowScriptBuilder) Int256Argument added in v1.0.1

func (t FlowScriptBuilder) Int256Argument(value int) FlowScriptBuilder

Int256Argument add an Int256 Argument to the transaction

func (FlowScriptBuilder) Int32Argument added in v1.0.1

func (t FlowScriptBuilder) Int32Argument(value int32) FlowScriptBuilder

Int32Argument add an Int32 Argument to the transaction

func (FlowScriptBuilder) Int64Argument added in v1.0.1

func (t FlowScriptBuilder) Int64Argument(value int64) FlowScriptBuilder

Int64Argument add an Int64 Argument to the transaction

func (FlowScriptBuilder) Int8Argument added in v1.0.1

func (t FlowScriptBuilder) Int8Argument(value int8) FlowScriptBuilder

Int8Argument add an Int8 Argument to the transaction

func (FlowScriptBuilder) IntArgument added in v1.0.1

func (t FlowScriptBuilder) IntArgument(value int) FlowScriptBuilder

IntArgument add an Int Argument to the transaction

func (FlowScriptBuilder) Run

func (t FlowScriptBuilder) Run()

Run executes a read only script

func (FlowScriptBuilder) RunReturns

func (t FlowScriptBuilder) RunReturns() cadence.Value

RunReturns executes a read only script

func (FlowScriptBuilder) RunReturnsInterface added in v1.16.0

func (t FlowScriptBuilder) RunReturnsInterface() interface{}

func (FlowScriptBuilder) RunReturnsJsonString added in v1.16.0

func (t FlowScriptBuilder) RunReturnsJsonString() 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 added in v1.0.1

func (t FlowScriptBuilder) UInt128Argument(value uint) FlowScriptBuilder

UInt128Argument add an UInt128 Argument to the transaction

func (FlowScriptBuilder) UInt16Argument added in v1.0.1

func (t FlowScriptBuilder) UInt16Argument(value uint16) FlowScriptBuilder

UInt16Argument add an UInt16 Argument to the transaction

func (FlowScriptBuilder) UInt256Argument added in v1.0.1

func (t FlowScriptBuilder) UInt256Argument(value uint) FlowScriptBuilder

UInt256Argument add an UInt256 Argument to the transaction

func (FlowScriptBuilder) UInt32Argument added in v1.0.1

func (t FlowScriptBuilder) UInt32Argument(value uint32) FlowScriptBuilder

UInt32Argument add an UInt32 Argument to the transaction

func (FlowScriptBuilder) UInt64Argument added in v1.0.1

func (t FlowScriptBuilder) UInt64Argument(value uint64) FlowScriptBuilder

UInt64Argument add an UInt64 Argument to the transaction

func (FlowScriptBuilder) UInt8Argument added in v1.0.1

func (t FlowScriptBuilder) UInt8Argument(value uint8) FlowScriptBuilder

UInt8Argument add an UInt8 Argument to the transaction

func (FlowScriptBuilder) UIntArgument added in v1.0.1

func (t FlowScriptBuilder) UIntArgument(value uint) FlowScriptBuilder

UIntArgument add an UInt Argument to the transaction

func (FlowScriptBuilder) Word16Argument added in v1.0.1

func (t FlowScriptBuilder) Word16Argument(value uint16) FlowScriptBuilder

Word16Argument add a Word16 Argument to the transaction

func (FlowScriptBuilder) Word32Argument added in v1.0.1

func (t FlowScriptBuilder) Word32Argument(value uint32) FlowScriptBuilder

Word32Argument add a Word32 Argument to the transaction

func (FlowScriptBuilder) Word64Argument added in v1.0.1

func (t FlowScriptBuilder) Word64Argument(value uint64) FlowScriptBuilder

Word64Argument add a Word64 Argument to the transaction

func (FlowScriptBuilder) Word8Argument added in v1.0.1

func (t FlowScriptBuilder) Word8Argument(value uint8) FlowScriptBuilder

Word8Argument add a Word8 Argument to the transaction

type FlowTransactionBuilder

type FlowTransactionBuilder struct {
	GoWithTheFlow  *GoWithTheFlow
	FileName       string
	Arguments      []cadence.Value
	MainSigner     *GoWithTheFlowAccount
	PayloadSigners []*GoWithTheFlowAccount
}

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 added in v1.0.1

func (t FlowTransactionBuilder) BooleanArgument(value bool) FlowTransactionBuilder

BooleanArgument add a Boolean Argument to the transaction

func (FlowTransactionBuilder) BytesArgument added in v1.0.1

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

BytesArgument add a Bytes Argument to the transaction

func (FlowTransactionBuilder) Fix64Argument added in v1.0.1

func (t FlowTransactionBuilder) Fix64Argument(value string) FlowTransactionBuilder

Fix64Argument add a Fix64 Argument to the transaction

func (FlowTransactionBuilder) Int128Argument added in v1.0.1

func (t FlowTransactionBuilder) Int128Argument(value int) FlowTransactionBuilder

Int128Argument add an Int128 Argument to the transaction

func (FlowTransactionBuilder) Int16Argument added in v1.0.1

func (t FlowTransactionBuilder) Int16Argument(value int16) FlowTransactionBuilder

Int16Argument add an Int16 Argument to the transaction

func (FlowTransactionBuilder) Int256Argument added in v1.0.1

func (t FlowTransactionBuilder) Int256Argument(value int) FlowTransactionBuilder

Int256Argument add an Int256 Argument to the transaction

func (FlowTransactionBuilder) Int32Argument added in v1.0.1

func (t FlowTransactionBuilder) Int32Argument(value int32) FlowTransactionBuilder

Int32Argument add an Int32 Argument to the transaction

func (FlowTransactionBuilder) Int64Argument added in v1.0.1

func (t FlowTransactionBuilder) Int64Argument(value int64) FlowTransactionBuilder

Int64Argument add an Int64 Argument to the transaction

func (FlowTransactionBuilder) Int8Argument added in v1.0.1

func (t FlowTransactionBuilder) Int8Argument(value int8) FlowTransactionBuilder

Int8Argument add an Int8 Argument to the transaction

func (FlowTransactionBuilder) IntArgument added in v1.0.1

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 added in v1.0.1

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) RunPrintEvents added in v1.0.1

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

RunPrintEvents will run a transaction and print all events

func (FlowTransactionBuilder) RunPrintEventsFull added in v1.0.1

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 added in v1.0.1

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

func (t FlowTransactionBuilder) UFix64Argument(value string) FlowTransactionBuilder

UFix64Argument add a UFix64 Argument to the transaction

func (FlowTransactionBuilder) UInt128Argument added in v1.0.1

func (t FlowTransactionBuilder) UInt128Argument(value uint) FlowTransactionBuilder

UInt128Argument add an UInt128 Argument to the transaction

func (FlowTransactionBuilder) UInt16Argument added in v1.0.1

func (t FlowTransactionBuilder) UInt16Argument(value uint16) FlowTransactionBuilder

UInt16Argument add an UInt16 Argument to the transaction

func (FlowTransactionBuilder) UInt256Argument added in v1.0.1

func (t FlowTransactionBuilder) UInt256Argument(value uint) FlowTransactionBuilder

UInt256Argument add an UInt256 Argument to the transaction

func (FlowTransactionBuilder) UInt32Argument added in v1.0.1

func (t FlowTransactionBuilder) UInt32Argument(value uint32) FlowTransactionBuilder

UInt32Argument add an UInt32 Argument to the transaction

func (FlowTransactionBuilder) UInt64Argument added in v1.0.1

func (t FlowTransactionBuilder) UInt64Argument(value uint64) FlowTransactionBuilder

UInt64Argument add an UInt64 Argument to the transaction

func (FlowTransactionBuilder) UInt8Argument added in v1.0.1

func (t FlowTransactionBuilder) UInt8Argument(value uint8) FlowTransactionBuilder

UInt8Argument add an UInt8 Argument to the transaction

func (FlowTransactionBuilder) UIntArgument added in v1.0.1

func (t FlowTransactionBuilder) UIntArgument(value uint) FlowTransactionBuilder

UIntArgument add an UInt Argument to the transaction

func (FlowTransactionBuilder) Word16Argument added in v1.0.1

func (t FlowTransactionBuilder) Word16Argument(value uint16) FlowTransactionBuilder

Word16Argument add a Word16 Argument to the transaction

func (FlowTransactionBuilder) Word32Argument added in v1.0.1

func (t FlowTransactionBuilder) Word32Argument(value uint32) FlowTransactionBuilder

Word32Argument add a Word32 Argument to the transaction

func (FlowTransactionBuilder) Word64Argument added in v1.0.1

func (t FlowTransactionBuilder) Word64Argument(value uint64) FlowTransactionBuilder

Word64Argument add a Word64 Argument to the transaction

func (FlowTransactionBuilder) Word8Argument added in v1.0.1

func (t FlowTransactionBuilder) Word8Argument(value uint8) FlowTransactionBuilder

Word8Argument add a Word8 Argument to the transaction

type FormatedEvent added in v1.0.1

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 ParseEvent added in v1.0.1

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 added in v1.15.0

func (e FormatedEvent) String() string

type GoWithTheFlow

type GoWithTheFlow struct {
	Service  GoWithTheFlowAccount
	Accounts map[string]GoWithTheFlowAccount
	WebHooks map[string]DiscordWebhook
	Address  string
	Gas      uint64
}

GoWithTheFlow Entire configuration to work with Go With the Flow

func NewGoWithTheFlow added in v1.0.1

func NewGoWithTheFlow(filename string) *GoWithTheFlow

NewGoWithTheFlow with custom file panic on error

func NewGoWithTheFlowDevNet added in v1.0.1

func NewGoWithTheFlowDevNet() *GoWithTheFlow

NewGoWithTheFlowDevNet setup dev like in https://www.notion.so/Accessing-Flow-Devnet-ad35623797de48c08d8b88102ea38131

func NewGoWithTheFlowEmulator

func NewGoWithTheFlowEmulator() *GoWithTheFlow

NewGoWithTheFlowEmulator create a new client

func NewGoWithTheFlowError

func NewGoWithTheFlowError(fileName string) (*GoWithTheFlow, error)

NewGoWithTheFlowError creates a new local go with the flow client

func NewGoWithTheFlowMainNet added in v1.15.0

func NewGoWithTheFlowMainNet() *GoWithTheFlow

NewGoWithTheFlowDevNet setup dev like in https://www.notion.so/Accessing-Flow-Devnet-ad35623797de48c08d8b88102ea38131

func (*GoWithTheFlow) AddContract added in v1.0.1

func (f *GoWithTheFlow) AddContract(accountName string, contractName string) []flow.Event

AddContract will deploy a contract with the given name to an account with the same name from wallet.json

func (*GoWithTheFlow) AddContractWithSignerAsInitArg added in v1.0.1

func (f *GoWithTheFlow) AddContractWithSignerAsInitArg(accountName string, contractName string) []flow.Event

AddContractWithSignerAsInitArg will deploy a contract with the given name to an account with the same name from wallet.json

func (*GoWithTheFlow) CreateAccount

func (f *GoWithTheFlow) CreateAccount(accountName ...string) *GoWithTheFlow

CreateAccount creates the accounts with the given names

func (*GoWithTheFlow) CreateAccountPrintEvents added in v1.0.1

func (f *GoWithTheFlow) CreateAccountPrintEvents(accountName ...string) *GoWithTheFlow

CreateAccountPrintEvents create accounts and print events

func (*GoWithTheFlow) CreateAccountWithAllContracts added in v1.0.1

func (f *GoWithTheFlow) CreateAccountWithAllContracts(accountName string) []flow.Event

CreateAccountWithAllContracts with all contracts in folder

func (*GoWithTheFlow) CreateAccountWithContracts added in v1.0.1

func (f *GoWithTheFlow) CreateAccountWithContracts(accountName string, contractsStrings ...string) []flow.Event

CreateAccountWithContracts will create an account for running transactions without a contract

func (*GoWithTheFlow) EventFetcher added in v1.15.0

func (f *GoWithTheFlow) EventFetcher() EventFetcherBuilder

SendEventsTo starts a event hook builder

func (*GoWithTheFlow) FindAddress

func (f *GoWithTheFlow) FindAddress(key string) cadence.Address

FindAddress finds an candence.Address value from a given key in your wallet

func (*GoWithTheFlow) InitializeContracts added in v1.0.1

func (f *GoWithTheFlow) InitializeContracts() *GoWithTheFlow

InitializeContracts installs all contracts to the account with name accounts

func (*GoWithTheFlow) InitializeContractsPrintEvents added in v1.0.1

func (f *GoWithTheFlow) InitializeContractsPrintEvents() *GoWithTheFlow

InitializeContractsPrintEvents installs all contracts to the account with name accounts

func (*GoWithTheFlow) ScriptFromFile

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

ScriptFromFile will start a flow script builder

func (*GoWithTheFlow) TransactionFromFile

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

TransactionFromFile will start a flow transaction builder

func (*GoWithTheFlow) UpdateContract added in v1.0.1

func (f *GoWithTheFlow) UpdateContract(accountName string, contractName string) []flow.Event

UpdateContract will deploy a contract with the given name to an account with the same name from wallet.json

type GoWithTheFlowAccount

type GoWithTheFlowAccount struct {
	Address    flow.Address
	SigAlgo    crypto.SignatureAlgorithm
	HashAlgo   crypto.HashAlgorithm
	PrivateKey crypto.PrivateKey

	//These three are set the first time they are accessed
	Signer  *crypto.InMemorySigner
	Account *flow.Account
	Key     *flow.AccountKey
}

GoWithTheFlowAccount represents an account for flow with resolves types

func (*GoWithTheFlowAccount) EnrichWithAccountSignerAndKey

func (a *GoWithTheFlowAccount) EnrichWithAccountSignerAndKey(c *client.Client) (*GoWithTheFlowAccount, error)

EnrichWithAccountSignerAndKey enriches and Account

func (*GoWithTheFlowAccount) NewAccountKey

func (a *GoWithTheFlowAccount) NewAccountKey() *flow.AccountKey

NewAccountKey creates a NewFlowAccountKey

type RawAccount

type RawAccount struct {
	Address string `json:"address"`
	Keys    string `json:"key"`
}

RawAccount flow accounts struct for marshalling into primitive types

type RawFlowConfig

type RawFlowConfig struct {
	Address          string
	GasLimit         uint64
	Accounts         map[string]RawAccount
	EmulatorAccounts map[string]string
	Webhooks         map[string]DiscordWebhook
}

RawFlowConfig for marshalling into simple types

func NewRawFlowConfig

func NewRawFlowConfig(path string) (*RawFlowConfig, error)

NewRawFlowConfig will read the flow.json file

Jump to

Keyboard shortcuts

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