Options
All
  • Public
  • Public/Protected
  • All
Menu

Module SolstoryAPI (start here)

This is the entry point for using the solstory API. You should import the SolstoryAPI as well as any types you need, then access individual modules with solstoryAPI.<module>.

Index

References

Re-exports SolstoryAppendItemOptions
Re-exports utils

Type aliases

SolstoryConfig: { cacheTimeout?: number; globalCdn?: string; includeNonValidatedWriters?: boolean }
param globalCdn

This is the global cdn, which allows for the connecting of NFTs to Metadata/Stories.

param cacheTimeout

How long to cache metadata for before doing a refresh.

param includeNonValidatedWriters

Get metadata/heads even for writers that haven't been validated by Solstory. Use this for testing.

Type declaration

  • Optional cacheTimeout?: number
  • Optional globalCdn?: string
  • Optional includeNonValidatedWriters?: boolean
SolstoryHead: { accessType: AccessType; authorized: boolean; currentHash: string; metadata: SolstoryMetadata; mintKey: web3.PublicKey; objId: Uint8Array; visibilityIndex: number; writerKey: web3.PublicKey }

Type declaration

  • accessType: AccessType
  • authorized: boolean

    Specifies that the NFT-Update-Owner (usually its creator) has approved of this program being added to the NFT

  • currentHash: string

    We store this as a hex here for interoperability with all the other places we use hex to store hashes, but it's stored as a 32 byte binary on the chain.

  • metadata: SolstoryMetadata

    There's many heads to a single metadata, this is the key back to that metadata

  • mintKey: web3.PublicKey
  • objId: Uint8Array

    This is the ID of the first item in the hashlist. It is also the most recent item. It is stored in a 32byte binary format, and then decompressed based on the location that the file is stored. This lets us fit 256 bits.

  • visibilityIndex: number

    Used by the NFT holder (usually the end user owning the NFT) to sort which writers get displayed in what order.

    -1 will override to NOT display something that is authorized, while >1 will override TO display something that may or may not be authorized. 0 will follow default behavior.

  • writerKey: web3.PublicKey
SolstoryItemContainer: { hash: string; next: { accessType: AccessType; cursor?: string; objId: Uint8Array }; objId?: string; verified: { item: SolstoryItemInner; itemHash: string; itemRaw: string; nextHash: string; timestamp: number }; verifiedSuccess?: boolean }

This is a wrapper on an item. It handles things like describing the location of the next item.

The JSON serialized version of this type is also the expected format of objects stored off chain, so if you wish to manually append an object,

Type declaration

  • hash: string
  • next: { accessType: AccessType; cursor?: string; objId: Uint8Array }
    • accessType: AccessType
    • Optional cursor?: string
    • objId: Uint8Array
  • Optional objId?: string

    This frequently does not exist on creation, only after upload, which means it is not a mandatory component when instiating a new item.

  • verified: { item: SolstoryItemInner; itemHash: string; itemRaw: string; nextHash: string; timestamp: number }

    The JSON of this section is what should be validated by the hash.

    • item: SolstoryItemInner
    • itemHash: string
    • itemRaw: string

      JSON doesn't naturally preserve order, so it's important we pick one stringified representation and then stick with it. Since there's a single source of truth this just means we need to save the original JSON.stringify when the item is created.

    • nextHash: string
    • timestamp: number
  • Optional verifiedSuccess?: boolean

    Whether the api was able to verify that the data hadn't been tampered with. This being set to false suggests tampering.

SolstoryItemInner: { data: any; display?: { description?: string; helpText?: string; img?: string; label?: string }; ref?: string; type: SolstoryItemType }

Inner item, this is the actual data contained within a solstory item.

Type declaration

  • data: any
  • Optional display?: { description?: string; helpText?: string; img?: string; label?: string }

    Instructions for how to display the item in a client.

    • Optional description?: string
    • Optional helpText?: string
    • Optional img?: string
    • Optional label?: string
  • Optional ref?: string

    Reference to a previous solstory item, by objId. Useful for things like corrections.

  • type: SolstoryItemType
SolstoryMetadata: { apiVersion: number; baseUrl: string; cdn: string; description: string; hasExtendedMetadata: boolean; label: string; logo: string; metadata: any; systemValidated?: boolean; url: string; visible: boolean; writerKey: web3.PublicKey }

Type declaration

  • apiVersion: number
  • baseUrl: string

    Base url, used for AccessType.URL, otherwise is "".

  • cdn: string

    CDN for this writer

  • description: string
  • hasExtendedMetadata: boolean
  • label: string

    Title used when displaying this writer.

  • logo: string

    URL for the logo to display with this writer.

  • metadata: any

    Additional metadata, JSON format.

  • Optional systemValidated?: boolean

    Whether this writer has been validated by solstory. Meant for fraud and spam protection.

  • url: string

    URL for more information about this writer. Homepage link, basically.

  • visible: boolean

    Whether this writer is meant to be visible. Set to false for internal programs.

  • writerKey: web3.PublicKey
SolstoryStory: { headHash: string; items: SolstoryItemContainer[]; loading?: boolean; metadata: SolstoryMetadata; mintKey: web3.PublicKey; next: { accessType: AccessType; cdnCursor?: any; objId: Uint8Array } }

Type declaration

  • headHash: string
  • items: SolstoryItemContainer[]
  • Optional loading?: boolean
  • metadata: SolstoryMetadata
  • mintKey: web3.PublicKey
  • next: { accessType: AccessType; cdnCursor?: any; objId: Uint8Array }
    • accessType: AccessType
    • Optional cdnCursor?: any
    • objId: Uint8Array
UpdateHeadData: { currentHash: Uint8Array; dataHash: Uint8Array; newHash: Uint8Array; objId: Uint8Array; timestamp: anchor.BN }

We have an internal object representation, but then we also need to stick these onto string only systems, like ardrive or a sql database.

Type declaration

  • currentHash: Uint8Array
  • dataHash: Uint8Array
  • newHash: Uint8Array
  • objId: Uint8Array
  • timestamp: anchor.BN

Generated using TypeDoc