shared

package
v0.0.0-...-1350c8b Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CadenceValueToInterface

func CadenceValueToInterface(field cadence.Value) interface{}

func EncodeMessageFromVoucher

func EncodeMessageFromVoucher(v *Voucher) string

func FloatBalanceToUint

func FloatBalanceToUint(balance float64) uint64

func GetUserCompositeSignatureFromVoucher

func GetUserCompositeSignatureFromVoucher(v *Voucher) *[]CompositeSignature

Non-custodial wallets will only contain one signer, so payloadSigs will be empty, and only the envelope will be signed. For Custodial wallets (Blocto/Dapper), the user signs the tx payload and envelope is signed by custodian.

This function returns only the signature generated by the user

func WaitForSeal

func WaitForSeal(
	ctx context.Context,
	c *client.Client,
	id flow.Identifier,
) (*flow.TransactionResult, *flow.Transaction, error)

Types

type Allowlist

type Allowlist struct {
	Addresses []string `json:"addresses"`
}

type Choice

type Choice struct {
	Choice_text    string  `json:"choiceText"`
	Choice_img_url *string `json:"choiceImgUrl"`
}

used in models/proposal.go

type CompositeSignature

type CompositeSignature struct {
	Addr      string  `json:"addr"`
	Key_id    uint    `json:"keyId"`
	Signature string  `json:"signature"`
	F_type    *string `json:"f_type,omitempty"`
	F_vsn     *string `json:"f_vsn,omitempty"`
}

type Config

type Config struct {
	Features map[string]bool `default:"useCorsMiddleware:false,validateTimestamps:true,validateAllowlist:true,validateBlocklist:true,validateSigs:true"`
}

type Contract

type Contract struct {
	Name           *string  `json:"name,omitempty"`
	Addr           *string  `json:"addr,omitempty"`
	Public_path    *string  `json:"publicPath,omitempty"`
	Threshold      *float64 `json:"threshold,omitempty,string"`
	MaxWeight      *float64 `json:"maxWeight,omitempty,string"`
	Float_event_id *uint64  `json:"floatEventId,omitempty,string"`
	Script         *string  `json:"script,omitempty"`
}

type CustomScript

type CustomScript struct {
	Key         string `json:"key" validate:"required"`
	Name        string `json:"name" validate:"required"`
	Description string `json:"description" validate:"required"`
	Src         string `json:"src" validate:"required"`
}

type Database

type Database struct {
	Conn    *pgxpool.Pool
	Context context.Context
	Name    string
	Env     *string
}

type FTBalanceResponse

type FTBalanceResponse struct {
	ID                      string    `json:"id,omitempty"`
	FungibleTokenID         string    `json:"fungibleTokenId"`
	Addr                    string    `json:"addr"`
	PrimaryAccountBalance   uint64    `json:"primaryAccountBalance"`
	SecondaryAddress        string    `json:"secondaryAddress"`
	SecondaryAccountBalance uint64    `json:"secondaryAccountBalance"`
	Balance                 uint64    `json:"balance"`
	StakingBalance          uint64    `json:"stakingBalance"`
	ScriptResult            string    `json:"scriptResult"`
	Stakes                  []string  `json:"stakes"`
	BlockHeight             uint64    `json:"blockHeight"`
	Proposal_id             int       `json:"proposal_id"`
	NFTCount                int       `json:"nftCount"`
	CreatedAt               time.Time `json:"createdAt"`
}

func (*FTBalanceResponse) NewFTBalance

func (b *FTBalanceResponse) NewFTBalance()

type FlowAdapter

type FlowAdapter struct {
	Config           FlowConfig
	ArchiveClient    *client.Client
	LiveClient       *client.Client
	Context          context.Context
	CustomScriptsMap map[string]CustomScript
	URL              string
	ArchiveURL       string
	Env              string
}

func NewFlowClient

func NewFlowClient(flowEnv string, customScriptsMap map[string]CustomScript) *FlowAdapter

func (*FlowAdapter) CheckIfUserHasEvent

func (fa *FlowAdapter) CheckIfUserHasEvent(voterAddr string, c *Contract) (bool, error)

func (*FlowAdapter) EnforceTokenThreshold

func (fa *FlowAdapter) EnforceTokenThreshold(scriptPath, creatorAddr string, c *Contract) (bool, error)

func (*FlowAdapter) GetAccountAtBlockHeight

func (fa *FlowAdapter) GetAccountAtBlockHeight(addr string, blockheight uint64) (*flow.Account, error)

func (*FlowAdapter) GetAddressBalanceAtBlockHeight

func (fa *FlowAdapter) GetAddressBalanceAtBlockHeight(addr string, blockHeight uint64, balanceResponse *FTBalanceResponse, contract *Contract) error

func (*FlowAdapter) GetCurrentBlockHeight

func (fa *FlowAdapter) GetCurrentBlockHeight() (int, error)

func (*FlowAdapter) GetEventNFT

func (fa *FlowAdapter) GetEventNFT(voterAddr string, c *Contract) (interface{}, error)

func (*FlowAdapter) GetFTBalance

func (fa *FlowAdapter) GetFTBalance(address string, blockHeight uint64, contractName string, contractAddress string, publicPath string) (float64, error)

@bluesign: this is called via archival node now

func (*FlowAdapter) GetFloatNFTIds

func (fa *FlowAdapter) GetFloatNFTIds(voterAddr string, c *Contract) ([]interface{}, error)

func (*FlowAdapter) GetFlowBalance

func (fa *FlowAdapter) GetFlowBalance(address string, blockHeight uint64) ([]float64, error)

func (*FlowAdapter) GetNFTIds

func (fa *FlowAdapter) GetNFTIds(voterAddr string, c *Contract, path string) ([]interface{}, error)

func (*FlowAdapter) ReplaceContractPlaceholders

func (fa *FlowAdapter) ReplaceContractPlaceholders(code string, c *Contract, isFungible bool) []byte

func (*FlowAdapter) ValidateSignature

func (fa *FlowAdapter) ValidateSignature(address, message string, sigs *[]CompositeSignature, messageType string) error

type FlowConfig

type FlowConfig struct {
	Contracts map[string]FlowContract `json:"contracts"`
	Networks  map[string]string       `json:"networks"`
}

type FlowContract

type FlowContract struct {
	Source  string            `json:"source,omitempty"`
	Aliases map[string]string `json:"aliases"`
}

type IpfsClient

type IpfsClient struct {
	BaseURL string

	HTTPClient *http.Client
	// contains filtered or unexported fields
}

func NewIpfsClient

func NewIpfsClient(apiKey string, apiSecret string) *IpfsClient

func (*IpfsClient) PinFile

func (c *IpfsClient) PinFile(file multipart.File, fileName string) (*Pin, error)

func (*IpfsClient) PinJson

func (c *IpfsClient) PinJson(data interface{}) (*Pin, error)

type MintParams

type MintParams struct {
	Recipient            string
	Name                 string
	Description          string
	Thumbnail            string
	Cuts                 []float64
	RoyaltyDescriptions  []string
	RoyaltyBeneficiaries []string
}

type PageParams

type PageParams struct {
	Start        int
	Count        int
	Order        string
	TotalRecords int
}

type PaginatedResponse

type PaginatedResponse struct {
	Data         interface{} `json:"data"`
	Start        int         `json:"start"`
	Count        int         `json:"count"`
	TotalRecords int         `json:"totalRecords"`
	Next         int         `json:"next"`
}

func GetPaginatedResponseWithPayload

func GetPaginatedResponseWithPayload(payload interface{}, p PageParams) *PaginatedResponse

Underlying value of payload needs to be a slice

type PayloadSig

type PayloadSig struct {
	Address string `json:"address"`
	KeyId   uint   `json:"keyId"`
	Sig     string `json:"sig"`
}

type Pin

type Pin struct {
	IpfsHash    string    `json:"IpfsHash"`
	PinSize     int       `json:"PinSize"`
	Timestamp   time.Time `json:"Timestamp"`
	IsDuplicate bool      `json:"isDuplicate"`
}

type ProposalKey

type ProposalKey struct {
	Address     string `json:"address"`
	KeyId       uint   `json:"keyId"`
	SequenceNum uint   `json:"sequenceNum"`
}

type SearchFilter

type SearchFilter struct {
	Text   string `json:"text"`
	Amount int    `json:"amount"`
}

type StrategyStruct

type StrategyStruct struct {
	FlowAdapter *FlowAdapter
	DB          *Database
}

type TimestampSignaturePayload

type TimestampSignaturePayload struct {
	Composite_signatures *[]CompositeSignature `json:"compositeSignatures"`
	Signing_addr         string                `json:"signingAddr"`
	Timestamp            string                `json:"timestamp"`
}

type Voucher

type Voucher struct {
	Cadence      string              `json:"cadence"`
	RefBlock     string              `json:"refBlock"`
	ComputeLimit uint                `json:"computeLimit"`
	Arguments    []map[string]string `json:"arguments"`
	Payer        string              `json:"payer"`
	Authorizers  []string            `json:"authorizers"`
	ProposalKey  ProposalKey         `json:"proposalKey"`
	PayloadSigs  []PayloadSig        `json:"payloadSigs"`
	EnvelopeSigs []PayloadSig        `json:"envelopeSigs"`
}

Jump to

Keyboard shortcuts

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