mirror of
https://github.com/luxfi/node.git
synced 2026-10-30 15:24:05 +00:00
The module already called itself github.com/luxfi/node while containing no node in Go: cmd/luxd was twenty-one lines that printed the size of a few types, and the Go column of the matrix measured a VM plugin. A repo that fetches the thing it claims to be has not replaced it, so the Go sources move in — 1515 files, the daemon and everything under it — and the build reaches outside this module for nothing. Rust and C++ sit beside it unchanged and are still measured against it by the differential. That is the point of one repo: the reference implementation and the two ports are the same checkout, so parity is a thing you can run rather than a thing you assert. Verified: builds, and the closure carries no lux-private — checked at build time rather than believed. The daemon starts twelve chains on a local network (P X C Q Z A B G K M F, plus D through its plugin) and reports healthy.
890 lines
24 KiB
Go
890 lines
24 KiB
Go
// Code generated by zip; DO NOT EDIT.
|
|
|
|
package xvm
|
|
|
|
import (
|
|
"encoding/binary"
|
|
"fmt"
|
|
"strings"
|
|
|
|
formatting "github.com/luxfi/formatting"
|
|
ids "github.com/luxfi/ids"
|
|
json "github.com/luxfi/node/utils/json"
|
|
utxo "github.com/luxfi/utxo"
|
|
zap "github.com/zap-proto/go"
|
|
)
|
|
|
|
// ---- AssetDefinition ---------------------------------------------------
|
|
|
|
const (
|
|
assetDefinitionAliasAt = 0
|
|
assetDefinitionNameAt = 8
|
|
assetDefinitionSymbolAt = 16
|
|
assetDefinitionDenominationAt = 24
|
|
assetDefinitionInitialStateAt = 32
|
|
assetDefinitionMemoAt = 40
|
|
assetDefinitionSize = 48
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*AssetDefinition)(nil)
|
|
|
|
// MarshalZAP writes AssetDefinition from constant offsets.
|
|
func (x *AssetDefinition) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(assetDefinitionSize + 256)
|
|
ob := b.StartObject(assetDefinitionSize)
|
|
ob.SetText(assetDefinitionAliasAt, string(x.Alias))
|
|
ob.SetText(assetDefinitionNameAt, string(x.Name))
|
|
ob.SetText(assetDefinitionSymbolAt, string(x.Symbol))
|
|
ob.SetUint8(assetDefinitionDenominationAt, uint8(x.Denomination))
|
|
innerInitialState, err := x.InitialState.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(assetDefinitionInitialStateAt, innerInitialState)
|
|
ob.SetText(assetDefinitionMemoAt, string(x.Memo))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads AssetDefinition out of the buffer that arrived.
|
|
func (x *AssetDefinition) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("AssetDefinition: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.Alias = string(strings.Clone(o.Text(assetDefinitionAliasAt)))
|
|
x.Name = string(strings.Clone(o.Text(assetDefinitionNameAt)))
|
|
x.Symbol = string(strings.Clone(o.Text(assetDefinitionSymbolAt)))
|
|
x.Denomination = json.Uint8(o.Uint8(assetDefinitionDenominationAt))
|
|
if raw := o.Bytes(assetDefinitionInitialStateAt); len(raw) > 0 {
|
|
if err := x.InitialState.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.Memo = string(strings.Clone(o.Text(assetDefinitionMemoAt)))
|
|
return nil
|
|
}
|
|
|
|
// ---- Balance -----------------------------------------------------------
|
|
|
|
const (
|
|
balanceAssetIDAt = 0
|
|
balanceBalanceAt = 8
|
|
balanceSize = 16
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*Balance)(nil)
|
|
|
|
// MarshalZAP writes Balance from constant offsets.
|
|
func (x *Balance) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(balanceSize + 256)
|
|
ob := b.StartObject(balanceSize)
|
|
ob.SetText(balanceAssetIDAt, string(x.AssetID))
|
|
ob.SetUint64(balanceBalanceAt, uint64(x.Balance))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads Balance out of the buffer that arrived.
|
|
func (x *Balance) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("Balance: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.AssetID = string(strings.Clone(o.Text(balanceAssetIDAt)))
|
|
x.Balance = json.Uint64(o.Uint64(balanceBalanceAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- BuildGenesisArgs --------------------------------------------------
|
|
|
|
const (
|
|
buildGenesisArgsNetworkIDAt = 0
|
|
buildGenesisArgsGenesisDataAt = 8
|
|
buildGenesisArgsEncodingAt = 16
|
|
buildGenesisArgsSize = 24
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*BuildGenesisArgs)(nil)
|
|
|
|
// MarshalZAP writes BuildGenesisArgs from constant offsets.
|
|
func (x *BuildGenesisArgs) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(buildGenesisArgsSize + 256)
|
|
genesisDataAt, genesisDataN := 0, len(x.GenesisData)
|
|
if genesisDataN > 0 {
|
|
var blob []byte
|
|
for i := range x.GenesisData {
|
|
enc, err := x.GenesisData[i].MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
genesisDataAt = b.WriteBytes(blob)
|
|
}
|
|
ob := b.StartObject(buildGenesisArgsSize)
|
|
ob.SetUint32(buildGenesisArgsNetworkIDAt, uint32(x.NetworkID))
|
|
ob.SetUint8(buildGenesisArgsEncodingAt, uint8(x.Encoding))
|
|
if genesisDataN > 0 {
|
|
ob.SetList(buildGenesisArgsGenesisDataAt, genesisDataAt, genesisDataN)
|
|
}
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads BuildGenesisArgs out of the buffer that arrived.
|
|
func (x *BuildGenesisArgs) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("BuildGenesisArgs: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.NetworkID = json.Uint32(o.Uint32(buildGenesisArgsNetworkIDAt))
|
|
if l := o.List(buildGenesisArgsGenesisDataAt); l.Len() > 0 {
|
|
rows := make(Assets, l.Len())
|
|
for i := range rows {
|
|
if err := rows[i].UnmarshalZAP(l.BytesAt(i)); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.GenesisData = rows
|
|
}
|
|
x.Encoding = formatting.Encoding(o.Uint8(buildGenesisArgsEncodingAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- BuildGenesisReply -------------------------------------------------
|
|
|
|
const (
|
|
buildGenesisReplyBytesAt = 0
|
|
buildGenesisReplyEncodingAt = 8
|
|
buildGenesisReplySize = 16
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*BuildGenesisReply)(nil)
|
|
|
|
// MarshalZAP writes BuildGenesisReply from constant offsets.
|
|
func (x *BuildGenesisReply) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(buildGenesisReplySize + 256)
|
|
ob := b.StartObject(buildGenesisReplySize)
|
|
ob.SetText(buildGenesisReplyBytesAt, string(x.Bytes))
|
|
ob.SetUint8(buildGenesisReplyEncodingAt, uint8(x.Encoding))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads BuildGenesisReply out of the buffer that arrived.
|
|
func (x *BuildGenesisReply) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("BuildGenesisReply: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.Bytes = string(strings.Clone(o.Text(buildGenesisReplyBytesAt)))
|
|
x.Encoding = formatting.Encoding(o.Uint8(buildGenesisReplyEncodingAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- FormattedAssetID --------------------------------------------------
|
|
|
|
const (
|
|
formattedAssetIDAssetIDAt = 0
|
|
formattedAssetIDSize = 32
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*FormattedAssetID)(nil)
|
|
|
|
// MarshalZAP writes FormattedAssetID from constant offsets.
|
|
func (x *FormattedAssetID) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(formattedAssetIDSize + 256)
|
|
ob := b.StartObject(formattedAssetIDSize)
|
|
ob.SetBytesFixed(formattedAssetIDAssetIDAt, x.AssetID[:])
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads FormattedAssetID out of the buffer that arrived.
|
|
func (x *FormattedAssetID) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("FormattedAssetID: %w", err)
|
|
}
|
|
o := m.Root()
|
|
copy(x.AssetID[:], o.BytesFixed(formattedAssetIDAssetIDAt, 32))
|
|
return nil
|
|
}
|
|
|
|
// ---- GetAddressTxsArgs -------------------------------------------------
|
|
|
|
const (
|
|
getAddressTxsArgsJSONAddressAt = 0
|
|
getAddressTxsArgsCursorAt = 8
|
|
getAddressTxsArgsPageSizeAt = 16
|
|
getAddressTxsArgsAssetIDAt = 24
|
|
getAddressTxsArgsSize = 32
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*GetAddressTxsArgs)(nil)
|
|
|
|
// MarshalZAP writes GetAddressTxsArgs from constant offsets.
|
|
func (x *GetAddressTxsArgs) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(getAddressTxsArgsSize + 256)
|
|
ob := b.StartObject(getAddressTxsArgsSize)
|
|
innerJSONAddress, err := x.JSONAddress.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(getAddressTxsArgsJSONAddressAt, innerJSONAddress)
|
|
ob.SetUint64(getAddressTxsArgsCursorAt, uint64(x.Cursor))
|
|
ob.SetUint64(getAddressTxsArgsPageSizeAt, uint64(x.PageSize))
|
|
ob.SetText(getAddressTxsArgsAssetIDAt, string(x.AssetID))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads GetAddressTxsArgs out of the buffer that arrived.
|
|
func (x *GetAddressTxsArgs) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("GetAddressTxsArgs: %w", err)
|
|
}
|
|
o := m.Root()
|
|
if raw := o.Bytes(getAddressTxsArgsJSONAddressAt); len(raw) > 0 {
|
|
if err := x.JSONAddress.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.Cursor = json.Uint64(o.Uint64(getAddressTxsArgsCursorAt))
|
|
x.PageSize = json.Uint64(o.Uint64(getAddressTxsArgsPageSizeAt))
|
|
x.AssetID = string(strings.Clone(o.Text(getAddressTxsArgsAssetIDAt)))
|
|
return nil
|
|
}
|
|
|
|
// ---- GetAddressTxsReply ------------------------------------------------
|
|
|
|
const (
|
|
getAddressTxsReplyTxIDsAt = 0
|
|
getAddressTxsReplyCursorAt = 8
|
|
getAddressTxsReplySize = 16
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*GetAddressTxsReply)(nil)
|
|
|
|
// MarshalZAP writes GetAddressTxsReply from constant offsets.
|
|
func (x *GetAddressTxsReply) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(getAddressTxsReplySize + 256)
|
|
txIDsAt, txIDsN := 0, len(x.TxIDs)
|
|
if txIDsN > 0 {
|
|
var blob []byte
|
|
for i := range x.TxIDs {
|
|
enc := x.TxIDs[i][:]
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
txIDsAt = b.WriteBytes(blob)
|
|
}
|
|
ob := b.StartObject(getAddressTxsReplySize)
|
|
ob.SetUint64(getAddressTxsReplyCursorAt, uint64(x.Cursor))
|
|
if txIDsN > 0 {
|
|
ob.SetList(getAddressTxsReplyTxIDsAt, txIDsAt, txIDsN)
|
|
}
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads GetAddressTxsReply out of the buffer that arrived.
|
|
func (x *GetAddressTxsReply) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("GetAddressTxsReply: %w", err)
|
|
}
|
|
o := m.Root()
|
|
if l := o.List(getAddressTxsReplyTxIDsAt); l.Len() > 0 {
|
|
rows := make([]ids.ID, l.Len())
|
|
for i := range rows {
|
|
copy(rows[i][:], l.BytesAt(i))
|
|
}
|
|
x.TxIDs = rows
|
|
}
|
|
x.Cursor = json.Uint64(o.Uint64(getAddressTxsReplyCursorAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- GetAllBalancesArgs ------------------------------------------------
|
|
|
|
const (
|
|
getAllBalancesArgsJSONAddressAt = 0
|
|
getAllBalancesArgsIncludePartialAt = 8
|
|
getAllBalancesArgsSize = 16
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*GetAllBalancesArgs)(nil)
|
|
|
|
// MarshalZAP writes GetAllBalancesArgs from constant offsets.
|
|
func (x *GetAllBalancesArgs) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(getAllBalancesArgsSize + 256)
|
|
ob := b.StartObject(getAllBalancesArgsSize)
|
|
innerJSONAddress, err := x.JSONAddress.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(getAllBalancesArgsJSONAddressAt, innerJSONAddress)
|
|
ob.SetBool(getAllBalancesArgsIncludePartialAt, bool(x.IncludePartial))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads GetAllBalancesArgs out of the buffer that arrived.
|
|
func (x *GetAllBalancesArgs) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("GetAllBalancesArgs: %w", err)
|
|
}
|
|
o := m.Root()
|
|
if raw := o.Bytes(getAllBalancesArgsJSONAddressAt); len(raw) > 0 {
|
|
if err := x.JSONAddress.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.IncludePartial = bool(o.Bool(getAllBalancesArgsIncludePartialAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- GetAllBalancesReply -----------------------------------------------
|
|
|
|
const (
|
|
getAllBalancesReplyBalancesAt = 0
|
|
getAllBalancesReplySize = 8
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*GetAllBalancesReply)(nil)
|
|
|
|
// MarshalZAP writes GetAllBalancesReply from constant offsets.
|
|
func (x *GetAllBalancesReply) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(getAllBalancesReplySize + 256)
|
|
balancesAt, balancesN := 0, len(x.Balances)
|
|
if balancesN > 0 {
|
|
var blob []byte
|
|
for i := range x.Balances {
|
|
enc, err := x.Balances[i].MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
balancesAt = b.WriteBytes(blob)
|
|
}
|
|
ob := b.StartObject(getAllBalancesReplySize)
|
|
if balancesN > 0 {
|
|
ob.SetList(getAllBalancesReplyBalancesAt, balancesAt, balancesN)
|
|
}
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads GetAllBalancesReply out of the buffer that arrived.
|
|
func (x *GetAllBalancesReply) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("GetAllBalancesReply: %w", err)
|
|
}
|
|
o := m.Root()
|
|
if l := o.List(getAllBalancesReplyBalancesAt); l.Len() > 0 {
|
|
rows := make([]Balance, l.Len())
|
|
for i := range rows {
|
|
if err := rows[i].UnmarshalZAP(l.BytesAt(i)); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.Balances = rows
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ---- GetAssetDescriptionArgs -------------------------------------------
|
|
|
|
const (
|
|
getAssetDescriptionArgsAssetIDAt = 0
|
|
getAssetDescriptionArgsSize = 8
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*GetAssetDescriptionArgs)(nil)
|
|
|
|
// MarshalZAP writes GetAssetDescriptionArgs from constant offsets.
|
|
func (x *GetAssetDescriptionArgs) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(getAssetDescriptionArgsSize + 256)
|
|
ob := b.StartObject(getAssetDescriptionArgsSize)
|
|
ob.SetText(getAssetDescriptionArgsAssetIDAt, string(x.AssetID))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads GetAssetDescriptionArgs out of the buffer that arrived.
|
|
func (x *GetAssetDescriptionArgs) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("GetAssetDescriptionArgs: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.AssetID = string(strings.Clone(o.Text(getAssetDescriptionArgsAssetIDAt)))
|
|
return nil
|
|
}
|
|
|
|
// ---- GetAssetDescriptionReply ------------------------------------------
|
|
|
|
const (
|
|
getAssetDescriptionReplyFormattedAssetIDAt = 0
|
|
getAssetDescriptionReplyNameAt = 8
|
|
getAssetDescriptionReplySymbolAt = 16
|
|
getAssetDescriptionReplyDenominationAt = 24
|
|
getAssetDescriptionReplySize = 32
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*GetAssetDescriptionReply)(nil)
|
|
|
|
// MarshalZAP writes GetAssetDescriptionReply from constant offsets.
|
|
func (x *GetAssetDescriptionReply) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(getAssetDescriptionReplySize + 256)
|
|
ob := b.StartObject(getAssetDescriptionReplySize)
|
|
innerFormattedAssetID, err := x.FormattedAssetID.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(getAssetDescriptionReplyFormattedAssetIDAt, innerFormattedAssetID)
|
|
ob.SetText(getAssetDescriptionReplyNameAt, string(x.Name))
|
|
ob.SetText(getAssetDescriptionReplySymbolAt, string(x.Symbol))
|
|
ob.SetUint8(getAssetDescriptionReplyDenominationAt, uint8(x.Denomination))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads GetAssetDescriptionReply out of the buffer that arrived.
|
|
func (x *GetAssetDescriptionReply) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("GetAssetDescriptionReply: %w", err)
|
|
}
|
|
o := m.Root()
|
|
if raw := o.Bytes(getAssetDescriptionReplyFormattedAssetIDAt); len(raw) > 0 {
|
|
if err := x.FormattedAssetID.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.Name = string(strings.Clone(o.Text(getAssetDescriptionReplyNameAt)))
|
|
x.Symbol = string(strings.Clone(o.Text(getAssetDescriptionReplySymbolAt)))
|
|
x.Denomination = json.Uint8(o.Uint8(getAssetDescriptionReplyDenominationAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- GetBalanceArgs ----------------------------------------------------
|
|
|
|
const (
|
|
getBalanceArgsAddressAt = 0
|
|
getBalanceArgsAssetIDAt = 8
|
|
getBalanceArgsIncludePartialAt = 16
|
|
getBalanceArgsSize = 24
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*GetBalanceArgs)(nil)
|
|
|
|
// MarshalZAP writes GetBalanceArgs from constant offsets.
|
|
func (x *GetBalanceArgs) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(getBalanceArgsSize + 256)
|
|
ob := b.StartObject(getBalanceArgsSize)
|
|
ob.SetText(getBalanceArgsAddressAt, string(x.Address))
|
|
ob.SetText(getBalanceArgsAssetIDAt, string(x.AssetID))
|
|
ob.SetBool(getBalanceArgsIncludePartialAt, bool(x.IncludePartial))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads GetBalanceArgs out of the buffer that arrived.
|
|
func (x *GetBalanceArgs) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("GetBalanceArgs: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.Address = string(strings.Clone(o.Text(getBalanceArgsAddressAt)))
|
|
x.AssetID = string(strings.Clone(o.Text(getBalanceArgsAssetIDAt)))
|
|
x.IncludePartial = bool(o.Bool(getBalanceArgsIncludePartialAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- GetBalanceReply ---------------------------------------------------
|
|
|
|
const (
|
|
getBalanceReplyBalanceAt = 0
|
|
getBalanceReplyUTXOIDsAt = 8
|
|
getBalanceReplySize = 16
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*GetBalanceReply)(nil)
|
|
|
|
// MarshalZAP writes GetBalanceReply from constant offsets.
|
|
func (x *GetBalanceReply) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(getBalanceReplySize + 256)
|
|
uTXOIDsAt, uTXOIDsN := 0, len(x.UTXOIDs)
|
|
if uTXOIDsN > 0 {
|
|
var blob []byte
|
|
for i := range x.UTXOIDs {
|
|
enc, err := x.UTXOIDs[i].MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
uTXOIDsAt = b.WriteBytes(blob)
|
|
}
|
|
ob := b.StartObject(getBalanceReplySize)
|
|
ob.SetUint64(getBalanceReplyBalanceAt, uint64(x.Balance))
|
|
if uTXOIDsN > 0 {
|
|
ob.SetList(getBalanceReplyUTXOIDsAt, uTXOIDsAt, uTXOIDsN)
|
|
}
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads GetBalanceReply out of the buffer that arrived.
|
|
func (x *GetBalanceReply) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("GetBalanceReply: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.Balance = json.Uint64(o.Uint64(getBalanceReplyBalanceAt))
|
|
if l := o.List(getBalanceReplyUTXOIDsAt); l.Len() > 0 {
|
|
rows := make([]utxo.UTXOID, l.Len())
|
|
for i := range rows {
|
|
if err := rows[i].UnmarshalZAP(l.BytesAt(i)); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.UTXOIDs = rows
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ---- Holder ------------------------------------------------------------
|
|
|
|
const (
|
|
holderAmountAt = 0
|
|
holderAddressAt = 8
|
|
holderSize = 16
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*Holder)(nil)
|
|
|
|
// MarshalZAP writes Holder from constant offsets.
|
|
func (x *Holder) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(holderSize + 256)
|
|
ob := b.StartObject(holderSize)
|
|
ob.SetUint64(holderAmountAt, uint64(x.Amount))
|
|
ob.SetText(holderAddressAt, string(x.Address))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads Holder out of the buffer that arrived.
|
|
func (x *Holder) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("Holder: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.Amount = json.Uint64(o.Uint64(holderAmountAt))
|
|
x.Address = string(strings.Clone(o.Text(holderAddressAt)))
|
|
return nil
|
|
}
|
|
|
|
// ---- InitialState ------------------------------------------------------
|
|
|
|
const (
|
|
initialStateFixedCapAt = 0
|
|
initialStateVariableCapAt = 8
|
|
initialStateSize = 16
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*InitialState)(nil)
|
|
|
|
// MarshalZAP writes InitialState from constant offsets.
|
|
func (x *InitialState) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(initialStateSize + 256)
|
|
fixedCapAt, fixedCapN := 0, len(x.FixedCap)
|
|
if fixedCapN > 0 {
|
|
var blob []byte
|
|
for i := range x.FixedCap {
|
|
enc, err := x.FixedCap[i].MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
fixedCapAt = b.WriteBytes(blob)
|
|
}
|
|
variableCapAt, variableCapN := 0, len(x.VariableCap)
|
|
if variableCapN > 0 {
|
|
var blob []byte
|
|
for i := range x.VariableCap {
|
|
enc, err := x.VariableCap[i].MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
variableCapAt = b.WriteBytes(blob)
|
|
}
|
|
ob := b.StartObject(initialStateSize)
|
|
if fixedCapN > 0 {
|
|
ob.SetList(initialStateFixedCapAt, fixedCapAt, fixedCapN)
|
|
}
|
|
if variableCapN > 0 {
|
|
ob.SetList(initialStateVariableCapAt, variableCapAt, variableCapN)
|
|
}
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads InitialState out of the buffer that arrived.
|
|
func (x *InitialState) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("InitialState: %w", err)
|
|
}
|
|
o := m.Root()
|
|
if l := o.List(initialStateFixedCapAt); l.Len() > 0 {
|
|
rows := make([]Holder, l.Len())
|
|
for i := range rows {
|
|
if err := rows[i].UnmarshalZAP(l.BytesAt(i)); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.FixedCap = rows
|
|
}
|
|
if l := o.List(initialStateVariableCapAt); l.Len() > 0 {
|
|
rows := make([]Owners, l.Len())
|
|
for i := range rows {
|
|
if err := rows[i].UnmarshalZAP(l.BytesAt(i)); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.VariableCap = rows
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ---- Owners ------------------------------------------------------------
|
|
|
|
const (
|
|
ownersThresholdAt = 0
|
|
ownersMintersAt = 8
|
|
ownersSize = 16
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*Owners)(nil)
|
|
|
|
// MarshalZAP writes Owners from constant offsets.
|
|
func (x *Owners) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(ownersSize + 256)
|
|
mintersAt, mintersN := 0, len(x.Minters)
|
|
if mintersN > 0 {
|
|
var blob []byte
|
|
for i := range x.Minters {
|
|
enc := []byte(x.Minters[i])
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
mintersAt = b.WriteBytes(blob)
|
|
}
|
|
ob := b.StartObject(ownersSize)
|
|
ob.SetUint32(ownersThresholdAt, uint32(x.Threshold))
|
|
if mintersN > 0 {
|
|
ob.SetList(ownersMintersAt, mintersAt, mintersN)
|
|
}
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads Owners out of the buffer that arrived.
|
|
func (x *Owners) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("Owners: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.Threshold = json.Uint32(o.Uint32(ownersThresholdAt))
|
|
if l := o.List(ownersMintersAt); l.Len() > 0 {
|
|
rows := make([]string, l.Len())
|
|
for i := range rows {
|
|
rows[i] = string(l.BytesAt(i))
|
|
}
|
|
x.Minters = rows
|
|
}
|
|
return nil
|
|
}
|