Help us shape the future of Go! Take the 2026 Go Developer Survey

types

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package types holds shared SDK domain types used across service packages.

Boundary discipline:

  • Only pure data types (structs, named primitives) and sentinel errors belong here.
  • No business logic, no helpers, no service glue.
  • Imports stay minimal and must not include service packages, because service imports from types must remain acyclic.

This package exists so every service can share the same vocabulary (WriteResult, DataSetID, ProviderID, ...) without cross-importing each other's service package.

Stability

0.x phase: public API may change between minor releases. Identifier widths follow the on-chain ABI; bounded SDK identifiers use uint64, while protocol-width identifiers (e.g. ClientDataSetID) keep the full uint256 *big.Int width for contract interoperability.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidListOptions = errors.New("invalid list options")

ErrInvalidListOptions is returned when ListOptions values are out of range. It is exposed so callers can assert on the class of error without depending on a specific service package.

View Source
var ErrTxFailed = txutil.ErrTxFailed

ErrTxFailed is the canonical sentinel reported when a transaction is mined but its receipt status is not successful (reverted or out-of-gas on-chain). Use errors.Is to match errors returned by any state-changing call in the SDK.

Service packages (payments, sessionkey, ...) expose aliases to this sentinel for backward compatibility; they are all the same error value.

Functions

This section is empty.

Types

type ChainID

type ChainID int64

ChainID is an EIP-155 chain identifier exposed at the SDK public boundary instead of the bare *big.Int used by go-ethereum. The newtype keeps callers honest about units (raw uint256 chain ids fit easily in int64 for every deployed EVM chain) and avoids silently accepting mutable *big.Int pointers across package boundaries.

The zero value is not a valid chain id; use IsValid to check.

func (ChainID) BigInt

func (c ChainID) BigInt() *big.Int

BigInt returns a freshly-allocated *big.Int for consumers (contract bindings, EIP-712 domain separators) that still require the legacy representation. The returned pointer is owned by the caller.

func (ChainID) Int64

func (c ChainID) Int64() int64

Int64 returns the chain id as an int64.

func (ChainID) IsValid

func (c ChainID) IsValid() bool

IsValid reports whether the chain id is a positive EIP-155 identifier.

type ClientDataSetID

type ClientDataSetID = *big.Int

ClientDataSetID is a caller-assigned identifier that scopes EIP-712 signatures to a specific client/data-set pair. It is a full uint256 in the protocol and reference SDK, so the Go SDK keeps the exact on-chain value.

The pointed-to value must be treated as immutable once shared.

type DataSetID

type DataSetID uint64

DataSetID identifies a warm-storage data set. On-chain it is stored as a uint256, but the Warm Storage contract bounds it to the uint64-safe range; SDK callers work with the typed value directly.

type Epoch

type Epoch uint64

Epoch is a Filecoin chain epoch number. Zero is the valid "indefinite" sentinel in several warm-storage fields.

type ListOptions

type ListOptions struct {
	Offset uint64
	Limit  uint64
}

ListOptions configures a paginated list call.

Limit must be > 0. The zero value is rejected as a programming error: different services/contracts disagree on what "Limit == 0" means (some treat it as "all remaining", others as a default page size), so callers must be explicit.

When you want to iterate every record regardless of page size, use the service's IterateAll* method instead of trying to encode "no cap" via ListOptions.

func (ListOptions) Validate

func (o ListOptions) Validate() error

Validate returns ErrInvalidListOptions when Limit is not > 0.

type PieceID

type PieceID uint64

PieceID identifies a piece within a data set.

type ProviderID

type ProviderID uint64

ProviderID identifies a storage provider registered with the SP registry.

type RailID

type RailID uint64

RailID identifies a payment rail in the payments contract.

type WriteResult

type WriteResult struct {
	Hash    common.Hash
	Receipt *ethtypes.Receipt
}

WriteResult is returned by every state-changing call in the SDK.

Hash is always populated when WriteResult is non-nil — it is set as soon as the transaction is broadcast. Receipt is populated only when the call was made with a wait option (e.g. WithWait(timeout)) and the transaction was mined (successfully or reverted) before the timeout elapsed.

Error semantics (observe WriteResult and err together):

  • WriteResult == nil, err != nil: pre-broadcast failure (validation, signing, or broadcast itself failed). The transaction was never submitted to the chain and it is safe to retry with fresh state.
  • WriteResult != nil, err == nil: transaction was broadcast successfully. Without a wait option, Receipt is nil. With a wait option, Receipt is non-nil and Status == 1 (successful execution).
  • WriteResult != nil, err != nil, Receipt == nil: the wait timed out before a terminal receipt was returned, or receipt lookup failed. This includes both "not mined yet" and "already mined, but the configured confirmation count has not been satisfied yet". Hash is valid; callers can keep polling by Hash.
  • WriteResult != nil, err != nil, Receipt != nil: transaction was mined but execution reverted. err wraps ErrTxFailed (use errors.Is). Receipt carries the failed status and any logs emitted before revert.

Jump to

Keyboard shortcuts

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