actions

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: BSD-3-Clause Imports: 10 Imported by: 9

Documentation

Index

Constants

View Source
const (
	// We restrict the [MaxContentSize] to be 768B such that any collection of
	// 1024 keys+values will never be more than [chain.NetworkSizeLimit].
	//
	// TODO: relax this once merkleDB/sync can ensure range proof resolution does
	// not surpass [NetworkSizeLimit]
	MaxContentSize = 1_600
)

Variables

View Source
var (
	OutputContentEmpty       = []byte("content empty")
	OutputContentMissing     = []byte("content missing")
	OutputInvalidSchema      = []byte("invalid schema")
	OutputInvalidContent     = []byte("invalid content")
	OutputWrongOwner         = []byte("wrong owner")
	OutputInvalidObject      = []byte("invalid object")
	OutputServicerMissing    = []byte("servicer missing")
	OutputInvalidBalance     = []byte("invalid balance")
	OutputAccountNotEmpty    = []byte("account not empty")
	OutputAccountEmpty       = []byte("account empty")
	OutputPermissionsUseless = []byte("permissions useless")
	OutputActorMismatch      = []byte("actor mismatch")
	OutputValueZero          = []byte("value is zero")
)

Functions

func UnmarshalAuthorize

func UnmarshalAuthorize(p *codec.Packer) (chain.Action, error)

func UnmarshalClear

func UnmarshalClear(p *codec.Packer) (chain.Action, error)

func UnmarshalIndex

func UnmarshalIndex(p *codec.Packer) (chain.Action, error)

func UnmarshalModify

func UnmarshalModify(p *codec.Packer) (chain.Action, error)

func UnmarshalTransfer

func UnmarshalTransfer(p *codec.Packer) (chain.Action, error)

func UnmarshalUnindex

func UnmarshalUnindex(p *codec.Packer) (chain.Action, error)

Types

type Authorize

type Authorize struct {
	// Actor must be specified so we can enumerate read keys
	Actor crypto.PublicKey `json:"actor"`
	// Signer is the new permissions
	//
	// Any balance pull must come from actor to avoid being able to steal other's
	// money.
	Signer crypto.PublicKey `json:"signer"`
	// TODO: based on order of index in permissions
	// if 0, then remove all perms
	ActionPermissions uint8 `json:"actionPermissions"`
	MiscPermissions   uint8 `json:"miscPermissions"`
}

func (*Authorize) Execute

func (a *Authorize) Execute(
	ctx context.Context,
	r chain.Rules,
	db chain.Database,
	_ int64,
	rauth chain.Auth,
	_ ids.ID,
) (*chain.Result, error)

func (*Authorize) Marshal

func (a *Authorize) Marshal(p *codec.Packer)

func (*Authorize) MaxUnits

func (*Authorize) MaxUnits(chain.Rules) uint64

func (*Authorize) StateKeys

func (a *Authorize) StateKeys(chain.Auth) [][]byte

func (*Authorize) ValidRange

func (*Authorize) ValidRange(chain.Rules) (int64, int64)

type Clear

type Clear struct {
	// To is the recipient of [Actor]'s funds
	To crypto.PublicKey `json:"to"`
}

func (*Clear) Execute

func (c *Clear) Execute(
	ctx context.Context,
	r chain.Rules,
	db chain.Database,
	_ int64,
	rauth chain.Auth,
	_ ids.ID,
) (*chain.Result, error)

func (*Clear) Marshal

func (c *Clear) Marshal(p *codec.Packer)

func (*Clear) MaxUnits

func (*Clear) MaxUnits(chain.Rules) uint64

func (*Clear) StateKeys

func (c *Clear) StateKeys(rauth chain.Auth) [][]byte

func (*Clear) ValidRange

func (*Clear) ValidRange(chain.Rules) (int64, int64)

type Index

type Index struct {
	// REQUIRED
	//
	// Schema of the content being indexed
	Schema ids.ID `json:"schema"`
	// Content is the indexed data that will be associated with the ID
	Content []byte `json:"content"`

	// OPTIONAL
	//
	// Royalty is the amount required to reference this object as a parent in
	// another [Index]
	//
	// If this value is > 0, the content will be registered to receive rewards
	// and the creator will need to lock up [Genesis.ContentStake]. To deregister an item
	// from receiving rewards and to receive their [Genesis.ContentStake] back, the creator must
	// issue an [UnindexTx].
	//
	// If this value is 0, the content will not be registered to receive rewards.
	Royalty uint64 `json:"royalty"`
	// Parent of the content being indexed (this may be nested)
	//
	// This can also be empty if there is no parent (first reference)
	Parent ids.ID `json:"parent"`
	// Searcher is the owner of [Parent]
	//
	// We require this in the transaction so that the owner can be prefetched
	// during execution.
	Searcher crypto.PublicKey `json:"searcher"`
	// Servicer is the recipient of the [Invoice] payment
	//
	// This is not enforced anywhere on-chain and is up to the transaction signer
	// to populate correctly. If not populate correctly, it is likely that the
	// service provider will simply stop serving the user.
	Servicer crypto.PublicKey `json:"servicer"`
	// Commission is the value to send to [Servicer] for their work in surfacing
	// the content for interaction
	//
	// This field is not standardized and enforced by a [Servicer] to provide
	// user-level flexibility. For example, a [Servicer] may choose to offer
	// a discount after performing so many interactions per month.
	Commission uint64 `json:"commission"`
}

func (*Index) ContentID

func (i *Index) ContentID() ids.ID

ContentID is the canonical identifier of the indexed data. We include the minimum amount of info required to describe the item.

func (*Index) Execute

func (i *Index) Execute(
	ctx context.Context,
	r chain.Rules,
	db chain.Database,
	_ int64,
	rauth chain.Auth,
	_ ids.ID,
) (*chain.Result, error)

func (*Index) Marshal

func (i *Index) Marshal(p *codec.Packer)

Marshal encodes all fields into the provided packer

func (*Index) MaxUnits

func (i *Index) MaxUnits(chain.Rules) uint64

func (*Index) StateKeys

func (i *Index) StateKeys(rauth chain.Auth) [][]byte

func (*Index) ValidRange

func (*Index) ValidRange(chain.Rules) (int64, int64)

type Modify

type Modify struct {
	// Content is the content to update
	Content ids.ID `json:"content"`

	// Royaly is the new value to apply to the content
	Royalty uint64 `json:"royalty"`
}

Modify will update the Royalty of any claimed content or claim unclaimed content

This allows content creators to update previously indexed info without unindexing im.

func (*Modify) Execute

func (m *Modify) Execute(
	ctx context.Context,
	r chain.Rules,
	db chain.Database,
	_ int64,
	rauth chain.Auth,
	_ ids.ID,
) (*chain.Result, error)

func (*Modify) Marshal

func (m *Modify) Marshal(p *codec.Packer)

func (*Modify) MaxUnits

func (*Modify) MaxUnits(chain.Rules) uint64

func (*Modify) StateKeys

func (m *Modify) StateKeys(chain.Auth) [][]byte

func (*Modify) ValidRange

func (*Modify) ValidRange(chain.Rules) (int64, int64)

type Transfer

type Transfer struct {
	// To is the recipient of the [Value].
	To crypto.PublicKey `json:"to"`

	// Amount are transferred to [To].
	Value uint64 `json:"value"`
}

func (*Transfer) Execute

func (t *Transfer) Execute(
	ctx context.Context,
	r chain.Rules,
	db chain.Database,
	_ int64,
	rauth chain.Auth,
	_ ids.ID,
) (*chain.Result, error)

func (*Transfer) Marshal

func (t *Transfer) Marshal(p *codec.Packer)

func (*Transfer) MaxUnits

func (*Transfer) MaxUnits(chain.Rules) uint64

func (*Transfer) StateKeys

func (t *Transfer) StateKeys(rauth chain.Auth) [][]byte

func (*Transfer) ValidRange

func (*Transfer) ValidRange(chain.Rules) (int64, int64)

type Unindex

type Unindex struct {
	// Content is the content to unindex
	//
	// This transaction will refund [Genesis.ContentStake] to the creator of the
	// content.
	Content ids.ID `json:"content"`
}

func (*Unindex) Execute

func (u *Unindex) Execute(
	ctx context.Context,
	r chain.Rules,
	db chain.Database,
	_ int64,
	rauth chain.Auth,
	_ ids.ID,
) (*chain.Result, error)

func (*Unindex) Marshal

func (u *Unindex) Marshal(p *codec.Packer)

func (*Unindex) MaxUnits

func (*Unindex) MaxUnits(chain.Rules) uint64

func (*Unindex) StateKeys

func (u *Unindex) StateKeys(rauth chain.Auth) [][]byte

func (*Unindex) ValidRange

func (*Unindex) ValidRange(chain.Rules) (int64, int64)

Jump to

Keyboard shortcuts

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