signer

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeBlockNumberToAttestTo

func ComputeBlockNumberToAttestTo(
	epochInfo *types.EpochInfo,
	attestWindow uint64,
) types.BlockNumber

func FetchAttestWindow

func FetchAttestWindow[S Signer](ctx context.Context, signer S) (uint64, error)

func FetchBalance added in v0.4.0

func FetchBalance[S Signer](
	ctx context.Context, signer S, address *types.Address,
) (types.Balance, error)

Fetches the STRK balance of any account, using the signer only to perform the call

func FetchEpochAndAttestInfo

func FetchEpochAndAttestInfo[S Signer](
	ctx context.Context, signer S, logger log.Logger,
) (types.EpochInfo, types.AttestInfo, error)

func FetchEpochInfo

func FetchEpochInfo[S Signer](ctx context.Context, signer S) (types.EpochInfo, error)

func HashAndSignTx

func HashAndSignTx(
	ctx context.Context,
	bTx *rpc.BroadcastInvokeTxnV3,
	chainID *felt.Felt,
	externalSignerURL string,
) (signer.Response, error)

func ReadableContractError added in v0.4.0

func ReadableContractError(err error) error

func SignInvokeTx

func SignInvokeTx(
	ctx context.Context,
	invokeTxnV3 *rpc.BroadcastInvokeTxnV3,
	chainID *felt.Felt,
	externalSignerURL string,
) error

Types

type ExternalSigner

type ExternalSigner struct {
	Provider rpc.RPCProvider
	// contains filtered or unexported fields
}

Used as a wrapper around an exgernal signer implementation

func NewExternalSigner

func NewExternalSigner(
	ctx context.Context,
	provider rpc.RPCProvider,
	logger log.Logger,
	sig *config.Signer,
	addresses *config.ContractAddresses,
) (ExternalSigner, error)

func (*ExternalSigner) Address

func (s *ExternalSigner) Address() *types.Address

func (*ExternalSigner) BlockWithTxHashes added in v0.2.4

func (s *ExternalSigner) BlockWithTxHashes(
	ctx context.Context, blockID rpc.BlockID,
) (any, error)

func (*ExternalSigner) BuildAttestTransaction added in v0.2.4

func (s *ExternalSigner) BuildAttestTransaction(
	ctx context.Context,
	blockhash *types.BlockHash,
) (rpc.BroadcastInvokeTxnV3, error)

func (*ExternalSigner) Call added in v0.2.4

func (s *ExternalSigner) Call(
	ctx context.Context, call rpc.FunctionCall, blockID rpc.BlockID,
) ([]*felt.Felt, error)

func (*ExternalSigner) EstimateFee added in v0.2.4

func (s *ExternalSigner) EstimateFee(
	ctx context.Context,
	txn *rpc.BroadcastInvokeTxnV3,
) (rpc.FeeEstimation, error)

func (*ExternalSigner) InvokeTransaction added in v0.2.4

func (*ExternalSigner) Nonce added in v0.2.4

func (s *ExternalSigner) Nonce(ctx context.Context) (*felt.Felt, error)

func (*ExternalSigner) SignTransaction added in v0.2.4

func (s *ExternalSigner) SignTransaction(
	ctx context.Context,
	txn *rpc.BroadcastInvokeTxnV3,
) (*rpc.BroadcastInvokeTxnV3, error)

func (*ExternalSigner) TransactionStatus added in v0.3.0

func (s *ExternalSigner) TransactionStatus(
	ctx context.Context, transactionHash *felt.Felt,
) (
	*rpc.TxnStatusResult, error,
)

func (*ExternalSigner) ValidationContracts

func (s *ExternalSigner) ValidationContracts() *types.ValidationContracts

type InternalSigner

type InternalSigner struct {
	Account account.Account
	// contains filtered or unexported fields
}

func NewInternalSigner

func NewInternalSigner(
	ctx context.Context,
	provider rpc.RPCProvider,
	logger log.Logger,
	signer *config.Signer,
	addresses *config.ContractAddresses,
) (InternalSigner, error)

func (*InternalSigner) Address

func (s *InternalSigner) Address() *types.Address

func (*InternalSigner) BlockWithTxHashes

func (s *InternalSigner) BlockWithTxHashes(
	ctx context.Context, blockID rpc.BlockID,
) (any, error)

func (*InternalSigner) BuildAttestTransaction added in v0.2.4

func (s *InternalSigner) BuildAttestTransaction(
	ctx context.Context,
	blockhash *types.BlockHash,
) (rpc.BroadcastInvokeTxnV3, error)

func (*InternalSigner) Call

func (s *InternalSigner) Call(
	ctx context.Context, call rpc.FunctionCall, blockID rpc.BlockID,
) ([]*felt.Felt, error)

func (*InternalSigner) EstimateFee added in v0.2.4

func (s *InternalSigner) EstimateFee(
	ctx context.Context, txn *rpc.BroadcastInvokeTxnV3,
) (rpc.FeeEstimation, error)

func (*InternalSigner) InvokeTransaction added in v0.2.4

func (*InternalSigner) Nonce added in v0.2.4

func (s *InternalSigner) Nonce(ctx context.Context) (*felt.Felt, error)

func (*InternalSigner) SignTransaction added in v0.2.4

func (s *InternalSigner) SignTransaction(
	ctx context.Context,
	txn *rpc.BroadcastInvokeTxnV3,
) (*rpc.BroadcastInvokeTxnV3, error)

func (*InternalSigner) TransactionStatus added in v0.3.0

func (s *InternalSigner) TransactionStatus(
	ctx context.Context, transactionHash *felt.Felt,
) (
	*rpc.TxnStatusResult, error,
)

func (*InternalSigner) ValidationContracts

func (s *InternalSigner) ValidationContracts() *types.ValidationContracts

type RewardSigner added in v0.4.0

type RewardSigner interface {
	Address() *types.Address
	ClaimRewards(ctx context.Context, tracer metrics.Tracer)
}

RewardSigner is a signer that can claim rewards from the staking contract. It is used for the validator to claim rewards automatically, an optional feature that can be enabled by setting the corresponding flags in the config.

func NewRewardSigner added in v0.4.0

func NewRewardSigner(
	ctx context.Context,
	provider rpc.RPCProvider,
	logger log.Logger,
	rewardConfig *config.Reward,
	contractAddresses *config.ContractAddresses,
	stakerAddress *types.Address,
	isExternal bool,
) (RewardSigner, error)

Creates a new RewardSigner and verifies that the configured reward account is allowed to claim the staker rewards, i.e. it's either the staker address or its reward address. When using an external signer, it also verifies that the signer is able to sign.

type Signer

type Signer interface {
	// Methods from Starknet.go Account implementation
	TransactionStatus(
		ctx context.Context, transactionHash *felt.Felt,
	) (*rpc.TxnStatusResult, error)

	BuildAttestTransaction(
		ctx context.Context, blockHash *types.BlockHash,
	) (rpc.BroadcastInvokeTxnV3, error)
	EstimateFee(ctx context.Context, txn *rpc.BroadcastInvokeTxnV3) (rpc.FeeEstimation, error)
	SignTransaction(
		ctx context.Context, txn *rpc.BroadcastInvokeTxnV3,
	) (*rpc.BroadcastInvokeTxnV3, error)
	InvokeTransaction(
		ctx context.Context, txn *rpc.BroadcastInvokeTxnV3,
	) (rpc.AddInvokeTransactionResponse, error)

	Call(ctx context.Context, call rpc.FunctionCall, blockID rpc.BlockID) ([]*felt.Felt, error)
	BlockWithTxHashes(ctx context.Context, blockID rpc.BlockID) (any, error)

	// Property Access
	Nonce(ctx context.Context) (*felt.Felt, error)
	Address() *types.Address
	ValidationContracts() *types.ValidationContracts
}

Jump to

Keyboard shortcuts

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