nftokens

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package nftokens provides functions and SQL framents for working with the "nf_tokens" table, which stores fat.NFToken with owner, creation id, and metadata.

Index

Constants

View Source
const CreateTable = `` /* 866-byte string literal not displayed */

CreateTable is a SQL string that creates the "nf_tokens" table.

The "nf_tokens" table has foreign key references to the "entries" and "addresses" tables, which must exist first.

View Source
const CreateTableTransactions = `` /* 782-byte string literal not displayed */

CreateTableTransactions is a SQL string that creates the "nf_token_transactions" table.

The "nf_token_transactions" table has a foreign key reference to the "address_transactions" and "nf_tokens" tables, which must exist first.

Variables

This section is empty.

Functions

func Insert

func Insert(conn *sqlite.Conn, nfID fat1.NFTokenID, adrID, entryID int64) (error, error)

Insert a new NFToken with "owner_id" set to the "addresses" foreign key adrID and the "creation_entry_id" set to the "entries" foreign key entryID.

func InsertTransactionRelation

func InsertTransactionRelation(conn *sqlite.Conn,
	nfID fat1.NFTokenID, adrTxID int64) error

InsertTransactionRelation inserts a row into "nf_token_transactions" relating the given adrTxID, a foreign row id from the "address_transactions" table, with the given nfID.

func SelectByOwner

func SelectByOwner(conn *sqlite.Conn, adr *factom.FAAddress,
	page, limit uint, order string) (fat1.NFTokens, error)

SelectByOwner returns the fat1.NFTokens owned by the given adr for the given pagination range.

Pages start at 1.

func SelectData

func SelectData(conn *sqlite.Conn, nfID fat1.NFTokenID) (
	factom.FAAddress, factom.Bytes32, []byte, error)

SelectData returns the owner address, the creation entry hash, and the NFToken metadata for the given nfID

If the nfID doesn't exist, all zero values are returned. Namely, check IsZero on the returned creation entry hash.

func SelectDataAll

func SelectDataAll(conn *sqlite.Conn, order string, page, limit uint) (
	[]fat1.NFTokenID, []factom.FAAddress, []factom.Bytes32, [][]byte, error)

SelectDataAll returns the nfIDs, owner addresses, creation entry hashes, and the NFToken metadata for the given pagination range of NFTokens.

Pages start at 1.

func SelectOwnerID

func SelectOwnerID(conn *sqlite.Conn, nfID fat1.NFTokenID) (int64, error)

SelectOwnerID returns the "owner_id" for the given nfID.

If the nfID does not yet exist, (-1, nil) is returned.

func SetMetadata

func SetMetadata(conn *sqlite.Conn, nfID fat1.NFTokenID, metadata json.RawMessage) error

SetMetadata updates the "metadata" to metadata for a given nfID.

If the nfID does not exist, this will panic.

func SetOwner

func SetOwner(conn *sqlite.Conn, nfID fat1.NFTokenID, adrID int64) error

SetOwner updates the "owner_id" of the given nfID to the given adrID.

If the given adrID does not exist, a foreign key constraint error will be returned. If the nfID does not exist, this will panic.

TODO: consider that the use of panic is inconsistent here. This function should never be called on an adrID that does not exist. Should it also panic on that constraint error too? Both reflect program integrity issues.

Types

This section is empty.

Jump to

Keyboard shortcuts

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