transactionbuilder

package
v0.0.0-...-c246823 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: Apache-2.0 Imports: 14 Imported by: 11

Documentation

Index

Constants

View Source
const (
	RAW_TRANSACTION_SALT           = "APTOS::RawTransaction"
	RAW_TRANSACTION_WITH_DATA_SALT = "APTOS::RawTransactionWithData"
)
View Source
const (
	ED25519_PUBLICKEY_LENGTH = 32
	ED25519_SIGNATURE_LENGTH = 64

	MAX_SIGNATURES_SUPPORTED = 32

	MULTI_ED25519_SIGNATURE_BITMAP_LENGTH = 4

	MULTI_ED25519_SCHEME = 0x1
)
View Source
const (
	ADDRESS_LENGTH = 32
)

Variables

This section is empty.

Functions

func BCSSerializeBasicValue

func BCSSerializeBasicValue[T bool | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | string](t T) []byte

func CreateBitmap

func CreateBitmap(bits []uint8) ([]byte, error)

*

  • Helper method to create a bitmap out of the specified bit positions
  • @param bits The bitmap positions that should be set. A position starts at index 0.
  • Valid position should range between 0 and 31.
  • @example
  • Here's an example of valid `bits`
  • ```
  • [0, 2, 31]
  • ```
  • `[0, 2, 31]` means the 1st, 3rd and 32nd bits should be set in the bitmap.
  • The result bitmap should be 0b10100000000000000000000000000001 *
  • @returns bitmap that is 32bit long

func GenerateBCSSimulation

func GenerateBCSSimulation(from ed25519.PublicKey, txn *RawTransaction) ([]byte, error)

func GenerateBCSTransaction

func GenerateBCSTransaction(from *aptosaccount.Account, txn *RawTransaction) ([]byte, error)

func ReverseBytes

func ReverseBytes(b []byte)

Types

type ABIBuilderConfig

type ABIBuilderConfig struct {
	Sender         AccountAddress
	SequenceNumber uint64
	GasUnitPrice   uint64
	MaxGasAmount   uint64
	ExpSecFromNow  uint64
	ChainId        uint8
}

type AccountAddress

type AccountAddress [ADDRESS_LENGTH]byte

func NewAccountAddressFromHex

func NewAccountAddressFromHex(addr string) (*AccountAddress, error)

*

  • Creates AccountAddress 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 (AccountAddress) ToShortString

func (a AccountAddress) ToShortString() string

func (AccountAddress) ToString

func (a AccountAddress) ToString() string

type AccountAuthenticator

type AccountAuthenticator interface{}

type AccountAuthenticatorEd25519

type AccountAuthenticatorEd25519 struct {
	PublicKey Ed25519PublicKey `lcs:"publicKey"`
	Signature Ed25519Signature `lcs:"signature"`
}

type AccountAuthenticatorMultiEd25519

type AccountAuthenticatorMultiEd25519 struct {
	PublicKey MultiEd25519PublicKey `lcs:"publicKey"`
	Signature MultiEd25519Signature `lcs:"signature"`
}

type ArgumentABI

type ArgumentABI struct {
	Name    string  `lcs:"name"`
	TypeTag TypeTag `lcs:"type_tag"`
}

type Ed25519PublicKey

type Ed25519PublicKey struct {
	PublicKey []byte `lcs:"publicKey"`
}

func NewEd25519PublicKey

func NewEd25519PublicKey(publicKey []byte) (*Ed25519PublicKey, error)

type Ed25519Signature

type Ed25519Signature struct {
	Signature []byte `lcs:"signature"`
}

func NewEd25519Signature

func NewEd25519Signature(signature []byte) (*Ed25519Signature, error)

type EntryFunctionABI

type EntryFunctionABI struct {
	Name       string            `lcs:"name"`
	ModuleName ModuleId          `lcs:"module_name"`
	Doc        string            `lcs:"doc"`
	TyArgs     []TypeArgumentABI `lcs:"ty_args"`
	Args       []ArgumentABI     `lcs:"args"`
}

type Identifier

type Identifier string

type Module

type Module struct {
	Code []byte `lcs:"code"`
}

type ModuleId

type ModuleId struct {
	Address AccountAddress `lcs:"address"`
	Name    Identifier     `lcs:"name"`
}

func NewModuleIdFromString

func NewModuleIdFromString(moduleId string) (*ModuleId, error)

type MultiAgentRawTransaction

type MultiAgentRawTransaction struct {
	RawTransaction           RawTransaction   `lcs:"raw_txn"`
	SecondarySignerAddresses []AccountAddress `lcs:"secondary_signer_addresses"`
}

func (*MultiAgentRawTransaction) GetSigningMessage

func (t *MultiAgentRawTransaction) GetSigningMessage() (SigningMessage, error)

type MultiEd25519PublicKey

type MultiEd25519PublicKey struct {
	PublicKeys []Ed25519PublicKey `lcs:"publicKeys"`
	Threshold  uint8              `lcs:"threshold"`
}

func NewMultiEd25519PublicKey

func NewMultiEd25519PublicKey(publicKeys [][]byte, threshold uint8) (*MultiEd25519PublicKey, error)

func (*MultiEd25519PublicKey) Address

func (mp *MultiEd25519PublicKey) Address() string

func (*MultiEd25519PublicKey) AuthenticationKey

func (mp *MultiEd25519PublicKey) AuthenticationKey() [32]byte

func (MultiEd25519PublicKey) MarshalLCS

func (mp MultiEd25519PublicKey) MarshalLCS(e *lcs.Encoder) error

func (*MultiEd25519PublicKey) ToBytes

func (mp *MultiEd25519PublicKey) ToBytes() []byte

func (*MultiEd25519PublicKey) UnmarshalLCS

func (mp *MultiEd25519PublicKey) UnmarshalLCS(d *lcs.Decoder) error

type MultiEd25519Signature

type MultiEd25519Signature struct {
	Signatures []Ed25519Signature
	Bitmap     []byte
}

func NewMultiEd25519Signature

func NewMultiEd25519Signature(signatures [][]byte, bits []uint8) (*MultiEd25519Signature, error)

func (MultiEd25519Signature) MarshalLCS

func (ms MultiEd25519Signature) MarshalLCS(e *lcs.Encoder) error

func (*MultiEd25519Signature) ToBytes

func (ms *MultiEd25519Signature) ToBytes() []byte

func (*MultiEd25519Signature) UnmarshalLCS

func (ms *MultiEd25519Signature) UnmarshalLCS(d *lcs.Decoder) error

type PublicKey

type PublicKey interface{}

type RawTransaction

type RawTransaction struct {
	Sender                  AccountAddress     `lcs:"sender"`
	SequenceNumber          uint64             `lcs:"sequence_number"`
	Payload                 TransactionPayload `lcs:"payload"`
	MaxGasAmount            uint64             `lcs:"max_gas_amount"`
	GasUnitPrice            uint64             `lcs:"gas_unit_price"`
	ExpirationTimestampSecs uint64             `lcs:"expiration_timestamp_secs"`
	ChainId                 uint8              `lcs:"chain_id"`
}

func (*RawTransaction) GetSigningMessage

func (t *RawTransaction) GetSigningMessage() (SigningMessage, error)

type RawTransactionWithData

type RawTransactionWithData interface{}

type RemoteModuleFetcher

type RemoteModuleFetcher interface {
	GetAccountModule(address, moduleName string, version uint64) (*aptostypes.MoveModule, error)
}

type ScriptABI

type ScriptABI interface{}

type Signable

type Signable interface {
	GetSigningMessage() (SigningMessage, error)
}

type Signature

type Signature interface{}

type SignedTransaction

type SignedTransaction struct {
	Transaction   *RawTransaction          `lcs:"transaction"`
	Authenticator TransactionAuthenticator `lcs:"authenticator"`
}

type SigningFunctionEd25519

type SigningFunctionEd25519 func(SigningMessage) []byte

type SigningFunctionMultiEd25519

type SigningFunctionMultiEd25519 func(SigningMessage) MultiEd25519Signature

type SigningMessage

type SigningMessage []byte

type Token

type Token struct {
	Type  string
	Value string
}

type TransactionArgument

type TransactionArgument interface{}

type TransactionArgumentAddress

type TransactionArgumentAddress struct {
	Value AccountAddress `lcs:"value"`
}

type TransactionArgumentBool

type TransactionArgumentBool struct {
	Value bool `lcs:"value"`
}

type TransactionArgumentU128

type TransactionArgumentU128 struct {
	Uint128
}

type TransactionArgumentU64

type TransactionArgumentU64 struct {
	Value uint64 `lcs:"value"`
}

type TransactionArgumentU8

type TransactionArgumentU8 struct {
	Value uint8 `lcs:"value"`
}

type TransactionArgumentU8Vector

type TransactionArgumentU8Vector struct {
	Value []uint8 `lcs:"value"`
}

type TransactionAuthenticator

type TransactionAuthenticator interface{}

type TransactionAuthenticatorEd25519

type TransactionAuthenticatorEd25519 struct {
	PublicKey Ed25519PublicKey `lcs:"publicKey"`
	Signature Ed25519Signature `lcs:"signature"`
}

type TransactionAuthenticatorMultiAgent

type TransactionAuthenticatorMultiAgent struct {
	Sender                   AccountAuthenticator   `lcs:"sender"`
	SecondarySignerAddresses []AccountAddress       `lcs:"secondary_signer_addresses"`
	SecondarySigners         []AccountAuthenticator `lcs:"secondary_signers"`
}

type TransactionAuthenticatorMultiEd25519

type TransactionAuthenticatorMultiEd25519 struct {
	PublicKey MultiEd25519PublicKey `lcs:"publicKey"`
	Signature MultiEd25519Signature `lcs:"signature"`
}

type TransactionBuilderABI

type TransactionBuilderABI struct {
	ABIMap map[string]ScriptABI
}

func NewTransactionBuilderABI

func NewTransactionBuilderABI(abis [][]byte) (*TransactionBuilderABI, error)

func (*TransactionBuilderABI) BuildTransactionPayload

func (tb *TransactionBuilderABI) BuildTransactionPayload(function string, tyTags []string, args []any) (TransactionPayload, error)

type TransactionBuilderEd25519

type TransactionBuilderEd25519 struct {
	SigningFn SigningFunctionEd25519
	PublicKey []byte
}

func NewTransactionBuilderEd25519

func NewTransactionBuilderEd25519(signingFn SigningFunctionEd25519, publicKey []byte) *TransactionBuilderEd25519

func (*TransactionBuilderEd25519) Sign

func (b *TransactionBuilderEd25519) Sign(rawTxn *RawTransaction) (data []byte, err error)

type TransactionBuilderMultiEd25519

type TransactionBuilderMultiEd25519 struct {
	SigningFn SigningFunctionMultiEd25519
	PublicKey MultiEd25519PublicKey
}

func (*TransactionBuilderMultiEd25519) Sign

func (b *TransactionBuilderMultiEd25519) Sign(rawTxn *RawTransaction) (data []byte, err error)

type TransactionBuilderRemoteABI

type TransactionBuilderRemoteABI struct {
	EntryFunctions map[string]aptostypes.MoveFunction
}

------ TransactionBuilderRemoteABI ------

func NewTransactionBuilderRemoteABI

func NewTransactionBuilderRemoteABI(contractAddress, moduleName string, fetcher RemoteModuleFetcher) (*TransactionBuilderRemoteABI, error)

func NewTransactionBuilderRemoteABIWithFunc

func NewTransactionBuilderRemoteABIWithFunc(functionName string, fetcher RemoteModuleFetcher) (*TransactionBuilderRemoteABI, error)

`functionName` is similar "0x1111::moduleName[::funcName]"

func (*TransactionBuilderRemoteABI) BuildTransactionPayload

func (tb *TransactionBuilderRemoteABI) BuildTransactionPayload(function string, tyTags []string, args []any) (TransactionPayload, error)

type TransactionPayload

type TransactionPayload interface{}

type TransactionPayloadEntryFunction

type TransactionPayloadEntryFunction struct {
	ModuleName   ModuleId   `lcs:"module_name"`
	FunctionName Identifier `lcs:"function_name"`
	TyArgs       []TypeTag  `lcs:"ty_args"`
	Args         [][]byte   `lcs:"args"`
}

type TransactionPayloadModuleBundle

type TransactionPayloadModuleBundle struct{}

type TransactionPayloadScript

type TransactionPayloadScript struct {
	Code   []byte                `lcs:"code"`
	TyArgs []TypeTag             `lcs:"ty_args"`
	Args   []TransactionArgument `lcs:"args"`
}

type TransactionScriptABI

type TransactionScriptABI struct {
	Name   string            `lcs:"name"`
	Doc    string            `lcs:"doc"`
	Code   []byte            `lcs:"code"`
	TyArgs []TypeArgumentABI `lcs:"ty_args"`
	Args   []ArgumentABI     `lcs:"args"`
}

type TypeArgumentABI

type TypeArgumentABI struct {
	Name string `lcs:"name"`
}

type TypeTag

type TypeTag interface{}

type TypeTagAddress

type TypeTagAddress struct{}

type TypeTagBool

type TypeTagBool struct{}

type TypeTagParser

type TypeTagParser struct {
	Tokens []Token
}

func NewTypeTagParser

func NewTypeTagParser(tyArg string) (*TypeTagParser, error)

func (*TypeTagParser) ParseTypeTag

func (p *TypeTagParser) ParseTypeTag() (TypeTag, error)

type TypeTagSigner

type TypeTagSigner struct{}

type TypeTagStruct

type TypeTagStruct struct {
	Address    AccountAddress `lcs:"address"`
	ModuleName Identifier     `lcs:"module_name"`
	Name       Identifier     `lcs:"name"`
	TypeArgs   []TypeTag      `lcs:"type_args"`
}

func NewTypeTagStructFromString

func NewTypeTagStructFromString(tag string) (*TypeTagStruct, error)

func (*TypeTagStruct) ShortFunctionName

func (t *TypeTagStruct) ShortFunctionName() string

type TypeTagU128

type TypeTagU128 struct{}

type TypeTagU64

type TypeTagU64 struct{}

type TypeTagU8

type TypeTagU8 struct{}

type TypeTagVector

type TypeTagVector struct {
	Value TypeTag `lcs:"value"`
}

type Uint128

type Uint128 struct{ *big.Int }

func (Uint128) MarshalLCS

func (u Uint128) MarshalLCS(e *lcs.Encoder) error

func (*Uint128) UnmarshalLCS

func (u *Uint128) UnmarshalLCS(d *lcs.Decoder) error

Jump to

Keyboard shortcuts

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