Documentation ¶
Index ¶
- Constants
- Variables
- func AverageApyOfDelegatedStakes(stakes *base.AnyArray) float64
- func DecodeAddressToPublicKey(address string) (string, error)
- func EncodePublicKeyToAddress(publicKey string) (string, error)
- func FaucetFundAccount(address string, faucetUrl string) (h *base.OptionalString, err error)
- func IsMergeError(err error) bool
- func IsSplitError(err error) bool
- func IsValidAddress(address string) bool
- func NewDelegatedStakeArrayWithJsonString(str string) (*base.AnyArray, error)
- func TransformNFT(nft *types.SuiObjectResponse) *base.NFT
- type Account
- func (a *Account) Address() string
- func (a *Account) DecodeAddressToPublicKey(address string) (string, error)
- func (a *Account) EncodePublicKeyToAddress(publicKey string) (string, error)
- func (a *Account) IsValidAddress(address string) bool
- func (a *Account) PrivateKey() ([]byte, error)
- func (a *Account) PrivateKeyHex() (string, error)
- func (a *Account) PublicKey() []byte
- func (a *Account) PublicKeyHex() string
- func (a *Account) Sign(message []byte, password string) ([]byte, error)
- func (a *Account) SignHex(messageHex string, password string) (*base.OptionalString, error)
- type Chain
- func (c *Chain) AddDelegation(owner, amount string, validatorAddress string) (txn *Transaction, err error)
- func (c *Chain) BalanceOfAccount(account base.Account) (*base.Balance, error)
- func (c *Chain) BalanceOfAddress(address string) (b *base.Balance, err error)
- func (c *Chain) BalanceOfPublicKey(publicKey string) (*base.Balance, error)
- func (c *Chain) BaseMoveCall(address, packageId, module, funcName string, typArgs []string, arg []any, ...) (txn *Transaction, err error)
- func (c *Chain) BatchFetchTransactionStatus(hashListString string) string
- func (c *Chain) BuildMergeCoinPreview(request *MergeCoinRequest) (preview *MergeCoinPreview, err error)
- func (c *Chain) BuildMergeCoinRequest(owner, coinType, targetAmount string) (req *MergeCoinRequest, err error)
- func (c *Chain) BuildSplitCoinTransaction(owner, coinType, targetAmount string) (txn *Transaction, err error)
- func (c *Chain) CachedGasPrice() (price uint64, err error)
- func (c *Chain) Client() (*client.Client, error)
- func (c *Chain) EstimateTransactionFee(transaction base.Transaction) (fee *base.OptionalString, err error)
- func (c *Chain) EstimateTransactionFeeAndRebuildTransaction(maxGasBudget uint64, ...) (*Transaction, error)
- func (c *Chain) EstimateTransactionFeeAndRebuildTransactionBCS(maxGasBudget uint64, ...) (*Transaction, error)
- func (c *Chain) EstimateTransactionFeeUsePublicKey(transaction base.Transaction, pubkey string) (fee *base.OptionalString, err error)
- func (c *Chain) FetchNFTs(owner string) (res map[string][]*base.NFT, err error)
- func (c *Chain) FetchNFTsJsonString(owner string) (*base.OptionalString, error)
- func (c *Chain) FetchSuiCatGlobalData() (data *SuiCatGlobalData, err error)
- func (c *Chain) FetchTransactionDetail(hash string) (detail *base.TransactionDetail, err error)
- func (c *Chain) FetchTransactionStatus(hash string) base.TransactionStatus
- func (c *Chain) GasPrice() (gasprice *base.OptionalString, err error)
- func (c *Chain) GetDelegatedStakes(owner string) (arr *base.AnyArray, err error)
- func (c *Chain) GetValidator(address string, useCache bool) (v *Validator, err error)
- func (c *Chain) GetValidatorState() (s *ValidatorState, err error)
- func (c *Chain) MainToken() base.Token
- func (c *Chain) MintNFT(creator, name, description, uri string) (txn *Transaction, err error)
- func (c *Chain) MintSuiCatNFT(signer string, amount string) (txn *Transaction, err error)
- func (c *Chain) PickGasCoins(owner sui_types.SuiAddress, maxGasBudget uint64) (picked *types.PickedCoins, err error)
- func (c *Chain) QueryIsInSuiCatWhiteList(address string) (b *base.OptionalBool, err error)
- func (c *Chain) SendRawTransaction(signedTx string) (hash string, err error)
- func (c *Chain) SendSignedTransaction(signedTxn base.SignedTransaction) (hash *base.OptionalString, err error)
- func (c *Chain) TotalStakedSuiAtValidator(validator, owner string, useCache bool) (sui *base.OptionalString, err error)
- func (c *Chain) TransferNFT(sender, receiver, nftId string) (txn *Transaction, err error)
- func (c *Chain) TransferObject(sender, receiver, objectId string, gasBudget int64) (txn *Transaction, err error)
- func (c *Chain) WithdrawDelegation(owner, stakeId string) (txn *Transaction, err error)
- type DelegatedStake
- func (o *DelegatedStake) AsAny() *base.Any
- func (s *DelegatedStake) EarningAmountTimeAfterNowMs(stateInfo *ValidatorState) int64
- func (s *DelegatedStake) EarningAmountTimeAfterTimestampMs(timestamp int64, stateInfo *ValidatorState) int64
- func (s *DelegatedStake) JsonString() (*base.OptionalString, error)
- type DelegationStatus
- type MergeCoinPreview
- type MergeCoinRequest
- type RestReachability
- type SignedTransaction
- type SuiCatConfig
- type SuiCatGlobalData
- type Token
- func (t *Token) BalanceOfAccount(account base.Account) (*base.Balance, error)
- func (t *Token) BalanceOfAddress(address string) (b *base.Balance, err error)
- func (t *Token) BalanceOfPublicKey(publicKey string) (*base.Balance, error)
- func (t *Token) BuildTransfer(sender, receiver, amount string) (txn base.Transaction, err error)
- func (t *Token) BuildTransferAll(sender, receiver string) (txn base.Transaction, err error)
- func (t *Token) BuildTransferTransaction(account *Account, receiverAddress, amount string) (s *Transaction, err error)
- func (t *Token) BuildTransferTx(privateKey, receiverAddress, amount string) (*base.OptionalString, error)
- func (t *Token) BuildTransferTxWithAccount(account *Account, receiverAddress, amount string) (s *base.OptionalString, err error)
- func (t *Token) CanTransferAll() bool
- func (t *Token) Chain() base.Chain
- func (t *Token) CoinType() string
- func (t *Token) EstimateFees(account *Account, receiverAddress, amount string) (f *base.OptionalString, err error)
- func (t *Token) IsSUI() bool
- func (t *Token) TokenInfo() (info *base.TokenInfo, err error)
- type Transaction
- type Util
- type Validator
- type ValidatorState
Constants ¶
const ( MaxGasBudget = 90000000 MinGasBudget = 1100000 MaxGasForPay = 10000000 MaxGasForTransfer = 10000000 TestNetFaucetUrl = client.TestNetFaucetUrl DevNetFaucetUrl = client.DevNetFaucetUrl )
const ( SuiName = "Sui" SuiSymbol = "Sui" SuiDecimal = 0 )
const MAX_INPUT_COUNT_MERGE = types.MAX_INPUT_COUNT_MERGE
= 256-1
const MAX_INPUT_COUNT_STAKE = types.MAX_INPUT_COUNT_STAKE
= 512-1
const SUI_COIN_TYPE = types.SUI_COIN_TYPE
"0x2::sui::SUI"
const (
SuiCatFuncMint = "mint"
)
Variables ¶
var ( ErrNoCoinsFound = types.ErrNoCoinsFound ErrInsufficientBalance = types.ErrInsufficientBalance ErrNeedMergeCoin = types.ErrNeedMergeCoin ErrNeedSplitGasCoin = types.ErrNeedSplitGasCoin ErrNoNeedMergeCoin = errors.New("existing coins exceed the target amount, no need to merge coins") ErrMergeOneCoin = errors.New("only one coin does not need to merge coins") )
var SuiCatTestnetConfig = &SuiCatConfig{
PackageId: "0xc5b18811206c9ef35b516cd90f1736e7504f17fec147179298cc6851f2aa10a9",
GlobalId: "0x9876b64fad60ef76235f56c3221a4ee1aa891eaa3b86b10ed16195169c7c3e19",
ModuleName: "suicat",
}
Functions ¶
func EncodePublicKeyToAddress ¶
@param publicKey can start with 0x or not.
func FaucetFundAccount ¶
func FaucetFundAccount(address string, faucetUrl string) (h *base.OptionalString, err error)
*
- @param address Hex-encoded 16 bytes Sui account address wich mints tokens
- @param faucetUrl default https://faucet.testnet.sui.io/gas
- @return digest of the faucet transfer transaction.
func IsMergeError ¶
func IsSplitError ¶
func TransformNFT ¶
func TransformNFT(nft *types.SuiObjectResponse) *base.NFT
Types ¶
type Account ¶
type Account struct {
// contains filtered or unexported fields
}
func AccountWithPrivateKey ¶
rename for support android. Android cannot support both NewAccountWithMnemonic(string) and NewAccountWithPrivateKey(string)
func AsSuiAccount ¶
func NewAccountWithMnemonic ¶
func (*Account) DecodeAddressToPublicKey ¶
@return publicKey that will start with 0x.
func (*Account) EncodePublicKeyToAddress ¶
@param publicKey can start with 0x or not.
func (*Account) IsValidAddress ¶
func (*Account) PrivateKeyHex ¶
@return privateKey string that will start with 0x.
func (*Account) PublicKeyHex ¶
@return publicKey string that will start with 0x.
type Chain ¶
type Chain struct { RpcUrl string // contains filtered or unexported fields }
func NewChainWithRpcUrl ¶
func (*Chain) AddDelegation ¶
func (c *Chain) AddDelegation(owner, amount string, validatorAddress string) (txn *Transaction, err error)
func (*Chain) BalanceOfAccount ¶
func (*Chain) BalanceOfAddress ¶
func (*Chain) BalanceOfPublicKey ¶
func (*Chain) BaseMoveCall ¶
func (c *Chain) BaseMoveCall(address, packageId, module, funcName string, typArgs []string, arg []any, maxGasBudget uint64) (txn *Transaction, err error)
@param maxGasBudget Default `MinGasBudget` if is 0.
func (*Chain) BatchFetchTransactionStatus ¶
func (*Chain) BuildMergeCoinPreview ¶
func (c *Chain) BuildMergeCoinPreview(request *MergeCoinRequest) (preview *MergeCoinPreview, err error)
func (*Chain) BuildMergeCoinRequest ¶
func (c *Chain) BuildMergeCoinRequest(owner, coinType, targetAmount string) (req *MergeCoinRequest, err error)
@param coinType Default is `SUI_COIN_TYPE`
func (*Chain) BuildSplitCoinTransaction ¶
func (c *Chain) BuildSplitCoinTransaction(owner, coinType, targetAmount string) (txn *Transaction, err error)
@param coinType Default is `SUI_COIN_TYPE`
func (*Chain) CachedGasPrice ¶
func (*Chain) EstimateTransactionFee ¶
func (c *Chain) EstimateTransactionFee(transaction base.Transaction) (fee *base.OptionalString, err error)
func (*Chain) EstimateTransactionFeeAndRebuildTransaction ¶
func (c *Chain) EstimateTransactionFeeAndRebuildTransaction(maxGasBudget uint64, buildTransaction func(gasBudget uint64) (*Transaction, error)) (*Transaction, error)
@param maxGasBudget: the firstly build required gas @param builer: the builder should build a transaction, it maybe will invoking twice, the firstly build gas pass the maxGasBudget, the second build will pass the estimate gas.
func (*Chain) EstimateTransactionFeeAndRebuildTransactionBCS ¶
func (c *Chain) EstimateTransactionFeeAndRebuildTransactionBCS(maxGasBudget uint64, buildTransaction func(gasBudget uint64) (*Transaction, error)) (*Transaction, error)
func (*Chain) EstimateTransactionFeeUsePublicKey ¶
func (c *Chain) EstimateTransactionFeeUsePublicKey(transaction base.Transaction, pubkey string) (fee *base.OptionalString, err error)
func (*Chain) FetchNFTsJsonString ¶
func (c *Chain) FetchNFTsJsonString(owner string) (*base.OptionalString, error)
func (*Chain) FetchSuiCatGlobalData ¶
func (c *Chain) FetchSuiCatGlobalData() (data *SuiCatGlobalData, err error)
func (*Chain) FetchTransactionDetail ¶
func (c *Chain) FetchTransactionDetail(hash string) (detail *base.TransactionDetail, err error)
Fetch transaction details through transaction hash
func (*Chain) FetchTransactionStatus ¶
func (c *Chain) FetchTransactionStatus(hash string) base.TransactionStatus
func (*Chain) GetDelegatedStakes ¶
@return Array of `DelegatedStake` elements
func (*Chain) GetValidator ¶
func (*Chain) GetValidatorState ¶
func (c *Chain) GetValidatorState() (s *ValidatorState, err error)
func (*Chain) MintNFT ¶
func (c *Chain) MintNFT(creator, name, description, uri string) (txn *Transaction, err error)
func (*Chain) MintSuiCatNFT ¶
func (c *Chain) MintSuiCatNFT(signer string, amount string) (txn *Transaction, err error)
func (*Chain) PickGasCoins ¶
func (c *Chain) PickGasCoins(owner sui_types.SuiAddress, maxGasBudget uint64) (picked *types.PickedCoins, err error)
func (*Chain) QueryIsInSuiCatWhiteList ¶
func (c *Chain) QueryIsInSuiCatWhiteList(address string) (b *base.OptionalBool, err error)
func (*Chain) SendRawTransaction ¶
Send the raw transaction on-chain @return the hex hash string
func (*Chain) SendSignedTransaction ¶
func (c *Chain) SendSignedTransaction(signedTxn base.SignedTransaction) (hash *base.OptionalString, err error)
func (*Chain) TotalStakedSuiAtValidator ¶
func (c *Chain) TotalStakedSuiAtValidator(validator, owner string, useCache bool) (sui *base.OptionalString, err error)
@useCache If true, when there is cached data, the result will be returned directly without requesting data on the chain.
func (*Chain) TransferNFT ¶
func (c *Chain) TransferNFT(sender, receiver, nftId string) (txn *Transaction, err error)
Just encapsulation and callbacks to method `TransferObject`. @param gasId gas object to be used in this transaction, the gateway will pick one from the signer's possession if not provided
func (*Chain) TransferObject ¶
func (c *Chain) TransferObject(sender, receiver, objectId string, gasBudget int64) (txn *Transaction, err error)
func (*Chain) WithdrawDelegation ¶
func (c *Chain) WithdrawDelegation(owner, stakeId string) (txn *Transaction, err error)
type DelegatedStake ¶
type DelegatedStake struct { StakeId string `json:"stakeId"` ValidatorAddress string `json:"validatorAddress"` Principal string `json:"principal"` RequestEpoch int64 `json:"requestEpoch"` Status DelegationStatus `json:"status"` DelegationId string `json:"delegationId"` EarnedAmount string `json:"earnedAmount"` Validator *Validator `json:"validator"` }
func AsDelegatedStake ¶
func AsDelegatedStake(a *base.Any) *DelegatedStake
func NewDelegatedStake ¶
func NewDelegatedStake() *DelegatedStake
func NewDelegatedStakeWithJsonString ¶
func NewDelegatedStakeWithJsonString(str string) (*DelegatedStake, error)
func (*DelegatedStake) AsAny ¶
func (o *DelegatedStake) AsAny() *base.Any
func (*DelegatedStake) EarningAmountTimeAfterNowMs ¶
func (s *DelegatedStake) EarningAmountTimeAfterNowMs(stateInfo *ValidatorState) int64
@return if time > 0 indicates how long it will take to get the reward; if time < 0 indicates how much time has passed since the reward was earned;
func (*DelegatedStake) EarningAmountTimeAfterTimestampMs ¶
func (s *DelegatedStake) EarningAmountTimeAfterTimestampMs(timestamp int64, stateInfo *ValidatorState) int64
func (*DelegatedStake) JsonString ¶
func (s *DelegatedStake) JsonString() (*base.OptionalString, error)
type DelegationStatus ¶
type DelegationStatus = base.SDKEnumInt
const ( DelegationStatusPending DelegationStatus = 0 DelegationStatusActived DelegationStatus = 1 )
type MergeCoinPreview ¶
type MergeCoinPreview struct { // The original request Request *MergeCoinRequest // The merge coins transaction Transaction *Transaction // Did the simulated transaction execute successfully? SimulateSuccess bool EstimateGasFee int64 // If the transaction is executed, owner will receive a coin amount that is not less than this. EstimateAmount string // Due to the results obtained through simulated execution, we may know that the balance may increase and the value of this state may be inconsistent with the value in the request. WillBeAchieved bool }
type MergeCoinRequest ¶
type MergeCoinRequest struct { Owner string CoinType string TargetAmount string // queried coins Coins types.PickedCoins CoinsCount int // If the transaction is executed, owner will receive a coin amount that is not less than this. EstimateAmount string // Will the goal of merging coins of a specified amount be achieved? WillBeAchieved bool }
type RestReachability ¶
type RestReachability struct { }
func NewRestReachability ¶
func NewRestReachability() *RestReachability
func (*RestReachability) LatencyOf ¶
func (r *RestReachability) LatencyOf(rpc string, timeout int64) (l *base.RpcLatency, err error)
@return latency (ms) of rpc query blockNumber. -1 means the connection failed.
type SignedTransaction ¶
type SignedTransaction struct { // transaction data bytes TxBytes *lib.Base64Data `json:"tx_bytes"` // transaction signature Signature *sui_types.Signature `json:"signature"` }
func AsSignedTransaction ¶
func AsSignedTransaction(txn base.SignedTransaction) *SignedTransaction
func (*SignedTransaction) HexString ¶
func (txn *SignedTransaction) HexString() (res *base.OptionalString, err error)
type SuiCatConfig ¶
type SuiCatGlobalData ¶
type SuiCatGlobalData struct { TotalMinted int64 `json:"total_minted"` Supply int64 `json:"supply"` PricePublic string `json:"price_public"` PriceWhitelist string `json:"price_whitelist"` StartTimeMs int64 `json:"start_time"` DurationMs int64 `json:"duration"` }
func NewSuiCatGlobalDataWithJsonString ¶
func NewSuiCatGlobalDataWithJsonString(str string) (*SuiCatGlobalData, error)
func (*SuiCatGlobalData) JsonString ¶
func (j *SuiCatGlobalData) JsonString() (*base.OptionalString, error)
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
func NewTokenMain ¶
func (*Token) BalanceOfAccount ¶
func (*Token) BalanceOfAddress ¶
func (*Token) BalanceOfPublicKey ¶
func (*Token) BuildTransfer ¶
func (t *Token) BuildTransfer(sender, receiver, amount string) (txn base.Transaction, err error)
func (*Token) BuildTransferAll ¶
func (t *Token) BuildTransferAll(sender, receiver string) (txn base.Transaction, err error)
Before invoking this method, it is best to check `CanTransferAll()`
func (*Token) BuildTransferTransaction ¶
func (t *Token) BuildTransferTransaction(account *Account, receiverAddress, amount string) (s *Transaction, err error)
func (*Token) BuildTransferTx ¶
func (t *Token) BuildTransferTx(privateKey, receiverAddress, amount string) (*base.OptionalString, error)
func (*Token) BuildTransferTxWithAccount ¶
func (*Token) CanTransferAll ¶
func (*Token) EstimateFees ¶
type Transaction ¶
type Transaction struct { Txn types.TransactionBytes TxnBytes lib.Base64Data EstimateGasFee int64 }
func (*Transaction) SignWithAccount ¶
func (t *Transaction) SignWithAccount(account base.Account) (signedTx *base.OptionalString, err error)
func (*Transaction) SignedTransactionWithAccount ¶
func (t *Transaction) SignedTransactionWithAccount(account base.Account) (signedTx base.SignedTransaction, err error)
func (*Transaction) TransactionBytes ¶
func (t *Transaction) TransactionBytes() []byte
type Util ¶
type Util struct { }
func (*Util) DecodeAddressToPublicKey ¶
Warning: Sui cannot support decode address to public key
func (*Util) EncodePublicKeyToAddress ¶
@param publicKey can start with 0x or not.
func (*Util) IsValidAddress ¶
type Validator ¶
type Validator struct { Address string `json:"address"` Name string `json:"name"` Desc string `json:"desc"` ImageUrl string `json:"imageUrl"` ProjectUrl string `json:"projectUrl"` APY float64 `json:"apy"` Commission int64 `json:"commission"` TotalStaked string `json:"totalStaked"` DelegatedStaked string `json:"delegatedStaked"` SelfStaked string `json:"selfStaked"` TotalRewards string `json:"totalRewards"` GasPrice int64 `json:"gasPrice"` }
func AsValidator ¶
func NewValidator ¶
func NewValidator() *Validator
func (*Validator) JsonString ¶
func (s *Validator) JsonString() (*base.OptionalString, error)
type ValidatorState ¶
type ValidatorState struct { // The current epoch in Sui. An epoch takes approximately 24 hours and runs in checkpoints. Epoch int64 `json:"epoch"` // Array of `Validator` elements Validators *base.AnyArray `json:"validators"` // The amount of all tokens staked in the Sui Network. TotalStaked string `json:"totalStaked"` // The amount of rewards won by all Sui validators in the last epoch. TotalRewards string `json:"lastEpochReward"` EpochStartTimestampMs int64 `json:"epochStartTimestampMs"` EpochDurationMs int64 `json:"epochDurationMs"` }
func NewValidatorState ¶
func NewValidatorState() *ValidatorState
func NewValidatorStateWithJsonString ¶
func NewValidatorStateWithJsonString(str string) (*ValidatorState, error)
func (*ValidatorState) EarningAmountTimeAfterNowMs ¶
func (s *ValidatorState) EarningAmountTimeAfterNowMs() int64
@return if time > 0 indicates how long it will take to get the reward; if time < 0 indicates how much time has passed since the reward was earned;
func (*ValidatorState) EarningAmountTimeAfterTimestampMs ¶
func (s *ValidatorState) EarningAmountTimeAfterTimestampMs(timestamp int64) int64
func (*ValidatorState) JsonString ¶
func (s *ValidatorState) JsonString() (*base.OptionalString, error)