Documentation ¶
Overview ¶
Package bind contains utility functions and types that are used by generated contract code.
Index ¶
- func MarshalParams(optimized bool, params ...any) (micheline.Prim, error)
- func MarshalParamsPath(optimized bool, paths [][]int, params ...any) (micheline.Prim, error)
- func MarshalPrim(v any, optimized bool) (micheline.Prim, error)
- func UnmarshalPrim(prim micheline.Prim, v any) error
- func UnmarshalPrimPath(root micheline.Prim, path string, v any) error
- func UnmarshalPrimPaths(root micheline.Prim, dst map[string]any) error
- type Bigmap
- func (b *Bigmap[K, V]) Get(ctx context.Context, key K) (v V, err error)
- func (b *Bigmap[K, B]) ID() int64
- func (b Bigmap[K, V]) MarshalPrim(optimized bool) (micheline.Prim, error)
- func (b *Bigmap[K, V]) SetContent(elt ...MapEntry[K, V])
- func (b *Bigmap[K, B]) SetKeyType(keyType micheline.Type) *Bigmap[K, B]
- func (b *Bigmap[K, B]) SetRPC(client RPC) *Bigmap[K, B]
- func (b Bigmap[K, V]) String() string
- func (b *Bigmap[K, V]) UnmarshalPrim(prim micheline.Prim) error
- type Contract
- type ErrKeyNotFound
- type Lambda
- type Map
- func (m *Map[K, V]) Entries() []MapEntry[K, V]
- func (m Map[K, V]) Format(f fmt.State, verb rune)
- func (m *Map[K, V]) Get(key K) (V, bool)
- func (m Map[K, V]) MarshalPrim(optimized bool) (micheline.Prim, error)
- func (m *Map[K, V]) Set(key K, value V)
- func (m *Map[K, V]) UnmarshalPrim(prim micheline.Prim) error
- type MapEntry
- type Option
- func (o Option[T]) Get() (v T, isSome bool)
- func (o Option[T]) GetUntyped() (v any, isSome bool)
- func (o Option[T]) IsNone() bool
- func (o Option[T]) IsSome() bool
- func (o Option[T]) MarshalPrim(optimized bool) (micheline.Prim, error)
- func (o *Option[T]) SetNone()
- func (o *Option[T]) SetSome(v T)
- func (o *Option[T]) SetUntyped(v any) error
- func (o Option[T]) String() string
- func (o *Option[T]) UnmarshalPrim(prim micheline.Prim) error
- func (o Option[T]) Unwrap() T
- func (o Option[T]) UnwrapOr(defaultValue T) T
- func (o Option[T]) UnwrapOrZero() T
- type Or
- type PrimMarshaler
- type RPC
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalParams ¶
MarshalParams marshals the provided params into a folded Prim.
func MarshalParamsPath ¶
MarshalParamsPath marshals the provided params into a Prim tree at specified paths. This function is useful to render any kind of structs (records) into a type-conform prim tree. It requires a list of tree positions in the form of paths. Both paths and params must have the same length.
func MarshalPrim ¶
MarshalPrim marshals v into a Prim by using reflection.
If true, timestamps ,addresses, keys and signatures will be marshaled in their optimized format. See https://tezos.gitlab.io/active/michelson.html#differences-with-the-formal-notation.
func UnmarshalPrim ¶
UnmarshalPrim unmarshals a prim into v.
v must be a non-nil pointer to the expected result.
func UnmarshalPrimPath ¶
UnmarshalPrimPath unmarshals a nested prim contained in root, obtained using the given path, into v.
v must be a non-nil pointer to the expected result.
Types ¶
type Bigmap ¶
type Bigmap[K, V any] struct { // contains filtered or unexported fields }
Bigmap is a handle to a Tezos bigmap.
It has two type parameters, K and V, which are determined when a contract script is parsed.
Before using a Bigmap to Get a value, its RPC client must be set with SetRPC.
func NewBigmap ¶
NewBigmap returns a new Bigmap that points to the given bigmap id.
The type parameters must match the key and value type of the corresponding bigmap.
func (*Bigmap[K, V]) Get ¶
Get the value corresponding to the given key.
This makes a rpc call, so SetRPC must have been called before calling this.
If the key doesn't exist in the bigmap, an ErrKeyNotFound is returned.
func (Bigmap[K, V]) MarshalPrim ¶
func (*Bigmap[K, V]) SetContent ¶
func (*Bigmap[K, B]) SetKeyType ¶
SetKeyType forces the key micheline type to use, when marshaling a key into an expression hash.
type ErrKeyNotFound ¶
type ErrKeyNotFound struct {
Key string
}
func (*ErrKeyNotFound) Error ¶
func (e *ErrKeyNotFound) Error() string
func (*ErrKeyNotFound) Is ¶
func (e *ErrKeyNotFound) Is(target error) bool
type Map ¶
type Map[K, V any] struct { // contains filtered or unexported fields }
Map is a map type used to interact with Tezos smart contracts.
Go's map type cannot be used in this context, because the "comparable" types are different in Go and in Tezos specification.
func (Map[K, V]) MarshalPrim ¶
type Option ¶
type Option[T any] struct { // contains filtered or unexported fields }
Option is a type that can either contain a value T, or be None.
func (Option[T]) Get ¶
Get returns the inner value of the Option and a boolean indicating if the Option is Some.
If it is none, the returned value is the default value for T.
func (Option[T]) GetUntyped ¶
GetUntyped is the equivalent of Get, but it returns v as an empty interface instead of T.
This method is useful when generic parameters cannot be used, for example with reflection.
func (Option[T]) MarshalPrim ¶
func (*Option[T]) SetSome ¶
func (o *Option[T]) SetSome(v T)
SetSome replaces o's value with Some(v).
func (*Option[T]) SetUntyped ¶
SetUntyped is the equivalent of SetSome or SetNone, but uses v as an empty interface instead of T.
If v is nil, then the Option will be set to None. Else, it will cast v to T and set the Option to Some.
Returns an error if the cast failed.
This method is useful when generic parameters cannot be used, for example with reflection.
func (Option[T]) Unwrap ¶
func (o Option[T]) Unwrap() T
Unwrap returns the inner value of the Option, expecting that it is Some.
Panics if the option is None.
func (Option[T]) UnwrapOr ¶
func (o Option[T]) UnwrapOr(defaultValue T) T
UnwrapOr returns the inner value of the Option if it is Some, or the provided default value if it is None.
func (Option[T]) UnwrapOrZero ¶
func (o Option[T]) UnwrapOrZero() T
UnwrapOrZero returns the inner value of the Option if it is Some, or T's zero value if it is None.
type Or ¶
type Or[L, R any] struct { // contains filtered or unexported fields }
Or is a type that can be either L or R.
It maps to michelson's `or` type.