Documentation ¶
Index ¶
- Constants
- Variables
- type ActiveDelegationStatus
- type ActiveFields
- type Address
- type AuthSignInfo
- type Balance
- type Base64Data
- type Bytes
- type BytesData
- type CertifiedTransaction
- type ChangeEpoch
- type Coin
- type CoinObject
- type CoinPage
- type Coins
- type DelegatedStake
- type DevInspectResult
- type DevInspectResults
- type Digest
- type Event
- type EventID
- type EventPage
- type EventQuery
- type ExecuteTransactionEffects
- type ExecuteTransactionRequestType
- type ExecuteTransactionResponse
- type GasCostSummary
- type HexData
- type InputObjectKind
- type ModulePublish
- type MoveCall
- type MoveFunction
- type MoveModule
- type ObjectId
- type ObjectInfo
- type ObjectOwner
- type ObjectOwnerInternal
- type ObjectRead
- type ObjectReadDetail
- type ObjectRef
- type ObjectStatus
- type OwnedObjectRef
- type ParsedTransactionResponse
- type Pay
- type PayAllSui
- type PaySui
- type ResourceType
- type SenderSignedData
- type SignatureScheme
- type SignatureSchemeSerialized
- type SignedTransaction
- type SignedTransactionSerializedSig
- type SingleTransactionKind
- type StakedSui
- type StakingPool
- type SuiCoinBalance
- type SuiCoinMetadata
- type SuiSystemState
- type Supply
- type TimeRange
- type TransactionBytes
- type TransactionEffects
- type TransactionQuery
- type TransactionResponse
- type TransactionStatus
- type TransactionsPage
- type TransferObject
- type TransferSui
- type Validator
- type ValidatorMetadata
- type ValidatorSet
Constants ¶
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 )
const ( TransactionStatusSuccess = "success" TransactionStatusFailure = "failure" )
const ( SuiCoinType = "0x2::sui::SUI" DevNetRpcUrl = "https://fullnode.devnet.sui.io" TestnetRpcUrl = "https://fullnode.testnet.sui.io" )
Variables ¶
var ErrCoinsNotMatchRequest error
var IntentBytes = []byte{0, 0, 0}
IntentBytes See: sui/crates/sui-types/src/intent.rs This is currently hardcoded with [IntentScope::TransactionData = 0, Version::V0 = 0, AppId::Sui = 0]
Functions ¶
This section is empty.
Types ¶
type ActiveDelegationStatus ¶
type ActiveDelegationStatus struct {
Active ActiveFields `json:"Active"`
}
type ActiveFields ¶
type Address ¶
type Address = HexData
func NewAddressFromHex ¶
NewAddressFromHex *
- Creates Address from a hex string.
- @param addr Hex string can be with a prefix or without a prefix,
- e.g. '0x1aa' or '1aa'. Hex string will be left padded with 0s if too short.
func (Address) ShortString ¶
ShortString Returns the address with leading zeros trimmed, e.g. 0x2
type AuthSignInfo ¶
type AuthSignInfo interface{}
type Base64Data ¶
type Base64Data struct {
// contains filtered or unexported fields
}
func NewBase64Data ¶
func NewBase64Data(str string) (*Base64Data, error)
func (Base64Data) Data ¶
func (h Base64Data) Data() []byte
func (Base64Data) Length ¶
func (h Base64Data) Length() int
func (Base64Data) MarshalBCS ¶
func (h Base64Data) MarshalBCS() ([]byte, error)
func (Base64Data) MarshalJSON ¶
func (h Base64Data) MarshalJSON() ([]byte, error)
func (Base64Data) String ¶
func (h Base64Data) String() string
func (*Base64Data) UnmarshalJSON ¶
func (h *Base64Data) UnmarshalJSON(data []byte) error
type Bytes ¶
type Bytes []byte
func (Bytes) GetBase64Data ¶
func (b Bytes) GetBase64Data() Base64Data
func (Bytes) GetHexData ¶
type CertifiedTransaction ¶
type CertifiedTransaction struct { TransactionDigest string `json:"transactionDigest"` TxSignature string `json:"txSignature"` AuthSignInfo *AuthSignInfo `json:"authSignInfo"` Data *SenderSignedData `json:"data"` }
type ChangeEpoch ¶
type CoinObject ¶
type CoinPage ¶
type CoinPage struct { Data []CoinObject `json:"data"` NextCursor *ObjectId `json:"nextCursor"` }
type Coins ¶
type Coins []Coin
func (Coins) PickCoins ¶
PickCoins pick coins, which sum >= amount, pickMethod, see PickSmaller|PickBigger|PickByOrder // if not satisfated amount, an ErrCoinsNotMatchRequest 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 error will return if gasAmount == 0, a nil gasCoin will return pickMethod, see PickSmaller|PickBigger|PickByOrder
func (Coins) TotalBalance ¶
type DelegatedStake ¶
type DelegatedStake struct { StakedSui StakedSui `json:"staked_sui"` DelegationStatus interface{} `json:"delegation_status"` // "Pending" or ActiveDelegationStatus }
func (*DelegatedStake) CalculateEarnAmount ¶
func (d *DelegatedStake) CalculateEarnAmount(activeValidators []Validator) (earn uint64, validator *Validator)
type DevInspectResult ¶
type DevInspectResults ¶
type DevInspectResults struct { Effects TransactionEffects `json:"effects"` Results DevInspectResult `json:"results"` }
type Digest ¶
type Digest = Base64Data
type EventQuery ¶
type EventQuery struct { // Return all events. All *string `json:"All"` // Return events emitted by the given transaction. Transaction *Digest `json:"Transaction"` // Return events emitted in a specified Move module MoveModule *MoveModule `json:"MoveModule"` // Return events with the given move event struct name MoveEvent *string `json:"MoveEvent"` // e.g. `0x2::devnet_nft::MintNFTEvent` // MoveEvent/Publish/CoinBalanceChange/EpochChange/Checkpoint // TransferObject/MutateObject/DeleteObject/NewObject EventType *string `json:"EventType"` // Query by sender address. Sender *Address `json:"Sender"` // Query by recipient address Recipient *ObjectOwnerInternal `json:"Recipient"` // Return events associated with the given object Object *ObjectId `json:"Object"` // Return events emitted in [start_time, end_time] interval TimeRange *TimeRange `json:"TimeRange"` }
func (EventQuery) MarshalJSON ¶
func (q EventQuery) MarshalJSON() ([]byte, error)
type ExecuteTransactionEffects ¶
type ExecuteTransactionEffects struct { TransactionEffectsDigest string `json:"transactionEffectsDigest"` Effects TransactionEffects `json:"effects"` AuthSignInfo *AuthSignInfo `json:"authSignInfo"` }
type ExecuteTransactionRequestType ¶
type ExecuteTransactionRequestType string
const ( TxnRequestTypeWaitForEffectsCert ExecuteTransactionRequestType = "WaitForEffectsCert" TxnRequestTypeWaitForLocalExecution ExecuteTransactionRequestType = "WaitForLocalExecution" )
type ExecuteTransactionResponse ¶
type ExecuteTransactionResponse struct { ImmediateReturn *struct { TransactionDigest string `json:"tx_digest"` } `json:"ImmediateReturn,omitempty"` TxCert *struct { Certificate CertifiedTransaction `json:"certificate"` } `json:"TxCert,omitempty"` EffectsCert *struct { Certificate CertifiedTransaction `json:"certificate"` Effects ExecuteTransactionEffects `json:"effects"` ConfirmedLocalExecution bool `json:"confirmed_local_execution"` } `json:"EffectsCert,omitempty"` }
func (*ExecuteTransactionResponse) TransactionDigest ¶
func (r *ExecuteTransactionResponse) TransactionDigest() string
type GasCostSummary ¶
type HexData ¶
type HexData struct {
// contains filtered or unexported fields
}
func NewHexData ¶
func (HexData) MarshalBCS ¶
func (HexData) MarshalJSON ¶
func (*HexData) UnmarshalJSON ¶
type InputObjectKind ¶
type InputObjectKind map[string]interface{}
type ModulePublish ¶
type ModulePublish struct {
Modules [][]byte `json:"modules"`
}
type MoveFunction ¶
type MoveModule ¶
type ObjectInfo ¶
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 ObjectRead ¶
type ObjectRead struct { Details *ObjectReadDetail `json:"details"` Status ObjectStatus `json:"status"` }
type ObjectReadDetail ¶
type ObjectReadDetail struct { Data map[string]interface{} `json:"data"` Owner *ObjectOwner `json:"owner"` PreviousTransaction string `json:"previousTransaction"` StorageRebate int `json:"storageRebate"` Reference *ObjectRef `json:"reference"` }
type ObjectRef ¶
type ObjectRef struct { ObjectId ObjectId `json:"objectId"` Version uint64 `json:"version"` Digest Digest `json:"digest"` }
ObjectRef for BCS, need to keep this order
type ObjectStatus ¶
type ObjectStatus string
const ( // ObjectStatusExists ObjectStatusNotExists ObjectStatusDeleted // status for sui_getObject ObjectStatusExists ObjectStatus = "Exists" ObjectStatusNotExists ObjectStatus = "NotExists" ObjectStatusDeleted ObjectStatus = "Deleted" // ObjectDeleted VersionFound VersionTooHigh VersionNotFound //status for sui_tryGetPastObject ObjectDeleted ObjectStatus = "ObjectDeleted" VersionFound ObjectStatus = "VersionFound" VersionTooHigh ObjectStatus = "VersionTooHigh" VersionNotFound ObjectStatus = "VersionNotFound" )
type OwnedObjectRef ¶
type OwnedObjectRef struct { Owner *ObjectOwner `json:"owner"` Reference *ObjectRef `json:"reference"` }
type ParsedTransactionResponse ¶
type ParsedTransactionResponse interface{}
type ResourceType ¶
type ResourceType struct { Address *Address 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 SenderSignedData ¶
type SenderSignedData struct { Transactions []SingleTransactionKind `json:"transactions,omitempty"` Sender *Address `json:"sender"` GasPayment *ObjectRef `json:"gasPayment"` GasBudget uint64 `json:"gasBudget"` }
type SignatureScheme ¶
type SignatureScheme string
const ( SignatureSchemeEd25519 SignatureScheme = "ED25519" SignatureSchemeSecp256k1 SignatureScheme = "Secp256k1" )
type SignatureSchemeSerialized ¶
type SignatureSchemeSerialized byte
const ( SignatureSchemeSerializedEd25519 SignatureSchemeSerialized = 0 SignatureSchemeSerializedSecp256k1 SignatureSchemeSerialized = 1 )
type SignedTransaction ¶
type SignedTransaction struct { // transaction data bytes TxBytes *Base64Data `json:"tx_bytes"` // Flag of the signature scheme that is used. SigScheme SignatureScheme `json:"sig_scheme"` // transaction signature Signature *Base64Data `json:"signature"` // signer's public key PublicKey *Base64Data `json:"pub_key"` }
SignedTransaction Deprecated: replace with SignedTransactionSerializedSig
type SignedTransactionSerializedSig ¶
type SignedTransactionSerializedSig struct { // transaction data bytes TxBytes *Base64Data `json:"tx_bytes"` // transaction signature Signature *Base64Data `json:"signature"` }
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 StakedSui ¶
type StakedSui struct { Id struct { Id ObjectId `json:"id"` } `json:"id"` ValidatorAddress Address `json:"validator_address"` PoolStartingEpoch uint64 `json:"pool_starting_epoch"` DelegationRequestEpoch uint64 `json:"delegation_request_epoch"` Principal Balance `json:"principal"` SuiTokenLock int `json:"sui_token_lock,omitempty"` }
type StakingPool ¶
type StakingPool struct { ValidatorAddress Address `json:"validator_address"` StartingEpoch uint64 `json:"starting_epoch"` SuiBalance uint64 `json:"sui_balance"` RewardsPool Balance `json:"rewards_pool"` DelegationTokenSupply Supply `json:"delegation_token_supply"` PendingDelegations interface{} `json:"pending_delegations"` //: LinkedTable<ObjectID>, PendingWithdraws interface{} `json:"pending_withdraws"` //: TableVec, }
type SuiCoinBalance ¶
type SuiCoinMetadata ¶
type SuiSystemState ¶
type SuiSystemState struct { Info interface{} `json:"info"` //: UID Epoch uint64 `json:"epoch"` Validators ValidatorSet `json:"validators"` Treasury_cap Supply `json:"treasury_cap"` StorageFund Balance `json:"storage_fund"` Parameters interface{} `json:"parameters"` //: SystemParameters, ReferenceGasPrice uint64 `json:"reference_gas_price"` ValidatorReportRecords interface{} `json:"validator_report_records"` //: VecMap<SuiAddress, VecSet<SuiAddress>>, StakeSubsidy interface{} `json:"stake_subsidy"` //: StakeSubsidy, SafeMode bool `json:"safe_mode"` EpochStartTimestampMs uint64 `json:"epoch_start_timestamp_ms"` }
type TransactionBytes ¶
type TransactionBytes struct { // the gas object to be used Gas ObjectRef `json:"gas"` // objects to be used in this transaction InputObjects []InputObjectKind `json:"inputObjects"` // transaction data bytes TxBytes Base64Data `json:"txBytes"` }
func (*TransactionBytes) SignSerializedSigWith ¶
func (txn *TransactionBytes) SignSerializedSigWith(privateKey ed25519.PrivateKey) *SignedTransactionSerializedSig
func (*TransactionBytes) SignWith ¶
func (txn *TransactionBytes) SignWith(privateKey ed25519.PrivateKey) *SignedTransaction
SignWith Deprecated: replace with SignSerializedSigWith
type TransactionEffects ¶
type TransactionEffects struct { Status TransactionStatus `json:"status"` TransactionDigest string `json:"transactionDigest"` GasUsed *GasCostSummary `json:"gasUsed"` GasObject *OwnedObjectRef `json:"gasObject"` Events []Event `json:"events,omitempty"` Dependencies []string `json:"dependencies,omitempty"` // SharedObjects []ObjectRef `json:"sharedObjects"` Created []OwnedObjectRef `json:"created,omitempty"` Mutated []OwnedObjectRef `json:"mutated,omitempty"` Unwrapped []OwnedObjectRef `json:"unwrapped,omitempty"` Deleted []ObjectRef `json:"deleted,omitempty"` Wrapped []ObjectRef `json:"wrapped,omitempty"` }
func (*TransactionEffects) GasFee ¶
func (te *TransactionEffects) GasFee() uint64
type TransactionQuery ¶
type TransactionQuery struct { All *string `json:"All"` /// Query by move function. MoveFunction *MoveFunction `json:"MoveFunction"` /// Query by input object. InputObject *ObjectId `json:"InputObject"` /// Query by mutated object. MutatedObject *ObjectId `json:"MutatedObject"` /// Query by sender address. FromAddress *Address `json:"FromAddress"` /// Query by recipient address. ToAddress *Address `json:"ToAddress"` }
func (TransactionQuery) MarshalJSON ¶
func (t TransactionQuery) MarshalJSON() ([]byte, error)
type TransactionResponse ¶
type TransactionResponse struct { Certificate *CertifiedTransaction `json:"certificate"` Effects *TransactionEffects `json:"effects"` ParsedData ParsedTransactionResponse `json:"parsed_data,omitempty"` TimestampMs uint64 `json:"timestamp_ms,omitempty"` }
type TransactionStatus ¶
type TransactionsPage ¶
type TransferObject ¶
type TransferSui ¶
type Validator ¶
type Validator struct { Metadata ValidatorMetadata `json:"metadata"` VotingPower uint64 `json:"voting_power"` StakeAmount uint64 `json:"stake_amount"` PendingStake uint64 `json:"pending_stake"` PendingWithdraw uint64 `json:"pending_withdraw"` GasPrice uint64 `json:"gas_price"` DelegationStakingPool StakingPool `json:"delegation_staking_pool"` CommissionRate uint64 `json:"commission_rate"` }
func (*Validator) CalculateAPY ¶
type ValidatorMetadata ¶
type ValidatorMetadata struct { SuiAddress Address `json:"sui_address"` PubkeyBytes []byte `json:"pubkey_bytes"` NetworkPubkeyBytes []byte `json:"network_pubkey_bytes"` WorkerPubkeyBytes []byte `json:"worker_pubkey_bytes"` ProofOfPossessionBytes []byte `json:"proof_of_possession_bytes"` Name []byte `json:"name"` Description []byte `json:"description"` ImageUrl []byte `json:"image_url"` ProjectUrl []byte `json:"project_url"` NetAddress []byte `json:"net_address"` ConsensusAddress []byte `json:"consensus_address"` WorkerAddress []byte `json:"worker_address"` NextEpochStake uint64 `json:"next_epoch_stake"` NextEpochDelegation uint64 `json:"next_epoch_delegation"` NextEpochGasPrice uint64 `json:"next_epoch_gas_price"` NextEpochCommissionRate uint64 `json:"next_epoch_commission_rate"` }
type ValidatorSet ¶
type ValidatorSet struct { ValidatorStake uint64 `json:"validator_stake"` DelegationStake uint64 `json:"delegation_stake"` ActiveValidators []Validator `json:"active_validators"` PendingValidators []Validator `json:"pending_validators"` PendingRemovals []uint64 `json:"pending_removals"` NextEpochValidators []ValidatorMetadata `json:"next_epoch_validators"` PendingDelegationSwitches interface{} `json:"pending_delegation_switches"` //: VecMap<ValidatorPair, TableVec>, }