Documentation
¶
Index ¶
- Constants
- Variables
- func All[T any](slice []T, f func(T) bool) bool
- func AnyOf[T comparable](e T, values ...T) bool
- func DerefSlice[T any](v *[]T) []T
- func FeltArrToString(arr []*felt.Felt) string
- func Filter[T any](slice []T, f func(T) bool) []T
- func Gzip64Decode(data string) ([]byte, error)
- func Gzip64Encode(data []byte) (string, error)
- func HTTPLogSettings(w http.ResponseWriter, r *http.Request, log *LogLevel)
- func HeapPtr[T any](v T) *T
- func IsNil(i any) bool
- func Map[T1, T2 any](slice []T1, f func(T1) T2) []T2
- func MapByRef[T1, T2 any](slice []T1, f func(*T1) T2) []T2
- func NonNilSlice[T any](sl []T) []T
- func RunAndWrapOnError(runnable func() error, existingErr error) error
- func Set[T comparable](slice []T) []T
- func SortedMap[K cmp.Ordered, T any](m map[K]T) iter.Seq2[K, T]
- func ToHex(b *big.Int) string
- func ToMap[T any, K comparable, V any](sl []T, f func(T) (K, V)) map[K]V
- func ToSlice[K comparable, V any, T any](m map[K]V, f func(K, V) T) []T
- type BlockHashMetaInfo
- type BlockSignFunc
- type DataSize
- type LogLevel
- func (l LogLevel) GetAtomicLevel() zap.AtomicLevel
- func (l LogLevel) Level() zapcore.Level
- func (l *LogLevel) MarshalText() ([]byte, error)
- func (l LogLevel) MarshalYAML() (any, error)
- func (l *LogLevel) Set(s string) error
- func (l LogLevel) String() string
- func (l *LogLevel) Type() string
- func (l *LogLevel) UnmarshalText(text []byte) error
- type Logger
- type Network
- type OrderedSet
- type SimpleLogger
- type Throttler
- type ZapLogger
Constants ¶
const ( Kilobyte = 1024 Megabyte = 1024 * Kilobyte Gigabyte = 1024 * Megabyte Terabyte = 1024 * Gigabyte )
const ( TRACE zapcore.Level = iota - 2 DEBUG INFO WARN ERROR )
Variables ¶
var ( // The docs states the addresses for each network: https://docs.starknet.io/tools/important-addresses/ Mainnet = Network{ Name: "mainnet", FeederURL: "https://feeder.alpha-mainnet.starknet.io/feeder_gateway/", GatewayURL: "https://alpha-mainnet.starknet.io/gateway/", L2ChainID: "SN_MAIN", L1ChainID: big.NewInt(1), CoreContractAddress: common.HexToAddress("0xc662c410C0ECf747543f5bA90660f6ABeBD9C8c4"), BlockHashMetaInfo: &BlockHashMetaInfo{ First07Block: 833, FallBackSequencerAddress: fallBackSequencerAddressMainnet, }, } Goerli = Network{ Name: "goerli", FeederURL: "https://alpha4.starknet.io/feeder_gateway/", GatewayURL: "https://alpha4.starknet.io/gateway/", L2ChainID: "SN_GOERLI", L1ChainID: big.NewInt(5), CoreContractAddress: common.HexToAddress("0xde29d060D45901Fb19ED6C6e959EB22d8626708e"), BlockHashMetaInfo: &BlockHashMetaInfo{ First07Block: 47028, UnverifiableRange: []uint64{119802, 148428}, FallBackSequencerAddress: fallBackSequencerAddress, }, } Goerli2 = Network{ Name: "goerli2", FeederURL: "https://alpha4-2.starknet.io/feeder_gateway/", GatewayURL: "https://alpha4-2.starknet.io/gateway/", L2ChainID: "SN_GOERLI2", L1ChainID: big.NewInt(5), CoreContractAddress: common.HexToAddress("0xa4eD3aD27c294565cB0DCc993BDdCC75432D498c"), BlockHashMetaInfo: &BlockHashMetaInfo{ First07Block: 0, FallBackSequencerAddress: fallBackSequencerAddress, }, } Integration = Network{ Name: "integration", FeederURL: "https://external.integration.starknet.io/feeder_gateway/", GatewayURL: "https://external.integration.starknet.io/gateway/", L2ChainID: "SN_GOERLI", L1ChainID: big.NewInt(5), CoreContractAddress: common.HexToAddress("0xd5c325D183C592C94998000C5e0EED9e6655c020"), BlockHashMetaInfo: &BlockHashMetaInfo{ First07Block: 110511, UnverifiableRange: []uint64{0, 110511}, FallBackSequencerAddress: fallBackSequencerAddress, }, } Sepolia = Network{ Name: "sepolia", FeederURL: "https://feeder.alpha-sepolia.starknet.io/feeder_gateway/", GatewayURL: "https://alpha-sepolia.starknet.io/gateway/", L2ChainID: "SN_SEPOLIA", L1ChainID: big.NewInt(11155111), CoreContractAddress: common.HexToAddress("0xE2Bb56ee936fd6433DC0F6e7e3b8365C906AA057"), BlockHashMetaInfo: &BlockHashMetaInfo{ First07Block: 0, FallBackSequencerAddress: fallBackSequencerAddress, }, } SepoliaIntegration = Network{ Name: "sepolia-integration", FeederURL: "https://feeder.integration-sepolia.starknet.io/feeder_gateway/", GatewayURL: "https://integration-sepolia.starknet.io/gateway/", L2ChainID: "SN_INTEGRATION_SEPOLIA", L1ChainID: big.NewInt(11155111), CoreContractAddress: common.HexToAddress("0x4737c0c1B4D5b1A687B42610DdabEE781152359c"), BlockHashMetaInfo: &BlockHashMetaInfo{ First07Block: 0, FallBackSequencerAddress: fallBackSequencerAddress, }, } Sequencer = Network{ Name: "sequencer", L2ChainID: "SN_JUNO_SEQUENCER", BlockHashMetaInfo: &BlockHashMetaInfo{}, } )
var DefaultEthFeeTokenAddress = felt.Felt([4]uint64{
4380532846569209554,
17839402928228694863,
17240401758547432026,
418961398025637529,
})
0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7
var DefaultFeeTokenAddresses = starknet.FeeTokenAddresses{ EthL2TokenAddress: DefaultEthFeeTokenAddress, StrkL2TokenAddress: DefaultStrkFeeTokenAddress, }
var DefaultStrkFeeTokenAddress = felt.Felt([4]uint64{
16432072983745651214,
1325769094487018516,
5134018303144032807,
468300854463065062,
})
0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d
var ErrResourceBusy = errors.New("resource busy, try again")
var ErrUnknownLogLevel = fmt.Errorf( "unknown log level (known: %s, %s, %s, %s, %s)", TRACE, DEBUG, INFO, WARN, ERROR, )
var KnownNetworkNames = []string{ Mainnet.String(), Sepolia.String(), SepoliaIntegration.String(), Sequencer.String(), }
Functions ¶
func AnyOf ¶ added in v0.12.0
func AnyOf[T comparable](e T, values ...T) bool
func DerefSlice ¶ added in v0.8.0
func DerefSlice[T any](v *[]T) []T
func FeltArrToString ¶ added in v0.13.0
func Gzip64Decode ¶ added in v0.4.0
func Gzip64Encode ¶ added in v0.4.0
func HTTPLogSettings ¶ added in v0.13.0
func HTTPLogSettings(w http.ResponseWriter, r *http.Request, log *LogLevel)
HTTPLogSettings is an HTTP handler that allows changing the log level of the logger. It can also be used to query what's the current log level.
func HeapPtr ¶ added in v0.13.3
func HeapPtr[T any](v T) *T
This function allocates a value into the heap and returns a pointer to it
func IsNil ¶ added in v0.13.0
IsNil checks if the underlying value of the interface is nil.
In Golang, an interface is boxed by an underlying type and value; both of them need to be nil for the interface to be nil. See the following examples:
var i any fmt.Println(i == nil) // true var p *int var i any = p fmt.Println(i == nil) // false!
A solution for this is to use i == nil || reflect.ValueOf(i).IsNil()), however, this can cause a panic as not all reflect.Value has IsNil() defined. Therefore, default is to return false. For example, reflect.Array cannot be nil, hence calling IsNil() will cause a panic.
func MapByRef ¶ added in v0.13.3
func MapByRef[T1, T2 any](slice []T1, f func(*T1) T2) []T2
The same as Map but the function receives a reference type
func NonNilSlice ¶ added in v0.8.0
func NonNilSlice[T any](sl []T) []T
func RunAndWrapOnError ¶ added in v0.6.2
func Set ¶ added in v0.13.0
func Set[T comparable](slice []T) []T
Unique returns a new slice with duplicates removed. Panics if the slice contains pointer types.
func ToMap ¶ added in v0.10.0
func ToMap[T any, K comparable, V any](sl []T, f func(T) (K, V)) map[K]V
func ToSlice ¶ added in v0.10.0
func ToSlice[K comparable, V any, T any](m map[K]V, f func(K, V) T) []T
Types ¶
type BlockHashMetaInfo ¶ added in v0.9.3
type BlockHashMetaInfo struct {
// The sequencer address to use for blocks that do not have one
FallBackSequencerAddress *felt.Felt `json:"fallback_sequencer_address" validate:"required"`
// First block that uses the post-0.7.0 block hash algorithm
First07Block uint64 `json:"first_07_block" validate:"required"`
// Range of blocks that are not verifiable
UnverifiableRange []uint64 `json:"unverifiable_range" validate:"required"`
}
type BlockSignFunc ¶ added in v0.14.6
func Sign ¶ added in v0.14.6
func Sign(privKey *ecdsa.PrivateKey) BlockSignFunc
Sign returns the builder's signature over data.
type LogLevel ¶
type LogLevel struct {
// contains filtered or unexported fields
}
func NewLogLevel ¶ added in v0.13.0
func (LogLevel) GetAtomicLevel ¶ added in v0.13.0
func (l LogLevel) GetAtomicLevel() zap.AtomicLevel
func (*LogLevel) MarshalText ¶ added in v0.11.0
func (LogLevel) MarshalYAML ¶ added in v0.6.0
func (*LogLevel) UnmarshalText ¶ added in v0.2.1
type Logger ¶
type Logger interface {
SimpleLogger
pebble.Logger
}
type Network ¶
type Network struct {
Name string `json:"name" validate:"required"`
FeederURL string `json:"feeder_url" validate:"required"`
GatewayURL string `json:"gateway_url" validate:"required"`
L1ChainID *big.Int `json:"l1_chain_id" validate:"required"`
L2ChainID string `json:"l2_chain_id" validate:"required"`
CoreContractAddress common.Address `json:"core_contract_address" validate:"required"`
BlockHashMetaInfo *BlockHashMetaInfo `json:"block_hash_meta_info"`
}
func (*Network) L2ChainIDFelt ¶ added in v0.9.3
func (*Network) MarshalText ¶ added in v0.11.0
func (*Network) MarshalYAML ¶ added in v0.6.0
func (*Network) UnmarshalText ¶ added in v0.2.1
type OrderedSet ¶ added in v0.13.0
type OrderedSet[K comparable, V any] struct { // contains filtered or unexported fields }
OrderedSet is a thread-safe data structure that maintains both uniqueness and insertion order of elements. It combines the benefits of both maps and slices: - Uses a map for O(1) lookups and to ensure element uniqueness - Uses a slice to maintain insertion order and enable ordered iteration The data structure is safe for concurrent access through the use of a read-write mutex.
func NewOrderedSet ¶ added in v0.13.0
func NewOrderedSet[K comparable, V any]() *OrderedSet[K, V]
func (*OrderedSet[K, V]) Clear ¶ added in v0.14.5
func (o *OrderedSet[K, V]) Clear()
func (*OrderedSet[K, V]) Get ¶ added in v0.13.0
func (o *OrderedSet[K, V]) Get(key K) (V, bool)
func (*OrderedSet[K, V]) Keys ¶ added in v0.13.0
func (o *OrderedSet[K, V]) Keys() []K
Keys returns a slice of keys in their insertion order
func (*OrderedSet[K, V]) List ¶ added in v0.13.0
func (o *OrderedSet[K, V]) List() []V
List returns a shallow copy of the proof set's value list.
func (*OrderedSet[K, V]) Put ¶ added in v0.13.0
func (o *OrderedSet[K, V]) Put(key K, value V)
func (*OrderedSet[K, V]) Size ¶ added in v0.13.0
func (o *OrderedSet[K, V]) Size() int
type SimpleLogger ¶
type Throttler ¶ added in v0.7.4
type Throttler[T any] struct { // contains filtered or unexported fields }
func NewThrottler ¶ added in v0.7.4
func (*Throttler[T]) Do ¶ added in v0.7.4
Do lets caller acquire the resource within the context of a callback
func (*Throttler[T]) JobsRunning ¶ added in v0.10.0
JobsRunning returns the number of Do calls that are running at the moment
func (*Throttler[T]) QueueLen ¶ added in v0.7.4
QueueLen returns the number of Do calls that is blocked on the resource
func (*Throttler[T]) WithMaxQueueLen ¶ added in v0.7.4
WithMaxQueueLen sets the maximum length the queue can grow to
type ZapLogger ¶
type ZapLogger struct {
*zap.SugaredLogger
}
func NewNopZapLogger ¶
func NewNopZapLogger() *ZapLogger