starknet

package
v0.0.1-beta-test Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: MIT Imports: 11 Imported by: 4

Documentation

Index

Constants

View Source
const (
	FeltLength = 32
)

Variables

This section is empty.

Functions

func CompareAddress

func CompareAddress(a, b string) bool

CompareAddress compares different hex starknet addresses with potentially different 0 padding

func DecodeFelts

func DecodeFelts(felts []*big.Int) ([]byte, error)

DecodeFelts is the reverse of EncodeFelts

func EncodeFelts

func EncodeFelts(data []byte) (felts []*big.Int)

EncodeFelts takes a byte slice and splits as bunch of felts. First felt indicates the total byte size.

func FeltToUnsignedBig

func FeltToUnsignedBig(felt *caigotypes.Felt) (num *big.Int, err error)

func FeltsToBig

func FeltsToBig(in []*caigotypes.Felt) (out []*big.Int)

func HexToUnsignedBig

func HexToUnsignedBig(str string) (num *big.Int, err error)

func IsEventFromContract

func IsEventFromContract(event *caigogw.Event, address caigotypes.Hash, eventName string) bool

func Min

func Min[T constraints.Ordered](a, b T) T

func NilResultError

func NilResultError(funcName string) error

func PadBytes

func PadBytes(a []byte, length int) []byte

padd bytes to specific length

func StringsToFelt

func StringsToFelt(in []string) (out []*caigotypes.Felt, _ error)

StringsToFelt maps felts from 'string' (hex) representation to 'caigo.Felt' representation

func XXXMustHexDecodeString

func XXXMustHexDecodeString(data string) []byte

Types

type CallOps

type CallOps struct {
	ContractAddress caigotypes.Hash
	Selector        string
	Calldata        []string
}

type Client

type Client struct {
	Gw *caigogw.GatewayProvider
	// contains filtered or unexported fields
}

func NewClient

func NewClient(chainID string, baseURL string, lggr logger.Logger, timeout *time.Duration) (*Client, error)

pass nil or 0 to timeout to not use built in default timeout

func (*Client) AccountNonce

func (c *Client) AccountNonce(ctx context.Context, address caigotypes.Hash) (*big.Int, error)

func (*Client) BlockByHash

func (c *Client) BlockByHash(ctx context.Context, hash string, _ string) (*caigogw.Block, error)

func (*Client) BlockByNumber

func (c *Client) BlockByNumber(ctx context.Context, num *big.Int, _ string) (*caigogw.Block, error)

func (*Client) BlockByNumberGateway

func (c *Client) BlockByNumberGateway(ctx context.Context, blockNum uint64) (block *caigogw.Block, err error)

func (*Client) Call

func (c *Client) Call(ctx context.Context, calls caigotypes.FunctionCall, blockHashOrTag string) ([]string, error)

func (*Client) CallContract

func (c *Client) CallContract(ctx context.Context, ops CallOps) (res []string, err error)

func (*Client) ChainID

func (c *Client) ChainID(ctx context.Context) (string, error)

func (*Client) EstimateFee

func (c *Client) EstimateFee(ctx context.Context, call caigotypes.FunctionInvoke, hash string) (*caigotypes.FeeEstimate, error)

func (*Client) LatestBlockHeight

func (c *Client) LatestBlockHeight(ctx context.Context) (height uint64, err error)

func (*Client) TransactionByHash

func (c *Client) TransactionByHash(ctx context.Context, hash string) (*caigogw.Transaction, error)

func (*Client) TransactionReceipt

func (c *Client) TransactionReceipt(ctx context.Context, hash string) (*caigogw.TransactionReceipt, error)

type Reader

type Reader interface {
	CallContract(context.Context, CallOps) ([]string, error)
	LatestBlockHeight(context.Context) (uint64, error)
	BlockByNumberGateway(context.Context, uint64) (*caigogw.Block, error)

	// provider interface
	BlockByHash(context.Context, string, string) (*caigogw.Block, error)
	BlockByNumber(context.Context, *big.Int, string) (*caigogw.Block, error)
	Call(context.Context, caigotypes.FunctionCall, string) ([]string, error)
	ChainID(context.Context) (string, error)
}

type ReaderWriter

type ReaderWriter interface {
	Reader
	Writer
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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