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, BigInt, ...) without cross-importing each other's service package.
Stability ¶
0.x phase: public API may change between minor releases. Contract uint256 identifiers are exposed as BigInt; field and parameter names carry the domain meaning.
Index ¶
- Variables
- type BigInt
- func (id BigInt) Big() *big.Int
- func (id BigInt) Bytes32() [32]byte
- func (id BigInt) Cmp(other BigInt) int
- func (id BigInt) Copy() BigInt
- func (id BigInt) Equal(other BigInt) bool
- func (id BigInt) IsZero() bool
- func (id BigInt) MarshalJSON() ([]byte, error)
- func (id BigInt) MarshalText() ([]byte, error)
- func (id BigInt) String() string
- func (id BigInt) Uint64() (uint64, bool)
- func (id *BigInt) UnmarshalJSON(data []byte) error
- func (id *BigInt) UnmarshalText(text []byte) error
- type ChainID
- type Epoch
- type ListOptions
- type WriteResult
Constants ¶
This section is empty.
Variables ¶
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.
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 BigInt ¶ added in v0.2.0
type BigInt struct {
// contains filtered or unexported fields
}
BigInt holds a uint256 value used by on-chain identifiers.
func BigIntFromBig ¶ added in v0.2.0
BigIntFromBig returns a BigInt after validating that v is a uint256.
func ParseBigInt ¶ added in v0.2.0
ParseBigInt parses a decimal uint256.
func (BigInt) Equal ¶ added in v0.2.0
Equal reports whether id and other hold the same numeric value.
func (BigInt) MarshalJSON ¶ added in v0.2.0
MarshalJSON implements json.Marshaler.
func (BigInt) MarshalText ¶ added in v0.2.0
MarshalText implements encoding.TextMarshaler.
func (*BigInt) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON implements json.Unmarshaler.
func (*BigInt) UnmarshalText ¶ added in v0.2.0
UnmarshalText implements encoding.TextUnmarshaler.
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.
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 ¶
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 WriteResult ¶
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.