sui

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CallArgPure   = "pure"
	CallArgObject = "object"
)

Variables

View Source
var (
	MethodClaimFee             = "claim_fees"
	MethodGetReceipt           = "get_receipt"
	MethodSetFee               = "set_fee"
	MethodGetFee               = "get_fee"
	MethodRevertMessage        = "revert_message"
	MethodSetAdmin             = "set_admin"
	MethodGetAdmin             = "get_admin"
	MethodRecvMessage          = "receive_message"
	MethodExecuteCall          = "execute_call"
	MethodExecuteRollback      = "execute_rollback"
	MethodGetWithdrawTokentype = "get_withdraw_token_type"

	ModuleConnection = "centralized_connection"
	ModuleEntry      = "centralized_entry"
	ModuleMain       = "main"
	XcallModule      = "xcall"

	ModuleMockDapp       = "mock_dapp"
	ModuleXcallManager   = "xcall_manager"
	ModuleAssetManager   = "asset_manager"
	ModuleBalancedDollar = "balanced_dollar_crosschain"
)

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(rpcClient *suisdkClient.Client, l *zap.Logger) *Client

func (*Client) ExecuteTx

func (cl *Client) ExecuteTx(ctx context.Context, wallet *account.Account, txBytes lib.Base64Data, signatures []any) (*types.SuiTransactionBlockResponse, error)

func (*Client) GetCheckpoint

func (c *Client) GetCheckpoint(ctx context.Context, checkpoint uint64) (*suitypes.CheckpointResponse, error)

func (Client) GetCoins

func (c Client) GetCoins(ctx context.Context, addr string) (types.Coins, error)

func (*Client) GetEvents

func (c *Client) GetEvents(
	ctx context.Context,
	txDigest sui_types.TransactionDigest,
) ([]types.SuiEvent, error)

func (*Client) GetEventsFromTxBlocks

func (c *Client) GetEventsFromTxBlocks(ctx context.Context, allowedEventTypes []string, digests []string) ([]suitypes.EventResponse, error)

func (Client) GetLatestCheckpointSeq

func (c Client) GetLatestCheckpointSeq(ctx context.Context) (uint64, error)

func (Client) GetObject

func (*Client) GetTotalBalance

func (c *Client) GetTotalBalance(ctx context.Context, addr string) (uint64, error)

func (*Client) GetTransaction

func (cl *Client) GetTransaction(ctx context.Context, txDigest string) (*types.SuiTransactionBlockResponse, error)

func (Client) MoveCall

func (c Client) MoveCall(
	ctx context.Context,
	signer move_types.AccountAddress,
	packageId move_types.AccountAddress,
	module, function string,
	typeArgs []string,
	arguments []any,
	gas *move_types.AccountAddress,
	gasBudget types.SafeSuiBigInt[uint64],
) (*types.TransactionBytes, error)

func (*Client) MultiGetTxBlocks

func (c *Client) MultiGetTxBlocks(ctx context.Context, digests []string) ([]*types.SuiTransactionBlockResponse, error)

func (*Client) QueryContract

func (cl *Client) QueryContract(ctx context.Context, senderAddr string, txBytes lib.Base64Data, resPtr interface{}) error

func (*Client) QueryTxBlocks

func (c *Client) QueryTxBlocks(
	ctx context.Context,
	query types.SuiTransactionBlockResponseQuery,
	cursor *sui_types.TransactionDigest,
	limit *uint,
	descendingOrder bool,
) (*types.TransactionBlocksPage, error)

func (*Client) SimulateTx

type Config

type Config struct {
	ChainName string `yaml:"-" json:"-"`
	ChainID   string `yaml:"chain-id" json:"chain-id"`
	RPCUrl    string `yaml:"rpc-url" json:"rpc-url"`
	Address   string `yaml:"address" json:"address"`
	NID       string `yaml:"nid" json:"nid"`

	// list of xcall package ids in order of latest to oldest in descending order
	XcallPkgIDs    []string `yaml:"xcall-package-ids" json:"xcall-package-ids"`
	XcallStorageID string   `yaml:"xcall-storage-id" json:"xcall-storage-id"`

	ConnectionID    string `yaml:"connection-id" json:"connection-id"`
	ConnectionCapID string `yaml:"connection-cap-id" json:"connection-cap-id"`

	DappPkgID   string       `yaml:"dapp-package-id" json:"dapp-package-id"`
	DappModules []DappModule `yaml:"dapp-modules" json:"dapp-modules"`

	HomeDir  string `yaml:"home-dir" json:"home-dir"`
	GasLimit uint64 `yaml:"gas-limit" json:"gas-limit"`
	Disabled bool   `json:"disabled" yaml:"disabled"`

	// Start tx-digest cursor to begin querying for events.
	// Should be empty if we want to query using last saved tx-digest
	// from database.
	StartTxDigest string `json:"start-tx-digest" yaml:"start-tx-digest"`
}

func (*Config) Enabled

func (c *Config) Enabled() bool

Enabled returns true if the chain is enabled

func (*Config) GetWallet

func (pc *Config) GetWallet() string

func (*Config) NewProvider

func (pc *Config) NewProvider(ctx context.Context, logger *zap.Logger, homePath string, debug bool, chainName string) (provider.ChainProvider, error)

func (*Config) SetWallet

func (pc *Config) SetWallet(addr string)

func (*Config) Validate

func (pc *Config) Validate() error

type DappModule

type DappModule struct {
	Name     string `yaml:"name" json:"name"`
	CapID    string `yaml:"cap-id" json:"cap-id"`
	ConfigID string `yaml:"config-id" json:"config-id"`
}

type IClient

type IClient interface {
	GetLatestCheckpointSeq(ctx context.Context) (uint64, error)
	GetTotalBalance(ctx context.Context, addr string) (uint64, error)
	SimulateTx(ctx context.Context, txBytes lib.Base64Data) (*types.DryRunTransactionBlockResponse, int64, error)
	ExecuteTx(ctx context.Context, wallet *account.Account, txBytes lib.Base64Data, signatures []any) (*types.SuiTransactionBlockResponse, error)
	GetTransaction(ctx context.Context, txDigest string) (*types.SuiTransactionBlockResponse, error)
	QueryContract(ctx context.Context, senderAddr string, txBytes lib.Base64Data, resPtr interface{}) error

	GetCheckpoint(ctx context.Context, checkpoint uint64) (*suitypes.CheckpointResponse, error)
	GetEventsFromTxBlocks(ctx context.Context, allowedEventTypes []string, digests []string) ([]suitypes.EventResponse, error)

	GetObject(ctx context.Context, objID sui_types.ObjectID, options *types.SuiObjectDataOptions) (*types.SuiObjectResponse, error)

	GetCoins(ctx context.Context, accountAddress string) (types.Coins, error)

	MoveCall(
		ctx context.Context,
		signer move_types.AccountAddress,
		packageId move_types.AccountAddress,
		module, function string,
		typeArgs []string,
		arguments []any,
		gas *move_types.AccountAddress,
		gasBudget types.SafeSuiBigInt[uint64],
	) (*types.TransactionBytes, error)

	QueryTxBlocks(
		ctx context.Context,
		query types.SuiTransactionBlockResponseQuery,
		cursor *sui_types.TransactionDigest,
		limit *uint,
		descendingOrder bool,
	) (*types.TransactionBlocksPage, error)

	GetEvents(
		ctx context.Context,
		txDigest sui_types.TransactionDigest,
	) ([]types.SuiEvent, error)

	MultiGetTxBlocks(
		ctx context.Context,
		digests []string,
	) ([]*types.SuiTransactionBlockResponse, error)
}

type KeyPair

type KeyPair byte
const (
	Ed25519Flag   KeyPair = 0
	Secp256k1Flag KeyPair = 1
)

type Provider

type Provider struct {
	LastSavedHeightFunc func() uint64
	// contains filtered or unexported fields
}

func (*Provider) ClaimFee

func (p *Provider) ClaimFee(ctx context.Context) error

func (*Provider) Config

func (p *Provider) Config() provider.Config

func (*Provider) FinalityBlock

func (p *Provider) FinalityBlock(ctx context.Context) uint64

FinalityBlock returns the number of blocks the chain has to advance from current block inorder to consider it as final. In Sui checkpoints are analogues to blocks and checkpoints once published are final. So Sui doesn't need to be checked for block/checkpoint finality.

func (*Provider) GenerateMessages

func (p *Provider) GenerateMessages(ctx context.Context, messageKey *relayertypes.MessageKeyWithMessageHeight) ([]*relayertypes.Message, error)

func (*Provider) GetFee

func (p *Provider) GetFee(ctx context.Context, networkID string, responseFee bool) (uint64, error)

func (*Provider) ImportKeystore

func (p *Provider) ImportKeystore(ctx context.Context, keyPath, passphrase string) (string, error)

Imports first ed25519 key pair from the keystore

func (*Provider) Init

func (p *Provider) Init(ctx context.Context, homePath string, kms kms.KMS) error

func (*Provider) Listener

func (p *Provider) Listener(ctx context.Context, lastProcessedTx relayertypes.LastProcessedTx, blockInfo chan *relayertypes.BlockInfo) error

func (*Provider) MakeSuiMessage

func (p *Provider) MakeSuiMessage(message *relayertypes.Message) (*SuiMessage, error)

func (*Provider) MessageReceived

func (p *Provider) MessageReceived(ctx context.Context, messageKey *relayertypes.MessageKey) (bool, error)

func (*Provider) NID

func (p *Provider) NID() string

func (*Provider) Name

func (p *Provider) Name() string

func (*Provider) NewKeystore

func (p *Provider) NewKeystore(password string) (string, error)

Creates new Ed25519 key

func (*Provider) NewSuiMessage

func (p *Provider) NewSuiMessage(typeArgs []string, params []SuiCallArg, packageId, module, method string) *SuiMessage

func (*Provider) QueryBalance

func (p *Provider) QueryBalance(ctx context.Context, addr string) (*relayertypes.Coin, error)

func (*Provider) QueryLatestHeight

func (p *Provider) QueryLatestHeight(ctx context.Context) (uint64, error)

func (*Provider) QueryTransactionReceipt

func (p *Provider) QueryTransactionReceipt(ctx context.Context, txDigest string) (*relayertypes.Receipt, error)

func (*Provider) RestoreKeystore

func (p *Provider) RestoreKeystore(ctx context.Context) error

Restores the addres configured

func (*Provider) RevertMessage

func (p *Provider) RevertMessage(ctx context.Context, sn *big.Int) error

func (*Provider) Route

func (p *Provider) Route(ctx context.Context, message *relayertypes.Message, callback relayertypes.TxResponseFunc) error

func (*Provider) SendTransaction

func (p *Provider) SendTransaction(ctx context.Context, txBytes lib.Base64Data) (*types.SuiTransactionBlockResponse, error)

func (*Provider) SetAdmin

func (p *Provider) SetAdmin(ctx context.Context, adminAddr string) error

SetAdmin transfers the ownership of sui connection module to new address

func (*Provider) SetFee

func (p *Provider) SetFee(ctx context.Context, networkID string, msgFee, resFee *big.Int) error

func (*Provider) SetLastSavedHeightFunc

func (p *Provider) SetLastSavedHeightFunc(f func() uint64)

SetLastSavedBlockHeightFunc sets the function to save the last saved block height

func (*Provider) ShouldReceiveMessage

func (p *Provider) ShouldReceiveMessage(ctx context.Context, messagekey *relayertypes.Message) (bool, error)

func (*Provider) ShouldSendMessage

func (p *Provider) ShouldSendMessage(ctx context.Context, messageKey *relayertypes.Message) (bool, error)

func (*Provider) Type

func (p *Provider) Type() string

Type returns chain-type

func (*Provider) Wallet

func (p *Provider) Wallet() (*account.Account, error)

type SuiCallArg

type SuiCallArg struct {
	Val  interface{}
	Type string
}

type SuiMessage

type SuiMessage struct {
	Params    []SuiCallArg
	TypeArgs  []string
	Method    string
	PackageId string
	Module    string
}

func (*SuiMessage) MsgBytes

func (m *SuiMessage) MsgBytes() ([]byte, error)

func (*SuiMessage) Type

func (m *SuiMessage) Type() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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