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.
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 BroadcastError
- 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 ErrReceiptRPCFailure = txutil.ErrReceiptRPCFailure
ErrReceiptRPCFailure reports an RPC failure that cannot be retried or exhausted the receipt wait's consecutive error budget. The error preserves the RPC cause.
var ErrReceiptTimeout = txutil.ErrReceiptTimeout
ErrReceiptTimeout reports that the receipt wait or its parent context reached its deadline. Returned wait errors also match context.DeadlineExceeded.
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, ...) provide convenience aliases to this sentinel; 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. Use Equal or Cmp for numeric comparisons.
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 BroadcastError ¶ added in v0.7.0
type BroadcastError struct {
Transaction *ethtypes.Transaction
Cause error
}
BroadcastError reports an error returned while sending a signed transaction. It does not establish whether the node rejected or accepted the transaction. SDK-originated errors always contain Transaction and Cause. Use errors.AsType to recover the original transaction for lookup or resubmission; do not retry the business operation merely because its WriteResult is nil.
func (*BroadcastError) Error ¶ added in v0.7.0
func (e *BroadcastError) Error() string
func (*BroadcastError) Unwrap ¶ added in v0.7.0
func (e *BroadcastError) Unwrap() error
Unwrap preserves the original send error for errors.Is and errors.AsType.
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 and reached any requested confirmation count before the wait ended. Explicit confirmations apply to both successful and failed receipts, counting the inclusion block as the first confirmation.
Error semantics (observe WriteResult and err together):
- WriteResult == nil, err != nil: no successful submission result is available. When sending returned an error, err wraps BroadcastError, which preserves the original signed transaction. A nil result does not establish that the node rejected the transaction; do not blindly retry the business operation with a new transaction.
- 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, was canceled, 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. Use errors.Is with ErrReceiptTimeout, ErrReceiptRPCFailure, or context.Canceled to distinguish these outcomes; RPC causes are preserved.
- 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.