txtypes

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NilNonce        = -1
	NilExpiredAt    = math.MaxInt64
	NilAccountIndex = int64(-1)
	NilAssetId      = int64(-1)
)
View Source
const (
	TxTypeEmpty = iota
	TxTypeRegisterZns
	TxTypeDeposit
	TxTypeDepositNft
	TxTypeTransfer
	TxTypeWithdraw
	TxTypeCreateCollection
	TxTypeMintNft
	TxTypeTransferNft
	TxTypeAtomicMatch
	TxTypeCancelOffer
	TxTypeWithdrawNft
	TxTypeFullExit
	TxTypeFullExitNft
	TxTypeOffer
)
View Source
const (
	BuyOfferType  = 0
	SellOfferType = 1
)
View Source
const (
	ChainId = 1
)
View Source
const (
	HashLength int = 32
)

Variables

View Source
var (
	ErrAccountIndexTooLow       = fmt.Errorf("AccountIndex should not be less than %d", minAccountIndex)
	ErrAccountIndexTooHigh      = fmt.Errorf("AccountIndex should not be larger than %d", maxAccountIndex)
	ErrGasAccountIndexTooLow    = fmt.Errorf("GasAccountIndex should not be less than %d", minAccountIndex)
	ErrGasAccountIndexTooHigh   = fmt.Errorf("GasAccountIndex should not be larger than %d", maxAccountIndex)
	ErrGasFeeAssetIdTooLow      = fmt.Errorf("GasFeeAssetId should not be less than %d", minAssetId)
	ErrGasFeeAssetIdTooHigh     = fmt.Errorf("GasFeeAssetId should not be larger than %d", maxAssetId)
	ErrGasFeeAssetAmountTooLow  = fmt.Errorf("GasFeeAssetAmount should not be less than %s", minPackedFeeAmount.String())
	ErrGasFeeAssetAmountTooHigh = fmt.Errorf("GasFeeAssetAmount should not be larger than %s", maxPackedFeeAmount.String())
	ErrNonceTooLow              = fmt.Errorf("Nonce should not be less than %d", minNonce)
	ErrOfferTypeInvalid         = fmt.Errorf("Type should only be buy(%d) and sell(%d)", BuyOfferType, SellOfferType)
	ErrOfferIdTooLow            = fmt.Errorf("OfferId should not be less than 0")
	ErrNftIndexTooLow           = fmt.Errorf("NftIndex should not be less than %d", minNftIndex)
	ErrNftIndexTooHigh          = fmt.Errorf("NftIndex should not be larger than %d", maxNftIndex)
	ErrAssetIdTooLow            = fmt.Errorf("AssetId should not be less than %d", minAssetId)
	ErrAssetIdTooHigh           = fmt.Errorf("AssetId should not be larger than %d", maxAssetId)
	ErrAssetAmountTooLow        = fmt.Errorf("AssetAmount should be larger than %s", minAssetAmount.String())
	ErrAssetAmountTooHigh       = fmt.Errorf("AssetAmount should not be larger than %s", maxAssetAmount.String())
	ErrListedAtTooLow           = fmt.Errorf("ListedAt should be larger than 0")
	ErrTreasuryRateTooLow       = fmt.Errorf("TreasuryRate should  not be less than %d", minTreasuryRate)
	ErrTreasuryRateTooHigh      = fmt.Errorf("TreasuryRate should not be larger than %d", maxTreasuryRate)
	ErrCollectionNameTooShort   = fmt.Errorf("length of Name should not be less than %d", minCollectionNameLength)
	ErrCollectionNameTooLong    = fmt.Errorf("length of Name should not be larger than %d", maxCollectionNameLength)
	ErrIntroductionTooLong      = fmt.Errorf("length of Introduction should not be larger than %d", maxCollectionIntroductionLength)
	ErrNftContentHashInvalid    = fmt.Errorf("NftContentHash is invalid")
	ErrNftCollectionIdTooLow    = fmt.Errorf("NftCollectionId should not be less than %d", minCollectionId)
	ErrNftCollectionIdTooHigh   = fmt.Errorf("NftCollectionId should not be larger than %d", maxCollectionId)
	ErrCallDataHashInvalid      = fmt.Errorf("CallDataHash is invalid")

	ErrCreatorAccountIndexTooLow  = fmt.Errorf("CreatorAccountIndex should not be less than %d", minAccountIndex)
	ErrCreatorAccountIndexTooHigh = fmt.Errorf("CreatorAccountIndex should not be larger than %d", maxAccountIndex)
	ErrToAccountIndexTooLow       = fmt.Errorf("ToAccountIndex should not be less than %d", minAccountIndex)
	ErrToAccountIndexTooHigh      = fmt.Errorf("ToAccountIndex should not be larger than %d", maxAccountIndex)
	ErrToAccountNameHashInvalid   = fmt.Errorf("ToAccountNameHash is invalid")
	ErrCreatorTreasuryRateTooLow  = fmt.Errorf("CreatorTreasuryRate should  not be less than %d", minTreasuryRate)
	ErrCreatorTreasuryRateTooHigh = fmt.Errorf("CreatorTreasuryRate should not be larger than %d", maxTreasuryRate)
	ErrFromAccountIndexTooLow     = fmt.Errorf("FromAccountIndex should not be less than %d", minAccountIndex)
	ErrFromAccountIndexTooHigh    = fmt.Errorf("FromAccountIndex should not be larger than %d", maxAccountIndex)
	ErrToAddressInvalid           = fmt.Errorf("ToAddress is invalid")
	ErrBuyOfferInvalid            = fmt.Errorf("BuyOffer is invalid")
	ErrSellOfferInvalid           = fmt.Errorf("SellOffer is invalid")
)

Functions

func CleanPackedAmount

func CleanPackedAmount(amount *big.Int) (nAmount *big.Int, err error)

func CleanPackedFee

func CleanPackedFee(amount *big.Int) (nAmount *big.Int, err error)

func FromHex

func FromHex(s string) ([]byte, error)

func IsValidHash

func IsValidHash(hash string) bool

func IsValidHashBytes

func IsValidHashBytes(bytes []byte) bool

func IsValidL1Address

func IsValidL1Address(address string) bool

func PaddingAddressToBytes32

func PaddingAddressToBytes32(addr string) []byte

func PaddingStringToBytes32

func PaddingStringToBytes32(name string) []byte

func ParsePublicKey

func ParsePublicKey(pkStr string) (pk *eddsa.PublicKey, err error)

func StringToBigInt

func StringToBigInt(a string) (res *big.Int, err error)

func ToPackedAmount

func ToPackedAmount(amount *big.Int) (res int64, err error)

ToPackedAmount: convert big int to 40 bit, 5 bits for 10^x, 35 bits for a * 10^x

func ToPackedFee

func ToPackedFee(amount *big.Int) (res int64, err error)

ToPackedFee: convert big int to 16 bit, 5 bits for 10^x, 11 bits for a * 10^x

func WriteBigIntIntoBuf

func WriteBigIntIntoBuf(buf *bytes.Buffer, a *big.Int)

func WriteInt64IntoBuf

func WriteInt64IntoBuf(buf *bytes.Buffer, inputs ...int64)

Types

type AtomicMatchSegmentFormat

type AtomicMatchSegmentFormat struct {
	AccountIndex int64  `json:"account_index"`
	BuyOffer     string `json:"buy_offer"`
	// OfferTxInfo Type
	SellOffer string `json:"sell_offer"`
	// OfferTxInfo Type
	GasAccountIndex   int64  `json:"gas_account_index"`
	GasFeeAssetId     int64  `json:"gas_fee_asset_id"`
	GasFeeAssetAmount string `json:"gas_fee_asset_amount"`
	Nonce             int64  `json:"nonce"`
	// transaction amount +1 for fromAccountIndex
	ExpiredAt int64 `json:"expired_at"`
}

type AtomicMatchTxInfo

type AtomicMatchTxInfo struct {
	AccountIndex      int64
	BuyOffer          *OfferTxInfo
	SellOffer         *OfferTxInfo
	GasAccountIndex   int64
	GasFeeAssetId     int64
	GasFeeAssetAmount *big.Int
	CreatorAmount     *big.Int
	TreasuryAmount    *big.Int
	Nonce             int64
	ExpiredAt         int64
	Sig               []byte
}

func ConstructAtomicMatchTxInfo

func ConstructAtomicMatchTxInfo(sk *PrivateKey, segmentStr string) (txInfo *AtomicMatchTxInfo, err error)

ConstructMintNftTxInfo: construct mint nft tx, sign txInfo

func (*AtomicMatchTxInfo) GetExpiredAt

func (txInfo *AtomicMatchTxInfo) GetExpiredAt() int64

func (*AtomicMatchTxInfo) GetFromAccountIndex

func (txInfo *AtomicMatchTxInfo) GetFromAccountIndex() int64

func (*AtomicMatchTxInfo) GetGas

func (txInfo *AtomicMatchTxInfo) GetGas() (int64, int64, *big.Int)

func (*AtomicMatchTxInfo) GetNonce

func (txInfo *AtomicMatchTxInfo) GetNonce() int64

func (*AtomicMatchTxInfo) GetTxType

func (txInfo *AtomicMatchTxInfo) GetTxType() int

func (*AtomicMatchTxInfo) Hash

func (txInfo *AtomicMatchTxInfo) Hash(hFunc hash.Hash) (msgHash []byte, err error)

func (*AtomicMatchTxInfo) Validate

func (txInfo *AtomicMatchTxInfo) Validate() error

func (*AtomicMatchTxInfo) VerifySignature

func (txInfo *AtomicMatchTxInfo) VerifySignature(pubKey string) error

type CancelOfferSegmentFormat

type CancelOfferSegmentFormat struct {
	AccountIndex      int64  `json:"account_index"`
	OfferId           int64  `json:"offer_id"`
	GasAccountIndex   int64  `json:"gas_account_index"`
	GasFeeAssetId     int64  `json:"gas_fee_asset_id"`
	GasFeeAssetAmount string `json:"gas_fee_asset_amount"`
	ExpiredAt         int64  `json:"expired_at"`
	Nonce             int64  `json:"nonce"`
}

type CancelOfferTxInfo

type CancelOfferTxInfo struct {
	AccountIndex      int64
	OfferId           int64
	GasAccountIndex   int64
	GasFeeAssetId     int64
	GasFeeAssetAmount *big.Int
	ExpiredAt         int64
	Nonce             int64
	Sig               []byte
}

func ConstructCancelOfferTxInfo

func ConstructCancelOfferTxInfo(sk *PrivateKey, segmentStr string) (txInfo *CancelOfferTxInfo, err error)

func (*CancelOfferTxInfo) GetExpiredAt

func (txInfo *CancelOfferTxInfo) GetExpiredAt() int64

func (*CancelOfferTxInfo) GetFromAccountIndex

func (txInfo *CancelOfferTxInfo) GetFromAccountIndex() int64

func (*CancelOfferTxInfo) GetGas

func (txInfo *CancelOfferTxInfo) GetGas() (int64, int64, *big.Int)

func (*CancelOfferTxInfo) GetNonce

func (txInfo *CancelOfferTxInfo) GetNonce() int64

func (*CancelOfferTxInfo) GetTxType

func (txInfo *CancelOfferTxInfo) GetTxType() int

func (*CancelOfferTxInfo) Hash

func (txInfo *CancelOfferTxInfo) Hash(hFunc hash.Hash) (msgHash []byte, err error)

func (*CancelOfferTxInfo) Validate

func (txInfo *CancelOfferTxInfo) Validate() error

func (*CancelOfferTxInfo) VerifySignature

func (txInfo *CancelOfferTxInfo) VerifySignature(pubKey string) error

type CreateCollectionSegmentFormat

type CreateCollectionSegmentFormat struct {
	AccountIndex      int64  `json:"account_index"`
	Name              string `json:"name"`
	Introduction      string `json:"introduction"`
	GasAccountIndex   int64  `json:"gas_account_index"`
	GasFeeAssetId     int64  `json:"gas_fee_asset_id"`
	GasFeeAssetAmount string `json:"gas_fee_asset_amount"`
	ExpiredAt         int64  `json:"expired_at"`
	Nonce             int64  `json:"nonce"`
}

type CreateCollectionTxInfo

type CreateCollectionTxInfo struct {
	AccountIndex      int64
	CollectionId      int64
	Name              string
	Introduction      string
	GasAccountIndex   int64
	GasFeeAssetId     int64
	GasFeeAssetAmount *big.Int
	ExpiredAt         int64
	Nonce             int64
	Sig               []byte
}

func ConstructCreateCollectionTxInfo

func ConstructCreateCollectionTxInfo(sk *PrivateKey, segmentStr string) (txInfo *CreateCollectionTxInfo, err error)

ConstructCreateCollectionTxInfo: construct mint nft tx, sign txInfo

func (*CreateCollectionTxInfo) GetExpiredAt

func (txInfo *CreateCollectionTxInfo) GetExpiredAt() int64

func (*CreateCollectionTxInfo) GetFromAccountIndex

func (txInfo *CreateCollectionTxInfo) GetFromAccountIndex() int64

func (*CreateCollectionTxInfo) GetGas

func (txInfo *CreateCollectionTxInfo) GetGas() (int64, int64, *big.Int)

func (*CreateCollectionTxInfo) GetNonce

func (txInfo *CreateCollectionTxInfo) GetNonce() int64

func (*CreateCollectionTxInfo) GetTxType

func (txInfo *CreateCollectionTxInfo) GetTxType() int

func (*CreateCollectionTxInfo) Hash

func (txInfo *CreateCollectionTxInfo) Hash(hFunc hash.Hash) (msgHash []byte, err error)

func (*CreateCollectionTxInfo) Validate

func (txInfo *CreateCollectionTxInfo) Validate() error

func (*CreateCollectionTxInfo) VerifySignature

func (txInfo *CreateCollectionTxInfo) VerifySignature(pubKey string) error

type DepositNftTxInfo

type DepositNftTxInfo struct {
	TxType uint8

	// Get from layer1 events.
	AccountNameHash     []byte
	CreatorAccountIndex int64
	CreatorTreasuryRate int64
	NftL1Address        string
	NftL1TokenId        *big.Int
	NftContentHash      []byte
	CollectionId        int64

	// New nft set by layer2, otherwise get from layer1.
	NftIndex int64

	// Set by layer2.
	AccountIndex int64
}

func (*DepositNftTxInfo) GetExpiredAt

func (txInfo *DepositNftTxInfo) GetExpiredAt() int64

func (*DepositNftTxInfo) GetFromAccountIndex

func (txInfo *DepositNftTxInfo) GetFromAccountIndex() int64

func (*DepositNftTxInfo) GetGas

func (txInfo *DepositNftTxInfo) GetGas() (int64, int64, *big.Int)

func (*DepositNftTxInfo) GetNonce

func (txInfo *DepositNftTxInfo) GetNonce() int64

func (*DepositNftTxInfo) GetTxType

func (txInfo *DepositNftTxInfo) GetTxType() int

func (*DepositNftTxInfo) Hash

func (txInfo *DepositNftTxInfo) Hash(hFunc hash.Hash) (msgHash []byte, err error)

func (*DepositNftTxInfo) Validate

func (txInfo *DepositNftTxInfo) Validate() error

func (*DepositNftTxInfo) VerifySignature

func (txInfo *DepositNftTxInfo) VerifySignature(pubKey string) error

type DepositTxInfo

type DepositTxInfo struct {
	TxType uint8

	// Get from layer1 events.
	AccountNameHash []byte
	AssetId         int64
	AssetAmount     *big.Int

	// Set by layer2.
	AccountIndex int64
}

func (*DepositTxInfo) GetExpiredAt

func (txInfo *DepositTxInfo) GetExpiredAt() int64

func (*DepositTxInfo) GetFromAccountIndex

func (txInfo *DepositTxInfo) GetFromAccountIndex() int64

func (*DepositTxInfo) GetGas

func (txInfo *DepositTxInfo) GetGas() (int64, int64, *big.Int)

func (*DepositTxInfo) GetNonce

func (txInfo *DepositTxInfo) GetNonce() int64

func (*DepositTxInfo) GetTxType

func (txInfo *DepositTxInfo) GetTxType() int

func (*DepositTxInfo) Hash

func (txInfo *DepositTxInfo) Hash(hFunc hash.Hash) (msgHash []byte, err error)

func (*DepositTxInfo) Validate

func (txInfo *DepositTxInfo) Validate() error

func (*DepositTxInfo) VerifySignature

func (txInfo *DepositTxInfo) VerifySignature(pubKey string) error

type FullExitNftTxInfo

type FullExitNftTxInfo struct {
	TxType uint8

	// Get from layer1 events.
	NftIndex        int64
	AccountNameHash []byte

	// Set by layer2.
	AccountIndex           int64
	CreatorAccountIndex    int64
	CreatorTreasuryRate    int64
	CreatorAccountNameHash []byte
	NftL1Address           string
	NftL1TokenId           *big.Int
	NftContentHash         []byte
	CollectionId           int64
}

func (*FullExitNftTxInfo) GetExpiredAt

func (txInfo *FullExitNftTxInfo) GetExpiredAt() int64

func (*FullExitNftTxInfo) GetFromAccountIndex

func (txInfo *FullExitNftTxInfo) GetFromAccountIndex() int64

func (*FullExitNftTxInfo) GetGas

func (txInfo *FullExitNftTxInfo) GetGas() (int64, int64, *big.Int)

func (*FullExitNftTxInfo) GetNonce

func (txInfo *FullExitNftTxInfo) GetNonce() int64

func (*FullExitNftTxInfo) GetTxType

func (txInfo *FullExitNftTxInfo) GetTxType() int

func (*FullExitNftTxInfo) Hash

func (txInfo *FullExitNftTxInfo) Hash(hFunc hash.Hash) (msgHash []byte, err error)

func (*FullExitNftTxInfo) Validate

func (txInfo *FullExitNftTxInfo) Validate() error

func (*FullExitNftTxInfo) VerifySignature

func (txInfo *FullExitNftTxInfo) VerifySignature(pubKey string) error

type FullExitTxInfo

type FullExitTxInfo struct {
	TxType uint8

	// Get from layer1 events.
	AccountNameHash []byte
	AssetId         int64

	// Set by layer2.
	AccountIndex int64
	AssetAmount  *big.Int
}

func (*FullExitTxInfo) GetExpiredAt

func (txInfo *FullExitTxInfo) GetExpiredAt() int64

func (*FullExitTxInfo) GetFromAccountIndex

func (txInfo *FullExitTxInfo) GetFromAccountIndex() int64

func (*FullExitTxInfo) GetGas

func (txInfo *FullExitTxInfo) GetGas() (int64, int64, *big.Int)

func (*FullExitTxInfo) GetNonce

func (txInfo *FullExitTxInfo) GetNonce() int64

func (*FullExitTxInfo) GetTxType

func (txInfo *FullExitTxInfo) GetTxType() int

func (*FullExitTxInfo) Hash

func (txInfo *FullExitTxInfo) Hash(hFunc hash.Hash) (msgHash []byte, err error)

func (*FullExitTxInfo) Validate

func (txInfo *FullExitTxInfo) Validate() error

func (*FullExitTxInfo) VerifySignature

func (txInfo *FullExitTxInfo) VerifySignature(pubKey string) error

type MintNftSegmentFormat

type MintNftSegmentFormat struct {
	CreatorAccountIndex int64  `json:"creator_account_index"`
	ToAccountIndex      int64  `json:"to_account_index"`
	ToAccountNameHash   string `json:"to_account_name_hash"`
	NftContentHash      string `json:"nft_content_hash"`
	NftCollectionId     int64  `json:"nft_collection_id"`
	CreatorTreasuryRate int64  `json:"creator_treasury_rate"`
	GasAccountIndex     int64  `json:"gas_account_index"`
	GasFeeAssetId       int64  `json:"gas_fee_asset_id"`
	GasFeeAssetAmount   string `json:"gas_fee_asset_amount"`
	ExpiredAt           int64  `json:"expired_at"`
	Nonce               int64  `json:"nonce"`
}

type MintNftTxInfo

type MintNftTxInfo struct {
	CreatorAccountIndex int64
	ToAccountIndex      int64
	ToAccountNameHash   string
	NftIndex            int64
	NftContentHash      string
	NftCollectionId     int64
	CreatorTreasuryRate int64
	GasAccountIndex     int64
	GasFeeAssetId       int64
	GasFeeAssetAmount   *big.Int
	ExpiredAt           int64
	Nonce               int64
	Sig                 []byte
}

func ConstructMintNftTxInfo

func ConstructMintNftTxInfo(sk *PrivateKey, segmentStr string) (txInfo *MintNftTxInfo, err error)

func (*MintNftTxInfo) GetExpiredAt

func (txInfo *MintNftTxInfo) GetExpiredAt() int64

func (*MintNftTxInfo) GetFromAccountIndex

func (txInfo *MintNftTxInfo) GetFromAccountIndex() int64

func (*MintNftTxInfo) GetGas

func (txInfo *MintNftTxInfo) GetGas() (int64, int64, *big.Int)

func (*MintNftTxInfo) GetNonce

func (txInfo *MintNftTxInfo) GetNonce() int64

func (*MintNftTxInfo) GetTxType

func (txInfo *MintNftTxInfo) GetTxType() int

func (*MintNftTxInfo) Hash

func (txInfo *MintNftTxInfo) Hash(hFunc hash.Hash) (msgHash []byte, err error)

func (*MintNftTxInfo) Validate

func (txInfo *MintNftTxInfo) Validate() error

func (*MintNftTxInfo) VerifySignature

func (txInfo *MintNftTxInfo) VerifySignature(pubKey string) error

type OfferSegmentFormat

type OfferSegmentFormat struct {
	Type         int64  `json:"type"`
	OfferId      int64  `json:"offer_id"`
	AccountIndex int64  `json:"account_index"`
	NftIndex     int64  `json:"nft_index"`
	AssetId      int64  `json:"asset_id"`
	AssetAmount  string `json:"asset_amount"`
	ListedAt     int64  `json:"listed_at"`
	ExpiredAt    int64  `json:"expired_at"`
	TreasuryRate int64  `json:"treasury_rate"`
}

type OfferTxInfo

type OfferTxInfo struct {
	Type         int64
	OfferId      int64
	AccountIndex int64
	NftIndex     int64
	AssetId      int64
	AssetAmount  *big.Int
	ListedAt     int64
	ExpiredAt    int64
	TreasuryRate int64
	Sig          []byte
}

func ConstructOfferTxInfo

func ConstructOfferTxInfo(sk *PrivateKey, segmentStr string) (txInfo *OfferTxInfo, err error)

func (*OfferTxInfo) GetExpiredAt

func (txInfo *OfferTxInfo) GetExpiredAt() int64

func (*OfferTxInfo) GetFromAccountIndex

func (txInfo *OfferTxInfo) GetFromAccountIndex() int64

func (*OfferTxInfo) GetGas

func (txInfo *OfferTxInfo) GetGas() (int64, int64, *big.Int)

func (*OfferTxInfo) GetNonce

func (txInfo *OfferTxInfo) GetNonce() int64

func (*OfferTxInfo) GetTxType

func (txInfo *OfferTxInfo) GetTxType() int

func (*OfferTxInfo) Hash

func (txInfo *OfferTxInfo) Hash(hFunc hash.Hash) (msgHash []byte, err error)

func (*OfferTxInfo) Validate

func (txInfo *OfferTxInfo) Validate() error

func (*OfferTxInfo) VerifySignature

func (txInfo *OfferTxInfo) VerifySignature(pubKey string) error

type PrivateKey

type PrivateKey = eddsa.PrivateKey

type RegisterZnsTxInfo

type RegisterZnsTxInfo struct {
	TxType uint8

	// Get from layer1 events.
	AccountIndex    int64
	AccountName     string
	AccountNameHash []byte
	PubKey          string
}

func (*RegisterZnsTxInfo) GetExpiredAt

func (txInfo *RegisterZnsTxInfo) GetExpiredAt() int64

func (*RegisterZnsTxInfo) GetFromAccountIndex

func (txInfo *RegisterZnsTxInfo) GetFromAccountIndex() int64

func (*RegisterZnsTxInfo) GetGas

func (txInfo *RegisterZnsTxInfo) GetGas() (int64, int64, *big.Int)

func (*RegisterZnsTxInfo) GetNonce

func (txInfo *RegisterZnsTxInfo) GetNonce() int64

func (*RegisterZnsTxInfo) GetTxType

func (txInfo *RegisterZnsTxInfo) GetTxType() int

func (*RegisterZnsTxInfo) Hash

func (txInfo *RegisterZnsTxInfo) Hash(hFunc hash.Hash) (msgHash []byte, err error)

func (*RegisterZnsTxInfo) Validate

func (txInfo *RegisterZnsTxInfo) Validate() error

func (*RegisterZnsTxInfo) VerifySignature

func (txInfo *RegisterZnsTxInfo) VerifySignature(pubKey string) error

type Signature

type Signature = eddsa.Signature

type TransferNftSegmentFormat

type TransferNftSegmentFormat struct {
	FromAccountIndex  int64  `json:"from_account_index"`
	ToAccountIndex    int64  `json:"to_account_index"`
	ToAccountNameHash string `json:"to_account_name"`
	NftIndex          int64  `json:"nft_index"`
	GasAccountIndex   int64  `json:"gas_account_index"`
	GasFeeAssetId     int64  `json:"gas_fee_asset_id"`
	GasFeeAssetAmount string `json:"gas_fee_asset_amount"`
	CallData          string `json:"call_data"`
	ExpiredAt         int64  `json:"expired_at"`
	Nonce             int64  `json:"nonce"`
}

type TransferNftTxInfo

type TransferNftTxInfo struct {
	FromAccountIndex  int64
	ToAccountIndex    int64
	ToAccountNameHash string
	NftIndex          int64
	GasAccountIndex   int64
	GasFeeAssetId     int64
	GasFeeAssetAmount *big.Int
	CallData          string
	CallDataHash      []byte
	ExpiredAt         int64
	Nonce             int64
	Sig               []byte
}

func ConstructTransferNftTxInfo

func ConstructTransferNftTxInfo(sk *PrivateKey, segmentStr string) (txInfo *TransferNftTxInfo, err error)

func (*TransferNftTxInfo) GetExpiredAt

func (txInfo *TransferNftTxInfo) GetExpiredAt() int64

func (*TransferNftTxInfo) GetFromAccountIndex

func (txInfo *TransferNftTxInfo) GetFromAccountIndex() int64

func (*TransferNftTxInfo) GetGas

func (txInfo *TransferNftTxInfo) GetGas() (int64, int64, *big.Int)

func (*TransferNftTxInfo) GetNonce

func (txInfo *TransferNftTxInfo) GetNonce() int64

func (*TransferNftTxInfo) GetTxType

func (txInfo *TransferNftTxInfo) GetTxType() int

func (*TransferNftTxInfo) Hash

func (txInfo *TransferNftTxInfo) Hash(hFunc hash.Hash) (msgHash []byte, err error)

func (*TransferNftTxInfo) Validate

func (txInfo *TransferNftTxInfo) Validate() error

func (*TransferNftTxInfo) VerifySignature

func (txInfo *TransferNftTxInfo) VerifySignature(pubKey string) error

type TransferSegmentFormat

type TransferSegmentFormat struct {
	FromAccountIndex  int64  `json:"from_account_index"`
	ToAccountIndex    int64  `json:"to_account_index"`
	ToAccountNameHash string `json:"to_account_name"`
	AssetId           int64  `json:"asset_id"`
	AssetAmount       string `json:"asset_amount"`
	GasAccountIndex   int64  `json:"gas_account_index"`
	GasFeeAssetId     int64  `json:"gas_fee_asset_id"`
	GasFeeAssetAmount string `json:"gas_fee_asset_amount"`
	Memo              string `json:"memo"`
	CallData          string `json:"call_data"`
	ExpiredAt         int64  `json:"expired_at"`
	Nonce             int64  `json:"nonce"`
}

type TransferTxInfo

type TransferTxInfo struct {
	FromAccountIndex  int64
	ToAccountIndex    int64
	ToAccountNameHash string
	AssetId           int64
	AssetAmount       *big.Int
	GasAccountIndex   int64
	GasFeeAssetId     int64
	GasFeeAssetAmount *big.Int
	Memo              string
	CallData          string
	CallDataHash      []byte
	ExpiredAt         int64
	Nonce             int64
	Sig               []byte
}

func ConstructTransferTxInfo

func ConstructTransferTxInfo(sk *PrivateKey, segmentStr string) (txInfo *TransferTxInfo, err error)

func (*TransferTxInfo) GetExpiredAt

func (txInfo *TransferTxInfo) GetExpiredAt() int64

func (*TransferTxInfo) GetFromAccountIndex

func (txInfo *TransferTxInfo) GetFromAccountIndex() int64

func (*TransferTxInfo) GetGas

func (txInfo *TransferTxInfo) GetGas() (int64, int64, *big.Int)

func (*TransferTxInfo) GetNonce

func (txInfo *TransferTxInfo) GetNonce() int64

func (*TransferTxInfo) GetTxType

func (txInfo *TransferTxInfo) GetTxType() int

func (*TransferTxInfo) Hash

func (txInfo *TransferTxInfo) Hash(hFunc hash.Hash) (msgHash []byte, err error)

func (*TransferTxInfo) Validate

func (txInfo *TransferTxInfo) Validate() error

func (*TransferTxInfo) VerifySignature

func (txInfo *TransferTxInfo) VerifySignature(pubKey string) error

type TxInfo

type TxInfo interface {
	GetTxType() int

	Validate() error

	VerifySignature(pubKey string) error

	GetFromAccountIndex() int64

	GetNonce() int64

	GetExpiredAt() int64

	Hash(hFunc hash.Hash) (msgHash []byte, err error)

	GetGas() (int64, int64, *big.Int)
}

type WithdrawNftSegmentFormat

type WithdrawNftSegmentFormat struct {
	AccountIndex      int64  `json:"account_index"`
	NftIndex          int64  `json:"nft_index"`
	ToAddress         string `json:"to_address"`
	GasAccountIndex   int64  `json:"gas_account_index"`
	GasFeeAssetId     int64  `json:"gas_fee_asset_id"`
	GasFeeAssetAmount string `json:"gas_fee_asset_amount"`
	ExpiredAt         int64  `json:"expired_at"`
	Nonce             int64  `json:"nonce"`
}

type WithdrawNftTxInfo

type WithdrawNftTxInfo struct {
	AccountIndex           int64
	CreatorAccountIndex    int64
	CreatorAccountNameHash []byte
	CreatorTreasuryRate    int64
	NftIndex               int64
	NftContentHash         []byte
	NftL1Address           string
	NftL1TokenId           *big.Int
	CollectionId           int64
	ToAddress              string
	GasAccountIndex        int64
	GasFeeAssetId          int64
	GasFeeAssetAmount      *big.Int
	ExpiredAt              int64
	Nonce                  int64
	Sig                    []byte
}

func ConstructWithdrawNftTxInfo

func ConstructWithdrawNftTxInfo(sk *PrivateKey, segmentStr string) (txInfo *WithdrawNftTxInfo, err error)

func (*WithdrawNftTxInfo) GetExpiredAt

func (txInfo *WithdrawNftTxInfo) GetExpiredAt() int64

func (*WithdrawNftTxInfo) GetFromAccountIndex

func (txInfo *WithdrawNftTxInfo) GetFromAccountIndex() int64

func (*WithdrawNftTxInfo) GetGas

func (txInfo *WithdrawNftTxInfo) GetGas() (int64, int64, *big.Int)

func (*WithdrawNftTxInfo) GetNonce

func (txInfo *WithdrawNftTxInfo) GetNonce() int64

func (*WithdrawNftTxInfo) GetTxType

func (txInfo *WithdrawNftTxInfo) GetTxType() int

func (*WithdrawNftTxInfo) Hash

func (txInfo *WithdrawNftTxInfo) Hash(hFunc hash.Hash) (msgHash []byte, err error)

func (*WithdrawNftTxInfo) Validate

func (txInfo *WithdrawNftTxInfo) Validate() error

func (*WithdrawNftTxInfo) VerifySignature

func (txInfo *WithdrawNftTxInfo) VerifySignature(pubKey string) error

type WithdrawSegmentFormat

type WithdrawSegmentFormat struct {
	FromAccountIndex  int64  `json:"from_account_index"`
	AssetId           int64  `json:"asset_id"`
	AssetAmount       string `json:"asset_amount"`
	GasAccountIndex   int64  `json:"gas_account_index"`
	GasFeeAssetId     int64  `json:"gas_fee_asset_id"`
	GasFeeAssetAmount string `json:"gas_fee_asset_amount"`
	ToAddress         string `json:"to_address"`
	ExpiredAt         int64  `json:"expired_at"`
	Nonce             int64  `json:"nonce"`
}

type WithdrawTxInfo

type WithdrawTxInfo struct {
	FromAccountIndex  int64
	AssetId           int64
	AssetAmount       *big.Int
	GasAccountIndex   int64
	GasFeeAssetId     int64
	GasFeeAssetAmount *big.Int
	ToAddress         string
	ExpiredAt         int64
	Nonce             int64
	Sig               []byte
}

func ConstructWithdrawTxInfo

func ConstructWithdrawTxInfo(sk *PrivateKey, segmentStr string) (txInfo *WithdrawTxInfo, err error)

func (*WithdrawTxInfo) GetExpiredAt

func (txInfo *WithdrawTxInfo) GetExpiredAt() int64

func (*WithdrawTxInfo) GetFromAccountIndex

func (txInfo *WithdrawTxInfo) GetFromAccountIndex() int64

func (*WithdrawTxInfo) GetGas

func (txInfo *WithdrawTxInfo) GetGas() (int64, int64, *big.Int)

func (*WithdrawTxInfo) GetNonce

func (txInfo *WithdrawTxInfo) GetNonce() int64

func (*WithdrawTxInfo) GetTxType

func (txInfo *WithdrawTxInfo) GetTxType() int

func (*WithdrawTxInfo) Hash

func (txInfo *WithdrawTxInfo) Hash(hFunc hash.Hash) (msgHash []byte, err error)

func (*WithdrawTxInfo) Validate

func (txInfo *WithdrawTxInfo) Validate() error

func (*WithdrawTxInfo) VerifySignature

func (txInfo *WithdrawTxInfo) VerifySignature(pubKey string) error

Jump to

Keyboard shortcuts

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