sui

package
v1.9.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: Apache-2.0 Imports: 30 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"
	MethodGetExecuteCallParams     = "get_execute_params"
	MethodGetExecuteRollbackParams = "get_rollback_params"

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

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, digests []string, txFilter func(*types.SuiTransactionBlockResponse) bool) ([]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"`

	XcallPkgID     string `yaml:"xcall-package-id" json:"xcall-package-id"`
	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"`

	Dapps []Dapp `yaml:"dapps" json:"dapps"`

	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"`

	PollInterval time.Duration `json:"poll-interval" yaml:"poll-interval"`
}

func (*Config) ContractsAddress added in v1.9.0

func (c *Config) ContractsAddress() types.ContractConfigMap

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 Dapp added in v1.7.0

type Dapp struct {
	PkgID string `json:"package-id" yaml:"package-id"`

	// DappConstant is a map of name of sui constant to object id.
	Constants map[string]string `json:"constants" yaml:"constants"`

	Modules []DappModule `json:"modules" yaml:"modules"`
}

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)

	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)

	GetEventsFromTxBlocks(
		ctx context.Context,
		digests []string,
		txFilter func(*types.SuiTransactionBlockResponse) bool,
	) ([]suitypes.EventResponse, 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) FetchTxMessages added in v1.9.0

func (p *Provider) FetchTxMessages(ctx context.Context, txHash string) ([]*relayertypes.Message, error)

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, fromHeight, toHeight uint64) ([]*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