gmsui

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxSignerInMultisig = 10
)
View Source
const (
	SuiGasCoinType = "0x2::sui::SUI"
)

Variables

This section is empty.

Functions

func B64PublicKeyToSuiAddress

func B64PublicKeyToSuiAddress(b64 string) (string, error)

func B64ToSuiPrivateKey

func B64ToSuiPrivateKey(b64 string) (string, error)

Utils

func Ed25519PublicKeyToB64PublicKey

func Ed25519PublicKeyToB64PublicKey(ed25519PubKey ed25519.PublicKey) string

func NewSuiMessageWithIntent

func NewSuiMessageWithIntent(message []byte, scope IntentScope) []byte

func NewSuiProvider

func NewSuiProvider(rpc string) (*sdk_client.Client, error)

func NewSuiProviderFromNetwork

func NewSuiProviderFromNetwork(network SuiNetwork) (*sdk_client.Client, error)

Create New Provider

func ParseFunctionTypeArguments

func ParseFunctionTypeArguments(typeArgs []string) (typeArguments []move_types.TypeTag, err error)

func ParseSignatureScheme

func ParseSignatureScheme(scheme byte) string

func SuiPrivateKeyToB64

func SuiPrivateKeyToB64(pk string) (string, error)

func ToSerializedSignature

func ToSerializedSignature(signature, pubKey []byte) string

func VerifyMessage

func VerifyMessage(message, signature string, scope IntentScope) (signer string, pass bool, err error)

func VerifyPersonalMessage

func VerifyPersonalMessage(message string, signature string) (signer string, pass bool, err error)

func VerifyTransactionMessage

func VerifyTransactionMessage(b64Message string, signature string) (signer string, pass bool, err error)

Types

type CompressedSignature

type CompressedSignature struct {
	Signature [65]byte `json:"signature"`
}

type IntentScope

type IntentScope = uint8
const (
	TransactionDataIntentScope IntentScope = 0
	PersonalMessageIntentScope IntentScope = 3
)

type MultiSigPublicKeyStruct

type MultiSigPublicKeyStruct struct {
	PKMap     []PubkeyEnumWeightPair `json:"pk_map"`
	Threshold uint16                 `json:"threshold"`
}

type MultiSigStruct

type MultiSigStruct struct {
	Sigs       []CompressedSignature   `json:"sigs"`
	Bitmap     uint16                  `json:"bitmap"`
	MultisigPK MultiSigPublicKeyStruct `json:"multisig_pk"`
}

type ProgrammableTransactionBlock

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

func (*ProgrammableTransactionBlock) Builder

func (*ProgrammableTransactionBlock) Client

func (ptb *ProgrammableTransactionBlock) Client() *SuiClient

func (*ProgrammableTransactionBlock) Context

func (*ProgrammableTransactionBlock) Finish

func (ptb *ProgrammableTransactionBlock) Finish(sender string, gasObject *string, gasBudget, gasPrice uint64) ([]byte, error)

func (*ProgrammableTransactionBlock) FinishFromMultisig

func (ptb *ProgrammableTransactionBlock) FinishFromMultisig() ([]byte, error)

func (*ProgrammableTransactionBlock) FinishFromSigner

func (ptb *ProgrammableTransactionBlock) FinishFromSigner() ([]byte, error)

func (*ProgrammableTransactionBlock) NewMoveCall

func (ptb *ProgrammableTransactionBlock) NewMoveCall(target string, args []interface{}, typeArgs []string) (*sui_types.Argument, error)

func (*ProgrammableTransactionBlock) ParseFunctionArguments

func (ptb *ProgrammableTransactionBlock) ParseFunctionArguments(target string, args []interface{}) (arguments []sui_types.Argument, err error)

txContext should be nil

type PubkeyEnumWeightPair

type PubkeyEnumWeightPair struct {
	PubKey [33]byte `json:"pub_key"`
	Weight uint8    `json:"weight"`
}

type SignaturePubkeyPair

type SignaturePubkeyPair struct {
	SignatureScheme string
	Signature       []byte
	PubKey          []byte
}

func FromSerializedSignature

func FromSerializedSignature(serializedSignature string) (*SignaturePubkeyPair, error)

type SuiClient

type SuiClient struct {
	Provider  *sdk_client.Client
	SuiSigner *SuiSigner
	MultiSig  *SuiMultiSig
	GasBudget *big.Int
	// contains filtered or unexported fields
}

func InitClient

func InitClient(ctx context.Context, suiApi *sdk_client.Client) *SuiClient

Create New Sui Client

func (*SuiClient) AutoUpdateGas

func (cli *SuiClient) AutoUpdateGas(owner string, gas *SuiGasObject)

func (*SuiClient) Context

func (client *SuiClient) Context() context.Context

func (*SuiClient) DevInspect

func (client *SuiClient) DevInspect(target string, args []interface{}, typeArgs []string) (*types.DevInspectResults, error)

func (*SuiClient) EnableAutoUpdateGasObjectFromMultiSig

func (client *SuiClient) EnableAutoUpdateGasObjectFromMultiSig()

func (*SuiClient) EnableAutoUpdateGasObjectFromSigner

func (client *SuiClient) EnableAutoUpdateGasObjectFromSigner()

func (*SuiClient) ExecuteTransaction

func (client *SuiClient) ExecuteTransaction(b64TxBytes string, signatures []any) (*types.SuiTransactionBlockResponse, error)

func (*SuiClient) GetAllCoins

func (client *SuiClient) GetAllCoins(owner string, coinType string) (data []types.Coin, err error)

Instance Get All Sui Coins

func (*SuiClient) GetCoins

func (client *SuiClient) GetCoins(owner, coinType string, nextCursor *move_types.AccountAddress) (ret *types.Page[types.Coin, move_types.AccountAddress], err error)

func (*SuiClient) GetFunctionArgumentTypes

func (client *SuiClient) GetFunctionArgumentTypes(target string) ([]interface{}, error)

func (*SuiClient) GetMaxCoinObject

func (cli *SuiClient) GetMaxCoinObject(address, coinType string) (*types.Coin, error)

func (*SuiClient) GetObject

func (client *SuiClient) GetObject(objectId string) (*types.SuiObjectResponse, error)

GET OBJECT/MULTI_OBJECTS

func (*SuiClient) GetObjects

func (client *SuiClient) GetObjects(objectIds []string) ([]types.SuiObjectResponse, error)

func (*SuiClient) ImplementationOfDevInspect

func (client *SuiClient) ImplementationOfDevInspect(txBytes string) (*types.DevInspectResults, error)

func (*SuiClient) MoveCallFromSigner

func (client *SuiClient) MoveCallFromSigner(target string, args []interface{}, typeArgs []string) (result *types.SuiTransactionBlockResponse, err error)

func (*SuiClient) NewMoveCall

func (client *SuiClient) NewMoveCall(signer, gas, target string, args []interface{}, typeArgs []string) (*types.TransactionBytes, error)

Instance: Move Call

func (*SuiClient) NewMoveCallFromMultiSig

func (client *SuiClient) NewMoveCallFromMultiSig(target string, args []interface{}, typeArgs []string) (*types.TransactionBytes, error)

func (*SuiClient) NewMoveCallFromSigner

func (client *SuiClient) NewMoveCallFromSigner(target string, args []interface{}, typeArgs []string) (*types.TransactionBytes, error)

func (*SuiClient) NewMultiSig

func (client *SuiClient) NewMultiSig(multisig *SuiMultiSig)

func (*SuiClient) NewProgrammableTransactionBlock

func (client *SuiClient) NewProgrammableTransactionBlock(ctx context.Context) *ProgrammableTransactionBlock

func (*SuiClient) NewSigner

func (client *SuiClient) NewSigner(signer *SuiSigner)

func (*SuiClient) SetDefaultGasBudget

func (client *SuiClient) SetDefaultGasBudget(budget *big.Int)

func (*SuiClient) SetDefaultGasObjectToMultiSig

func (client *SuiClient) SetDefaultGasObjectToMultiSig(obj string)

func (*SuiClient) SetDefaultGasObjectToSigner

func (client *SuiClient) SetDefaultGasObjectToSigner(obj string)

Tools

type SuiGasObject

type SuiGasObject struct {
	Live    string
	Pending []string
}

type SuiMultiSig

type SuiMultiSig struct {
	Threshold    uint16
	Address      string
	PublicKeyMap []SuiPubkeyWeightPair
	Gas          *SuiGasObject
}

func NewSuiMultiSig

func NewSuiMultiSig(pubKeys []string, weights []uint8, threshold uint16) (*SuiMultiSig, error)

func (*SuiMultiSig) CombineSignatures

func (m *SuiMultiSig) CombineSignatures(signatures []string) (string, error)

func (*SuiMultiSig) Info

func (m *SuiMultiSig) Info() *SuiMultiSigInfo

func (*SuiMultiSig) ToMultiSigAddress

func (m *SuiMultiSig) ToMultiSigAddress() (string, error)

type SuiMultiSigInfo

type SuiMultiSigInfo struct {
	Address   string
	Threshold uint16
	Signers   []SuiMultiSigInfoSigner
}

type SuiMultiSigInfoSigner

type SuiMultiSigInfoSigner struct {
	Address      string
	B64PublicKey string
	HexPublicKey string
	Weight       uint8
}

type SuiNetwork

type SuiNetwork = string
var (
	MainnetFullNode SuiNetwork = "https://fullnode.mainnet.sui.io:443/"
	TestnetFullNode SuiNetwork = "https://fullnode.testnet.sui.io:443/"
	DevnetFullNode  SuiNetwork = "https://fullnode.devnet.sui.io:443/"
)

type SuiPubkeyWeightPair

type SuiPubkeyWeightPair struct {
	PublicKey string
	Weight    uint8
}

type SuiSignedDataRet

type SuiSignedDataRet struct {
	TxBytes   string `json:"tx_bytes"`
	Signature string `json:"signature"`
}

type SuiSignedMessageRet

type SuiSignedMessageRet = SuiSignedDataRet

type SuiSignedTransactionRet

type SuiSignedTransactionRet = SuiSignedDataRet

type SuiSigner

type SuiSigner struct {
	Signer *account.Account
	Gas    *SuiGasObject
}

func NewSuiSignerFromBase64PrivateKey

func NewSuiSignerFromBase64PrivateKey(b64PriKey string) (*SuiSigner, error)

Create New Signer

func NewSuiSignerFromMnemonic

func NewSuiSignerFromMnemonic(mnemonic string, derivePath string) (*SuiSigner, error)

func NewSuiSignerFromPrivateKey

func NewSuiSignerFromPrivateKey(priKey string) (*SuiSigner, error)

func NewSuiSignerFromSeed

func NewSuiSignerFromSeed(seed []byte) *SuiSigner

func (*SuiSigner) GetAddress

func (s *SuiSigner) GetAddress() string

func (*SuiSigner) GetPulbicKey

func (s *SuiSigner) GetPulbicKey() string

Instance Function

func (*SuiSigner) SignMessage

func (s *SuiSigner) SignMessage(data string, scope IntentScope) (*SuiSignedDataRet, error)

func (*SuiSigner) SignMessageBytes

func (s *SuiSigner) SignMessageBytes(data []byte) (*SuiSignedDataRet, error)

func (*SuiSigner) SignPersonalMessage

func (s *SuiSigner) SignPersonalMessage(message string) (*SuiSignedMessageRet, error)

func (*SuiSigner) SignTransaction

func (s *SuiSigner) SignTransaction(b64TxBytes string) (*SuiSignedTransactionRet, error)

Jump to

Keyboard shortcuts

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