Options
All
  • Public
  • Public/Protected
  • All
Menu

Creates an Amman instance which is used to interact with address labels and other amman features. By default it connects the socket client to the running amman validator. This allows it to update the amman-explorer with recent transactions and addresses.

NOTE: that Amman should only be instantiated once during the life time of your program, tests, etc.

Example

export const amman = Amman.instance({
knownLabels: { [PROGRAM_ADDRESS]: 'My Program' },
log: console.log,
})

Hierarchy

  • Amman

Index

Other

ammanClient: AmmanClient
errorResolver?: ErrorResolver
genKeypair: GenKeypair = ...

Generates a keypair and returns its public key and the keypair itself as a Tuple.

returns
genLabeledKeypair: GenLabeledKeypair = ...

Generates a keypair, labels it and returns its public key and the keypair itself as a Tuple.

param label

the key will be added to existing labels

returns
  • get existingInstance(): undefined | Amman
  • destroy(): void
  • More force full version of disconnect.

    Returns void

  • disconnect(): void
  • Disconnects the amman relay client and allows the app to shut down. Only needed if you set { autoUnref: false } for the amman client opts.

    Returns void

  • payerTransactionHandler(connection: Connection, payer: Keypair, errorResolver?: ErrorResolver): PayerTransactionHandler
  • Provides a TransactionHandler which uses the {@link payer} to sign transactions.

    catetory

    transactions

    Parameters

    • connection: Connection
    • payer: Keypair
    • Optional errorResolver: ErrorResolver

    Returns PayerTransactionHandler

  • transactionChecker(connection: Connection, errorResolver?: ErrorResolver): TransactionChecker
  • If you cannot use the payerTransactionHandler then you can use this to verify the outcome of your transactions.

    catetory

    transactions

    catetory

    asserts

    Parameters

    • connection: Connection
    • Optional errorResolver: ErrorResolver

    Returns TransactionChecker

  • instance(args?: { ammanClient?: AmmanClient; ammanClientOpts?: AmmanClientOpts; connectClient?: boolean; errorResolver?: ErrorResolver; knownLabels?: Record<string, string>; transactionLabelMapper?: TransactionLabelMapper; log?: any }): Amman
  • Creates an instance of Amman.

    Parameters

    • args: { ammanClient?: AmmanClient; ammanClientOpts?: AmmanClientOpts; connectClient?: boolean; errorResolver?: ErrorResolver; knownLabels?: Record<string, string>; transactionLabelMapper?: TransactionLabelMapper; log?: any } = {}
      • Optional ammanClient?: AmmanClient

        allows to override the client used to connect to the amman validator

      • Optional ammanClientOpts?: AmmanClientOpts

        allows to specify options for the amman relay client instead

      • Optional connectClient?: boolean

        used to determine if to connect an amman client if no {@link args.ammanClient} is provided; defaults to connect unless running in a CI environment

      • Optional errorResolver?: ErrorResolver

        used to resolve a known errors from the program logs, see https://github.com/metaplex-foundation/cusper

      • Optional knownLabels?: Record<string, string>

        label keys that do not change, i.e. { [PROGRM_ID]: 'My Program' }

      • Optional transactionLabelMapper?: TransactionLabelMapper

        function to replace key strings in a label to enhance it, i.e. with an icon

      • log?:function
        • log(msg: string): void
        • used to log labels that are added to {@link Amman.addresses} and information about other events

          Parameters

          • msg: string

          Returns void

    Returns Amman

storage

  • Provides a AmmanMockStorageDriver which stores uploaded data on the filesystem inside a tmp directory. The {@link MockStorageServer} initialized with the same {@link storageId} serves the files from there.

    Parameters

    Returns MetaplexPlugin

utils

  • airdrop(connection: Connection, publicKey: PublicKey, sol?: number): Promise<{ signature: string; signatureResult: RpcResponseAndContext<SignatureResult> }>
  • Drops the specified amount of tokens to the provided public key.

    Parameters

    • connection: Connection

      to solana JSON RPC node

    • publicKey: PublicKey

      to drop sols to

    • sol: number = 1

      amount of sols to drop

    Returns Promise<{ signature: string; signatureResult: RpcResponseAndContext<SignatureResult> }>

Generated using TypeDoc