Documentation
¶
Index ¶
- Constants
- Variables
- func GetAddressFromPublicKey(pubKey []byte) (string, error)
- func SerializeSuiSignature(signature, pubKey []byte) string
- type EventData
- type EventFilterByMoveEventModule
- type EventId
- type EventSelector
- type FunctionReadResponse
- type MoveCallRequest
- type PTBClient
- func (c *PTBClient) BlockByDigest(ctx context.Context, txDigest string) (*SuiTransactionBlockResponse, error)
- func (c *PTBClient) EstimateGas(ctx context.Context, txBytes string) (uint64, error)
- func (c *PTBClient) FinishPTBAndSend(ctx context.Context, txnSigner *signer.Signer, tx *transaction.Transaction, ...) (SuiTransactionBlockResponse, error)
- func (c *PTBClient) GetBlockById(ctx context.Context, checkpointId string) (models.CheckpointResponse, error)
- func (c *PTBClient) GetCCIPPackageID(ctx context.Context, offRampPackageID string, signerAddress string) (string, error)
- func (c *PTBClient) GetCache() *cache.Cache
- func (c *PTBClient) GetCachedValue(key string) (any, bool)
- func (c *PTBClient) GetCachedValues(keys []string) (map[string]any, bool)
- func (c *PTBClient) GetClient() sui.ISuiAPI
- func (c *PTBClient) GetCoinsByAddress(ctx context.Context, address string) ([]models.CoinData, error)
- func (c *PTBClient) GetLatestEpoch(ctx context.Context) (string, error)
- func (c *PTBClient) GetLatestPackageId(ctx context.Context, packageId string, module string) (string, error)
- func (c *PTBClient) GetNormalizedModule(ctx context.Context, packageId string, module string) (models.GetNormalizedMoveModuleResponse, error)
- func (c *PTBClient) GetParentObjectID(ctx context.Context, packageID string, moduleID string, ...) (string, error)
- func (c *PTBClient) GetReferenceGasPrice(ctx context.Context) (*big.Int, error)
- func (c *PTBClient) GetSUIBalance(ctx context.Context, address string) (*big.Int, error)
- func (c *PTBClient) GetTokenPoolConfigByPackageAddress(ctx context.Context, accountAddress string, tokenPoolAddress string, ...) (module_token_admin_registry.TokenConfig, error)
- func (c *PTBClient) GetTransactionPaymentCoinForAddress(ctx context.Context, payer string) (models.SuiAddressBytes, uint64, models.ObjectDigestBytes, error)
- func (c *PTBClient) GetTransactionStatus(ctx context.Context, digest string) (TransactionResult, error)
- func (c *PTBClient) GetValuesFromPackageOwnedObjectField(ctx context.Context, packageID string, moduleID string, objectName string, ...) (map[string]string, error)
- func (c *PTBClient) HashTxBytes(txBytes []byte) []byte
- func (c *PTBClient) LoadModulePackageIds(ctx context.Context, packageId string, module string) ([]string, error)
- func (c *PTBClient) MoveCall(ctx context.Context, req MoveCallRequest) (TxnMetaData, error)
- func (c *PTBClient) PayAllSui(ctx context.Context, toAddress string, coinObjectRefs []string, signer string) error
- func (c *PTBClient) QueryCoinsByAddress(ctx context.Context, address string, coinType string) ([]models.CoinData, error)
- func (c *PTBClient) QueryEvents(ctx context.Context, filter EventFilterByMoveEventModule, limit *uint, ...) (*models.PaginatedEventsResponse, error)
- func (c *PTBClient) QueryTransactions(ctx context.Context, fromAddress string, cursor *string, limit *uint64) (models.SuiXQueryTransactionBlocksResponse, error)
- func (c *PTBClient) ReadFilterOwnedObjectIds(ctx context.Context, ownerAddress string, structType string, cursor string) ([]models.SuiObjectData, error)
- func (c *PTBClient) ReadFunction(ctx context.Context, signerAddress string, packageId string, module string, ...) ([]any, error)
- func (c *PTBClient) ReadObjectId(ctx context.Context, objectId string) (models.SuiObjectData, error)
- func (c *PTBClient) ReadOwnedObjects(ctx context.Context, ownerAddress string, cursor *models.ObjectId) ([]models.SuiObjectResponse, error)
- func (c *PTBClient) SendTransaction(ctx context.Context, payload TransactionBlockRequest) (SuiTransactionBlockResponse, error)
- func (c *PTBClient) SetCachedValue(key string, value any)
- func (c *PTBClient) SetCachedValues(keyValues map[string]any)
- func (c *PTBClient) SignAndSendTransaction(ctx context.Context, txBytesRaw string, signerPublicKey []byte, ...) (SuiTransactionBlockResponse, error)
- func (c *PTBClient) TransformTransactionArg(ctx context.Context, tx *transaction.Transaction, arg any, argType string, ...) (*transaction.Argument, error)
- func (c *PTBClient) WithRateLimit(ctx context.Context, methodName string, f func(ctx context.Context) error) error
- type PaginatedEventsResponse
- type QuerySortOptions
- type SigFlag
- type SuiExecutionStatus
- type SuiPTBClient
- type SuiTransactionBlockResponse
- type TransactionBlockOptions
- type TransactionBlockRequest
- type TransactionRequestType
- type TransactionResult
- type TxnMetaData
Constants ¶
Variables ¶
var RateLimitWeights = map[string]int64{
"MoveCall": 1,
"SendTransaction": 1,
"ReadFunction": 1,
"SignAndSendTransaction": 1,
"QueryEvents": 1,
"QueryTransactions": 1,
"GetCoinsByAddress": 1,
"QueryCoinsByAddress": 1,
"EstimateGas": 1,
"GetTransactionStatus": 1,
"GetBlockById": 1,
"GetNormalizedModule": 1,
"GetSUIBalance": 1,
"GetValuesFromPackageOwnedObjectField": 1,
"GetReferenceGasPrice": 1,
"FinishPTBAndSend": 1,
"BlockByDigest": 1,
"ReadFilterOwnedObjectIds": 0,
"ReadOwnedObjects": 0,
"ReadObjectId": 0,
"GetLatestPackageId": 0,
"LoadModulePackageIds": 0,
"GetParentObjectID": 0,
"GetCCIPPackageID": 0,
"GetTokenPoolConfigByPackageAddress": 0,
"GetLatestEpoch": 0,
}
Functions ¶
func GetAddressFromPublicKey ¶
func SerializeSuiSignature ¶
SerializeSuiSignature formats and serializes a signature for use with Sui transactions.
This function follows the Sui transaction signature format specification: 1. A one-byte flag indicating the signature scheme (0x00 for Ed25519) 2. The raw signature bytes 3. The public key bytes These components are concatenated and then base64 encoded to produce the final signature string that can be submitted to the Sui network.
Based on the implementation from block-vision's sui-go-sdk: https://github.com/block-vision/sui-go-sdk/blob/main/models/signature.go#L140
Parameters:
signature - The raw signature bytes from the ed25519 Sign operation pubKey - The public key corresponding to the private key that produced the signature
Returns:
A base64-encoded string containing the serialized signature ready for submission to Sui
Types ¶
type EventData ¶
type EventData struct {
Id struct {
TxDigest string `json:"txDigest"`
EventSeq string `json:"eventSeq"`
} `json:"id"`
PackageId string `json:"packageId"`
TransactionModule string `json:"transactionModule"`
Sender string `json:"sender"`
Type struct {
Address string `json:"address"`
Module string `json:"module"`
Name string `json:"name"`
} `json:"type"`
ParsedJson any `json:"parsedJson"`
Bcs string `json:"bcs"`
TimestampMs string `json:"timestampMs"`
}
type EventSelector ¶
type EventSelector = EventFilterByMoveEventModule
EventSelector is an alias for EventFilterByMoveEventModule
type FunctionReadResponse ¶
type FunctionReadResponse struct {
ReturnValues []any `json:"returnValues"`
}
type MoveCallRequest ¶
type MoveCallRequest struct {
// the transaction signer's Sui address
Signer string `json:"signer"`
// the package containing the module and function
PackageObjectId string `json:"packageObjectId"`
// the specific module in the package containing the function
Module string `json:"module"`
// the function to be called
Function string `json:"function"`
// the type arguments to the function
TypeArguments []any `json:"typeArguments"`
// the arguments to the function
Arguments []any `json:"arguments"`
// gas object to be used in this transaction, node will pick one from the signer's possession if not provided
Gas uint64 `json:"gas"`
// the gas budget, the transaction will fail if the gas cost exceed the budget
GasBudget uint64 `json:"gasBudget"`
}
type PTBClient ¶
type PTBClient struct {
// contains filtered or unexported fields
}
PTBClient implements SuiClient interface using the blockvision SDK
func NewPTBClient ¶
func (*PTBClient) BlockByDigest ¶
func (*PTBClient) EstimateGas ¶
func (*PTBClient) FinishPTBAndSend ¶
func (c *PTBClient) FinishPTBAndSend(ctx context.Context, txnSigner *signer.Signer, tx *transaction.Transaction, requestType TransactionRequestType) (SuiTransactionBlockResponse, error)
FinishPTBAndSend finishes the PTB transaction and sends it to the network. IMPORTANT: This method is only used for testing purposes.
func (*PTBClient) GetBlockById ¶
func (c *PTBClient) GetBlockById(ctx context.Context, checkpointId string) (models.CheckpointResponse, error)
GetBlockById (i.e. get checkpoint by id) returns the checkpoint details given its ID
func (*PTBClient) GetCCIPPackageID ¶
func (c *PTBClient) GetCCIPPackageID(ctx context.Context, offRampPackageID string, signerAddress string) (string, error)
GetCCIPPackageId gets the CCIP package ID from the offramp package ID. IMPORTANT: This function expects to call the original (un-upgraded / first version) offramp package ID.
func (*PTBClient) GetCachedValues ¶
func (*PTBClient) GetCoinsByAddress ¶
func (*PTBClient) GetLatestEpoch ¶
func (*PTBClient) GetLatestPackageId ¶
func (*PTBClient) GetNormalizedModule ¶
func (*PTBClient) GetParentObjectID ¶
func (c *PTBClient) GetParentObjectID(ctx context.Context, packageID string, moduleID string, pointerObjectName string) (string, error)
GetParentObjectID gets the parent object ID from a pointer object's field. With derived objects, pointers now store a reference to the parent "Object" struct (e.g., OffRampObject, CCIPObject). e.g. OffRampStatePointer contains "off_ramp_object_id" field pointing to OffRampObject.
func (*PTBClient) GetReferenceGasPrice ¶
func (*PTBClient) GetSUIBalance ¶
func (*PTBClient) GetTokenPoolConfigByPackageAddress ¶
func (c *PTBClient) GetTokenPoolConfigByPackageAddress(ctx context.Context, accountAddress string, tokenPoolAddress string, ccipPackageAddress string) (module_token_admin_registry.TokenConfig, error)
A helper to abstract away having to provide the generic type of a token pool state. Requires a CCIP / StateObject package binding.
func (*PTBClient) GetTransactionPaymentCoinForAddress ¶
func (c *PTBClient) GetTransactionPaymentCoinForAddress(ctx context.Context, payer string) (models.SuiAddressBytes, uint64, models.ObjectDigestBytes, error)
func (*PTBClient) GetTransactionStatus ¶
func (*PTBClient) GetValuesFromPackageOwnedObjectField ¶
func (c *PTBClient) GetValuesFromPackageOwnedObjectField(ctx context.Context, packageID string, moduleID string, objectName string, fieldKeys []string) (map[string]string, error)
GetValueFromPackageOwnedObjectField gets the value of a field from a package owned object. This is used to get addresses stored within pointer objects on-chain. For example, the state object ID of a package is stored in the pointer object, so we need to get the value of the pointer object's field to get the state object ID.
func (*PTBClient) HashTxBytes ¶
HashTxBytes is a helper method to hash (Blake2) the transaction bytes before signing
func (*PTBClient) LoadModulePackageIds ¶
func (c *PTBClient) LoadModulePackageIds(ctx context.Context, packageId string, module string) ([]string, error)
LoadModulePackages returns the set of package IDs for a given module using its original package ID This method assumes that module names are unique across all packages
func (*PTBClient) MoveCall ¶
func (c *PTBClient) MoveCall(ctx context.Context, req MoveCallRequest) (TxnMetaData, error)
func (*PTBClient) QueryCoinsByAddress ¶
func (*PTBClient) QueryEvents ¶
func (c *PTBClient) QueryEvents(ctx context.Context, filter EventFilterByMoveEventModule, limit *uint, cursor *EventId, sortOptions *QuerySortOptions) (*models.PaginatedEventsResponse, error)
func (*PTBClient) QueryTransactions ¶
func (*PTBClient) ReadFilterOwnedObjectIds ¶
func (*PTBClient) ReadFunction ¶
func (*PTBClient) ReadObjectId ¶
func (*PTBClient) ReadOwnedObjects ¶
func (*PTBClient) SendTransaction ¶
func (c *PTBClient) SendTransaction(ctx context.Context, payload TransactionBlockRequest) (SuiTransactionBlockResponse, error)
func (*PTBClient) SetCachedValue ¶
func (*PTBClient) SetCachedValues ¶
func (*PTBClient) SignAndSendTransaction ¶
func (c *PTBClient) SignAndSendTransaction(ctx context.Context, txBytesRaw string, signerPublicKey []byte, executionRequestType TransactionRequestType) (SuiTransactionBlockResponse, error)
func (*PTBClient) TransformTransactionArg ¶
func (c *PTBClient) TransformTransactionArg( ctx context.Context, tx *transaction.Transaction, arg any, argType string, mutable bool, ) (*transaction.Argument, error)
type PaginatedEventsResponse ¶
type QuerySortOptions ¶
type QuerySortOptions struct {
Descending bool `json:"descending"`
}
type SuiExecutionStatus ¶
type SuiPTBClient ¶
type SuiPTBClient interface {
MoveCall(ctx context.Context, req MoveCallRequest) (TxnMetaData, error)
SendTransaction(ctx context.Context, payload TransactionBlockRequest) (SuiTransactionBlockResponse, error)
ReadOwnedObjects(ctx context.Context, ownerAddress string, cursor *models.ObjectId) ([]models.SuiObjectResponse, error)
ReadFilterOwnedObjectIds(ctx context.Context, ownerAddress string, structType string, cursor string) ([]models.SuiObjectData, error)
ReadObjectId(ctx context.Context, objectId string) (models.SuiObjectData, error)
ReadFunction(ctx context.Context, signerAddress string, packageId string, module string, function string, args []any, argTypes []string, typeArgs []string) ([]any, error)
SignAndSendTransaction(ctx context.Context, txBytesRaw string, signerPublicKey []byte, executionRequestType TransactionRequestType) (SuiTransactionBlockResponse, error)
QueryEvents(ctx context.Context, filter EventFilterByMoveEventModule, limit *uint, cursor *EventId, sortOptions *QuerySortOptions) (*models.PaginatedEventsResponse, error)
QueryTransactions(ctx context.Context, fromAddress string, cursor *string, limit *uint64) (models.SuiXQueryTransactionBlocksResponse, error)
GetTransactionStatus(ctx context.Context, digest string) (TransactionResult, error)
GetCoinsByAddress(ctx context.Context, address string) ([]models.CoinData, error)
QueryCoinsByAddress(ctx context.Context, address string, coinType string) ([]models.CoinData, error)
EstimateGas(ctx context.Context, txBytes string) (uint64, error)
GetReferenceGasPrice(ctx context.Context) (*big.Int, error)
FinishPTBAndSend(ctx context.Context, txnSigner *signer.Signer, tx *transaction.Transaction, requestType TransactionRequestType) (SuiTransactionBlockResponse, error)
BlockByDigest(ctx context.Context, txDigest string) (*SuiTransactionBlockResponse, error)
GetBlockById(ctx context.Context, checkpointId string) (models.CheckpointResponse, error)
GetLatestEpoch(ctx context.Context) (string, error)
GetNormalizedModule(ctx context.Context, packageId string, moduleId string) (models.GetNormalizedMoveModuleResponse, error)
GetSUIBalance(ctx context.Context, address string) (*big.Int, error)
LoadModulePackageIds(ctx context.Context, packageId string, module string) ([]string, error)
GetLatestPackageId(ctx context.Context, packageId string, module string) (string, error)
GetClient() sui.ISuiAPI
GetCache() *cache.Cache
GetCachedValue(key string) (any, bool)
SetCachedValue(key string, value any)
GetCachedValues(keys []string) (map[string]any, bool)
SetCachedValues(keyValues map[string]any)
HashTxBytes(txBytes []byte) []byte
GetCCIPPackageID(ctx context.Context, offRampPackageID string, signerAddress string) (string, error)
GetValuesFromPackageOwnedObjectField(ctx context.Context, packageID string, moduleID string, objectName string, fieldKeys []string) (map[string]string, error)
GetParentObjectID(ctx context.Context, packageID string, moduleID string, pointerObjectName string) (string, error)
GetTokenPoolConfigByPackageAddress(ctx context.Context, accountAddress string, tokenPoolAddress string, ccipPackageAddress string) (module_token_admin_registry.TokenConfig, error)
}
type SuiTransactionBlockResponse ¶
type SuiTransactionBlockResponse struct {
TxDigest string `json:"txDigest"`
Status SuiExecutionStatus `json:"status"`
Effects models.SuiEffects `json:"effects"`
Events []models.SuiEventResponse `json:"events,omitempty"`
Timestamp uint64 `json:"timestamp"`
Height uint64 `json:"height"`
ObjectChanges []models.ObjectChange `json:"objectChanges,omitempty"`
}
type TransactionBlockOptions ¶
type TransactionBlockOptions struct {
ShowInput bool `json:"showInput,omitempty"`
ShowRawInput bool `json:"showRawInput,omitempty"`
ShowEffects bool `json:"showEffects,omitempty"`
ShowEvents bool `json:"showEvents,omitempty"`
ShowObjectChanges bool `json:"showObjectChanges,omitempty"`
ShowBalanceChanges bool `json:"showBalanceChanges,omitempty"`
}
type TransactionBlockRequest ¶
type TransactionBlockRequest struct {
// BCS serialized transaction data bytes without its type tag, as base-64 encoded string.
TxBytes string `json:"txBytes"`
// A list of signatures (`flag || signature || pubkey` bytes, as base-64 encoded string).
// Signature is committed to the intent message of the transaction data, as base-64 encoded string.
Signatures []string `json:"signature"`
// Options for specifying the content to be returned
Options TransactionBlockOptions `json:"options"`
// The request type, derived from `SuiTransactionBlockResponseOptions` if None.
// The optional enumeration values are: `WaitForEffectsCert`, or `WaitForLocalExecution`
RequestType string `json:"requestType"`
}
TransactionBlockRequest represents the request the SuiExecuteTransactionBlock endpoint. https://docs.sui.io/sui-api-ref#sui_executetransactionblock
type TransactionRequestType ¶
type TransactionRequestType string
TransactionRequestType defines the possible request types for transaction execution
const ( WaitForEffectsCert TransactionRequestType = "WaitForEffectsCert" WaitForLocalExecution TransactionRequestType = "WaitForLocalExecution" )
type TransactionResult ¶
type TxnMetaData ¶
type TxnMetaData struct {
TxBytes string `json:"txBytes"`
}