types

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: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PickSmaller = iota // pick smaller coins to match amount
	PickBigger         // pick bigger coins to match amount
	PickByOrder        // pick coins by coins order to match amount
)
View Source
const (
	TransactionStatusSuccess = "success"
	TransactionStatusFailure = "failure"
)
View Source
const (
	SuiCoinType = "0x2::sui::SUI"
)

Variables

View Source
var ErrCoinsNotMatchRequest error
View Source
var IntentBytes = []byte{0, 0, 0}

IntentBytes See: sui/crates/sui-types/src/intent.rs This is currently hardcoded with [IntentScope::TransactionData = 0, Version::V0 = 0, AppId::Sui = 0]

Functions

This section is empty.

Types

type Address

type Address = HexData

func NewAddressFromHex

func NewAddressFromHex(addr string) (*Address, error)

NewAddressFromHex *

  • Creates Address from a hex string.
  • @param addr Hex string can be with a prefix or without a prefix,
  • e.g. '0x1aa' or '1aa'. Hex string will be left padded with 0s if too short.

func (Address) ShortString

func (a Address) ShortString() string

ShortString Returns the address with leading zeros trimmed, e.g. 0x2

type AuthSignInfo

type AuthSignInfo interface{}

type Base64Data

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

func NewBase64Data

func NewBase64Data(str string) (*Base64Data, error)

func (Base64Data) Data

func (h Base64Data) Data() []byte

func (Base64Data) Length

func (h Base64Data) Length() int

func (Base64Data) MarshalJSON

func (h Base64Data) MarshalJSON() ([]byte, error)

func (Base64Data) String

func (h Base64Data) String() string

func (*Base64Data) UnmarshalJSON

func (h *Base64Data) UnmarshalJSON(data []byte) error

type Bytes

type Bytes []byte

func (Bytes) GetBase64Data

func (b Bytes) GetBase64Data() Base64Data

func (Bytes) GetHexData

func (b Bytes) GetHexData() HexData

type BytesData

type BytesData interface {
	Data() []byte
	Length() int
	String() string
}

type CertifiedTransaction

type CertifiedTransaction struct {
	TransactionDigest string        `json:"transactionDigest"`
	TxSignature       string        `json:"txSignature"`
	AuthSignInfo      *AuthSignInfo `json:"authSignInfo"`

	Data *SenderSignedData `json:"data"`
}

type ChangeEpoch

type ChangeEpoch struct {
	Epoch             interface{} `json:"epoch"`
	StorageCharge     uint64      `json:"storage_charge"`
	ComputationCharge uint64      `json:"computation_charge"`
}

type Coin

type Coin struct {
	Balance   uint64     `json:"balance"`
	Type      string     `json:"type"`
	Owner     *Address   `json:"owner"`
	Reference *ObjectRef `json:"reference"`
}

type CoinObject

type CoinObject struct {
	CoinType     string   `json:"coinType"`
	CoinObjectId ObjectId `json:"coinObjectId"`
	Version      int64    `json:"version"`
	Digest       string   `json:"digest"`
	Balance      int64    `json:"balance"`
}

type CoinPage

type CoinPage struct {
	Data       []CoinObject `json:"data"`
	NextCursor *ObjectId    `json:"nextCursor"`
}

type Coins

type Coins []Coin

func (Coins) PickCoinNoLess

func (cs Coins) PickCoinNoLess(amount uint64) (*Coin, error)

func (Coins) PickCoins

func (cs Coins) PickCoins(amount *big.Int, pickMethod int) (Coins, error)

PickCoins pick coins, which sum >= amount, pickMethod, see PickSmaller|PickBigger|PickByOrder // if not satisfated amount, an ErrCoinsNotMatchRequest error will return

func (Coins) PickSUICoinsWithGas

func (cs Coins) PickSUICoinsWithGas(amount *big.Int, gasAmount uint64, pickMethod int) (Coins, *Coin, error)

PickSUICoinsWithGas pick coins, which sum >= amount, and pick a gas coin >= gasAmount which not in coins if not satisfated amount/gasAmount, an ErrCoinsNotMatchRequest error will return if gasAmount == 0, a nil gasCoin will return pickMethod, see PickSmaller|PickBigger|PickByOrder

func (Coins) TotalBalance

func (cs Coins) TotalBalance() *big.Int

type DevInspectResult

type DevInspectResult struct {
	Err string `json:"Err,omitempty"`
	Ok  any    `json:"Ok,omitempty"` //Result_of_Array_of_Tuple_of_uint_and_SuiExecutionResult_or_String
}

type DevInspectResults

type DevInspectResults struct {
	Effects TransactionEffects `json:"effects"`
	Results DevInspectResult   `json:"results"`
}

type Digest

type Digest = Base64Data

type Event

type Event interface{}

type ExecuteTransactionEffects

type ExecuteTransactionEffects struct {
	TransactionEffectsDigest string `json:"transactionEffectsDigest"`

	Effects      TransactionEffects `json:"effects"`
	AuthSignInfo *AuthSignInfo      `json:"authSignInfo"`
}

type ExecuteTransactionRequestType

type ExecuteTransactionRequestType string
const (
	TxnRequestTypeWaitForEffectsCert    ExecuteTransactionRequestType = "WaitForEffectsCert"
	TxnRequestTypeWaitForLocalExecution ExecuteTransactionRequestType = "WaitForLocalExecution"
)

type ExecuteTransactionResponse

type ExecuteTransactionResponse struct {
	ImmediateReturn *struct {
		TransactionDigest string `json:"tx_digest"`
	} `json:"ImmediateReturn,omitempty"`

	TxCert *struct {
		Certificate CertifiedTransaction `json:"certificate"`
	} `json:"TxCert,omitempty"`

	EffectsCert *struct {
		Certificate CertifiedTransaction      `json:"certificate"`
		Effects     ExecuteTransactionEffects `json:"effects"`

		ConfirmedLocalExecution bool `json:"confirmed_local_execution"`
	} `json:"EffectsCert,omitempty"`
}

func (*ExecuteTransactionResponse) TransactionDigest

func (r *ExecuteTransactionResponse) TransactionDigest() string

type GasCostSummary

type GasCostSummary struct {
	ComputationCost uint64 `json:"computationCost"`
	StorageCost     uint64 `json:"storageCost"`
	StorageRebate   uint64 `json:"storageRebate"`
}

type HexData

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

func NewHexData

func NewHexData(str string) (*HexData, error)

func (HexData) Data

func (a HexData) Data() []byte

func (HexData) Length

func (a HexData) Length() int

func (HexData) MarshalJSON

func (a HexData) MarshalJSON() ([]byte, error)

func (HexData) String

func (a HexData) String() string

func (*HexData) UnmarshalJSON

func (a *HexData) UnmarshalJSON(data []byte) error

type InputObjectKind

type InputObjectKind map[string]interface{}

type ModulePublish

type ModulePublish struct {
	Modules [][]byte `json:"modules"`
}

type MoveCall

type MoveCall struct {
	Package  ObjectRef     `json:"package"`
	Module   string        `json:"module"`
	Function string        `json:"function"`
	TypeArgs []interface{} `json:"typeArguments"`
	Args     []interface{} `json:"arguments"`
}

type ObjectId

type ObjectId = HexData

type ObjectInfo

type ObjectInfo struct {
	ObjectId *ObjectId    `json:"objectId"`
	Version  int          `json:"version"`
	Digest   string       `json:"digest"`
	Type     string       `json:"type"`
	Owner    *ObjectOwner `json:"owner"`

	PreviousTransaction string `json:"previousTransaction"`
}

type ObjectOwner

type ObjectOwner struct {
	*ObjectOwnerInternal
	// contains filtered or unexported fields
}

func (ObjectOwner) MarshalJSON

func (o ObjectOwner) MarshalJSON() ([]byte, error)

func (*ObjectOwner) UnmarshalJSON

func (o *ObjectOwner) UnmarshalJSON(data []byte) error

type ObjectOwnerInternal

type ObjectOwnerInternal struct {
	AddressOwner *Address `json:"AddressOwner,omitempty"`
	ObjectOwner  *Address `json:"ObjectOwner,omitempty"`
	SingleOwner  *Address `json:"SingleOwner,omitempty"`
	Shared       *struct {
		InitialSharedVersion int64 `json:"initial_shared_version"`
	} `json:"Shared,omitempty"`
}

type ObjectRead

type ObjectRead struct {
	Details *ObjectReadDetail `json:"details"`
	Status  ObjectStatus      `json:"status"`
}

type ObjectReadDetail

type ObjectReadDetail struct {
	Data  map[string]interface{} `json:"data"`
	Owner *ObjectOwner           `json:"owner"`

	PreviousTransaction string     `json:"previousTransaction"`
	StorageRebate       int        `json:"storageRebate"`
	Reference           *ObjectRef `json:"reference"`
}

type ObjectRef

type ObjectRef struct {
	Digest   string   `json:"digest"`
	ObjectId ObjectId `json:"objectId"`
	Version  int64    `json:"version"`
}

type ObjectStatus

type ObjectStatus string
const (
	ObjectStatusExists    ObjectStatus = "Exists"
	ObjectStatusNotExists ObjectStatus = "NotExists"
	ObjectStatusDeleted   ObjectStatus = "Deleted"
)

type OwnedObjectRef

type OwnedObjectRef struct {
	Owner     *ObjectOwner `json:"owner"`
	Reference *ObjectRef   `json:"reference"`
}

type ParsedTransactionResponse

type ParsedTransactionResponse interface{}

type Pay

type Pay struct {
	Coins      []ObjectRef `json:"coins"`
	Recipients []Address   `json:"recipients"`
	Amounts    []uint64    `json:"amounts"`
}

type PayAllSui

type PayAllSui struct {
	Coins     []ObjectRef `json:"coins"`
	Recipient Address     `json:"recipient"`
}

type PaySui

type PaySui struct {
	Coins      []ObjectRef `json:"coins"`
	Recipients []Address   `json:"recipients"`
	Amounts    []uint64    `json:"amounts"`
}

type ResourceType

type ResourceType struct {
	Address    *Address
	ModuleName string
	FuncName   string

	SubType *ResourceType
}

func NewResourceType

func NewResourceType(str string) (*ResourceType, error)

func (*ResourceType) ShortString

func (t *ResourceType) ShortString() string

func (*ResourceType) String

func (t *ResourceType) String() string

type SenderSignedData

type SenderSignedData struct {
	Transactions []SingleTransactionKind `json:"transactions,omitempty"`

	Sender     *Address   `json:"sender"`
	GasPayment *ObjectRef `json:"gasPayment"`
	GasBudget  uint64     `json:"gasBudget"`
	GasPrice   uint64     `json:"gasPrice"`
}

type SignatureScheme

type SignatureScheme string
const (
	SignatureSchemeEd25519   SignatureScheme = "ED25519"
	SignatureSchemeSecp256k1 SignatureScheme = "Secp256k1"
)

type SignatureSchemeSerialized

type SignatureSchemeSerialized byte
const (
	SignatureSchemeSerializedEd25519   SignatureSchemeSerialized = 0
	SignatureSchemeSerializedSecp256k1 SignatureSchemeSerialized = 1
)

type SignedTransaction

type SignedTransaction struct {
	// transaction data bytes
	TxBytes *Base64Data `json:"tx_bytes"`

	// Flag of the signature scheme that is used.
	SigScheme SignatureScheme `json:"sig_scheme"`

	// transaction signature
	Signature *Base64Data `json:"signature"`

	// signer's public key
	PublicKey *Base64Data `json:"pub_key"`
}

type SignedTransactionSerializedSig

type SignedTransactionSerializedSig struct {
	// transaction data bytes
	TxBytes *Base64Data `json:"tx_bytes"`

	// transaction signature
	Signature *Base64Data `json:"signature"`
}

type SingleTransactionKind

type SingleTransactionKind struct {
	TransferObject *TransferObject `json:"TransferObject,omitempty"`
	Publish        *ModulePublish  `json:"Publish,omitempty"`
	Call           *MoveCall       `json:"Call,omitempty"`
	TransferSui    *TransferSui    `json:"TransferSui,omitempty"`
	ChangeEpoch    *ChangeEpoch    `json:"ChangeEpoch,omitempty"`
	PaySui         *PaySui         `json:"PaySui,omitempty"`
	Pay            *Pay            `json:"Pay,omitempty"`
	PayAllSui      *PayAllSui      `json:"PayAllSui,omitempty"`
}

type SuiCoinBalance

type SuiCoinBalance struct {
	CoinType        string `json:"coinType"`
	CoinObjectCount int64  `json:"coinObjectCount"`
	TotalBalance    int64  `json:"totalBalance"`
}

type SuiCoinMetadata

type SuiCoinMetadata struct {
	Decimals    uint8    `json:"decimals"`
	Description string   `json:"description"`
	IconUrl     string   `json:"iconUrl,omitempty"`
	Id          ObjectId `json:"id"`
	Name        string   `json:"name"`
	Symbol      string   `json:"symbol"`
}

type Supply

type Supply struct {
	Value uint64 `json:"value"`
}

type TransactionBytes

type TransactionBytes struct {
	// the gas object to be used
	Gas ObjectRef `json:"gas"`

	// objects to be used in this transaction
	InputObjects []InputObjectKind `json:"inputObjects"`

	// transaction data bytes
	TxBytes Base64Data `json:"txBytes"`
}

func (*TransactionBytes) SignSerializedSigWith

func (txn *TransactionBytes) SignSerializedSigWith(privateKey ed25519.PrivateKey) *SignedTransactionSerializedSig

func (*TransactionBytes) SignWith

func (txn *TransactionBytes) SignWith(privateKey ed25519.PrivateKey) *SignedTransaction

type TransactionEffects

type TransactionEffects struct {
	Status TransactionStatus `json:"status"`

	TransactionDigest string          `json:"transactionDigest"`
	GasUsed           *GasCostSummary `json:"gasUsed"`
	GasObject         *OwnedObjectRef `json:"gasObject"`
	Events            []Event         `json:"events,omitempty"`
	Dependencies      []string        `json:"dependencies,omitempty"`

	SharedObjects []ObjectRef      `json:"sharedObjects,omitempty"`
	Created       []OwnedObjectRef `json:"created,omitempty"`
	Mutated       []OwnedObjectRef `json:"mutated,omitempty"`
	Unwrapped     []OwnedObjectRef `json:"unwrapped,omitempty"`
	Deleted       []ObjectRef      `json:"deleted,omitempty"`
	Wrapped       []ObjectRef      `json:"wrapped,omitempty"`
}

func (*TransactionEffects) GasFee

func (te *TransactionEffects) GasFee() uint64

type TransactionResponse

type TransactionResponse struct {
	Certificate *CertifiedTransaction     `json:"certificate"`
	Effects     *TransactionEffects       `json:"effects"`
	ParsedData  ParsedTransactionResponse `json:"parsed_data,omitempty"`
	TimestampMs uint64                    `json:"timestamp_ms,omitempty"`
}

type TransactionStatus

type TransactionStatus struct {
	Status string `json:"status"`
	Error  string `json:"error,omitempty"`
}

type TransferObject

type TransferObject struct {
	Recipient Address   `json:"recipient"`
	ObjectRef ObjectRef `json:"objectRef"`
}

type TransferSui

type TransferSui struct {
	Recipient Address `json:"recipient"`
	Amount    uint64  `json:"amount"`
}

Jump to

Keyboard shortcuts

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