client

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DevNetFaucetUrl = "https://faucet.devnet.sui.io/gas"
)

Variables

View Source
var (
	ErrNoResult = errors.New("no result in JSON-RPC response")
)

Functions

func FaucetFundAccount

func FaucetFundAccount(address string, faucetUrl string) (string, error)

Types

type BatchElem

type BatchElem struct {
	Method string
	Args   []interface{}
	// The result is unmarshaled into this field. Result must be set to a
	// non-nil pointer value of the desired type, otherwise the response will be
	// discarded.
	Result interface{}
	// Error is set if the server returns an error for this request, or if
	// unmarshaling into Result fails. It is not set for I/O errors.
	Error error
}

BatchElem is an element in a batch request.

type Client

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

func Dial

func Dial(rpcUrl string) (client *Client, err error)

func DialWithClient

func DialWithClient(rpcUrl string, c *http.Client) (client *Client, err error)

func (*Client) BatchCall

func (c *Client) BatchCall(b []BatchElem) error

BatchCall sends all given requests as a single batch and waits for the server to return a response for all of them.

func (*Client) BatchCallContext

func (c *Client) BatchCallContext(ctx context.Context, b []BatchElem) error

BatchCallContext sends all given requests as a single batch and waits for the server to return a response for all of them. The wait duration is bounded by the context's deadline.

func (*Client) BatchGetFilteredObjectsOwnedByAddress

func (c *Client) BatchGetFilteredObjectsOwnedByAddress(ctx context.Context, address types.Address, filter func(types.ObjectInfo) bool) ([]types.ObjectRead, error)

func (*Client) BatchGetObject

func (c *Client) BatchGetObject(objects []types.ObjectId) (map[string]*types.ObjectRead, error)

func (*Client) BatchGetObjectsOwnedByAddress

func (c *Client) BatchGetObjectsOwnedByAddress(ctx context.Context, address types.Address, filterType string) ([]types.ObjectRead, error)

BatchGetObjectsOwnedByAddress @param filterType You can specify filtering out the specified resources, this will fetch all resources if it is not empty ""

func (*Client) BatchGetTransaction

func (c *Client) BatchGetTransaction(digests []string) (map[string]*types.TransactionResponse, error)

func (*Client) BatchTransaction

func (c *Client) BatchTransaction(ctx context.Context, signer types.Address, txnParams []map[string]interface{}, gas *types.ObjectId, gasBudget uint64) (*types.TransactionBytes, error)

func (*Client) Call

func (c *Client) Call(result interface{}, method string, args ...interface{}) error

Call performs a JSON-RPC call with the given arguments and unmarshals into the result if no error occurred.

The result must be a pointer so that package json can unmarshal into it. You can also pass nil, in which case the result is ignored.

func (*Client) CallContext

func (c *Client) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error

CallContext performs a JSON-RPC call with the given arguments. If the context is canceled before the call has successfully returned, CallContext returns immediately.

The result must be a pointer so that package json can unmarshal into it. You can also pass nil, in which case the result is ignored.

func (*Client) DevInspectMoveCall

func (c *Client) DevInspectMoveCall(ctx context.Context, signer types.Address, packageId types.ObjectId, module, function string, typeArgs []string, arguments []any) (*types.DevInspectResults, error)

func (*Client) DevInspectTransaction

func (c *Client) DevInspectTransaction(ctx context.Context, txByte types.Base64Data) (*types.DevInspectResults, error)

func (*Client) DryRunTransaction

func (c *Client) DryRunTransaction(ctx context.Context, tx *types.TransactionBytes) (*types.TransactionEffects, error)

func (*Client) GetAllBalances

func (c *Client) GetAllBalances(ctx context.Context, address types.Address) ([]types.SuiCoinBalance, error)

func (*Client) GetAllCoins

func (c *Client) GetAllCoins(ctx context.Context, address types.Address, cursor *types.ObjectId, limit uint) (*types.CoinPage, error)

GetAllCoins start with the first object when cursor is nil

func (*Client) GetBalance

func (c *Client) GetBalance(ctx context.Context, address types.Address, coinType *string) (*types.SuiCoinBalance, error)

GetBalance to use default sui coin(0x2::sui::SUI) when coinType is nil

func (*Client) GetCoinMetadata

func (c *Client) GetCoinMetadata(ctx context.Context, coinType string) (*types.SuiCoinMetadata, error)

func (*Client) GetCoins

func (c *Client) GetCoins(ctx context.Context, address types.Address, coinType *string, cursor *types.ObjectId, limit uint) (*types.CoinPage, error)

GetCoins to use default sui coin(0x2::sui::SUI) when coinType is nil start with the first object when cursor is nil

func (*Client) GetCoinsOwnedByAddress

func (c *Client) GetCoinsOwnedByAddress(ctx context.Context, address types.Address, coinType string) (coins types.Coins, err error)

func (*Client) GetNFTsOwnedByAddress

func (c *Client) GetNFTsOwnedByAddress(ctx context.Context, address types.Address) ([]types.ObjectRead, error)

func (*Client) GetObject

func (c *Client) GetObject(ctx context.Context, objID types.ObjectId) (*types.ObjectRead, error)

func (*Client) GetObjectsOwnedByAddress

func (c *Client) GetObjectsOwnedByAddress(ctx context.Context, address types.Address) ([]types.ObjectInfo, error)

func (*Client) GetObjectsOwnedByObject

func (c *Client) GetObjectsOwnedByObject(ctx context.Context, objID types.ObjectId) ([]types.ObjectInfo, error)

func (*Client) GetRawObject

func (c *Client) GetRawObject(ctx context.Context, objID types.ObjectId) (*types.ObjectRead, error)

func (*Client) GetSuiCoinsOwnedByAddress

func (c *Client) GetSuiCoinsOwnedByAddress(ctx context.Context, address types.Address) (types.Coins, error)

func (*Client) GetTotalSupply

func (c *Client) GetTotalSupply(ctx context.Context, coinType string) (*types.Supply, error)

func (*Client) GetTotalTransactionNumber

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

func (*Client) GetTransaction

func (c *Client) GetTransaction(ctx context.Context, digest string) (*types.TransactionResponse, error)

func (*Client) GetTransactionsInRange

func (c *Client) GetTransactionsInRange(ctx context.Context, start, end uint64) ([]string, error)

func (*Client) MergeCoins

func (c *Client) MergeCoins(ctx context.Context, signer types.Address, primaryCoin, coinToMerge types.ObjectId, gas *types.ObjectId, gasBudget uint64) (*types.TransactionBytes, error)

MergeCoins Create an unsigned transaction to merge multiple coins into one coin.

func (*Client) MintNFT

func (c *Client) MintNFT(ctx context.Context, signer types.Address, nftName, nftDescription, nftUri string, gas *types.ObjectId, gasBudget uint64) (*types.TransactionBytes, error)

MintNFT Create an unsigned transaction to mint a nft at devnet

func (*Client) MoveCall

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

MoveCall Create an unsigned transaction to execute a Move call on the network, by calling the specified function in the module of a given package. TODO: not support param `typeArguments` yet. So now only methods with `typeArguments` are supported

func (*Client) Pay

func (c *Client) Pay(ctx context.Context, signer types.Address, inputCoins []types.ObjectId, recipients []types.Address, amount []uint64, gas types.ObjectId, gasBudget uint64) (*types.TransactionBytes, error)

func (*Client) PayAllSui

func (c *Client) PayAllSui(ctx context.Context, signer, recipient types.Address, inputCoins []types.ObjectId, gasBudget uint64) (*types.TransactionBytes, error)

PayAllSui Create an unsigned transaction to send all SUI coins to one recipient.

func (*Client) PaySui

func (c *Client) PaySui(ctx context.Context, signer types.Address, inputCoins []types.ObjectId, recipients []types.Address, amount []uint64, gasBudget uint64) (*types.TransactionBytes, error)

func (*Client) Publish

func (c *Client) Publish(ctx context.Context, address types.Address, compiledModules []*types.Base64Data, gas types.ObjectId, gasBudget uint) (*types.TransactionBytes, error)

func (*Client) SplitCoin

func (c *Client) SplitCoin(ctx context.Context, signer types.Address, Coin types.ObjectId, splitAmounts []uint64, gas *types.ObjectId, gasBudget uint64) (*types.TransactionBytes, error)

SplitCoin Create an unsigned transaction to split a coin object into multiple coins.

func (*Client) SplitCoinEqual

func (c *Client) SplitCoinEqual(ctx context.Context, signer types.Address, Coin types.ObjectId, splitCount uint64, gas *types.ObjectId, gasBudget uint64) (*types.TransactionBytes, error)

SplitCoinEqual Create an unsigned transaction to split a coin object into multiple equal-size coins.

func (*Client) TransferObject

func (c *Client) TransferObject(ctx context.Context, signer, recipient types.Address, objID types.ObjectId, gas *types.ObjectId, gasBudget uint64) (*types.TransactionBytes, error)

TransferObject Create an unsigned transaction to transfer an object from one address to another. The object's type must allow public transfers

func (*Client) TransferSui

func (c *Client) TransferSui(ctx context.Context, signer, recipient types.Address, suiObjID types.ObjectId, amount, gasBudget uint64) (*types.TransactionBytes, error)

TransferSui Create an unsigned transaction to send SUI coin object to a Sui address. The SUI object is also used as the gas object.

type HTTPError

type HTTPError struct {
	StatusCode int
	Status     string
	Body       []byte
}

func (HTTPError) Error

func (err HTTPError) Error() string

Jump to

Keyboard shortcuts

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