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 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, 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 ¶ added in v0.2.2
MarshalParams marshals the provided params into a folded Prim.
func MarshalPrim ¶ added in v0.2.2
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 ¶ added in v0.2.2
UnmarshalPrim unmarshals a prim into v.
v must be a non-nil pointer to the expected result.
func UnmarshalPrimPath ¶ added in v0.2.2
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 ¶ added in v0.2.3
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 ¶ added in v0.2.3
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 ¶ added in v0.2.3
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, B]) SetKeyType ¶ added in v0.2.3
SetKeyType forces the key micheline type to use, when marshaling a key into an expression hash.
type ErrKeyNotFound ¶ added in v0.2.3
type ErrKeyNotFound struct {
Key string
}
func (*ErrKeyNotFound) Error ¶ added in v0.2.3
func (e *ErrKeyNotFound) Error() string
func (*ErrKeyNotFound) Is ¶ added in v0.2.3
func (e *ErrKeyNotFound) Is(target error) bool
type Lambda ¶ added in v0.4.0
Lambda is raw Michelson code represented as a Prim tree.
func (*Lambda) MarshalPrim ¶ added in v0.4.0
type Map ¶ added in v0.2.3
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 ¶ added in v0.2.3
type Option ¶ added in v0.2.2
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 ¶ added in v0.2.2
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 ¶ added in v0.3.4
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 ¶ added in v0.2.2
func (*Option[T]) SetNone ¶ added in v0.3.2
func (o *Option[T]) SetNone()
SetNone replaces o's value with None.
func (*Option[T]) SetSome ¶ added in v0.3.2
func (o *Option[T]) SetSome(v T)
SetSome replaces o's value with Some(v).
func (*Option[T]) SetUntyped ¶ added in v0.3.4
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]) UnmarshalPrim ¶ added in v0.2.2
func (Option[T]) Unwrap ¶ added in v0.2.2
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 ¶ added in v0.2.2
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 ¶ added in v0.2.2
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 ¶ added in v0.2.2
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.