Documentation
¶
Overview ¶
Package nftoken provides functions and SQL framents for working with the "nftoken" table, which stores fat.NFToken with owner, creation id, and metadata.
Index ¶
- Constants
- func Insert(conn *sqlite.Conn, nfID fat1.NFTokenID, adrID, entryID int64) (error, error)
- func InsertTxRelation(conn *sqlite.Conn, nfID fat1.NFTokenID, adrEntryID int64) error
- func SelectByOwner(conn *sqlite.Conn, adr *factom.FAAddress, page, limit uint, order string) (fat1.NFTokens, error)
- func SelectData(conn *sqlite.Conn, nfID fat1.NFTokenID) (factom.FAAddress, factom.Bytes32, []byte, error)
- func SelectDataAll(conn *sqlite.Conn, order string, page, limit uint) ([]fat1.NFTokenID, []factom.FAAddress, []factom.Bytes32, [][]byte, error)
- func SelectOwnerID(conn *sqlite.Conn, nfID fat1.NFTokenID) (int64, error)
- func SetMetadata(conn *sqlite.Conn, nfID fat1.NFTokenID, metadata json.RawMessage) error
- func SetOwner(conn *sqlite.Conn, nfID fat1.NFTokenID, adrID int64) error
Constants ¶
const CreateTable = `` /* 836-byte string literal not displayed */
CreateTable is a SQL string that creates the "nftoken" table.
The "nftoken" table has foreign key references to the "entry" and "address" tables, which must exist first.
const CreateTableTxRelation = `` /* 708-byte string literal not displayed */
CreateTableTxRelation is a SQL string that creates the "nftoken_tx" table.
The "nftoken_tx" table has a foreign key reference to the "address_tx" and "nftoken" tables, which must exist first.
Variables ¶
This section is empty.
Functions ¶
func Insert ¶
Insert a new NFToken with "owner_id" set to the "address" foreign key adrID and the "creation_entry_id" set to the "entry" foreign key entryID.
func InsertTxRelation ¶
InsertTxRelation inserts a row into "nftoken_entry" relating the given adrTxID, a foreign row id from the "address_tx" 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 ¶
SelectOwnerID returns the "owner_id" for the given nfID.
If the nfID does not yet exist, (-1, nil) is returned.
func SetMetadata ¶
SetMetadata updates the "metadata" to metadata for a given nfID.
If the nfID does not exist, this will panic.
func SetOwner ¶
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.