sui_types

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: Apache-2.0 Imports: 15 Imported by: 7

Documentation

Index

Constants

View Source
const (
	StakingPoolModuleName = move_types.Identifier("staking_pool")
	StakedSuiStructName   = move_types.Identifier("StakedSui")

	AddStakeMulCoinFunName = move_types.Identifier("request_add_stake_mul_coin")
	AddStakeFunName        = move_types.Identifier("request_add_stake")
	WithdrawStakeFunName   = move_types.Identifier("request_withdraw_stake")
)
View Source
const (
	ObjectStartVersion = SequenceNumber(1)
)

Variables

View Source
var (
	SuiSystemMut = CallArg{
		Object: &SuiSystemMutObj,
	}

	SuiSystemMutObj = ObjectArg{
		SharedObject: &struct {
			Id                   ObjectID
			InitialSharedVersion SequenceNumber
			Mutable              bool
		}{Id: *SuiSystemStateObjectId, InitialSharedVersion: SuiSystemStateObjectSharedVersion, Mutable: true},
	}
)
View Source
var (
	SuiSystemAddress, _               = NewAddressFromHex("0x3")
	SuiSystemPackageId                = SuiSystemAddress
	SuiSystemStateObjectId, _         = NewObjectIdFromHex("0x5")
	SuiSystemStateObjectSharedVersion = ObjectStartVersion
)

Functions

func UseDefaultHash added in v2.0.1

func UseDefaultHash(signable Signable) []byte

Types

type AppId

type AppId struct {
	Sui     *lib.EmptyEnum
	Narwhal *lib.EmptyEnum
}

func (AppId) IsBcsEnum

func (a AppId) IsBcsEnum()

type Argument

type Argument struct {
	GasCoin      *lib.EmptyEnum
	Input        *uint16
	Result       *uint16
	NestedResult *struct {
		Result1 uint16
		Result2 uint16
	}
}

func (Argument) IsBcsEnum

func (a Argument) IsBcsEnum()

type BcsSignable added in v2.0.1

type BcsSignable[K BcsSignableKind] struct {
	Data K
}

func (BcsSignable[K]) Write added in v2.0.1

func (s BcsSignable[K]) Write(digest hash.Hash)

type BcsSignableKind added in v2.0.1

type BcsSignableKind interface {
	TransactionData | Object
}

type BuilderArg

type BuilderArg struct {
	Object              *ObjectID
	Pure                *[]uint8
	ForcedNonUniquePure *uint
}

func (BuilderArg) String

func (b BuilderArg) String() string

type CallArg

type CallArg struct {
	Pure   *[]byte
	Object *ObjectArg
}

func (CallArg) IsBcsEnum

func (c CallArg) IsBcsEnum()

type CertificateDigest

type CertificateDigest = Digest

type ChangeEpoch

type ChangeEpoch struct {
	Epoch                   EpochId
	ProtocolVersion         sui_protocol.ProtocolVersion
	StorageCharge           uint64
	ComputationCharge       uint64
	StorageRebate           uint64
	NonRefundableStorageFee uint64
	EpochStartTimestampMs   uint64
	SystemPackages          []*struct {
		SequenceNumber SequenceNumber
		Bytes          [][]uint8
		Objects        []*ObjectID
	}
}

type CheckpointContentsDigest

type CheckpointContentsDigest = Digest

type CheckpointDigest

type CheckpointDigest = Digest

type CheckpointSequenceNumber

type CheckpointSequenceNumber = uint64

type CheckpointTimestamp

type CheckpointTimestamp = uint64

type Command

type Command struct {
	MoveCall        *ProgrammableMoveCall
	TransferObjects *struct {
		Arguments []Argument
		Argument  Argument
	}
	SplitCoins *struct {
		Argument  Argument
		Arguments []Argument
	}
	MergeCoins *struct {
		Argument  Argument
		Arguments []Argument
	}
	Publish *struct {
		Bytes   [][]uint8
		Objects []ObjectID
	}
	MakeMoveVec *struct {
		TypeTag   *move_types.TypeTag `bcs:"optional"`
		Arguments []Argument
	}
	Upgrade *struct {
		Bytes    [][]uint8
		Objects  []ObjectID
		ObjectID ObjectID
		Argument Argument
	}
}

func (Command) IsBcsEnum

func (c Command) IsBcsEnum()

type ConsensusCommitPrologue

type ConsensusCommitPrologue struct {
	Epoch             uint64
	Round             uint64
	CommitTimestampMs CheckpointTimestamp
}

type Data

type Data struct {
	Move    *MoveObject
	Package *MovePackage
}

func (Data) IsBcsEnum

func (d Data) IsBcsEnum()

type DefaultHash added in v2.0.1

type DefaultHash struct {
	hash.Hash
}

func NewDefaultHash added in v2.0.1

func NewDefaultHash() DefaultHash

type Digest

type Digest = lib.Base58

func NewDigest

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

type DynamicFieldName

type DynamicFieldName struct {
	Type  string `json:"type"`
	Value any    `json:"value"`
}

type DynamicFieldType

type DynamicFieldType struct {
	DynamicField  *lib.EmptyEnum `json:"DynamicField"`
	DynamicObject *lib.EmptyEnum `json:"DynamicObject"`
}

func (DynamicFieldType) Content

func (d DynamicFieldType) Content() string

func (DynamicFieldType) Tag

func (d DynamicFieldType) Tag() string

type Ed25519SuiSignature

type Ed25519SuiSignature struct {
	Signature [ed25519.PublicKeySize + ed25519.SignatureSize + 1]byte
}

func NewEd25519SuiSignature

func NewEd25519SuiSignature(keyPair crypto.KeyPair, message []byte) *Ed25519SuiSignature

type EpochId

type EpochId = uint64

type GasData

type GasData struct {
	Payment []*ObjectRef
	Owner   SuiAddress
	Price   uint64
	Budget  uint64
}

type GenesisObject

type GenesisObject struct {
	RawObject *struct {
		Data  Data
		Owner Owner
	}
}

type GenesisTransaction

type GenesisTransaction struct {
	Objects []GenesisObject
}

type Intent

type Intent struct {
	Scope   IntentScope
	Version IntentVersion
	AppId   AppId
}

func DefaultIntent

func DefaultIntent() Intent

type IntentMessage

type IntentMessage[T IntentValue] struct {
	Intent Intent
	Value  T
}

func NewIntentMessage

func NewIntentMessage[T IntentValue](intent Intent, value T) IntentMessage[T]

type IntentScope

type IntentScope struct {
	TransactionData         *lib.EmptyEnum // Used for a user signature on a transaction data.
	TransactionEffects      *lib.EmptyEnum // Used for an authority signature on transaction effects.
	CheckpointSummary       *lib.EmptyEnum // Used for an authority signature on a checkpoint summary.
	PersonalMessage         *lib.EmptyEnum // Used for a user signature on a personal message.
	SenderSignedTransaction *lib.EmptyEnum // Used for an authority signature on a user signed transaction.
	ProofOfPossession       *lib.EmptyEnum // Used as a signature representing an authority's proof of possesion of its authority protocol key.
	HeaderDigest            *lib.EmptyEnum // Used for narwhal authority signature on header digest.
}

func (IntentScope) IsBcsEnum

func (i IntentScope) IsBcsEnum()

type IntentValue

type IntentValue interface {
	TransactionData | ~[]byte
}

type IntentVersion

type IntentVersion struct {
	V0 *lib.EmptyEnum
}

func (IntentVersion) IsBcsEnum

func (i IntentVersion) IsBcsEnum()

type MoveCall

type MoveCall struct {
	Package       ObjectID
	Module        string
	Function      string
	TypeArguments []*move_types.TypeTag
	Arguments     []*CallArg
}

type MoveModulePublish

type MoveModulePublish struct {
	Modules [][]byte
}

type MoveObject

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

type MoveObjectType

type MoveObjectType = MoveObjectType_

type MoveObjectType_

type MoveObjectType_ struct {
	Other     *move_types.StructTag
	GasCoin   *lib.EmptyEnum
	StakedSui *lib.EmptyEnum
	Coin      *move_types.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 Object added in v2.0.1

type Object struct {
	Data                Data
	Owner               Owner
	PreviousTransaction TransactionDigest
	StorageRebate       uint64
}

type ObjectArg

type ObjectArg struct {
	ImmOrOwnedObject *ObjectRef
	SharedObject     *struct {
		Id                   ObjectID
		InitialSharedVersion SequenceNumber
		Mutable              bool
	}
}

func (ObjectArg) IsBcsEnum

func (o ObjectArg) IsBcsEnum()

type ObjectDigest

type ObjectDigest = Digest

type ObjectID

type ObjectID = move_types.AccountAddress

func NewObjectIdFromHex

func NewObjectIdFromHex(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 Owner

type Owner struct {
	AddressOwner *SuiAddress `json:"AddressOwner"`
	ObjectOwner  *SuiAddress `json:"ObjectOwner"`
	Shared       *struct {
		InitialSharedVersion SequenceNumber `json:"initial_shared_version"`
	} `json:"Shared,omitempty"`
	Immutable *lib.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 Pay

type Pay struct {
	Coins      []*ObjectRef
	Recipients []*SuiAddress
	Amounts    []*uint64
}

type PayAllSui

type PayAllSui struct {
	Coins     []*ObjectRef
	Recipient SuiAddress
}

type PaySui

type PaySui = Pay

type ProgrammableMoveCall

type ProgrammableMoveCall struct {
	Package       ObjectID
	Module        move_types.Identifier
	Function      move_types.Identifier
	TypeArguments []move_types.TypeTag
	Arguments     []Argument
}

type ProgrammableTransaction

type ProgrammableTransaction struct {
	Inputs   []CallArg
	Commands []Command
}

type ProgrammableTransactionBuilder

type ProgrammableTransactionBuilder struct {
	Inputs         map[string]CallArg //maybe has hash clash
	InputsKeyOrder []BuilderArg
	Commands       []Command
}

func NewProgrammableTransactionBuilder

func NewProgrammableTransactionBuilder() *ProgrammableTransactionBuilder

func (*ProgrammableTransactionBuilder) Command

func (p *ProgrammableTransactionBuilder) Command(command Command) Argument

func (*ProgrammableTransactionBuilder) Finish

func (*ProgrammableTransactionBuilder) ForceSeparatePure

func (p *ProgrammableTransactionBuilder) ForceSeparatePure(value any) (Argument, error)

func (*ProgrammableTransactionBuilder) Input

func (*ProgrammableTransactionBuilder) MakeObjList

func (p *ProgrammableTransactionBuilder) MakeObjList(objs []ObjectArg) (Argument, error)

func (*ProgrammableTransactionBuilder) MoveCall

func (p *ProgrammableTransactionBuilder) MoveCall(
	packageID ObjectID,
	module move_types.Identifier,
	function move_types.Identifier,
	typeArguments []move_types.TypeTag,
	callArgs []CallArg,
) error

func (*ProgrammableTransactionBuilder) Obj

func (*ProgrammableTransactionBuilder) Pay

func (p *ProgrammableTransactionBuilder) Pay(
	coins []*ObjectRef,
	recipients []SuiAddress,
	amounts []uint64,
) error

func (*ProgrammableTransactionBuilder) PayAllSui

func (p *ProgrammableTransactionBuilder) PayAllSui(recipient SuiAddress) error

func (*ProgrammableTransactionBuilder) PayMulInternal

func (p *ProgrammableTransactionBuilder) PayMulInternal(
	recipients []SuiAddress,
	amounts []uint64, coin Argument,
) error

func (*ProgrammableTransactionBuilder) PaySui

func (p *ProgrammableTransactionBuilder) PaySui(
	recipients []SuiAddress,
	amounts []uint64,
) error

func (*ProgrammableTransactionBuilder) Pure

func (*ProgrammableTransactionBuilder) TransferObject

func (p *ProgrammableTransactionBuilder) TransferObject(
	recipient SuiAddress,
	objectRefs []*ObjectRef,
) error

func (*ProgrammableTransactionBuilder) TransferSui

func (p *ProgrammableTransactionBuilder) TransferSui(recipient SuiAddress, amount *uint64) error

type Secp256k1SuiSignature

type Secp256k1SuiSignature struct {
	Signature []byte //secp256k1.pubKey + Secp256k1Signature + 1
}

type Secp256r1SuiSignature

type Secp256r1SuiSignature struct {
	Signature []byte //secp256k1.pubKey + Secp256k1Signature + 1
}

type SequenceNumber

type SequenceNumber = uint64

type Signable added in v2.0.1

type Signable interface {
	Write(digest hash.Hash)
}

type Signature

func NewSignatureSecure

func NewSignatureSecure[T IntentValue](value IntentMessage[T], secret crypto.Signer[Signature]) (Signature, error)

func (Signature) MarshalJSON

func (s Signature) MarshalJSON() ([]byte, error)

func (*Signature) UnmarshalJSON

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

type SignatureScheme

type SignatureScheme struct {
	ED25519   *lib.EmptyEnum
	Secp256k1 *lib.EmptyEnum
	Secp256r1 *lib.EmptyEnum
	MultiSig  *lib.EmptyEnum
	BLS12381  *lib.EmptyEnum
}

func NewSignatureScheme

func NewSignatureScheme(flag byte) (SignatureScheme, error)

func (*SignatureScheme) Flag

func (s *SignatureScheme) Flag() byte

type SingleTransactionKind

type SingleTransactionKind struct {
	TransferObject *TransferObject
	Publish        *MoveModulePublish
	Call           *MoveCall
	TransferSui    *TransferSui
	Pay            *Pay
	PaySui         *PaySui
	PayAllSui      *PayAllSui
	ChangeEpoch    *ChangeEpoch
	Genesis        *GenesisTransaction
}

func (SingleTransactionKind) IsBcsEnum

func (s SingleTransactionKind) IsBcsEnum()

type SuiAddress

type SuiAddress = move_types.AccountAddress

func NewAddressFromHex

func NewAddressFromHex(str string) (*SuiAddress, error)

type SuiKeyPair

type SuiKeyPair struct {
	Ed25519 *crypto.Ed25519KeyPair
	//Secp256k1 *Secp256k1KeyPair
	//Secp256r1 *Secp256r1KeyPair
	SignatureScheme
}

func NewSuiKeyPair

func NewSuiKeyPair(scheme SignatureScheme, seed []byte) SuiKeyPair

func (*SuiKeyPair) PrivateKey

func (s *SuiKeyPair) PrivateKey() []byte

func (*SuiKeyPair) PublicKey

func (s *SuiKeyPair) PublicKey() []byte

func (*SuiKeyPair) Sign

func (s *SuiKeyPair) Sign(msg []byte) Signature

type TransactionData

type TransactionData struct {
	V1 *TransactionDataV1
}

func NewProgrammable

func NewProgrammable(
	sender SuiAddress,
	gasPayment []*ObjectRef,
	pt ProgrammableTransaction,
	gasBudget uint64,
	gasPrice uint64,
) TransactionData

func NewProgrammableAllowSponsor

func NewProgrammableAllowSponsor(
	sender SuiAddress,
	gasPayment []*ObjectRef,
	pt ProgrammableTransaction,
	gasBudge,
	gasPrice uint64,
	sponsor SuiAddress,
) TransactionData

func (TransactionData) IsBcsEnum

func (t TransactionData) IsBcsEnum()

type TransactionDataV1

type TransactionDataV1 struct {
	Kind       TransactionKind
	Sender     SuiAddress
	GasData    GasData
	Expiration TransactionExpiration
}

type TransactionDigest

type TransactionDigest = Digest

type TransactionEffectsDigest

type TransactionEffectsDigest = Digest

type TransactionEventsDigest

type TransactionEventsDigest = Digest

type TransactionExpiration

type TransactionExpiration struct {
	None  *lib.EmptyEnum
	Epoch *EpochId
}

func (TransactionExpiration) IsBcsEnum

func (t TransactionExpiration) IsBcsEnum()

type TransactionKind

type TransactionKind struct {
	ProgrammableTransaction *ProgrammableTransaction
	ChangeEpoch             *ChangeEpoch
	Genesis                 *GenesisTransaction
	ConsensusCommitPrologue *ConsensusCommitPrologue
}

func (TransactionKind) IsBcsEnum

func (t TransactionKind) IsBcsEnum()

type TransferObject

type TransferObject struct {
	Recipient SuiAddress
	ObjectRef ObjectRef
}

type TransferSui

type TransferSui struct {
	Recipient SuiAddress
	Amount    *uint64 `bcs:"optional"`
}

type TypeOrigin

type TypeOrigin struct {
	ModuleName string
	StructName string
	Package    ObjectID
}

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