Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @tezos-dappetizer/decorators

Index

Type aliases

ContractFilterOptions: { anyOfAddresses?: undefined; name: string } | { anyOfAddresses: NonEmptyReadonlyArray<string>; name?: undefined }

Options for matching the contract to index. Used by contractFilter decorator.

property

name Matches contract by its ContractConfig.name which comes from IndexingDappetizerConfig.contracts.

property

anyOfAddresses Matches contract if has one of these addresses. It must be a non-empty array.

IndexBigMapDiffOptions: IndexBigMapOptions
IndexBigMapOptions: { name?: undefined; path: readonly string[] } | { name: string; path?: undefined }

Options for matching the big map to index its diffs.

property

path Matches big map by its full BigMapInfo.path based on Michelson annots. This is more exact than name.

property

name Matches big map by its BigMapInfo.name based on Michelson annots.

IndexBigMapUpdateOptions: IndexBigMapOptions

Functions

  • The decorator for a contract indexer class to select a contract for indexing based on specified filter options.

    example

    Demonstrates the usage:

    import { contractFilter } from '@tezos-dappetizer/decorators';

    @contractFilter({ name: 'TezosDomains' })
    class YourContractIndexerByName {
    ...
    }

    @contractFilter({ anyOfAddresses: ['KT191reDVKrLxU9rjTSxg53wRqj6zh8pnHgr'] })
    class YourContractIndexerByAddress {
    ...
    }
    remark

    This is based on ContractIndexer.shouldIndex.

    Parameters

    Returns ClassDecorator

  • createContractIndexerFromDecorators<TDbContext, TContextData, TContractData>(decoratedIndexer: object): ContractIndexer<TDbContext, TContextData, TContractData>
  • The decorator for a method of a contract indexer to index Diffs of the specified big map.

    example

    Demonstrates the method signature:

    import { DbContext } from '@tezos-dappetizer/database';
    import { indexBigMapDiff } from '@tezos-dappetizer/decorators';
    import { BigMapDiff, BigMapDiffIndexingContext } from '@tezos-dappetizer/indexer';

    class YourContractIndexer {
    @indexBigMapDiff({ name: 'ledger' })
    indexLedgerDiff(
    bigMapDiff: BigMapDiff,
    dbContext: DbContext,
    indexingContext: BigMapDiffIndexingContext<TData, TContractData>,
    ): void | PromiseLike<void> {
    // Your code to index the storage change.
    }
    }
    remark

    This is based on ContractIndexer.indexBigMapDiff.

    Parameters

    Returns MethodDecorator

  • The decorator for a method of a contract indexer to index updates of the specified big map.

    example

    Demonstrates the method signature:

    import { DbContext } from '@tezos-dappetizer/database';
    import { indexBigMapUpdate } from '@tezos-dappetizer/decorators';
    import { BigMapUpdateIndexingContext } from '@tezos-dappetizer/indexer';

    class YourContractIndexer {
    @indexBigMapUpdate({ name: 'ledger' })
    indexLedgerUpdate(
    key: StronglyTypedBigMapKey,
    value: StronglyTypedBigMapValue,
    dbContext: DbContext,
    indexingContext: BigMapUpdateIndexingContext<TData, TContractData>,
    ): void | PromiseLike<void> {
    // Your code to index the storage change.
    }
    }
    remark

    This is based on ContractIndexer.indexBigMapUpdate.

    Parameters

    Returns MethodDecorator

  • indexEntrypoint(entrypoint: string): MethodDecorator
  • The decorator for a method of a contract indexer to index its transactions with the specified entrypoint.

    example

    Demonstrates the method signature:

    import { DbContext } from '@tezos-dappetizer/database';
    import { indexEntrypoint } from '@tezos-dappetizer/decorators';
    import { TransactionIndexingContext } from '@tezos-dappetizer/indexer';

    class YourContractIndexer {
    @indexEntrypoint('foo_entrypoint')
    indexFoo(
    parameter: FooStronglyTypedParameter,
    dbContext: DbContext,
    indexingContext: TransactionIndexingContext<TData, TContractData>,
    ): void | PromiseLike<void> {
    // Your code to index the transaction.
    }
    }
    remark

    If you want to index all entrypoints with a single method, then see indexTransaction decorator.

    remark

    This is based on ContractIndexer.indexTransaction.

    Parameters

    • entrypoint: string

    Returns MethodDecorator

  • indexOrigination(): MethodDecorator
  • The decorator for a method of a contract indexer to index its origination operation.

    example

    Demonstrates the method signature:

    import { DbContext } from '@tezos-dappetizer/database';
    import { indexOrigination } from '@tezos-dappetizer/decorators';
    import { OriginationIndexingContext } from '@tezos-dappetizer/indexer';

    class YourContractIndexer {
    @indexOrigination()
    indexMyContractOrigination(
    initialStorage: StronglyTypedInitialStorage,
    dbContext: DbContext,
    indexingContext: OriginationIndexingContext<TContextData, TContractData>,
    ): void | Promise<void> {
    // Your code to index the transaction.
    }
    }
    remark

    This is based on ContractIndexer.indexOrigination.

    Returns MethodDecorator

  • indexStorageChange(): MethodDecorator
  • The decorator for a method of a contract indexer to index changes of its storage.

    example

    Demonstrates the method signature:

    import { DbContext } from '@tezos-dappetizer/database';
    import { indexStorageChange } from '@tezos-dappetizer/decorators';
    import { StorageChangeIndexingContext } from '@tezos-dappetizer/indexer';

    class YourContractIndexer {
    @indexStorageChange()
    indexMyContractStorageChange(
    storage: StronglyTypedChangedStorage,
    dbContext: DbContext,
    indexingContext: StorageChangeIndexingContext<TData, TContractData>,
    ): void | PromiseLike<void> {
    // Your code to index the storage change.
    }
    }
    remark

    This is based on ContractIndexer.indexStorageChange.

    Returns MethodDecorator

  • indexTransaction(): MethodDecorator
  • The decorator for a method of a contract indexer to index all its transactions regardless of entrypoint.

    example

    Demonstrates the method signature:

    import { DbContext } from '@tezos-dappetizer/database';
    import { indexTransaction } from '@tezos-dappetizer/decorators';
    import { TransactionIndexingContext } from '@tezos-dappetizer/indexer';

    class YourContractIndexer {
    @indexTransaction()
    indexMyContractTransaction(
    // You may want a union with narrowing on the entrypoint.
    parameter: { entrypoint: string; value: unknown },
    dbContext: DbContext,
    indexingContext: TransactionIndexingContext<TData, TContractData>,
    ): void | PromiseLike<void> {
    // Your code to index the transaction.
    }
    }
    remark

    If you want a method to index only a specific entrypoint, then see indexEntrypoint decorator.

    remark

    This is based on ContractIndexer.indexTransaction.

    Returns MethodDecorator

  • shouldIndex(): MethodDecorator
  • The decorator for a method of a contract indexer to dynamically select a contract for indexing.

    example

    Demonstrates the method signature:

    import { shouldIndex } from '@tezos-dappetizer/decorators';
    import { LazyContract } from '@tezos-dappetizer/indexer';

    class YourContractIndexer {
    @shouldIndex()
    shouldIndexMyContracts(
    lazyContract: LazyContract,
    ): TContractData | false | PromiseLike<TContractData | false> {
    // Your code to return false or create your context data.
    return true; // Just return true, if you do not need context data.
    }
    }
    remark

    This is based on ContractIndexer.shouldIndex.

    Returns MethodDecorator

Generated using TypeDoc