massalib

package module
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: MIT Imports: 19 Imported by: 0

README

massalib

Simple library for massa related operations: address check and generation, transaction parsing, etc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeProtobufVarint

func DecodeProtobufVarint(buf []byte) (result uint64, buflen int, err error)

DecodeProtobufVarint decodes a varint encoded following protobuf conventions

func EncodeProtobufVarint

func EncodeProtobufVarint(x uint64) []byte

EncodeProtobufVarint encodes the given integer using protobuf conventions

func ReadProtobufVarint

func ReadProtobufVarint(r bytereader) (uint64, int64, error)

Types

type Address

type Address struct {
	Category uint64 // 0 for User, 1 for Smart contract
	Version  uint64
	Hash     []byte // Underlying blake3 hash
}

func DecodeAddress added in v0.0.4

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

func (*Address) Bytes

func (a *Address) Bytes() []byte

Bytes encodes the address in massa byte format

func (*Address) MarshalBinary

func (a *Address) MarshalBinary() ([]byte, error)

MarshalBinary encodes the address in massa byte format (for compatibility)

func (*Address) ReadFrom

func (a *Address) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads a binary address from a given source, which is made of two varint (category, version) followed by 32 bytes of hash

func (*Address) SetValue

func (a *Address) SetValue(in []byte)

SetValue computes the hash of the provided buffer and sets it as address Hash

func (*Address) String

func (a *Address) String() string

String encodes the address as a string following encoding conventions

func (*Address) Thread

func (a *Address) Thread() byte

type Amount

type Amount uint64

func (Amount) Bytes

func (a Amount) Bytes() []byte

func (*Amount) ReadFrom

func (a *Amount) ReadFrom(r io.Reader) (int64, error)

type BodyCallSC

type BodyCallSC struct {
	MaxGas   uint64
	MaxCoins Amount
	Target   *Address
	Function string // Name of the function to call encoded as UTF-8 string without null termination
	Param    []byte
}

type BodyExecuteSC

type BodyExecuteSC struct {
	MaxGas    uint64
	MaxCoins  Amount
	Bytecode  []byte           // Raw bytes of bytecode to execute (up to 10MB)
	Datastore []*DataStoreItem // Concatenated datastore items. (keyval, keys up to
}

type BodyRollBuy

type BodyRollBuy struct {
	Rolls uint64
}

type BodyRollSell

type BodyRollSell struct {
	Rolls uint64
}

type BodyTransaction

type BodyTransaction struct {
	Destination *Address
	Amount      Amount
}

func (*BodyTransaction) Bytes

func (tx *BodyTransaction) Bytes() []byte

func (*BodyTransaction) ReadFrom

func (tx *BodyTransaction) ReadFrom(r io.Reader) (int64, error)

func (*BodyTransaction) Type

func (tx *BodyTransaction) Type() OperationType

func (*BodyTransaction) UnmarshalBinary

func (tx *BodyTransaction) UnmarshalBinary(buf []byte) error

type ChainId

type ChainId uint64
const (
	MainNet   ChainId = 77658377
	BuildNet  ChainId = 77658366
	SecureNet ChainId = 77658383
	LabNet    ChainId = 77658376
	Sandbox   ChainId = 77
)

func (ChainId) AppendBinary added in v0.0.5

func (c ChainId) AppendBinary(b []byte) ([]byte, error)

func (ChainId) Bytes added in v0.0.5

func (c ChainId) Bytes() []byte

type DataStoreItem

type DataStoreItem struct {
	Key   []byte
	Value []byte
}

type Operation

type Operation struct {
	Fee    Amount
	Expire uint64 // expire_period, typically current period + 10
	Body   OperationBody
}

func (*Operation) Bytes

func (o *Operation) Bytes() []byte

Bytes returns a binary representation of the operation

func (*Operation) Hash added in v0.0.5

func (o *Operation) Hash(chainId ChainId, pubKey ed25519.PublicKey) []byte

Hash returns the operation contents hash

func (*Operation) ReadFrom

func (o *Operation) ReadFrom(r io.Reader) (int64, error)

func (*Operation) Sign added in v0.0.5

func (o *Operation) Sign(chainId ChainId, key crypto.Signer) ([]byte, error)

Sign signs the given operation and returns a serialized operation

func (*Operation) UnmarshalBinary

func (o *Operation) UnmarshalBinary(b []byte) error

type OperationBody

type OperationBody interface {
	Bytes() []byte
	UnmarshalBinary(data []byte) error
	Type() OperationType
	ReadFrom(r io.Reader) (int64, error)
}

type OperationType

type OperationType uint32
const (
	OpTransaction OperationType = iota // 0
	OpRollBuy                          // 1
	OpRollSell                         // 2
	OpExecuteSC                        // 3
	OpCallSC                           // 4
)

type PublicKey

type PublicKey struct {
	Version uint64
	PubKey  ed25519.PublicKey
}

func (*PublicKey) AsAddress added in v0.0.9

func (pk *PublicKey) AsAddress() *Address

func (*PublicKey) Bytes

func (pk *PublicKey) Bytes() []byte

func (*PublicKey) MarshalBinary

func (pk *PublicKey) MarshalBinary() ([]byte, error)

func (*PublicKey) MarshalText

func (pk *PublicKey) MarshalText() (text []byte, err error)

func (*PublicKey) String

func (pk *PublicKey) String() string

func (*PublicKey) UnmarshalText

func (pk *PublicKey) UnmarshalText(text []byte) error

type RPC added in v0.0.2

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

func New added in v0.0.2

func New(target string, opts ...grpc.DialOption) (*RPC, error)

New returns a new connection to a massa node

grpc://localhost:33037

func (*RPC) GetSlotTransfers added in v0.0.3

func (rpc *RPC) GetSlotTransfers(ctx context.Context, finality massagrpc.FinalityLevel) (chan *massagrpc.NewSlotTransfersResponse, io.Closer, error)

func (*RPC) GetStatus added in v0.0.2

func (rpc *RPC) GetStatus(ctx context.Context) (*massagrpc.PublicStatus, error)

GetStatus returns the status of the node

func (*RPC) Public added in v0.0.2

func (rpc *RPC) Public() massagrpc.PublicServiceClient

Public exposes the raw grpc public interface

func (*RPC) SendOperations added in v0.0.7

func (rpc *RPC) SendOperations(ctx context.Context, op ...[]byte) ([]string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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