account

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: MIT Imports: 12 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotAllParametersSet   = errors.New("Not all neccessary parameters have been set")
	ErrTxnTypeUnSupported    = errors.New("Unsupported transction type")
	ErrTxnVersionUnSupported = errors.New("Unsupported transction version")
	ErrFeltToBigInt          = errors.New("Felt to BigInt error")
)
View Source
var (
	PREFIX_TRANSACTION      = new(felt.Felt).SetBytes([]byte("invoke"))
	PREFIX_DECLARE          = new(felt.Felt).SetBytes([]byte("declare"))
	PREFIX_CONTRACT_ADDRESS = new(felt.Felt).SetBytes([]byte("STARKNET_CONTRACT_ADDRESS"))
	PREFIX_DEPLOY_ACCOUNT   = new(felt.Felt).SetBytes([]byte("deploy_account"))
)
View Source
var ErrSenderNoExist = errors.New("sender does not exist")

Functions

func FmtCalldataCairo0

func FmtCalldataCairo0(fnCalls []rpc.FunctionCall) []*felt.Felt

Formats the call data for Cairo0 contracts

func FmtCalldataCairo2

func FmtCalldataCairo2(fnCalls []rpc.FunctionCall) []*felt.Felt

Formats the call data for Cairo 2 contracs

Types

type Account

type Account struct {
	ChainId        *felt.Felt
	AccountAddress *felt.Felt
	// contains filtered or unexported fields
}

func NewAccount

func NewAccount(provider rpc.RpcProvider, accountAddress *felt.Felt, publicKey string, keystore Keystore) (*Account, error)

func (*Account) AddDeclareTransaction

func (account *Account) AddDeclareTransaction(ctx context.Context, declareTransaction rpc.AddDeclareTxnInput) (*rpc.AddDeclareTransactionResponse, error)

func (*Account) AddDeployAccountTransaction

func (account *Account) AddDeployAccountTransaction(ctx context.Context, deployAccountTransaction rpc.DeployAccountTxn) (*rpc.AddDeployAccountTransactionResponse, error)

func (*Account) AddInvokeTransaction

func (account *Account) AddInvokeTransaction(ctx context.Context, invokeTx rpc.InvokeTxnV1) (*rpc.AddInvokeTransactionResponse, error)

func (*Account) BlockHashAndNumber

func (account *Account) BlockHashAndNumber(ctx context.Context) (*rpc.BlockHashAndNumberOutput, error)

func (*Account) BlockNumber

func (account *Account) BlockNumber(ctx context.Context) (uint64, error)

func (*Account) BlockTransactionCount

func (account *Account) BlockTransactionCount(ctx context.Context, blockID rpc.BlockID) (uint64, error)

func (*Account) BlockWithTxHashes

func (account *Account) BlockWithTxHashes(ctx context.Context, blockID rpc.BlockID) (interface{}, error)

func (*Account) BlockWithTxs

func (account *Account) BlockWithTxs(ctx context.Context, blockID rpc.BlockID) (interface{}, error)

func (*Account) Call

func (account *Account) Call(ctx context.Context, call rpc.FunctionCall, blockId rpc.BlockID) ([]*felt.Felt, error)

func (*Account) ChainID

func (account *Account) ChainID(ctx context.Context) (string, error)

func (*Account) Class

func (account *Account) Class(ctx context.Context, blockID rpc.BlockID, classHash *felt.Felt) (rpc.ClassOutput, error)

func (*Account) ClassAt

func (account *Account) ClassAt(ctx context.Context, blockID rpc.BlockID, contractAddress *felt.Felt) (rpc.ClassOutput, error)

func (*Account) ClassHashAt

func (account *Account) ClassHashAt(ctx context.Context, blockID rpc.BlockID, contractAddress *felt.Felt) (*felt.Felt, error)

func (*Account) EstimateFee

func (account *Account) EstimateFee(ctx context.Context, requests []rpc.EstimateFeeInput, blockID rpc.BlockID) ([]rpc.FeeEstimate, error)

func (*Account) EstimateMessageFee

func (account *Account) EstimateMessageFee(ctx context.Context, msg rpc.MsgFromL1, blockID rpc.BlockID) (*rpc.FeeEstimate, error)

func (*Account) Events

func (account *Account) Events(ctx context.Context, input rpc.EventsInput) (*rpc.EventChunk, error)

func (*Account) FmtCalldata

func (account *Account) FmtCalldata(fnCalls []rpc.FunctionCall, cairoVersion int) ([]*felt.Felt, error)

func (*Account) Nonce

func (account *Account) Nonce(ctx context.Context, blockID rpc.BlockID, contractAddress *felt.Felt) (*string, error)

func (*Account) PrecomputeAddress

func (account *Account) PrecomputeAddress(deployerAddress *felt.Felt, salt *felt.Felt, classHash *felt.Felt, constructorCalldata []*felt.Felt) (*felt.Felt, error)

precomputeAddress precomputes the accounts address ref: https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/core/os/contract_address/contract_address.py

func (*Account) Sign

func (account *Account) Sign(ctx context.Context, msg *felt.Felt) ([]*felt.Felt, error)

func (*Account) SignDeclareTransaction

func (account *Account) SignDeclareTransaction(ctx context.Context, tx *rpc.DeclareTxnV2) error

func (*Account) SignDeployAccountTransaction

func (account *Account) SignDeployAccountTransaction(ctx context.Context, tx *rpc.DeployAccountTxn, precomputeAddress *felt.Felt) error

func (*Account) SignInvokeTransaction

func (account *Account) SignInvokeTransaction(ctx context.Context, invokeTx *rpc.InvokeTxnV1) error

func (*Account) SimulateTransactions

func (account *Account) SimulateTransactions(ctx context.Context, blockID rpc.BlockID, txns []rpc.Transaction, simulationFlags []rpc.SimulationFlag) ([]rpc.SimulatedTransaction, error)

func (*Account) StateUpdate

func (account *Account) StateUpdate(ctx context.Context, blockID rpc.BlockID) (*rpc.StateUpdateOutput, error)

func (*Account) StorageAt

func (account *Account) StorageAt(ctx context.Context, contractAddress *felt.Felt, key string, blockID rpc.BlockID) (string, error)

func (*Account) Syncing

func (account *Account) Syncing(ctx context.Context) (*rpc.SyncStatus, error)

func (*Account) TraceBlockTransactions

func (account *Account) TraceBlockTransactions(ctx context.Context, blockHash *felt.Felt) ([]rpc.Trace, error)

func (*Account) TransactionByBlockIdAndIndex

func (account *Account) TransactionByBlockIdAndIndex(ctx context.Context, blockID rpc.BlockID, index uint64) (rpc.Transaction, error)

func (*Account) TransactionByHash

func (account *Account) TransactionByHash(ctx context.Context, hash *felt.Felt) (rpc.Transaction, error)

func (*Account) TransactionHashDeclare

func (account *Account) TransactionHashDeclare(tx rpc.DeclareTxnType) (*felt.Felt, error)

func (*Account) TransactionHashDeployAccount

func (account *Account) TransactionHashDeployAccount(tx rpc.DeployAccountTxn, contractAddress *felt.Felt) (*felt.Felt, error)

TransactionHashDeployAccount computes the transaction hash for deployAccount transactions

func (*Account) TransactionHashInvoke

func (account *Account) TransactionHashInvoke(tx rpc.InvokeTxnType) (*felt.Felt, error)

func (*Account) TransactionReceipt

func (account *Account) TransactionReceipt(ctx context.Context, transactionHash *felt.Felt) (rpc.TransactionReceipt, error)

func (*Account) TransactionTrace

func (account *Account) TransactionTrace(ctx context.Context, transactionHash *felt.Felt) (rpc.TxnTrace, error)

func (*Account) WaitForTransactionReceipt

func (account *Account) WaitForTransactionReceipt(ctx context.Context, transactionHash *felt.Felt, pollInterval time.Duration) (*rpc.TransactionReceipt, error)

WaitForTransactionReceipt waits for the transaction to succeed or fail

type AccountInterface

type AccountInterface interface {
	Sign(ctx context.Context, msg *felt.Felt) ([]*felt.Felt, error)
	TransactionHashInvoke(invokeTxn rpc.InvokeTxnType) (*felt.Felt, error)
	TransactionHashDeployAccount(tx rpc.DeployAccountTxn, contractAddress *felt.Felt) (*felt.Felt, error)
	TransactionHashDeclare(tx rpc.DeclareTxnType) (*felt.Felt, error)
	SignInvokeTransaction(ctx context.Context, tx *rpc.InvokeTxnV1) error
	SignDeployAccountTransaction(ctx context.Context, tx *rpc.DeployAccountTxn, precomputeAddress *felt.Felt) error
	SignDeclareTransaction(ctx context.Context, tx *rpc.DeclareTxnV2) error
	PrecomputeAddress(deployerAddress *felt.Felt, salt *felt.Felt, classHash *felt.Felt, constructorCalldata []*felt.Felt) (*felt.Felt, error)
	WaitForTransactionReceipt(ctx context.Context, transactionHash *felt.Felt, pollInterval time.Duration) (*rpc.TransactionReceipt, error)
}

type Keystore

type Keystore interface {
	Sign(ctx context.Context, id string, msgHash *big.Int) (x *big.Int, y *big.Int, err error)
}

type MemKeystore

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

MemKeystore implements the Keystore interface and is intended for example and test code.

func GetRandomKeys

func GetRandomKeys() (*MemKeystore, *felt.Felt, *felt.Felt)

GetRandomKeys gets a random set of pub-priv keys. Note: This should be used for testing purposes only, do NOT send real funds to these addresses.

func NewMemKeystore

func NewMemKeystore() *MemKeystore

func SetNewMemKeystore

func SetNewMemKeystore(pub string, priv *big.Int) *MemKeystore

func (*MemKeystore) Get

func (ks *MemKeystore) Get(senderAddress string) (*big.Int, error)

func (*MemKeystore) Put

func (ks *MemKeystore) Put(senderAddress string, k *big.Int)

func (*MemKeystore) Sign

func (ks *MemKeystore) Sign(ctx context.Context, id string, msgHash *big.Int) (*big.Int, *big.Int, error)

Jump to

Keyboard shortcuts

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