sui

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MoveVisibilityNone = iota
	MoveVisibilityPrivate
	MoveVisibilityPublic
	MoveVisibilityFriend
)
View Source
const (
	MoveAbilityNone = iota
	MoveAbilityCopy
	MoveAbilityDrop
	MoveAbilityStore
	MoveAbilityKey
)
View Source
const (
	UnitSui  = 1e9
	UnitMist = 1
)
View Source
const AddressLen = 32

Variables

View Source
var (
	SuiPackageIdMoveStdlib   = MustPackageIdFromHex("0x1")
	SuiPackageIdSuiFramework = MustPackageIdFromHex("0x2")
	SuiPackageIdSuiSystem    = MustPackageIdFromHex("0x3")
	SuiPackageIdBridge       = MustPackageIdFromHex("0xb")
	SuiPackageIdDeepbook     = MustPackageIdFromHex("0xdee9")
)
View Source
var (
	SuiObjectIdSystemState        = MustObjectIdFromHex("0x5")
	SuiObjectIdClock              = MustObjectIdFromHex("0x6")
	SuiObjectIdAuthenticatorState = MustObjectIdFromHex("0x7")
	SuiObjectIdRandomnessState    = MustObjectIdFromHex("0x8")
	SuiObjectIdBridge             = MustObjectIdFromHex("0x9")
	SuiObjectIdDenyList           = MustObjectIdFromHex("0x403")
)
View Source
var (
	SuiSystemStateObjectSharedVersion        = SequenceNumber(1)
	SuiClockObjectSharedVersion              = SequenceNumber(1)
	SuiAuthenticatorStateObjectSharedVersion = SequenceNumber(1)
)
View Source
var (
	SuiCoinType = "0x2::sui::SUI"
)

Functions

func IsSameAddressString

func IsSameAddressString(addr1, addr2 string) bool

Types

type Address

type Address [AddressLen]uint8

func AddressFromHex

func AddressFromHex(str string) (*Address, error)

func MustAddressFromHex

func MustAddressFromHex(str string) *Address

func (Address) Bytes

func (a Address) Bytes() []byte

func (Address) Length

func (a Address) Length() int

func (Address) MarshalBCS

func (a Address) MarshalBCS() ([]byte, error)

func (Address) MarshalJSON

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

func (Address) ShortString

func (a Address) ShortString() string

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

func (Address) String

func (a Address) String() string

func (*Address) UnmarshalJSON

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

type Base58

type Base58 []byte

func NewBase58

func NewBase58(str string) (*Base58, error)

func (Base58) Data

func (b Base58) Data() []byte

func (Base58) Length

func (b Base58) Length() int

func (Base58) MarshalJSON

func (b Base58) MarshalJSON() ([]byte, error)

func (Base58) String

func (b Base58) String() string

func (*Base58) UnmarshalJSON

func (b *Base58) UnmarshalJSON(data []byte) error

type Base64Data

type Base64Data []byte

func MustNewBase64Data

func MustNewBase64Data(str string) *Base64Data

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 BigInt

type BigInt struct {
	*big.Int
}

func NewBigInt

func NewBigInt(v uint64) *BigInt

func NewBigIntInt64

func NewBigIntInt64(v int64) *BigInt

func (*BigInt) MarshalJSON

func (w *BigInt) MarshalJSON() ([]byte, error)

func (*BigInt) UnmarshalJSON

func (w *BigInt) UnmarshalJSON(data []byte) error

func (*BigInt) UnmarshalText

func (w *BigInt) UnmarshalText(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 {
	~[]byte
	Data() []byte
	Length() int
	String() string
}

type CertificateDigest

type CertificateDigest = Digest

type CheckpointContentsDigest

type CheckpointContentsDigest = Digest

type CheckpointDigest

type CheckpointDigest = Digest

type Data

type Data struct {
	Move    *MoveObject
	Package *MovePackage
}

func (Data) IsBcsEnum

func (d Data) IsBcsEnum()

type Digest

type Digest = Base58

func MustNewDigest

func MustNewDigest(str string) *Digest

func NewDigest

func NewDigest(str string) (*Digest, error)

type EmptyEnum

type EmptyEnum struct{}

func (EmptyEnum) MarshalBCS

func (e EmptyEnum) MarshalBCS() ([]byte, error)

func (*EmptyEnum) UnmarshalBCS

func (e *EmptyEnum) UnmarshalBCS(io.Reader) (int, error)

type EpochId

type EpochId = uint64

type HexData

type HexData []byte

func NewHexData

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

func (HexData) Data

func (h HexData) Data() []byte

func (HexData) Length

func (h HexData) Length() int

func (HexData) MarshalJSON

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

func (HexData) ShortString

func (h HexData) ShortString() string

func (HexData) String

func (h HexData) String() string

func (*HexData) UnmarshalJSON

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

type Identifier

type Identifier = string
var (
	SuiSystemModuleName Identifier = "sui_system"
)

type MoveAbility

type MoveAbility int

func (*MoveAbility) UnmarshalJSON

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

type MoveAbilitySet

type MoveAbilitySet struct {
	Abilities []MoveAbility
}

type MoveFunctionArgType

type MoveFunctionArgType int
const (
	MoveFunctionArgTypeNone MoveFunctionArgType = iota
	MoveFunctionArgTypePure
	MoveFunctionArgTypeImmutableReference
	MoveFunctionArgTypeMutableReference
	MoveFunctionArgTypeValue
)

func (*MoveFunctionArgType) UnmarshalJSON

func (m *MoveFunctionArgType) UnmarshalJSON(data []byte) error

type MoveModule

type MoveModule struct {
	Package *ObjectId  `json:"package"`
	Module  Identifier `json:"module"`
}

type MoveModuleId

type MoveModuleId struct {
	Address *Address
	Name    Identifier
}

type MoveNormalizedField

type MoveNormalizedField struct {
	Name Identifier
	Type *MoveNormalizedType
}

type MoveNormalizedFunction

type MoveNormalizedFunction struct {
	Visibility     MoveVisibility
	IsEntry        bool
	TypeParameters []MoveAbilitySet
	Parameters     []MoveNormalizedType
	Return         []MoveNormalizedType
}

type MoveNormalizedModule

type MoveNormalizedModule struct {
	FileFormatVersion uint32
	Address           *Address
	Name              Identifier
	Friends           []*MoveModuleId
	Structs           map[Identifier]*MoveNormalizedStruct
	ExposedFunctions  map[Identifier]*MoveNormalizedFunction
}

type MoveNormalizedStruct

type MoveNormalizedStruct struct {
	Abilities      MoveAbilitySet
	TypeParameters []*MoveStructTypeParameter
	Fields         []*MoveNormalizedField
}

type MoveNormalizedType

type MoveNormalizedType struct {
	Bool             *EmptyEnum
	U8               *EmptyEnum
	U16              *EmptyEnum
	U32              *EmptyEnum
	U64              *EmptyEnum
	U128             *EmptyEnum
	U256             *EmptyEnum
	Address          *EmptyEnum
	Signer           *EmptyEnum
	Struct           *MoveNormalizedTypeStructType
	Vector           *MoveNormalizedType
	TypeParameter    *MoveTypeParameterIndex
	Reference        *MoveNormalizedType
	MutableReference *MoveNormalizedType
}

func (*MoveNormalizedType) UnmarshalJSON

func (s *MoveNormalizedType) UnmarshalJSON(data []byte) error

type MoveNormalizedTypeStructType

type MoveNormalizedTypeStructType struct {
	Address       *Address             `json:"address"`
	Module        Identifier           `json:"module"`
	Name          Identifier           `json:"name"`
	TypeArguments []MoveNormalizedType `json:"typeArguments"`
}

type MoveObject

type MoveObject struct {
	Type              MoveObjectType
	HasPublicTransfer bool
	Version           SequenceNumber
	Contents          []uint8
}

type MoveObjectType

type MoveObjectType struct {
	Other     *StructTag
	GasCoin   *EmptyEnum
	StakedSui *EmptyEnum
	Coin      *TypeTag
}

func (MoveObjectType) IsBcsEnum

func (o MoveObjectType) IsBcsEnum()

type MovePackage

type MovePackage struct {
	Id              ObjectId
	Version         SequenceNumber
	ModuleMap       map[string][]uint8
	TypeOriginTable []TypeOrigin
	LinkageTable    map[ObjectId]UpgradeInfo
}

type MoveStructTypeParameter

type MoveStructTypeParameter struct {
	Constraints MoveAbilitySet
	IsPhantom   bool
}

type MoveTypeParameterIndex

type MoveTypeParameterIndex uint16

type MoveVisibility

type MoveVisibility int

func (*MoveVisibility) UnmarshalJSON

func (v *MoveVisibility) UnmarshalJSON(data []byte) error

type ObjectDigest

type ObjectDigest = Digest

type ObjectId

type ObjectId = Address

func MustObjectIdFromHex

func MustObjectIdFromHex(str string) *ObjectId

func ObjectIdFromHex

func ObjectIdFromHex(str string) (*ObjectId, error)

type ObjectRef

type ObjectRef struct {
	ObjectId *ObjectId      `json:"objectId"`
	Version  SequenceNumber `json:"version"`
	Digest   *ObjectDigest  `json:"digest"`
}

ObjectRef for BCS, need to keep this order

type ObjectType

type ObjectType = string

func ObjectTypeFromString

func ObjectTypeFromString(str string) ObjectType

type Owner

type Owner struct {
	AddressOwner *Address `json:"AddressOwner"`
	ObjectOwner  *Address `json:"ObjectOwner"`
	Shared       *struct {
		InitialSharedVersion SequenceNumber `json:"initial_shared_version"`
	} `json:"Shared,omitempty"`
	Immutable *EmptyEnum `json:"Immutable,omitempty"`
}

func (Owner) Content

func (o Owner) Content() string

func (Owner) IsBcsEnum

func (o Owner) IsBcsEnum()

func (Owner) Tag

func (o Owner) Tag() string

type PackageId

type PackageId = Address

func MustPackageIdFromHex

func MustPackageIdFromHex(str string) *PackageId

func PackageIdFromHex

func PackageIdFromHex(str string) (*PackageId, error)

type ProtocolVersion

type ProtocolVersion = uint64

type ResourceType

type ResourceType struct {
	Address    *Address
	Module     Identifier
	ObjectName Identifier // it can be function name or struct name, etc.

	SubType *ResourceType
}

func NewResourceType

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

func (ResourceType) Contains

func (r ResourceType) Contains(address *Address, moduleName string, funcName string) bool

func (*ResourceType) ShortString

func (t *ResourceType) ShortString() string

func (*ResourceType) String

func (t *ResourceType) String() string

type SequenceNumber

type SequenceNumber = uint64

type StructTag

type StructTag struct {
	Address    *Address
	Module     Identifier
	Name       Identifier
	TypeParams []TypeTag
}

func StructTagFromString

func StructTagFromString(data string) (*StructTag, error)

func (*StructTag) MarshalJSON

func (s *StructTag) MarshalJSON() ([]byte, error)

func (*StructTag) String

func (s *StructTag) String() string

func (*StructTag) UnmarshalJSON

func (s *StructTag) UnmarshalJSON(data []byte) error

type TransactionDigest

type TransactionDigest = Digest

type TransactionEffectsDigest

type TransactionEffectsDigest = Digest

type TransactionEventsDigest

type TransactionEventsDigest = Digest

type TypeOrigin

type TypeOrigin struct {
	Module     string   `json:"moduleName"`
	StructName string   `json:"structName"`
	Package    ObjectId `json:"package"`
}

type TypeTag

type TypeTag struct {
	Bool    *EmptyEnum
	U8      *EmptyEnum
	U64     *EmptyEnum
	U128    *EmptyEnum
	Address *EmptyEnum
	Signer  *EmptyEnum
	Vector  *TypeTag
	Struct  *StructTag

	U16  *EmptyEnum
	U32  *EmptyEnum
	U256 *EmptyEnum
}

refer BCS doc https://github.com/diem/bcs/blob/master/README.md#externally-tagged-enumerations IMPORTANT! The order of the fields MATTERS! DON'T CHANGE! this is enum `TypeTag` in `external-crates/move/crates/move-core-types/src/language_storage.rs` each field should be the same as enum `TypeTag` there

func MustNewTypeTag

func MustNewTypeTag(data string) *TypeTag

func NewTypeTag

func NewTypeTag(data string) (*TypeTag, error)

refer TypeTagSerializer.parseFromStr() at 'sdk/typescript/src/bcs/type-tag-serializer.ts'

func (TypeTag) Equal

func (t1 TypeTag) Equal(t2 TypeTag) bool

func (TypeTag) IsBcsEnum

func (t TypeTag) IsBcsEnum()

func (*TypeTag) String

func (t *TypeTag) String() string

type UpgradeInfo

type UpgradeInfo struct {
	UpgradedId      ObjectId
	UpgradedVersion SequenceNumber
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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