types

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BigToHex

func BigToHex(in *big.Int) string

convert big int to hexidecimal string

func BytesToBig

func BytesToBig(bytes []byte) *big.Int

func ComputeFact

func ComputeFact(programHash *big.Int, programOutputs []*big.Int) *big.Int

compute the keccack fact given the program hash and outputs

func FmtKecBytes

func FmtKecBytes(in *big.Int, rolen int) (buf []byte)

format the bytes in Keccak hash

func GetSelectorFromName

func GetSelectorFromName(funcName string) *big.Int

todo(): this is used by the signer. Should it return a felt?

func GetSelectorFromNameFelt

func GetSelectorFromNameFelt(funcName string) *felt.Felt

func HexToBN

func HexToBN(hexString string) *big.Int

trim "0x" prefix(if exists) and converts hexidecimal string to big int

func HexToBytes

func HexToBytes(hexString string) ([]byte, error)

trim "0x" prefix(if exists) and converts hexidecimal string to byte slice

func HexToShortStr

func HexToShortStr(hexStr string) string

convert hex string to Starknet 'short string'

func Keccak256

func Keccak256(data ...[]byte) []byte

Keccak256 calculates and returns the Keccak256 hash of the input data. (ref: https://github.com/ethereum/go-ethereum/blob/master/crypto/crypto.go)

func MaskBits

func MaskBits(mask, wordSize int, slice []byte) (ret []byte)

mask excess bits

func SNValToBN

func SNValToBN(str string) *big.Int

used in string conversions when interfacing with the APIs

func SplitFactStr

func SplitFactStr(fact string) (fact_low, fact_high string)

split a fact into two felts

func StrToBig

func StrToBig(str string) *big.Int

convert decimal string to big int

func UTF8StrToBig

func UTF8StrToBig(str string) *big.Int

convert utf8 string to big int

Types

type AddDeclareResponse

type AddDeclareResponse struct {
	Code            string `json:"code"`
	TransactionHash string `json:"transaction_hash"`
	ClassHash       string `json:"class_hash"`
}

type AddDeployResponse

type AddDeployResponse struct {
	Code            string `json:"code"`
	TransactionHash string `json:"transaction_hash"`
	ContractAddress string `json:"address"`
}

type AddInvokeTransactionOutput

type AddInvokeTransactionOutput struct {
	TransactionHash *felt.Felt `json:"transaction_hash"`
}

type DeployAccountRequest

type DeployAccountRequest struct {
	MaxFee *big.Int `json:"max_fee"`
	// Version of the transaction scheme, should be set to 0 or 1
	Version *big.Int `json:"version"`
	// Signature
	Signature Signature `json:"signature"`
	// Nonce should only be set with Transaction V1
	Nonce *big.Int `json:"nonce,omitempty"`

	Type                string   `json:"type"`
	ContractAddressSalt string   `json:"contract_address_salt"`
	ConstructorCalldata []string `json:"constructor_calldata"`
	ClassHash           string   `json:"class_hash"`
}

type ExecuteDetails

type ExecuteDetails struct {
	MaxFee *big.Int
	Nonce  *big.Int
}

ExecuteDetails provides some details about the execution.

type FeeEstimate

type FeeEstimate struct {
	// GasConsumed the Ethereum gas cost of the transaction (see https://docs.starknet.io/docs/Fees/fee-mechanism for more info)
	GasConsumed NumAsHex `json:"gas_consumed"`

	// GasPrice the gas price (in gwei) that was used in the cost estimation
	GasPrice NumAsHex `json:"gas_price"`

	// OverallFee the estimated fee for the transaction (in gwei), product of gas_consumed and gas_price
	OverallFee NumAsHex `json:"overall_fee"`
}

type FunctionCall

type FunctionCall struct {
	ContractAddress    *felt.Felt `json:"contract_address"`
	EntryPointSelector *felt.Felt `json:"entry_point_selector,omitempty"`

	// Calldata The parameters passed to the function
	Calldata []*felt.Felt `json:"calldata"`
}

FunctionCall function call information

type FunctionInvoke

type FunctionInvoke struct {
	MaxFee *big.Int `json:"max_fee"`
	// Version of the transaction scheme, should be set to 0 or 1
	Version *big.Int `json:"version"`
	// Signature
	Signature Signature `json:"signature"`
	// Nonce should only be set with Transaction V1
	Nonce *big.Int `json:"nonce,omitempty"`
	// Defines the transaction type to invoke
	Type string `json:"type,omitempty"`

	SenderAddress      *felt.Felt `json:"sender_address"`
	EntryPointSelector string     `json:"entry_point_selector,omitempty"`

	// Calldata The parameters passed to the function
	Calldata []string `json:"calldata"`
}

todo(): what is this used for?

type KeccakState

type KeccakState interface {
	hash.Hash
	Read([]byte) (int, error)
}

KeccakState wraps sha3.state. In addition to the usual hash methods, it also supports Read to get a variable amount of data from the hash state. Read is faster than Sum because it doesn't copy the internal state, but also modifies the internal state.

func NewKeccakState

func NewKeccakState() KeccakState

NewKeccakState creates a new KeccakState (ref: https://github.com/ethereum/go-ethereum/blob/master/crypto/crypto.go)

type NumAsHex

type NumAsHex string

type Signature

type Signature []*big.Int

type TransactionState

type TransactionState string
const (
	TransactionAcceptedOnL1 TransactionState = "ACCEPTED_ON_L1"
	TransactionAcceptedOnL2 TransactionState = "ACCEPTED_ON_L2"
	TransactionNotReceived  TransactionState = "NOT_RECEIVED"
	TransactionPending      TransactionState = "PENDING"
	TransactionReceived     TransactionState = "RECEIVED"
	TransactionRejected     TransactionState = "REJECTED"
)

func (TransactionState) IsTransactionFinal

func (s TransactionState) IsTransactionFinal() bool

func (TransactionState) MarshalJSON

func (ts TransactionState) MarshalJSON() ([]byte, error)

func (TransactionState) String

func (s TransactionState) String() string

func (*TransactionState) UnmarshalJSON

func (ts *TransactionState) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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