Options
All
  • Public
  • Public/Protected
  • All
Menu

@metaplex-foundation/amman

Index

Other

AccountDiff: Diff<Record<string, any>, Record<string, any>>[]
AmmanAccount: { pretty: any }

Type declaration

  • pretty:function
    • pretty(): Record<string, any>
AmmanAccountRendererMap: Map<any, AmmanRenderAccount>
AmmanConfig: { assetsFolder?: string; relay?: RelayConfig; storage?: StorageConfig; streamTransactionLogs?: boolean; validator?: ValidatorConfig }

Amman Config

property

validatorConfig Validator configuration

property

relayConfig Relay configuration

property

storageConfig Mock Storage configuration

property

streamTransactionLogs if true the solana logs command is spawned and its output piped through a prettifier, defaults to run except when in a CI environment

Type declaration

  • Optional assetsFolder?: string
  • Optional relay?: RelayConfig
  • Optional storage?: StorageConfig
  • Optional streamTransactionLogs?: boolean
  • Optional validator?: ValidatorConfig
AmmanMockStorageDriverOptions: { costPerByte?: BN | number; logDebug?: any; logInfo?: any; logTrace?: any }

Type declaration

AmmanRenderAccount: (account: any) => string

Type declaration

    • (account: any): string
    • Parameters

      • account: any

      Returns string

ConfirmedTransactionAsserts: { assertError: any; assertSuccess: any }

Type declaration

MaybeErrorWithCode: ErrorWithCode | null | undefined

Possibly {@link ErrorWithCode} or None.

RelayAccountState: { account: Record<string, any>; accountDiff?: AccountDiff; rendered?: string; renderedDiff?: Change[]; slot: number; timestamp: number }

Type declaration

  • account: Record<string, any>
  • Optional accountDiff?: AccountDiff
  • Optional rendered?: string
  • Optional renderedDiff?: Change[]
  • slot: number
  • timestamp: number
  • assertErrorMatches<Err>(t: Assert, err: MaybeErrorWithCode, opts?: { msgRx?: RegExp; txSignature?: string; type?: Err }): void
  • Asserts that the provided error is defined and matches the provided requirements.

    If {@link opts.type} is provided the error needs to be of that type. If {@link opts.msgRx} is provided the error message needs match to it.

    Type parameters

    • Err: Function

    Parameters

    • t: Assert
    • err: MaybeErrorWithCode

      error to verify

    • opts: { msgRx?: RegExp; txSignature?: string; type?: Err } = {}
      • Optional msgRx?: RegExp

        a {@link RegExp} that the error message is expected to match

      • Optional txSignature?: string
      • Optional type?: Err

        the type of the error to expect

    Returns void

  • assertTransactionError<Err>(t: Assert, details: Pick<ConfirmedTransactionDetails, "txSummary"> & { txSignature?: string }, errOrRx?: RegExp | Err, msgRx?: RegExp): void
  • Asserts that the provided ConfirmedTransactionDetails has an error that matches the provided requirements.

    Provide either an Error to {@link errOrRx} to verify the error type or a {@link RegExp} to only verify the error message. In order to verify both provide an Error to {@link errOrRx} and the {@link RegExp} via {@link msgRx}.

    Type parameters

    • Err: Function

    Parameters

    • t: Assert
    • details: Pick<ConfirmedTransactionDetails, "txSummary"> & { txSignature?: string }

      result of executing a transaction

    • Optional errOrRx: RegExp | Err

      the type of the error to expect or the {@link msgRx} to match

    • Optional msgRx: RegExp

      a {@link RegExp} that the error message is expected to match

    Returns void

  • Asserts that a transaction completed successfully and optionally checks for messages in the transaction logs.

    Parameters

    Returns void

  • identifySolanaAddress(maybeAddress: string): Address | null

asserts

Assert: { equal: any; fail: any; match: any; ok: any }

The minimum methods that the first argument passed to assert functions like assertConfirmedTransaction needs to have.

Type declaration

  • equal:function
    • equal(actual: any, expected: any, msg?: string): void
  • fail:function
    • fail(msg?: string): void
  • match:function
    • match(actual: string, expected: RegExp, msg?: string): void
  • ok:function
    • ok(value: any, msg?: string): void
  • assertConfirmedTransaction(t: Assert, tx: TransactionResponse, args?: { fee?: number }): void
  • assertError(t: Assert, err: Error, msgRxs: RegExp[]): void
  • Asserts that the provided error contains specific information as part of the error message or the attached error logs.

    To check for they error type instead use assertErrorMatches instead.

    Parameters

    • t: Assert
    • err: Error

      error to verify

    • msgRxs: RegExp[]

      list of {@link RegExp} which will be matched on the error message or err.logs.

    Returns void

  • assertTransactionSummary(t: Assert, summary: TransactionSummary, args?: { failed?: boolean; fee?: number; msgRxs?: RegExp[] }): void

diagnostics

AmmanAccountProvider: { byteSize: number | ((args: any) => void); fromAccountInfo: any }

The type that an account provider needs to implement so that amman can deserialize account data.

Type declaration

  • byteSize: number | ((args: any) => void)
  • fromAccountInfo:function
    • fromAccountInfo(accountInfo: AccountInfo<Buffer>, offset?: number): [AmmanAccount, number]

transactions

TransactionHandler: { publicKey: PublicKey; sendAndConfirmTransaction: any }

Interface to transaction handlers that can either be backed directly by a payer or can use a wallet.

property

publicKey of payer

property

sendAndConfirmTransaction sends and confirms a transaction

Type declaration

  • publicKey: PublicKey
  • sendAndConfirmTransaction:function
    • sendAndConfirmTransaction(transaction: Transaction, signers: Signer[], optionsOrLabel?: string | SendOptions, label?: string): Promise<ConfirmedTransactionDetails>
    • Sends and confirms the given transaction after signing it.

      Parameters

      • transaction: Transaction

        to send

      • signers: Signer[]

        with which the transaction should be signed

      • Optional optionsOrLabel: string | SendOptions

        either options used to send the transaction or the {@link label}

      • Optional label: string

        of the transaction in order to identify it in logs and the amman-explorer

      Returns Promise<ConfirmedTransactionDetails>

TransactionSummary: { blockTime: number; fee: number | undefined; logMessages: string[]; loggedError: MaybeErrorWithCode; slot: number; transactionError: TransactionError | null | undefined }

Derived from a {@link ConfirmedTransaction} this summary eases assertions and logging.

property

logMessages obtained from the {@link ConfirmedTransaction['meta']} property

property

fee charged for the transaction execution

property

slot same as {@link ConfirmedTransaction['slot']

property

transactionError obtained from the {@link ConfirmedTransaction['meta']} property

Type declaration

  • blockTime: number
  • fee: number | undefined
  • logMessages: string[]
  • loggedError: MaybeErrorWithCode
  • slot: number
  • transactionError: TransactionError | null | undefined
defaultConfirmOptions: ConfirmOptions = ...

Default options for sending and confirming a transaction

utils

LOCALHOST: "http://127.0.0.1:8899" = 'http://127.0.0.1:8899'

URL at which a locally running solana test validator listens on by default

  • tmpLedgerDir(testLabel?: string): string
  • Gets the path to a temporary directory in which to store the test validator ledger.

    Parameters

    • testLabel: string = 'amman-ledger'

      label used to name that directory

    Returns string

Generated using TypeDoc