model

package
v0.0.0-...-fd63c1f Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DustLimit       int64 = 10_000 // 0.01 tez
	AccountTableKey       = "account"
)
View Source
const (
	BigmapAllocTableKey  = "bigmap_types"
	BigmapUpdateTableKey = "bigmap_updates"
	BigmapValueTableKey  = "bigmap_values"
)
View Source
const (
	ElectionTableKey = "gov_election"
	ProposalTableKey = "gov_proposal"
	VoteTableKey     = "gov_vote"
	BallotTableKey   = "gov_ballot"
	StakeTableKey    = "gov_stake"
)
View Source
const (
	OpTableKey        = "op"
	EndorseOpTableKey = "endorsement"
)
View Source
const (
	OPL_PROTOCOL_UPGRADE = -1 // migration
	OPL_BLOCK_EVENTS     = -1 // block-level events like auto (un)freeze, rewards
	OPL_BLOCK_HEADER     = -1 // implicit operations like liquidity baking
)

implicit operation list ids

View Source
const (
	SnapshotTableKey        = "snapshot"
	SnapshotStagingTableKey = "snapstage"
)
View Source
const BakerTableKey = "baker"
View Source
const BalanceTableKey = "balance"
View Source
const BlockTableKey = "block"
View Source
const ChainTableKey = "chain"
View Source
const ConstantTableKey = "constant"
View Source
const ContractTableKey = "contract"
View Source
const CycleTableKey = "cycle"
View Source
const EventTableKey = "event"
View Source
const FlowTableKey = "flow"
View Source
const IncomeTableKey = "income"
View Source
const MetadataTableKey = "metadata"
View Source
const RightsTableKey = "rights"
View Source
const StorageTableKey = "storage"
View Source
const SupplyTableKey = "supply"
View Source
const (
	TicketEventTableKey = "ticket_events"
)
View Source
const (
	TicketOwnerTableKey = "ticket_owners"
)
View Source
const (
	TicketTableKey = "ticket"
)
View Source
const (
	TicketUpdateTableKey = "ticket_updates"
)
View Source
const (
	TokenEventTableKey = "token_events"
)
View Source
const (
	TokenMetaTableKey = "token_metadata"
)
View Source
const (
	TokenOwnerTableKey = "token_owners"
)
View Source
const (
	TokenTableKey = "token"
)

Variables

View Source
var (
	ErrNoAccount      = errors.New("account not indexed")
	ErrInvalidAddress = errors.New("invalid address")
)
View Source
var (
	ErrNoBigmap        = errors.New("bigmap not indexed")
	ErrInvalidExprHash = errors.New("invalid expr hash")
)
View Source
var (

	// ErrNoBlock is an error that indicates a requested entry does
	// not exist in the block bucket.
	ErrNoBlock = errors.New("block not indexed")

	// ErrInvalidBlockHeight
	ErrInvalidBlockHeight = errors.New("invalid block height")

	// ErrInvalidBlockHash
	ErrInvalidBlockHash = errors.New("invalid block hash")
)
View Source
var (
	// ErrNoElection is an error that indicates a requested entry does
	// not exist in the election table.
	ErrNoElection = errors.New("election not indexed")

	// ErrNoProposal is an error that indicates a requested entry does
	// not exist in the proposal table.
	ErrNoProposal = errors.New("proposal not indexed")

	// ErrNoVote is an error that indicates a requested entry does
	// not exist in the vote table.
	ErrNoVote = errors.New("vote not indexed")

	// ErrNoBallot is an error that indicates a requested entry does
	// not exist in the ballot table.
	ErrNoBallot = errors.New("ballot not indexed")

	ErrInvalidProtocolHash = errors.New("invalid protocol hash")
)
View Source
var (
	ErrNoOp          = errors.New("op not indexed")
	ErrNoEndorsement = errors.New("endorsement not indexed")
	ErrInvalidOpID   = errors.New("invalid op id")
	ErrInvalidOpHash = errors.New("invalid op hash")
)
View Source
var (
	ErrLedgerSkip = errors.New("skip")
)
View Source
var ErrNoBaker = errors.New("baker not indexed")
View Source
var ErrNoBalance = errors.New("balance not indexed")
View Source
var (
	// ErrNoChain is an error that indicates a requested entry does
	// not exist in the chain table.
	ErrNoChain = errors.New("chain state not indexed")
)
View Source
var (
	ErrNoConstant = errors.New("constant not indexed")
)
View Source
var (
	ErrNoContract = errors.New("contract not indexed")
)
View Source
var ErrNoCycle = errors.New("cycle not indexed")
View Source
var (
	ErrNoEvent = errors.New("event not indexed")
)
View Source
var (
	ErrNoFlow = errors.New("flow not indexed")
)
View Source
var (
	ErrNoIncome = errors.New("income not indexed")
)
View Source
var ErrNoMetadata = errors.New("metadata not indexed")
View Source
var (
	ErrNoRights = errors.New("rights not indexed")
)
View Source
var (
	ErrNoSnapshot = errors.New("snapshot not indexed")
)
View Source
var ErrNoStorage = errors.New("storage not indexed")
View Source
var ErrNoSupply = errors.New("supply not indexed")
View Source
var (
	ErrNoTicket = errors.New("ticket type not indexed")
)
View Source
var (
	ErrNoTicketEvent = errors.New("ticket event not indexed")
)
View Source
var (
	ErrNoTicketOwner = errors.New("ticket owner not indexed")
)
View Source
var (
	ErrNoTicketUpdate = errors.New("ticket update not indexed")
)
View Source
var (
	ErrNoToken = errors.New("token not indexed")
)
View Source
var (
	ErrNoTokenEvent = errors.New("token event not indexed")
)
View Source
var (
	ErrNoTokenMeta = errors.New("token metadata not indexed")
)
View Source
var (
	ErrNoTokenOwner = errors.New("token owner not indexed")
)

Functions

func DetectLedger

func DetectLedger(s micheline.Script) (schema LedgerSchema, typ TokenType, lid, mid int64)

Detect legder type from interface and schema from bigmap type.

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.

func GetKeyId

func GetKeyId(bigmapid int64, kh tezos.ExprHash) uint64

func Int16Correct

func Int16Correct(i int) int

Correct overflow from negative numbers caused by DB storage/type

func IsFA1

func IsFA1(s micheline.Script) bool

func IsFA12

func IsFA12(s micheline.Script) bool

func IsFA2

func IsFA2(s micheline.Script) bool

func IsLedgerOwner

func IsLedgerOwner(ctx context.Context, t *pack.Table, ownerId, ledgerId AccountID) (bool, error)

func PrimMatches

func PrimMatches(prim micheline.Prim, template [][]int) bool

func ReadConfigOpts

func ReadConfigOpts(keys ...string) pack.Options

func StoreTicketEvents

func StoreTicketEvents(ctx context.Context, t *pack.Table, events []*TicketEvent) error

func StoreTokenEvents

func StoreTokenEvents(ctx context.Context, t *pack.Table, events []*TokenEvent) error

func TicketHash

func TicketHash(a tezos.Address, typ, content micheline.Prim) uint64

func UnpackTnsString

func UnpackTnsString(v string) (string, error)

func UseLogger

func UseLogger(logger logpkg.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using logpkg.

Types

type Account

type Account struct {
	RowId            AccountID         `pack:"I,pk"      json:"row_id"`
	Address          tezos.Address     `pack:"H,bloom=3" json:"address"`
	Type             tezos.AddressType `pack:"t,u8"      json:"address_type"`
	Pubkey           tezos.Key         `pack:"k"         json:"pubkey"`
	Counter          int64             `pack:"j,i32"     json:"counter"`
	BakerId          AccountID         `pack:"D"         json:"baker_id"`
	CreatorId        AccountID         `pack:"C"         json:"creator_id"`
	FirstIn          int64             `pack:"i,i32"     json:"first_in"`
	FirstOut         int64             `pack:"o,i32"     json:"first_out"`
	LastIn           int64             `pack:"J,i32"     json:"last_in"`
	LastOut          int64             `pack:"O,i32"     json:"last_out"`
	FirstSeen        int64             `pack:"0,i32"     json:"first_seen"`
	LastSeen         int64             `pack:"l,i32"     json:"last_seen"`
	DelegatedSince   int64             `pack:"+,i32"     json:"delegated_since"`
	TotalReceived    int64             `pack:"R"         json:"total_received"`
	TotalSent        int64             `pack:"S"         json:"total_sent"`
	TotalBurned      int64             `pack:"B"         json:"total_burned"`
	TotalFeesPaid    int64             `pack:"F"         json:"total_fees_paid"`
	TotalFeesUsed    int64             `pack:"u"         json:"total_fees_used"`
	UnclaimedBalance int64             `pack:"U"         json:"unclaimed_balance"`
	SpendableBalance int64             `pack:"s"         json:"spendable_balance"`
	FrozenRollupBond int64             `pack:"L"         json:"frozen_rollup_bond"` // rollup
	LostRollupBond   int64             `pack:"X"         json:"lost_rollup_bond"`   // rollup
	StakedBalance    int64             `pack:"Y"         json:"staked_balance"`     // stake
	UnstakedBalance  int64             `pack:"Z"         json:"unstaked_balance"`   // stake
	LostStake        int64             `pack:"V"         json:"lost_stake"`         // stake
	StakeShares      int64             `pack:"W"         json:"stake_shares"`       // stake
	IsFunded         bool              `pack:"f,snappy"  json:"is_funded"`
	IsActivated      bool              `pack:"A,snappy"  json:"is_activated"`
	IsDelegated      bool              `pack:"=,snappy"  json:"is_delegated"`
	IsStaked         bool              `pack:"?,snappy"  json:"is_staked"`
	IsRevealed       bool              `pack:"r,snappy"  json:"is_revealed"`
	IsBaker          bool              `pack:"d,snappy"  json:"is_baker"`
	IsContract       bool              `pack:"c,snappy"  json:"is_contract"`
	NTxSuccess       int               `pack:"1,i32"     json:"n_tx_success"`
	NTxFailed        int               `pack:"2,i32"     json:"n_tx_failed"`
	NTxIn            int               `pack:"3,i32"     json:"n_tx_in"`
	NTxOut           int               `pack:"4,i32"     json:"n_tx_out"`

	// used during block processing, not stored in DB
	IsNew       bool   `pack:"-" json:"-"` // first seen this block
	WasFunded   bool   `pack:"-" json:"-"` // true if account was funded before processing this block
	WasDust     bool   `pack:"-" json:"-"` // true if account had 0 < balance < 1tez at start of block
	IsDirty     bool   `pack:"-" json:"-"` // indicates an update happened
	MustDelete  bool   `pack:"-" json:"-"` // indicates the account should be deleted (during rollback)
	PrevBalance int64  `pack:"-" json:"-"` // previous balance before update
	Baker       *Baker `pack:"-" json:"-"` // used for stake updates
	AuxBaker    *Baker `pack:"-" json:"-"` // used for unstake during delegation
}

Account is an up-to-date snapshot of the current status of all known accounts. For history look at Op and Flow (balance updates) for baker info look at Baker, for smart contract info at Contract.

func AllocAccount

func AllocAccount() *Account

func NewAccount

func NewAccount(addr tezos.Address) *Account

func (Account) Balance

func (a Account) Balance() int64

func (*Account) Equal

func (a *Account) Equal(b *Account) bool

func (*Account) Free

func (a *Account) Free()

func (Account) ID

func (a Account) ID() uint64

func (Account) IndexOpts

func (m Account) IndexOpts(key string) pack.Options

func (Account) IsDust

func (a Account) IsDust() bool

func (Account) MarshalBinary

func (a Account) MarshalBinary() ([]byte, error)

func (*Account) Reset

func (a *Account) Reset()

func (*Account) RollbackBalance

func (a *Account) RollbackBalance(f *Flow) error

func (*Account) RollbackBalanceN

func (a *Account) RollbackBalanceN(flows []*Flow) error

func (*Account) SetID

func (a *Account) SetID(id uint64)

func (Account) String

func (a Account) String() string

func (Account) TableKey

func (m Account) TableKey() string

func (Account) TableOpts

func (m Account) TableOpts() pack.Options

func (*Account) UnmarshalBinary

func (a *Account) UnmarshalBinary(data []byte) error

func (*Account) UpdateBalance

func (a *Account) UpdateBalance(f *Flow) error

func (*Account) UpdateBalanceN

func (a *Account) UpdateBalanceN(flows []*Flow) error

type AccountID

type AccountID uint64

func (AccountID) U32

func (id AccountID) U32() uint32

Handle with care, this is OK as long as number of accounts < 4,294,967,295

func (AccountID) U64

func (id AccountID) U64() uint64

type AccountRank

type AccountRank struct {
	AccountId    AccountID
	Balance      int64 // total balance
	TxVolume24h  int64 // tx volume in+out
	TxTraffic24h int64 // number of tx in+out
	RichRank     int   // assigned rank based on balance
	VolumeRank   int   // assigned rank based on volume
	TrafficRank  int   // assigned rank based on traffic
}

type Baker

type Baker struct {
	RowId               BakerID       `pack:"I,pk"      json:"row_id"`
	AccountId           AccountID     `pack:"A,u32"     json:"account_id"`
	Address             tezos.Address `pack:"H,bloom=3" json:"address"`
	ConsensusKey        tezos.Key     `pack:"K"         json:"consensus_key"`
	IsActive            bool          `pack:"v,snappy"  json:"is_active"`
	BakerSince          int64         `pack:"*,i32"     json:"baker_since"`
	BakerUntil          int64         `pack:"/,i32"     json:"baker_until"`
	TotalRewardsEarned  int64         `pack:"W"         json:"total_rewards_earned"`
	TotalFeesEarned     int64         `pack:"E"         json:"total_fees_earned"`
	TotalLost           int64         `pack:"L"         json:"total_lost"`
	FrozenDeposits      int64         `pack:"z"         json:"frozen_deposits"`
	FrozenRewards       int64         `pack:"Z"         json:"frozen_rewards"`
	FrozenFees          int64         `pack:"Y"         json:"frozen_fees"`
	DelegatedBalance    int64         `pack:"~"         json:"delegated_balance"`
	TotalStake          int64         `pack:"g"         json:"total_stake"`
	TotalShares         int64         `pack:"h"         json:"total_shares"`
	ActiveStakers       int64         `pack:"j"         json:"active_stakers"`
	StakingEdge         int64         `pack:"k"         json:"staking_edge"`
	StakingLimit        int64         `pack:"l"         json:"staking_limit"`
	DepositsLimit       int64         `pack:"T"         json:"deposit_limit"`
	ActiveDelegations   int64         `pack:"a,i32"     json:"active_delegations"`
	BlocksBaked         int64         `pack:"b,i32"     json:"blocks_baked"`
	BlocksProposed      int64         `pack:"P,i32"     json:"blocks_proposed"`
	BlocksNotBaked      int64         `pack:"N,i32"     json:"blocks_not_baked"`
	BlocksEndorsed      int64         `pack:"x,i32"     json:"blocks_endorsed"`
	BlocksNotEndorsed   int64         `pack:"y,i32"     json:"blocks_not_endorsed"`
	SlotsEndorsed       int64         `pack:"e"         json:"slots_endorsed"`
	NBakerOps           int64         `pack:"1,i32"     json:"n_baker_ops"`
	NProposal           int64         `pack:"2,i32"     json:"n_proposals"`
	NBallot             int64         `pack:"3,i32"     json:"n_ballots"`
	NEndorsement        int64         `pack:"4,i32"     json:"n_endorsements"`
	NPreendorsement     int64         `pack:"5,i32"     json:"n_preendorsements"`
	NSeedNonce          int64         `pack:"6,i32"     json:"n_nonce_revelations"`
	N2Baking            int64         `pack:"7,i32"     json:"n_double_bakings"`
	N2Endorsement       int64         `pack:"8,i32"     json:"n_double_endorsements"`
	NSetDepositsLimit   int64         `pack:"9,i32"     json:"n_set_limits"`
	NAccusations        int64         `pack:"0,i32"     json:"n_accusations"`
	NUpdateConsensusKey int64         `pack:"!,i32"     json:"n_update_consensus_key"`
	NDrainDelegate      int64         `pack:"=,i32"     json:"n_drain_delegate"`
	GracePeriod         int64         `pack:"G,i32"     json:"grace_period"`
	Version             uint32        `pack:"V,snappy"  json:"baker_version"`

	Account     *Account `pack:"-" json:"-"` // related account
	Reliability int64    `pack:"-" json:"-"` // current cycle reliability from rights
	IsNew       bool     `pack:"-" json:"-"` // first seen this block
	IsDirty     bool     `pack:"-" json:"-"` // indicates an update happened
}

Baker is an up-to-date snapshot of the current status of active or inactive bakers. For history look at Op and Flow (balance updates), for generic info look at Account.

func NewBaker

func NewBaker(acc *Account) *Baker

func (Baker) BakingPower

func (b Baker) BakingPower(p *rpc.Params, adjust int64) int64

BakingPower calculates how much of the baker's stake (deposits and delegated) is used to derive consensus rights. There are subtle differences between versions. Post Oxford this is influenced by global and local limits.

func (Baker) BakingPowerEmmy

func (b Baker) BakingPowerEmmy(p *rpc.Params, adjust int64) int64

func (Baker) BakingPowerOxford

func (b Baker) BakingPowerOxford(p *rpc.Params, adjust int64) int64

Ofxord active stake depends on global 5x limit and baker's local limit anything above these limits is counted as delegation and delegations are further capped to 9x stake

func (Baker) BakingPowerTenderbake

func (b Baker) BakingPowerTenderbake(p *rpc.Params, adjust int64) int64

v12+ staking balance capped by locked deposits

func (Baker) Balance

func (b Baker) Balance() int64

func (*Baker) BurnStake

func (b *Baker) BurnStake(stake int64) int64

func (Baker) DelegationCapOxford

func (b Baker) DelegationCapOxford(p *rpc.Params, adjust int64) int64

Max counted delegation for baking power

func (Baker) DelegationCapacity

func (b Baker) DelegationCapacity(p *rpc.Params, netRolls, adjust int64) int64

func (Baker) DelegationCapacityEmmy

func (b Baker) DelegationCapacityEmmy(p *rpc.Params, netRolls, adjust int64) int64

Emmy - capacity depends on ratio between on stake and network-wide stake - adjust for end of cycle snapshot difference

func (Baker) DelegationCapacityOxford

func (b Baker) DelegationCapacityOxford(p *rpc.Params, adjust int64) int64

Oxford staking same as in Tenderbake, but config option semantic has changed to - FrozenDepositsPercentage = 10 // means deposit must be >= 10% of eligible delegation - LimitOfDelegationOverBaking = 9 // means max delegation = 9x stake

func (Baker) DelegationCapacityTenderbake

func (b Baker) DelegationCapacityTenderbake(p *rpc.Params, adjust int64) int64

Tenderbake - 10% of staking balance must be locked - deposit = stake * frozen_deposits_percentage / 100 - max_stake = total_balance / frozen_deposits_percentage * 100 - adjust for end of cycle snapshot difference

func (Baker) FrozenStake

func (b Baker) FrozenStake() int64

func (*Baker) GetVersionBytes

func (b *Baker) GetVersionBytes() []byte

func (Baker) ID

func (b Baker) ID() uint64

func (Baker) IndexOpts

func (b Baker) IndexOpts(key string) pack.Options

func (*Baker) InitGracePeriod

func (b *Baker) InitGracePeriod(cycle int64, params *rpc.Params)

init 11 cycles ahead of current cycle

func (Baker) IsOverDelegated

func (b Baker) IsOverDelegated(p *rpc.Params) bool

func (Baker) IsOverStaked

func (b Baker) IsOverStaked(p *rpc.Params) bool

func (*Baker) MintStake

func (b *Baker) MintStake(stake int64) int64

Oxford stake pool ownership tracking

func (*Baker) Reset

func (b *Baker) Reset()

func (*Baker) RollbackBalance

func (b *Baker) RollbackBalance(f *Flow) error

func (*Baker) RollbackBalanceN

func (b *Baker) RollbackBalanceN(flows []*Flow) error

func (*Baker) SetID

func (b *Baker) SetID(id uint64)

func (*Baker) SetVersion

func (b *Baker) SetVersion(nonce uint64)

func (Baker) StakeAdjust

func (b Baker) StakeAdjust(block *Block) int64

func (Baker) StakeAdjustEmmy

func (b Baker) StakeAdjustEmmy(block *Block) (adjust int64)

func (Baker) StakeAdjustTenderbake

func (b Baker) StakeAdjustTenderbake(block *Block) (adjust int64)

func (Baker) StakeAmount

func (b Baker) StakeAmount(shares int64) int64

func (Baker) StakingBalance

func (b Baker) StakingBalance() int64

own balance plus frozen deposits+fees (NOT REWARDS!) plus all delegated balances (this is self-delegation safe) post oxford this is equal to TotalStake + SpendableBalance + DelegatedBalance

func (Baker) StakingCap

func (b Baker) StakingCap(p *rpc.Params) int64

max counted stake for baking power calc

func (Baker) StakingCapacity

func (b Baker) StakingCapacity(p *rpc.Params) int64

Oxford staking baker setting limit_of_staking_over_baking = 5(.000.000) means 5x own stake global_limit_of_staking_over_baking = 5 means baker total stake capcacity == 5x own stake

func (Baker) String

func (b Baker) String() string

func (Baker) TableKey

func (b Baker) TableKey() string

func (Baker) TableOpts

func (b Baker) TableOpts() pack.Options

func (Baker) TotalBalance

func (b Baker) TotalBalance() int64

func (*Baker) UpdateBalance

func (b *Baker) UpdateBalance(f *Flow) error

func (*Baker) UpdateBalanceN

func (b *Baker) UpdateBalanceN(flows []*Flow) error

func (*Baker) UpdateGracePeriod

func (b *Baker) UpdateGracePeriod(cycle int64, params *rpc.Params)

keep initial (+11) max grace period, otherwise cycle + 6

type BakerID

type BakerID uint64

func (BakerID) U64

func (id BakerID) U64() uint64

type Balance

type Balance struct {
	RowId     uint64    `pack:"I,pk"     json:"row_id"`
	AccountId AccountID `pack:"A,bloom"  json:"account_id"`
	Balance   int64     `pack:"B"        json:"balance"`
	ValidFrom int64     `pack:">,i32"    json:"valid_from"`
}

func (Balance) ID

func (b Balance) ID() uint64

func (Balance) IndexOpts

func (m Balance) IndexOpts(key string) pack.Options

func (*Balance) Reset

func (b *Balance) Reset()

func (*Balance) SetID

func (b *Balance) SetID(id uint64)

func (Balance) TableKey

func (m Balance) TableKey() string

func (Balance) TableOpts

func (m Balance) TableOpts() pack.Options

type Ballot

type Ballot struct {
	RowId            uint64                 `pack:"I,pk"  json:"row_id"`             // unique id
	ElectionId       ElectionID             `pack:"E"     json:"election_id"`        // related election id
	ProposalId       ProposalID             `pack:"P"     json:"proposal_id"`        // related proposal id
	VotingPeriod     int64                  `pack:"p,i16" json:"voting_period"`      // on-chain sequence number
	VotingPeriodKind tezos.VotingPeriodKind `pack:"k,u8"  json:"voting_period_kind"` // on-chain period
	Height           int64                  `pack:"h,i32" json:"height"`             // proposal/ballot operation block height
	Time             time.Time              `pack:"T"     json:"time"`               // proposal/ballot operation block time
	SourceId         AccountID              `pack:"S"     json:"source_id"`          // voting account
	OpId             OpID                   `pack:"O"     json:"op_id"`              // proposal/ballot operation id
	Stake            int64                  `pack:"s"     json:"stake"`              // voting power (at beginning of voting period)
	Ballot           tezos.BallotVote       `pack:"b,u8"  json:"ballot"`             // yay, nay, pass; proposal period uses yay only
}

Ballot represent a single vote cast by a baker during a voting period. Only periods 1, 2 and 4 support casting votes, period 1 uses `proposals` operations to vote on up to 20 proposals, periods 2 and 4 use `ballot` operations to vote on progressing with a single winning proposal.

func (*Ballot) ID

func (b *Ballot) ID() uint64

func (Ballot) IndexOpts

func (m Ballot) IndexOpts(key string) pack.Options

func (*Ballot) SetID

func (b *Ballot) SetID(id uint64)

func (Ballot) TableKey

func (m Ballot) TableKey() string

func (Ballot) TableOpts

func (m Ballot) TableOpts() pack.Options

type BaseRight

type BaseRight struct {
	AccountId      AccountID
	Type           tezos.RightType
	IsUsed         bool
	IsLost         bool
	IsStolen       bool
	IsMissed       bool
	IsSeedRequired bool
	IsSeedRevealed bool
}

type BigmapAlloc

type BigmapAlloc struct {
	RowId     uint64    `pack:"I,pk"     json:"row_id"`        // internal: id
	BigmapId  int64     `pack:"B,i32"    json:"bigmap_id"`     // unique bigmap id
	AccountId AccountID `pack:"A,u32"    json:"account_id"`    // account table id for contract
	Height    int64     `pack:"h,i32"    json:"alloc_height"`  // allocation height
	NUpdates  int64     `pack:"n,i32"    json:"n_updates"`     // running update counter
	NKeys     int64     `pack:"k,i32"    json:"n_keys"`        // current number of active keys
	Updated   int64     `pack:"u,i32"    json:"update_height"` // last update height
	Deleted   int64     `pack:"D,i32"    json:"delete_height"` // block when bigmap was removed
	Data      []byte    `pack:"d,snappy" json:"-"`             // micheline encoded type tree (key/val pair)

	// internal, not stored
	KeyType   micheline.Type `pack:"-" json:"-"`
	ValueType micheline.Type `pack:"-" json:"-"`
}

/tables/bigmaps

func CopyBigmapAlloc

func CopyBigmapAlloc(b *BigmapAlloc, op *Op, dst int64) *BigmapAlloc

func NewBigmapAlloc

func NewBigmapAlloc(op *Op, b micheline.BigmapEvent) *BigmapAlloc

func (*BigmapAlloc) GetKeyType

func (b *BigmapAlloc) GetKeyType() micheline.Type

func (*BigmapAlloc) GetKeyTypeBytes

func (b *BigmapAlloc) GetKeyTypeBytes() []byte

func (*BigmapAlloc) GetValueType

func (b *BigmapAlloc) GetValueType() micheline.Type

func (*BigmapAlloc) GetValueTypeBytes

func (b *BigmapAlloc) GetValueTypeBytes() []byte

func (*BigmapAlloc) ID

func (m *BigmapAlloc) ID() uint64

func (BigmapAlloc) IndexOpts

func (m BigmapAlloc) IndexOpts(key string) pack.Options

func (*BigmapAlloc) Reset

func (m *BigmapAlloc) Reset()

func (*BigmapAlloc) SetID

func (m *BigmapAlloc) SetID(id uint64)

func (BigmapAlloc) TableKey

func (m BigmapAlloc) TableKey() string

func (BigmapAlloc) TableOpts

func (m BigmapAlloc) TableOpts() pack.Options

func (*BigmapAlloc) ToRemove

func (b *BigmapAlloc) ToRemove(op *Op) *BigmapUpdate

func (*BigmapAlloc) ToUpdate

func (b *BigmapAlloc) ToUpdate(op *Op) *BigmapUpdate

func (*BigmapAlloc) ToUpdateCopy

func (b *BigmapAlloc) ToUpdateCopy(op *Op, srcid int64) *BigmapUpdate

type BigmapUpdate

type BigmapUpdate struct {
	RowId     uint64               `pack:"I,pk"             json:"row_id"`    // internal: id
	BigmapId  int64                `pack:"B,i32,bloom"      json:"bigmap_id"` // unique bigmap id
	KeyId     uint64               `pack:"K,bloom=3,snappy" json:"key_id"`    // xxhash(BigmapId, KeyHash)
	Action    micheline.DiffAction `pack:"a,u8"             json:"action"`    // action (alloc, copy, update, remove)
	OpId      OpID                 `pack:"o"                json:"op_id"`     // operation id
	Height    int64                `pack:"h,i32"            json:"height"`    // creation time
	Timestamp time.Time            `pack:"t"                json:"time"`      // creation height
	Key       []byte               `pack:"k,snappy"         json:"key"`       // key/value bytes: binary encoded micheline.Prim
	Value     []byte               `pack:"v,snappy"         json:"value"`     // key/value bytes: binary encoded micheline.Prim, (Pair(int,int) on copy)
}

/tables/bigmap_updates

func NewBigmapUpdate

func NewBigmapUpdate(op *Op, b micheline.BigmapEvent) *BigmapUpdate

func (*BigmapUpdate) GetKey

func (b *BigmapUpdate) GetKey(typ micheline.Type) (micheline.Key, error)

func (*BigmapUpdate) GetKeyHash

func (b *BigmapUpdate) GetKeyHash() tezos.ExprHash

func (*BigmapUpdate) GetKeyType

func (b *BigmapUpdate) GetKeyType() micheline.Type

func (*BigmapUpdate) GetValue

func (b *BigmapUpdate) GetValue(typ micheline.Type) micheline.Value

func (*BigmapUpdate) GetValueType

func (b *BigmapUpdate) GetValueType() micheline.Type

func (*BigmapUpdate) ID

func (m *BigmapUpdate) ID() uint64

func (BigmapUpdate) IndexOpts

func (m BigmapUpdate) IndexOpts(key string) pack.Options

func (*BigmapUpdate) Reset

func (m *BigmapUpdate) Reset()

func (*BigmapUpdate) SetID

func (m *BigmapUpdate) SetID(id uint64)

func (BigmapUpdate) TableKey

func (m BigmapUpdate) TableKey() string

func (BigmapUpdate) TableOpts

func (m BigmapUpdate) TableOpts() pack.Options

func (*BigmapUpdate) ToAlloc

func (b *BigmapUpdate) ToAlloc() *BigmapAlloc

func (*BigmapUpdate) ToEvent

func (b *BigmapUpdate) ToEvent() micheline.BigmapEvent

func (*BigmapUpdate) ToKV

func (b *BigmapUpdate) ToKV() *BigmapValue

type BigmapValue

type BigmapValue struct {
	RowId    uint64 `pack:"I,pk"             json:"row_id"`    // internal: id
	BigmapId int64  `pack:"B,i32,bloom"      json:"bigmap_id"` // unique bigmap id
	Height   int64  `pack:"h,i32"            json:"height"`    // update height
	KeyId    uint64 `pack:"K,bloom=3,snappy" json:"key_id"`    // xxhash(BigmapId, KeyHash)
	Key      []byte `pack:"k,snappy"         json:"key"`       // key/value bytes: binary encoded micheline.Prim Pair
	Value    []byte `pack:"v,snappy"         json:"value"`     // key/value bytes: binary encoded micheline.Prim Pair
}

/tables/bigmap_values

func CopyBigmapValue

func CopyBigmapValue(b *BigmapValue, dst, height int64) *BigmapValue

func NewBigmapValue

func NewBigmapValue(b micheline.BigmapEvent, height int64) *BigmapValue

func (*BigmapValue) GetKey

func (b *BigmapValue) GetKey(typ micheline.Type) (micheline.Key, error)

func (*BigmapValue) GetKeyHash

func (b *BigmapValue) GetKeyHash() tezos.ExprHash

func (*BigmapValue) GetValue

func (b *BigmapValue) GetValue(typ micheline.Type) micheline.Value

func (*BigmapValue) ID

func (m *BigmapValue) ID() uint64

func (BigmapValue) IndexOpts

func (m BigmapValue) IndexOpts(key string) pack.Options

func (*BigmapValue) Reset

func (m *BigmapValue) Reset()

func (*BigmapValue) SetID

func (m *BigmapValue) SetID(id uint64)

func (BigmapValue) TableKey

func (m BigmapValue) TableKey() string

func (BigmapValue) TableOpts

func (m BigmapValue) TableOpts() pack.Options

func (*BigmapValue) ToUpdateCopy

func (b *BigmapValue) ToUpdateCopy(op *Op) *BigmapUpdate

func (*BigmapValue) ToUpdateRemove

func (b *BigmapValue) ToUpdateRemove(op *Op) *BigmapUpdate

type Block

type Block struct {
	RowId                  uint64                 `pack:"I,pk"             json:"row_id"`
	ParentId               uint64                 `pack:"P"                json:"parent_id"`
	Hash                   tezos.BlockHash        `pack:"H,snappy,bloom=3" json:"hash"`
	Height                 int64                  `pack:"h,i32"            json:"height"`
	Cycle                  int64                  `pack:"c,i16"            json:"cycle"`
	IsCycleSnapshot        bool                   `pack:"o,snappy"         json:"is_cycle_snapshot"`
	Timestamp              time.Time              `pack:"T"                json:"time"`
	Solvetime              int                    `pack:"d,i16"            json:"solvetime"`
	Version                int                    `pack:"v,i8"             json:"version"`
	Round                  int                    `pack:"p,i8"             json:"round"`
	Nonce                  uint64                 `pack:"n,snappy"         json:"nonce"`
	VotingPeriodKind       tezos.VotingPeriodKind `pack:"k,u8"             json:"voting_period_kind"`
	BakerId                AccountID              `pack:"B,u32"            json:"baker_id"`
	ProposerId             AccountID              `pack:"X,u32"            json:"proposer_id"`
	NSlotsEndorsed         int                    `pack:"e,i16"            json:"n_endorsed_slots"`
	NOpsApplied            int                    `pack:"1,i16"            json:"n_ops_applied"`
	NOpsFailed             int                    `pack:"2,i16"            json:"n_ops_failed"`
	NContractCalls         int                    `pack:"3,i16"            json:"n_calls"`
	NRollupCalls           int                    `pack:"6,i16"            json:"n_rollup_calls"`
	NEvents                int                    `pack:"4,i16"            json:"n_events"`
	NTx                    int                    `pack:"5,i16"            json:"n_tx"`
	NTickets               int                    `pack:"7,i16"            json:"n_tickets"`
	Volume                 int64                  `pack:"V"                json:"volume"`
	Fee                    int64                  `pack:"F"                json:"fee"`
	Reward                 int64                  `pack:"R"                json:"reward"`
	Deposit                int64                  `pack:"D"                json:"deposit"`
	ActivatedSupply        int64                  `pack:"S"                json:"activated_supply"`
	BurnedSupply           int64                  `pack:"b"                json:"burned_supply"`
	MintedSupply           int64                  `pack:"m"                json:"minted_supply"`
	SeenAccounts           int                    `pack:"a,i16"            json:"n_accounts"`
	NewAccounts            int                    `pack:"A,i16"            json:"n_new_accounts"`
	NewContracts           int                    `pack:"C,i16"            json:"n_new_contracts"`
	ClearedAccounts        int                    `pack:"E,i16"            json:"n_cleared_accounts"`
	FundedAccounts         int                    `pack:"J,i16"            json:"n_funded_accounts"`
	GasLimit               int64                  `pack:"L,i32"            json:"gas_limit"`
	GasUsed                int64                  `pack:"G,i32"            json:"gas_used"`
	StoragePaid            int64                  `pack:"Y,i32"            json:"storage_paid"`
	LbVote                 tezos.FeatureVote      `pack:"O,snappy"         json:"lb_vote"`
	LbEma                  int64                  `pack:"M,i32"            json:"lb_ema"`
	AiVote                 tezos.FeatureVote      `pack:"z,snappy"         json:"ai_vote"`
	AiEma                  int64                  `pack:"i,i32"            json:"ai_ema"`
	ProposerConsensusKeyId AccountID              `pack:"x"                json:"proposer_consensus_key_id"`
	BakerConsensusKeyId    AccountID              `pack:"y"                json:"baker_consensus_key_id"`

	// other tz or extracted/translated data for processing
	TZ               *rpc.Bundle `pack:"-" json:"-"`
	Params           *rpc.Params `pack:"-" json:"-"`
	Chain            *Chain      `pack:"-" json:"-"`
	Supply           *Supply     `pack:"-" json:"-"`
	Ops              []*Op       `pack:"-" json:"-"`
	Flows            []*Flow     `pack:"-" json:"-"`
	Baker            *Baker      `pack:"-" json:"-"`
	Proposer         *Baker      `pack:"-" json:"-"`
	Parent           *Block      `pack:"-" json:"-"`
	HasProposals     bool        `pack:"-" json:"-"`
	HasBallots       bool        `pack:"-" json:"-"`
	HasSeeds         bool        `pack:"-" json:"-"`
	OfflineBaker     AccountID   `pack:"-" json:"-"`
	OfflineEndorsers []AccountID `pack:"-" json:"-"`
}

Block contains extracted and translated data describing a Tezos block. Block also contains raw data and translations for related types such as operations, chain totals rights, etc. that is used by indexers and reporters

func AllocBlock

func AllocBlock() *Block

func NewBlock

func NewBlock(tz *rpc.Bundle, parent *Block) (*Block, error)

func (*Block) Age

func (b *Block) Age(height int64) int64

used for token age in flows and ops

func (*Block) Clean

func (b *Block) Clean()

func (Block) Clone

func (b Block) Clone() *Block

func (*Block) FetchRPC

func (b *Block) FetchRPC(ctx context.Context, c *rpc.Client) error

func (*Block) Free

func (b *Block) Free()

func (*Block) GetOpId

func (b *Block) GetOpId(opn, opc, opi int) (OpID, bool)

func (Block) ID

func (b Block) ID() uint64

func (Block) IndexOpts

func (m Block) IndexOpts(key string) pack.Options

func (*Block) IsProtocolUpgrade

func (b *Block) IsProtocolUpgrade() bool

func (*Block) NextN

func (b *Block) NextN() int

func (*Block) Reset

func (b *Block) Reset()

func (*Block) Rollback

func (b *Block) Rollback(accounts map[AccountID]*Account, bakers map[AccountID]*Baker)

func (*Block) SetID

func (b *Block) SetID(id uint64)

func (Block) TableKey

func (m Block) TableKey() string

func (Block) TableOpts

func (m Block) TableOpts() pack.Options

func (Block) Time

func (b Block) Time() time.Time

be compatible with time series interface

func (*Block) Update

func (b *Block) Update(accounts map[AccountID]*Account, bakers map[AccountID]*Baker)

type BlockBuilder

type BlockBuilder interface {
	// resolves account from builder cache, returns nil and false when not found
	AccountByAddress(tezos.Address) (*Account, bool)

	// resolves account from database, returns nil and error when not found
	LoadAccountByAddress(context.Context, tezos.Address) (*Account, error)

	// resolves account from id, returns nil and false when not found
	AccountById(AccountID) (*Account, bool)

	// resolves baker from address, returns nil and false when not found
	BakerByAddress(tezos.Address) (*Baker, bool)

	// resolves baker from id, returns nil and false when not found
	BakerById(AccountID) (*Baker, bool)

	// resolves contract from account id, returns nil and false when not found
	ContractById(AccountID) (*Contract, bool)

	// returns a map of all accounts referenced in the current block
	Accounts() map[AccountID]*Account

	// returns a map of all delegates referenced in the current block
	Bakers() map[AccountID]*Baker

	// returns a map of all contracts referenced in the current block
	Contracts() map[AccountID]*Contract

	// returns a map of all constants referenced in the current block
	Constants() micheline.ConstantDict

	// return params at specific height
	Params(int64) *rpc.Params

	// returns the requested database table if exists or error otherwise
	Table(string) (*pack.Table, error)

	// returns global task scheduler
	Sched() *task.Scheduler

	// returns true if indexer is run in light mode
	IsLightMode() bool
}

BlockBuilder is an interface to access block builder caches and info.

type BlockCrawler

type BlockCrawler interface {
	// returns the requested database table if exists or error otherwise
	Table(string) (*pack.Table, error)

	// returns the blockchain params at specified block height
	ParamsByHeight(height int64) *rpc.Params

	// returns the blockchain params for the specified protocol
	ParamsByProtocol(proto tezos.ProtocolHash) *rpc.Params

	// returns the current crawler chain tip
	Tip() *ChainTip

	// returns the crawler's most recently seen block height
	Height() int64

	// returns stored (main chain) block at specified height
	BlockByHeight(ctx context.Context, height int64) (*Block, error)

	// returns stored chain data at specified height
	ChainByHeight(ctx context.Context, height int64) (*Chain, error)

	// returns stored supply table data at specified height
	SupplyByHeight(ctx context.Context, height int64) (*Supply, error)

	// returns height for timestamp
	BlockHeightFromTime(ctx context.Context, tm time.Time) int64
}

BlockCrawler is an interface to access the block crawler state and execute DB queries.

type BlockIndexer

type BlockIndexer interface {
	// Name returns the human-readable name of the index.
	Name() string

	// Key returns the key of the index as a string.
	Key() string

	// Create is invoked when the indexer manager determines the index needs
	// to be created for the first time.
	Create(path, label string, opts interface{}) error

	// Init is invoked when the table manager is first initializing the
	// datastore.  This differs from the Create method in that it is called on
	// every load, including the case the datatable was just created.
	Init(path, label string, opts interface{}) error

	// ConnectBlock is invoked when the table manager is notified that a new
	// block has been connected to the main chain.
	ConnectBlock(ctx context.Context, block *Block, builder BlockBuilder) error

	// DisconnectBlock is invoked when the table manager is notified that a
	// block has been disconnected from the main chain.
	DisconnectBlock(ctx context.Context, block *Block, builder BlockBuilder) error

	// DeleteBlock is invoked when the table manager is notified that a
	// block must be rolled back after an error occured.
	DeleteBlock(ctx context.Context, height int64) error

	// DeleteCycle is invoked when an index must delete all content from
	// a particular cycle.
	DeleteCycle(ctx context.Context, cycle int64) error

	// FinalizeSync is invoked when an the initial sync has finished. It may
	// be used to clean and defrag tables or (re)build indexes.
	FinalizeSync(ctx context.Context) error

	// OnTaskComplete is called when a scheduled task completes.
	OnTaskComplete(context.Context, *task.TaskResult) error

	// Flush flushes all indexer databases.
	Flush(ctx context.Context) error

	// Close closes the indexer and frees all associated resources, if any.
	Close() error

	// returns the database storing all indexer tables
	DB() *pack.DB

	// returns the list of database tables used by the indexer
	Tables() []*pack.Table
}

BlockIndexer is the interface all indexers must implement.

type Chain

type Chain struct {
	RowId                uint64    `pack:"I,pk,snappy"       json:"row_id"`                    // unique id
	Height               int64     `pack:"a,i32,snappy"      json:"height"`                    // bc: block height (also for orphans)
	Cycle                int64     `pack:"b,i16,snappy"      json:"cycle"`                     // bc: block cycle (tezos specific)
	Timestamp            time.Time `pack:"c,snappy"          json:"time"`                      // bc: block creation time
	TotalAccounts        int64     `pack:"d,i32,snappy"      json:"total_accounts"`            // default accounts
	TotalContracts       int64     `pack:"e,i32,snappy"      json:"total_contracts"`           // smart contracts (KT1 with code)
	TotalRollups         int64     `pack:"f,i32,snappy"      json:"total_rollups"`             // rollups (any kind)
	TotalOps             int64     `pack:"g,i32,snappy"      json:"total_ops"`                 //
	TotalOpsFailed       int64     `pack:"h,i32,snappy"      json:"total_ops_failed"`          //
	TotalContractOps     int64     `pack:"i,i32,snappy"      json:"total_contract_ops"`        // ops on KT1 contracts
	TotalContractCalls   int64     `pack:"j,i32,snappy"      json:"total_contract_calls"`      // calls from EOA to KT1 contracts with params
	TotalRollupCalls     int64     `pack:"k,i32,snappy"      json:"total_rollup_calls"`        // calls from EOA or KT1 to rollups
	TotalActivations     int64     `pack:"l,i32,snappy"      json:"total_activations"`         // fundraiser accounts activated
	TotalSeedNonces      int64     `pack:"m,i32,snappy"      json:"total_nonce_revelations"`   //
	TotalEndorsements    int64     `pack:"n,i32,snappy"      json:"total_endorsements"`        //
	TotalPreendorsements int64     `pack:"o,i32,snappy"      json:"total_preendorsements"`     //
	TotalDoubleBake      int64     `pack:"p,i32,snappy"      json:"total_double_bakings"`      //
	TotalDoubleEndorse   int64     `pack:"q,i32,snappy"      json:"total_double_endorsements"` //
	TotalDelegations     int64     `pack:"r,i32,snappy"      json:"total_delegations"`         //
	TotalReveals         int64     `pack:"s,i32,snappy"      json:"total_reveals"`             //
	TotalOriginations    int64     `pack:"t,i32,snappy"      json:"total_originations"`        //
	TotalTransactions    int64     `pack:"u,i32,snappy"      json:"total_transactions"`        //
	TotalProposals       int64     `pack:"v,i32,snappy"      json:"total_proposals"`           //
	TotalBallots         int64     `pack:"w,i32,snappy"      json:"total_ballots"`             //
	TotalConstants       int64     `pack:"x,i32,snappy"      json:"total_constants"`           // registered global constants
	TotalSetLimits       int64     `pack:"y,i32,snappy"      json:"total_set_limits"`          // registered global constants
	TotalStorageBytes    int64     `pack:"z,snappy"          json:"total_storage_bytes"`       //
	TotalTicketTransfers int64     `pack:"1,i32,snappy"      json:"total_ticket_transfers"`    // transfer ticket
	FundedAccounts       int64     `pack:"2,i32,snappy"      json:"funded_accounts"`           // total number of accounts qith non-zero balance
	DustAccounts         int64     `pack:"3,i32,snappy"      json:"dust_accounts"`             // accounts with a balance < 1 tez
	GhostAccounts        int64     `pack:"4,i32,snappy"      json:"ghost_accounts"`            // unfunded L2 accounts (who own tokens, but cannot move them)
	UnclaimedAccounts    int64     `pack:"5,i16,snappy"      json:"unclaimed_accounts"`        // fundraiser accounts unclaimed
	TotalDelegators      int64     `pack:"6,i32,snappy"      json:"total_delegators"`          // count of all non-zero balance delegators
	ActiveDelegators     int64     `pack:"7,i32,snappy"      json:"active_delegators"`         // KT1 delegating to active bakers
	InactiveDelegators   int64     `pack:"8,i32,snappy"      json:"inactive_delegators"`       // KT1 delegating to inactive bakers
	DustDelegators       int64     `pack:"9,i32,snappy"      json:"dust_delegators"`           // KT1 delegating to inactive bakers
	TotalBakers          int64     `pack:"0,i16,snappy"      json:"total_bakers"`              // count of all bakers (active and inactive)
	EligibleBakers       int64     `pack:"A,i16,snappy"      json:"eligible_bakers"`           // bakers above minimum
	ActiveBakers         int64     `pack:"B,i16,snappy"      json:"active_bakers"`             // tz* active bakers
	InactiveBakers       int64     `pack:"C,i16,snappy"      json:"inactive_bakers"`           // tz* inactive bakers
	ZeroBakers           int64     `pack:"D,i16,snappy"      json:"zero_bakers"`               // tz* delegate with zero staking balance
	SelfBakers           int64     `pack:"E,i16,snappy"      json:"self_bakers"`               // tz* delegate with no incoming delegation
	SingleBakers         int64     `pack:"F,i16,snappy"      json:"single_bakers"`             // tz* delegate with 1 incoming delegation
	MultiBakers          int64     `pack:"G,i16,snappy"      json:"multi_bakers"`              // tz* delegate with >1 incoming delegations (delegation services)
	TotalStakers         int64     `pack:"H,i32,snappy"      json:"total_stakers"`             // wallets staking
	ActiveStakers        int64     `pack:"J,i32,snappy"      json:"active_stakers"`            // wallets staking with active bakers
	InactiveStakers      int64     `pack:"K,i32,snappy"      json:"inactive_stakers"`          // wallets staking with inactive bakers
}

func (*Chain) ID

func (c *Chain) ID() uint64

func (Chain) IndexOpts

func (m Chain) IndexOpts(key string) pack.Options

func (*Chain) Rollback

func (c *Chain) Rollback(b *Block)

func (*Chain) SetID

func (c *Chain) SetID(id uint64)

func (Chain) TableKey

func (m Chain) TableKey() string

func (Chain) TableOpts

func (m Chain) TableOpts() pack.Options

func (Chain) Time

func (c Chain) Time() time.Time

be compatible with time series interface

func (*Chain) Update

func (c *Chain) Update(b *Block, accounts map[AccountID]*Account, bakers map[AccountID]*Baker)

type ChainTip

type ChainTip struct {
	Name        string            `json:"name"`         // chain name, e.g. Bitcoin
	Symbol      string            `json:"symbol"`       // chain symbol, e.g. BTC
	ChainId     tezos.ChainIdHash `json:"chain_id"`     // chain identifier (same for all blocks)
	BestHash    tezos.BlockHash   `json:"last_block"`   // The hash of the chain tip block.
	BestId      uint64            `json:"last_id"`      // The internal blockindex id of the tip block;
	BestHeight  int64             `json:"height"`       // The height of the tip block.
	BestTime    time.Time         `json:"timestamp"`    // The timestamp of the tip block.
	GenesisTime time.Time         `json:"genesis_time"` // cache of first block generation time
	NYEveBlocks []int64           `json:"nye_blocks"`   // first block heights per year for annual statistics
	Deployments []Deployment      `json:"deployments"`  // protocol deployments
}

ChainTip reflects the blockchain state at the currently indexed height.

func (*ChainTip) AddDeployment

func (t *ChainTip) AddDeployment(p *rpc.Params)

func (*ChainTip) Clone

func (t *ChainTip) Clone() *ChainTip

type Constant

type Constant struct {
	RowId       ConstantID         `pack:"I,pk"      json:"row_id"`
	Address     tezos.ExprHash     `pack:"H,bloom=3" json:"address"`
	CreatorId   AccountID          `pack:"C,u32"     json:"creator_id"`
	Value       []byte             `pack:"v,snappy"  json:"value"`
	Height      int64              `pack:"h,i32"     json:"height"`
	StorageSize int64              `pack:"z,i32"     json:"storage_size"`
	Features    micheline.Features `pack:"F,snappy"  json:"features"`
}

Constant holds code and info about registered global constants

func NewConstant

func NewConstant(rop *rpc.ConstantRegistration, op *Op) *Constant

assuming the op was successful!

func (*Constant) ID

func (g *Constant) ID() uint64

func (Constant) IndexOpts

func (m Constant) IndexOpts(key string) pack.Options

func (*Constant) SetID

func (g *Constant) SetID(id uint64)

func (Constant) TableKey

func (m Constant) TableKey() string

func (Constant) TableOpts

func (m Constant) TableOpts() pack.Options

type ConstantID

type ConstantID uint64

func (ConstantID) U64

func (id ConstantID) U64() uint64

type Contract

type Contract struct {
	RowId          ContractID           `pack:"I,pk"      json:"row_id"`
	Address        tezos.Address        `pack:"H,bloom=3" json:"address"`
	AccountId      AccountID            `pack:"A,u32"     json:"account_id"`
	CreatorId      AccountID            `pack:"C,u32"     json:"creator_id"`
	FirstSeen      int64                `pack:"f,i32"     json:"first_seen"`
	LastSeen       int64                `pack:"l,i32"     json:"last_seen"`
	StorageSize    int64                `pack:"z,i32"     json:"storage_size"`
	StoragePaid    int64                `pack:"y,i32"     json:"storage_paid"`
	StorageBurn    int64                `pack:"Y"         json:"storage_burn"`
	Script         []byte               `pack:"s,snappy"  json:"script"`
	Storage        []byte               `pack:"g,snappy"  json:"storage"`
	InterfaceHash  uint64               `pack:"i,snappy"  json:"iface_hash"`
	CodeHash       uint64               `pack:"c,snappy"  json:"code_hash"`
	StorageHash    uint64               `pack:"x,snappy"  json:"storage_hash"`
	CallStats      []byte               `pack:"S,snappy"  json:"call_stats"`
	Features       micheline.Features   `pack:"F,snappy"  json:"features"`
	Interfaces     micheline.Interfaces `pack:"n,snappy"  json:"interfaces"`
	LedgerType     TokenType            `pack:"t"         json:"ledger_type"`
	LedgerSchema   LedgerSchema         `pack:"h"         json:"ledger_schema"`
	LedgerBigmap   int64                `pack:"b,i32"     json:"ledger_bigmap"`
	LedgerMeta     MetaID               `pack:"M"         json:"metadata_id"`
	MetadataBigmap int64                `pack:"m,i32"     json:"metadata_bigmap"`

	IsDirty bool `pack:"-" json:"-"` // indicates an update happened
	IsNew   bool `pack:"-" json:"-"` // new contract, used during migration
	// contains filtered or unexported fields
}

Contract holds code and info about smart contracts on the Tezos blockchain.

func AllocContract

func AllocContract() *Contract

func NewContract

func NewContract(acc *Account, oop *rpc.Origination, op *Op, dict micheline.ConstantDict, p *rpc.Params) *Contract

assuming the op was successful!

func NewImplicitContract

func NewImplicitContract(acc *Account, res rpc.ImplicitResult, op *Op, p *rpc.Params) *Contract

func NewInternalContract

func NewInternalContract(acc *Account, iop rpc.InternalResult, op *Op, dict micheline.ConstantDict, p *rpc.Params) *Contract

func NewManagerTzContract

func NewManagerTzContract(a *Account, height int64) (*Contract, error)

create manager.tz contract, used during migration only

func NewRollupContract

func NewRollupContract(acc *Account, op *Op, res rpc.OperationResult, p *rpc.Params) *Contract

func (*Contract) ConvertParams

func (c *Contract) ConvertParams(in micheline.Parameters) (out micheline.Parameters)

func (*Contract) DecCallStats

func (c *Contract) DecCallStats(entrypoint int)

func (*Contract) Free

func (c *Contract) Free()

func (*Contract) HeapSize

func (c *Contract) HeapSize() int

func (Contract) ID

func (c Contract) ID() uint64

func (*Contract) IncCallStats

func (c *Contract) IncCallStats(entrypoint int)

stats are stored as uint32 in a byte slice limit entrypoint count to 255

func (Contract) IndexOpts

func (m Contract) IndexOpts(key string) pack.Options

func (Contract) IsRollup

func (c Contract) IsRollup() bool

func (*Contract) ListCallStats

func (c *Contract) ListCallStats() map[string]int

func (*Contract) ListSmartRollupCallStats

func (c *Contract) ListSmartRollupCallStats() map[string]int

func (*Contract) ListTxRollupCallStats

func (c *Contract) ListTxRollupCallStats() map[string]int

func (*Contract) LoadScript

func (c *Contract) LoadScript() (*micheline.Script, error)

loads script and upgrades to babylon on-the-fly if originated earlier

func (*Contract) LoadType

func (c *Contract) LoadType() (ptyp micheline.Type, styp micheline.Type, err error)

Loads type data from already unmarshaled script or from optimized unmarshaler

func (*Contract) NamedBigmaps

func (c *Contract) NamedBigmaps(m []*BigmapAlloc) map[string]int64

func (*Contract) Reset

func (c *Contract) Reset()

func (*Contract) Rollback

func (c *Contract) Rollback(drop, last *Op, p *rpc.Params)

func (*Contract) SetID

func (c *Contract) SetID(id uint64)

func (Contract) String

func (c Contract) String() string

func (Contract) TableKey

func (m Contract) TableKey() string

func (Contract) TableOpts

func (m Contract) TableOpts() pack.Options

func (*Contract) Update

func (c *Contract) Update(op *Op, p *rpc.Params) bool

type ContractID

type ContractID uint64

func (ContractID) U64

func (id ContractID) U64() uint64

type Cycle

type Cycle struct {
	RowId                    uint64 `pack:"I,pk" json:"row_id"`
	Cycle                    int64  `pack:"a"    json:"cycle"`
	StartHeight              int64  `pack:"b"    json:"start_height"`
	EndHeight                int64  `pack:"c"    json:"end_height"`
	SnapshotHeight           int64  `pack:"d"    json:"snapshot_height"`
	SnapshotIndex            int    `pack:"e"    json:"snapshot_index"`
	MissedRounds             int    `pack:"f"    json:"missed_rounds"`
	MissedEndorsements       int    `pack:"g"    json:"missed_endorsements"`
	Num2Baking               int    `pack:"h"    json:"n_double_baking"`
	Num2Endorsement          int    `pack:"i"    json:"n_double_endorsement"`
	NumSeeds                 int    `pack:"j"    json:"n_seed_nonces"`
	SolveTimeMin             int    `pack:"k"    json:"solvetime_min"`
	SolveTimeMax             int    `pack:"l"    json:"solvetime_max"`
	SolveTimeSum             int    `pack:"m"    json:"solvetime_sum"`
	RoundMin                 int    `pack:"n"    json:"round_min"`
	RoundMax                 int    `pack:"o"    json:"round_max"`
	EndorsementsMin          int    `pack:"q"    json:"endorsements_min"`
	EndorsementsMax          int    `pack:"r"    json:"endorsements_max"`
	WorstBakedBlock          int64  `pack:"t"    json:"worst_baked_block"`
	WorstEndorsedBlock       int64  `pack:"u"    json:"worst_endorsed_block"`
	UniqueBakers             int    `pack:"v"    json:"unique_bakers"`
	BlockReward              int64  `pack:"w"    json:"block_reward"`
	BlockBonusPerSlot        int64  `pack:"x"    json:"block_bonus_per_slot"`
	MaxBlockReward           int64  `pack:"y"    json:"max_block_reward"`
	EndorsementRewardPerSlot int64  `pack:"z"    json:"endorsement_reward_per_slot"`
	NonceRevelationReward    int64  `pack:"1"    json:"nonce_revelation_reward"`
	VdfRevelationReward      int64  `pack:"2"    json:"vdf_revelation_reward"`
	LBSubsidy                int64  `pack:"3"    json:"lb_subsidy"`
}

Cycle is a per-cycle stats collector.

func (Cycle) ID

func (c Cycle) ID() uint64

func (Cycle) IndexOpts

func (m Cycle) IndexOpts(key string) pack.Options

func (*Cycle) SetID

func (c *Cycle) SetID(id uint64)

func (Cycle) TableKey

func (m Cycle) TableKey() string

func (Cycle) TableOpts

func (m Cycle) TableOpts() pack.Options

type Deployment

type Deployment struct {
	Protocol    tezos.ProtocolHash `json:"protocol"`
	Version     int                `json:"version"`      // protocol version
	Deployment  int                `json:"deployment"`   // protocol sequence id on indexed chain
	StartHeight int64              `json:"start_height"` // first block on indexed chain
	EndHeight   int64              `json:"end_height"`   // last block on indexed chain or -1
}

type Election

type Election struct {
	RowId        ElectionID `pack:"I,pk"      json:"row_id"`        // unique id
	ProposalId   ProposalID `pack:"P"         json:"proposal_id"`   // winning proposal id (after first vote)
	NumPeriods   int        `pack:"n,i8"      json:"num_periods"`   // number of periods processed (so far)
	NumProposals int        `pack:"N,i8"      json:"num_proposals"` // number of sumbitted proposals
	VotingPeriod int64      `pack:"p,i16"     json:"voting_period"` // protocol (proposal) voting period starting the election
	StartTime    time.Time  `pack:"T"         json:"start_time"`    // proposal voting period start
	EndTime      time.Time  `pack:"t"         json:"end_time"`      // last voting perid end, estimate when open
	StartHeight  int64      `pack:"H,i32"     json:"start_height"`  // proposal voting period start block
	EndHeight    int64      `pack:"h,i32"     json:"end_height"`    // last voting perid end block, estimate when open
	IsEmpty      bool       `pack:"e,snappy"  json:"is_empty"`      // no proposal published during this period
	IsOpen       bool       `pack:"o,snappy"  json:"is_open"`       // flag, election in progress
	IsFailed     bool       `pack:"f,snappy"  json:"is_failed"`     // flag, election aborted du to missing proposal or missed quorum/supermajority
	NoQuorum     bool       `pack:"!,snappy"  json:"no_quorum"`     // flag, quorum not reached
	NoMajority   bool       `pack:"m,snappy"  json:"no_majority"`   // flag, supermajority not reached
}

func (*Election) ID

func (e *Election) ID() uint64

func (Election) IndexOpts

func (m Election) IndexOpts(key string) pack.Options

func (*Election) SetID

func (e *Election) SetID(id uint64)

func (Election) TableKey

func (m Election) TableKey() string

func (Election) TableOpts

func (m Election) TableOpts() pack.Options

type ElectionID

type ElectionID uint64

An Election represents a unique voting cycle which may be between 1 and 4 voting periods in length. Elections finish with the activation of the winning proposal protocol after period 4 or abort at the end of period 1 when no proposal was published, at the end of periods 2 and 4 when no quorum or supermajority was reached. Period 3 always ends successfully.

func (ElectionID) U64

func (id ElectionID) U64() uint64

type Endorsement

type Endorsement struct {
	RowId    OpID         `pack:"I,pk,snappy"        json:"row_id"`            // internal: unique row id
	Hash     tezos.OpHash `pack:"H,snappy,bloom=3"   json:"hash"`              // op hash
	Height   int64        `pack:"h,i32,snappy"       json:"height"`            // block height
	OpN      int          `pack:"n,i16,snappy"       json:"op_n"`              // unique in-block pos
	OpP      int          `pack:"P,i16,snappy"       json:"op_p"`              // op list pos (list can be derived from type)
	Reward   int64        `pack:"r,snappy"           json:"reward"`            // baking/endorsement reward
	Deposit  int64        `pack:"d,snappy"           json:"deposit"`           // baker deposit
	SenderId AccountID    `pack:"S,u32,snappy,bloom" json:"sender_id"`         // sender id, also on internal ops
	Power    int64        `pack:"p,i16,snappy"       json:"power"`             // power
	IsPre    bool         `pack:"i,snappy"           json:"is_preendorsement"` // Ithaca pre-endorsement
}

func (Endorsement) ID

func (m Endorsement) ID() uint64

func (Endorsement) IndexOpts

func (m Endorsement) IndexOpts(key string) pack.Options

func (*Endorsement) SetID

func (m *Endorsement) SetID(id uint64)

func (Endorsement) TableKey

func (m Endorsement) TableKey() string

func (Endorsement) TableOpts

func (m Endorsement) TableOpts() pack.Options

func (Endorsement) ToOp

func (e Endorsement) ToOp() *Op

type Event

type Event struct {
	RowId     EventID   `pack:"I,pk"      json:"row_id"`
	Height    int64     `pack:"h,i32"     json:"height"`
	OpId      uint64    `pack:"o"         json:"op_id"` // unique external operation id
	AccountId AccountID `pack:"C,bloom=3" json:"account_id"`
	Type      []byte    `pack:"t,snappy"  json:"type"`
	Payload   []byte    `pack:"p,snappy"  json:"payload"`
	Tag       string    `pack:"a,snappy"  json:"tag"`
	TypeHash  uint64    `pack:"H,bloom"   json:"type_hash"`
}

Event holds location, type and content of on-chain events

func NewEvent

func NewEvent() *Event

func NewEventWithData

func NewEventWithData(ev rpc.InternalResult, src AccountID, op *Op) *Event

assuming the op was successful!

func (*Event) Free

func (m *Event) Free()

func (*Event) ID

func (e *Event) ID() uint64

func (Event) IndexOpts

func (m Event) IndexOpts(key string) pack.Options

func (*Event) Reset

func (m *Event) Reset()

func (*Event) SetID

func (e *Event) SetID(id uint64)

func (Event) TableKey

func (m Event) TableKey() string

func (Event) TableOpts

func (m Event) TableOpts() pack.Options

type EventID

type EventID uint64

func (EventID) U64

func (id EventID) U64() uint64

type FA1Transfer

type FA1Transfer TransferList

func (*FA1Transfer) UnmarshalPrim

func (t *FA1Transfer) UnmarshalPrim(prim micheline.Prim) error

type FA2Transfer

type FA2Transfer TransferList

func (*FA2Transfer) UnmarshalPrim

func (t *FA2Transfer) UnmarshalPrim(prim micheline.Prim) error

type Flow

type Flow struct {
	RowId          uint64    `pack:"I,pk"               json:"row_id"`
	Height         int64     `pack:"h,i32,snappy"       json:"height"`
	Cycle          int64     `pack:"c,i16,snappy"       json:"cycle"`
	Timestamp      time.Time `pack:"T,snappy"           json:"time"`
	OpN            int       `pack:"1,i16,snappy"       json:"op_n"`
	OpC            int       `pack:"2,i16,snappy"       json:"op_c"`
	OpI            int       `pack:"3,i16,snappy"       json:"op_i"`
	AccountId      AccountID `pack:"A,u32,snappy,bloom" json:"account_id"`
	CounterPartyId AccountID `pack:"R,u32,snappy"       json:"counterparty_id"` // account that initiated the flow
	Kind           FlowKind  `pack:"C,u8,snappy,bloom"  json:"kind"`            // sub-account that received the update
	Type           FlowType  `pack:"O,u8,snappy,bloom"  json:"type"`            // op type that caused this update
	AmountIn       int64     `pack:"i,snappy"           json:"amount_in"`       // sum flowing in to the account
	AmountOut      int64     `pack:"o,snappy"           json:"amount_out"`      // sum flowing out of the account
	IsFee          bool      `pack:"e,snappy"           json:"is_fee"`          // flag: out-flow paid a fee
	IsBurned       bool      `pack:"b,snappy"           json:"is_burned"`       // flag: out-flow was burned
	IsFrozen       bool      `pack:"f,snappy"           json:"is_frozen"`       // flag: in-flow is frozen
	IsUnfrozen     bool      `pack:"u,snappy"           json:"is_unfrozen"`     // flag: out-flow was unfrozen (rewards -> balance)
	IsShielded     bool      `pack:"y,snappy"           json:"is_shielded"`     // flag: in-flow was shielded (Sapling)
	IsUnshielded   bool      `pack:"Y,snappy"           json:"is_unshielded"`   // flag: out-flow was unshielded (Sapling)
	TokenAge       int64     `pack:"a,i32,snappy"       json:"token_age"`       // time since last transfer in seconds
}

func NewFlow

func NewFlow(b *Block, acc *Account, cntr *Account, id OpRef) *Flow

func (*Flow) Free

func (f *Flow) Free()

func (*Flow) ID

func (f *Flow) ID() uint64

func (Flow) IndexOpts

func (m Flow) IndexOpts(key string) pack.Options

func (*Flow) Reset

func (f *Flow) Reset()

func (*Flow) SetID

func (f *Flow) SetID(id uint64)

func (Flow) TableKey

func (m Flow) TableKey() string

func (Flow) TableOpts

func (m Flow) TableOpts() pack.Options

func (Flow) Time

func (f Flow) Time() time.Time

be compatible with time series interface

type FlowKind

type FlowKind byte
const (
	FlowKindRewards    FlowKind = iota // 0 freezer category
	FlowKindDeposits                   // 1 freezer category
	FlowKindFees                       // 2 freezer category
	FlowKindBalance                    // 3 spendable balance
	FlowKindDelegation                 // 4 delegated balance from other accounts
	FlowKindBond                       // 5 rollup bond
	FlowKindStake                      // 6 staking
	FlowKindInvalid
)

func ParseFlowKind

func ParseFlowKind(s string) FlowKind

func (FlowKind) IsValid

func (c FlowKind) IsValid() bool

func (FlowKind) String

func (c FlowKind) String() string

type FlowType

type FlowType byte
const (
	FlowTypeEndorsement           FlowType = iota // 0
	FlowTypeTransaction                           // 1
	FlowTypeOrigination                           // 2
	FlowTypeDelegation                            // 3
	FlowTypeReveal                                // 4
	FlowTypeBaking                                // 5
	FlowTypeNonceRevelation                       // 6
	FlowTypeActivation                            // 7
	FlowTypePenalty                               // 8
	FlowTypeInternal                              // 9 - used for unfreeze
	FlowTypeInvoice                               // 10 - invoice feature
	FlowTypeAirdrop                               // 11 - Babylon Airdrop
	FlowTypeSubsidy                               // 12 - Granada liquidity baking
	FlowTypeRegisterConstant                      // 13 - Hangzhou+
	FlowTypeBonus                                 // 14 - Ithaca+ baking bonus
	FlowTypeReward                                // 15 - Ithaca+ endorsing reward (or slash)
	FlowTypeDeposit                               // 16 - Ithaca+ deposit transfer
	FlowTypeDepositsLimit                         // 17 - Ithaca+
	FlowTypeRollupOrigination                     // 18 - Jakarta+
	FlowTypeRollupTransaction                     // 19 - Jakarta+
	FlowTypeRollupReward                          // 20 - Jakarta+
	FlowTypeRollupPenalty                         // 21 - Jakarta+
	FlowTypePayStorage                            // 22 - Kathmandu+
	FlowTypeUpdateConsensusKey                    // 23 - Lima+
	FlowTypeDrain                                 // 24 - Lima+
	FlowTypeTransferTicket                        // 25 - Jakarta+
	FlowTypeStake                                 // 26 - Oxford+
	FlowTypeUnstake                               // 27 - Oxford+
	FlowTypeFinalizeUnstake                       // 28 - Oxford+
	FlowTypeSetDelegateParameters                 // 29 - Oxford+
	FlowTypeInvalid               = 255
)

func MapFlowType

func MapFlowType(typ OpType) FlowType

func ParseFlowType

func ParseFlowType(s string) FlowType

func (FlowType) IsValid

func (t FlowType) IsValid() bool

func (*FlowType) MarshalText

func (t *FlowType) MarshalText() ([]byte, error)

func (FlowType) String

func (t FlowType) String() string

func (*FlowType) UnmarshalText

func (t *FlowType) UnmarshalText(data []byte) error

type Income

type Income struct {
	RowId                  uint64    `pack:"I,pk,snappy"     json:"row_id"`
	Cycle                  int64     `pack:"c,i16,snappy"    json:"cycle"`
	StartHeight            int64     `pack:"h,i32"           json:"start_height"`
	EndHeight              int64     `pack:"e,i32"           json:"end_height"`
	AccountId              AccountID `pack:"A,u32,snappy"    json:"account_id"`
	Balance                int64     `pack:"B,snappy"        json:"balance"`         // @snapshot
	Delegated              int64     `pack:"d,snappy"        json:"delegated"`       // @snapshot
	OwnStake               int64     `pack:"b,snappy"        json:"own_stake"`       // @snapshot
	StakingBalance         int64     `pack:"S,snappy"        json:"staking_balance"` // @snapshot
	NDelegations           int64     `pack:"n,i32,snappy"    json:"n_delegations"`   // @snapshot
	NStakers               int64     `pack:"#,i32,snappy"    json:"n_stakers"`       // @snapshot
	NBakingRights          int64     `pack:"R,i16,snappy"    json:"n_baking_rights"`
	NEndorsingRights       int64     `pack:"r,i32,snappy"    json:"n_endorsing_rights"`
	Luck                   int64     `pack:"L,snappy"        json:"luck"`                       // coins by fair share of stake
	LuckPct                int64     `pack:"l,d32,scale=2,snappy"  json:"luck_percent"`         // 0.0 .. +N.00 by fair share of stake
	ContributionPct        int64     `pack:"t,d32,scale=2,snappy"  json:"contribution_percent"` // 0.0 .. +N.00 by rights utilized
	PerformancePct         int64     `pack:"p,d32,scale=2,snappy"  json:"performance_percent"`  // -N.00 .. +N.00 by expected income
	NBlocksBaked           int64     `pack:"k,i16,snappy"    json:"n_blocks_baked"`
	NBlocksProposed        int64     `pack:"K,i16,snappy"    json:"n_blocks_proposed"`
	NBlocksNotBaked        int64     `pack:"N,i16,snappy"    json:"n_blocks_not_baked"`
	NBlocksEndorsed        int64     `pack:"E,i16,snappy"    json:"n_blocks_endorsed"`
	NBlocksNotEndorsed     int64     `pack:"X,i16,snappy"    json:"n_blocks_not_endorsed"`
	NSlotsEndorsed         int64     `pack:"Z,i32,snappy"    json:"n_slots_endorsed"`
	NSeedsRevealed         int64     `pack:"s,i16,snappy"    json:"n_seeds_revealed"`
	ExpectedIncome         int64     `pack:"f,snappy"        json:"expected_income"`
	TotalIncome            int64     `pack:"i,snappy"        json:"total_income"`
	BakingIncome           int64     `pack:"1,snappy"        json:"baking_income"`
	EndorsingIncome        int64     `pack:"2,snappy"        json:"endorsing_income"`
	AccusationIncome       int64     `pack:"3,snappy"        json:"accusation_income"`
	SeedIncome             int64     `pack:"4,snappy"        json:"seed_income"`
	FeesIncome             int64     `pack:"5,snappy"        json:"fees_income"`
	TotalLoss              int64     `pack:"6,snappy"        json:"total_loss"`
	AccusationLoss         int64     `pack:"7,snappy"        json:"accusation_loss"`
	SeedLoss               int64     `pack:"8,snappy"        json:"seed_loss"`
	EndorsingLoss          int64     `pack:"9,snappy"        json:"endorsing_loss"`
	LostAccusationFees     int64     `pack:"F,snappy"        json:"lost_accusation_fees"`     // from denunciations
	LostAccusationRewards  int64     `pack:"W,snappy"        json:"lost_accusation_rewards"`  // from denunciations
	LostAccusationDeposits int64     `pack:"D,snappy"        json:"lost_accusation_deposits"` // from denunciations
	LostSeedFees           int64     `pack:"V,snappy"        json:"lost_seed_fees"`           // from missed seed nonce revelations
	LostSeedRewards        int64     `pack:"Y,snappy"        json:"lost_seed_rewards"`        // from missed seed nonce revelations

}

Income is a per-cycle income sheet for baker accounts.

func NewIncome

func NewIncome() *Income

func (*Income) Free

func (s *Income) Free()

func (Income) ID

func (s Income) ID() uint64

func (Income) IndexOpts

func (m Income) IndexOpts(key string) pack.Options

func (*Income) Reset

func (s *Income) Reset()

func (*Income) SetID

func (s *Income) SetID(id uint64)

func (Income) TableKey

func (m Income) TableKey() string

func (Income) TableOpts

func (m Income) TableOpts() pack.Options

func (*Income) UpdateLuck

func (s *Income) UpdateLuck(totalStake int64, p *rpc.Params)

func (*Income) UpdatePerformance

func (v *Income) UpdatePerformance(reliability int64)

type LedgerBalance

type LedgerBalance struct {
	Owner   tezos.Address
	TokenId tezos.Z
	Balance tezos.Z
	Name    string // use for domain names

	// internal
	OwnerRef *TokenOwner // hook
	TokenRef *Token      // hook
	// contains filtered or unexported fields
}

func (LedgerBalance) IsValid

func (b LedgerBalance) IsValid() bool

func (*LedgerBalance) UnmarshalPrim

func (b *LedgerBalance) UnmarshalPrim(prim micheline.Prim) error

type LedgerDomain

type LedgerDomain LedgerBalance

// 15 Tezos Domains // - records KT1GBZmSxmnKJXGMdMLbugPfLyUPmuLSMwKS // Note: records contain a tzip12_token_id, but key is bytes (domain name) // sale example: https://tzstats.com/onzVjWA6LeBSEYd4ZEpiyfiHo7z2kcuqmeM94YD2t7fmoxQ1Zyr LedgerSchemaDomain: micheline.NewPairType(

micheline.NewCode(micheline.T_BYTES), // domain name
micheline.NewPairType(
    micheline.NewPairType(
        micheline.NewPairType(
            micheline.NewOptType(micheline.NewCode(micheline.T_ADDRESS)), // address
            micheline.NewMapType( // data
                micheline.NewCode(micheline.T_STRING), // key
                micheline.NewCode(micheline.T_BYTES),  // value
            ),
        ),
        micheline.NewPairType(
            micheline.NewOptType(micheline.NewCode(micheline.T_BYTES)), // expiry_key
            micheline.NewMapType( // internal_data
                micheline.NewCode(micheline.T_STRING), // key
                micheline.NewCode(micheline.T_BYTES),  // value
            ),
        ),
    ),
    micheline.NewPairType(
        micheline.NewPairType(
            micheline.NewCode(micheline.T_NAT),     // level
            micheline.NewCode(micheline.T_ADDRESS), // owner
        ),
        micheline.NewOptType(micheline.NewCode(micheline.T_NAT)), // tzip12_token_id
    ),
),

),

func (*LedgerDomain) UnmarshalPrim

func (b *LedgerDomain) UnmarshalPrim(prim micheline.Prim) error

type LedgerFAa

type LedgerFAa LedgerBalance

5 FA 1.2 with approvals USDtez ledger KT1LN4LPSqTMS7Sd2CJw4bbDGRkMv2t68Fy9 PAUL ledger KT19DUSZw7mfeEATrbWVPHRrWNVbNnmfFAE6 @key: address @value: {0: nat, 1: map { @key: address @val: nat }

func (*LedgerFAa) UnmarshalPrim

func (b *LedgerFAa) UnmarshalPrim(prim micheline.Prim) error

type LedgerFAb

type LedgerFAb LedgerBalance

6 FA 1.2 with approvals (flipped order) - HEH balances KT1G1cCRNBgQ48mVDjopHjEmTN5Sbtar8nn9 @key: address @value: {0: nat, 1: map { @key: address @val: nat }

func (*LedgerFAb) UnmarshalPrim

func (b *LedgerFAb) UnmarshalPrim(prim micheline.Prim) error

type LedgerFAc

type LedgerFAc LedgerBalance

7 FA1.2 without approvals - Ctez tokens KT1SjXiUX63QvdNMcM2m492f7kuf8JxXRLp4 - Kalamint ledger KT1A5P4ejnLix13jtadsfV9GCnXLMNnab8UT (FA2 !!) - liquidity-baking tokens KT1AafHA1C1vk959wvHWBispY9Y2f3fxBUUo - Staker Gov token.ledger KT1AEfeckNbdEYwaMKkytBwPJPycz7jdSGea @key: address @value: nat

func (*LedgerFAc) UnmarshalPrim

func (b *LedgerFAc) UnmarshalPrim(prim micheline.Prim) error

type LedgerFAd

type LedgerFAd LedgerBalance

8 FA2 without operators/approvals (== NFT1) - WRAP assets.ledger KT18fp5rcTW7mbWDmzFwjLDUhs5MeJmagDSZ - hDAO ledger KT1AFA2mwNUMNd4SsujE1YYp29vd8BZejyKW @key: {0:address, 1:nat} @value: nat

func (*LedgerFAd) UnmarshalPrim

func (b *LedgerFAd) UnmarshalPrim(prim micheline.Prim) error

type LedgerFAe

type LedgerFAe LedgerBalance

9 FA2 with balance map and allowance set - QuipuSwap Governance Token (name: account_info) KT193D4vozYnhGJQVtw7CoxxqphqUEEwK6Vb @key: address @value: {map: nat -> nat } // token_id -> balance

{set: address } // allowances

func (*LedgerFAe) UnmarshalPrim

func (b *LedgerFAe) UnmarshalPrim(prim micheline.Prim) error

type LedgerFAf

type LedgerFAf LedgerBalance

10 Quipuswap legacy FA2 with allowance set, balance and frozen - QuipuSwap dex legder KT1Qm3urGqkRsWsovGzNb2R81c3dSfxpteHG @key: address @value: {0: { 0:{set: address}, 1:nat } // allowances, balance

 1: nat                         // frozen_balance
}

func (*LedgerFAf) UnmarshalPrim

func (b *LedgerFAf) UnmarshalPrim(prim micheline.Prim) error

type LedgerFAg

type LedgerFAg LedgerBalance

11 FA2 with single balance and allowance set - fDAO Token ledger KT1KPoyzkj82Sbnafm6pfesZKEhyCpXwQfMc - Flame ledger KT1Wa8yqRBpFCusJWgcQyjhRz7hUQAmFxW7j @key: address @value: {set: address } // allowances

nat             // balance

func (*LedgerFAg) UnmarshalPrim

func (b *LedgerFAg) UnmarshalPrim(prim micheline.Prim) error

type LedgerFAh

type LedgerFAh LedgerBalance

12 FA2 Lugh Stablecoin - ledger KT1JBNFcB5tiycHNdYGYCtR3kk6JaJysUCi8 @key: {0:address, 1:nat} // owner, token_id @value: {0:nat, 1:bool} // balance, lock

func (*LedgerFAh) UnmarshalPrim

func (b *LedgerFAh) UnmarshalPrim(prim micheline.Prim) error

type LedgerFAi

type LedgerFAi LedgerBalance

13 Flame Dex - shares KT1PRtrP7pKZ3PSLwgfTwt8hD39bxVojoKuX @key: {0:address, 1:nat} // owner, token_id @value: {nat, nat, nat} // balance, last_rewards_per_share, rewards

func (*LedgerFAi) UnmarshalPrim

func (b *LedgerFAi) UnmarshalPrim(prim micheline.Prim) error

type LedgerFAj

type LedgerFAj LedgerBalance

14 MAG - ledger KT1H5KJDxuM9DURSfttepebb6Cn7GbvAAT45 @key: address // owner @value: {map: address => nat} // approvals

nat // balance
nat // frozenBalance
nat // reward
nat // rewardDebt
nat // usedVotes

func (*LedgerFAj) UnmarshalPrim

func (b *LedgerFAj) UnmarshalPrim(prim micheline.Prim) error

type LedgerNFT1

type LedgerNFT1 LedgerBalance

1 @key: {0: address, 1: nat} @value: nat

func (*LedgerNFT1) UnmarshalPrim

func (b *LedgerNFT1) UnmarshalPrim(prim micheline.Prim) error

type LedgerNFT2

type LedgerNFT2 LedgerBalance

2 @key: nat @value: address

func (*LedgerNFT2) UnmarshalPrim

func (b *LedgerNFT2) UnmarshalPrim(prim micheline.Prim) error

type LedgerNFT3

type LedgerNFT3 LedgerBalance

3 @key: {0: nat, 1: address} @value: nat

func (*LedgerNFT3) UnmarshalPrim

func (b *LedgerNFT3) UnmarshalPrim(prim micheline.Prim) error

type LedgerSchema

type LedgerSchema byte

LedgerSchema describes the internal data storage structure of a token ledger. It is used to decode and reconcile balance updates and can be detected from matching the ledger's storage spec (i.e. bigmap key and value types).

const (
	LedgerSchemaInvalid LedgerSchema = iota
	LedgerSchemaNFT1                 // 1 nft
	LedgerSchemaNFT2                 // 2 nft
	LedgerSchemaNFT3                 // 3 nft
	LedgerSchemaTzBTC                // 4
	LedgerSchemaFAa                  // 5
	LedgerSchemaFAb                  // 6
	LedgerSchemaFAc                  // 7
	LedgerSchemaFAd                  // 8 == nft1
	LedgerSchemaFAe                  // 9
	LedgerSchemaFAf                  // 10
	LedgerSchemaFAg                  // 11
	LedgerSchemaFAh                  // 12
	LedgerSchemaFAi                  // 13
	LedgerSchemaFAj                  // 14
	LedgerSchemaDomain               // 15
	LedgerSchemaTezFin               // 16
)

func (LedgerSchema) DecodeBalance

func (s LedgerSchema) DecodeBalance(prim micheline.Prim) (bal *LedgerBalance, err error)

func (LedgerSchema) DecodeBalanceUpdates

func (s LedgerSchema) DecodeBalanceUpdates(upd micheline.BigmapEvents, id int64) ([]*LedgerBalance, error)

func (LedgerSchema) IsValid

func (s LedgerSchema) IsValid() bool

type LedgerTezFin

type LedgerTezFin LedgerBalance

// 16 TezFin LedgerSchemaTezFin: micheline.NewPairType(

micheline.NewCode(micheline.T_ADDRESS), // owner
micheline.NewPairType(
    micheline.NewPairType( // accountBorrows
        micheline.NewCode(micheline.T_NAT), // interestIndex
        micheline.NewCode(micheline.T_NAT), // principal
    ),
    micheline.NewPairType(
        micheline.NewMapType( // approvals
            micheline.NewCode(micheline.T_ADDRESS),
            micheline.NewCode(micheline.T_NAT),
        ),
        micheline.NewCode(micheline.T_NAT), // balance
    ),
),

),

func (*LedgerTezFin) UnmarshalPrim

func (b *LedgerTezFin) UnmarshalPrim(prim micheline.Prim) error

type LedgerTzBTC

type LedgerTzBTC LedgerBalance

4 tzBTC (packed bytes) @key:{0: string = ledger, 1: address} @value: {0: int, 1: map { @key: address @val: nat }

func (*LedgerTzBTC) UnmarshalPrim

func (b *LedgerTzBTC) UnmarshalPrim(prim micheline.Prim) error

type MetaID

type MetaID uint64

func (MetaID) U64

func (i MetaID) U64() uint64

type Metadata

type Metadata struct {
	RowId     MetaID        `pack:"I,pk"      json:"row_id"`
	AccountId AccountID     `pack:"A,u32"     json:"account_id"`
	Address   tezos.Address `pack:"H,bloom=3" json:"address"`
	Content   []byte        `pack:"C,snappy"  json:"content"` // JSON or binary encoded content
}

func (*Metadata) ID

func (c *Metadata) ID() uint64

func (Metadata) IndexOpts

func (m Metadata) IndexOpts(key string) pack.Options

func (*Metadata) SetID

func (c *Metadata) SetID(id uint64)

func (Metadata) TableKey

func (m Metadata) TableKey() string

func (Metadata) TableOpts

func (m Metadata) TableOpts() pack.Options

type Model

type Model interface {
	TableKey() string
	TableOpts() pack.Options
	IndexOpts(string) pack.Options
}

Model is the interface all data models must implement.

type Op

type Op struct {
	RowId        OpID           `pack:"I,pk"             json:"row_id"`        // internal: unique row id
	Type         OpType         `pack:"t,u8,bloom"       json:"type"`          // indexer op type
	Hash         tezos.OpHash   `pack:"H,snappy,bloom=3" json:"hash"`          // op hash
	Height       int64          `pack:"h,i32"            json:"height"`        // block height
	Cycle        int64          `pack:"c,i16"            json:"cycle"`         // block cycle
	Timestamp    time.Time      `pack:"T"                json:"time"`          // block time
	OpN          int            `pack:"n,i32"            json:"op_n"`          // unique in-block pos
	OpP          int            `pack:"P,i16"            json:"op_p"`          // op list pos (list can be derived from type)
	Status       tezos.OpStatus `pack:"?,u8"             json:"status"`        // op status
	IsSuccess    bool           `pack:"!,snappy"         json:"is_success"`    // success flag
	IsContract   bool           `pack:"C,snappy"         json:"is_contract"`   // contract call flag (target is contract)
	IsInternal   bool           `pack:"N,snappy"         json:"is_internal"`   // internal contract call or op
	IsEvent      bool           `pack:"m,snappy"         json:"is_event"`      // this is an implicit event
	IsRollup     bool           `pack:"u,snappy"         json:"is_rollup"`     // this is an rollup operation
	Counter      int64          `pack:"j,i32"            json:"counter"`       // signer counter
	GasLimit     int64          `pack:"l,i32"            json:"gas_limit"`     // gas limit
	GasUsed      int64          `pack:"G,i32"            json:"gas_used"`      // gas used
	StorageLimit int64          `pack:"Z,i32"            json:"storage_limit"` // storage size limit
	StoragePaid  int64          `pack:"$,i32"            json:"storage_paid"`  // storage allocated/paid
	Volume       int64          `pack:"v"                json:"volume"`        // transacted tez volume
	Fee          int64          `pack:"f"                json:"fee"`           // tx fees
	Reward       int64          `pack:"r"                json:"reward"`        // baking/endorsement reward
	Deposit      int64          `pack:"d"                json:"deposit"`       // baker deposit
	Burned       int64          `pack:"b"                json:"burned"`        // burned tez (for storage allocation)
	SenderId     AccountID      `pack:"S,u32,bloom"      json:"sender_id"`     // sender id, also on internal ops
	ReceiverId   AccountID      `pack:"R,u32,bloom"      json:"receiver_id"`   // receiver id
	CreatorId    AccountID      `pack:"M,u32"            json:"creator_id"`    // creator id, direct source for internal ops
	BakerId      AccountID      `pack:"D,u32,bloom"      json:"baker_id"`      // delegate id
	Data         string         `pack:"a,snappy"         json:"data"`          // custom op data
	Parameters   []byte         `pack:"p,snappy"         json:"parameters"`    // call params
	CodeHash     uint64         `pack:"x"                json:"code_hash"`     // code hash of target contract
	StorageHash  uint64         `pack:"s"                json:"storage_hash"`  // storage hash
	Errors       []byte         `pack:"e,snappy"         json:"errors"`        // call errors
	Entrypoint   int            `pack:"E,i8"             json:"entrypoint_id"` // update contract counters, search by entrypoint

	// internal
	OpC              int                    `pack:"-"  json:"-"` // contents list pos
	OpI              int                    `pack:"-"  json:"-"` // internal op result list pos
	Raw              rpc.TypedOperation     `pack:"-"  json:"-"` // cache
	RawTicketUpdates []rpc.TicketUpdate     `pack:"-"  json:"-"` // rpc ticket updates
	BigmapEvents     micheline.BigmapEvents `pack:"-"  json:"-"` // cache here for bigmap index
	Storage          []byte                 `pack:"-"  json:"-"` // storage update
	IsStorageUpdate  bool                   `pack:"-"  json:"-"` // true when contract storage changed
	Contract         *Contract              `pack:"-"  json:"-"` // cached contract
	BigmapUpdates    []BigmapUpdate         `pack:"-"  json:"-"` // cached query result
	Events           []*Event               `pack:"-"  json:"-"` // cached query result
	TicketUpdates    []*TicketUpdate        `pack:"-"  json:"-"` // cached query result
	IsBurnAddress    bool                   `pack:"-"  json:"-"` // target is known burn address
}

func AllocOp

func AllocOp() *Op

func NewEventOp

func NewEventOp(block *Block, recv AccountID, id OpRef) *Op

func NewOp

func NewOp(block *Block, id OpRef) *Op

func (*Op) Free

func (o *Op) Free()

func (Op) ID

func (o Op) ID() uint64

func (Op) Id

func (o Op) Id() uint64

func (Op) IndexOpts

func (m Op) IndexOpts(key string) pack.Options

func (*Op) Reset

func (o *Op) Reset()

func (*Op) SetID

func (o *Op) SetID(id uint64)

func (Op) TableKey

func (m Op) TableKey() string

func (Op) TableOpts

func (m Op) TableOpts() pack.Options

func (Op) Time

func (o Op) Time() time.Time

be compatible with time series interface

func (Op) ToEndorsement

func (o Op) ToEndorsement() *Endorsement

type OpID

type OpID uint64

func (OpID) U64

func (id OpID) U64() uint64

type OpRef

type OpRef struct {
	Hash tezos.OpHash
	Kind OpType
	N    int
	L    int
	P    int
	C    int
	I    int
	Raw  rpc.TypedOperation
}

Helper to uniquely identify an operation while indexing

func (OpRef) Get

func (id OpRef) Get(op *rpc.Operation) rpc.TypedOperation

func (OpRef) InternalResult

func (id OpRef) InternalResult(op *rpc.Operation) *rpc.InternalResult

func (OpRef) Result

func (id OpRef) Result(op *rpc.Operation) rpc.OperationResult

func (OpRef) Url

func (id OpRef) Url(block int64) string

type OpType

type OpType byte

Indexer operation and event type

const (
	OpTypeBake                  OpType = iota // 0 implicit event (bake reward pay)
	OpTypeEndorsement                         // 1
	OpTypeTransaction                         // 2
	OpTypeReveal                              // 3
	OpTypeDelegation                          // 4
	OpTypeOrigination                         // 5
	OpTypeNonceRevelation                     // 6
	OpTypeActivation                          // 7
	OpTypeBallot                              // 8
	OpTypeProposal                            // 9
	OpTypeDoubleBaking                        // 10
	OpTypeDoubleEndorsement                   // 11
	OpTypeUnfreeze                            // 12 implicit event
	OpTypeInvoice                             // 13 implicit event
	OpTypeAirdrop                             // 14 implicit event
	OpTypeSeedSlash                           // 15 implicit event
	OpTypeMigration                           // 16 implicit event
	OpTypeSubsidy                             // 17 v010 liquidity baking
	OpTypeRegisterConstant                    // 18 v011
	OpTypePreendorsement                      // 19 v012
	OpTypeDoublePreendorsement                // 20 v012
	OpTypeDepositsLimit                       // 21 v012
	OpTypeDeposit                             // 22 v012 implicit event (baker deposit)
	OpTypeBonus                               // 23 v012 implicit event (baker extra bonus)
	OpTypeReward                              // 24 v012 implicit event (endorsement reward pay/burn)
	OpTypeRollupOrigination                   // 25 v013
	OpTypeRollupTransaction                   // 26 v013
	OpTypeVdfRevelation                       // 27 v014
	OpTypeIncreasePaidStorage                 // 28 v014
	OpTypeDrainDelegate                       // 29 v015
	OpTypeUpdateConsensusKey                  // 30 v015
	OpTypeTransferTicket                      // 31 v013
	OpTypeStake                               // 32 v018
	OpTypeUnstake                             // 33 v018
	OpTypeFinalizeUnstake                     // 34 v018
	OpTypeSetDelegateParameters               // 35 v018
	OpTypeStakeSlash                          // 36 v018 implicit event (staker slash)
	OpTypeBatch                 = 254         // API output only
	OpTypeInvalid               = 255
)

enums are allocated in chronological order with most often used ops first

func MapOpType

func MapOpType(typ tezos.OpType) OpType

func ParseOpType

func ParseOpType(s string) OpType

func (OpType) IsEvent

func (t OpType) IsEvent() bool

func (OpType) IsValid

func (t OpType) IsValid() bool

func (OpType) ListId

func (t OpType) ListId() int

func (*OpType) MarshalText

func (t *OpType) MarshalText() ([]byte, error)

func (OpType) String

func (t OpType) String() string

func (*OpType) UnmarshalText

func (t *OpType) UnmarshalText(data []byte) error

type OpTypeList

type OpTypeList []OpType

func (OpTypeList) Contains

func (l OpTypeList) Contains(typ OpType) bool

func (OpTypeList) IsEmpty

func (l OpTypeList) IsEmpty() bool

type Proposal

type Proposal struct {
	RowId        ProposalID         `pack:"I,pk"      json:"row_id"`        // unique id
	Hash         tezos.ProtocolHash `pack:"H,snappy"  json:"hash"`          // unique proposal hash
	Height       int64              `pack:"h,i32"     json:"height"`        // proposal publishing block
	Time         time.Time          `pack:"T"         json:"time"`          // proposal publishing time
	SourceId     AccountID          `pack:"S"         json:"source_id"`     // proposal publisher
	OpId         OpID               `pack:"O"         json:"op_id"`         // operation publishing this proposal
	ElectionId   ElectionID         `pack:"E"         json:"election_id"`   // custom: election sequence number (same for all voting periods)
	VotingPeriod int64              `pack:"p,i16"     json:"voting_period"` // protocol: proposal period sequence number
	Stake        int64              `pack:"s"         json:"stake"`         // stake accumulated by this proposal
	Voters       int64              `pack:"v,i16"     json:"voters"`        // number of voters who voted for this proposal
}

func (*Proposal) ID

func (p *Proposal) ID() uint64

func (Proposal) IndexOpts

func (m Proposal) IndexOpts(key string) pack.Options

func (*Proposal) SetID

func (p *Proposal) SetID(id uint64)

func (Proposal) TableKey

func (m Proposal) TableKey() string

func (Proposal) TableOpts

func (m Proposal) TableOpts() pack.Options

type ProposalID

type ProposalID uint64

Proposal implements unique individual proposals, a baker can choose to publish multiple proposals in one operation, which results in multiple rows been created.

func (ProposalID) U64

func (id ProposalID) U64() uint64
type Right struct {
	RowId     uint64     `pack:"I,pk"      json:"row_id"`           // unique id
	Cycle     int64      `pack:"c,i16"     json:"cycle"`            // cycle
	Height    int64      `pack:"h,i32"     json:"height"`           // height
	AccountId AccountID  `pack:"A,u32"     json:"account_id"`       // rights holder
	Bake      vec.BitSet `pack:"B,snappy"  json:"baking_rights"`    // bits for every block
	Endorse   vec.BitSet `pack:"E,snappy"  json:"endorsing_rights"` // bits for every block
	Baked     vec.BitSet `pack:"b,snappy"  json:"blocks_baked"`     // bits for every block
	Endorsed  vec.BitSet `pack:"e,snappy"  json:"blocks_endorsed"`  // bits for every block
	Seed      vec.BitSet `pack:"S,snappy"  json:"seeds_required"`   // only bits for every seed block
	Seeded    vec.BitSet `pack:"s,snappy"  json:"seeds_revealed"`   // only bits for every seed block
}

func AllocRight

func AllocRight() *Right

func NewRight

func NewRight(acc AccountID, height, cycle int64, nBlocks, nSeeds int) *Right

func (*Right) Free

func (r *Right) Free()

func (*Right) ID

func (r *Right) ID() uint64

func (Right) IndexOpts

func (m Right) IndexOpts(key string) pack.Options

func (Right) IsLost

func (r Right) IsLost(pos int) bool

func (Right) IsMissed

func (r Right) IsMissed(pos int) bool

func (Right) IsSeedRequired

func (r Right) IsSeedRequired(pos int) bool

func (Right) IsSeedRevealed

func (r Right) IsSeedRevealed(pos int) bool

func (Right) IsStolen

func (r Right) IsStolen(pos int) bool

func (Right) IsUsed

func (r Right) IsUsed(pos int) bool

func (Right) Reliability

func (r Right) Reliability(pos int) int64

func (*Right) Reset

func (r *Right) Reset()

func (*Right) SetID

func (r *Right) SetID(id uint64)

func (Right) TableKey

func (m Right) TableKey() string

func (Right) TableOpts

func (m Right) TableOpts() pack.Options

func (Right) ToBase

func (r Right) ToBase(pos int, typ tezos.RightType) (BaseRight, bool)

type Snapshot

type Snapshot struct {
	RowId          uint64    `pack:"I,pk"         json:"row_id"`
	Height         int64     `pack:"h,i32"        json:"height"`
	Cycle          int64     `pack:"c,i16"        json:"cycle"`
	Timestamp      time.Time `pack:"T"            json:"time"`
	Index          int       `pack:"i,i8"         json:"index"`
	OwnStake       int64     `pack:"O"            json:"own_stake"`
	StakingBalance int64     `pack:"K"            json:"staking_balance"`
	AccountId      AccountID `pack:"a,u32,bloom"  json:"account_id"`
	BakerId        AccountID `pack:"d,u32"        json:"baker_id"`
	IsBaker        bool      `pack:"?,snappy"     json:"is_baker"`
	IsActive       bool      `pack:"v,snappy"     json:"is_active"`
	Balance        int64     `pack:"B"            json:"balance"`
	Delegated      int64     `pack:"D"            json:"delegated"`
	NDelegations   int64     `pack:"n,i32"        json:"n_delegations"`
	NStakers       int64     `pack:"#,i32"        json:"n_stakers"`
	Since          int64     `pack:"S,i32"        json:"since"`
}

Snapshot is an account balance snapshot made at a snapshot block.

func NewSnapshot

func NewSnapshot() *Snapshot

func (*Snapshot) Free

func (s *Snapshot) Free()

func (Snapshot) ID

func (s Snapshot) ID() uint64

func (Snapshot) IndexOpts

func (m Snapshot) IndexOpts(key string) pack.Options

func (*Snapshot) Reset

func (s *Snapshot) Reset()

func (*Snapshot) SetID

func (s *Snapshot) SetID(id uint64)

func (Snapshot) TableKey

func (m Snapshot) TableKey() string

func (Snapshot) TableOpts

func (m Snapshot) TableOpts() pack.Options

type Stake

type Stake struct {
	RowId     uint64    `pack:"I,pk"  json:"row_id"`
	Height    int64     `pack:"h,i32" json:"height"`
	AccountId AccountID `pack:"A"     json:"account_id"`
	Stake     int64     `pack:"s"     json:"stake"`
}

Stake snapshots

func (*Stake) ID

func (b *Stake) ID() uint64

func (Stake) IndexOpts

func (m Stake) IndexOpts(key string) pack.Options

func (*Stake) SetID

func (b *Stake) SetID(id uint64)

func (Stake) TableKey

func (m Stake) TableKey() string

func (Stake) TableOpts

func (m Stake) TableOpts() pack.Options

type Status

type Status struct {
	Status    string  `json:"status"`
	Blocks    int64   `json:"blocks"`
	Finalized int64   `json:"finalized"`
	Indexed   int64   `json:"indexed"`
	Progress  float64 `json:"progress"`
}

type Storage

type Storage struct {
	RowId     StorageID `pack:"I,pk"             json:"row_id"`
	AccountId AccountID `pack:"A,bloom=3,snappy" json:"account_id"`
	Hash      uint64    `pack:"H,bloom=3,snappy" json:"hash"`
	Height    int64     `pack:"h,i32"            json:"height"`
	Storage   []byte    `pack:"S,snappy"         json:"storage"`
}

Storage holds a snapshot of smart contract storage content.

func (Storage) ID

func (s Storage) ID() uint64

func (Storage) IndexOpts

func (m Storage) IndexOpts(key string) pack.Options

func (*Storage) Reset

func (s *Storage) Reset()

func (*Storage) SetID

func (s *Storage) SetID(id uint64)

func (Storage) TableKey

func (m Storage) TableKey() string

func (Storage) TableOpts

func (m Storage) TableOpts() pack.Options

type StorageID

type StorageID uint64

func (StorageID) U64

func (id StorageID) U64() uint64

type Supply

type Supply struct {
	RowId               uint64    `pack:"I,pk"         json:"row_id"`             // unique id
	Height              int64     `pack:"h,i32,snappy" json:"height"`             // bc: block height (also for orphans)
	Cycle               int64     `pack:"c,i16,snappy" json:"cycle"`              // bc: block cycle (tezos specific)
	Timestamp           time.Time `pack:"T,snappy"     json:"time"`               // bc: block creation time
	Total               int64     `pack:"t,snappy"     json:"total"`              // total available supply (including unclaimed)
	Activated           int64     `pack:"A,snappy"     json:"activated"`          // activated fundraiser supply
	Unclaimed           int64     `pack:"U,snappy"     json:"unclaimed"`          // all non-activated fundraiser supply
	Circulating         int64     `pack:"C,snappy"     json:"circulating"`        // (total - unclaimed)
	Liquid              int64     `pack:"L,snappy"     json:"liquid"`             // (total - frozen - unclaimed)
	Delegated           int64     `pack:"E,snappy"     json:"delegated"`          // all delegated balances (includes overdelegation)
	Staking             int64     `pack:"D,snappy"     json:"staking"`            // baker's own balances / v18+ total stake (includes overstaking)
	Unstaking           int64     `pack:"N,snappy"     json:"unstaking"`          // staking exit queue
	Shielded            int64     `pack:"S,snappy"     json:"shielded"`           // Sapling shielded supply
	ActiveStake         int64     `pack:"K,snappy"     json:"active_stake"`       // network wide stake used for consensus
	ActiveDelegated     int64     `pack:"G,snappy"     json:"active_delegated"`   // delegated  balances to active bakers
	ActiveStaking       int64     `pack:"J,snappy"     json:"active_staking"`     // active baker's slashable / v18+ stake
	InactiveDelegated   int64     `pack:"g,snappy"     json:"inactive_delegated"` // delegated balances to inactive bakers
	InactiveStaking     int64     `pack:"j,snappy"     json:"inactive_staking"`   // inactive baker's slashable / v18+ stake
	Minted              int64     `pack:"M,snappy"     json:"minted"`
	MintedBaking        int64     `pack:"b,snappy"     json:"minted_baking"`
	MintedEndorsing     int64     `pack:"e,snappy"     json:"minted_endorsing"`
	MintedSeeding       int64     `pack:"s,snappy"     json:"minted_seeding"`
	MintedAirdrop       int64     `pack:"a,snappy"     json:"minted_airdrop"`
	MintedSubsidy       int64     `pack:"y,snappy"     json:"minted_subsidy"`
	Burned              int64     `pack:"B,snappy"     json:"burned"`
	BurnedDoubleBaking  int64     `pack:"1,snappy"     json:"burned_double_baking"`
	BurnedDoubleEndorse int64     `pack:"2,snappy"     json:"burned_double_endorse"`
	BurnedOrigination   int64     `pack:"3,snappy"     json:"burned_origination"`
	BurnedAllocation    int64     `pack:"4,snappy"     json:"burned_allocation"`
	BurnedSeedMiss      int64     `pack:"5,snappy"     json:"burned_seed_miss"`
	BurnedStorage       int64     `pack:"6,snappy"     json:"burned_storage"`
	BurnedExplicit      int64     `pack:"7,snappy"     json:"burned_explicit"`
	BurnedOffline       int64     `pack:"8,snappy"     json:"burned_offline"`
	BurnedRollup        int64     `pack:"9,snappy"     json:"burned_rollup"`
	Frozen              int64     `pack:"F,snappy"     json:"frozen"`
	FrozenDeposits      int64     `pack:"d,snappy"     json:"frozen_deposits"`     // <v18
	FrozenRewards       int64     `pack:"r,snappy"     json:"frozen_rewards"`      // <v18
	FrozenFees          int64     `pack:"f,snappy"     json:"frozen_fees"`         // <v18
	FrozenBonds         int64     `pack:"o,snappy"     json:"frozen_bonds"`        // rollup
	FrozenStake         int64     `pack:"x,snappy"     json:"frozen_stake"`        // v18+ all
	FrozenBakerStake    int64     `pack:"i,snappy"     json:"frozen_baker_stake"`  // v18+ baker only
	FrozenStakerStake   int64     `pack:"k,snappy"     json:"frozen_staker_stake"` // v18+ staker only
}

Note: removed vesting supply in v9.1, TF vesting time is over

func (*Supply) ID

func (s *Supply) ID() uint64

func (Supply) IndexOpts

func (m Supply) IndexOpts(key string) pack.Options

func (*Supply) Reset

func (s *Supply) Reset()

func (*Supply) Rollback

func (s *Supply) Rollback(b *Block)

func (*Supply) SetID

func (s *Supply) SetID(id uint64)

func (Supply) TableKey

func (m Supply) TableKey() string

func (Supply) TableOpts

func (m Supply) TableOpts() pack.Options

func (Supply) Time

func (s Supply) Time() time.Time

be compatible with time series interface

func (*Supply) Update

func (s *Supply) Update(b *Block, bakers map[AccountID]*Baker)

type Ticket

type Ticket struct {
	Id           TicketID       `pack:"I,pk"      json:"row_id"`
	Address      tezos.Address  `pack:"A,bloom=3" json:"address"`
	Ticketer     AccountID      `pack:"X,bloom=3" json:"ticketer"`
	Type         micheline.Prim `pack:"T,snappy"  json:"type"`
	Content      micheline.Prim `pack:"C,snappy"  json:"content"`
	Hash         uint64         `pack:"H,bloom"   json:"hash"`
	Creator      AccountID      `pack:"c"         json:"creator"`
	FirstBlock   int64          `pack:"<,i32"     json:"first_block"`
	FirstTime    time.Time      `pack:"f"         json:"first_time"`
	LastBlock    int64          `pack:">,i32"     json:"last_block"`
	LastTime     time.Time      `pack:"t"         json:"last_time"`
	Supply       tezos.Z        `pack:"S,snappy"  json:"total_supply"`
	TotalMint    tezos.Z        `pack:"m,snappy"  json:"total_mint"`
	TotalBurn    tezos.Z        `pack:"b,snappy"  json:"total_burn"`
	NumTransfers int            `pack:"x,i32"     json:"num_transfers"`
	NumHolders   int            `pack:"y,i32"     json:"num_holders"`
}

Ticket tracks all ticket instances. A Ticket is uniquely defined by a ticketer (the issuing contract), type and contents matching this type.

func GetTicketId

func GetTicketId(ctx context.Context, s *pack.Table, id TicketID) (*Ticket, error)

func ListTickets

func ListTickets(ctx context.Context, s *pack.Table, q pack.Query) ([]*Ticket, error)

func LookupTicket

func LookupTicket(ctx context.Context, s *pack.Table, addr tezos.Address, hash uint64) (*Ticket, error)

func NewTicket

func NewTicket() *Ticket

func (*Ticket) Free

func (t *Ticket) Free()

func (Ticket) ID

func (t Ticket) ID() uint64

func (Ticket) IndexOpts

func (_ Ticket) IndexOpts(_ string) pack.Options

func (*Ticket) Reset

func (t *Ticket) Reset()

func (*Ticket) SetID

func (t *Ticket) SetID(id uint64)

func (Ticket) Size

func (t Ticket) Size() int

func (*Ticket) Store

func (t *Ticket) Store(ctx context.Context, s *pack.Table) error

func (Ticket) TableKey

func (_ Ticket) TableKey() string

func (Ticket) TableOpts

func (_ Ticket) TableOpts() pack.Options

type TicketEvent

type TicketEvent struct {
	Id       TicketEventID   `pack:"I,pk"      json:"row_id"`
	Type     TicketEventType `pack:"y"         json:"type"`
	Ticket   TicketID        `pack:"T,bloom=3" json:"ticket"`
	Ticketer AccountID       `pack:"E,bloom=3" json:"ticketer"`
	Sender   AccountID       `pack:"S"         json:"sender"`
	Receiver AccountID       `pack:"R"         json:"receiver"`
	Amount   tezos.Z         `pack:"A,snappy"  json:"amount"`
	Height   int64           `pack:"h,i32"     json:"height"`
	Time     time.Time       `pack:"t"         json:"time"`
	OpId     uint64          `pack:"d"         json:"op_id"`
}

TicketEvent tracks all ticket events such as transfers, mints, burns.

func ListTicketEvents

func ListTicketEvents(ctx context.Context, t *pack.Table, q pack.Query) ([]*TicketEvent, error)

func NewTicketEvent

func NewTicketEvent() *TicketEvent

func (*TicketEvent) Free

func (e *TicketEvent) Free()

func (TicketEvent) ID

func (t TicketEvent) ID() uint64

func (TicketEvent) IndexOpts

func (_ TicketEvent) IndexOpts(_ string) pack.Options

func (*TicketEvent) Reset

func (e *TicketEvent) Reset()

func (*TicketEvent) SetID

func (t *TicketEvent) SetID(id uint64)

func (*TicketEvent) Store

func (e *TicketEvent) Store(ctx context.Context, t *pack.Table) error

func (TicketEvent) TableKey

func (_ TicketEvent) TableKey() string

func (TicketEvent) TableOpts

func (_ TicketEvent) TableOpts() pack.Options

type TicketEventID

type TicketEventID uint64

func (TicketEventID) U64

func (i TicketEventID) U64() uint64

type TicketEventType

type TicketEventType byte
const (
	TicketEventTypeInvalid TicketEventType = iota
	TicketEventTypeTransfer
	TicketEventTypeMint
	TicketEventTypeBurn
)

func ParseTicketEventType

func ParseTicketEventType(s string) TicketEventType

func (TicketEventType) IsValid

func (t TicketEventType) IsValid() bool

func (TicketEventType) MarshalText

func (t TicketEventType) MarshalText() ([]byte, error)

func (TicketEventType) String

func (t TicketEventType) String() string

func (*TicketEventType) UnmarshalText

func (t *TicketEventType) UnmarshalText(data []byte) error

type TicketID

type TicketID uint64

func LookupTicketId

func LookupTicketId(ctx context.Context, t *pack.Table, addr tezos.Address, hash uint64) (TicketID, error)

func (TicketID) U64

func (i TicketID) U64() uint64

type TicketOwner

type TicketOwner struct {
	Id           TicketOwnerID `pack:"I,pk"      json:"row_id"`
	Ticket       TicketID      `pack:"T,bloom=3" json:"ticket"`
	Ticketer     AccountID     `pack:"E,bloom=3" json:"ticketer"`
	Account      AccountID     `pack:"A,bloom=3" json:"account"`
	Balance      tezos.Z       `pack:"B,snappy"  json:"balance"`       // current balance
	FirstBlock   int64         `pack:"<,i32"     json:"first_block"`   // block height
	FirstTime    time.Time     `pack:"f"         json:"first_time"`    // block time
	LastBlock    int64         `pack:">,i32"     json:"last_block"`    // block height
	LastTime     time.Time     `pack:"t"         json:"last_time"`     // block time
	NumTransfers int           `pack:"x,i32"     json:"num_transfers"` // #xfers this owner/ticket combi sent or recv
	NumMints     int           `pack:"y,i32"     json:"num_mints"`     // #mints this owner/ticket combi
	NumBurns     int           `pack:"z,i32"     json:"num_burns"`     // #burns this owner/ticket combi
	VolSent      tezos.Z       `pack:"s,snappy"  json:"vol_sent"`      // running total
	VolRecv      tezos.Z       `pack:"r,snappy"  json:"vol_recv"`      // running total
	VolMint      tezos.Z       `pack:"m,snappy"  json:"vol_mint"`      // running total
	VolBurn      tezos.Z       `pack:"b,snappy"  json:"vol_burn"`      // running total

	// internal, used for stats
	WasZero bool `pack:"-"  json:"-"`
}

TicketOwner tracks owner info.

func GetOrCreateTicketOwner

func GetOrCreateTicketOwner(ctx context.Context, t *pack.Table, accountId, issuerId AccountID, id TicketID, height int64, tm time.Time) (*TicketOwner, error)

func GetTicketOwner

func GetTicketOwner(ctx context.Context, t *pack.Table, accountId AccountID, id TicketID) (*TicketOwner, error)

func GetTicketOwnerId

func GetTicketOwnerId(ctx context.Context, t *pack.Table, id TicketOwnerID) (*TicketOwner, error)

func ListTicketOwners

func ListTicketOwners(ctx context.Context, t *pack.Table, q pack.Query) ([]*TicketOwner, error)

func NewTicketOwner

func NewTicketOwner() *TicketOwner

func (*TicketOwner) Free

func (o *TicketOwner) Free()

func (TicketOwner) ID

func (t TicketOwner) ID() uint64

func (TicketOwner) IndexOpts

func (_ TicketOwner) IndexOpts(_ string) pack.Options

func (*TicketOwner) Reset

func (o *TicketOwner) Reset()

func (*TicketOwner) SetID

func (t *TicketOwner) SetID(id uint64)

func (*TicketOwner) Store

func (o *TicketOwner) Store(ctx context.Context, t *pack.Table) error

func (TicketOwner) TableKey

func (_ TicketOwner) TableKey() string

func (TicketOwner) TableOpts

func (_ TicketOwner) TableOpts() pack.Options

type TicketOwnerID

type TicketOwnerID uint64

func (TicketOwnerID) U64

func (i TicketOwnerID) U64() uint64

type TicketUpdate

type TicketUpdate struct {
	Id        TicketUpdateID `pack:"I,pk"      json:"row_id"`
	TicketId  TicketID       `pack:"T"         json:"ticket"`
	AccountId AccountID      `pack:"S"         json:"account"`
	Amount    tezos.Z        `pack:"A,snappy"  json:"amount"`
	Height    int64          `pack:"h,i32"     json:"height"`
	Time      time.Time      `pack:"t"         json:"time"`
	OpId      uint64         `pack:"d"         json:"op_id"`
}

TicketUpdate tracks low-level updates issued in operation receipts.

func ListTicketUpdates

func ListTicketUpdates(ctx context.Context, t *pack.Table, q pack.Query) ([]*TicketUpdate, error)

func NewTicketUpdate

func NewTicketUpdate() *TicketUpdate

func (*TicketUpdate) Free

func (m *TicketUpdate) Free()

func (TicketUpdate) ID

func (t TicketUpdate) ID() uint64

func (TicketUpdate) IndexOpts

func (_ TicketUpdate) IndexOpts(_ string) pack.Options

func (TicketUpdate) Indexes

func (_ TicketUpdate) Indexes() []string

func (*TicketUpdate) Reset

func (m *TicketUpdate) Reset()

func (*TicketUpdate) SetID

func (t *TicketUpdate) SetID(id uint64)

func (*TicketUpdate) Store

func (t *TicketUpdate) Store(ctx context.Context, table *pack.Table) error

func (TicketUpdate) TableKey

func (_ TicketUpdate) TableKey() string

func (TicketUpdate) TableOpts

func (_ TicketUpdate) TableOpts() pack.Options

type TicketUpdateID

type TicketUpdateID uint64

type Token

type Token struct {
	Id           TokenID   `pack:"I,pk"      json:"row_id"`
	Ledger       AccountID `pack:"l,bloom=3" json:"ledger"`
	TokenId      tezos.Z   `pack:"i,snappy"  json:"token_id"`
	TokenId64    int64     `pack:"6"         json:"token_id64"`
	Creator      AccountID `pack:"C"         json:"creator"`
	Type         TokenType `pack:"Y"         json:"type"`
	FirstBlock   int64     `pack:"<"         json:"first_block"`
	FirstTime    time.Time `pack:"T"         json:"first_time"`
	LastBlock    int64     `pack:">"         json:"last_block"`
	LastTime     time.Time `pack:"t"         json:"last_time"`
	Supply       tezos.Z   `pack:"S,snappy"  json:"total_supply"`
	TotalMint    tezos.Z   `pack:"m,snappy"  json:"total_mint"`
	TotalBurn    tezos.Z   `pack:"b,snappy"  json:"total_burn"`
	NumTransfers int       `pack:"x,i32"     json:"num_transfers"`
	NumHolders   int       `pack:"y,i32"     json:"num_holders"`
}

Token tracks token state and stats

func FindTokenId

func FindTokenId(ctx context.Context, t *pack.Table, id TokenID) (*Token, error)

func GetOrCreateToken

func GetOrCreateToken(ctx context.Context, t *pack.Table, ledger *Contract, signer *Account, id tezos.Z, height int64, tm time.Time) (*Token, error)

func GetToken

func GetToken(ctx context.Context, t *pack.Table, ledger *Contract, id tezos.Z) (*Token, error)

func NewToken

func NewToken() *Token

func NewTokenMeta

func NewTokenMeta() *Token

func (*Token) Free

func (m *Token) Free()

func (*Token) ID

func (m *Token) ID() uint64

func (Token) IndexOpts

func (m Token) IndexOpts(key string) pack.Options

func (*Token) Reset

func (m *Token) Reset()

func (*Token) SetID

func (m *Token) SetID(id uint64)

func (Token) TableKey

func (m Token) TableKey() string

func (Token) TableOpts

func (m Token) TableOpts() pack.Options

type TokenEvent

type TokenEvent struct {
	Id       TokenEventID   `pack:"I,pk"      json:"row_id"`
	Ledger   AccountID      `pack:"l,bloom=3" json:"ledger"`
	Token    TokenID        `pack:"T,bloom=3" json:"token"`
	Type     TokenEventType `pack:"y"         json:"type"`
	Signer   AccountID      `pack:"Z"         json:"signer"`
	Sender   AccountID      `pack:"S"         json:"sender"`
	Receiver AccountID      `pack:"R"         json:"receiver"`
	Amount   tezos.Z        `pack:"A,snappy"  json:"amount"`
	Height   int64          `pack:"h"         json:"height"`
	Time     time.Time      `pack:"t"         json:"time"`
	OpId     OpID           `pack:"d"         json:"op_id"`

	TokenRef *Token `pack:"-" json:"-"`
}

TokenEvent tracks all token events such as transfers, mints, burns.

func NewTokenEvent

func NewTokenEvent() *TokenEvent

func (*TokenEvent) Free

func (m *TokenEvent) Free()

func (*TokenEvent) ID

func (m *TokenEvent) ID() uint64

func (TokenEvent) IndexOpts

func (m TokenEvent) IndexOpts(key string) pack.Options

func (*TokenEvent) Reset

func (m *TokenEvent) Reset()

func (*TokenEvent) SetID

func (m *TokenEvent) SetID(id uint64)

func (TokenEvent) TableKey

func (m TokenEvent) TableKey() string

func (TokenEvent) TableOpts

func (m TokenEvent) TableOpts() pack.Options

type TokenEventID

type TokenEventID uint64

type TokenEventType

type TokenEventType byte
const (
	TokenEventTypeInvalid TokenEventType = iota
	TokenEventTypeTransfer
	TokenEventTypeMint
	TokenEventTypeBurn
)

func ParseTokenEventType

func ParseTokenEventType(s string) TokenEventType

func (TokenEventType) IsValid

func (t TokenEventType) IsValid() bool

func (TokenEventType) MarshalText

func (t TokenEventType) MarshalText() ([]byte, error)

func (TokenEventType) String

func (t TokenEventType) String() string

func (*TokenEventType) UnmarshalText

func (t *TokenEventType) UnmarshalText(data []byte) error

type TokenID

type TokenID uint64

func (TokenID) U64

func (i TokenID) U64() uint64

type TokenMeta

type TokenMeta struct {
	Id    TokenMetaID `pack:"I,pk"      json:"row_id"`
	Token TokenID     `pack:"T,snappy"  json:"token"`
	Data  []byte      `pack:"D,snappy"  json:"data"`
}

TokenMeta tracks token metadata from off-chain resolution

func (*TokenMeta) Free

func (m *TokenMeta) Free()

func (*TokenMeta) ID

func (m *TokenMeta) ID() uint64

func (TokenMeta) IndexOpts

func (m TokenMeta) IndexOpts(key string) pack.Options

func (*TokenMeta) Reset

func (m *TokenMeta) Reset()

func (*TokenMeta) SetID

func (m *TokenMeta) SetID(id uint64)

func (TokenMeta) TableKey

func (m TokenMeta) TableKey() string

func (TokenMeta) TableOpts

func (m TokenMeta) TableOpts() pack.Options

type TokenMetaID

type TokenMetaID uint64

type TokenOwner

type TokenOwner struct {
	Id           TokenOwnerID `pack:"I,pk"      json:"row_id"`
	Account      AccountID    `pack:"A,bloom=3" json:"account"`
	Ledger       AccountID    `pack:"L,bloom=3" json:"ledger"`
	Token        TokenID      `pack:"T,bloom=3" json:"token"`
	Balance      tezos.Z      `pack:"B,snappy"  json:"balance"`       // current balance
	FirstBlock   int64        `pack:"<,i32"     json:"first_seen"`    // height
	LastBlock    int64        `pack:">,i32"     json:"last_seen"`     // height
	NumTransfers int          `pack:"x,i32"     json:"num_transfers"` // #xfers this owner/token combi sent or recv
	NumMints     int          `pack:"y,i32"     json:"num_mints"`     // #mints this owner/token combi
	NumBurns     int          `pack:"z,i32"     json:"num_burns"`     // #burns this owner/token combi
	VolSent      tezos.Z      `pack:"s,snappy"  json:"vol_sent"`      // running total
	VolRecv      tezos.Z      `pack:"r,snappy"  json:"vol_recv"`      // running total
	VolMint      tezos.Z      `pack:"m,snappy"  json:"vol_mint"`      // running total
	VolBurn      tezos.Z      `pack:"b,snappy"  json:"vol_burn"`      // running total

	// internal, used for stats
	WasZero bool `pack:"-"  json:"-"`
}

TokenOwner tracks current token ownership balances for each account and lifetime running totals. First/last and counters are useful as app-level stats and to limit db query range scans.

func GetCurrentTokenOwner

func GetCurrentTokenOwner(ctx context.Context, t *pack.Table, tokenId TokenID) (*TokenOwner, error)

func GetOrCreateOwner

func GetOrCreateOwner(ctx context.Context, t *pack.Table, accountId AccountID, tokenId TokenID, ledgerId AccountID) (*TokenOwner, error)

func GetOwnerId

func GetOwnerId(ctx context.Context, t *pack.Table, id TokenOwnerID) (*TokenOwner, error)

func GetTokenOwner

func GetTokenOwner(ctx context.Context, t *pack.Table, accountId AccountID, tokenId TokenID) (*TokenOwner, error)

func ListOwners

func ListOwners(ctx context.Context, t *pack.Table, q pack.Query) ([]*TokenOwner, error)

func NewTokenOwner

func NewTokenOwner() *TokenOwner

func (*TokenOwner) Free

func (m *TokenOwner) Free()

func (*TokenOwner) ID

func (m *TokenOwner) ID() uint64

func (TokenOwner) IndexOpts

func (m TokenOwner) IndexOpts(key string) pack.Options

func (*TokenOwner) Reset

func (m *TokenOwner) Reset()

func (*TokenOwner) SetID

func (m *TokenOwner) SetID(id uint64)

func (TokenOwner) TableKey

func (m TokenOwner) TableKey() string

func (TokenOwner) TableOpts

func (m TokenOwner) TableOpts() pack.Options

type TokenOwnerID

type TokenOwnerID uint64

type TokenTransfer

type TokenTransfer struct {
	From    tezos.Address
	To      tezos.Address
	TokenId tezos.Z
	Amount  tezos.Z
}

func (TokenTransfer) IsValid

func (t TokenTransfer) IsValid() bool

type TokenType

type TokenType byte

FA1, FA1.2, FA2

const (
	TokenTypeInvalid TokenType = iota
	TokenTypeFA1
	TokenTypeFA1_2
	TokenTypeFA2
)

func DetectTokenType

func DetectTokenType(s micheline.Script) TokenType

func ParseTokenType

func ParseTokenType(s string) TokenType

func (TokenType) DecodeTransfers

func (t TokenType) DecodeTransfers(prim micheline.Prim) ([]TokenTransfer, error)

func (TokenType) IsValid

func (t TokenType) IsValid() bool

func (TokenType) MarshalText

func (t TokenType) MarshalText() ([]byte, error)

func (TokenType) Matches

func (t TokenType) Matches(prim micheline.Prim) bool

func (TokenType) String

func (t TokenType) String() string

func (*TokenType) UnmarshalText

func (t *TokenType) UnmarshalText(data []byte) error

type TransferList

type TransferList struct {
	Transfers []TokenTransfer
	// contains filtered or unexported fields
}

func (*TransferList) UnmarshalPrim

func (t *TransferList) UnmarshalPrim(prim micheline.Prim) error

type Vote

type Vote struct {
	RowId            uint64                 `pack:"I,pk"            json:"row_id"`              // unique id
	ElectionId       ElectionID             `pack:"E"               json:"election_id"`         // related election id
	ProposalId       ProposalID             `pack:"P"               json:"proposal_id"`         // related proposal id
	VotingPeriod     int64                  `pack:"p,i16"           json:"voting_period"`       // on-chain sequence number
	VotingPeriodKind tezos.VotingPeriodKind `pack:"k,u8"            json:"voting_period_kind"`  // on-chain period
	StartTime        time.Time              `pack:"T"               json:"period_start_time"`   // start time (block time) of voting period
	EndTime          time.Time              `pack:"t"               json:"period_end_time"`     // end time (block time), estimate when polls are open
	StartHeight      int64                  `pack:"H,i32"           json:"period_start_height"` // start block height of voting period
	EndHeight        int64                  `pack:"h,i32"           json:"period_end_height"`   // end block height
	EligibleStake    int64                  `pack:"s"               json:"eligible_stake"`      // stake at start of period
	EligibleVoters   int64                  `pack:"v,i16"           json:"eligible_voters"`     // total number of eligible bakers at start of period
	QuorumPct        int64                  `pack:"q,d32,scale=2"   json:"quorum_pct"`          // required quorum in percent (store as integer with 2 digits)
	QuorumStake      int64                  `pack:"S"               json:"quorum_stake"`        // required quorum in stake (0 for proposal_period)
	TurnoutStake     int64                  `pack:"R"               json:"turnout_stake"`       // actual participation in stake
	TurnoutVoters    int64                  `pack:"U,i16"           json:"turnout_voters"`      // actual participation in voters
	TurnoutPct       int64                  `pack:"c,d32,scale=2"   json:"turnout_pct"`         // actual participation in percent
	TurnoutEma       int64                  `pack:"e,d32,scale=2"   json:"turnout_ema"`         // EMA (80/20) of participation in percent
	YayStake         int64                  `pack:"V"               json:"yay_stake"`
	YayVoters        int64                  `pack:"Y,i16"           json:"yay_voters"`
	NayStake         int64                  `pack:"W"               json:"nay_stake"`
	NayVoters        int64                  `pack:"N,i16"           json:"nay_voters"`
	PassStake        int64                  `pack:"X"               json:"pass_stake"`
	PassVoters       int64                  `pack:"A,i16"           json:"pass_voters"`
	IsOpen           bool                   `pack:"o,snappy"        json:"is_open"`     // flag, polls are open (only current period)
	IsFailed         bool                   `pack:"f,snappy"        json:"is_failed"`   // flag, failed reaching quorum or supermajority
	IsDraw           bool                   `pack:"d,snappy"        json:"is_draw"`     // flag, draw between at least two proposals
	NoProposal       bool                   `pack:"?,snappy"        json:"no_proposal"` // flag, no proposal submitted
	NoQuorum         bool                   `pack:"!,snappy"        json:"no_quorum"`   // flag, quorum not reached
	NoMajority       bool                   `pack:"m,snappy"        json:"no_majority"` // flag, supermajority not reached
}

Vote represent the most recent state of a voting period during elections or, when closed, the final result of a voting period. Votes contain the cummulative aggregate state at the current block.

func (*Vote) ID

func (v *Vote) ID() uint64

func (Vote) IndexOpts

func (m Vote) IndexOpts(key string) pack.Options

func (*Vote) SetID

func (v *Vote) SetID(id uint64)

func (Vote) TableKey

func (m Vote) TableKey() string

func (Vote) TableOpts

func (m Vote) TableOpts() pack.Options

type Voter

type Voter struct {
	RowId     AccountID
	Stake     int64
	Ballot    tezos.BallotVote
	HasVoted  bool
	Time      time.Time
	Proposals []ProposalID
}

Jump to

Keyboard shortcuts

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