types

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: Apache-2.0 Imports: 11 Imported by: 10

Documentation

Index

Constants

View Source
const (
	PickSmaller = iota // pick smaller coins to match amount
	PickBigger         // pick bigger coins to match amount
	PickByOrder        // pick coins by coins order to match amount
)
View Source
const (
	ExecutionStatusSuccess = "success"
	ExecutionStatusFailure = "failure"
)
View Source
const (
	SuiTransactionBlockKindSuiChangeEpoch             = "ChangeEpoch"
	SuiTransactionBlockKindSuiConsensusCommitPrologue = "ConsensusCommitPrologue"
	SuiTransactionBlockKindGenesis                    = "Genesis"
	SuiTransactionBlockKindProgrammableTransaction    = "ProgrammableTransaction"
)
View Source
const (
	SuiCoinType   = "0x2::sui::SUI"
	DevNetRpcUrl  = "https://fullnode.devnet.sui.io"
	TestnetRpcUrl = "https://fullnode.testnet.sui.io"
	MainnetRpcUrl = "https://fullnode.mainnet.sui.io"
)
View Source
const (
	StakeStatusActive   = "Active"
	StakeStatusPending  = "Pending"
	StakeStatusUnstaked = "Unstaked"
)
View Source
const MAX_INPUT_COUNT_MERGE = 256 - 1
View Source
const MAX_INPUT_COUNT_STAKE = 512 - 1
View Source
const SUI_COIN_TYPE = "0x2::sui::SUI"

Variables

View Source
var (
	ErrNoCoinsFound        = errors.New("no coins found")
	ErrInsufficientBalance = errors.New("insufficient account balance")

	ErrNeedMergeCoin    = errors.New("no coins of such a large amount were found to execute this transaction")
	ErrNeedSplitGasCoin = errors.New("missing an extra coin to use as the transaction fee")

	ErrCoinsNotMatchRequest = errors.New("coins not match request")
	ErrCoinsNeedMoreObject  = errors.New("you should get more SUI coins and try again")
)

Functions

func IsSameStringAddress

func IsSameStringAddress(addr1, addr2 string) bool

Types

type AuthSignInfo

type AuthSignInfo interface{}

type Balance

type Balance struct {
	CoinType        string                              `json:"coinType"`
	CoinObjectCount uint64                              `json:"coinObjectCount"`
	TotalBalance    SuiBigInt                           `json:"totalBalance"`
	LockedBalance   map[SafeSuiBigInt[uint64]]SuiBigInt `json:"lockedBalance"`
}

type BalanceChange

type BalanceChange struct {
	Owner    ObjectOwner `json:"owner"`
	CoinType string      `json:"coinType"`
	/* Coin balance change(positive means receive, negative means send) */
	Amount string `json:"amount"`
}

type CertifiedTransaction

type CertifiedTransaction struct {
	TransactionDigest string        `json:"transactionDigest"`
	TxSignature       string        `json:"txSignature"`
	AuthSignInfo      *AuthSignInfo `json:"authSignInfo"`

	Data *SenderSignedData `json:"data"`
}

type ChangeEpoch

type ChangeEpoch struct {
	Epoch             interface{} `json:"epoch"`
	StorageCharge     uint64      `json:"storage_charge"`
	ComputationCharge uint64      `json:"computation_charge"`
}

type CheckpointSequenceNumber

type CheckpointSequenceNumber = uint64

type CheckpointedObjectId

type CheckpointedObjectId struct {
	ObjectId     sui_types.ObjectID                       `json:"objectId"`
	AtCheckpoint *SafeSuiBigInt[CheckpointSequenceNumber] `json:"atCheckpoint"`
}

type Coin

type Coin struct {
	CoinType     string                 `json:"coinType"`
	CoinObjectId sui_types.ObjectID     `json:"coinObjectId"`
	Version      SafeSuiBigInt[uint64]  `json:"version"`
	Digest       sui_types.ObjectDigest `json:"digest"`
	Balance      SafeSuiBigInt[uint64]  `json:"balance"`

	LockedUntilEpoch    *SafeSuiBigInt[uint64]      `json:"lockedUntilEpoch,omitempty"`
	PreviousTransaction sui_types.TransactionDigest `json:"previousTransaction"`
}

func (*Coin) IsSUI

func (c *Coin) IsSUI() bool

func (*Coin) Reference

func (c *Coin) Reference() *sui_types.ObjectRef

type CoinPage

type CoinPage = Page[Coin, sui_types.ObjectID]

type Coins

type Coins []Coin

func (Coins) PickCoinNoLess

func (cs Coins) PickCoinNoLess(amount uint64) (*Coin, error)

func (Coins) PickCoins

func (cs Coins) PickCoins(amount *big.Int, pickMethod int) (Coins, error)

PickCoins pick coins, which sum >= amount, pickMethod, see PickSmaller|PickBigger|PickByOrder if not satisfated amount, an ErrCoinsNeedMoreObject error will return

func (Coins) PickSUICoinsWithGas

func (cs Coins) PickSUICoinsWithGas(amount *big.Int, gasAmount uint64, pickMethod int) (Coins, *Coin, error)

PickSUICoinsWithGas pick coins, which sum >= amount, and pick a gas coin >= gasAmount which not in coins if not satisfated amount/gasAmount, an ErrCoinsNotMatchRequest/ErrCoinsNeedMoreObject error will return if gasAmount == 0, a nil gasCoin will return pickMethod, see PickSmaller|PickBigger|PickByOrder

func (Coins) TotalBalance

func (cs Coins) TotalBalance() *big.Int

type DelegatedStake

type DelegatedStake struct {
	ValidatorAddress sui_types.SuiAddress `json:"validatorAddress"`
	StakingPool      sui_types.ObjectID   `json:"stakingPool"`
	Stakes           []JsonFlatten[Stake] `json:"stakes"`
}

type DevInspectResult

type DevInspectResult struct {
	Err string `json:"Err,omitempty"`
	Ok  any    `json:"Ok,omitempty"` //Result_of_Array_of_Tuple_of_uint_and_SuiExecutionResult_or_String
}

type DevInspectResults

type DevInspectResults struct {
	Effects lib.TagJson[SuiTransactionBlockEffects] `json:"effects"`
	Events  []SuiEvent                              `json:"events"`
	Results []ExecutionResultType                   `json:"results,omitempty"`
	Error   *string                                 `json:"error,omitempty"`
}

type DryRunTransactionBlockResponse

type DryRunTransactionBlockResponse struct {
	Effects        lib.TagJson[SuiTransactionBlockEffects] `json:"effects"`
	Events         []SuiEvent                              `json:"events"`
	ObjectChanges  []lib.TagJson[ObjectChange]             `json:"objectChanges"`
	BalanceChanges []BalanceChange                         `json:"balanceChanges"`
	Input          lib.TagJson[SuiTransactionBlockData]    `json:"input"`
}

type DynamicFieldInfo

type DynamicFieldInfo struct {
	Name sui_types.DynamicFieldName `json:"name"`
	//Base58
	BcsName    lib.Base58                              `json:"bcsName"`
	Type       lib.TagJson[sui_types.DynamicFieldType] `json:"type"`
	ObjectType string                                  `json:"objectType"`
	ObjectId   sui_types.ObjectID                      `json:"objectId"`
	Version    sui_types.SequenceNumber                `json:"version"`
	Digest     sui_types.ObjectDigest                  `json:"digest"`
}

type DynamicFieldPage

type DynamicFieldPage = Page[DynamicFieldInfo, sui_types.ObjectID]

type EpochId

type EpochId = uint64

type EventFilter

type EventFilter struct {
	/// Query by sender sui_types.address.
	Sender *sui_types.SuiAddress `json:"Sender,omitempty"`
	/// Return events emitted by the given transaction.
	Transaction *sui_types.TransactionDigest `json:"Transaction,omitempty"`

	/// Return events emitted in a specified Package.
	Package *sui_types.ObjectID `json:"Package,omitempty"`
	/// Return events emitted in a specified Move module.
	MoveModule *struct {
		/// the Move package ID
		Package sui_types.ObjectID `json:"package"`
		/// the module name
		Module string `json:"module"`
	} `json:"MoveModule,omitempty"`
	/// Return events with the given move event struct name
	MoveEventType  *string `json:"MoveEventType,omitempty"`
	MoveEventField *struct {
		Path  string      `json:"path"`
		Value interface{} `json:"value"`
	} `json:"MoveEventField,omitempty"`
	/// Return events emitted in [start_time, end_time] interval
	TimeRange *struct {
		/// left endpoint of time interval, milliseconds since epoch, inclusive
		StartTime SafeSuiBigInt[uint64] `json:"startTime"`
		/// right endpoint of time interval, milliseconds since epoch, exclusive
		EndTime SafeSuiBigInt[uint64] `json:"endTime"`
	} `json:"TimeRange,omitempty"`

	All *[]EventFilter `json:"All,omitempty"`
	Any *[]EventFilter `json:"Any,omitempty"`
}

type EventId

type EventId struct {
	TxDigest sui_types.TransactionDigest `json:"txDigest"`
	EventSeq SafeSuiBigInt[uint64]       `json:"eventSeq"`
}

type EventPage

type EventPage = Page[SuiEvent, EventId]

type ExecuteTransactionEffects

type ExecuteTransactionEffects struct {
	TransactionEffectsDigest string `json:"transactionEffectsDigest"`

	Effects      lib.TagJson[SuiTransactionBlockEffects] `json:"effects"`
	AuthSignInfo *AuthSignInfo                           `json:"authSignInfo"`
}

type ExecuteTransactionRequestType

type ExecuteTransactionRequestType string
const (
	TxnRequestTypeWaitForEffectsCert    ExecuteTransactionRequestType = "WaitForEffectsCert"
	TxnRequestTypeWaitForLocalExecution ExecuteTransactionRequestType = "WaitForLocalExecution"
)

type ExecuteTransactionResponse

type ExecuteTransactionResponse struct {
	Certificate CertifiedTransaction      `json:"certificate"`
	Effects     ExecuteTransactionEffects `json:"effects"`

	ConfirmedLocalExecution bool `json:"confirmed_local_execution"`
}

func (*ExecuteTransactionResponse) TransactionDigest

func (r *ExecuteTransactionResponse) TransactionDigest() string

type ExecutionResultType

type ExecutionResultType struct {
	MutableReferenceOutputs []MutableReferenceOutputType `json:"mutableReferenceOutputs,omitempty"`
	ReturnValues            []ReturnValueType            `json:"returnValues,omitempty"`
}

type ExecutionStatus

type ExecutionStatus struct {
	Status string `json:"status"`
	Error  string `json:"error,omitempty"`
}

type GasCostSummary

type GasCostSummary struct {
	ComputationCost         SafeSuiBigInt[uint64] `json:"computationCost"`
	StorageCost             SafeSuiBigInt[uint64] `json:"storageCost"`
	StorageRebate           SafeSuiBigInt[uint64] `json:"storageRebate"`
	NonRefundableStorageFee SafeSuiBigInt[uint64] `json:"nonRefundableStorageFee"`
}

type InputObjectKind

type InputObjectKind map[string]interface{}

type JsonFlatten

type JsonFlatten[T Stake] struct {
	Data T
}

func (*JsonFlatten[T]) UnmarshalJSON

func (s *JsonFlatten[T]) UnmarshalJSON(data []byte) error

type ModulePublish

type ModulePublish struct {
	Modules [][]byte `json:"modules"`
}

type MoveCall

type MoveCall struct {
	Package  sui_types.ObjectID `json:"package"`
	Module   string             `json:"module"`
	Function string             `json:"function"`
	TypeArgs []interface{}      `json:"typeArguments"`
	Args     []interface{}      `json:"arguments"`
}

type MoveModule

type MoveModule struct {
	Package sui_types.ObjectID `json:"package"`
	Module  string             `json:"module"`
}

type MutableReferenceOutputType

type MutableReferenceOutputType interface{}

type ObjectChange

type ObjectChange struct {
	Published *struct {
		PackageId sui_types.ObjectID                      `json:"packageId"`
		Version   SafeSuiBigInt[sui_types.SequenceNumber] `json:"version"`
		Digest    sui_types.ObjectDigest                  `json:"digest"`
		Nodules   []string                                `json:"nodules"`
	} `json:"published,omitempty"`
	/// Transfer objects to new address / wrap in another object
	Transferred *struct {
		Sender     sui_types.SuiAddress                    `json:"sender"`
		Recipient  ObjectOwner                             `json:"recipient"`
		ObjectType string                                  `json:"objectType"`
		ObjectId   sui_types.ObjectID                      `json:"objectId"`
		Version    SafeSuiBigInt[sui_types.SequenceNumber] `json:"version"`
		Digest     sui_types.ObjectDigest                  `json:"digest"`
	} `json:"transferred,omitempty"`
	/// Object mutated.
	Mutated *struct {
		Sender          sui_types.SuiAddress                    `json:"sender"`
		Owner           ObjectOwner                             `json:"owner"`
		ObjectType      string                                  `json:"objectType"`
		ObjectId        sui_types.ObjectID                      `json:"objectId"`
		Version         SafeSuiBigInt[sui_types.SequenceNumber] `json:"version"`
		PreviousVersion SafeSuiBigInt[sui_types.SequenceNumber] `json:"previousVersion"`
		Digest          sui_types.ObjectDigest                  `json:"digest"`
	} `json:"mutated,omitempty"`
	/// Delete object j
	Deleted *struct {
		Sender     sui_types.SuiAddress                    `json:"sender"`
		ObjectType string                                  `json:"objectType"`
		ObjectId   sui_types.ObjectID                      `json:"objectId"`
		Version    SafeSuiBigInt[sui_types.SequenceNumber] `json:"version"`
	} `json:"deleted,omitempty"`
	/// Wrapped object
	Wrapped *struct {
		Sender     sui_types.SuiAddress                    `json:"sender"`
		ObjectType string                                  `json:"objectType"`
		ObjectId   sui_types.ObjectID                      `json:"objectId"`
		Version    SafeSuiBigInt[sui_types.SequenceNumber] `json:"version"`
	} `json:"wrapped,omitempty"`
	/// New object creation
	Created *struct {
		Sender     sui_types.SuiAddress                    `json:"sender"`
		Owner      ObjectOwner                             `json:"owner"`
		ObjectType string                                  `json:"objectType"`
		ObjectId   sui_types.ObjectID                      `json:"objectId"`
		Version    SafeSuiBigInt[sui_types.SequenceNumber] `json:"version"`
		Digest     sui_types.ObjectDigest                  `json:"digest"`
	} `json:"created,omitempty"`
}

func (ObjectChange) Content

func (o ObjectChange) Content() string

func (ObjectChange) Tag

func (o ObjectChange) Tag() string

type ObjectOwner

type ObjectOwner struct {
	*ObjectOwnerInternal
	// contains filtered or unexported fields
}

func (ObjectOwner) MarshalJSON

func (o ObjectOwner) MarshalJSON() ([]byte, error)

func (*ObjectOwner) UnmarshalJSON

func (o *ObjectOwner) UnmarshalJSON(data []byte) error

type ObjectOwnerInternal

type ObjectOwnerInternal struct {
	AddressOwner *sui_types.SuiAddress `json:"AddressOwner,omitempty"`
	ObjectOwner  *sui_types.SuiAddress `json:"ObjectOwner,omitempty"`
	SingleOwner  *sui_types.SuiAddress `json:"SingleOwner,omitempty"`
	Shared       *struct {
		InitialSharedVersion *sui_types.SequenceNumber `json:"initial_shared_version"`
	} `json:"Shared,omitempty"`
}

type OwnedObjectRef

type OwnedObjectRef struct {
	Owner     lib.TagJson[sui_types.Owner] `json:"owner"`
	Reference SuiObjectRef                 `json:"reference"`
}

type Page

type Page[T SuiTransactionBlockResponse | SuiEvent | Coin | SuiObjectResponse | DynamicFieldInfo | string,
	C sui_types.TransactionDigest | EventId | sui_types.ObjectID] struct {
	Data        []T  `json:"data"`
	NextCursor  *C   `json:"nextCursor,omitempty"`
	HasNextPage bool `json:"hasNextPage"`
}

type ParsedTransactionResponse

type ParsedTransactionResponse interface{}

type Pay

type Pay struct {
	Coins      []sui_types.ObjectRef  `json:"coins"`
	Recipients []sui_types.SuiAddress `json:"recipients"`
	Amounts    []uint64               `json:"amounts"`
}

type PayAllSui

type PayAllSui struct {
	Coins     []sui_types.ObjectRef `json:"coins"`
	Recipient sui_types.SuiAddress  `json:"recipient"`
}

type PaySui

type PaySui struct {
	Coins      []sui_types.ObjectRef  `json:"coins"`
	Recipients []sui_types.SuiAddress `json:"recipients"`
	Amounts    []uint64               `json:"amounts"`
}

type PickedCoins

type PickedCoins struct {
	Coins        []Coin
	TotalAmount  big.Int
	TargetAmount big.Int
}

func PickupCoins

func PickupCoins(inputCoins *CoinPage, targetAmount big.Int, gasBudget uint64, limit int, moreCount int) (
	*PickedCoins,
	error,
)

Select coins that match the target amount. @param inputCoins queried page coin datas @param targetAmount total amount of coins to be selected from inputCoins @param gasBudget the transaction gas budget @param limit the max number of coins selected, default is `MAX_INPUT_COUNT_MERGE` @param moreCount get more count of coins as possible, maybe the caller will want to try to merge out some small coin objects, default is 10 @throw ErrNoCoinsFound If the count of input coins is 0. @throw ErrInsufficientBalance If the input coins are all that is left and the total amount is less than the target amount. @throw ErrNeedMergeCoin If there are many coins, but the total amount of coins limited is less than the target amount.

func (*PickedCoins) CoinIds

func (cs *PickedCoins) CoinIds() []sui_types.ObjectID

func (*PickedCoins) CoinRefs

func (cs *PickedCoins) CoinRefs() []*sui_types.ObjectRef

func (*PickedCoins) Count

func (cs *PickedCoins) Count() int

func (*PickedCoins) SuggestMaxGasBudget

func (cs *PickedCoins) SuggestMaxGasBudget() uint64

@return Min(total-target, 10e9) (10 SUI)

type ResourceType

type ResourceType struct {
	Address    *sui_types.SuiAddress
	ModuleName string
	FuncName   string

	SubType *ResourceType
}

func NewResourceType

func NewResourceType(str string) (*ResourceType, error)

func (*ResourceType) ShortString

func (t *ResourceType) ShortString() string

func (*ResourceType) String

func (t *ResourceType) String() string

type ReturnValueType

type ReturnValueType interface{}

type SafeBigInt

type SafeBigInt interface {
	~int64 | ~uint64
}

type SafeSuiBigInt

type SafeSuiBigInt[T SafeBigInt] struct {
	// contains filtered or unexported fields
}

func NewSafeSuiBigInt

func NewSafeSuiBigInt[T SafeBigInt](num T) SafeSuiBigInt[T]

func (*SafeSuiBigInt[T]) Decimal

func (s *SafeSuiBigInt[T]) Decimal() decimal.Decimal

func (SafeSuiBigInt[T]) Int64

func (s SafeSuiBigInt[T]) Int64() int64

func (SafeSuiBigInt[T]) MarshalJSON

func (s SafeSuiBigInt[T]) MarshalJSON() ([]byte, error)

func (SafeSuiBigInt[T]) Uint64

func (s SafeSuiBigInt[T]) Uint64() uint64

func (*SafeSuiBigInt[T]) UnmarshalJSON

func (s *SafeSuiBigInt[T]) UnmarshalJSON(data []byte) error

func (*SafeSuiBigInt[T]) UnmarshalText

func (s *SafeSuiBigInt[T]) UnmarshalText(data []byte) error

type SenderSignedData

type SenderSignedData struct {
	Transactions []SingleTransactionKind `json:"transactions,omitempty"`

	Sender     *sui_types.SuiAddress `json:"sender"`
	GasPayment *sui_types.ObjectRef  `json:"gasPayment"`
	GasBudget  uint64                `json:"gasBudget"`
}

type SingleTransactionKind

type SingleTransactionKind struct {
	TransferObject *TransferObject `json:"TransferObject,omitempty"`
	Publish        *ModulePublish  `json:"Publish,omitempty"`
	Call           *MoveCall       `json:"Call,omitempty"`
	TransferSui    *TransferSui    `json:"TransferSui,omitempty"`
	ChangeEpoch    *ChangeEpoch    `json:"ChangeEpoch,omitempty"`
	PaySui         *PaySui         `json:"PaySui,omitempty"`
	Pay            *Pay            `json:"Pay,omitempty"`
	PayAllSui      *PayAllSui      `json:"PayAllSui,omitempty"`
}

type Stake

type Stake struct {
	StakedSuiId       sui_types.ObjectID     `json:"stakedSuiId"`
	StakeRequestEpoch SafeSuiBigInt[EpochId] `json:"stakeRequestEpoch"`
	StakeActiveEpoch  SafeSuiBigInt[EpochId] `json:"stakeActiveEpoch"`
	Principal         SafeSuiBigInt[uint64]  `json:"principal"`
	StakeStatus       *StakeStatus           `json:"-,flatten"`
}

func (*Stake) IsActive

func (s *Stake) IsActive() bool

type StakeStatus

type StakeStatus = lib.TagJson[Status]

type Status

type Status struct {
	Pending *struct{} `json:"Pending,omitempty"`
	Active  *struct {
		EstimatedReward SafeSuiBigInt[uint64] `json:"estimatedReward"`
	} `json:"Active,omitempty"`
	Unstaked *struct{} `json:"Unstaked,omitempty"`
}

func (Status) Content

func (s Status) Content() string

func (Status) Tag

func (s Status) Tag() string

type SuiBigInt

type SuiBigInt = decimal.Decimal

type SuiChangeEpoch

type SuiChangeEpoch struct {
	Epoch                 SafeSuiBigInt[EpochId] `json:"epoch"`
	StorageCharge         uint64                 `json:"storage_charge"`
	ComputationCharge     uint64                 `json:"computation_charge"`
	StorageRebate         uint64                 `json:"storage_rebate"`
	EpochStartTimestampMs uint64                 `json:"epoch_start_timestamp_ms"`
}

type SuiCoinMetadata

type SuiCoinMetadata struct {
	Decimals    uint8              `json:"decimals"`
	Description string             `json:"description"`
	IconUrl     string             `json:"iconUrl,omitempty"`
	Id          sui_types.ObjectID `json:"id"`
	Name        string             `json:"name"`
	Symbol      string             `json:"symbol"`
}

type SuiConsensusCommitPrologue

type SuiConsensusCommitPrologue struct {
	Epoch             uint64 `json:"epoch"`
	Round             uint64 `json:"round"`
	CommitTimestampMs uint64 `json:"commit_timestamp_ms"`
}

type SuiEvent

type SuiEvent struct {
	Id EventId `json:"id"`
	// Move package where this event was emitted.
	PackageId sui_types.ObjectID `json:"packageId"`
	// Move module where this event was emitted.
	TransactionModule string `json:"transactionModule"`
	// Sender's Sui sui_types.address.
	Sender sui_types.SuiAddress `json:"sender"`
	// Move event type.
	Type string `json:"type"`
	// Parsed json value of the event
	ParsedJson interface{} `json:"parsedJson,omitempty"`
	// Base 58 encoded bcs bytes of the move event
	Bcs         string                 `json:"bcs"`
	TimestampMs *SafeSuiBigInt[uint64] `json:"timestampMs,omitempty"`
}

type SuiGasData

type SuiGasData struct {
	Payment []SuiObjectRef `json:"payment"`
	/** Gas Object's owner */
	Owner  string                `json:"owner"`
	Price  SafeSuiBigInt[uint64] `json:"price"`
	Budget SafeSuiBigInt[uint64] `json:"budget"`
}

type SuiGenesisTransaction

type SuiGenesisTransaction struct {
	Objects []sui_types.ObjectID `json:"objects"`
}

type SuiMovePackage

type SuiMovePackage struct {
	Disassembled map[string]interface{} `json:"disassembled"`
}

type SuiNamePage added in v2.0.1

type SuiNamePage = Page[string, sui_types.ObjectID]

type SuiObjectData

type SuiObjectData struct {
	ObjectId sui_types.ObjectID                      `json:"objectId"`
	Version  SafeSuiBigInt[sui_types.SequenceNumber] `json:"version"`
	Digest   sui_types.ObjectDigest                  `json:"digest"`
	/**
	 * Type of the object, default to be undefined unless SuiObjectDataOptions.showType is set to true
	 */
	Type *string `json:"type,omitempty"`
	/**
	 * Move object content or package content, default to be undefined unless SuiObjectDataOptions.showContent is set to true
	 */
	Content *lib.TagJson[SuiParsedData] `json:"content,omitempty"`
	/**
	 * Move object content or package content in BCS bytes, default to be undefined unless SuiObjectDataOptions.showBcs is set to true
	 */
	Bcs *lib.TagJson[SuiRawData] `json:"bcs,omitempty"`
	/**
	 * The owner of this object. Default to be undefined unless SuiObjectDataOptions.showOwner is set to true
	 */
	Owner *ObjectOwner `json:"owner,omitempty"`
	/**
	 * The digest of the transaction that created or last mutated this object.
	 * Default to be undefined unless SuiObjectDataOptions.showPreviousTransaction is set to true
	 */
	PreviousTransaction *sui_types.TransactionDigest `json:"previousTransaction,omitempty"`
	/**
	 * The amount of SUI we would rebate if this object gets deleted.
	 * This number is re-calculated each time the object is mutated based on
	 * the present storage gas price.
	 * Default to be undefined unless SuiObjectDataOptions.showStorageRebate is set to true
	 */
	StorageRebate *SafeSuiBigInt[uint64] `json:"storageRebate,omitempty"`
	/**
	 * Display metadata for this object, default to be undefined unless SuiObjectDataOptions.showDisplay is set to true
	 * This can also be None if the struct type does not have Display defined
	 * See more details in https://forums.sui.io/t/nft-object-display-proposal/4872
	 */
	Display interface{} `json:"display,omitempty"`
}

func (*SuiObjectData) Reference added in v2.0.1

func (data *SuiObjectData) Reference() sui_types.ObjectRef

type SuiObjectDataFilter

type SuiObjectDataFilter struct {
	Package    *sui_types.ObjectID `json:"Package,omitempty"`
	MoveModule *MoveModule         `json:"MoveModule,omitempty"`
	StructType string              `json:"StructType,omitempty"`
}

TODO need use Enum

type SuiObjectDataOptions

type SuiObjectDataOptions struct {
	/* Whether to fetch the object type, default to be false */
	ShowType bool `json:"showType,omitempty"`
	/* Whether to fetch the object content, default to be false */
	ShowContent bool `json:"showContent,omitempty"`
	/* Whether to fetch the object content in BCS bytes, default to be false */
	ShowBcs bool `json:"showBcs,omitempty"`
	/* Whether to fetch the object owner, default to be false */
	ShowOwner bool `json:"showOwner,omitempty"`
	/* Whether to fetch the previous transaction digest, default to be false */
	ShowPreviousTransaction bool `json:"showPreviousTransaction,omitempty"`
	/* Whether to fetch the storage rebate, default to be false */
	ShowStorageRebate bool `json:"showStorageRebate,omitempty"`
	/* Whether to fetch the display metadata, default to be false */
	ShowDisplay bool `json:"showDisplay,omitempty"`
}

type SuiObjectRef

type SuiObjectRef struct {
	/** Base64 string representing the object digest */
	Digest sui_types.TransactionDigest `json:"digest"`
	/** Hex code as string representing the object id */
	ObjectId string `json:"objectId"`
	/** Object version */
	Version sui_types.SequenceNumber `json:"version"`
}

type SuiObjectResponse

type SuiObjectResponse struct {
	Data  *SuiObjectData                       `json:"data,omitempty"`
	Error *lib.TagJson[SuiObjectResponseError] `json:"error,omitempty"`
}

type SuiObjectResponseError

type SuiObjectResponseError struct {
	NotExists *struct {
		ObjectId sui_types.ObjectID `json:"object_id"`
	} `json:"notExists,omitempty"`
	Deleted *struct {
		ObjectId sui_types.ObjectID       `json:"object_id"`
		Version  sui_types.SequenceNumber `json:"version"`
		Digest   sui_types.ObjectDigest   `json:"digest"`
	} `json:"deleted,omitempty"`
	UnKnown      *struct{} `json:"unKnown"`
	DisplayError *struct {
		Error string `json:"error"`
	} `json:"displayError"`
}

func (SuiObjectResponseError) Content

func (e SuiObjectResponseError) Content() string

func (SuiObjectResponseError) Tag

type SuiObjectResponseQuery

type SuiObjectResponseQuery struct {
	Filter  *SuiObjectDataFilter  `json:"filter,omitempty"`
	Options *SuiObjectDataOptions `json:"options,omitempty"`
}

type SuiParsedData

type SuiParsedData struct {
	MoveObject *SuiParsedMoveObject `json:"moveObject,omitempty"`
	Package    *SuiMovePackage      `json:"package,omitempty"`
}

func (SuiParsedData) Content

func (p SuiParsedData) Content() string

func (SuiParsedData) Tag

func (p SuiParsedData) Tag() string

type SuiParsedMoveObject

type SuiParsedMoveObject struct {
	Type              string `json:"type"`
	HasPublicTransfer bool   `json:"hasPublicTransfer"`
	Fields            any    `json:"fields"`
}

type SuiPastObject

type SuiPastObject struct {
	/// The object exists and is found with this version
	VersionFound *SuiObjectData `json:"VersionFound,omitempty"`
	/// The object does not exist
	ObjectNotExists *sui_types.ObjectID `json:"ObjectNotExists,omitempty"`
	/// The object is found to be deleted with this version
	ObjectDeleted *SuiObjectRef `json:"ObjectDeleted,omitempty"`
	/// The object exists but not found with this version
	VersionNotFound *struct{ ObjectId sui_types.SequenceNumber } `json:"VersionNotFound,omitempty"`
	/// The asked object version is higher than the latest
	VersionTooHigh *struct {
		ObjectId      sui_types.ObjectID       `json:"object_id"`
		AskedVersion  sui_types.SequenceNumber `json:"asked_version"`
		LatestVersion sui_types.SequenceNumber `json:"latest_version"`
	} `json:"VersionTooHigh,omitempty"`
}

TODO need test VersionNotFound

func (SuiPastObject) Content

func (s SuiPastObject) Content() string

func (SuiPastObject) Tag

func (s SuiPastObject) Tag() string

type SuiPastObjectResponse

type SuiPastObjectResponse = lib.TagJson[SuiPastObject]

type SuiProgrammableTransactionBlock

type SuiProgrammableTransactionBlock struct {
	Inputs []interface{} `json:"inputs"`
	/// The transactions to be executed sequentially. A failure in any transaction will
	/// result in the failure of the entire programmable transaction block.
	Commands []interface{} `json:"transactions"`
}

type SuiRawData

type SuiRawData struct {
	MoveObject *SuiRawMoveObject  `json:"moveObject,omitempty"`
	Package    *SuiRawMovePackage `json:"package,omitempty"`
}

func (SuiRawData) Content

func (r SuiRawData) Content() string

func (SuiRawData) Tag

func (r SuiRawData) Tag() string

type SuiRawMoveObject

type SuiRawMoveObject struct {
	Type              string                   `json:"type"`
	HasPublicTransfer bool                     `json:"hasPublicTransfer"`
	Version           sui_types.SequenceNumber `json:"version"`
	BcsBytes          lib.Base64Data           `json:"bcsBytes"`
}

type SuiRawMovePackage

type SuiRawMovePackage struct {
	Id              sui_types.ObjectID        `json:"id"`
	Version         sui_types.SequenceNumber  `json:"version"`
	ModuleMap       map[string]lib.Base64Data `json:"moduleMap"`
	TypeOriginTable []TypeOrigin              `json:"typeOriginTable"`
	LinkageTable    map[string]UpgradeInfo
}

type SuiSystemStateSummary

type SuiSystemStateSummary struct {
	Epoch                                 SafeSuiBigInt[uint64]   `json:"epoch"`
	ProtocolVersion                       SafeSuiBigInt[uint64]   `json:"protocolVersion"`
	SystemStateVersion                    SafeSuiBigInt[uint64]   `json:"systemStateVersion"`
	StorageFundTotalObjectStorageRebates  SafeSuiBigInt[uint64]   `json:"storageFundTotalObjectStorageRebates"`
	StorageFundNonRefundableBalance       SafeSuiBigInt[uint64]   `json:"storageFundNonRefundableBalance"`
	ReferenceGasPrice                     SafeSuiBigInt[uint64]   `json:"referenceGasPrice"`
	SafeMode                              bool                    `json:"safeMode"`
	SafeModeStorageRewards                SafeSuiBigInt[uint64]   `json:"safeModeStorageRewards"`
	SafeModeComputationRewards            SafeSuiBigInt[uint64]   `json:"safeModeComputationRewards"`
	SafeModeStorageRebates                SafeSuiBigInt[uint64]   `json:"safeModeStorageRebates"`
	SafeModeNonRefundableStorageFee       SafeSuiBigInt[uint64]   `json:"safeModeNonRefundableStorageFee"`
	EpochStartTimestampMs                 SafeSuiBigInt[uint64]   `json:"epochStartTimestampMs"`
	EpochDurationMs                       SafeSuiBigInt[uint64]   `json:"epochDurationMs"`
	StakeSubsidyStartEpoch                SafeSuiBigInt[uint64]   `json:"stakeSubsidyStartEpoch"`
	MaxValidatorCount                     SafeSuiBigInt[uint64]   `json:"maxValidatorCount"`
	MinValidatorJoiningStake              SafeSuiBigInt[uint64]   `json:"minValidatorJoiningStake"`
	ValidatorLowStakeThreshold            SafeSuiBigInt[uint64]   `json:"validatorLowStakeThreshold"`
	ValidatorVeryLowStakeThreshold        SafeSuiBigInt[uint64]   `json:"validatorVeryLowStakeThreshold"`
	ValidatorLowStakeGracePeriod          SafeSuiBigInt[uint64]   `json:"validatorLowStakeGracePeriod"`
	StakeSubsidyBalance                   SafeSuiBigInt[uint64]   `json:"stakeSubsidyBalance"`
	StakeSubsidyDistributionCounter       SafeSuiBigInt[uint64]   `json:"stakeSubsidyDistributionCounter"`
	StakeSubsidyCurrentDistributionAmount SafeSuiBigInt[uint64]   `json:"stakeSubsidyCurrentDistributionAmount"`
	StakeSubsidyPeriodLength              SafeSuiBigInt[uint64]   `json:"stakeSubsidyPeriodLength"`
	StakeSubsidyDecreaseRate              uint16                  `json:"stakeSubsidyDecreaseRate"`
	TotalStake                            SafeSuiBigInt[uint64]   `json:"totalStake"`
	ActiveValidators                      []SuiValidatorSummary   `json:"activeValidators"`
	PendingActiveValidatorsId             sui_types.ObjectID      `json:"pendingActiveValidatorsId"`
	PendingActiveValidatorsSize           SafeSuiBigInt[uint64]   `json:"pendingActiveValidatorsSize"`
	PendingRemovals                       []SafeSuiBigInt[uint64] `json:"pendingRemovals"`
	StakingPoolMappingsId                 sui_types.ObjectID      `json:"stakingPoolMappingsId"`
	StakingPoolMappingsSize               SafeSuiBigInt[uint64]   `json:"stakingPoolMappingsSize"`
	InactivePoolsId                       sui_types.ObjectID      `json:"inactivePoolsId"`
	InactivePoolsSize                     SafeSuiBigInt[uint64]   `json:"inactivePoolsSize"`
	ValidatorCandidatesId                 sui_types.ObjectID      `json:"validatorCandidatesId"`
	ValidatorCandidatesSize               SafeSuiBigInt[uint64]   `json:"validatorCandidatesSize"`
	AtRiskValidators                      interface{}             `json:"atRiskValidators"`
	ValidatorReportRecords                interface{}             `json:"validatorReportRecords"`
}

type SuiTransactionBlock

type SuiTransactionBlock struct {
	Data         lib.TagJson[SuiTransactionBlockData] `json:"data"`
	TxSignatures []string                             `json:"txSignatures"`
}

type SuiTransactionBlockData

type SuiTransactionBlockData struct {
	V1 *SuiTransactionBlockDataV1 `json:"v1,omitempty"`
}

func (SuiTransactionBlockData) Content

func (t SuiTransactionBlockData) Content() string

func (SuiTransactionBlockData) Tag

type SuiTransactionBlockDataV1

type SuiTransactionBlockDataV1 struct {
	Transaction SuiTransactionBlockKind `json:"transaction"`
	Sender      sui_types.SuiAddress    `json:"sender"`
	GasData     SuiGasData              `json:"gasData"`
}

type SuiTransactionBlockEffects

type SuiTransactionBlockEffects struct {
	V1 *SuiTransactionBlockEffectsV1 `json:"v1"`
}

func (SuiTransactionBlockEffects) Content

func (t SuiTransactionBlockEffects) Content() string

func (SuiTransactionBlockEffects) GasFee

func (t SuiTransactionBlockEffects) GasFee() int64

func (SuiTransactionBlockEffects) IsSuccess

func (t SuiTransactionBlockEffects) IsSuccess() bool

func (SuiTransactionBlockEffects) Tag

type SuiTransactionBlockEffectsModifiedAtVersions

type SuiTransactionBlockEffectsModifiedAtVersions struct {
	ObjectId       sui_types.ObjectID                      `json:"objectId"`
	SequenceNumber SafeSuiBigInt[sui_types.SequenceNumber] `json:"sequenceNumber"`
}

type SuiTransactionBlockEffectsV1

type SuiTransactionBlockEffectsV1 struct {
	/** The status of the execution */
	Status ExecutionStatus `json:"status"`
	/** The epoch when this transaction was executed */
	ExecutedEpoch SafeSuiBigInt[EpochId] `json:"executedEpoch"`
	/** The version that every modified (mutated or deleted) object had before it was modified by this transaction. **/
	ModifiedAtVersions []SuiTransactionBlockEffectsModifiedAtVersions `json:"modifiedAtVersions,omitempty"`
	GasUsed            GasCostSummary                                 `json:"gasUsed"`
	/** The object references of the shared objects used in this transaction. Empty if no shared objects were used. */
	SharedObjects []SuiObjectRef `json:"sharedObjects,omitempty"`
	/** The transaction digest */
	TransactionDigest sui_types.TransactionDigest `json:"transactionDigest"`
	/** ObjectRef and owner of new objects created */
	Created []OwnedObjectRef `json:"created,omitempty"`
	/** ObjectRef and owner of mutated objects, including gas object */
	Mutated []OwnedObjectRef `json:"mutated,omitempty"`
	/**
	 * ObjectRef and owner of objects that are unwrapped in this transaction.
	 * Unwrapped objects are objects that were wrapped into other objects in the past,
	 * and just got extracted out.
	 */
	Unwrapped []OwnedObjectRef `json:"unwrapped,omitempty"`
	/** Object Refs of objects now deleted (the old refs) */
	Deleted []SuiObjectRef `json:"deleted,omitempty"`
	/** Object Refs of objects now deleted (the old refs) */
	UnwrappedThenDeleted []SuiObjectRef `json:"unwrapped_then_deleted,omitempty"`
	/** Object refs of objects now wrapped in other objects */
	Wrapped []SuiObjectRef `json:"wrapped,omitempty"`
	/**
	 * The updated gas object reference. Have a dedicated field for convenient access.
	 * It's also included in mutated.
	 */
	GasObject OwnedObjectRef `json:"gasObject"`
	/** The events emitted during execution. Note that only successful transactions emit events */
	EventsDigest *sui_types.TransactionEventsDigest `json:"eventsDigest,omitempty"`
	/** The set of transaction digests this transaction depends on */
	Dependencies []sui_types.TransactionDigest `json:"dependencies,omitempty"`
}

type SuiTransactionBlockKind

type SuiTransactionBlockKind = lib.TagJson[TransactionBlockKind]

type SuiTransactionBlockResponse

type SuiTransactionBlockResponse struct {
	Digest                  sui_types.TransactionDigest              `json:"digest"`
	Transaction             *SuiTransactionBlock                     `json:"transaction,omitempty"`
	RawTransaction          []byte                                   `json:"rawTransaction,omitempty"`
	Effects                 *lib.TagJson[SuiTransactionBlockEffects] `json:"effects,omitempty"`
	Events                  []SuiEvent                               `json:"events,omitempty"`
	TimestampMs             *SafeSuiBigInt[uint64]                   `json:"timestampMs,omitempty"`
	Checkpoint              *SafeSuiBigInt[CheckpointSequenceNumber] `json:"checkpoint,omitempty"`
	ConfirmedLocalExecution *bool                                    `json:"confirmedLocalExecution,omitempty"`
	ObjectChanges           []lib.TagJson[ObjectChange]              `json:"objectChanges,omitempty"`
	BalanceChanges          []BalanceChange                          `json:"balanceChanges,omitempty"`
	/* Errors that occurred in fetching/serializing the transaction. */
	Errors []string `json:"errors,omitempty"`
}

type SuiTransactionBlockResponseOptions

type SuiTransactionBlockResponseOptions struct {
	/* Whether to show transaction input data. Default to be false. */
	ShowInput bool `json:"showInput,omitempty"`
	/* Whether to show transaction effects. Default to be false. */
	ShowEffects bool `json:"showEffects,omitempty"`
	/* Whether to show transaction events. Default to be false. */
	ShowEvents bool `json:"showEvents,omitempty"`
	/* Whether to show object changes. Default to be false. */
	ShowObjectChanges bool `json:"showObjectChanges,omitempty"`
	/* Whether to show coin balance changes. Default to be false. */
	ShowBalanceChanges bool `json:"showBalanceChanges,omitempty"`
}

type SuiTransactionBlockResponseQuery

type SuiTransactionBlockResponseQuery struct {
	Filter  *TransactionFilter                  `json:"filter,omitempty"`
	Options *SuiTransactionBlockResponseOptions `json:"options,omitempty"`
}

type SuiValidatorSummary

type SuiValidatorSummary struct {
	SuiAddress             sui_types.SuiAddress `json:"suiAddress"`
	ProtocolPubkeyBytes    lib.Base64Data       `json:"protocolPubkeyBytes"`
	NetworkPubkeyBytes     lib.Base64Data       `json:"networkPubkeyBytes"`
	WorkerPubkeyBytes      lib.Base64Data       `json:"workerPubkeyBytes"`
	ProofOfPossessionBytes lib.Base64Data       `json:"proofOfPossessionBytes"`
	OperationCapId         sui_types.ObjectID   `json:"operationCapId"`
	Name                   string               `json:"name"`
	Description            string               `json:"description"`
	ImageUrl               string               `json:"imageUrl"`
	ProjectUrl             string               `json:"projectUrl"`
	P2pAddress             string               `json:"p2pAddress"`
	NetAddress             string               `json:"netAddress"`
	PrimaryAddress         string               `json:"primaryAddress"`
	WorkerAddress          string               `json:"workerAddress"`

	NextEpochProtocolPubkeyBytes lib.Base64Data `json:"nextEpochProtocolPubkeyBytes"`
	NextEpochProofOfPossession   lib.Base64Data `json:"nextEpochProofOfPossession"`
	NextEpochNetworkPubkeyBytes  lib.Base64Data `json:"nextEpochNetworkPubkeyBytes"`
	NextEpochWorkerPubkeyBytes   lib.Base64Data `json:"nextEpochWorkerPubkeyBytes"`
	NextEpochNetAddress          string         `json:"nextEpochNetAddress"`
	NextEpochP2pAddress          string         `json:"nextEpochP2pAddress"`
	NextEpochPrimaryAddress      string         `json:"nextEpochPrimaryAddress"`
	NextEpochWorkerAddress       string         `json:"nextEpochWorkerAddress"`

	VotingPower             SafeSuiBigInt[uint64] `json:"votingPower"`
	GasPrice                SafeSuiBigInt[uint64] `json:"gasPrice"`
	CommissionRate          SafeSuiBigInt[uint64] `json:"commissionRate"`
	NextEpochStake          SafeSuiBigInt[uint64] `json:"nextEpochStake"`
	NextEpochGasPrice       SafeSuiBigInt[uint64] `json:"nextEpochGasPrice"`
	NextEpochCommissionRate SafeSuiBigInt[uint64] `json:"nextEpochCommissionRate"`
	StakingPoolId           sui_types.ObjectID    `json:"stakingPoolId"`

	StakingPoolActivationEpoch   SafeSuiBigInt[uint64] `json:"stakingPoolActivationEpoch"`
	StakingPoolDeactivationEpoch SafeSuiBigInt[uint64] `json:"stakingPoolDeactivationEpoch"`

	StakingPoolSuiBalance    SafeSuiBigInt[uint64] `json:"stakingPoolSuiBalance"`
	RewardsPool              SafeSuiBigInt[uint64] `json:"rewardsPool"`
	PoolTokenBalance         SafeSuiBigInt[uint64] `json:"poolTokenBalance"`
	PendingStake             SafeSuiBigInt[uint64] `json:"pendingStake"`
	PendingPoolTokenWithdraw SafeSuiBigInt[uint64] `json:"pendingPoolTokenWithdraw"`
	PendingTotalSuiWithdraw  SafeSuiBigInt[uint64] `json:"pendingTotalSuiWithdraw"`
	ExchangeRatesId          sui_types.ObjectID    `json:"exchangeRatesId"`
	ExchangeRatesSize        SafeSuiBigInt[uint64] `json:"exchangeRatesSize"`
}

type Supply

type Supply struct {
	Value SafeSuiBigInt[uint64] `json:"value"`
}

type TimeRange

type TimeRange struct {
	StartTime uint64 `json:"startTime"` // left endpoint of time interval, milliseconds since epoch, inclusive
	EndTime   uint64 `json:"endTime"`   // right endpoint of time interval, milliseconds since epoch, exclusive
}

type TransactionBlockKind

type TransactionBlockKind struct {
	/// A system transaction that will update epoch information on-chain.
	ChangeEpoch *SuiChangeEpoch `json:"ChangeEpoch,omitempty"`
	/// A system transaction used for initializing the initial state of the chain.
	Genesis *SuiGenesisTransaction `json:"Genesis,omitempty"`
	/// A system transaction marking the start of a series of transactions scheduled as part of a
	/// checkpoint
	ConsensusCommitPrologue *SuiConsensusCommitPrologue `json:"ConsensusCommitPrologue,omitempty"`
	/// A series of transactions where the results of one transaction can be used in future
	/// transactions
	ProgrammableTransaction *SuiProgrammableTransactionBlock `json:"ProgrammableTransaction,omitempty"`
}

func (TransactionBlockKind) Content

func (t TransactionBlockKind) Content() string

func (TransactionBlockKind) Tag

func (t TransactionBlockKind) Tag() string

type TransactionBytes

type TransactionBytes struct {
	// the gas object to be used
	Gas []sui_types.ObjectRef `json:"gas"`

	// objects to be used in this transaction
	InputObjects []InputObjectKind `json:"inputObjects"`

	// transaction data bytes
	TxBytes lib.Base64Data `json:"txBytes"`
}

type TransactionFilter

type TransactionFilter struct {
	Checkpoint   *sui_types.SequenceNumber `json:"Checkpoint,omitempty"`
	MoveFunction *struct {
		Package  sui_types.ObjectID `json:"package"`
		Module   string             `json:"module,omitempty"`
		Function string             `json:"function,omitempty"`
	} `json:"MoveFunction,omitempty"`
	InputObject      *sui_types.ObjectID   `json:"InputObject,omitempty"`
	ChangedObject    *sui_types.ObjectID   `json:"ChangedObject,omitempty"`
	FromAddress      *sui_types.SuiAddress `json:"FromAddress,omitempty"`
	ToAddress        *sui_types.SuiAddress `json:"ToAddress,omitempty"`
	FromAndToAddress *struct {
		From *sui_types.SuiAddress `json:"from"`
		To   *sui_types.SuiAddress `json:"to"`
	} `json:"FromAndToAddress,omitempty"`
	TransactionKind *string `json:"TransactionKind,omitempty"`
}

type TransferObject

type TransferObject struct {
	Recipient sui_types.SuiAddress `json:"recipient"`
	ObjectRef sui_types.ObjectRef  `json:"object_ref"`
}

type TransferSui

type TransferSui struct {
	Recipient sui_types.SuiAddress `json:"recipient"`
	Amount    uint64               `json:"amount"`
}

type TypeName

type TypeName []sui_types.SuiAddress

type TypeOrigin

type TypeOrigin struct {
	ModuleName string             `json:"moduleName"`
	StructName string             `json:"structName"`
	Package    sui_types.ObjectID `json:"package"`
}

type UpgradeInfo

type UpgradeInfo struct {
	UpgradedId      sui_types.ObjectID
	UpgradedVersion sui_types.SequenceNumber
}

type ValidatorsApy

type ValidatorsApy struct {
	Epoch SafeSuiBigInt[EpochId] `json:"epoch"`
	Apys  []struct {
		Address string  `json:"address"`
		Apy     float64 `json:"apy"`
	} `json:"apys"`
}

func (*ValidatorsApy) ApyMap

func (apys *ValidatorsApy) ApyMap() map[string]float64

Jump to

Keyboard shortcuts

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