zksync

package
v0.0.0-...-d7b061b Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package zksync implements transfer operation on ZkSync network.

Index

Constants

View Source
const EtherSignMessage = "\x19Ethereum Signed Message:\n"
View Source
const ZkSyncMessage = "Access zkSync account.\n\nOnly sign this message for a trusted client!"

Variables

This section is empty.

Functions

func TxStateFromZkStatus

func TxStateFromZkStatus(status TxStatus) pipelinedb.TxState

Types

type AccountInfo

type AccountInfo struct {
	ID        int64
	Address   string
	Committed AccountState
	Verified  AccountState
}

type AccountState

type AccountState struct {
	Balances map[string]string
	Nonce    uint64
}

type Auditor

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

func NewAuditor

func NewAuditor(
	url string,
	chainID int) (*Auditor, error)

func (Auditor) CheckConfirmedTransactionState

func (a Auditor) CheckConfirmedTransactionState(ctx context.Context, hash string) (pipelinedb.TxState, error)

func (Auditor) CheckTransactionState

func (a Auditor) CheckTransactionState(ctx context.Context, hash string) (pipelinedb.TxState, error)

type BlockStatus

type BlockStatus struct {
	Committed   bool
	Verified    bool
	BlockNumber int
}

type Payer

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

func NewPayer

func NewPayer(
	ctx context.Context,
	url string,
	key *ecdsa.PrivateKey,
	chainID int,
	withdraw bool,
	maxFee *big.Int) (*Payer, error)

func (Payer) CheckNonceGroup

func (z Payer) CheckNonceGroup(ctx context.Context, log *zap.Logger, nonceGroup *pipelinedb.NonceGroup, checkOnly bool) (pipelinedb.TxState, []*pipelinedb.TxStatus, error)

func (Payer) CheckPreconditions

func (z Payer) CheckPreconditions(ctx context.Context) ([]string, error)

func (Payer) CreateRawTransaction

func (z Payer) CreateRawTransaction(ctx context.Context, log *zap.Logger, payouts []*pipelinedb.Payout, nonce uint64, storjPrice decimal.Decimal) (tx payer.Transaction, from common.Address, err error)

func (Payer) GetTokenBalance

func (z Payer) GetTokenBalance(ctx context.Context) (*big.Int, error)

func (Payer) GetTokenDecimals

func (z Payer) GetTokenDecimals(ctx context.Context) (int32, error)

func (Payer) NextNonce

func (z Payer) NextNonce(ctx context.Context) (uint64, error)

func (Payer) PrintEstimate

func (z Payer) PrintEstimate(ctx context.Context, remaining int64) error

func (Payer) SendTransaction

func (z Payer) SendTransaction(ctx context.Context, log *zap.Logger, t payer.Transaction) error

func (Payer) TxTypeString

func (z Payer) TxTypeString() string

type Signature

type Signature struct {
	Type      string `json:"type"`
	Signature string `json:"signature"`
}

type Token

type Token struct {
	Symbol   string
	Decimals int32
	ID       int
}

func (*Token) Format

func (t *Token) Format(value *big.Int) string

func (Token) MarshalJSON

func (t Token) MarshalJSON() ([]byte, error)

type Tx

type Tx struct {
	Type      string         `json:"type"`
	AccountID int            `json:"accountId"`
	From      common.Address `json:"from"`
	To        common.Address `json:"to"`
	Token     Token          `json:"token"`
	Amount    *big.Int       `json:"amount"`
	Fee       *big.Int       `json:"fee"`
	Nonce     int            `json:"nonce"`
	Signature TxSignature    `json:"signature"`
}

func (Tx) GetTypeID

func (tx Tx) GetTypeID() byte

GetTypeID returns with the internal byte representation of the transaction type (or 0 if unsupported).

func (Tx) Hash

func (tx Tx) Hash() (string, error)

Hash returns with the tx hash calculated from the struct values.

type TxSignature

type TxSignature struct {
	PubKey    string `json:"pubKey"`
	Signature string `json:"signature"`
}

type TxStatus

type TxStatus struct {
	Executed bool
	Success  bool
	Block    BlockStatus
}

type TxWithEthSignature

type TxWithEthSignature struct {
	Tx        Tx
	Signature Signature
}

type ZkClient

type ZkClient struct {
	ChainID int
	// contains filtered or unexported fields
}

func NewZkClient

func NewZkClient(pk *ecdsa.PrivateKey, url string) (ZkClient, error)

func (*ZkClient) Address

func (c *ZkClient) Address() (common.Address, error)

func (*ZkClient) CreateTransferTx

func (c *ZkClient) CreateTransferTx(ctx context.Context, to common.Address, amount *big.Int, fee *big.Int, token Token, nonce int) (TxWithEthSignature, error)

func (*ZkClient) CreateTx

func (c *ZkClient) CreateTx(ctx context.Context, txType string, to common.Address, amount *big.Int, fee *big.Int, token Token, nonce int) (TxWithEthSignature, error)

func (*ZkClient) GetBalance

func (c *ZkClient) GetBalance(ctx context.Context, instrument string) (*big.Int, error)

func (*ZkClient) GetFee

func (c *ZkClient) GetFee(ctx context.Context, txType string, address string, instrument string) (*big.Int, error)

func (*ZkClient) GetNonce

func (c *ZkClient) GetNonce(ctx context.Context) (uint64, error)

func (*ZkClient) GetToken

func (c *ZkClient) GetToken(ctx context.Context, symbol string) (Token, error)

func (*ZkClient) SubmitTransaction

func (c *ZkClient) SubmitTransaction(ctx context.Context, txs TxWithEthSignature) (string, error)

func (*ZkClient) Transfer

func (c *ZkClient) Transfer(ctx context.Context, to common.Address, amount *big.Int, fee *big.Int, token Token) (string, error)

func (*ZkClient) TxStatus

func (c *ZkClient) TxStatus(ctx context.Context, txHash string) (TxStatus, error)

Jump to

Keyboard shortcuts

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