Documentation ¶
Index ¶
- Constants
- func AddNewLeafOpt(ethAddress string, tokenId, accountId uint64, amount string, chainAddr string) []*types.KeyValue
- func BuildHistoryAccountByProof(db dbm.KV, proofId uint64, reqRootHash string, feeAddrs *zt.ZkFeeAddrs) (*zt.HistoryAccountProofInfo, error)
- func BuildStateDbHistoryAccount(db dbm.KV, reqRootHash string) (*zt.HistoryAccountProofInfo, error)
- func CalcLatestAccountIDKey() []byte
- func CalcNewAccountIDkv(accounID int64) *types.KeyValue
- func GetAccountIdPrimaryKey(accountId uint64) []byte
- func GetAccountIdPrimaryKeyPrefix() string
- func GetAccountTreeKey() []byte
- func GetAmountWithFee(db dbm.KV, actionTy int32, amount string, tokenId uint64) (amountPlusFee, fee string, err error)
- func GetChainEthPrimaryKey(chainAddr string, ethAddr string) []byte
- func GetFeeData(db dbm.KV, actionTy int32, tokenId uint64) (*zt.ZkFee, error)
- func GetHistoryAccountProof(historyAccountInfo *zt.HistoryAccountProofInfo, ...) (*zt.ZkProofWitness, error)
- func GetL2FirstQueueId(db dbm.KV) (int64, error)
- func GetL2LastQueueId(db dbm.KV) (int64, error)
- func GetL2QueueIdOp(db dbm.KV, id int64) (*zt.ZkOperation, error)
- func GetLeafByAccountId(db dbm.KV, accountId uint64) (*zt.Leaf, error)
- func GetLeafByChainAddress(db dbm.KV, chainAddr string) ([]*zt.Leaf, error)
- func GetLeafByChainAndEthAddress(db dbm.KV, chainAddr, ethAddress string) (*zt.Leaf, error)
- func GetLeafByEthAddress(db dbm.KV, ethAddress string) ([]*zt.Leaf, error)
- func GetLocalChainEthPrimaryKey(chainAddr string, ethAddr string) []byte
- func GetNFTHashPrimaryKey(nftHash string) []byte
- func GetNFTIdPrimaryKey(nftTokenId uint64) []byte
- func GetName() string
- func GetPriority2QueueId(db dbm.KV, priorityId int64) (int64, error)
- func GetPriorityDepositData(db dbm.KV, priorityId int64) (*zt.ZkDepositWitnessInfo, error)
- func GetProofId2QueueId(db dbm.KV, id uint64) (*zt.ProofId2QueueIdData, error)
- func GetRootIndexPrimaryKey(rootIndex uint64) []byte
- func GetTokenByAccountIdAndTokenId(db dbm.KV, accountId uint64, tokenId uint64) (*zt.TokenBalance, error)
- func GetTokenByAccountIdAndTokenIdInDB(db dbm.KV, accountId uint64, tokenId uint64) (*zt.TokenBalance, error)
- func GetTokenBySymbol(db dbm.KV, symbol string) (*zt.ZkTokenSymbol, error)
- func GetTokenByTokenId(db dbm.KV, tokenId string) (*zt.ZkTokenSymbol, error)
- func GetTokenPrimaryKey(accountId uint64, tokenId uint64) []byte
- func GetTokenPrimaryKeyPrefix() string
- func GetTokenSymbolIdKey(symbol string) []byte
- func GetTokenSymbolKey(tokenId string) []byte
- func GetTreeSideAmount(amount, totalAmount, fee string, sysDecimal, tokenDecimal int) (amount4Tree, totalAmount4Tree, feeAmount4Tree string, err error)
- func Init(name string, cfg *types.ChainConfig, sub []byte)
- func InitExecType()
- func MakeSetTokenSymbolReceipt(id string, oldVal, newVal *zt.ZkTokenSymbol) *types.Receipt
- func NewAccountTreeTable(kvdb db.KV) *table.Table
- func NewCommitProofTable(kvdb db.KV) *table.Table
- func NewInitAccount(ethFeeAddr, chainFeeAddr string) ([]*types.KeyValue, error)
- func NewZksync() drivers.Driver
- func NewZksyncInfoTable(kvdb db.KV) *table.Table
- func TransferDecimalAmount(amount string, fromDecimal, toDecimal int) (string, error)
- func UpdatePubKey(statedb dbm.KV, localdb dbm.KV, pubKeyTy uint64, pubKey *zt.ZkPubKey, ...) ([]*types.KeyValue, []*types.KeyValue, error)
- type AccountTreeRow
- type Action
- func (a *Action) AssetTransfer(transfer *types.AssetsTransfer, tx *types.Transaction, index int) (*types.Receipt, error)
- func (a *Action) AssetTransferToExec(transfer *types.AssetsTransferToExec, tx *types.Transaction, index int) (*types.Receipt, error)
- func (a *Action) AssetWithdraw(withdraw *types.AssetsWithdraw, tx *types.Transaction, index int) (*types.Receipt, error)
- func (a *Action) ContractToTree(payload *zt.ZkContractToTree) (*types.Receipt, error)
- func (a *Action) Deposit(payload *zt.ZkDeposit) (*types.Receipt, error)
- func (a *Action) GetIndex() int64
- func (a *Action) MakeFeeLog(amount string, tokenId uint64) (*types.Receipt, *zt.ZkOperation, error)
- func (a *Action) MintNFT(payload *zt.ZkMintNFT) (*types.Receipt, error)
- func (a *Action) ProxyExit(payload *zt.ZkProxyExit) (*types.Receipt, error)
- func (a *Action) SetDefultPubKey(payload *zt.ZkSetPubKey) ([]*types.KeyValue, []*types.KeyValue, error)
- func (a *Action) SetProxyPubKey(payload *zt.ZkSetPubKey, leaf *zt.Leaf) ([]*types.KeyValue, []*types.KeyValue, error)
- func (a *Action) SetPubKey(payload *zt.ZkSetPubKey) (*types.Receipt, error)
- func (a *Action) TransferToNew(payload *zt.ZkTransferToNew) (*types.Receipt, error)
- func (a *Action) TreeToContract(payload *zt.ZkTreeToContract) (*types.Receipt, error)
- func (a *Action) UpdateContractAccount(amount, symbol string, option int32, execName string) (*types.Receipt, error)
- func (a *Action) UpdateExecAccount(accountdb *account.DB, amount int64, option int32, execName string) (*types.Receipt, error)
- func (a *Action) ZkTransfer(payload *zt.ZkTransfer, actionTy int32) (*types.Receipt, error)
- func (a *Action) ZkWithdraw(payload *zt.ZkWithdraw) (*types.Receipt, error)
- type CommitProofRow
- type TreeUpdateInfo
- type ZksyncInfoRow
Constants ¶
const ( //KeyPrefixStateDB state db key必须前缀 KeyPrefixStateDB = "mavl-zksync-" //KeyPrefixLocalDB local db的key必须前缀 KeyPrefixLocalDB = "LODB-zksync" )
Variables ¶
This section is empty.
Functions ¶
func AddNewLeafOpt ¶
func BuildHistoryAccountByProof ¶
func BuildHistoryAccountByProof(db dbm.KV, proofId uint64, reqRootHash string, feeAddrs *zt.ZkFeeAddrs) (*zt.HistoryAccountProofInfo, error)
BuildHistoryAccountByProof 根据ProofId构建截止到当前proof的account tree,以此账户构建证明,适用于截止到某个proof的证明
func BuildStateDbHistoryAccount ¶
BuildStateDbHistoryAccount 从statedb中构建账户tree,以此构建证明
func CalcLatestAccountIDKey ¶
func CalcLatestAccountIDKey() []byte
func CalcNewAccountIDkv ¶
func GetAccountIdPrimaryKey ¶
func GetAccountIdPrimaryKeyPrefix ¶
func GetAccountIdPrimaryKeyPrefix() string
func GetAccountTreeKey ¶
func GetAccountTreeKey() []byte
func GetAmountWithFee ¶
func GetChainEthPrimaryKey ¶
func GetFeeData ¶
该接口需要被zkrelayer使用
func GetHistoryAccountProof ¶
func GetHistoryAccountProof(historyAccountInfo *zt.HistoryAccountProofInfo, targetAccountID, targetTokenID uint64) (*zt.ZkProofWitness, error)
func GetL2LastQueueId ¶
L2 queue id 从1开始编号,跟L1 priority 不同,后者为了和eth合约编号保持一致
func GetL2QueueIdOp ¶
func GetLeafByChainAddress ¶
func GetLeafByEthAddress ¶
func GetNFTHashPrimaryKey ¶
func GetNFTIdPrimaryKey ¶
func GetPriorityDepositData ¶
func GetProofId2QueueId ¶
GetProofId2QueueId proof中的pubdata 对应的operation的start/end queueId
func GetRootIndexPrimaryKey ¶
func GetTokenBySymbol ¶
func GetTokenByTokenId ¶
func GetTokenPrimaryKey ¶
func GetTokenPrimaryKeyPrefix ¶
func GetTokenPrimaryKeyPrefix() string
func GetTokenSymbolIdKey ¶
GetTokenSymbolIdKey token symbol 对应id
func GetTokenSymbolKey ¶
GetTokenSymbolKey tokenId 对应symbol
func GetTreeSideAmount ¶
func GetTreeSideAmount(amount, totalAmount, fee string, sysDecimal, tokenDecimal int) (amount4Tree, totalAmount4Tree, feeAmount4Tree string, err error)
根据系统和token精度,计算合约转化为二层tree侧的amount,合约侧amount都是系统精度
func MakeSetTokenSymbolReceipt ¶
func MakeSetTokenSymbolReceipt(id string, oldVal, newVal *zt.ZkTokenSymbol) *types.Receipt
func NewAccountTreeTable ¶
NewAccountTreeTable ...
func NewCommitProofTable ¶
NewCommitProofTable ...
func NewInitAccount ¶
func TransferDecimalAmount ¶
from向to小数对齐,如果from>to, 需要裁减掉差别部分,且差别部分需要全0,如果from<to,差别部分需要补0
Types ¶
type AccountTreeRow ¶
AccountTreeRow table meta 结构
func NewAccountTreeRow ¶
func NewAccountTreeRow() *AccountTreeRow
func (*AccountTreeRow) Get ¶
func (r *AccountTreeRow) Get(key string) ([]byte, error)
Get 按照indexName 查询 indexValue
func (*AccountTreeRow) SetPayload ¶
func (r *AccountTreeRow) SetPayload(data types.Message) error
SetPayload 设置数据
type Action ¶
type Action struct {
// contains filtered or unexported fields
}
Action action struct
func (*Action) AssetTransfer ¶
func (a *Action) AssetTransfer(transfer *types.AssetsTransfer, tx *types.Transaction, index int) (*types.Receipt, error)
func (*Action) AssetTransferToExec ¶
func (a *Action) AssetTransferToExec(transfer *types.AssetsTransferToExec, tx *types.Transaction, index int) (*types.Receipt, error)
func (*Action) AssetWithdraw ¶
func (a *Action) AssetWithdraw(withdraw *types.AssetsWithdraw, tx *types.Transaction, index int) (*types.Receipt, error)
func (*Action) ContractToTree ¶
func (*Action) MakeFeeLog ¶
func (*Action) SetDefultPubKey ¶
func (*Action) SetProxyPubKey ¶
func (a *Action) SetProxyPubKey(payload *zt.ZkSetPubKey, leaf *zt.Leaf) ([]*types.KeyValue, []*types.KeyValue, error)
设置代理地址的公钥
func (*Action) TransferToNew ¶
func (*Action) TreeToContract ¶
L2 ----> 合约账户(树) 操作1. FromAccountId -----> SystemTree2ContractAcctId,执行ZkTransfer 操作2. UpdateContractAccount,在合约内部的铸币操作
func (*Action) UpdateContractAccount ¶
func (*Action) UpdateExecAccount ¶
func (*Action) ZkTransfer ¶
func (*Action) ZkWithdraw ¶
type CommitProofRow ¶
type CommitProofRow struct {
*zt.ZkCommitProof
}
CommitProofRow table meta 结构
func NewCommitProofRow ¶
func NewCommitProofRow() *CommitProofRow
func (*CommitProofRow) Get ¶
func (r *CommitProofRow) Get(key string) ([]byte, error)
Get 按照indexName 查询 indexValue
func (*CommitProofRow) SetPayload ¶
func (r *CommitProofRow) SetPayload(data types.Message) error
SetPayload 设置数据
type TreeUpdateInfo ¶
type TreeUpdateInfo struct {
// contains filtered or unexported fields
}
TreeUpdateInfo 更新信息,用于查询
type ZksyncInfoRow ¶
type ZksyncInfoRow struct {
*zt.AccountTokenBalanceReceipt
}
AccountTreeRow table meta 结构
func NewZksyncInfoRow ¶
func NewZksyncInfoRow() *ZksyncInfoRow
func (*ZksyncInfoRow) Get ¶
func (r *ZksyncInfoRow) Get(key string) ([]byte, error)
Get 按照indexName 查询 indexValue
func (*ZksyncInfoRow) SetPayload ¶
func (r *ZksyncInfoRow) SetPayload(data types.Message) error
SetPayload 设置数据